* finish task #2494.
This commit is contained in:
+8
-15
@@ -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);
|
||||
|
||||
@@ -115,7 +115,7 @@ js::set('refresh', $lang->refresh);
|
||||
<span class='pri-text'></span> <span class='caret'></span>
|
||||
</button>
|
||||
<ul class='dropdown-menu pull-right'></ul>
|
||||
<?php echo html::select('pri', (array)$lang->bug->priList, $pri, "class='hide'");?>
|
||||
<?php echo html::select('pri', $lang->bug->priList, '', "class='hide'");?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ if(!isset($error))
|
||||
\$config->db->prefix = '$dbPrefix';
|
||||
\$config->webRoot = getWebRoot();
|
||||
\$config->default->lang = '$defaultLang';
|
||||
\$config->mysqldump = '$mysqldump';
|
||||
EOT;
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user