commit 89ea01c4290f2c1973ed0a703f832072ccc0e6f2
Author: DSB
', $messages['actions']);
+}
+if (isset($messages['errors']) && is_array($messages['errors'])) {
+ $r['errors'] = implode('
', $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);
\ No newline at end of file
diff --git a/ajax/install_get_language_files.php b/ajax/install_get_language_files.php
new file mode 100644
index 0000000..d67d048
--- /dev/null
+++ b/ajax/install_get_language_files.php
@@ -0,0 +1,150 @@
+ 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);
diff --git a/ajax/restore_ajax.php b/ajax/restore_ajax.php
new file mode 100644
index 0000000..c3b3817
--- /dev/null
+++ b/ajax/restore_ajax.php
@@ -0,0 +1,369 @@
+ 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'] . '
' . $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('
', $messages['actions']);
+if (isset($messages['errors']) && is_array($messages['errors']))
+$r['errors'] = implode('
', $messages['errors']);
+$_SESSION['log'] = $_SESSION['log'] + $_SESSION['temp_log'];
+
+// save actual values to session
+$_SESSION['restore'] = $restore;
+echo $json->encode($r);
+obend(true);
diff --git a/ajax/show_log_entry.php b/ajax/show_log_entry.php
new file mode 100644
index 0000000..c6fdf4f
--- /dev/null
+++ b/ajax/show_log_entry.php
@@ -0,0 +1,121 @@
+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, '
');
+ $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);
diff --git a/ajax/show_table_field.php b/ajax/show_table_field.php
new file mode 100644
index 0000000..0d284d9
--- /dev/null
+++ b/ajax/show_table_field.php
@@ -0,0 +1,58 @@
+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);
diff --git a/ajax/show_tabledata_entry.php b/ajax/show_tabledata_entry.php
new file mode 100644
index 0000000..b451070
--- /dev/null
+++ b/ajax/show_tabledata_entry.php
@@ -0,0 +1,105 @@
+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 "Keine Datensätze gefunden!
";
+ obend(true);
+ exit();
+ } elseif (count($row) > 1) {
+ // TODO clean error handling
+ echo "Mehrere Datensätze gefunden!
";
+ }
+ $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);
\ No newline at end of file
diff --git a/css/msd/icons/ajax-loader.gif b/css/msd/icons/ajax-loader.gif
new file mode 100644
index 0000000..5b33f7e
Binary files /dev/null and b/css/msd/icons/ajax-loader.gif differ
diff --git a/css/msd/icons/arrow_down.gif b/css/msd/icons/arrow_down.gif
new file mode 100644
index 0000000..a0c49e7
Binary files /dev/null and b/css/msd/icons/arrow_down.gif differ
diff --git a/css/msd/icons/arrow_up.gif b/css/msd/icons/arrow_up.gif
new file mode 100644
index 0000000..d6dd5ad
Binary files /dev/null and b/css/msd/icons/arrow_up.gif differ
diff --git a/css/msd/icons/arrowleft.gif b/css/msd/icons/arrowleft.gif
new file mode 100644
index 0000000..292440f
Binary files /dev/null and b/css/msd/icons/arrowleft.gif differ
diff --git a/css/msd/icons/browse.gif b/css/msd/icons/browse.gif
new file mode 100644
index 0000000..af7bf1c
Binary files /dev/null and b/css/msd/icons/browse.gif differ
diff --git a/css/msd/icons/close.gif b/css/msd/icons/close.gif
new file mode 100644
index 0000000..fe48d38
Binary files /dev/null and b/css/msd/icons/close.gif differ
diff --git a/css/msd/icons/db.gif b/css/msd/icons/db.gif
new file mode 100644
index 0000000..fe181fb
Binary files /dev/null and b/css/msd/icons/db.gif differ
diff --git a/css/msd/icons/delete.gif b/css/msd/icons/delete.gif
new file mode 100644
index 0000000..eccb32f
Binary files /dev/null and b/css/msd/icons/delete.gif differ
diff --git a/css/msd/icons/download.png b/css/msd/icons/download.png
new file mode 100644
index 0000000..dd525cc
Binary files /dev/null and b/css/msd/icons/download.png differ
diff --git a/css/msd/icons/edit.gif b/css/msd/icons/edit.gif
new file mode 100644
index 0000000..c33293d
Binary files /dev/null and b/css/msd/icons/edit.gif differ
diff --git a/css/msd/icons/gz.gif b/css/msd/icons/gz.gif
new file mode 100644
index 0000000..803ed55
Binary files /dev/null and b/css/msd/icons/gz.gif differ
diff --git a/css/msd/icons/index.gif b/css/msd/icons/index.gif
new file mode 100644
index 0000000..318cdc4
Binary files /dev/null and b/css/msd/icons/index.gif differ
diff --git a/css/msd/icons/key_fulltext.gif b/css/msd/icons/key_fulltext.gif
new file mode 100644
index 0000000..80098b3
Binary files /dev/null and b/css/msd/icons/key_fulltext.gif differ
diff --git a/css/msd/icons/key_nokey.gif b/css/msd/icons/key_nokey.gif
new file mode 100644
index 0000000..fe181fb
Binary files /dev/null and b/css/msd/icons/key_nokey.gif differ
diff --git a/css/msd/icons/key_primary.gif b/css/msd/icons/key_primary.gif
new file mode 100644
index 0000000..2c20699
Binary files /dev/null and b/css/msd/icons/key_primary.gif differ
diff --git a/css/msd/icons/key_unique.gif b/css/msd/icons/key_unique.gif
new file mode 100644
index 0000000..80ad956
Binary files /dev/null and b/css/msd/icons/key_unique.gif differ
diff --git a/css/msd/icons/minus.gif b/css/msd/icons/minus.gif
new file mode 100644
index 0000000..49f6a2a
Binary files /dev/null and b/css/msd/icons/minus.gif differ
diff --git a/css/msd/icons/mysql_help.gif b/css/msd/icons/mysql_help.gif
new file mode 100644
index 0000000..b39cde9
Binary files /dev/null and b/css/msd/icons/mysql_help.gif differ
diff --git a/css/msd/icons/notok.gif b/css/msd/icons/notok.gif
new file mode 100644
index 0000000..0b2d56e
Binary files /dev/null and b/css/msd/icons/notok.gif differ
diff --git a/css/msd/icons/ok.gif b/css/msd/icons/ok.gif
new file mode 100644
index 0000000..06bb815
Binary files /dev/null and b/css/msd/icons/ok.gif differ
diff --git a/css/msd/icons/openfile.gif b/css/msd/icons/openfile.gif
new file mode 100644
index 0000000..8225ba3
Binary files /dev/null and b/css/msd/icons/openfile.gif differ
diff --git a/css/msd/icons/plus.gif b/css/msd/icons/plus.gif
new file mode 100644
index 0000000..96425a5
Binary files /dev/null and b/css/msd/icons/plus.gif differ
diff --git a/css/msd/icons/progressbar_dump.gif b/css/msd/icons/progressbar_dump.gif
new file mode 100644
index 0000000..35292ff
Binary files /dev/null and b/css/msd/icons/progressbar_dump.gif differ
diff --git a/css/msd/icons/progressbar_restore.gif b/css/msd/icons/progressbar_restore.gif
new file mode 100644
index 0000000..b9def18
Binary files /dev/null and b/css/msd/icons/progressbar_restore.gif differ
diff --git a/css/msd/icons/progressbar_speed.gif b/css/msd/icons/progressbar_speed.gif
new file mode 100644
index 0000000..a7fca58
Binary files /dev/null and b/css/msd/icons/progressbar_speed.gif differ
diff --git a/css/msd/icons/save.png b/css/msd/icons/save.png
new file mode 100644
index 0000000..9bc130e
Binary files /dev/null and b/css/msd/icons/save.png differ
diff --git a/css/msd/icons/search.gif b/css/msd/icons/search.gif
new file mode 100644
index 0000000..af7bf1c
Binary files /dev/null and b/css/msd/icons/search.gif differ
diff --git a/css/msd/icons/table_truncate.gif b/css/msd/icons/table_truncate.gif
new file mode 100644
index 0000000..0aabf51
Binary files /dev/null and b/css/msd/icons/table_truncate.gif differ
diff --git a/css/msd/icons/table_truncate_reset.gif b/css/msd/icons/table_truncate_reset.gif
new file mode 100644
index 0000000..da1f273
Binary files /dev/null and b/css/msd/icons/table_truncate_reset.gif differ
diff --git a/css/msd/icons/truncate.gif b/css/msd/icons/truncate.gif
new file mode 100644
index 0000000..eccb32f
Binary files /dev/null and b/css/msd/icons/truncate.gif differ
diff --git a/css/msd/pics/bg-body.gif b/css/msd/pics/bg-body.gif
new file mode 100644
index 0000000..4e94b13
Binary files /dev/null and b/css/msd/pics/bg-body.gif differ
diff --git a/css/msd/pics/bg-buttons.gif b/css/msd/pics/bg-buttons.gif
new file mode 100644
index 0000000..1fb2865
Binary files /dev/null and b/css/msd/pics/bg-buttons.gif differ
diff --git a/css/msd/pics/bg-headings.gif b/css/msd/pics/bg-headings.gif
new file mode 100644
index 0000000..0506a7b
Binary files /dev/null and b/css/msd/pics/bg-headings.gif differ
diff --git a/css/msd/pics/h1_logo.gif b/css/msd/pics/h1_logo.gif
new file mode 100644
index 0000000..6dc5b42
Binary files /dev/null and b/css/msd/pics/h1_logo.gif differ
diff --git a/css/msd/pics/loveyourdata.gif b/css/msd/pics/loveyourdata.gif
new file mode 100644
index 0000000..ddcc647
Binary files /dev/null and b/css/msd/pics/loveyourdata.gif differ
diff --git a/css/msd/pics/navi_bg.jpg b/css/msd/pics/navi_bg.jpg
new file mode 100644
index 0000000..018cbdd
Binary files /dev/null and b/css/msd/pics/navi_bg.jpg differ
diff --git a/css/msd/pics/navi_bg_expert.jpg b/css/msd/pics/navi_bg_expert.jpg
new file mode 100644
index 0000000..3791d98
Binary files /dev/null and b/css/msd/pics/navi_bg_expert.jpg differ
diff --git a/css/msd/pics/truck_bg.png b/css/msd/pics/truck_bg.png
new file mode 100644
index 0000000..3b81b9f
Binary files /dev/null and b/css/msd/pics/truck_bg.png differ
diff --git a/css/msd/style.css b/css/msd/style.css
new file mode 100644
index 0000000..874e841
--- /dev/null
+++ b/css/msd/style.css
@@ -0,0 +1,906 @@
+/************************************************************************************************************************
+ @MySQLDumper STYLESHEET
+ @name msd
+ @author Ingo Wagener
Mysqli: executing query: " . $query;
+ $result = $this->_mysqli->query($query);
+ if (false === $result) {
+ $this->sqlError($this->_mysqli->error, $this->_mysqli->errno);
+ }
+ if (!$result instanceof mysqli_result || $kind === self::SIMPLE) {
+ return $result;
+ }
+ $ret = array();
+ if ($kind === self::ARRAY_OBJECT) {
+ WHILE ($row = $result->fetch_object()) {
+ $ret[] = $row;
+ }
+ } elseif ($kind === self::ARRAY_NUMERIC) {
+ WHILE ($row = $result->fetch_array(MYSQLI_NUM)) {
+ $ret[] = $row;
+ }
+ } elseif ($kind === self::ARRAY_ASSOC) {
+ WHILE ($row = $result->fetch_assoc()) {
+ $ret[] = $row;
+ }
+ }
+ if ($result instanceof mysqli) {
+ $result->close();
+ }
+ return $ret;
+ }
+ /**
+ * Get table list of given database(s)
+ *
+ * Stores them in $this->tables[database]
+ * When no database is given, all databases are scanned for tables.
+ * Returns table list for selected or for all databases.
+ *
+ * @param string|array $database
+ * @return array
+ */
+ public function getTables($database = false)
+ {
+ if (!$this->_mysqli instanceof mysqli) {
+ $this->dbConnect($this->dbSelected);
+ }
+ if (!isset($this->tables)) {
+ $this->tables = array();
+ }
+ if ($database !== false) {
+ //only list tables of selected database
+ if (is_array($database)) {
+ $databases = $database;
+ } else {
+ $databases = array();
+ $databases[0] = $database;
+ }
+ } else {
+ //list tables for all databases
+ $databases = $this->databases;
+ }
+ // get tablenames for each database
+ foreach ($databases as $db) {
+ $this->tables[$db] = array();
+ $sql = 'SHOW TABLES FROM `' . $db . '`';
+ $res = $this->query($sql, self::ARRAY_NUMERIC);
+ foreach ($res as $val) {
+ $this->tables[$db][] = $val[0];
+ }
+ }
+ return is_string($database) ? $this->tables[$database] : $this->tables;
+ }
+ /**
+ * Gets extended table information for one or all tables
+ *
+ * @param string $table
+ * @param string $database
+ * @return array
+ */
+ public function getTableStatus($table = false, $database = false)
+ {
+ if ($database !== false && $database != $this->dbSelected) {
+ $this->selectDb($database);
+ }
+ if (!$this->_mysqli instanceof mysqli) {
+ $this->selectDb($this->dbSelected);
+ }
+ if (!isset($this->tableinfo)) {
+ $this->tableinfo = array();
+ }
+ if (!isset($this->tableinfo[$this->dbSelected])) {
+ $this->tableinfo[$this->dbSelected] = array();
+ }
+ $sql = 'SHOW TABLE STATUS';
+ if ($table !== false) {
+ $sql .= ' LIKE \'' . $table . '\'';
+ }
+ $res = $this->query($sql, self::ARRAY_ASSOC);
+ if (is_array($res)) {
+ foreach ($res as $r) {
+ $tablename = $r['Name'];
+ unset($r['Name']);
+ $this->tableinfo[$this->dbSelected][$tablename] = $r;
+ }
+ } elseif ($res === false) {
+ $this->sqlError($this->_mysqli->error, $this->_mysqli->errno);
+ }
+ if ($table !== false) {
+ if (isset($this->tableinfo[$this->dbSelected][$table])) {
+ return $this->tableinfo[$this->dbSelected][$table];
+ }
+ }
+ return $this->tableinfo[$this->dbSelected];
+ }
+ /**
+ * Returns the CREATE Statement of a table.
+ *
+ * @throws Exception
+ * @param string $table
+ * @param string $database
+ *
+ * @return string
+ */
+ public function getTableCreate($table, $database = false)
+ {
+ if (false === $database) {
+ $database = $this->dbSelected;
+ }
+ if ($database != $this->dbSelected) {
+ if (false === $this->selectDB($database)) {
+ $this->sqlError($this->_mysqli->error, $this->_mysqli->errno);
+ }
+ }
+ if (!$this->_mysqli instanceof mysqli) {
+ $this->dbConnect($this->dbSelected);
+ }
+ $sql = 'SHOW CREATE TABLE `' . $table . '`';
+ $res = $this->query($sql, self::ARRAY_ASSOC);
+ if (isset($res[0]['Create Table'])) {
+ return $res[0]['Create Table'];
+ } else {
+ $this->sqlError($this->_mysqli->error, $this->_mysqli->errno);
+ }
+ }
+ /**
+ * Gets the full description of all columns of a table
+ *
+ * Saves it to $this->metaTables[$database][$table].
+ *
+ * @param string $table
+ * @param string $database
+ *
+ * @return array
+ */
+ public function getTableColumns($table, $database = false)
+ {
+ if (!$this->_mysqli instanceof mysqli) {
+ $this->dbConnect($this->dbSelected);
+ }
+ if (false === $database) {
+ $database = $this->dbSelected;
+ }
+ if ($database != $this->dbSelected) {
+ if (false === $this->selectDB($database)) {
+ $this->sqlError($this->_mysqli->error, $this->_mysqli->errno);
+ }
+ }
+ $sql = 'SHOW FULL FIELDS FROM `' . $table . '`';
+ $res = $this->query($sql, self::ARRAY_ASSOC);
+ if (!isset($this->metaTables[$database])) $this->metaTables[$database] = array();
+ if (is_array($res)) {
+ $this->metaTables[$database][$table] = array();
+ foreach ($res as $r) {
+ $this->metaTables[$database][$table][$r['Field']] = $r;
+ }
+ }
+ return $this->metaTables[$database][$table];
+ }
+ /**
+ * Gets the number of affected rows for the last query
+ *
+ * @see inc/classes/db/MsdDbFactory#affectedRows()
+ * @return integer
+ */
+ public function getAffectedRows()
+ {
+ return $this->_mysqli->affected_rows;
+ }
+ /**
+ * Escape a value to use it in a query
+ *
+ * @see inc/classes/db/MsdDbFactory#escape($val)
+ * @param mixed $val The value to escape
+ *
+ * @return mixed
+ */
+ public function escape($val)
+ {
+ return $this->_mysqli->real_escape_string($val);
+ }
+ /**
+ * Optimize a table. Returns true on success or MySQL-Error.
+ *
+ * @param string $table Name of table
+ *
+ * @return boolean or string true on success or mysql_error() on failure
+ */
+ function optimizeTable($table)
+ {
+ $sql = 'OPTIMIZE TABLE `' . $this->dbSelected . '`.`' . $table . '`';
+ $res = $this->query($sql, MsdDbFactory::ARRAY_ASSOC);
+ if (isset($res[0]['Msg_text'])) {
+ return $res[0];
+ } else {
+ return false;
+ }
+ }
+
+}
diff --git a/inc/classes/helper/File.php b/inc/classes/helper/File.php
new file mode 100644
index 0000000..7cee0b8
--- /dev/null
+++ b/inc/classes/helper/File.php
@@ -0,0 +1,51 @@
+ $val) {
+ $r .= '' . "\n";
+ }
+ return $r;
+ }
+
+ /**
+ * Get HTML output for attribute "checked"
+ *
+ * @param string $val The current value
+ * @param string $checked The value for the element if it should be checked
+ * @return string Html attribute "checked" or empty string
+ */
+ public static function getChecked($val, $checked)
+ {
+ return $val == $checked ? ' checked="checked"' : '';
+ }
+
+ /**
+ * Get HTML output for attribute "disable"
+ *
+ * @param string $val The current value
+ * @param string $disabled The value for the element if disabled
+ *
+ * @return string Html attribute "disabled" or empty string
+ */
+ public static function getDisabled($val, $disabled)
+ {
+ return $val == $disabled ? ' disabled="disabled"' : '';
+ }
+ /**
+ * Get HTML output for attribute "selected"
+ *
+ * @param string $val The current value
+ * @param string $selected The value for the element if selected
+ *
+ * @return string Html attribute "selected" or empty string
+ */
+ public static function getSelected($val, $selected)
+ {
+ return $val == $selected ? ' selected="selected"' : '';
+ }
+
+ /**
+ * Convert HTML br's to new lines.
+ *
+ * @param string $str The string to convert
+ * @return string Converted string
+ */
+ public static function br2nl($str)
+ {
+ $search = array('
', '
', '
');
+ $replace = array("\n", "\n", "\n");
+ return str_replace($search, $replace, $str);
+ }
+
+ /**
+ * Escape quotes and/or slashes and double quotes.
+ *
+ * Used for escaping strings in JS-alerts and config-files.
+ *
+ * @param string $string String to escape
+ * @param boolean $escapeSlashes Escape slashes and double quotes
+ *
+ * @return string Escaped string
+ */
+ public static function getJsQuote($string, $escapeSlashes = false)
+ {
+ if ($escapeSlashes) {
+ $string = str_replace('/', '\/', $string);
+ $string = str_replace('"', '\"', $string);
+ }
+ $string = str_replace("\n", '\n', $string);
+ return str_replace("'", '\\\'', $string);
+ }
+
+ /**
+ * Replace quotes with their Html entity.
+ *
+ * Used for outputing values in HTML attributes without breaking HTML
+ *
+ * @param string $string String with quotes
+ *
+ * @return string String with replaced quotes
+ */
+ public static function replaceQuotes($string)
+ {
+ $string = str_replace("\n", '\n', $string);
+ return str_replace('"', '"', $string);
+ }
+
+ /**
+ * Escape special chars according to Perl syntax.
+ *
+ * @param string $text The string to escape
+ *
+ * @return string Escaped string
+ */
+ public static function escapeSpecialchars($string)
+ {
+ $search = array('@', '$', '\\\\', '"');
+ $replace = array('\@', '\$', '\\', '\"');
+ return str_replace($search, $replace, $string);
+ }
+
+ /**
+ * Remove added slashes recursively.
+ *
+ * @param mixed $values Array or string to remove added slashes from
+ *
+ * @return mixed Array or String with recursively removed slashes
+ */
+ public static function stripslashesDeep($values)
+ {
+ if (is_array($values)) {
+ $values = array_map('Html::stripslashesDeep', $values);
+ } else {
+ $values = stripslashes($values);
+ }
+ return $values;
+ }
+
+ /**
+ * Remove whitespaces before and after string or array.
+ *
+ * @param mixed $values Array or string to remove whitespaces from
+ *
+ * @return mixed Recursively trimmed array or string
+ */
+ public static function trimDeep($values)
+ {
+ if (is_array($values)) {
+ $values = array_map('Html::trimDeep', $values);
+ } else {
+ $values = trim($values);
+ }
+ return $values;
+ }
+ /**
+ * Build HTML-Message-String for success messages
+ *
+ * @param string $text Message to print
+ *
+ * @return string Message surrounded by HTML-Container
+ */
+ public static function getOkMsg($text)
+ {
+ $html= sprintf('%s', $text);
+ $html .= '';
+ $html .= '';
+ $html .= '
';
+ return $html;
+ }
+ /**
+ * Build HTML-Message-String for error messages
+ *
+ * @param string $text Message to print
+ *
+ * @return string Message surrounded by HTML-Container
+ */
+ public static function getErrorMsg($text)
+ {
+ $html= sprintf('%s', $text);
+ $html .= '';
+ $html .= '';
+ $html .= '
';
+ return $html;
+ }
+ /**
+ * Create IMG-Tag
+ *
+ * @param string $pic Filename of picture
+ * @param string $title Title for the picture (will alsobe used for alt-tag)
+ *
+ * @return string Built img-tag
+ */
+ public static function getIcon($pic, $title = '')
+ {
+ //TODO get value from a config class and get rid of global
+ global $config;
+ $img = '';
+ return sprintf($img, $config['files']['iconpath'], $pic, $title, $title);
+ }
+}
diff --git a/inc/classes/helper/Sql.php b/inc/classes/helper/Sql.php
new file mode 100644
index 0000000..2d13a78
--- /dev/null
+++ b/inc/classes/helper/Sql.php
@@ -0,0 +1,87 @@
+optimizeTable($table);
+ if (false !== $res) {
+ $success=array('status', 'info','warning','note');
+ if (in_array($res['Msg_type'], $success)) {
+ $logMsg = $lang['L_OPTIMIZE'].' `'.$dbo->dbSelected. '`.`';
+ $logMsg .= $table.'`: '.$res['Msg_text'];
+ $log->write(Log::PHP, $logMsg);
+ return true;
+ } else {
+ $logMsg = sprintf($lang['L_OPTIMIZE_TABLE_ERR'], $table);
+ writeToErrorLog($dbo->dbSelected, $logMsg, $res['msg_text'], 0);
+ return false;
+ }
+ } else {
+ $logMsg = sprintf($lang['L_OPTIMIZE_TABLE_ERR'], $table);
+ writeToErrorLog($dbo->dbSelecte, $logMsg, $res['msg_text'], 0);
+ return false;
+ }
+ }
+ /**
+ * Creates a INSERT INTO-string
+ *
+ * "INSERT INTO (`field1`,`field2`,..)"-Command for the given table
+ * by looking up the meta-information. Table must exists.
+ * Note: Only used when restoring a backup not from MySQLDumper containing
+ * extended inserts.
+ *
+ * @param MsdDbFactory Database object
+ * @param string $table Name of table to analyze
+ *
+ * @return string $insert The name of the table extracted from the Query
+ **/
+ public static function getInsertSyntax(MsdDbFactory $dbo, $table)
+ {
+ $insert = '';
+ $columns=$dbo->getTableColumns($table);
+ $fields=array_keys($columns);
+ $insert = 'INSERT INTO `' . $table . '` (`';
+ $insert .=implode('`,`', $fields) . '`)';
+ return $insert;
+ }
+ /**
+ * Disables keys for given table
+ *
+ * @param MsdDbFactory $dbo Database object
+ * @param string $table Name of table
+ *
+ * @return bool
+ */
+ public static function disableKeys(MsdDbFactory $dbo, $table)
+ {
+ $query = '/*!40000 ALTER TABLE `' . $table . '` DISABLE KEYS */';
+ return $dbo->query($query, MsdDbFactory::SIMPLE);
+ }
+}
diff --git a/inc/classes/helper/String.php b/inc/classes/helper/String.php
new file mode 100644
index 0000000..0fc00a4
--- /dev/null
+++ b/inc/classes/helper/String.php
@@ -0,0 +1,37 @@
+ '') {
+ $tmpConfigfilename = utf8_decode(trim($_POST['new_configurationfile']));
+ if (!preg_match("/^[a-z.-_]+$/i", $tmpConfigfilename, $matches)) {
+ $msg = sprintf(
+ $lang['L_ERROR_CONFIGFILE_NAME'],
+ $_POST['new_configurationfile']
+ );
+ $msg = Html::getErrorMsg($msg);
+ } else {
+ $config['config_file'] = $_POST['new_configurationfile'];
+ $config['cron_configurationfile'] = $_POST['new_configurationfile']
+ . ".conf.php";
+ $saveConfig = true;
+ }
+
+ if ($saveConfig) {
+ if (saveConfig() == true) {
+ $saveConfig = false;
+ $msg = sprintf(
+ $lang['L_SUCCESS_CONFIGFILE_CREATED'],
+ $_POST['new_configurationfile']
+ );
+ $msg = Html::getOkMsg($msg);
+ } else {
+ $msg = Html::getErrorMsg($lang['L_SAVE_ERROR']);
+ $saveConfig = false;
+ }
+ }
+ } else {
+ $msg = Html::getErrorMsg($lang['L_NO_NAME_GIVEN']);
+ }
+}
+
+if ($saveConfig) {
+ // validation was fine, we can write the values to the actual config file
+ if (saveConfig() == true) {
+ getConfig($config['config_file']);
+ if ($config['logcompression'] != $oldlogcompression) {
+ deleteLog();
+ }
+ $msg = sprintf($lang['L_SAVE_SUCCESS'], $config['config_file']);
+ $msg = Html::getOkMsg($msg);
+ } else {
+ $msg = Html::getErrorMsg($lang['L_SAVE_ERROR']);
+ }
+}
+include ('./inc/configuration/config_files.php');
+include ('./inc/configuration/config_menu.php');
+include ('./inc/configuration/footer.php');
diff --git a/inc/configuration/autodelete.php b/inc/configuration/autodelete.php
new file mode 100644
index 0000000..b064fc4
--- /dev/null
+++ b/inc/configuration/autodelete.php
@@ -0,0 +1,46 @@
+set_filenames(
+ array(
+ 'tplConfigurationAutodelete' => 'tpl/configuration/autodelete.tpl')
+);
+
+$tplConfigurationAutodelete->assign_vars(
+ array(
+ 'ICON_SAVE' => $icon['small']['save'],
+ 'AUTODELETE_ENABLED_SELECTED' =>
+ Html::getChecked($config['auto_delete']['activated'], 1),
+ 'AUTODELETE_DISABLED_SELECTED' =>
+ Html::getChecked($config['auto_delete']['activated'], 0),
+ 'MAX_BACKUP_FILES' =>
+ (int) $config['auto_delete']['max_backup_files'],
+ 'MAX_BACKUP_FILES_DISABLED' =>
+ Html::getDisabled($config['auto_delete']['activated'], 0))
+);
\ No newline at end of file
diff --git a/inc/configuration/config_files.php b/inc/configuration/config_files.php
new file mode 100644
index 0000000..fa3a331
--- /dev/null
+++ b/inc/configuration/config_files.php
@@ -0,0 +1,206 @@
+'
+ . sprintf($lang['L_CONFIG_LOADED'], $config['config_file'])
+ . '
' + . sprintf( + $lang['L_ERROR_LOADING_CONFIGFILE'], + $config['config_file'] + ) . '
'; + } +} + +if (isset($_GET['config_delete'])) { + $deleteConfig = urldecode($_GET['config_delete']); + if ($deleteConfig == $config['config_file']) { + //actaul configuration was deleted, fall back to mysqldumper-conf + $config['config_file'] = 'mysqldumper'; + $_SESSION['config_file'] = $config['config_file']; + getConfig($config['config_file']); + } + $del = @unlink('./' . $config['paths']['config'] . $deleteConfig . '.php'); + if ($del) { + // delete Perl config file + $delFile = $config['paths']['config'] . $deleteConfig . '.conf.php'; + $del = @unlink('./' . $delFile); + } + if ($del === false) { + $msg = '' + . sprintf($lang['L_ERROR_DELETING_CONFIGFILE'], $deleteConfig) + . '
'; + } else { + $msg = '' + . sprintf($lang['L_SUCCESS_DELETING_CONFIGFILE'], $deleteConfig) + . '
'; + } + $sel = 'configs'; +} + +$tplConfigurationConfigFiles = new MSDTemplate(); +$tplConfigurationConfigFiles->set_filenames( + array( + 'tplConfigurationConfigFiles' => 'tpl/configuration/configFiles.tpl' + ) +); +$tplConfigurationConfigFiles->assign_vars( + array( + 'ICON_SAVE' => $icon['small']['save'], + 'ICON_SEARCH' => $icon['search'], + 'ICON_EDIT' => $icon['edit'], + 'ICON_DELETE' => $icon['delete'] + ) +); +$i = 0; +$configs = getConfigFilenames(); +// iterate config files and print settings to screen +foreach ($configs as $c) { + $i++; + unset($databases); + $databases = array(); + getConfig($c); + $rowclass = ($i % 2) ? 'dbrow' : 'dbrow1'; + if ($oldConfig == $c) { + $rowclass = 'dbrowsel'; // highlight active configuration + } + // Generate configuration output + $outputstringMultisettings = ''; + $dbsToBackup = array(); + // look up which databases are set to be dumped + prepareDumpProcess(); + $dbs = array_keys($dump['databases']); + $dbsToBackup = implode(', ', $dbs); + + $tplConfigurationConfigFiles->assign_block_vars( + 'ROW', + array( + 'ROWCLASS' => $rowclass, + 'NR' => $i, + 'CONFIG_ID' => sprintf("%03d", $i), + 'CONFIG_NAME' => $c, + 'CONFIG_NAME_URLENCODED' => urlencode($c), + 'DB_HOST' => $config['dbhost'], + 'DB_USER' => $config['dbuser'], + 'NR_OF_DATABASES' => sizeof($databases), + 'DBS_TO_BACKUP' => $dbsToBackup . ' ', + 'ATTACH_BACKUP' => + $config['email']['attach_backup'] == 1 ? + $lang['L_YES'] : $lang['L_NO'] + ) + ); + + if (count($databases) > 0) { + $a = 1; + foreach ($databases as $dbName => $val) { + $tplConfigurationConfigFiles->assign_block_vars( + 'ROW.LIST_DBS', + array( + 'ROWCLASS' => $a % 2 ? 'dbrow' : 'dbrow1', + 'NR' => $a, + 'DB_NAME_URLENCODED' => base64_encode($dbName), + 'DB_NAME' => $dbName + ) + ); + $a++; + } + } + + // is Multipart used? + if ($config['multi_part'] == 1) { + $tplConfigurationConfigFiles->assign_block_vars( + 'ROW.USE_MULTIPART', + array( + 'MULTIPART_FILESIZE' => + byteOutput($config['multipart_groesse']) + ) + ); + } + + // send mail after backup? + if ($config['send_mail'] == 1) { + $recipientsCc = implodeSubarray( + $config['email']['recipient_cc'], + 'address' + ); + if ($config['email']['recipient_name'] > '') { + $recipient = $config['email']['recipient_name']; + } else { + $recipient = $config['email']['recipient_address']; + } + $tplConfigurationConfigFiles->assign_block_vars( + 'ROW.SEND_EMAIL', + array( + 'RECIPIENT' => $recipient, + 'RECIPIENT_CC' => + $recipientsCc > '' ? $recipientsCc : $lang['L_NO'] + ) + ); + $bytes = $config['email_maxsize1'] * 1024; + if ($config['email_maxsize2'] == 2) $bytes = $bytes * 1024; + if ($config['email']['attach_backup'] == 1) { + $tplConfigurationConfigFiles->assign_block_vars( + 'ROW.SEND_EMAIL.EMAIL_MAX_SIZE', + array( + 'SIZE' => byteOutput($bytes) + ) + ); + } + } + + // FTP settings + foreach ($config['ftp'] as $ftp) { + if ($ftp['transfer'] > 0) { + $ftpSettings = sprintf( + $lang['L_FTP_SEND_TO'], $ftp['server'], $ftp['dir'] + ); + $tplConfigurationConfigFiles->assign_block_vars( + 'ROW.SEND_FTP', + array( + 'FTP_SETTINGS' => Html::replaceQuotes($ftpSettings) + ) + ); + } + } + + // Show delete-button if it is not the standard config file + if ($c != 'mysqldumper') { + $confirmDelete = sprintf($lang['L_CONFIRM_CONFIGFILE_DELETE'], $c); + $tplConfigurationConfigFiles->assign_block_vars( + 'ROW.DELETE_CONFIG', + array( + 'CONFIRM_DELETE' => Html::getJsQuote($confirmDelete) + ) + ); + } +} + +unset($databases); +$databases = array(); +$_SESSION['config_file'] = $oldConfig; +$config['config_file'] = $oldConfig; +// reload actual configuration +getConfig($oldConfig); diff --git a/inc/configuration/config_menu.php b/inc/configuration/config_menu.php new file mode 100644 index 0000000..41667ad --- /dev/null +++ b/inc/configuration/config_menu.php @@ -0,0 +1,31 @@ +set_filenames( + array( + 'tplConfigurationConfigMenu' => 'tpl/configuration/config_menu.tpl' + ) +); + +$msdMode = $lang['L_MODE_EXPERT']; +if ($config['msd_mode'] == 0) { + $msdMode = $lang['L_MODE_EASY']; +} +$tplConfigurationConfigMenu->assign_vars( + array( + 'CONFIGURATION_NAME' => $config['config_file'], + 'ICON_SAVE' => $icon['small']['save'], + 'ICON_OPEN_FILE' => $icon['small']['open_file'], + 'MSD_MODE' => $msdMode + ) +); diff --git a/inc/configuration/cronscript.php b/inc/configuration/cronscript.php new file mode 100644 index 0000000..1817c10 --- /dev/null +++ b/inc/configuration/cronscript.php @@ -0,0 +1,69 @@ + 1 + && substr($config['cron_execution_path'], -1) != '/') { + $config['cron_execution_path'] .= '/'; + } + if (isset($_POST['cron_printout'])) { + $config['cron_printout'] = (int) $_POST['cron_printout']; + } + if (isset($_POST['cron_completelog'])) { + $config['cron_completelog'] = (int) $_POST['cron_completelog']; + } + if (isset($_POST['compression'])) { + $config['cron_compression'] = (int) $_POST['compression']; + } + if (isset($_POST['cron_completelog'])) { + $config['cron_completelog'] = (int) $_POST['cron_completelog']; + } +} + +$tplConfigurationCronscript = new MSDTemplate(); +$tplConfigurationCronscript->set_filenames( + array('tplConfigurationCronscript' => 'tpl/configuration/cronscript.tpl') +); + +$tplConfigurationCronscript->assign_vars( + array( + 'ICON_SAVE' => $icon['small']['save'], + 'EXTENSION_PL_SELECTED' => + Html::getChecked($config['cron_extender'], 0), + 'EXTENSION_CGI_SELECTED' => + Html::getChecked($config['cron_extender'], 1), + 'EXEC_PATH' => $config['cron_execution_path'], + 'CRON_PRINTOUT_ENABLED_SELECTED' => + Html::getChecked($config['cron_printout'], 1), + 'CRON_PRINTOUT_DISABLED_SELECTED' => + Html::getChecked($config['cron_printout'], 0), + 'CRON_COMPLETELOG_ENABLED_SELECTED' => + Html::getChecked($config['cron_completelog'], 1), + 'CRON_COMPLETELOG_DISABLED_SELECTED' => + Html::getChecked($config['cron_completelog'], 0), + 'CRON_COMMENT' => + htmlspecialchars($config['cron_comment'], ENT_COMPAT, 'UTF-8') + ) +); diff --git a/inc/configuration/databases.php b/inc/configuration/databases.php new file mode 100644 index 0000000..fe344b3 --- /dev/null +++ b/inc/configuration/databases.php @@ -0,0 +1,174 @@ + 0) { + $i = 0; + foreach ($databases as $dbName => $val) { + $databases[$dbName]['prefix'] = ''; + if (isset($_POST['dbpraefix_' . $i])) { + $databases[$dbName]['prefix'] = $_POST['dbpraefix_' . $i]; + } + $databases[$dbName]['command_before_dump'] = ''; + if (!empty($_POST['command_before_' . $i])) { + $databases[$dbName]['command_before_dump'] = + getQueryFromSqlLibrary($_POST['command_before_' . $i]); + } + $databases[$dbName]['command_after_dump'] = ''; + if (!empty($_POST['command_after_' . $i])) { + $databases[$dbName]['command_after_dump'] = + getQueryFromSqlLibrary($_POST['command_after_' . $i]); + } + if (isset($_POST['db_multidump_' . $i]) + && $_POST['db_multidump_' . $i] == "db_multidump_$i") { + $databases[$dbName]['dump'] = 1; + } else { + $databases[$dbName]['dump'] = 0; + } + $i++; + } + } + if ($config['dbhost'] != $_POST['dbhost'] + || $config['dbuser'] != $_POST['dbuser'] + || $config['dbpass'] != $_POST['dbpass'] + || $config['dbport'] != $_POST['dbport'] + || $config['dbsocket'] != $_POST['dbsocket']) { + //neue Verbindungsparameter + $blendInConnectionParams = true; + //alte Parameter sichern + $old['dbhost'] = $config['dbhost']; + $old['dbuser'] = $config['dbuser']; + $old['dbpass'] = $config['dbpass']; + $old['dbport'] = $config['dbport']; + $old['dbsocket'] = $config['dbsocket']; + //neu setzen + $config['dbhost'] = $_POST['dbhost']; + $config['dbuser'] = $_POST['dbuser']; + $config['dbpass'] = $_POST['dbpass']; + $config['dbport'] = $_POST['dbport']; + $config['dbsocket'] = $_POST['dbsocket']; + $dbo = MsdDbFactory::getAdapter( + $config['dbhost'], + $config['dbuser'], + $config['dbpass'], + $config['dbport'], + $config['dbsocket'] + ); + // try to connect with new params + $res = $dbo->dbConnect(); + if ($res === true) { + // ok - get list of databases + $dbo->getDatabases(); + setDefaultConfig(); + } else { + //something went wrong - resume old values + $config['dbhost'] = $old['dbhost']; + $config['dbuser'] = $old['dbuser']; + $config['dbpass'] = $old['dbpass']; + $config['dbport'] = $old['dbport']; + $config['dbsocket'] = $old['dbsocket']; + $msg .= '' . $lang['L_WRONG_CONNECTIONPARS'] . ': ' . $res . '
'; + $saveConfig = false; + $dbo = MsdDbFactory::getAdapter( + $config['dbhost'], + $config['dbuser'], + $config['dbpass'], + $config['dbport'], + $config['dbsocket'] + ); + } + } + // manual adding of a database + if ($_POST['add_db_manual'] > '') { + $saveConfig = false; + $blendInConnectionParams = true; + $dbToAdd = trim($_POST['add_db_manual']); + $found = false; + // Check if we already have this one in our db list + if (isset($databases[$dbToAdd])) { + $addDbMessage = sprintf($lang['L_DB_IN_LIST'], $dbToAdd); + } else { + $dbo = MsdDbFactory::getAdapter( + $config['dbhost'], + $config['dbuser'], + $config['dbpass'], + $config['dbport'], + $config['dbsocket'] + ); + try { + $dbo->selectDb($dbToAdd, true); + addDatabaseToConfig($dbToAdd); + $saveConfig = true; + } catch (Exception $e){ + $addDbMessage = $lang['L_ERROR'] . ': (' . $e->getCode() . ') '; + $addDbMessage .= $e->getMessage(); + } + } + } +} +$tplConfigurationDatabases = new MSDTemplate(); +$tplConfigurationDatabases->set_filenames( + array('tplConfigurationDatabases' => 'tpl/configuration/databases.tpl') +); +$tplConfigurationDatabases->assign_vars( + array( + 'ICON_SAVE' => $icon['small']['save'], + 'DB_HOST' => $config['dbhost'], + 'DB_USER' => $config['dbuser'], + 'DB_PASS' => $config['dbpass'], + 'DB_PORT' => $config['dbport'], + 'DB_SOCKET' => $config['dbsocket'], + 'ICON_EDIT' => $icon['edit'], + 'ICON_DOWN' => $icon['arrow_down'], + 'ICON_PLUS' => $icon['plus'], + 'ICON_MINUS' => $icon['minus']) +); +if (isset($addDbMessage) && $addDbMessage > '') + $tplConfigurationDatabases->assign_block_vars( + 'MANUAL_DB_ADD', array('MESSAGE' => $addDbMessage) +); + //Wenn Datenbanken vorhanden sind +if (count($databases) > 0) { + $dbCount = count($databases); + $tplConfigurationDatabases->assign_block_vars( + 'DBS', array('DB_COUNT' => $dbCount) + ); + $i = 0; + foreach ($databases as $dbName => $val) { + if (!isset($val['dump'])) { + $val['dump'] = 0; + } + if (!isset($val['prefix'])) { + $val['prefix'] = ''; + } + $rowclass = $i % 2 ? 'dbrow' : 'dbrow1'; + if ($dbName == $config['db_actual']) { + $rowclass = 'dbrowsel'; + } + $tplConfigurationDatabases->assign_block_vars( + 'DBS.ROW', array( + 'ROWCLASS' => $rowclass, + 'ID' => $i, + 'NR' => $i + 1, + 'DB_NAME' => $dbName, + 'DB_MULTIDUMP_ENABLED' => Html::getChecked($val['dump'], 1), + 'DB_PREFIX' => $val['prefix'], + 'COMMAND_BEFORE_BACKUP_COMBO' => getCommandDumpComboBox(0, $i, $dbName), + 'COMMAND_AFTER_BACKUP_COMBO' => getCommandDumpComboBox(1, $i, $dbName)) + ); + $i++; + } +} else { + $tplConfigurationDatabases->assign_block_vars('NO_DB', array()); +} diff --git a/inc/configuration/email.php b/inc/configuration/email.php new file mode 100644 index 0000000..dd870e6 --- /dev/null +++ b/inc/configuration/email.php @@ -0,0 +1,184 @@ + $val) { + $config['email']['recipient_cc'][$i] = array(); + $config['email']['recipient_cc'][$i]['name'] = $val['name']; + $config['email']['recipient_cc'][$i]['address'] = $val['address']; + $i++; + } + } + if (isset($_POST['email_sender_name'])) { + $config['email']['sender_name'] = $_POST['email_sender_name']; + } + if (isset($_POST['email_sender_address'])) { + $config['email']['sender_address'] = $_POST['email_sender_address']; + } + if (isset($_POST['attach_backup'])) { + $config['email']['sender_address'] = $_POST['attach_backup']; + } + if (isset($_POST['email_maxsize1'])) { + $config['email_maxsize1'] = floatval($_POST['email_maxsize1']); + } + if (isset($_POST['email_maxsize2'])) { + $config['email_maxsize2'] = $_POST['email_maxsize2']; + } + $config['email_maxsize'] = $config['email_maxsize1'] + * (($config['email_maxsize2'] == 1) ? 1024 : 1024 * 1024); + if (isset($_POST['use_mailer'])) { + $config['use_mailer'] = $_POST['use_mailer']; + } + if (isset($_POST['sendmail_call'])) { + $config['sendmail_call'] = $_POST['sendmail_call']; + } + if (isset($_POST['smtp_server'])) { + $config['smtp_server'] = $_POST['smtp_server']; + } + if (isset($_POST['smtp_user'])) { + $config['smtp_user'] = $_POST['smtp_user']; + } + if (isset($_POST['smtp_pass'])) { + $config['smtp_pass'] = $_POST['smtp_pass']; + } + if (isset($_POST['smtp_useauth'])) { + $config['smtp_useauth'] = $_POST['smtp_useauth']; + } + if (isset($_POST['smtp_usessl'])) { + $config['smtp_usessl'] = $_POST['smtp_usessl']; + } + if (isset($_POST['smtp_port'])) { + $config['smtp_port'] = (int) $_POST['smtp_port']; + } + if (isset($_POST['smtp_pop3_server'])) { + $config['smtp_pop3_server'] = (string) $_POST['smtp_pop3_server']; + } + if (isset($_POST['smtp_pop3_port'])) { + $config['smtp_pop3_port'] = (int) $_POST['smtp_pop3_port']; + } +} + +// backwards compatibilty with older configurations +if (!isset($config['email_maxsize1'])) { + $config['email_maxsize1'] = 0; +} +if (!isset($config['email_maxsize2'])) { + $config['email_maxsize2'] = 1; +} +$tplConfigurationEmail = new MSDTemplate(); +$tplConfigurationEmail->set_filenames( + array('tplConfigurationEmail' => 'tpl/configuration/email.tpl') +); + +$tplConfigurationEmail->assign_vars( + array( + 'ICON_SAVE' => $icon['small']['save'], + 'ICON_PLUS' => $icon['plus'], + 'ICON_DELETE' => $icon['delete'], + 'SEND_MAIL_ENABLED_SELECTED' => Html::getChecked($config['send_mail'], 1), + 'EMAIL_DISABLED' => Html::getDisabled($config['send_mail'], 0), + 'SEND_MAIL_DISABLED_SELECTED' => Html::getChecked($config['send_mail'], 0), + 'EMAIL_RECIPIENT_NAME' => + Html::replaceQuotes($config['email']['recipient_name']), + 'EMAIL_RECIPIENT_ADDRESS' => + Html::replaceQuotes($config['email']['recipient_address']), + 'EMAIL_SENDER_NAME' => Html::replaceQuotes($config['email']['sender_name']), + 'EMAIL_SENDER_ADDRESS' => + Html::replaceQuotes($config['email']['sender_address']), + 'ATTACH_BACKUP_ENABLED_SELECTED' => + Html::getChecked($config['email']['attach_backup'], 1), + 'ATTACH_BACKUP_DISABLED_SELECTED' => + Html::getChecked($config['email']['attach_backup'], 0), + 'MAXSIZE_DISABLED' => + Html::getDisabled($config['email']['attach_backup'], 0), + 'EMAIL_MAXSIZE' => $config['email_maxsize1'], + 'EMAIL_UNIT_SIZE_KB_SELECTED' => + Html::getSelected($config['email_maxsize2'], 1), + 'EMAIL_UNIT_SIZE_MB_SELECTED' => + Html::getSelected($config['email_maxsize2'], 2), + 'EMAIL_USE_PHPMAIL_SELECTED' => Html::getChecked($config['use_mailer'], 0), + 'EMAIL_USE_SENDMAIL_SELECTED' => Html::getChecked($config['use_mailer'], 1), + 'EMAIL_USE_SMTP_SELECTED' => Html::getChecked($config['use_mailer'], 2), + 'SENDMAIL_CALL' => Html::replaceQuotes($config['sendmail_call']), + 'SMTP_SERVER' => $config['smtp_server'], + 'SMTP_USER' => $config['smtp_user'], + 'SMTP_PASS' => $config['smtp_pass'], + 'SMTP_AUTH_DISABLED' => Html::getDisabled($config['smtp_useauth'], 0), + 'SMTP_AUTH_SELECTED' => Html::getChecked($config['smtp_useauth'], 1), + 'SMTP_AUTH_NOT_SELECTED' => Html::getChecked($config['smtp_useauth'], 0), + 'SMTP_SSL_SELECTED' => Html::getChecked($config['smtp_usessl'], 1), + 'SMTP_SSL_NOT_SELECTED' => Html::getChecked($config['smtp_usessl'], 0), + 'SMTP_PORT' => $config['smtp_port'], + 'SMTP_POP3_SERVER' => $config['smtp_pop3_server'], + 'SMTP_POP3_PORT' => $config['smtp_pop3_port']) +); +if ($config['smtp_useauth'] == 0) { + $tplConfigurationEmail->assign_block_vars('HIDE_SMTP_AUTH_FIELDS', array()); +} +if (is_array($config['email']['recipient_cc']) + && sizeof($config['email']['recipient_cc']) > 0) { + foreach ($config['email']['recipient_cc'] as $key => $val) { + $confirmRecDelete = sprintf( + $lang['L_CONFIRM_RECIPIENT_DELETE'], + $val['name'] . ' ' . $val['address'] + ); + $confirmRecDelete = Html::replaceQuotes($confirmRecDelete); + + $tplConfigurationEmail->assign_block_vars( + 'EMAIL_RECIPIENT_CC', + array( + 'NR' => $key, + 'CONFIRM_RECIPIENT_DELETE' => $confirmRecDelete, + 'EMAIL_RECIPIENT_CC_NAME' => Html::replaceQuotes($val['name']), + 'EMAIL_RECIPIENT_CC_ADDRESS' => + Html::replaceQuotes($val['address']) + ) + ); + } +} \ No newline at end of file diff --git a/inc/configuration/footer.php b/inc/configuration/footer.php new file mode 100644 index 0000000..0003929 --- /dev/null +++ b/inc/configuration/footer.php @@ -0,0 +1,44 @@ +set_filenames( + array('tplConfigurationFooter' => 'tpl/configuration/footer.tpl') +); + +$tplConfigurationFooter->assign_vars( + array( + 'SELECTED_DIV' => $sel, + 'NOTIFICATION_POSITION' => $config['notification_position'] + ) +); + +//output notification message if we have one +if ($msg > '') { + $tplConfigurationFooter->assign_block_vars( + 'MESSAGE', array('TEXT' => Html::getJsQuote($msg, true)) + ); +} +// if something went wrong with the change of a user or no database was found +// -> blend in connection params and let the user correct it +if ( (isset($blendInConnectionParams) && $blendInConnectionParams) + || count($databases) == 0) { + $tplConfigurationFooter->assign_block_vars( + 'SWITCH_TO_CONNECTION_PARAMETER', array() + ); +} \ No newline at end of file diff --git a/inc/configuration/ftp.php b/inc/configuration/ftp.php new file mode 100644 index 0000000..27dd91b --- /dev/null +++ b/inc/configuration/ftp.php @@ -0,0 +1,156 @@ + $val) { + // set default values if this connection is a new one + if (!isset($config['ftp'][$key]) || !is_array($config['ftp'][$key])) { + $config['ftp'][$key] = array(); + } + if (!isset($config['ftp'][$key]['server'])) { + $config['ftp'][$key]['server'] = ''; + } + if (!isset($config['ftp'][$key]['transfer'])) { + $config['ftp'][$key]['transfer'] = 0; + } + if (!isset($config['ftp'][$key]['timeout'])) { + $config['ftp'][$key]['timeout'] = 10; + } + if (!isset($config['ftp'][$key]['ssl'])) { + $config['ftp'][$key]['ssl'] = 0; + } + if (!isset($config['ftp'][$key]['mode'])) { + $config['ftp'][$key]['mode'] = 0; + } + if (!isset($config['ftp'][$key]['port'])) { + $config['ftp'][$key]['port'] = 21; + } + if (!isset($config['ftp'][$key]['user'])) { + $config['ftp'][$key]['user'] = ''; + } + if (!isset($config['ftp'][$key]['pass'])) { + $config['ftp'][$key]['pass'] = ''; + } + if (!isset($config['ftp'][$key]['dir'])) { + $config['ftp'][$key]['dir'] = '/'; + } + if (isset($val['transfer'])) { + $config['ftp'][$key]['transfer'] = (int) $val['transfer']; + } + if (isset($val['server'])) { + $config['ftp'][$key]['server'] = (string) $val['server']; + } + if (isset($val['timeout'])) { + $config['ftp'][$key]['timeout'] = (int) $val['timeout']; + } + if (isset($val['ssl'])) { + $config['ftp'][$key]['ssl'] = (int) $val['ssl']; + } + if (isset($val['mode'])) { + $config['ftp'][$key]['mode'] = (int) $val['mode']; + } + if (isset($val['port'])) { + $config['ftp'][$key]['port'] = (int) $val['port']; + } + if (isset($val['user'])) { + $config['ftp'][$key]['user'] = (string) $val['user']; + } + if (isset($val['pass'])) { + $config['ftp'][$key]['pass'] = (string) $val['pass']; + } + if (isset($val['dir'])) { + $config['ftp'][$key]['dir'] = (string) $val['dir']; + } + if ($config['ftp'][$key]['dir'] == '' + || (strlen($config['ftp'][$key]['dir']) > 1 + && substr($config['ftp'][$key]['dir'], -1) != '/')) { + $config['ftp'][$key]['dir'] .= '/'; + } + if (isset($_POST['ftp'][$key]['test'])) { + $ftpConnectionCheck[$key] = testFTP($key); + // don't save values - we just want to test the ftp connection data + $saveConfig = false; + } + } +} + +if (isset($_GET['del_ftp'])) { + $index = intval($_GET['del_ftp']); + if (isset($config['ftp'][$index])) { + unset($config['ftp'][$index]); + } + sort($config['ftp']); +} + +$tplConfigurationFtp = new MSDTemplate(); +$tplConfigurationFtp->set_filenames( + array('tplConfigurationFtp' => 'tpl/configuration/ftp.tpl') +); + +$tplConfigurationFtp->assign_vars( + array( + 'ICON_ADD' => $icon['plus'], + 'ICON_DELETE' => $icon['delete'], + 'ICON_SAVE' => $icon['small']['save'] + ) +); + +foreach ($config['ftp'] as $key => $val) { + // if ftp extension is not loaded -> disable ftp transfer + if (!extension_loaded('ftp')) { + $config['ftp'][$key]['transfer'] = 0; + } + + $tplConfigurationFtp->assign_block_vars( + 'FTP', + array( + 'NR' => $key + 1, + 'ID' => $key, + 'FTP_DISABLED' => Html::getDisabled(!extension_loaded("ftp"), true), + 'FTP_ENABLED_SELECTED' => Html::getChecked($val['transfer'], 1), + 'FTP_DISABLED_SELECTED' => Html::getChecked($val['transfer'], 0), + 'FTP_FIELDS_DISABLED' => Html::getDisabled($val['transfer'], 0), + 'FTP_TIMEOUT' => $val['timeout'], + 'FTP_PASSIVE_MODE_SELECTED' => Html::getChecked($val['mode'], 1), + 'FTP_SSL_DISABLED' => + Html::getDisabled(extension_loaded('openssl'), false), + 'FTP_SSL_ENABLED_SELECTED' => Html::getChecked($val['ssl'], 1), + 'FTP_SERVER' => $config['ftp'][$key]['server'], + 'FTP_PORT' => $val['port'], + 'FTP_USER' => Html::replaceQuotes($val['user']), + 'FTP_PASSWORD' => Html::replaceQuotes($val['pass']), + 'FTP_DIRECTORY' => $val['dir'], + 'FTP_CONFIRM_DELETE' => + Html::replaceQuotes($lang['L_FTP_CONFIRM_DELETE']) + ) + ); + if (isset($ftpConnectionCheck[$key])) { + $tplConfigurationFtp->assign_block_vars( + 'FTP.CHECK', array('RESULT' => $ftpConnectionCheck[$key]) + ); + } +} diff --git a/inc/configuration/general.php b/inc/configuration/general.php new file mode 100644 index 0000000..e45d174 --- /dev/null +++ b/inc/configuration/general.php @@ -0,0 +1,146 @@ + delete old log file + $oldlogcompression = $config['logcompression']; + if (isset($_POST['logcompression'])) { + $config['logcompression'] = $_POST['logcompression']; + } else { + $config['logcompression'] = 0; + } + // if zlib-extension is not installed de-activate compression + // for log and dump file automatically + if (!$config['zlib']) { + $config['logcompression'] = 0; + $config['compression'] = 0; + } + // max size of logfiles + if (isset($_POST['log_maxsize1'])) { + $config['log_maxsize1'] = (int) $_POST['log_maxsize1']; + } + if (isset($_POST['log_maxsize2'])) { + $config['log_maxsize2'] = (int) $_POST['log_maxsize2']; + } + if ($config['log_maxsize1'] < 1) { + $config['log_maxsize1'] = 1; + } + if ($config['log_maxsize1'] < 100 && $config['log_maxsize2'] == 1) { + $config['log_maxsize1'] = 100; + } + if ($config['log_maxsize2'] == 1) { + $config['log_maxsize'] = 1024 * $config['log_maxsize1']; // kB + } else { + $config['log_maxsize'] = 1024 * 1024 * $config['log_maxsize1']; // MB + } + if (isset($_POST['empty_db_before_restore'])) { + $config['empty_db_before_restore'] = + (int) $_POST['empty_db_before_restore']; + } + if (isset($_POST['optimize_tables'])) { + $config['optimize_tables_beforedump'] = (int) $_POST['optimize_tables']; + } + //if we are not in mode expert -> reset hidden settings to safe defaults + if ($config['msd_mode'] == 0) { + $config['empty_db_before_restore'] = 0; + } +} + +$tplConfigurationGeneral = new MSDTemplate(); +$tplConfigurationGeneral->set_filenames( + array('tplConfigurationGeneral' => 'tpl/configuration/general.tpl') +); +if ($config['msd_mode'] > 0) { + $tplConfigurationGeneral->assign_block_vars('MODE_EXPERT', array()); +} +$logGz = !$config['zlib'] ? '' : Html::getChecked($config['logcompression'], 1); + +$tplConfigurationGeneral->assign_vars( + array( + 'ICON_SAVE' => $icon['small']['save'], + 'MSD_MODE_EASY_SELECTED' => Html::getChecked($config['msd_mode'], 0), + 'MSD_MODE_EXPERT_SELECTED' => Html::getChecked($config['msd_mode'], 1), + 'GZ_DISABLED' => Html::getDisabled($config['zlib'], 0), + 'LOG_GZ_SELECTED' => $logGz, + 'LOG_MAXSIZE1' => $config['log_maxsize1'], + 'LOG_UNIT_KB_SELECTED' => Html::getSelected($config['log_maxsize2'], 1), + 'LOG_UNIT_MB_SELECTED' => Html::getSelected($config['log_maxsize2'], 2), + 'PHP_MEMORY_LIMIT' => $config['memory_limit'], + 'MIN_SPEED' => $config['minspeed'], + 'MAX_SPEED' => $config['maxspeed'], + 'DUMP_GZ_ENABLED_SELECTED' => + Html::getChecked($config['compression'], 1), + 'DUMP_GZ_DISABLED_SELECTED' => + Html::getChecked($config['compression'], 0), + 'MULTIPART_ENABLED_SELECTED' => + Html::getChecked($config['multi_part'], 1), + 'MULTIPART_DISABLED_SELECTED' => + Html::getChecked($config['multi_part'], 0), + 'MULTIPART_FILE_SIZE' => $config['multipartgroesse1'], + 'MULTIPART_DISABLED' => Html::getDisabled($config['multi_part'], 0), + 'MULTIPART_FILE_SIZE_DISABLED' => + Html::getDisabled($config['multi_part'], 0), + 'MULTIPART_FILE_UNIT_KB_SELECTED' => + Html::getSelected($config['multipartgroesse2'], 1), + 'MULTIPART_FILE_UNIT_MB_SELECTED' => + Html::getSelected($config['multipartgroesse2'], 2), + 'OPTIMIZE_TABLES_ENABLED_SELECTED' => + Html::getChecked($config['optimize_tables_beforedump'], 1), + 'OPTIMIZE_TABLES_DISABLED_SELECTED' => + Html::getChecked($config['optimize_tables_beforedump'], 0), + 'TRUNCATE_DB_ENABLED_SELECTED' => + Html::getChecked($config['empty_db_before_restore'], 1), + 'TRUNCATE_DB_DISABLED_SELECTED' => + Html::getChecked($config['empty_db_before_restore'], 0), + 'STOP_ON_ERROR_ENABLED_SELECTED' => + Html::getChecked($config['stop_with_error'], 1), + 'STOP_ON_ERROR_DISABLED_SELECTED' => + Html::getChecked($config['stop_with_error'], 0) + ) +); + diff --git a/inc/configuration/interface.php b/inc/configuration/interface.php new file mode 100644 index 0000000..cb27346 --- /dev/null +++ b/inc/configuration/interface.php @@ -0,0 +1,100 @@ + $lang['L_POSITION_TL'], + 'tc' => $lang['L_POSITION_TC'], + 'tr' => $lang['L_POSITION_TR'], + 'ml' => $lang['L_POSITION_ML'], + 'mc' => $lang['L_POSITION_MC'], + 'mr' => $lang['L_POSITION_MR'], + 'bl' => $lang['L_POSITION_BL'], + 'bc' => $lang['L_POSITION_BC'], + 'br' => $lang['L_POSITION_BR'] +); + +if (isset($_POST['save'])) { + if (isset($_POST['interface_server_caption'])) { + $config['interface_server_caption'] = 1; + } else { + $config['interface_server_caption'] = 0; + } + if (isset($_POST['interface_server_caption_position_1'])) { + $config['interface_server_caption_position'] = 1; + } else { + $config['interface_server_caption_position'] = 0; + } + if (isset($_POST['sqlboxsize'])) { + $config['interface_sqlboxsize'] = (int) $_POST['sqlboxsize']; + } + if (isset($_POST['theme'])) { + $config['theme'] =(string) $_POST['theme']; + } + // make sure that the theme exists! If not fall back to standard theme + if (!is_dir('./css/' . $config['theme']) + || !is_readable('./css/' . $config['theme'])) { + $config['theme'] = 'msd'; + } + if (isset($_POST['notification_position'])) { + $config['notification_position'] = $_POST['notification_position']; + } + if (isset($_POST['interface_table_compact'])) { + $config['interface_table_compact'] + = (int) $_POST['interface_table_compact']; + }; + if (isset($_POST['resultsPerPage'])) { + $config['resultsPerPage'] = (int) $_POST['resultsPerPage']; + } + if (isset($_POST['refresh_processlist'])) { + $config['refresh_processlist'] = (int) $_POST['refresh_processlist']; + } + if ($config['refresh_processlist'] < 2) { + $config['refresh_processlist'] = 2; + } +} + +$tplConfigurationInterface = new MSDTemplate(); +$tplConfigurationInterface->set_filenames( + array('tplConfigurationInterface' => 'tpl/configuration/interface.tpl') +); + +$tplConfigurationInterface->assign_vars( + array( + 'ICON_SAVE' => $icon['small']['save'], + 'SEL_LANGUAGES' => getLanguageCombo(), + 'LINK_DOWNLOAD_LANGUAGE_PACKS' => + 'http://forum.mysqldumper.de/downloads.php?cat=9', + 'LANGUAGE' => $config['language'], + 'SERVER_CAPTION' => $config['interface_server_caption'], + 'INTERFACE_SERVER_CAPTION_ACTIVATED' => + Html::getChecked($config['interface_server_caption'], 1), + 'INTERFACE_SERVER_CAPTION_DISABLED' => + Html::getDisabled($config['interface_server_caption'], 0), + 'SERVER_CAPTION_POS_MAINFRAME_SELECTED' => + Html::getChecked($config['interface_server_caption_position'], 1), + 'SERVER_CAPTION_POS_MENUE_SELECTED' => + Html::getChecked($config['interface_server_caption_position'], 0), + 'SEL_THEME' => getThemes(), + 'LINK_DOWNLOAD_THEMES' => + 'http://forum.mysqldumper.de/downloads.php?cat=3', + 'SQLBOX_HEIGHT' => intval($config['interface_sqlboxsize']), + 'RESULTS_PER_PAGE' => intval($config['resultsPerPage']), + 'SEL_NOTIFICATION_POSITION' => + Html::getOptionlist($positions, $config['notification_position']), + 'REFRESH_PROCESSLIST' => (int) $config['refresh_processlist'], + 'SQL_GRID_TYPE_COMPACT_SELECTED' => + $config['interface_table_compact'] == 1 ? ' checked="checked"' : '', + 'SQL_GRID_TYPE_NORMAL_SELECTED' => + $config['interface_table_compact'] == 0 ? ' checked="checked"' : '' + ) +); diff --git a/inc/define_icons.php b/inc/define_icons.php new file mode 100644 index 0000000..546f5d1 --- /dev/null +++ b/inc/define_icons.php @@ -0,0 +1,69 @@ + clear arrays with values from last run + $_SESSION['dump'] = array(); + $_SESSION['log'] = array(); + $_SESSION['log']['actions'] = array(); + $_SESSION['log']['errors'] = array(); + $_SESSION['log']['files_created'] = array(); + $dump['comment'] = ''; + $action = 'prepare_dump'; +} +if ($action == 'prepare_dump') include ('./inc/dump/dump_prepare.php'); +if ($action == 'select_tables') include ('./inc/dump/select_tables.php'); +if ($action == 'do_dump') include ('./inc/dump/do_dump.php'); +if ($action == 'done') include ('./inc/dump/dump_finished.php'); +$_SESSION['dump'] = $dump; diff --git a/inc/dump/do_dump.php b/inc/dump/do_dump.php new file mode 100644 index 0000000..061864c --- /dev/null +++ b/inc/dump/do_dump.php @@ -0,0 +1,70 @@ + set start values +$dump = $_SESSION['dump']; +$dump['tables_total'] = 0; +$dump['records_total'] = 0; +$dump['tables_optimized'] = 0; +$dump['part'] = 1; +$dump['part_offset'] = 0; +$dump['errors'] = 0; +//-1 instead of 0 is needed for the execution of command before backup +$dump['table_offset'] = -1; +$dump['table_record_offset'] = 0; +$dump['filename_stamp'] = ''; +$dump['speed'] = $config['minspeed'] > 0 ? $config['minspeed'] : 50; +$dump['max_zeit'] = + (int) $config['max_execution_time'] * $config['time_buffer']; +$dump['dump_start_time'] = time(); +$dump['countdata'] = 0; +$dump['table_offset_total'] = 0; +$dump['page_refreshs'] = 0; +// used as overall flag including e-mail and ftp-actions +$dump['backup_in_progress'] = 1; +// used to determine id databases still need to be dumped +$dump['backup_done'] = 0; +$dump['selected_tables'] = FALSE; +if (isset($_POST['sel_tbl'])) { + $dump['selected_tables'] = $_POST['sel_tbl']; +} +// function was called in dump_prepare +// -- maybe get rid of this second call later on +prepareDumpProcess(); +// last_db_actual is used to detect if db changed in multidump-mode +// -> set to first db +$dump['last_db_actual'] = $dump['db_actual']; + +$_SESSION['config_file'] = $config['config_file']; +$_SESSION['dump'] = $dump; + +$tplDoDump = new MSDTemplate(); +$tplDoDump->set_filenames(array('tplDoDump' => 'tpl/dump/dump.tpl')); +$gzip = $config['compression'] == 1 ? $icon['gz'] : $lang['L_NOT_ACTIVATED']; +$tplDoDump->assign_vars( + array( + 'ICONPATH' => $config['files']['iconpath'], + 'GZIP' => $gzip, + 'SESSION_ID' => session_id(), + 'NOTIFICATION_POSITION' => $config['notification_position'] + ) +); + +$sizeUnits = array(1, 1024, 1024 * 1024, 1024 * 10242 * 1024); +$size = $config['multipartgroesse1'] * $sizeUnits[$config['multipartgroesse2']]; +if ($config['multi_part'] > 0) { + $tplDoDump->assign_block_vars( + 'MULTIPART', array('SIZE' => byteOutput($size)) + ); +} + +$tplDoDump->assign_var('TABLES_TO_DUMP', $dump['tables_total']); + diff --git a/inc/dump/dump_finished.php b/inc/dump/dump_finished.php new file mode 100644 index 0000000..4b88b73 --- /dev/null +++ b/inc/dump/dump_finished.php @@ -0,0 +1,88 @@ +set_filenames( + array('tplDumpFinished' => 'tpl/dump/dump_finished.tpl') +); +$recordsTotal = String::formatNumber((int)$dump['records_total']); +$tablesTotal = $dump['tables_total']; +$msg = sprintf($lang['L_DUMP_ENDERGEBNIS'], $tablesTotal, $recordsTotal); +$tplDumpFinished->assign_vars( + array( + 'ICON_OPEN_FILE' => $icon['small']['open_file'], + 'ICON_EDIT' => $icon['small']['edit'], + 'ICON_VIEW' => $icon['small']['view'], + 'SESSION_ID' => session_id(), + 'BACKUPPATH' => $config['paths']['backup'], + 'PAGE_REFRESHS' => $dump['page_refreshs'], + 'TIME_ELAPSED' => getTimeFormat(time() - $dump['dump_start_time']), + 'MSG' => $msg + ) +); + +if (count($dump['databases']) > 1) { + $msg = sprintf($lang['L_MULTIDUMP_FINISHED'], count($dump['databases'])); + $tplDumpFinished->assign_block_vars('MULTIDUMP', array('MSG' => $msg)); +} +$i = 1; +foreach ($_SESSION['log']['files_created'] as $file) { + $fileSize = @filesize($config['paths']['backup'] . $file); + $tplDumpFinished->assign_block_vars( + 'FILE', + array( + 'NR' => $i, + 'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1', + 'FILENAME' => $file, + 'FILENAME_URLENCODED' => urlencode($file), + 'FILESIZE' => byteOutput($fileSize) + ) + ); + $i++; +} + +$i = 1; +foreach ($_SESSION['log']['actions'] as $message) { + $timestamp = substr($message, 0, 19); + $message = substr($message, 20); + $tplDumpFinished->assign_block_vars( + 'ACTION', + array( + 'NR' => $i, + 'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1', + 'TIMESTAMP' => $timestamp, + 'ACTION' => $message + ) + ); + $i++; +} + +if (sizeof($_SESSION['log']['errors']) > 0) { + $tplDumpFinished->assign_block_vars('ERROR', array()); + $i = 1; + foreach ($_SESSION['log']['errors'] as $error) { + $timestamp = substr($error, 0, 19); + $error = substr($error, 20); + $tplDumpFinished->assign_block_vars( + 'ERROR.ERRORMSG', + array( + 'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1', + 'TIMESTAMP' => $timestamp, + 'MSG' => $error + ) + ); + $i++; + } +} diff --git a/inc/dump/dump_prepare.php b/inc/dump/dump_prepare.php new file mode 100644 index 0000000..e436ab1 --- /dev/null +++ b/inc/dump/dump_prepare.php @@ -0,0 +1,158 @@ + reset hidden settings to safe defaults +if ($config['msd_mode'] == 0) { + $config['replace_command'] = 0; +} + +$tplDumpPrepare = new MSDTemplate(); +$tplDumpPrepare->set_filenames( + array('tplDumpPrepare' => 'tpl/dump/dump_prepare.tpl') +); +if ($config['msd_mode'] > 0) { + $tplDumpPrepare->assign_block_vars('MODE_EXPERT', array()); +} +// set charset-selectbox to standard-encoding of MySQL-Server as initial value +$dump['sel_dump_encoding'] = 'utf8'; +$dump['dump_encoding'] = 'utf8'; +$charsets=$dbo->getCharsets(); +foreach ($charsets as $name=>$val) { + $charsetsDescription[$name]=$name.' - '.$val['Description']; +} +// tables will be selected on next page, but we need a dummy val +// for prepareDumpProcess() +$dump['selected_tables'] = false; +$dbsToBackup = array(); +// look up which databases need to be dumped +prepareDumpProcess(); +$dbs = array_keys($dump['databases']); +$dbsToBackup = implode(', ', $dbs); + +$cext = ($config['cron_extender'] == 0) ? 'pl' : 'cgi'; +$scriptName = $_SERVER['SCRIPT_NAME']; +$serverName = $_SERVER['SERVER_NAME']; +$url = substr($scriptName, 0, strrpos($scriptName, '/') + 1); +if (substr($url, -1) != '/') $url .= '/'; +if (substr($url, 0, 1) != '/') $url = '/' . $url; +$refdir = (substr($config['cron_execution_path'], 0, 1) == '/') ? '' : $url; +$scriptdir = $config['cron_execution_path'] . 'crondump.' . $cext; +$perlModultest = $config['cron_execution_path'] . "perltest.$cext"; +$perlSimpletest = $config['cron_execution_path'] . "simpletest.$cext"; +$scriptentry = myRealpath('./') . $config['paths']['config']; +$cronabsolute = myRealpath('./') . $scriptdir; +if (substr($config['cron_execution_path'], 0, 1) == '/') { + $cronabsolute = $_SERVER['DOCUMENT_ROOT'] . $scriptdir; +} +$confabsolute = $config['config_file']; +$perlHttpCall = getServerProtocol() . $serverName . $refdir; +$perlHttpCall .= $config['cron_execution_path'] . 'crondump.' . $cext; +$perlHttpCall .= '?config=' . $confabsolute; +$perlCrontabCall = 'perl ' . $cronabsolute . ' -config=' . $confabsolute; +$perlCrontabCall .= ' -html_output=0'; +$tplDumpPrepare->assign_vars( + array( + 'SESSION_ID' => session_id(), + 'CONFIG_FILE' => $config['config_file'], + 'POSSIBLE_DUMP_ENCODINGS' => + Html::getOptionlist($charsetsDescription, 'utf8'), + 'DBS_TO_BACKUP' => $dbsToBackup, + 'TABLES_TOTAL' => $dump['tables_total'], + 'RECORDS_TOTAL' => String::formatNumber(intval($dump['records_total'])), + 'DATASIZE_TOTAL' => byteOutput($dump['datasize_total']), + 'NR_OF_DBS' => count($dump['databases']), + 'DUMP_COMMENT' => Html::replaceQuotes($dump['comment']), + 'PERL_TEST' => $perlSimpletest, + 'PERL_MODULTEST' => $perlModultest, + 'PERL_HTTP_CALL' => $perlHttpCall, + 'PERL_CRONTAB_CALL' => $perlCrontabCall, + 'PERL_ABSOLUTE_PATH_OF_CONFIGDIR' => $scriptentry, + 'TIMESTAMP' => time() + ) +); + +if (count($dump['databases']) == 1 && $config['db_actual'] == $dbsToBackup) { + $tplDumpPrepare->assign_block_vars('TABLESELECT', array()); +} +if ($config['compression'] == 1) { + $tplDumpPrepare->assign_block_vars('GZIP_ACTIVATED', array()); +} else { + $tplDumpPrepare->assign_block_vars('GZIP_NOT_ACTIVATED', array()); +} + +if ($config['multi_part'] == 1) { + $tplDumpPrepare->assign_block_vars( + 'MULTIPART', + array('SIZE' => byteOutput($config['multipart_groesse'])) + ); +} else { + $tplDumpPrepare->assign_block_vars('NO_MULTIPART', array()); +} + +if ($config['send_mail'] == 1) { + $tplDumpPrepare->assign_block_vars( + 'SEND_MAIL', + array('RECIPIENT' => $config['email']['recipient_address']) + ); + $recipients = $config['email']['recipient_cc']; + $recipientsCc = implodeSubarray($recipients, 'address'); + if ($recipientsCc > '') { + $tplDumpPrepare->assign_block_vars( + 'SEND_MAIL.CC', array('EMAIL_ADRESS' => $recipientsCc) + ); + } + if ($config['email']['attach_backup'] == 1) { + $bytes = $config['email_maxsize1'] * 1024; + if ($config['email_maxsize2'] == 2) { + $bytes = $bytes * 1024; + } + $tplDumpPrepare->assign_block_vars( + 'SEND_MAIL.ATTACH_BACKUP', array('SIZE' => byteOutput($bytes)) + ); + } else { + $tplDumpPrepare->assign_block_vars( + 'SEND_MAIL.DONT_ATTACH_BACKUP', array() + ); + } +} else { + $tplDumpPrepare->assign_block_vars('NO_SEND_MAIL', array()); +} + +$i = 1; +foreach ($config['ftp'] as $ftp) { + if ($ftp['transfer'] == 1) { + $tplDumpPrepare->assign_block_vars( + 'FTP', + array( + 'NR' => $i, + 'ROWCLASS' => $i % 2 ? 'dbrow1' : 'dbrow' + ) + ); + + $tplDumpPrepare->assign_block_vars( + 'FTP.CONNECTION', + array( + 'SERVER' => $ftp['server'], + 'PORT' => $ftp['port'], + 'DIR' => $ftp['dir'] + ) + ); + $i++; + } +} diff --git a/inc/dump/select_tables.php b/inc/dump/select_tables.php new file mode 100644 index 0000000..da33467 --- /dev/null +++ b/inc/dump/select_tables.php @@ -0,0 +1,76 @@ +set_filenames( + array('tplDumpSelectTables' => 'tpl/dump/selectTables.tpl') + ); + $dbo->selectDb($dump['db_actual']); + $tables=$dbo->getTableStatus(); + $i=0; + foreach ($tables as $tableName => $row) { + $klasse = ($i % 2) ? 1 : ''; + $tableSize = byteOutput($row['Data_length'] + $row['Index_length']); + $tableType = $row['Engine']; + $nrOfRecords = String::formatNumber($row['Rows']); + if (substr($row['Comment'], 0, 4) == 'VIEW' && $row['Engine'] == '') { + $tableType = 'View'; + $tableSize = '-'; + $nrOfRecords = '-'; + } + $tplDumpSelectTables->assign_block_vars( + 'ROW', + array( + 'CLASS' => 'dbrow' . $klasse, + 'ID' => $i, + 'NR' => $i + 1, + 'TABLENAME' => $tableName, + 'TABLETYPE' => $tableType, + 'RECORDS' => $nrOfRecords, + 'SIZE' => $tableSize, + 'LAST_UPDATE' => $row['Update_time'] + ) + ); + $i++; + } + + $tplDumpSelectTables->assign_vars( + array( + 'PAGETITLE' => $lang['L_TABLESELECTION'], + 'SESSION_ID' => session_id(), + 'DATABASE' => $config['db_actual'], + 'ICON_OK' => $icon['ok'], + 'ICON_DELETE' => $icon['delete'], + 'ICON_DB' => $icon['db'], + 'L_NO_MSD_BACKUP' => $lang['L_NOT_SUPPORTED'] + ) + ); +} diff --git a/inc/filemanagement/converter.php b/inc/filemanagement/converter.php new file mode 100644 index 0000000..c66a6f8 --- /dev/null +++ b/inc/filemanagement/converter.php @@ -0,0 +1,77 @@ +pparse('tplGlobalHeader'); +$tplMenu->pparse('tplMenu'); + +// Konverter +$selectfile = (isset($_POST['selectfile'])) ? $_POST['selectfile'] : ''; +$destfile = (isset($_POST['destfile'])) ? $_POST['destfile'] : ''; +$compressed = (isset($_POST['compressed'])) ? $_POST['compressed'] : ''; +include ('./inc/define_icons.php'); +$doConversion = false; +if ($selectfile != '' & file_exists($config['paths']['backup'] . $selectfile) + && strlen($destfile) > 2) { + $doConversion = true; +} + +$tpl = new MSDTemplate(); +$tpl->set_filenames(array('show' => 'tpl/filemanagement/converter.tpl')); + +$tpl->assign_vars( + array( + 'SELECTBOX_FILE_LIST' => getFilelisteCombo($selectfile), + 'NEW_FILE' => Html::replaceQuotes($destfile), + 'NEW_FILE_COMPRESED' => $compressed == 1 ? ' checked="checked"' : '', + 'ICON_GZ' => $icon['gz'] + ) +); + +if ($doConversion) { + $tpl->assign_block_vars('AUTOSCROLL', array()); +} + +$tpl->pparse('show'); +flush(); +if (isset($_POST['startconvert'])) { + echo $lang['L_CONVERTING'] . ' ' . $selectfile + . ' ==> ' . $destfile . '.sql'; + if ($compressed == 1) { + echo '.gz'; + } + if ($doConversion) { + convert($selectfile, $destfile, $compressed); + } else { + echo '' . $lang['L_CONVERT_WRONG_PARAMETERS'] + . '
'; + } +} + +if ($doConversion) { + ?> + + + +