if ($dump['speed'] > $config['maxspeed']) { $dump['speed'] = $config['maxspeed']; } } else { $dump['speed'] *= $config['tuning_sub']; if ($dump['speed'] < $config['minspeed']) { $dump['speed'] = $config['minspeed']; } } $dump['speed'] = (int) $dump['speed']; $dump['page_refreshs']++; } else { //Backup for all databases is done $dump['data'] = "\nSET FOREIGN_KEY_CHECKS=1;"; $dump['data'] .= "\n" . '-- EOB' . "\n\n"; writeToDumpFile(); executeCommand('a'); chmod($config['paths']['backup'] . $dump['backupdatei'], 0777); $logMsg = sprintf($lang['L_DUMP_OF_DB_FINISHED'], $dump['db_actual']); $log->write(Log::PHP, $logMsg); checkForNextDB(); } } } // everything is dumped -> check for e-mail and ftp-actions if ($dump['backup_done'] == 1) { if (count($_SESSION['log']['files_created']) > 0) { if (!isset($_SESSION['log']['email'])) { // first call after backup is finished -> create todo-list $_SESSION['log']['email'] = array(); $_SESSION['email']['filelist'] = array();
/** * Read records from table, build query-strings and write them to dump file * * @param string $db The database to read from * @param string $table The table to read from * @return void */ function getContent($db, $table) { global $dbo, $config, $dump, $lang, $log; $content = ''; $fields = $dbo->getTableColumns($table, $db); // TODO decide if the type of field needs to be escaped and placed between quotes // also handle NULL-values very strict for MySQL-servers running with sql-mod=STRICT $fieldNames = array_keys($fields); $fieldList = '`' . implode('`,`', $fieldNames) . '`'; // indicator if the actual table is fully dumped in this call $tableDone = 0; $sql = 'SELECT * FROM `' . $db . '`.`' . $table . '` LIMIT ' . $dump['table_record_offset'] . ',' . ($dump['restzeilen'] + 1); $result = $dbo->query($sql, MsdDbFactory::ARRAY_NUMERIC); $numRows = @count($result); if ($numRows > 0) { // we've got records - get fields $numfields = count($result[0]); if ($numRows > $dump['restzeilen']) { // there are more records to get - table is not fully dumped $dump['table_record_offset'] += $dump['restzeilen']; //set table record offset for next call $numRows--; // correct counter - we only used the last record to find out if there is more to fetch unset($result[$numRows]); } else { // table is done -> increase table offset $recordsSaved = $dump['table_record_offset'] + $numRows; $log->write(Log::PHP, sprintf($lang['L_BACKUP_TABLE_DONE'], $table, String::formatNumber($recordsSaved))); $dump['table_offset']++; $dump['table_offset_total']++; $dump['table_record_offset'] = 0; $tableDone = 1; } foreach ($result as $row) { //if($config['backup_using_updates']==1){ $insert = 'INSERT INTO `' . $table . '` (' . $fieldList . ') VALUES ('; //TODO implement REPLACE INTO for expert mode // } //else{ //$insert='REPLACE INTO `'.$table.'` '.$complete.' VALUES ('; // } foreach ($row as $field => $val) { if ($val != '') { $insert .= '\'' . $dbo->escape($val) . '\','; } else { $insert .= '\'\','; } } $insert = substr($insert, 0, -1) . ');' . "\n"; $dump['data'] .= $insert; $dump['restzeilen']--; $dump['countdata']++; if (strlen($dump['data']) > $config['memory_limit'] || $config['multi_part'] == 1 && strlen($dump['data']) + MULTIPART_FILESIZE_BUFFER > $config['multipart_groesse']) { writeToDumpFile(); } } if ($tableDone == 1) { // check if records have been saved and add "enable keys" $tables = $dump['databases'][$dump['db_actual']]['tables']; if ($tables[$table]['dump_records'] == 1) { $dump['data'] .= "/*!40000 ALTER TABLE `{$table}`" . " ENABLE KEYS */;"; } } } else { // table corrupt -> skip it $dump['table_offset']++; $dump['table_offset_total']++; $dump['table_record_offset'] = 0; $dump['restzeilen'] = $dump['restzeilen'] - $numRows; $dump['data'] .= "/*!40000 ALTER TABLE `{$table}` ENABLE KEYS */;\n"; if (strlen($dump['data']) > $config['memory_limit'] || $config['multi_part'] == 1 && strlen($dump['data']) + MULTIPART_FILESIZE_BUFFER > $config['multipart_groesse']) { writeToDumpFile(); } } }