예제 #1
0
 $sqlcharset = getval('sqlcharset');
 $extendins = getval('extendins');
 $sqlcompat = getval('sqlcompat');
 $usehex = intval(getval('usehex'));
 $_SGLOBAL['db']->query('SET SQL_QUOTE_SHOW_CREATE=0', 'SILENT');
 //Error-free execution off the table and I create a column without quotes
 if (empty($filename) || strlen($filename) > 40) {
     //Determine the length of the file name
     cpmessage('documents_were_incorrect_length');
 } else {
     $filename = preg_replace("/[^a-z0-9_]/i", '', str_replace('.', '_', $filename));
 }
 $tables = array();
 // backup mode
 if ($type == 'uchomes') {
     $tables = arraykeys2(fetchtablelist($tablepre), 'Name');
 } elseif ($type == 'custom') {
     if (isset($_POST['setup'])) {
         //POST submit backup
         $tables = empty($_POST['customtables']) ? array() : $_POST['customtables'];
         data_set('custombackup', $tables);
     } else {
         //Jump backup automatically
         $tables = data_get('custombackup');
         $tables = unserialize($tables);
     }
 }
 if (empty($tables) || !is_array($tables)) {
     cpmessage('backup_table_wrong');
 }
 $time = sgmdate('Y-m-d H:i:s', $_SGLOBAL['timestamp']);
예제 #2
0
파일: db.php 프로젝트: renduples/alibtob
     if ($admin_runquery) {
         $result = sql_run($_POST['sql_content']);
         if ($result) {
             flash("success");
         } else {
             flash();
         }
     } else {
         flash("admin_runquery_forbidden");
     }
 }
 if ($do == "backup") {
     $filename = date('ymd') . '_' . pb_radom(6);
     $db->query('SET SQL_QUOTE_SHOW_CREATE=0', 'SILENT');
     $time = gmdate("M d Y H:i:s", mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y")));
     $tables = arraykeys2(fetchtablelist($tb_prefix), 'Name');
     if (mysql_get_server_info() > '4.1') {
         $db->query("set names '" . $dbcharset . "'");
     }
     $backupfilename = DATA_PATH . "backup_" . $backupdir . DS . str_replace(array('/', '\\', '.'), '', $filename);
     $sqldump = '';
     $tableid = 0;
     $startfrom = 0;
     for (; $tableid < count($tables); $tableid++) {
         $sqldump .= sqldumptable($tables[$tableid], $startfrom, strlen($sqldump));
         $startfrom = 0;
     }
     $dumpfile = $backupfilename . '.sql';
     $tableid--;
     if (trim($sqldump)) {
         $fp = file_put_contents($dumpfile, $sqldump);
예제 #3
0
<input class="button" type="submit" name="exportsubmit" value="<?=$lang['submit']?>"></center></form>
<?

	} else {

		$db->query('SET SQL_QUOTE_SHOW_CREATE=0', 'SILENT');

		if(!$filename || preg_match("/(\.)(exe|jsp|asp|aspx|cgi|fcgi|pl)(\.|$)/i", $filename)) {
			cpmsg('database_export_filename_invalid');
		}

		$time = gmdate("$dateformat $timeformat", $timestamp + $timeoffset * 3600);
		if($type == 'discuz') {
			$tables = arraykeys2(fetchtablelist($tablepre), 'Name');
		} elseif($type == 'discuzsupesite') {
			$tables = arraykeys2(array_merge(fetchtablelist($tablepre), ($supe['tablepre'] ? fetchtablelist($supe['tablepre']) : array())), 'Name');
		} elseif($type == 'custom') {
			$tables = array();
			if(empty($setup)) {
				if($tables = $db->fetch_first("SELECT value FROM {$tablepre}settings WHERE variable='custombackup'")) {
					$tables = unserialize($tables['value']);
				}
			} else {
				$customtables= array_merge(empty($customtables) ? array() : $customtables, empty($supetables) ? array() : $supetables);
				$customtablesnew = empty($customtables)? '' : addslashes(serialize($customtables));
				$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('custombackup', '$customtablesnew')");
				$tables = & $customtables;
			}
			if( !is_array($tables) || empty($tables)) {
				cpmsg('database_export_custom_invalid');
			}