Index: branches/RC/core/units/admin/admin_tag_processor.php =================================================================== diff -u -r10721 -r10739 --- branches/RC/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 10721) +++ branches/RC/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 10739) @@ -916,7 +916,7 @@ if( getArrayValue($params, 'as_preg') ) $ret = preg_quote($ret, '/'); return $ret; } - + /** * Returns list of all backup file dates formatted * in passed block @@ -925,41 +925,44 @@ * @return string * @access public */ - function PrintBackupDates($params) + function PrintBackupDates($params) { - $datearray=$this->getDirList($this->Application->ConfigValue('Backup_Path')); + $datearray = $this->getDirList($this->Application->ConfigValue('Backup_Path')); $ret = ''; foreach($datearray as $key => $value) { - $params['backuptimestamp'] = $value; - $params['backuptime'] = date('F j, Y, g:i a', $value); + $params['backuptimestamp'] = $value['filedate']; + $params['backuptime'] = date('F j, Y, g:i a', $value['filedate']); + $params['backupsize'] = round($value['filesize']/1024/1024, 2); // MBytes $ret .= $this->Application->ParseBlock($params); - } + } return $ret; } - + function getDirList ($dirName) { - $filedates = array(); + $fileinfo = array(); $d = dir($dirName); - + while($entry = $d->read()) { if ($entry != "." && $entry != "..") { if (!is_dir($dirName."/".$entry) && eregi("dump",$entry)) { - $filedate[]=$this->chopchop($entry); + $fileinfo[]= Array('filedate' => $this->chopchop($entry), + 'filesize' => filesize($dirName. '/'. $entry) + ); } } } $d->close(); - rsort($filedate); - - return $filedate; - + rsort($fileinfo); + + return $fileinfo; + } - + function chopchop ($filename) { $p = pathinfo($filename); @@ -968,7 +971,7 @@ $filename= ereg_replace("dump","",$filename); $filename= ereg_replace($ext,"",$filename); return $filename; - } - + } + } ?> \ No newline at end of file Index: branches/RC/core/admin_templates/tools/backup3.tpl =================================================================== diff -u -r10716 -r10739 --- branches/RC/core/admin_templates/tools/backup3.tpl (.../backup3.tpl) (revision 10716) +++ branches/RC/core/admin_templates/tools/backup3.tpl (.../backup3.tpl) (revision 10739) @@ -62,9 +62,8 @@
- - - + + M Index: branches/RC/core/units/admin/admin_events_handler.php =================================================================== diff -u -r10721 -r10739 --- branches/RC/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 10721) +++ branches/RC/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 10739) @@ -519,16 +519,16 @@ $event->status = erSTOP; return ; } - - + + /** * Backup all data * * @param kEvent $event */ function OnBackup(&$event) { - + $a_tables = $this->Conn->GetCol('SHOW TABLES'); // array_keys($tables); $TableNames = Array(); for($x=0;$x"; print_r($TableNames); echo ""; // exit; - + $backupProgress = Array ( 'table_num' => 0, 'table_names' => $TableNames, @@ -552,30 +552,30 @@ ); $this->Application->RemoveVar('adm.backupcomplete_filename'); $this->Application->RemoveVar('adm.backupcomplete_filesize'); - + $out = array(); - + for($x=0;$xGetTableCreate($TableNames[$x]); } } - + $fp = fopen($backupProgress['file_name'], 'a'); - + $sql = "SELECT Name, Version FROM ".TABLE_PREFIX."Modules"; $r = $this->Conn->Query($sql); foreach ($r AS $a_module) { $version = $a_module['Version']; fwrite($fp, "# ".$a_module['Name']." Version: $version;\n"); } fwrite($fp, "#------------------------------------------\n\n"); - + fwrite($fp,implode("\n",$out)); fwrite($fp,"\n"); - + fclose($fp); - + $this->Application->StoreVar('adm.backup_status', serialize($backupProgress)); $event->redirect = 'tools/backup2'; } @@ -607,7 +607,7 @@ { $event->redirect = 'tools/backup1'; } - + /** * Stops Restore & redirect to Restore template * @@ -617,19 +617,19 @@ { $event->redirect = 'tools/restore1'; } - + function performBackup() { $backupProgress = unserialize($this->Application->RecallVar('adm.backup_status')); // echo "
"; print_r($backupProgress); echo "
"; // exit; $CurrentTable = $backupProgress['table_names'][$backupProgress['table_num']]; - + // get records $a_records = $this->insert_data($CurrentTable,$backupProgress['record_count'],50,""); // echo "
"; print_r($a_records); echo "
"; // exit; - + if ($a_records['num'] < 50) { $backupProgress['table_num']++; if ($backupProgress['table_names'][$backupProgress['table_num']] == TABLE_PREFIX.'Cache') { @@ -639,30 +639,30 @@ } else { $backupProgress['record_count']+=50; } - + if ($a_records['sql']) { $fp = fopen($backupProgress['file_name'], 'a'); fwrite($fp, $a_records['sql']); fclose($fp); - } - $percent = ($backupProgress['table_num'] / $backupProgress['table_count']) * 100; + } + $percent = ($backupProgress['table_num'] / $backupProgress['table_count']) * 100; if ($percent >= 100) { $percent = 100; $this->Application->StoreVar('adm.backupcomplete_filename', $backupProgress['file_name']); - $this->Application->StoreVar('adm.backupcomplete_filesize', filesize($backupProgress['file_name'])); + $this->Application->StoreVar('adm.backupcomplete_filesize', round(filesize($backupProgress['file_name'])/1024/1024, 2)); // Mbytes } else { $this->Application->StoreVar('adm.backup_status', serialize($backupProgress)); - } - + } + return round($percent); - + } - + //extracts the rows of data from tables using limits function insert_data($table, $start, $limit, $mywhere) { // global $out; - + if ($mywhere !="") { $whereclause= " WHERE ".$mywhere." "; @@ -671,7 +671,7 @@ { $whereclause = ""; } - + $a_data = $this->Conn->Query("SELECT * from $table $whereclause LIMIT $start, $limit"); // echo "SELECT * from $table $whereclause LIMIT $start, $limit"; // echo "
"; print_r($a_records); echo "
"; @@ -703,20 +703,20 @@ $sql=ereg_replace("\r","\\r", $sql); $temp .= $sql."\n"; } - + if(strlen(TABLE_PREFIX)) { $temp = str_replace("INSERT INTO ".TABLE_PREFIX, "INSERT INTO ", $temp); } - + return Array( 'num' => count($a_data), 'sql' => $temp, ); } - - - + + + function GetTableCreate($table, $crlf="\n") { $schema_create = 'DROP TABLE IF EXISTS ' . $table . ';' . $crlf; @@ -735,7 +735,7 @@ $pos = $pos2; $tmpres["Create Table"] = str_replace(",", ",\n ", $tmpres["Create Table"]); } - + $tmpres["Create Table"] = substr($tmpres["Create Table"], 0, 13) . (($use_backquotes) ? $tmpres["Table"] : $tmpres["Table"]) . substr($tmpres["Create Table"], $pos); @@ -772,7 +772,7 @@ $schema_create .= "\n# --------------------------------------------------------\n"; return $schema_create; } - + /** * Deletes one backup file * @@ -782,12 +782,12 @@ { @unlink($this->get_backup_file()); } - + function get_backup_file() { return $this->Application->ConfigValue('Backup_Path').'/dump'.$this->Application->GetVar('backupdate').'.txt'; } - + /** * Starts restore process * @@ -796,7 +796,7 @@ function OnRestore(&$event) { $file = $this->get_backup_file(); - + $restoreProgress = Array ( 'file_pos' => 0, 'file_name' => $file, @@ -806,7 +806,7 @@ $this->Application->StoreVar('adm.restore_status', serialize($restoreProgress)); $event->redirect = 'tools/restore3'; } - + function OnRestoreProgress(&$event) { $done_percent = $this->performRestore(); @@ -815,7 +815,7 @@ $event->redirect = 'tools/restore4'; return ; } - + if ($done_percent < 0) { $this->Application->StoreVar('adm.restore_error', 'File read error'); $event->redirect = 'tools/restore4'; return ; @@ -830,9 +830,9 @@ echo $done_percent; $event->status = erSTOP; - + } - + function replaceRestoredFiles() { // gather restored table names @@ -849,27 +849,27 @@ $this->Conn->Query('DROP TABLE '.$table); } } - + } - + function performRestore() { $restoreProgress = unserialize($this->Application->RecallVar('adm.restore_status')); $filename = $restoreProgress['file_name']; $FileOffset = $restoreProgress['file_pos']; $MaxLines = 200; $size = filesize($filename); - + if($FileOffset > $size) { return -2; - } - + } + $fp = fopen($filename,"r"); if(!$fp) { return -1; } - - + + if($FileOffset>0) { fseek($fp,$FileOffset); @@ -895,14 +895,14 @@ { $error = $this->runSchemaText($sql); if ($error != '') { - - $this->Application->StoreVar('adm.restore_error', $error); + + $this->Application->StoreVar('adm.restore_error', $error); return -3; } } fseek($fp,$FileOffset); } - + $LinesRead = 0; $sql = ""; $AllSql = array(); @@ -924,25 +924,25 @@ $FileOffset = $size; } fclose($fp); - + if(count($AllSql)>0) { $error = $this->runSQLText($AllSql); if ($error != '') { - - $this->Application->StoreVar('adm.restore_error', $error); + + $this->Application->StoreVar('adm.restore_error', $error); return -3; } - + } $restoreProgress['file_pos'] = $FileOffset; $this->Application->StoreVar('adm.restore_status', serialize($restoreProgress)); - + return round($FileOffset/$size * 100); // $this->Application->StoreVar('adm.restore_error', 'lalalal'); // $event->redirect = 'tools/restore4'; } - - + + function runSchemaText($sql) { $table_prefix = 'restore'.TABLE_PREFIX; @@ -952,31 +952,31 @@ $what = "CREATE TABLE "; $replace = "CREATE TABLE ".$table_prefix; $sql = ereg_replace($what, $replace, $sql); - + $what = "DROP TABLE "; $replace = "DROP TABLE IF EXISTS ".$table_prefix; $sql = ereg_replace($what, $replace, $sql); - + $what = "INSERT INTO "; $replace = "INSERT INTO ".$table_prefix; $sql = ereg_replace($what, $replace, $sql); - + $what = "UPDATE "; $replace = "UPDATE ".$table_prefix; $sql = ereg_replace($what, $replace, $sql); - + $what = "ALTER TABLE "; $replace = "ALTER TABLE ".$table_prefix; $sql = ereg_replace($what, $replace, $sql); } - + $commands = explode("# --------------------------------------------------------",$sql); if(count($commands)>0) { // $query_func = getConnectionInterface('query',$dbo_type); // $errorno_func = getConnectionInterface('errorno',$dbo_type); // $errormsg_func = getConnectionInterface('errormsg',$dbo_type); - + for($i = 0; $i < count($commands); $i++) { $cmd = $commands[$i]; @@ -992,14 +992,14 @@ } } } - + function runSQLText($allsql) { $line = 0; // $query_func = getConnectionInterface('query',$dbo_type); // $errorno_func = getConnectionInterface('errorno',$dbo_type); // $errormsg_func = getConnectionInterface('errormsg',$dbo_type); - + while($line0) { $this->Conn->Query($sql); - + if($this->Conn->errorCode != 0) { return $this->Conn->errorMessage." COMMAND:
$sql
"; @@ -1050,7 +1050,7 @@ $line++; } } - - - + + + } \ No newline at end of file Index: branches/RC/core/admin_templates/tools/restore2.tpl =================================================================== diff -u -r10721 -r10739 --- branches/RC/core/admin_templates/tools/restore2.tpl (.../restore2.tpl) (revision 10721) +++ branches/RC/core/admin_templates/tools/restore2.tpl (.../restore2.tpl) (revision 10739) @@ -73,11 +73,11 @@ "> - + ( M) - + \ No newline at end of file