Struggeling with relocating
Dieser Commit ist enthalten in:
Commit
89ea01c429
301 geänderte Dateien mit 59926 neuen und 0 gelöschten Zeilen
343
ajax/dump_ajax.php
Normale Datei
343
ajax/dump_ajax.php
Normale Datei
|
|
@ -0,0 +1,343 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @version SVN: $rev: 1221 $
|
||||
* @author $Author$
|
||||
* @lastmodified $Date$
|
||||
*/
|
||||
chdir('./../');
|
||||
include ('./inc/classes/db/MsdDbFactory.php');
|
||||
include ('./inc/classes/Log.php');
|
||||
include ('./inc/classes/helper/String.php');
|
||||
include ('./inc/classes/helper/Sql.php');
|
||||
include ('./inc/functions/functions.php');
|
||||
include ('./inc/runtime.php');
|
||||
include ('./inc/mysql.php');
|
||||
include ('./inc/functions/functions_global.php');
|
||||
include ('./inc/functions/functions_dump.php');
|
||||
include ('./lib/json.php');
|
||||
obstart(true);
|
||||
$dump = $_SESSION['dump'];
|
||||
$dump['page_start_time'] = time();
|
||||
$dump['progress_table_percent'] = 0;
|
||||
$recordOffset = 0;
|
||||
$recordsTotal = 0;
|
||||
$prozent = 0;
|
||||
$table = '';
|
||||
$msg = '';
|
||||
$log=new Log();
|
||||
$dbo->setConnectionCharset($dump['dump_encoding']);
|
||||
// each time a new database will be dumped ->
|
||||
// look for Command before dump to be executed
|
||||
if ($dump['table_offset'] == - 1)
|
||||
executeCommand('b');
|
||||
$dump['data'] = ''; // will hold string data to be saved to the dump file
|
||||
// needed to find out if new log-messages were added
|
||||
$_SESSION['temp_log'] = $_SESSION['log'];
|
||||
if (! isset($dump['table_records_total']))
|
||||
$dump['table_records_total'] = 0;
|
||||
$tableIndex = $dump['table_offset'] == - 1 ? 0 : $dump['table_offset'];
|
||||
if ($dump['backup_done'] == 0) {
|
||||
if ($dump['databases'][$dump['db_actual']]['table_count'] == 0) {
|
||||
//no tables found -> prevent creation of empty backupfile
|
||||
$msg = sprintf($lang['L_DUMP_NOTABLES'], $dump['db_actual']);
|
||||
if ($dump['databases'][$dump['db_actual']]['prefix'] != '') {
|
||||
$msg = sprintf($lang['L_DUMP_NOTABLES'], $dump['db_actual']);
|
||||
$msg .= ' (' . $lang['L_WITHPRAEFIX'] . ': \'' ;
|
||||
$msg .= $dump['databases'][$dump['db_actual']]['prefix']. '\')';
|
||||
}
|
||||
writeToErrorLog($dump['db_actual'], '', $msg);
|
||||
$dbsToBackup = array(
|
||||
$dump['db_actual']);
|
||||
$dump['backupdatei'] = '';
|
||||
$dump['filesize'] = 0;
|
||||
checkForNextDB();
|
||||
} else {
|
||||
if ($dump['table_offset'] == - 1) {
|
||||
// first call for this database -> create new backup file
|
||||
createNewFile();
|
||||
$dump['table_offset'] = 0; // begin with first table
|
||||
$dump['table_record_offset'] = 0;
|
||||
$dump['restzeilen'] = $config['minspeed'];
|
||||
}
|
||||
$dump['restzeilen'] = $dump['speed'];
|
||||
while ($dump['restzeilen'] > 0 && $dump['table_offset'] <
|
||||
$dump['databases'][$dump['db_actual']]['table_count']) {
|
||||
$tableNames = $dump['databases'][$dump['db_actual']]['tables'];
|
||||
$table = getValueFromIndex($tableNames, $dump['table_offset']);
|
||||
if ($dump['table_record_offset'] == 0) {
|
||||
$dbo->selectDb($dump['db_actual']);
|
||||
// a new table begins
|
||||
// optimize it?
|
||||
if ($config['optimize_tables_beforedump'] == 1) {
|
||||
if (true === Sql::optimizeTable($dbo, $table)) {
|
||||
$dump['tables_optimized']++;
|
||||
}
|
||||
}
|
||||
$recordOffset = 0;
|
||||
$recordsTotal = 0;
|
||||
$dump['progress_table_percent'] = 0;
|
||||
$dump['speed'] = $config['minspeed'];
|
||||
// should we dump the table structure?
|
||||
if ($dump['databases'][$dump['db_actual']]['tables'][$table]['dump_structure'] > 0) {
|
||||
// get create statement of table
|
||||
try {
|
||||
$records = $dump['databases'][$dump['db_actual']]['tables'][$table]['dump_records'];
|
||||
$createStatement = getCreateString($dump['db_actual'], $table, $records);
|
||||
$dump['data'] .= $createStatement;
|
||||
} catch (Exception $e) {
|
||||
// error reading table definition
|
||||
writeToDumpFile(); // save data we have up to now
|
||||
$logMsg = sprintf($lang['L_FATAL_ERROR_DUMP'], $table, $dump['db_actual']);
|
||||
$readCreateError = $logMsg . ': ' . $e->getMessage();
|
||||
writeToErrorLog($config['db_actual'], '', $readCreateError, 0);
|
||||
$log->write(Log::ERROR, $readCreateError);
|
||||
$dump['errors'] ++;
|
||||
//next table
|
||||
$dump['table_offset'] ++;
|
||||
$dump['table_record_offset'] = 0;
|
||||
// set records of table not to be dumped
|
||||
$dump['databases'][$dump['db_actual']]['tables'][$table]['dump_records'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($dump['databases'][$dump['db_actual']]['tables'][$table]['dump_records'] ==1) {
|
||||
getContent($dump['db_actual'], $table);
|
||||
} else {
|
||||
//jump to next table if we don't need to dump the records of this table
|
||||
$dump['table_offset'] ++;
|
||||
}
|
||||
if (strlen($dump['data']) > $config['memory_limit']) {
|
||||
writeToDumpFile();
|
||||
}
|
||||
}
|
||||
// create list of databases for output
|
||||
$dbsToBackup = implode(', ', array_keys($dump['databases']));
|
||||
// highligth actual db
|
||||
$replace = '<span class="success">' . $dump['db_actual'] . '</span>';
|
||||
$dbsToBackup = str_replace($dump['db_actual'], $replace, $dbsToBackup);
|
||||
// we need to get the actual table again because it might have changed
|
||||
$table = getValueFromIndex($dump['databases'][$dump['db_actual']]['tables'], $dump['table_offset']);
|
||||
if ($table) {
|
||||
// get nr of records from dump-array
|
||||
$dump['table_records_total'] = $dump['databases'][$dump['db_actual']]['tables'][$table]['records'];
|
||||
if ($dump['table_records_total'] > 0) {
|
||||
$percent = (100 * $dump['table_record_offset']) / $dump['table_records_total'];
|
||||
$dump['progress_table_percent'] = round($percent, 2);
|
||||
} else {
|
||||
$dump['progress_table_percent'] = 0;
|
||||
}
|
||||
if ($dump['speed'] + $dump['table_record_offset'] >=
|
||||
$dump['table_records_total']) {
|
||||
$recordOffset = $dump['table_record_offset'] +
|
||||
1;
|
||||
$recordsTotal = $dump['table_records_total'];
|
||||
if ($recordsTotal == 0) {
|
||||
$recordOffset = 0;
|
||||
}
|
||||
} else {
|
||||
$recordsTotal = $dump['table_record_offset'] + $dump['speed'];
|
||||
$recordOffset = $dump['table_record_offset'] + 1;
|
||||
}
|
||||
} else {
|
||||
// looks like we've done the job
|
||||
$dump['table_offset'] ++;
|
||||
$dump['table_records_total'] = 0;
|
||||
$table = '';
|
||||
}
|
||||
writeToDumpFile();
|
||||
if ($dump['table_offset'] <= $dump['databases'][$dump['db_actual']]['table_count']) {
|
||||
$dauer = time() - $dump['page_start_time'];
|
||||
//Zeitanpassung
|
||||
if ($dauer < $dump['max_zeit']) {
|
||||
if ($dauer < $dump['max_zeit'] / 2) {
|
||||
$dump['speed'] *= 1.8;
|
||||
} else {
|
||||
$dump['speed'] *= $config['tuning_add'];
|
||||
}
|
||||
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();
|
||||
$_SESSION['log']['ftp'] = array();
|
||||
foreach ($_SESSION['log']['files_created'] as $file) {
|
||||
if ($config['send_mail'] == 1) {
|
||||
$_SESSION['log']['email'][] = $file;
|
||||
}
|
||||
foreach ($config['ftp'] as $index => $val) {
|
||||
// build array with files to send. The key of $_SESSION['log']['ftp'] is the index of
|
||||
// the ftp-connection details of the configuration profile to be used
|
||||
if ($val['transfer'] == 1) {
|
||||
if (! isset($_SESSION['log']['ftp'])) {
|
||||
$_SESSION['log']['ftp'][$index] = array();
|
||||
}
|
||||
$_SESSION['log']['ftp'][$index][] = $file; // add file to transfer
|
||||
}
|
||||
}
|
||||
}
|
||||
// don't start sending now, because we want to inform the client first and show the logentry
|
||||
// log-messages will be sent to client
|
||||
if ($config['send_mail'] == 1) {
|
||||
$log->write(Log::PHP, $lang['L_EMAIL_START']);
|
||||
}
|
||||
if (count($_SESSION['log']['ftp']) > 0) {
|
||||
$log->write(Log::PHP, $lang['L_FTP_START']);
|
||||
}
|
||||
} else {
|
||||
if (count($_SESSION['log']['email']) > 0) {
|
||||
// Ok we need to send an e-mail -> get index of first file
|
||||
$files = $_SESSION['log']['email'];
|
||||
$key = array_keys($files);
|
||||
doEmail($_SESSION['log']['email'][$key[0]]);
|
||||
unset($_SESSION['log']['email'][$key[0]]); // remove from array
|
||||
} else {
|
||||
$dump['backup_in_progress'] = 0; // all files sent
|
||||
}
|
||||
if ($dump['backup_in_progress'] == 0) {
|
||||
// check if ftp-transfers need to be done
|
||||
if (isset($_SESSION['log']['ftp']) && count($_SESSION['log']['ftp']) > 0) {
|
||||
// a file needs to be transferred
|
||||
$dump['backup_in_progress'] = 1; // indicate that there is still more to do
|
||||
// get index of ftp-connection
|
||||
$ftpConnectionIndexes = array_keys($_SESSION['log']['ftp']);
|
||||
$ftpConnection = $ftpConnectionIndexes[0];
|
||||
// now get next file to be transferred
|
||||
$files = $_SESSION['log']['ftp'][$ftpConnection];
|
||||
$fileKeys = array_keys($files);
|
||||
if (isset($fileKeys[0])) {
|
||||
$fileKey = $fileKeys[0];
|
||||
sendViaFTP($ftpConnection, $_SESSION['log']['ftp'][$ftpConnection][$fileKey]);
|
||||
// remove file from todo-list
|
||||
unset($_SESSION['log']['ftp'][$ftpConnection][$fileKey]);
|
||||
} else {
|
||||
// all files transferred for this ftp-connection -> remove connection index
|
||||
unset($_SESSION['log']['ftp'][$ftpConnection]);
|
||||
}
|
||||
} else {
|
||||
$dump['backup_in_progress'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// get values to return
|
||||
$r = array();
|
||||
$json = new Services_JSON();
|
||||
$r['backup_in_progress'] = $dump['backup_in_progress'];
|
||||
// send vars that do not change while dumping only once
|
||||
if ($dump['page_refreshs'] == 1) {
|
||||
$r['tables_total'] = $dump['tables_total'];
|
||||
$r['records_total'] = String::formatNumber($dump['records_total']);
|
||||
$r['speed_min'] = String::formatNumber($config['minspeed']);
|
||||
$r['speed_max'] = String::formatNumber($config['maxspeed']);
|
||||
$r['config_file'] = $config['config_file'];
|
||||
$r['dump_encoding'] = $dump['dump_encoding'];
|
||||
$r['comment'] = $dump['comment'] > '' ? $dump['comment'] : '-';
|
||||
}
|
||||
$r['table_records_total'] = String::formatNumber($dump['table_records_total']);
|
||||
if (isset($dbsToBackup)) {
|
||||
$r['dbs_to_backup'] = $dbsToBackup;
|
||||
}
|
||||
$r['actual_database'] = $dump['db_actual'];
|
||||
$r['actual_table'] = $table;
|
||||
$_SESSION['actual_table'] = $table;
|
||||
$r['actual_table_nr'] = String::formatNumber($dump['table_offset_total'] + 1);
|
||||
$r['page_refreshs'] = String::formatNumber($dump['page_refreshs']);
|
||||
$r['filename'] = $dump['backupdatei'];
|
||||
$r['filesize'] = byteOutput($dump['filesize']);
|
||||
$r['record_offset_start'] = String::formatNumber($recordOffset);
|
||||
$r['record_offset_end'] = String::formatNumber($recordsTotal);
|
||||
$r['progressbar_table_width'] = (int) $dump['progress_table_percent'] * 3;
|
||||
$r['progress_table_percent'] = String::formatNumber($dump['progress_table_percent'], 2);
|
||||
$elapsed = time() - $dump['dump_start_time'];
|
||||
$r['elapsed_time'] = getTimeFormat($elapsed);
|
||||
if ($dump['records_total'] > 0) {
|
||||
$progressOverallPercent = $dump['countdata'] * 100 / $dump['records_total'];
|
||||
if ($progressOverallPercent == 0) {
|
||||
$progressOverallPercent = 0.001;
|
||||
}
|
||||
$r['progress_overall_percent'] = String::formatNumber($progressOverallPercent, 2);
|
||||
$r['progressbar_overall_width'] = $r['progress_overall_percent'] * 3;
|
||||
$estimatedTime = ceil(($elapsed * 100 / $progressOverallPercent) - $elapsed);
|
||||
$r['estimated_end'] = getTimeFormat($estimatedTime);
|
||||
}
|
||||
$r['speed'] = String::formatNumber($dump['speed']);
|
||||
$r['speedbar_width'] = (int) $dump['speed'] * 100 / $config['maxspeed'] * 3;
|
||||
$r['nr_of_errors'] = $dump['errors'] == 0 ? '-' : $dump['errors'];
|
||||
$r['records_saved_total'] = String::formatNumber($dump['countdata']);
|
||||
$r['tables_optimized'] ='';
|
||||
if ($dump['tables_optimized'] > 0) {
|
||||
$r['tables_optimized'] = sprintf($lang['L_NR_TABLES_OPTIMIZED'], String::formatNumber($dump['tables_optimized']));
|
||||
}
|
||||
if ($msg > '') {
|
||||
$r['log'] = $msg;
|
||||
}
|
||||
if ($config['multi_part'] == 1) {
|
||||
$r['multipart_part'] = $dump['part'] - $dump['part_offset'] - 1;
|
||||
}
|
||||
$r['prefix'] = '';
|
||||
if (isset($dump['databases'][$dump['db_actual']]['prefix'])) {
|
||||
$r['prefix'] = $dump['databases'][$dump['db_actual']]['prefix'];
|
||||
}
|
||||
// check if new log-messages werde added
|
||||
$messages = getArrayDiffAssocRecursive($_SESSION['log'], $_SESSION['temp_log']);
|
||||
if (isset($messages['actions']) && is_array($messages['actions'])) {
|
||||
$r['actions'] = implode('<br />', $messages['actions']);
|
||||
}
|
||||
if (isset($messages['errors']) && is_array($messages['errors'])) {
|
||||
$r['errors'] = implode('<br />', $messages['errors']);
|
||||
}
|
||||
$_SESSION['log'] = $_SESSION['log'] + $_SESSION['temp_log'];
|
||||
$dump['last_db_actual'] = $dump['db_actual'];
|
||||
//backup_done means that all tables are saved. The overall progress
|
||||
//(emails, ftp) can still continue
|
||||
if ($dump['backup_done'] == 1) {
|
||||
// some values need to be decreased
|
||||
$r['progressbar_table_width'] = 0;
|
||||
$r['progress_table_percent'] = '';
|
||||
$r['actual_database'] = '';
|
||||
$r['actual_table'] = '';
|
||||
$r['record_offset_start'] = '-';
|
||||
$r['record_offset_end'] = '-';
|
||||
$r['table_records_total'] = '-';
|
||||
$r['actual_table_nr'] = String::formatNumber($dump['table_offset_total']);
|
||||
$r['progress_overall_percent'] = String::formatNumber(100, 2);
|
||||
$r['progressbar_overall_width'] = 300;
|
||||
$r['speed'] = 0;
|
||||
$r['speedbar_width'] = 0;
|
||||
}
|
||||
// save actual values to session
|
||||
$_SESSION['dump'] = $dump;
|
||||
echo $json->encode($r);
|
||||
obend(true);
|
||||
150
ajax/install_get_language_files.php
Normale Datei
150
ajax/install_get_language_files.php
Normale Datei
|
|
@ -0,0 +1,150 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @version SVN: $rev: 1212 $
|
||||
* @author $Author$
|
||||
* @lastmodified $Date$
|
||||
*/
|
||||
$updateUrl = 'http://update.mysqldumper.de/index.php';
|
||||
session_name('MySQLDumper');
|
||||
session_start();
|
||||
$languageToLoad = isset($_GET['l']) ? trim($_GET['l']) : '';
|
||||
$version = isset($_GET['v']) ? floatval(trim($_GET['v'])) : '';
|
||||
$path = './language/' . $languageToLoad;
|
||||
$error = false;
|
||||
if (session_id() != $_GET['MySQLDumper']) {
|
||||
$error[] = 'Invalid Session';
|
||||
}
|
||||
chdir('./../');
|
||||
include ('./inc/functions/functions.php');
|
||||
include ('./inc/runtime.php');
|
||||
include ('./lib/json.php');
|
||||
include ('./inc/functions/functions_global.php');
|
||||
include ('./inc/mysql.php');
|
||||
include ('./inc/classes/helper/Html.php');
|
||||
include ('./inc/classes/helper/File.php');
|
||||
header('Pragma: no-cache');
|
||||
header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1
|
||||
header('Expires: -1'); // Datum in der Vergangenheit
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
$message = array();
|
||||
$inProgress = 1;
|
||||
clearstatcache();
|
||||
$filesToLoad = array('lang');
|
||||
if (!isset($_SESSION['get_language'])) {
|
||||
// try to create sub-dir for language if it does not exists
|
||||
if (!is_dir($path)) {
|
||||
$res = @mkdir($path, 0755);
|
||||
if (true === $res) {
|
||||
$msg = 'Directory \'' . $path . '\' created successfully';
|
||||
$message[] = Html::getOkMsg($msg);
|
||||
} else {
|
||||
$msg = 'Fatal error: Couldn\'t create directory \'' . $path;
|
||||
$msg .= '\'! You need to create it using your FTP-Programm and ';
|
||||
$msg .= 'grant rights 0777!';
|
||||
$message[] = Html::getErrorMsg($msg);
|
||||
}
|
||||
} else {
|
||||
$message[] = Html::getOkMsg('Directory \'' . $path . '\' exists.');
|
||||
}
|
||||
// try to chmod
|
||||
if (!File::isWritable($path, 0755)) {
|
||||
if (File::isWritable($path, 0777)) {
|
||||
$msg = 'Directory \'' . $path . '\' is writable.';
|
||||
$message[] =Html::getOkMsg($msg);
|
||||
} else {
|
||||
$msg = 'Fatal error: Directory \'' . $path;
|
||||
$msg .= '\' is not writable for me! Make it writable using your ';
|
||||
$msg .= 'FTP-Programm!';
|
||||
$message[] = Html::getErrorMsg($msg);
|
||||
}
|
||||
} else {
|
||||
$message[] = Html::getOkMsg('Directory \'' . $path . '\' is writable.');
|
||||
$_SESSION['get_language'] = $filesToLoad;
|
||||
}
|
||||
} else {
|
||||
// get next file to download
|
||||
if (count($_SESSION['get_language']) > 0) {
|
||||
$file = $_SESSION['get_language'][count($_SESSION['get_language']) - 1];
|
||||
$call = '?a=get_language_file&v=' . $version . '&l=' . $languageToLoad ;
|
||||
$call .= '&f=' . $file;
|
||||
$fileData = getFileDataFromURL($updateUrl . $call);
|
||||
if (false === $fileData || $fileData == '') {
|
||||
$msg = 'Fatal error: error downloading file \'' . $file . '\'!';
|
||||
$msg .= ' Please try again.';
|
||||
$message[] = Html::getErrorMsg($msg);
|
||||
} else {
|
||||
// save file to disk
|
||||
$file = $path . '/' . $file . '.php';
|
||||
$fp = @fopen($file, 'wb');
|
||||
if ($fp) {
|
||||
fwrite($fp, $fileData);
|
||||
fclose($fp);
|
||||
if (!File::isWritable($file, 0644)) {
|
||||
File::isWritable($file, 0777);
|
||||
}
|
||||
$msg = ' File \'' . $file . '\' saved succesfully.';
|
||||
$message[] = Html::getOkMsg($msg);
|
||||
// remove file from todo list
|
||||
$fileIndex = count($_SESSION['get_language']) - 1;
|
||||
unset($_SESSION['get_language'][$fileIndex]);
|
||||
} else {
|
||||
$msg = 'Fatal error: couldn\'t write file \'' . $file;
|
||||
$msg .= '\' to \'' . $path . '\'';
|
||||
$message[] = Html::getErrorMsg($msg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$inProgress = 0;
|
||||
$msg = 'Finished installing language \'' . $languageToLoad;
|
||||
$msg .= '\' successfully.';
|
||||
$message[] = Html::getOkMsg($msg);
|
||||
}
|
||||
}
|
||||
$json = new Services_JSON();
|
||||
$r = array();
|
||||
$r['in_progress'] = $inProgress; // finished? 0=no
|
||||
$r['error'] = 0;
|
||||
if ($error) {
|
||||
if (!empty($_SESSION['get_language'])) {
|
||||
$msg = 'Incomplete installation of language pack: ';
|
||||
$msg .= 'removing incomplete files.';
|
||||
$message[] = Html::getErrorMsg($msg);
|
||||
// now we need to delete the language files
|
||||
foreach ($filesToLoad as $file) {
|
||||
if (file_exists($path . '/' . $file . '.php')) {
|
||||
if (@unlink($path . '/' . $file . '.php')) {
|
||||
$msg = 'Deleted file \'' . $file . '\' successfully.';
|
||||
$message[] = Html::getOkMsg($msg);
|
||||
} else {
|
||||
$msg = 'Error deleting file \'' . $file;
|
||||
$msg .= '\'! Remove it using your FTP-Programm!';
|
||||
$message[] = Html::getErrorMsg($msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!in_array($languageToLoad, array('en', 'de'))) {
|
||||
if (@rmdir($path)) {
|
||||
$msg = 'Directory \'' . $languageToLoad;
|
||||
$msg .= '\' deleted successfully.';
|
||||
$message[] = Html::getOkMsg($msg);
|
||||
} else {
|
||||
$msg = 'Error deleting directory \'' . $path . '\'!';
|
||||
$message[] = Html::getErrorMsg($msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
$r['error'] = 1; // inidcate that an error occured to stop further actions
|
||||
$r['in_progress'] = 0;
|
||||
}
|
||||
$r['message'] = implode('', $message);
|
||||
if ($r['in_progress'] == 0) {
|
||||
unset($_SESSION['get_language']);
|
||||
}
|
||||
echo $json->encode($r);
|
||||
369
ajax/restore_ajax.php
Normale Datei
369
ajax/restore_ajax.php
Normale Datei
|
|
@ -0,0 +1,369 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @version SVN: $rev: 1207 $
|
||||
* @author $Author$
|
||||
* @lastmodified $Date$
|
||||
*/
|
||||
error_reporting(E_ALL);
|
||||
chdir('./../');
|
||||
include ('./inc/classes/db/MsdDbFactory.php');
|
||||
include ('./inc/classes/helper/String.php');
|
||||
include ('./inc/classes/helper/Sql.php');
|
||||
include ('./inc/classes/Log.php');
|
||||
include ('./inc/functions/functions.php');
|
||||
include ('./inc/runtime.php');
|
||||
include ('./inc/mysql.php');
|
||||
include ('./inc/functions/functions_global.php');
|
||||
include ('./lib/template.php');
|
||||
include ('./inc/functions/functions_restore.php');
|
||||
include ('./lib/json.php');
|
||||
obstart(true);
|
||||
$config = $_SESSION['config'];
|
||||
$databases = $_SESSION['databases'];
|
||||
$restore = $_SESSION['restore'];
|
||||
if (!isset($_SESSION['temp_log'])) {
|
||||
$_SESSION['temp_log'] = array();
|
||||
}
|
||||
// remember the start time to calculate speed later on
|
||||
$restore['page_start_time'] = time();
|
||||
if ($restore['page_refreshs'] > 0)
|
||||
// clear temp log. Needed to find out if new log-messages were added
|
||||
$_SESSION['temp_log'] = $_SESSION['log'];
|
||||
if (!isset($config['language'])) {
|
||||
// some server limit the number of vars that can be saved in a session
|
||||
die('Incomplete session in restore_ajax.php');
|
||||
}
|
||||
$restore['restore_in_progress'] = 1;
|
||||
$timeElapsed = 0;
|
||||
$commandsFound = 0;
|
||||
try
|
||||
{
|
||||
$dbo->setConnectionCharset($restore['dump_encoding']);
|
||||
$dbo->selectDb($config['db_actual'], true);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
die($lang['L_DB_SELECT_ERROR'] . $config['db_actual']
|
||||
. $lang['L_DB_SELECT_ERROR2'] . '<br>' . $e->getMessage());
|
||||
}
|
||||
|
||||
// open backup file
|
||||
$file = $config['paths']['backup'] . $restore['filename'];
|
||||
if ($restore['compressed'] == 1) {
|
||||
$restore['filehandle'] = gzopen($file, 'r');
|
||||
} else {
|
||||
$restore['filehandle'] = fopen($file, 'r');
|
||||
}
|
||||
if (!$restore['filehandle']) {
|
||||
// fatal error: we couldn't open the backup file
|
||||
writeToErrorLog(
|
||||
'', '', $lang['L_FILE_OPEN_ERROR'] . ': ' . $config['paths']['backup']
|
||||
. $restore['filename'], 0
|
||||
);
|
||||
die($lang['L_FILE_OPEN_ERROR'] . ': ' . $restore['filename']);
|
||||
}
|
||||
|
||||
$filesize = filesize($config['paths']['backup'] . $restore['filename']);
|
||||
// move file pointer to the actual positon in the file
|
||||
if ($restore['compressed']) {
|
||||
gzseek($restore['filehandle'], $restore['offset']);
|
||||
} else {
|
||||
fseek($restore['filehandle'], $restore['offset']);
|
||||
}
|
||||
$log=new Log();
|
||||
|
||||
// Disable Keys of actual table (after page-refresh: again!)
|
||||
// to speed up restoring
|
||||
// but only if the table should be restored and if it already exists
|
||||
$existingTables = $dbo->getTables($config['db_actual']);
|
||||
$actualTable = $restore['actual_table'];
|
||||
if (in_array($actualTable, $existingTables)) {
|
||||
if ($restore['tables_to_restore']) {
|
||||
if (in_array($actualTable, $restore['tables_to_restore'])) {
|
||||
Sql::disableKeys($dbo, $restore['actual_table']);
|
||||
}
|
||||
} elseif ($actualTable > '' && $actualTable != 'unbekannt') {
|
||||
Sql::disableKeys($dbo, $restore['actual_table']);
|
||||
}
|
||||
}
|
||||
WHILE ($commandsFound < $restore['speed'] &&
|
||||
$timeElapsed < $restore['max_zeit'] &&
|
||||
!$restore['fileEOF'] && !$restore['EOB']) {
|
||||
$sqlCommand = getQueryFromFile();
|
||||
$commandsFound++;
|
||||
if ($sqlCommand > '') {
|
||||
//$log->write(Log::PHP, $sqlCommand);
|
||||
try
|
||||
{
|
||||
$res = $dbo->query($sqlCommand, MsdDbFactory::SIMPLE);
|
||||
// get nr of affected rows
|
||||
$command = strtoupper(substr($sqlCommand, 0, 7));
|
||||
if ($command == 'INSERT ' || $command == 'REPLACE') {
|
||||
$rowsAffected = $dbo->getAffectedRows();
|
||||
$restore['records_inserted'] += $rowsAffected;
|
||||
if (!isset(
|
||||
$restore['records_inserted_table'][$restore['actual_table']])
|
||||
) {
|
||||
$restore['records_inserted_table'][$restore['actual_table']] = 0;
|
||||
}
|
||||
$restore['records_inserted_table'][$restore['actual_table']] += $rowsAffected;
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
// we've got a mysql error
|
||||
$sqlError = $e->getMessage();
|
||||
if ($sqlError != '') {
|
||||
if (strtolower(substr($sqlError, 0, 15)) == 'duplicate entry') {
|
||||
writeToErrorLog(
|
||||
$config['db_actual'], $sqlCommand, $sqlError, 1
|
||||
);
|
||||
$restore['notices']++;
|
||||
} else {
|
||||
if ($config['stop_with_error'] == 0) {
|
||||
// according to the config we continue restoring
|
||||
// but log the error
|
||||
writeToErrorLog(
|
||||
$config['db_actual'],
|
||||
$sqlCommand, $sqlError, 0
|
||||
);
|
||||
$restore['errors']++;
|
||||
} else {
|
||||
// we should die if errors occur -> print error message
|
||||
writeToErrorLog(
|
||||
$config['db_actual'],
|
||||
$sqlCommand,
|
||||
'Fatal error, restore failed: ' . $sqlError, 0
|
||||
);
|
||||
SQLError($sqlCommand, $sqlError);
|
||||
$restore['restore_in_progress'] = 0;
|
||||
die();
|
||||
// TODO clean end of process - last message is not
|
||||
// logged on restore screen and
|
||||
// not sent back to client. Flag missing here that
|
||||
// should be handled via JSON
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$timeElapsed = time() - $restore['page_start_time'];
|
||||
}
|
||||
|
||||
if ($restore['compressed']) {
|
||||
$restore['offset'] = gztell($restore['filehandle']);
|
||||
gzclose($restore['filehandle']);
|
||||
} else {
|
||||
$restore['offset'] = ftell($restore['filehandle']);
|
||||
fclose($restore['filehandle']);
|
||||
}
|
||||
$restore['page_refreshs']++;
|
||||
|
||||
// progress of actual file
|
||||
if ($restore['compressed']) {
|
||||
// compressed backup - there is no way to get the exact file offset,
|
||||
// because gztell delivers uncompressed bytes
|
||||
// so we assume the average packing factor is 11 and will divide the file
|
||||
// offset by it
|
||||
$restore['progress_file_percent'] =
|
||||
$restore['offset'] / 11 * 100 / $filesize;
|
||||
if ($restore['progress_file_percent'] > 100)
|
||||
$restore['progress_file_percent'] = 100;
|
||||
} else {
|
||||
// uncompressed backup -> get percentage from file offset
|
||||
$restore['progress_file_percent'] = 0;
|
||||
if ($filesize > 0) {
|
||||
$restore['progress_file_percent'] =
|
||||
($restore['offset'] * 100) / $filesize;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Overall progress
|
||||
if ($restore['records_total'] > 0) {
|
||||
// it's a backup of MySQLDumper (the number of total records is known) ->
|
||||
// calculate on count of records
|
||||
$restore['progress_overall_percent'] =
|
||||
$restore['records_inserted'] * 100 / $restore['records_total'];
|
||||
} else {
|
||||
// backup from another script. We don't know how many records will follow
|
||||
$restore['progress_overall_percent'] = 0;
|
||||
}
|
||||
// tables to create
|
||||
if ((int) $restore['tables_total'] > 0) {
|
||||
// MSD-Backup
|
||||
// tables to go
|
||||
$tablesToDo = $restore['tables_total'];
|
||||
// selected tables should be restored? Overwrite value
|
||||
if (is_array($restore['tables_to_restore']))
|
||||
$tablesToDo = count($restore['tables_to_restore']);
|
||||
$tablesToCreate = sprintf(
|
||||
$lang['L_RESTORE_TABLES_COMPLETED'], $restore['table_ready'], $tablesToDo
|
||||
);
|
||||
$recordsDone = sprintf(
|
||||
$lang['L_ACTUALLY_INSERTED_RECORDS_OF'],
|
||||
String::formatNumber($restore['records_inserted']),
|
||||
String::formatNumber($restore['records_total'])
|
||||
);
|
||||
} else {
|
||||
// not a MSD-Backup
|
||||
$tablesToCreate = sprintf(
|
||||
$lang['L_RESTORE_TABLES_COMPLETED'],
|
||||
$restore['table_ready'],
|
||||
$lang['L_UNKNOWN']
|
||||
);
|
||||
$recordsDone = sprintf(
|
||||
$lang['L_ACTUALLY_INSERTED_RECORDS'],
|
||||
String::formatNumber($restore['records_inserted']),
|
||||
$lang['L_UNKNOWN']
|
||||
);
|
||||
}
|
||||
|
||||
// calculate speed for next page call
|
||||
if ($timeElapsed < $restore['max_zeit']) {
|
||||
// wenn wir mehr als die Haelfte der Zeit noch haetten nutzen koennen:
|
||||
// Anzahl direkt um fast das Doppelte erhoehen
|
||||
if ($timeElapsed < $restore['max_zeit'] / 2)
|
||||
$restore['speed'] = $restore['speed'] * 1.8;
|
||||
else $restore['speed'] = $restore['speed'] * $config['tuning_add'];
|
||||
if ($restore['speed'] > $config['maxspeed'])
|
||||
$restore['speed'] = $config['maxspeed'];
|
||||
} else {
|
||||
$restore['speed'] = $restore['speed'] * $config['tuning_sub'];
|
||||
if ($restore['speed'] < $config['minspeed'])
|
||||
$restore['speed'] = $config['minspeed'];
|
||||
}
|
||||
|
||||
if ($restore['fileEOF'] && $restore['part'] == 0)
|
||||
$restore['EOB'] = true; //part is >0 if we have a Multipart backup
|
||||
if ($restore['EOB']) {
|
||||
// Done
|
||||
$time = getTimeFormat(time() - $restore['restore_start_time']);
|
||||
$log->write(
|
||||
Log::PHP, sprintf(
|
||||
$lang['L_RESTORE_DB_COMPLETE_IN'],
|
||||
$config['db_actual'],
|
||||
$time
|
||||
)
|
||||
);
|
||||
$restore['restore_in_progress'] = 0;
|
||||
} else {
|
||||
if ($restore['fileEOF']) {
|
||||
// let's get the next Multipart file
|
||||
$restore['fileEOF'] = false;
|
||||
$nextfile = getNextPart($restore['filename'], 0, true);
|
||||
// there is more to do -> process the next Multipart file
|
||||
if (!file_exists($config['paths']['backup'] . $nextfile)) {
|
||||
writeToErrorLog(
|
||||
$config['db_actual'], '',
|
||||
sprintf($lang['L_ERROR_MULTIPART_RESTORE'], $nextfile)
|
||||
);
|
||||
$restore['restore_in_progress'] = 0;
|
||||
} else {
|
||||
$restore['filename'] = $nextfile;
|
||||
$restore['offset'] = 0;
|
||||
$restore['part']++;
|
||||
$log->write(
|
||||
Log::PHP,
|
||||
sprintf(
|
||||
$lang['L_CONTINUE_MULTIPART_RESTORE'],
|
||||
$restore['filename']
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// collect values to return to client
|
||||
$r = array();
|
||||
$json = new Services_JSON();
|
||||
$r['restore_in_progress'] = $restore['restore_in_progress'];
|
||||
if ($restore['page_refreshs'] == 1) {
|
||||
// Only send on first page call because values won't change
|
||||
$r['speed_min'] = String::formatNumber($config['minspeed']);
|
||||
$r['speed_max'] = String::formatNumber($config['maxspeed']);
|
||||
$r['dump_encoding'] = $restore['dump_encoding'];
|
||||
}
|
||||
|
||||
// if restore is finished and file is gzipped, the file pointer
|
||||
// might not be accurate
|
||||
if ($restore['restore_in_progress'] == 0) {
|
||||
// correct percentage of file to now known exact value
|
||||
$restore['progress_file_percent'] = 100;
|
||||
$restore['speed'] = 0;
|
||||
}
|
||||
|
||||
$r['filename'] = $restore['filename'];
|
||||
$r['nr_of_errors'] = String::formatNumber($restore['errors']);
|
||||
$r['nr_of_notices'] = String::formatNumber($restore['notices']);
|
||||
|
||||
$r['progress_file_percent'] = String::formatNumber(
|
||||
$restore['progress_file_percent'], 2
|
||||
);
|
||||
$r['progress_file_bar_width'] = round($restore['progress_file_percent'] * 3, 0);
|
||||
|
||||
if ($restore['progress_overall_percent'] > 0) {
|
||||
$r['progress_overall_percent'] = String::formatNumber(
|
||||
$restore['progress_overall_percent'], 2
|
||||
);
|
||||
$r['progress_overall_bar_width'] = round(
|
||||
$restore['progress_overall_percent'] * 3, 0
|
||||
);
|
||||
} else {
|
||||
$r['progress_overall_percent'] = $lang['L_UNKNOWN'];
|
||||
$r['progress_overall_bar_width'] = 0;
|
||||
}
|
||||
if ($restore['part'] > 0) {
|
||||
$r['part'] = $restore['part'];
|
||||
}
|
||||
$r['tables_to_create'] = $tablesToCreate;
|
||||
$r['records_done'] = $recordsDone;
|
||||
$r['actual_table'] = sprintf(
|
||||
$lang['L_ANALYZING_TABLE'], $restore['actual_table']
|
||||
);
|
||||
$r['speed'] = String::formatNumber($restore['speed']);
|
||||
$r['speedbar_width'] = round(
|
||||
$restore['speed'] * 100 / $config['maxspeed'] * 3, 0
|
||||
);
|
||||
$r['page_refreshs'] = String::formatNumber($restore['page_refreshs']);
|
||||
|
||||
$elapsed = time() - $restore['restore_start_time'];
|
||||
$r['elapsed_time'] = getTimeFormat($elapsed);
|
||||
|
||||
// if we restore a MySQLDumper-Backup we know the nr of records and can
|
||||
// calculate the estimated time from it
|
||||
// if we restore a backup from another program we need to rely on the filesize
|
||||
//which is not accurate
|
||||
// when the file is gzipped, but we can't help it because there is no way to
|
||||
// get the exact file pointer position in a gzipped file.
|
||||
// So we give our best to guess the corect position (see line 117 above)
|
||||
if ($restore['progress_overall_percent'] > 0) {
|
||||
$percentageDone = $restore['progress_overall_percent'];
|
||||
} else {
|
||||
$percentageDone = $restore['progress_file_percent'];
|
||||
}
|
||||
$estimatedTime = 0;
|
||||
if ($percentageDone > 0) {
|
||||
$estimatedTime = (100 - $percentageDone) * ($elapsed / $percentageDone);
|
||||
$r['estimated_end'] = getTimeFormat($estimatedTime);
|
||||
} else {
|
||||
$r['estimated_end'] = $lang['L_UNKNOWN'];
|
||||
}
|
||||
|
||||
// check if new log-messages have been added
|
||||
$messages = getArrayDiffAssocRecursive($_SESSION['log'], $_SESSION['temp_log']);
|
||||
if (isset($messages['actions']) && is_array($messages['actions']))
|
||||
$r['actions'] = implode('<br />', $messages['actions']);
|
||||
if (isset($messages['errors']) && is_array($messages['errors']))
|
||||
$r['errors'] = implode('<br />', $messages['errors']);
|
||||
$_SESSION['log'] = $_SESSION['log'] + $_SESSION['temp_log'];
|
||||
|
||||
// save actual values to session
|
||||
$_SESSION['restore'] = $restore;
|
||||
echo $json->encode($r);
|
||||
obend(true);
|
||||
121
ajax/show_log_entry.php
Normale Datei
121
ajax/show_log_entry.php
Normale Datei
|
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @version SVN: $rev: $
|
||||
* @author $Author$
|
||||
* @lastmodified $Date$
|
||||
*/
|
||||
$error = false;
|
||||
chdir('./../');
|
||||
include ('./inc/functions/functions.php');
|
||||
include ('./inc/runtime.php');
|
||||
include ('./inc/functions/functions_global.php');
|
||||
include ('./inc/mysql.php');
|
||||
include ('./inc/classes/db/MsdDbFactory.php');
|
||||
include ('./inc/classes/helper/String.php');
|
||||
include ('./inc/classes/helper/Html.php');
|
||||
include ('./inc/classes/Log.php');
|
||||
obstart();
|
||||
include ('./inc/define_icons.php');
|
||||
include ('./lib/template.php');
|
||||
|
||||
$logType = (isset($_GET['log'])) ? $_GET['log'] : Log::PHP;
|
||||
$revers = (isset($_GET['revers'])) ? $_GET['revers'] : 1;
|
||||
$offset = (isset($_GET['offset'])) ? $_GET['offset'] : 0;
|
||||
$entriesShown = 25;
|
||||
|
||||
// define template
|
||||
$tplLog = new MSDTemplate();
|
||||
$tplLog->set_filenames(array('tplLog' => 'tpl/log/log_ajax.tpl'));
|
||||
|
||||
// get log filename to show
|
||||
$lfile = Log::getLogfile($logType);
|
||||
$tplLog->assign_vars(
|
||||
array(
|
||||
'ICON_SORT' => $revers == 0 ? $icon['arrow_up'] : $icon['arrow_down'],
|
||||
'SORT_ORDER' => $revers == 0 ? 1 : 0,
|
||||
'LOG' => str_replace($config['paths']['log'], '', $lfile))
|
||||
);
|
||||
|
||||
$tplLog->assign_vars(
|
||||
array(
|
||||
'LOG_TYPE' => $logType,
|
||||
'REVERS' => $revers)
|
||||
);
|
||||
|
||||
if (file_exists($lfile)) {
|
||||
$lines = ($config['logcompression'] == 1) ? gzfile($lfile) : file($lfile);
|
||||
if ($revers == 1) {
|
||||
$lines = array_reverse($lines);
|
||||
}
|
||||
$i = 1;
|
||||
$entriesTotal = count($lines);
|
||||
foreach ($lines as $index => $val) {
|
||||
if ($index >= $offset * $entriesShown
|
||||
&& $index < ($offset + 1) * $entriesShown) {
|
||||
// strip html in Perl-Log
|
||||
$val = strip_tags($val, '<br>');
|
||||
$timestamp = substr($val, 0, 19);
|
||||
$message = substr($val, 20);
|
||||
if ($revers == 0) {
|
||||
$nr = String::formatNumber($offset * $entriesShown + $i);
|
||||
} else {
|
||||
$nr= String::formatNumber($entriesTotal - $index);
|
||||
}
|
||||
$tplLog->assign_block_vars(
|
||||
'LINE',
|
||||
array(
|
||||
'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1',
|
||||
'NR' => $nr,
|
||||
'TIMESTAMP' => $timestamp,
|
||||
'MSG' => $message)
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$maxOffset = floor($entriesTotal / $entriesShown);
|
||||
if ($maxOffset * $entriesShown == $entriesTotal) {
|
||||
$maxOffset--;
|
||||
}
|
||||
|
||||
$offsetForeward = $offset < $maxOffset ? $offset + 1 : 0;
|
||||
$offsetBackward = $offset > 0 ? $offset - 1 : $maxOffset;
|
||||
if ($revers == 0) {
|
||||
$entryTo = ($offset + 1) * $entriesShown;
|
||||
if ($entryTo > $entriesTotal) {
|
||||
$entryTo = $entriesTotal;
|
||||
}
|
||||
$pagination = sprintf(
|
||||
$lang['L_SHOWING_ENTRY_X_TO_Y_OF_Z'],
|
||||
String::formatNumber($offset * $entriesShown + 1),
|
||||
String::formatNumber($entryTo),
|
||||
String::formatNumber($entriesTotal)
|
||||
);
|
||||
} else {
|
||||
$total = $maxOffset * $entriesShown;
|
||||
$entryFrom = $entriesTotal - ($offset * $entriesShown);
|
||||
if ($entryFrom > $entriesTotal) $entryFrom = $entriesTotal;
|
||||
$entryTo = $entriesTotal - (($offset + 1) * $entriesShown) + 1;
|
||||
if ($entryTo < 1) {
|
||||
$entryTo = 1;
|
||||
}
|
||||
$pagination = sprintf(
|
||||
$lang['L_SHOWING_ENTRY_X_TO_Y_OF_Z'],
|
||||
String::formatNumber($entryFrom),
|
||||
String::formatNumber($entryTo),
|
||||
String::formatNumber($entriesTotal)
|
||||
);
|
||||
}
|
||||
|
||||
$tplLog->assign_vars(
|
||||
array(
|
||||
'OFFSET_FOREWARD' => $offsetForeward,
|
||||
'OFFSET_BACKWARD' => $offsetBackward,
|
||||
'PAGINATION_ENTRIES' => $pagination)
|
||||
);
|
||||
}
|
||||
$tplLog->pparse('tplLog');
|
||||
obend(true);
|
||||
58
ajax/show_table_field.php
Normale Datei
58
ajax/show_table_field.php
Normale Datei
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @version SVN: $rev: 1205 $
|
||||
* @author $Author$
|
||||
* @lastmodified $Date$
|
||||
*/
|
||||
chdir('./../');
|
||||
include ('./inc/classes/db/MsdDbFactory.php');
|
||||
include ('./inc/functions/functions.php');
|
||||
include ('./inc/runtime.php');
|
||||
include ('./inc/mysql.php');
|
||||
include ('./inc/functions/functions_global.php');
|
||||
include ('./lib/template.php');
|
||||
include ('./inc/functions/functions_restore.php');
|
||||
include ('./lib/json.php');
|
||||
obstart(true);
|
||||
include ('./inc/functions/functions_sql.php');
|
||||
|
||||
$tplSqlbrowserTableShowTabledataEntry = new MSDTemplate();
|
||||
$tplSqlbrowserTableShowTabledataEntry->set_filenames(
|
||||
array(
|
||||
'tpl_sqlbrowser_table_show_tabledata' =>
|
||||
'./tpl/sqlbrowser/table/edit_field.tpl'
|
||||
)
|
||||
);
|
||||
|
||||
/*
|
||||
* Fetch and check _GET variables
|
||||
*/
|
||||
$validModes = array('new');
|
||||
$db = isset($_GET['db']) ? base64_decode($_GET['db']) : $config['db_actual'];
|
||||
$tablename = isset($_GET['tablename']) ? base64_decode($_GET['tablename']) : '';
|
||||
$fieldname = isset($_GET['fieldname']) ? base64_decode($_GET['fieldname']) : '';
|
||||
$rowKey = isset($_GET['key']) ? base64_decode($_GET['key']) : '';
|
||||
$mode = 'new';
|
||||
if (isset($_GET['do']) && in_array($_GET['do'], $validModes)) {
|
||||
$mode = $_GET['do'];
|
||||
}
|
||||
$tableInfos = getExtendedFieldInfo($db, $tablename);
|
||||
|
||||
$tplSqlbrowserTableShowTabledataEntry->assign_vars(array('MODE' => $mode));
|
||||
|
||||
$row = array();
|
||||
if ($mode == 'EDIT') {
|
||||
//TODO implement :)
|
||||
}
|
||||
|
||||
$tplSqlbrowserTableShowTabledataEntry->assign_block_vars(
|
||||
'FOOTER_' . $mode, array()
|
||||
);
|
||||
$tplSqlbrowserTableShowTabledataEntry->pparse(
|
||||
'tpl_sqlbrowser_table_show_tabledata'
|
||||
);
|
||||
obend(true);
|
||||
105
ajax/show_tabledata_entry.php
Normale Datei
105
ajax/show_tabledata_entry.php
Normale Datei
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @version $Rev$
|
||||
* @author $Author$
|
||||
* @lastmodified $Date$
|
||||
*/
|
||||
error_reporting(E_ALL);
|
||||
chdir('./../');
|
||||
include ('./inc/classes/db/MsdDbFactory.php');
|
||||
include ('./inc/classes/helper/Html.php');
|
||||
include ('./inc/functions/functions.php');
|
||||
include ('./inc/runtime.php');
|
||||
include ('./inc/mysql.php');
|
||||
include ('./inc/functions/functions_global.php');
|
||||
include ('./lib/template.php');
|
||||
include ('./inc/functions/functions_restore.php');
|
||||
include ('./lib/json.php');
|
||||
obstart(true);
|
||||
include ('./inc/functions/functions_sql.php');
|
||||
|
||||
$tplSqlbrowserTableShowTabledataEntry = new MSDTemplate();
|
||||
$tplSqlbrowserTableShowTabledataEntry->set_filenames(
|
||||
array(
|
||||
'tplSqlbrowserTableShowTabledataEntry' =>
|
||||
'./tpl/sqlbrowser/table/show_tabledata_entry.tpl'
|
||||
)
|
||||
);
|
||||
|
||||
/*
|
||||
* Fetch and check _GET variables
|
||||
*/
|
||||
$validModes = array('VIEW', 'EDIT', 'NEW');
|
||||
$db = isset($_GET['db']) ? base64_decode($_GET['db']) : $config['db_actual'];
|
||||
$tablename = isset($_GET['tablename']) ? base64_decode($_GET['tablename']) : '';
|
||||
$rowKey = isset($_GET['key']) ? base64_decode($_GET['key']) : '';
|
||||
$mode = 'VIEW';
|
||||
if (isset($_GET['do'])) {
|
||||
$mode =strtoupper((string) $_GET['do']);
|
||||
}
|
||||
if (!in_array($mode, $validModes)) {
|
||||
$mode = 'VIEW';
|
||||
}
|
||||
$tableInfos = getExtendedFieldInfo($db, $tablename);
|
||||
|
||||
$tplSqlbrowserTableShowTabledataEntry->assign_vars(
|
||||
array(
|
||||
'DB_NAME' => $db,
|
||||
'TABLE_NAME' => $tablename,
|
||||
'DB_NAME_URLENCODED' => base64_encode($db),
|
||||
'TABLE_NAME_URLENCODED' => base64_encode($tablename)
|
||||
)
|
||||
);
|
||||
|
||||
$row = array();
|
||||
|
||||
if ($mode == 'VIEW' || $mode == 'EDIT') {
|
||||
$dbo->selectDb($db);
|
||||
$query = "SELECT * FROM `$tablename` WHERE $rowKey";
|
||||
$row = $dbo->query($query, MsdDbFactory::ARRAY_ASSOC);
|
||||
if (false === $row || !isset($row[0])) {
|
||||
//TODO clean error handling
|
||||
echo "<h2>Keine Datensätze gefunden!</h2>";
|
||||
obend(true);
|
||||
exit();
|
||||
} elseif (count($row) > 1) {
|
||||
// TODO clean error handling
|
||||
echo "<h2>Mehrere Datensätze gefunden!</h2>";
|
||||
}
|
||||
$row = $row[0];
|
||||
} elseif ($mode == 'NEW') {
|
||||
foreach ($tableInfos as $key => $val) {
|
||||
if (isset($val['field'])) {
|
||||
$row[$val['field']] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($row as $key => $value) {
|
||||
$keyComment = '';
|
||||
if (isset($tableInfos[$key]['comment'])) {
|
||||
$keyComment = $tableInfos[$key]['comment'];
|
||||
}
|
||||
$templateVars = array(
|
||||
'NAME' => htmlspecialchars($key),
|
||||
'KEY' => base64_encode($key),
|
||||
'KEY_COMMENT' => Html::getJsQuote($keyComment),
|
||||
'VALUE' => htmlspecialchars($value)
|
||||
);
|
||||
$tplSqlbrowserTableShowTabledataEntry->assign_block_vars(
|
||||
'FIELD_' . ($mode == 'VIEW' ? 'VIEW' : 'EDIT'), $templateVars
|
||||
);
|
||||
}
|
||||
|
||||
$templateVars = array('RECORD_KEY' => base64_encode($rowKey));
|
||||
$tplSqlbrowserTableShowTabledataEntry->assign_block_vars(
|
||||
'FOOTER_' . $mode, $templateVars
|
||||
);
|
||||
$tplSqlbrowserTableShowTabledataEntry->pparse(
|
||||
'tplSqlbrowserTableShowTabledataEntry'
|
||||
);
|
||||
obend(true);
|
||||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren