Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
<?php /***************************************************************************\ | Sypex Dumper Lite version 1.0.8b | | (c)2003-2006 zapimir zapimir@zapimir.net http://sypex.net/ | | (c)2005-2006 BINOVATOR info@sypex.net | |---------------------------------------------------------------------------| | created: 2003.09.02 19:07 modified: 2006.10.27 03:30 | |---------------------------------------------------------------------------| | This program is free software; you can redistribute it and/or | | modify it under the terms of the GNU General Public License | | as published by the Free Software Foundation; either version 2 | | of the License, or (at your option) any later version. | | | | This program is distributed in the hope that it will be useful, | | but WITHOUT ANY WARRANTY; without even the implied warranty of | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | GNU General Public License for more details. | | | | You should have received a copy of the GNU General Public License | | along with this program; if not, write to the Free Software | | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. | \***************************************************************************/ // Ïóòü è URL ê ôàéëàì áåêàïà define('PATH', 'backup/'); define('URL', 'backup/'); // Ìàêñèìàëüíîå âðåìÿ âûïîëíåíèÿ ñêðèïòà â ñåêóíäàõ // 0 - áåç îãðàíè÷åíèé define('TIME_LIMIT', 0); // Îãðàíè÷åíèå ðàçìåðà äàííûõ äîñòàâàåìûõ çà îäíî îáðàùåíèÿ ê ÁÄ (â ìåãàáàéòàõ) // Íóæíî äëÿ îãðàíè÷åíèÿ êîëè÷åñòâà ïàìÿòè ïîæèðàåìîé ñåðâåðîì ïðè äàìïå î÷åíü îáúåìíûõ òàáëèö define('LIMIT', 1); // mysql ñåðâåð define('DBHOST', 'localhost:3306'); // Áàçû äàííûõ, åñëè ñåðâåð íå ðàçðåøàåò ïðîñìàòðèâàòü ñïèñîê áàç äàííûõ, // è íè÷åãî íå ïîêàçûâàåòñÿ ïîñëå àâòîðèçàöèè. Ïåðå÷èñëèòå íàçâàíèÿ ÷åðåç çàïÿòóþ define('DBNAMES', ''); // Êîäèðîâêà ñîåäèíåíèÿ ñ MySQL // auto - àâòîìàòè÷åñêèé âûáîð (óñòàíàâëèâàåòñÿ êîäèðîâêà òàáëèöû), cp1251 - windows-1251, è ò.ï. define('CHARSET', 'auto'); // Êîäèðîâêà ñîåäèíåíèÿ ñ MySQL ïðè âîññòàíîâëåíèè // Íà ñëó÷àé ïåðåíîñà ñî ñòàðûõ âåðñèé MySQL (äî 4.1), ó êîòîðûõ íå óêàçàíà êîäèðîâêà òàáëèö â äàìïå // Ïðè äîáàâëåíèè 'forced->', ê ïðèìåðó 'forced->cp1251', êîäèðîâêà òàáëèö ïðè âîññòàíîâëåíèè áóäåò ïðèíóäèòåëüíî çàìåíåíà íà cp1251 // Ìîæíî òàêæå óêàçûâàòü ñðàâíåíèå íóæíîå ê ïðèìåðó 'cp1251_ukrainian_ci' èëè 'forced->cp1251_ukrainian_ci' define('RESTORE_CHARSET', 'cp1251'); // Âêëþ÷èòü ñîõðàíåíèå íàñòðîåê è ïîñëåäíèõ äåéñòâèé // Äëÿ îòêëþ÷åíèÿ óñòàíîâèòü çíà÷åíèå 0 define('SC', 1); // Òèïû òàáëèö ó êîòîðûõ ñîõðàíÿåòñÿ òîëüêî ñòðóêòóðà, ðàçäåëåííûå çàïÿòîé define('ONLY_CREATE', 'MRG_MyISAM,MERGE,HEAP,MEMORY'); // Ãëîáàëüíàÿ ñòàòèñòèêà // Äëÿ îòêëþ÷åíèÿ óñòàíîâèòü çíà÷åíèå 0 define('GS', 1); // Äàëüøå íè÷åãî ðåäàêòèðîâàòü íå íóæíî $is_safe_mode = ini_get('safe_mode') == '1' ? 1 : 0; if (!$is_safe_mode && function_exists('set_time_limit')) set_time_limit(TIME_LIMIT); header("Expires: Tue, 1 Jul 2003 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Pragma: no-cache"); $timer = array_sum(explode(' ', microtime())); ob_implicit_flush(); error_reporting(E_ALL); $auth = 0; $error = ''; if (!empty($_POST['login']) && isset($_POST['pass'])) { if (@mysql_connect(DBHOST, $_POST['login'], $_POST['pass'])){ setcookie("sxd", base64_encode("SKD101:{$_POST['login']}:{$_POST['pass']}")); header("Location: dumper.php"); mysql_close(); exit; } else{ $error = '#' . mysql_errno() . ': ' . mysql_error(); } } elseif (!empty($_COOKIE['sxd'])) { $user = explode(":", base64_decode($_COOKIE['sxd'])); if (@mysql_connect(DBHOST, $user[1], $user[2])){ $auth = 1; } else{ $error = '#' . mysql_errno() . ': ' . mysql_error(); } } if (!$auth || (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] == 'reload')) { setcookie("sxd"); echo tpl_page(tpl_auth($error ? tpl_error($error) : ''), "<SCRIPT>if (jsEnabled) {document.write('<INPUT TYPE=submit VALUE=دخول>');}</SCRIPT>"); echo "<SCRIPT>document.getElementById('timer').innerHTML = '" . round(array_sum(explode(' ', microtime())) - $timer, 4) . " seconds.'</SCRIPT>"; exit; } if (!file_exists(PATH) && !$is_safe_mode) { mkdir(PATH, 0777) || trigger_error("Íå óäàëîñü ñîçäàòü êàòàëîã äëÿ áåêàïà", E_USER_ERROR); } $SK = new dumper(); define('C_DEFAULT', 1); define('C_RESULT', 2); define('C_ERROR', 3); define('C_WARNING', 4); $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; switch($action){ case 'backup': $SK->backup(); break; case 'restore': $SK->restore(); break; default: $SK->main(); } mysql_close(); echo "<SCRIPT>document.getElementById('timer').innerHTML = '" . round(array_sum(explode(' ', microtime())) - $timer, 4) . " seconds.'</SCRIPT>"; class dumper { function dumper() { if (file_exists(PATH . "dumper.cfg.php")) { include(PATH . "dumper.cfg.php"); } else{ $this->SET['last_action'] = 0; $this->SET['last_db_backup'] = ''; $this->SET['tables'] = ''; $this->SET['comp_method'] = 2; $this->SET['comp_level'] = 7; $this->SET['last_db_restore'] = ''; } $this->tabs = 0; $this->records = 0; $this->size = 0; $this->comp = 0; // Âåðñèÿ MySQL âèäà 40101 preg_match("/^(\d+)\.(\d+)\.(\d+)/", mysql_get_server_info(), $m); $this->mysql_version = sprintf("%d%02d%02d", $m[1], $m[2], $m[3]); $this->only_create = explode(',', ONLY_CREATE); $this->forced_charset = false; $this->restore_charset = $this->restore_collate = ''; if (preg_match("/^(forced->)?(([a-z0-9]+)(\_\w+)?)$/", RESTORE_CHARSET, $matches)) { $this->forced_charset = $matches[1] == 'forced->'; $this->restore_charset = $matches[3]; $this->restore_collate = !empty($matches[4]) ? ' COLLATE ' . $matches[2] : ''; } } function backup() { if (!isset($_POST)) {$this->main();} set_error_handler("SXD_errorHandler"); $buttons = "<A ID=save HREF='' STYLE='display: none;'>تحميل الملف</A> <INPUT ID=back TYPE=button VALUE='رجوع للخلف' DISABLED onClick=\"history.back();\">"; echo tpl_page(tpl_process("النسخ الاحتياطي لقاعدة البيانات"), $buttons); $this->SET['last_action'] = 0; $this->SET['last_db_backup'] = isset($_POST['db_backup']) ? $_POST['db_backup'] : ''; $this->SET['tables_exclude'] = !empty($_POST['tables']) && $_POST['tables']{0} == '^' ? 1 : 0; $this->SET['tables'] = isset($_POST['tables']) ? $_POST['tables'] : ''; $this->SET['comp_method'] = isset($_POST['comp_method']) ? intval($_POST['comp_method']) : 0; $this->SET['comp_level'] = isset($_POST['comp_level']) ? intval($_POST['comp_level']) : 0; $this->fn_save(); $this->SET['tables'] = explode(",", $this->SET['tables']); if (!empty($_POST['tables'])) { foreach($this->SET['tables'] AS $table){ $table = preg_replace("/[^\w*?^]/", "", $table); $pattern = array( "/\?/", "/\*/"); $replace = array( ".", ".*?"); $tbls[] = preg_replace($pattern, $replace, $table); } } else{ $this->SET['tables_exclude'] = 1; } if ($this->SET['comp_level'] == 0) { $this->SET['comp_method'] = 0; } $db = $this->SET['last_db_backup']; if (!$db) { echo tpl_l("ÎØÈÁÊÀ! Íå óêàçàíà áàçà äàííûõ!", C_ERROR); echo tpl_enableBack(); exit; } echo tpl_l("اسم القاعدة `{$db}`."); mysql_select_db($db) or trigger_error ("Íå óäàåòñÿ âûáðàòü áàçó äàííûõ.<BR>" . mysql_error(), E_USER_ERROR); $tables = array(); $result = mysql_query("SHOW TABLES"); $all = 0; while($row = mysql_fetch_array($result)) { $status = 0; if (!empty($tbls)) { foreach($tbls AS $table){ $exclude = preg_match("/^\^/", $table) ? true : false; if (!$exclude) { if (preg_match("/^{$table}$/i", $row[0])) { $status = 1; } $all = 1; } if ($exclude && preg_match("/{$table}$/i", $row[0])) { $status = -1; } } } else { $status = 1; } if ($status >= $all) { $tables[] = $row[0]; } } $tabs = count($tables); // Îïðåäåëåíèå ðàçìåðîâ òàáëèö $result = mysql_query("SHOW TABLE STATUS"); $tabinfo = array(); $tab_charset = array(); $tab_type = array(); $tabinfo[0] = 0; $info = ''; while($item = mysql_fetch_assoc($result)){ //print_r($item); if(in_array($item['Name'], $tables)) { $item['Rows'] = empty($item['Rows']) ? 0 : $item['Rows']; $tabinfo[0] += $item['Rows']; $tabinfo[$item['Name']] = $item['Rows']; $this->size += $item['Data_length']; $tabsize[$item['Name']] = 1 + round(LIMIT * 1048576 / ($item['Avg_row_length'] + 1)); if($item['Rows']) $info .= "|" . $item['Rows']; if (!empty($item['Collation']) && preg_match("/^([a-z0-9]+)_/i", $item['Collation'], $m)) { $tab_charset[$item['Name']] = $m[1]; } $tab_type[$item['Name']] = isset($item['Engine']) ? $item['Engine'] : $item['Type']; } } $show = 10 + $tabinfo[0] / 50; $info = $tabinfo[0] . $info; $name = $db . '_' . date("Y-m-d_H-i"); $fp = $this->fn_open($name, "w"); echo tpl_l("Create file with backup database:<BR>\\n - {$this->filename}"); $this->fn_write($fp, "#SKD101|{$db}|{$tabs}|" . date("Y.m.d H:i:s") ."|{$info}\n\n"); $t=0; echo tpl_l(str_repeat("-", 60)); $result = mysql_query("SET SQL_QUOTE_SHOW_CREATE = 1"); // Êîäèðîâêà ñîåäèíåíèÿ ïî óìîë÷àíèþ if ($this->mysql_version > 40101 && CHARSET != 'auto') { mysql_query("SET NAMES '" . CHARSET . "'") or trigger_error ("Íåóäàåòñÿ èçìåíèòü êîäèðîâêó ñîåäèíåíèÿ.<BR>" . mysql_error(), E_USER_ERROR); $last_charset = CHARSET; } else{ $last_charset = ''; } foreach ($tables AS $table){ // Âûñòàâëÿåì êîäèðîâêó ñîåäèíåíèÿ ñîîòâåòñòâóþùóþ êîäèðîâêå òàáëèöû if ($this->mysql_version > 40101 && $tab_charset[$table] != $last_charset) { if (CHARSET == 'auto') { mysql_query("SET NAMES '" . $tab_charset[$table] . "'") or trigger_error ("Íåóäàåòñÿ èçìåíèòü êîäèðîâêó ñîåäèíåíèÿ.<BR>" . mysql_error(), E_USER_ERROR); echo tpl_l("Óñòàíîâëåíà êîäèðîâêà ñîåäèíåíèÿ `" . $tab_charset[$table] . "`.", C_WARNING); $last_charset = $tab_charset[$table]; } else{ echo tpl_l('Êîäèðîâêà ñîåäèíåíèÿ è òàáëèöû íå ñîâïàäàåò:', C_ERROR); echo tpl_l('استرجاع `'. $table .'` -> ' . $tab_charset[$table] . ' (ñîåäèíåíèå ' . CHARSET . ')', C_ERROR); } } echo tpl_l("جاري تنفيذ العملية على `{$table}` [" . fn_int($tabinfo[$table]) . "]."); // Ñîçäàíèå òàáëèöû $result = mysql_query("SHOW CREATE TABLE `{$table}`"); $tab = mysql_fetch_array($result); $tab = preg_replace('/(default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP|DEFAULT CHARSET=\w+|COLLATE=\w+|character set \w+|collate \w+)/i', '/*!40101 \\1 */', $tab); $this->fn_write($fp, "DROP TABLE IF EXISTS `{$table}`;\n{$tab[1]};\n\n"); // Ïðîâåðÿåì íóæíî ëè äàìïèòü äàííûå if (in_array($tab_type[$table], $this->only_create)) { continue; } // Îïðåäåäåëÿåì òèïû ñòîëáöîâ $NumericColumn = array(); $result = mysql_query("SHOW COLUMNS FROM `{$table}`"); $field = 0; while($col = mysql_fetch_row($result)) { $NumericColumn[$field++] = preg_match("/^(\w*int|year)/", $col[1]) ? 1 : 0; } $fields = $field; $from = 0; $limit = $tabsize[$table]; $limit2 = round($limit / 3); if ($tabinfo[$table] > 0) { if ($tabinfo[$table] > $limit2) { echo tpl_s(0, $t / $tabinfo[0]); } $i = 0; $this->fn_write($fp, "INSERT INTO `{$table}` VALUES"); while(($result = mysql_query("SELECT * FROM `{$table}` LIMIT {$from}, {$limit}")) && ($total = mysql_num_rows($result))){ while($row = mysql_fetch_row($result)) { $i++; $t++; for($k = 0; $k < $fields; $k++){ if ($NumericColumn[$k]) $row[$k] = isset($row[$k]) ? $row[$k] : "NULL"; else $row[$k] = isset($row[$k]) ? "'" . mysql_escape_string($row[$k]) . "'" : "NULL"; } $this->fn_write($fp, ($i == 1 ? "" : ",") . "\n(" . implode(", ", $row) . ")"); if ($i % $limit2 == 0) echo tpl_s($i / $tabinfo[$table], $t / $tabinfo[0]); } mysql_free_result($result); if ($total < $limit) { break; } $from += $limit; } $this->fn_write($fp, ";\n\n"); echo tpl_s(1, $t / $tabinfo[0]);} } $this->tabs = $tabs; $this->records = $tabinfo[0]; $this->comp = $this->SET['comp_method'] * 10 + $this->SET['comp_level']; echo tpl_s(1, 1); echo tpl_l(str_repeat("-", 60)); $this->fn_close($fp); echo tpl_l("نسخ قاعدة `{$db}` تم.", C_RESULT); echo tpl_l("حجم القاعدة: " . round($this->size / 1048576, 2) . " mb", C_RESULT); $filesize = round(filesize(PATH . $this->filename) / 1048576, 2) . " mb"; echo tpl_l("حجم الملف: {$filesize}", C_RESULT); echo tpl_l("مجموع الجداول: {$tabs}", C_RESULT); echo tpl_l("Error found: " . fn_int($tabinfo[0]), C_RESULT); echo "<SCRIPT>with (document.getElementById('save')) {style.display = ''; innerHTML = 'رابط الملف ({$filesize})'; href = '" . URL . $this->filename . "'; }document.getElementById('back').disabled = 0;</SCRIPT>"; } function restore(){ if (!isset($_POST)) {$this->main();} set_error_handler("SXD_errorHandler"); $buttons = "<INPUT ID=back TYPE=button VALUE='الرجوع للخلف' DISABLED onClick=\"history.back();\">"; echo tpl_page(tpl_process("استرجاع قاعدة بيانات"), $buttons); $this->SET['last_action'] = 1; $this->SET['last_db_restore'] = isset($_POST['db_restore']) ? $_POST['db_restore'] : ''; $file = isset($_POST['file']) ? $_POST['file'] : ''; $this->fn_save(); $db = $this->SET['last_db_restore']; if (!$db) { echo tpl_l("ÎØÈÁÊÀ! Íå óêàçàíà áàçà äàííûõ!", C_ERROR); echo tpl_enableBack(); exit; } echo tpl_l("اسم القاعدة `{$db}`."); mysql_select_db($db) or trigger_error ("Íå óäàåòñÿ âûáðàòü áàçó äàííûõ.<BR>" . mysql_error(), E_USER_ERROR); // Îïðåäåëåíèå ôîðìàòà ôàéëà if(preg_match("/^(.+?)\.sql(\.(bz2|gz))?$/", $file, $matches)) { if (isset($matches[3]) && $matches[3] == 'bz2') { $this->SET['comp_method'] = 2; } elseif (isset($matches[2]) &&$matches[3] == 'gz'){ $this->SET['comp_method'] = 1; } else{ $this->SET['comp_method'] = 0; } $this->SET['comp_level'] = ''; if (!file_exists(PATH . "/{$file}")) { echo tpl_l("ÎØÈÁÊÀ! Ôàéë íå íàéäåí!", C_ERROR); echo tpl_enableBack(); exit; } echo tpl_l("اسم الملف `{$file}`."); $file = $matches[1]; } else{ echo tpl_l("لم تقم باختيار ملف لاسترجاعه", C_ERROR); echo tpl_enableBack(); exit; } echo tpl_l(str_repeat("-", 60)); $fp = $this->fn_open($file, "r"); $this->file_cache = $sql = $table = $insert = ''; $is_skd = $query_len = $execute = $q =$t = $i = $aff_rows = 0; $limit = 300; $index = 4; $tabs = 0; $cache = ''; $info = array(); // Óñòàíîâêà êîäèðîâêè ñîåäèíåíèÿ if ($this->mysql_version > 40101 && (CHARSET != 'auto' || $this->forced_charset)) { // Êîäèðîâêà ïî óìîë÷àíèþ, åñëè â äàìïå íå óêàçàíà êîäèðîâêà mysql_query("SET NAMES '" . $this->restore_charset . "'") or trigger_error ("Íåóäàåòñÿ èçìåíèòü êîäèðîâêó ñîåäèíåíèÿ.<BR>" . mysql_error(), E_USER_ERROR); echo tpl_l("Óñòàíîâëåíà êîäèðîâêà ñîåäèíåíèÿ `" . $this->restore_charset . "`.", C_WARNING); $last_charset = $this->restore_charset; } else { $last_charset = ''; } $last_showed = ''; while(($str = $this->fn_read_str($fp)) !== false){ if (empty($str) || preg_match("/^(#|--)/", $str)) { if (!$is_skd && preg_match("/^#SKD101\|/", $str)) { $info = explode("|", $str); echo tpl_s(0, $t / $info[4]); $is_skd = 1; } continue; } $query_len += strlen($str); if (!$insert && preg_match("/^(INSERT INTO `?([^` ]+)`? .*?VALUES)(.*)$/i", $str, $m)) { if ($table != $m[2]) { $table = $m[2]; $tabs++; $cache .= tpl_l("استرجاع `{$table}`."); $last_showed = $table; $i = 0; if ($is_skd) echo tpl_s(100 , $t / $info[4]); } $insert = $m[1] . ' '; $sql .= $m[3]; $index++; $info[$index] = isset($info[$index]) ? $info[$index] : 0; $limit = round($info[$index] / 20); $limit = $limit < 300 ? 300 : $limit; if ($info[$index] > $limit){ echo $cache; $cache = ''; echo tpl_s(0 / $info[$index], $t / $info[4]); } } else{ $sql .= $str; if ($insert) { $i++; $t++; if ($is_skd && $info[$index] > $limit && $t % $limit == 0){ echo tpl_s($i / $info[$index], $t / $info[4]); } } } if (!$insert && preg_match("/^CREATE TABLE (IF NOT EXISTS )?`?([^` ]+)`?/i", $str, $m) && $table != $m[2]){ $table = $m[2]; $insert = ''; $tabs++; $is_create = true; $i = 0; } if ($sql) { if (preg_match("/;$/", $str)) { $sql = rtrim($insert . $sql, ";"); if (empty($insert)) { if ($this->mysql_version < 40101) { $sql = preg_replace("/ENGINE\s?=/", "TYPE=", $sql); } elseif (preg_match("/CREATE TABLE/i", $sql)){ // Âûñòàâëÿåì êîäèðîâêó ñîåäèíåíèÿ if (preg_match("/(CHARACTER SET|CHARSET)[=\s]+(\w+)/i", $sql, $charset)) { if (!$this->forced_charset && $charset[2] != $last_charset) { if (CHARSET == 'auto') { mysql_query("SET NAMES '" . $charset[2] . "'") or trigger_error ("Íåóäàåòñÿ èçìåíèòü êîäèðîâêó ñîåäèíåíèÿ.<BR>{$sql}<BR>" . mysql_error(), E_USER_ERROR); $cache .= tpl_l("Óñòàíîâëåíà êîäèðîâêà ñîåäèíåíèÿ `" . $charset[2] . "`.", C_WARNING); $last_charset = $charset[2]; } else{ $cache .= tpl_l('Êîäèðîâêà ñîåäèíåíèÿ è òàáëèöû íå ñîâïàäàåò:', C_ERROR); $cache .= tpl_l('استرجاع `'. $table .'` -> ' . $charset[2] . ' (ñîåäèíåíèå ' . $this->restore_charset . ')', C_ERROR); } } // Ìåíÿåì êîäèðîâêó åñëè óêàçàíî ôîðñèðîâàòü êîäèðîâêó if ($this->forced_charset) { $sql = preg_replace("/(\/\*!\d+\s)?((COLLATE)[=\s]+)\w+(\s+\*\/)?/i", '', $sql); $sql = preg_replace("/((CHARACTER SET|CHARSET)[=\s]+)\w+/i", "\\1" . $this->restore_charset . $this->restore_collate, $sql); } } elseif(CHARSET == 'auto'){ // Âñòàâëÿåì êîäèðîâêó äëÿ òàáëèö, åñëè îíà íå óêàçàíà è óñòàíîâëåíà auto êîäèðîâêà $sql .= ' DEFAULT CHARSET=' . $this->restore_charset . $this->restore_collate; if ($this->restore_charset != $last_charset) { mysql_query("SET NAMES '" . $this->restore_charset . "'") or trigger_error ("Íåóäàåòñÿ èçìåíèòü êîäèðîâêó ñîåäèíåíèÿ.<BR>{$sql}<BR>" . mysql_error(), E_USER_ERROR); $cache .= tpl_l("Óñòàíîâëåíà êîäèðîâêà ñîåäèíåíèÿ `" . $this->restore_charset . "`.", C_WARNING); $last_charset = $this->restore_charset; } } } if ($last_showed != $table) {$cache .= tpl_l("استرجاع `{$table}`."); $last_showed = $table;} } elseif($this->mysql_version > 40101 && empty($last_charset)) { // Óñòàíàâëèâàåì êîäèðîâêó íà ñëó÷àé åñëè îòñóòñòâóåò CREATE TABLE mysql_query("SET $this->restore_charset '" . $this->restore_charset . "'") or trigger_error ("Íåóäàåòñÿ èçìåíèòü êîäèðîâêó ñîåäèíåíèÿ.<BR>{$sql}<BR>" . mysql_error(), E_USER_ERROR); echo tpl_l("Óñòàíîâëåíà êîäèðîâêà ñîåäèíåíèÿ `" . $this->restore_charset . "`.", C_WARNING); $last_charset = $this->restore_charset; } $insert = ''; $execute = 1; } if ($query_len >= 65536 && preg_match("/,$/", $str)) { $sql = rtrim($insert . $sql, ","); $execute = 1; } if ($execute) { $q++; mysql_query($sql) or trigger_error ("Íåïðàâèëüíûé çàïðîñ.<BR>" . mysql_error(), E_USER_ERROR); if (preg_match("/^insert/i", $sql)) { $aff_rows += mysql_affected_rows(); } $sql = ''; $query_len = 0; $execute = 0; } } } echo $cache; echo tpl_s(1 , 1); echo tpl_l(str_repeat("-", 60)); echo tpl_l("ÁÄ âîññòàíîâëåíà èç ðåçåðâíîé êîïèè.", C_RESULT); if (isset($info[3])) echo tpl_l("Äàòà ñîçäàíèÿ êîïèè: {$info[3]}", C_RESULT); echo tpl_l("Çàïðîñîâ ê ÁÄ: {$q}", C_RESULT); echo tpl_l("Òàáëèö ñîçäàíî: {$tabs}", C_RESULT); echo tpl_l("Ñòðîê äîáàâëåíî: {$aff_rows}", C_RESULT); $this->tabs = $tabs; $this->records = $aff_rows; $this->size = filesize(PATH . $this->filename); $this->comp = $this->SET['comp_method'] * 10 + $this->SET['comp_level']; echo "<SCRIPT>document.getElementById('back').disabled = 0;</SCRIPT>"; // Ïåðåäà÷à äàííûõ äëÿ ãëîáàëüíîé ñòàòèñòèêè $this->fn_close($fp); } function main(){ $this->comp_levels = array('9' => '9 (قوي)', '8' => '8', '7' => '7', '6' => '6', '5' => '5 (متوسط)', '4' => '4', '3' => '3', '2' => '2', '1' => '1 (خفيف)','0' => 'sql'); if (function_exists("bzopen")) { $this->comp_methods[2] = 'BZip2'; } if (function_exists("gzopen")) { $this->comp_methods[1] = 'GZip'; } $this->comp_methods[0] = 'sql'; if (count($this->comp_methods) == 1) { $this->comp_levels = array('0' =>'sql'); } $dbs = $this->db_select(); $this->vars['db_backup'] = $this->fn_select($dbs, $this->SET['last_db_backup']); $this->vars['db_restore'] = $this->fn_select($dbs, $this->SET['last_db_restore']); $this->vars['comp_levels'] = $this->fn_select($this->comp_levels, $this->SET['comp_level']); $this->vars['comp_methods'] = $this->fn_select($this->comp_methods, $this->SET['comp_method']); $this->vars['tables'] = $this->SET['tables']; $this->vars['files'] = $this->fn_select($this->file_select(), ''); $buttons = "<INPUT TYPE=submit VALUE=تنفيذ><INPUT TYPE=button VALUE=رجوع onClick=\"location.href = 'dumper.php?reload'\">"; echo tpl_page(tpl_main(), $buttons); } function db_select(){ if (DBNAMES != '') { $items = explode(',', trim(DBNAMES)); foreach($items AS $item){ if (mysql_select_db($item)) { $tables = mysql_query("SHOW TABLES"); if ($tables) { $tabs = mysql_num_rows($tables); $dbs[$item] = "{$item} ({$tabs})"; } } } } else { $result = mysql_query("SHOW DATABASES"); $dbs = array(); while($item = mysql_fetch_array($result)){ if (mysql_select_db($item[0])) { $tables = mysql_query("SHOW TABLES"); if ($tables) { $tabs = mysql_num_rows($tables); $dbs[$item[0]] = "{$item[0]} ({$tabs})"; } } } } return $dbs; } function file_select(){ $files = array('' => ' '); if (is_dir(PATH) && $handle = opendir(PATH)) { while (false !== ($file = readdir($handle))) { if (preg_match("/^.+?\.sql(\.(gz|bz2))?$/", $file)) { $files[$file] = $file; } } closedir($handle); } ksort($files); return $files; } function fn_open($name, $mode){ if ($this->SET['comp_method'] == 2) { $this->filename = "{$name}.sql.bz2"; return bzopen(PATH . $this->filename, "{$mode}b{$this->SET['comp_level']}"); } elseif ($this->SET['comp_method'] == 1) { $this->filename = "{$name}.sql.gz"; return gzopen(PATH . $this->filename, "{$mode}b{$this->SET['comp_level']}"); } else{ $this->filename = "{$name}.sql"; return fopen(PATH . $this->filename, "{$mode}b"); } } function fn_write($fp, $str){ if ($this->SET['comp_method'] == 2) { bzwrite($fp, $str); } elseif ($this->SET['comp_method'] == 1) { gzwrite($fp, $str); } else{ fwrite($fp, $str); } } function fn_read($fp){ if ($this->SET['comp_method'] == 2) { return bzread($fp, 4096); } elseif ($this->SET['comp_method'] == 1) { return gzread($fp, 4096); } else{ return fread($fp, 4096); } } function fn_read_str($fp){ $string = ''; $this->file_cache = ltrim($this->file_cache); $pos = strpos($this->file_cache, "\n", 0); if ($pos < 1) { while (!$string && ($str = $this->fn_read($fp))){ $pos = strpos($str, "\n", 0); if ($pos === false) { $this->file_cache .= $str; } else{ $string = $this->file_cache . substr($str, 0, $pos); $this->file_cache = substr($str, $pos + 1); } } if (!$str) { if ($this->file_cache) { $string = $this->file_cache; $this->file_cache = ''; return trim($string); } return false; } } else { $string = substr($this->file_cache, 0, $pos); $this->file_cache = substr($this->file_cache, $pos + 1); } return trim($string); } function fn_close($fp){ if ($this->SET['comp_method'] == 2) { bzclose($fp); } elseif ($this->SET['comp_method'] == 1) { gzclose($fp); } else{ fclose($fp); } $this->fn_index(); } function fn_select($items, $selected){ $select = ''; foreach($items AS $key => $value){ $select .= $key == $selected ? "<OPTION VALUE='{$key}' SELECTED>{$value}" : "<OPTION VALUE='{$key}'>{$value}"; } return $select; } function fn_save(){ if (SC) { $ne = !file_exists(PATH . "dumper.cfg.php"); $fp = fopen(PATH . "dumper.cfg.php", "wb"); fwrite($fp, "<?php\n\$this->SET = " . fn_arr2str($this->SET) . "\n?>"); fclose($fp); $this->fn_index(); } } function fn_index(){ if (!file_exists(PATH . 'index.html')) { $fh = fopen(PATH . 'index.html', 'wb'); fwrite($fh, tpl_backup_index()); fclose($fh); } } } function fn_int($num){ return number_format($num, 0, ',', ' '); } function fn_arr2str($array) { $str = "array(\n"; foreach ($array as $key => $value) { if (is_array($value)) { $str .= "'$key' => " . fn_arr2str($value) . ",\n\n"; } else { $str .= "'$key' => '" . str_replace("'", "\'", $value) . "',\n"; } } return $str . ")"; } // Øàáëîíû function tpl_page($content = '', $buttons = ''){ return <<<HTML <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <TITLE>Sypex Dumper Lite 1.0.8 | © 2006 zapimir|تعريب سوفت ار</TITLE> <META HTTP-EQUIV=Content-Type CONTENT="text/html; charset=windows-1251"> <html dir="rtl"> <STYLE TYPE="TEXT/CSS"> <!-- body{ overflow: auto; } td { font: 11px tahoma, verdana, arial; cursor: default; } input, select, div { font: 11px tahoma, verdana, arial; } input.text, select { width: 100%; } fieldset { margin-bottom: 10px; } --> </STYLE> </HEAD> <BODY BGCOLOR=#ECE9D8 TEXT=#000000> <TABLE WIDTH=100% HEIGHT=100% BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=CENTER> <TR> <TD HEIGHT=60% ALIGN=CENTER VALIGN=MIDDLE> <TABLE WIDTH=360 BORDER=0 CELLSPACING=0 CELLPADDING=0> <TR> <TD VALIGN=TOP STYLE="border: 1px solid #919B9C;"> <TABLE WIDTH=100% HEIGHT=100% BORDER=0 CELLSPACING=1 CELLPADDING=0> <TR> <TD ID=Header HEIGHT=20 BGCOLOR=#7A96DF STYLE="font-size: 13px; color: white; font-family: verdana, arial; padding-left: 5px; FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=1,startColorStr=#7A96DF,endColorStr=#FBFBFD)" TITLE='© 2003-2006 zapimir'> <B><A HREF=http://sypex.net/products/dumper/ STYLE="color: white; text-decoration: none;">Sypex Dumper Lite 1.0.8</A></B><IMG ID=GS WIDTH=1 HEIGHT=1 STYLE="visibility: hidden;"></TD> </TR> <TR> <FORM NAME=skb METHOD=POST ACTION=dumper.php> <TD VALIGN=TOP BGCOLOR=#F4F3EE STYLE="FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#FCFBFE,endColorStr=#F4F3EE); padding: 8px 8px;"> {$content} <TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=2> <TR> <TD STYLE='color: #CECECE' ID=timer></TD> <TD ALIGN=RIGHT>{$buttons}</TD> </TR> </TABLE></TD> </FORM> </TR> </TABLE></TD> </TR> </TABLE></TD> </TR> </TABLE> </TD> </TR> </TABLE> </BODY> </HTML> HTML; } function tpl_main(){ global $SK; return <<<HTML <FIELDSET onClick="document.skb.action[0].checked = 1;"> <LEGEND> <INPUT TYPE=radio NAME=action VALUE=backup> Backup / النسخ الاحتياطي لقواعد البيانات </LEGEND> <TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=2> <TR> <TD WIDTH=35%>قاعدة البيانات:</TD> <TD WIDTH=65%><SELECT NAME=db_backup> {$SK->vars['db_backup']} </SELECT></TD> </TR> <TR> <TD>لنسخ جدول فقط قم بادراج اسم الجدول:</TD> <TD><INPUT NAME=tables TYPE=text CLASS=text VALUE='{$SK->vars['tables']}'></TD> </TR> <TR> <TD>خيارات النسخ:</TD> <TD><SELECT NAME=comp_method> {$SK->vars['comp_methods']} </SELECT></TD> </TR> <TR> <TD>خياراتgzip:</TD> <TD><SELECT NAME=comp_level> {$SK->vars['comp_levels']} </SELECT></TD> </TR> </TABLE> </FIELDSET> <FIELDSET onClick="document.skb.action[1].checked = 1;"> <LEGEND> <INPUT TYPE=radio NAME=action VALUE=restore> Restore / استرجاع قاعدة بيانات </LEGEND> <TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=2> <TR> <TD>قاعدة البيانات:</TD> <TD><SELECT NAME=db_restore> {$SK->vars['db_restore']} </SELECT></TD> </TR> <TR> <TD WIDTH=35%>اختر الملف:</TD> <TD WIDTH=65%><SELECT NAME=file> {$SK->vars['files']} </SELECT></TD> </TR> </TABLE> </FIELDSET> </SPAN> <SCRIPT> document.skb.action[{$SK->SET['last_action']}].checked = 1; </SCRIPT> HTML; } function tpl_process($title){ return <<<HTML <FIELDSET> <LEGEND>{$title} </LEGEND> <TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=2> <TR><TD COLSPAN=2><DIV ID=logarea STYLE="width: 100%; height: 140px; border: 1px solid #7F9DB9; padding: 3px; overflow: auto;"></DIV></TD></TR> <TR><TD WIDTH=31%>جاري نسخ الجدول :</TD><TD WIDTH=69%><TABLE WIDTH=100% BORDER=1 CELLPADDING=0 CELLSPACING=0> <TR><TD BGCOLOR=#FFFFFF><TABLE WIDTH=1 BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=#5555CC ID=st_tab STYLE="FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#CCCCFF,endColorStr=#5555CC); border-right: 1px solid #AAAAAA"><TR><TD HEIGHT=12></TD></TR></TABLE></TD></TR></TABLE></TD></TR> <TR><TD>جاري نسخ قاعدة البيانات:</TD><TD><TABLE WIDTH=100% BORDER=1 CELLSPACING=0 CELLPADDING=0> <TR><TD BGCOLOR=#FFFFFF><TABLE WIDTH=1 BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=#00AA00 ID=so_tab STYLE="FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#CCFFCC,endColorStr=#00AA00); border-right: 1px solid #AAAAAA"><TR><TD HEIGHT=12></TD></TR></TABLE></TD> </TR></TABLE></TD></TR></TABLE> </FIELDSET> <SCRIPT> var WidthLocked = false; function s(st, so){ document.getElementById('st_tab').width = st ? st + '%' : '1'; document.getElementById('so_tab').width = so ? so + '%' : '1'; } function l(str, color){ switch(color){ case 2: color = 'navy'; break; case 3: color = 'red'; break; case 4: color = 'maroon'; break; default: color = 'black'; } with(document.getElementById('logarea')){ if (!WidthLocked){ style.width = clientWidth; WidthLocked = true; } str = '<FONT COLOR=' + color + '>' + str + '</FONT>'; innerHTML += innerHTML ? "<BR>\\n" + str : str; scrollTop += 14; } } </SCRIPT> HTML; } function tpl_auth($error){ return <<<HTML <SPAN ID=error> <FIELDSET> <LEGEND>Îøèáêà</LEGEND> <TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=2> <TR> <TD>Äëÿ ðàáîòû Sypex Dumper Lite òðåáóåòñÿ:<BR> - Internet Explorer 5.5+, Mozilla ëèáî Opera 8+ (<SPAN ID=sie>-</SPAN>)<BR> - âêëþ÷åíî âûïîëíåíèå JavaScript ñêðèïòîâ (<SPAN ID=sjs>-</SPAN>)</TD> </TR> </TABLE> </FIELDSET> </SPAN> <SPAN ID=body STYLE="display: none;"> {$error} <FIELDSET> <LEGEND>تسجيل دخول </LEGEND> <TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=2> <TR> <TD WIDTH=41%>اسم المستخدم :</TD> <TD WIDTH=59%><INPUT NAME=login TYPE=text CLASS=text></TD> </TR> <TR> <TD>كلمة المرور :</TD> <TD><INPUT NAME=pass TYPE=password CLASS=text></TD> </TR> </TABLE> </FIELDSET> </SPAN> <SCRIPT> document.getElementById('sjs').innerHTML = '+'; document.getElementById('body').style.display = ''; document.getElementById('error').style.display = 'none'; var jsEnabled = true; </SCRIPT> HTML; } function tpl_l($str, $color = C_DEFAULT){ $str = preg_replace("/\s{2}/", " ", $str); return <<<HTML <SCRIPT>l('{$str}', $color);</SCRIPT> HTML; } function tpl_enableBack(){ return <<<HTML <SCRIPT>document.getElementById('back').disabled = 0;</SCRIPT> HTML; } function tpl_s($st, $so){ $st = round($st * 100); $st = $st > 100 ? 100 : $st; $so = round($so * 100); $so = $so > 100 ? 100 : $so; return <<<HTML <SCRIPT>s({$st},{$so});</SCRIPT> HTML; } function tpl_backup_index(){ return <<<HTML <CENTER> <H1>الوصول إلى هذه الصفحة غير مسموح به!<br> Access to the requested URL is not allowed! </H1> </CENTER> HTML; } function tpl_error($error){ return <<<HTML <FIELDSET> <LEGEND>لقد أدخلت اسم المستخدم أو كلمة مرور خاطئة</LEGEND> <TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=2> <TR> <TD ALIGN=center>{$error}</TD> </TR> </TABLE> </FIELDSET> HTML; } function SXD_errorHandler($errno, $errmsg, $filename, $linenum, $vars) { if ($errno == 2048) return true; return true; $dt = date("Y.m.d H:i:s"); $errmsg = addslashes($errmsg); echo tpl_l("{$dt}<BR><B>Âîçíèêëà îøèáêà!</B>", C_ERROR); echo tpl_l("{$errmsg} ({$errno})", C_ERROR); echo tpl_enableBack(); die(); } ?>
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
I made $15,000 * 2 hours
CSS | 24 min ago | 0.99 KB
✅ API Glitch (Docs Leak)
CSS | 28 min ago | 0.99 KB
[TLF - A KING'S MEMORY]
1 hour ago | 1.62 KB
ccounter.cpp
C++ | 5 hours ago | 3.61 KB
Untitled
5 hours ago | 3.94 KB
arasaka
C | 1 day ago | 3.14 KB
new
C | 1 day ago | 3.06 KB
old
C | 1 day ago | 3.06 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!