From fb65e3660bb975dcd9a3478ce2eb55b3836c3ed7 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Mon, 7 Mar 2016 10:06:20 +0800 Subject: [PATCH] * finish task #2494. --- bin/php/backup.php | 23 ++++++------------ module/bug/view/create.html.php | 2 +- module/install/control.php | 1 - module/install/model.php | 39 ------------------------------ module/install/view/step3.html.php | 1 - 5 files changed, 9 insertions(+), 57 deletions(-) diff --git a/bin/php/backup.php b/bin/php/backup.php index 6901860cde..97f7d12e81 100755 --- a/bin/php/backup.php +++ b/bin/php/backup.php @@ -6,19 +6,11 @@ error_reporting(E_ALL ^ E_NOTICE); $pmsRoot = dirname(dirname(dirname(__FILE__))); $myConfig = $pmsRoot . '/config/config.php'; $zipClass = $pmsRoot . '/lib/pclzip/pclzip.class.php'; +$zdbClass = $pmsRoot . '/lib/zdb/zdb.class.php'; include $myConfig; include $zipClass; - -/* Judge mysqldump cmd setted or not. */ -if(empty($config->mysqldump)) -{ - echo "Please set the mysqldump path in $myConfig:\n"; - echo "Just like: \n"; - echo '$config->mysqldump = \'/usr/bin/mysqldump\'; for linux' . "\n"; - echo '$config->mysqldump = \'D:\xampp\mysql\bin\mysqldump.exe\'; for windows' . "\n"; - exit; -} +include $zdbClass; /* Init the backupRoot and dest directory. */ $backupRoot = $pmsRoot . "/backup"; @@ -29,12 +21,13 @@ if(!file_exists($destDir)) mkdir($destDir, 0777); /* Backup database. */ $dbRawFile = "db." . date('Ymd') . ".sql"; -$password = $config->db->password ? "-p{$config->db->password}" : ' '; -$command = "\"{$config->mysqldump}\" -u{$config->db->user} $password -P {$config->db->port} {$config->db->name} > {$dbRawFile}"; - +$dsn = "mysql:host={$config->db->host}; port={$config->db->port}; dbname={$config->db->name}"; +$dbh = new PDO($dsn, $config->db->user, $config->db->password, array(PDO::ATTR_PERSISTENT => $config->db->persistant)); +$dbh->exec("SET NAMES {$config->db->encoding}"); echo "Backuping database,"; -system($command, $return); -if($return == 0) +$zdb = new zdb(); +$return = $zdb->dump($dbRawFile); +if($return->result) { $dbZipFile = $destDir . "/" . str_replace("sql", "zip", $dbRawFile); $archive = new pclzip($dbZipFile); diff --git a/module/bug/view/create.html.php b/module/bug/view/create.html.php index 790853dcfc..6cb3b3d5c1 100644 --- a/module/bug/view/create.html.php +++ b/module/bug/view/create.html.php @@ -115,7 +115,7 @@ js::set('refresh', $lang->refresh);   - bug->priList, $pri, "class='hide'");?> + bug->priList, '', "class='hide'");?> diff --git a/module/install/control.php b/module/install/control.php index b59f182c89..b657030f22 100644 --- a/module/install/control.php +++ b/module/install/control.php @@ -110,7 +110,6 @@ class install extends control $this->view->lang = $this->lang; $this->view->config = $this->config; $this->view->title = $this->lang->install->saveConfig; - $this->view->mysqldump = $this->install->getMySQLDump(); $this->display(); } else diff --git a/module/install/model.php b/module/install/model.php index 4a446294dd..6fc6132f93 100644 --- a/module/install/model.php +++ b/module/install/model.php @@ -445,43 +445,4 @@ class installModel extends model $this->dao->replace(TABLE_CONFIG)->data($config)->exec(); return true; } - - /** - * Get the mysqldump binary. - * - * @access public - * @return string - */ - public function getMySQLDump() - { - $mysqldump = ''; - - if(strpos(__FILE__, '/opt/lampp') !== false) // linux. - { - $mysqldump = '/opt/lampp/bin/mysqldump'; - } - elseif(strpos(__FILE__, '\xampp\zentao') !== false) // windows. - { - $mysqldump = substr(__FILE__, 0, 2) . '\xampp\mysql\bin\mysqldump.exe'; - } - else - { - if(strpos(PHP_OS, 'WIN') !== false) - { - $mysql = @`wmic process where name='mysqld.exe' get executablepath`; - if(strpos($mysql, 'mysqld.exe') !== false) - { - $mysql = explode("\n", $mysql); - if(isset($mysql[1])) $mysqldump = trim(str_replace('mysqld.exe', 'mysqldump.exe', $mysql[1])); - } - } - else - { - $mysqldump = trim(@`which mysqldump`); - } - } - - if(file_exists($mysqldump)) return $mysqldump; - return ''; - } } diff --git a/module/install/view/step3.html.php b/module/install/view/step3.html.php index ec06637c26..82b3291c92 100644 --- a/module/install/view/step3.html.php +++ b/module/install/view/step3.html.php @@ -26,7 +26,6 @@ if(!isset($error)) \$config->db->prefix = '$dbPrefix'; \$config->webRoot = getWebRoot(); \$config->default->lang = '$defaultLang'; -\$config->mysqldump = '$mysqldump'; EOT; } ?>