本文整理汇总了PHP中syntablestruct函数的典型用法代码示例。如果您正苦于以下问题:PHP syntablestruct函数的具体用法?PHP syntablestruct怎么用?PHP syntablestruct使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了syntablestruct函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runquery
function runquery($queries){//执行sql语句
global $tablepre,$whereis;
$sqlquery = splitsql(str_replace(array(' cdb_', ' {tablepre}', ' `cdb_'), array(' '.$tablepre, ' '.$tablepre, ' `'.$tablepre), $queries));
$affected_rows = 0;
foreach($sqlquery as $sql) {
$sql = syntablestruct(trim($sql), $my_version > '4.1', $dbcharset);
if(trim($sql) != '') {
mysql_query(stripslashes($sql));
if($sqlerror = mysql_error()) {
break;
} else {
$affected_rows += intval(mysql_affected_rows());
}
}
}
if(strpos($queries,'seccodestatus') && $whereis == 'is_dz') {
dz_updatecache();
}
if(strpos($queries,'bbclosed') && $whereis == 'is_dz') {
dz_updatecache();
}
if(strpos($queries,'template') && $whereis == 'is_uch') {
uch_updatecache();
}
if(strpos($queries,'seccode_login') && $whereis == 'is_uch') {
uch_updatecache();
}
if(strpos($queries,'close') && $whereis == 'is_uch') {
uch_updatecache();
}
errorpage($sqlerror? $sqlerror : "数据库升级成功,影响行数: $affected_rows",'数据库升级');
if(strpos($queries,'settings') && $whereis == 'is_dz') {
require_once './include/cache.func.php';
updatecache('settings');
}
}
示例2: fread
if ($identify[3] == 'multivol') {
$sqldump .= fread($fp, filesize($datafile_root));
}
fclose($fp);
} else {
if (isset($_GET['autoimport'])) {
cpmessage('the_volumes_of_data_into_databases_success', 'admincp.php?ac=backup');
} else {
cpmessage('data_file_does_not_exist');
}
}
if ($identify[3] == 'multivol') {
$sqlquery = splitsql($sqldump);
unset($sqldump);
foreach ($sqlquery as $sql) {
$sql = syntablestruct(trim($sql), $_SGLOBAL['db']->version() > '4.1', $_SC['dbcharset']);
if (!empty($sql)) {
$_SGLOBAL['db']->query($sql, 'SILENT');
//Ignore error
if ($_SGLOBAL['db']->error() && $_SGLOBAL['db']->errno() != 1062) {
$_SGLOBAL['db']->halt('MySQL Query Error', $sql);
}
}
}
if (isset($_GET['delunzip'])) {
@unlink(S_ROOT . './data/' . $_GET['datafile']);
}
$identify[4] = intval($identify[4]);
$datafile_next = preg_replace("/-({$identify['4']})(\\..+)\$/", '-' . ($identify[4] + 1) . '\\2', $_GET['datafile']);
if ($identify[4] == 1) {
$showform = 5;
示例3: trim
}
}
if (isset($_GET['do'])) {
$do = trim($_GET['do']);
if ($do == "refresh" && !empty($_GET['id'])) {
$datafile = DATA_PATH . "backup_" . $backupdir . DS . $_GET['id'];
if (!file_exists($datafile)) {
flash("file_not_exists");
} else {
if (@($fp = fopen($datafile, 'rb'))) {
$sqldump = fread($fp, filesize($datafile));
fclose($fp);
$sqlquery = splitsql($sqldump);
unset($sqldump);
foreach ($sqlquery as $sql) {
$sql = syntablestruct(trim($sql), $db->version() > '4.1', $dbcharset);
if ($sql != '') {
$db->query($sql);
if (($sqlerror = $db->error()) && $db->errno() != 1062) {
$db->halt('MySQL Query Error', $sql);
}
}
}
flash("db_restored", "db.php?do=restore");
} else {
flash();
}
}
}
if ($do == "del" && !empty($_GET['id'])) {
$datafile = DATA_PATH . "backup_" . $backupdir . DS . $_GET['id'];
示例4: template
if ($checkperm !== true) {
$msg = $checkperm;
$msg_type = 'text-error';
include template('database');
exit;
}
$runquerys = array();
//include_once(DZZ_ROOT.'source/admincp/admincp_quickquery.php');
if (!submitcheck('sqlsubmit')) {
} else {
$queries = $_GET['queries'];
$sqlquery = splitsql(str_replace(array(' {tablepre}', ' cdb_', ' `cdb_', ' pre_', ' `pre_'), array(' ' . $tablepre, ' ' . $tablepre, ' `' . $tablepre, ' ' . $tablepre, ' `' . $tablepre), $queries));
$affected_rows = 0;
foreach ($sqlquery as $sql) {
if (trim($sql) != '') {
$sql = !empty($_GET['createcompatible']) ? syntablestruct(trim($sql), $db->version() > '4.1', $dbcharset) : $sql;
DB::query($sql, 'SILENT');
if ($sqlerror = DB::error()) {
break;
} else {
$affected_rows += intval(DB::affected_rows());
}
}
}
if ($sqlerror) {
$msg = lang('template', 'database_run_query_invalid', array('sqlerror' => $sqlerror));
$msg_type = 'text-error';
$redirecturl = dreferer();
} else {
$msg = lang('template', 'database_run_query_succeed', array('affected_rows' => $affected_rows));
$msg_type = 'text-success';
示例5: mediumint
$indexoption[] = $identifier;
}
}
}
$create_table_sql .= ($create_tableoption_sql ? $create_tableoption_sql . ',' : '') . "tid mediumint(8) UNSIGNED NOT NULL DEFAULT '0',fid smallint(6) UNSIGNED NOT NULL DEFAULT '0',dateline int(10) UNSIGNED NOT NULL DEFAULT '0',expiration int(10) UNSIGNED NOT NULL DEFAULT '0',";
$create_table_sql .= "KEY (fid), KEY(dateline)";
if ($indexoption) {
foreach ($indexoption as $index) {
$create_table_sql .= "{$separator} KEY {$index} ({$index})\r\n";
$separator = ' ,';
}
}
$create_table_sql .= ") TYPE=MyISAM;";
$dbcharset = empty($dbcharset) ? str_replace('-', '', CHARSET) : $dbcharset;
$db = DB::object();
$create_table_sql = syntablestruct($create_table_sql, $db->version() > '4.1', $dbcharset);
DB::query($create_table_sql);
} else {
$tables = array();
$db = DB::object();
if ($db->version() > '4.1') {
$query = DB::query("SHOW FULL COLUMNS FROM " . DB::table('forum_optionvalue') . "{$_G['gp_sortid']}", 'SILENT');
} else {
$query = DB::query("SHOW COLUMNS FROM " . DB::table('forum_optionvalue') . "{$_G['gp_sortid']}", 'SILENT');
}
while ($field = @DB::fetch($query)) {
$tables[$field['Field']] = 1;
}
foreach ($addoption as $optionid => $option) {
$identifier = $insertoptionid[$optionid]['identifier'];
if (!$tables[$identifier]) {
示例6: fread
$sqldump .= fread($fp, filesize($datafile));
}
fclose($fp);
} else {
if (getgpc('autoimport', 'G')) {
touch($lock_file);
show_msg('database_import_multivol_succeed', '', 'message', 1);
} else {
show_msg('database_import_file_illegal');
}
}
if ($dumpinfo['method'] == 'multivol') {
$sqlquery = splitsql($sqldump);
unset($sqldump);
foreach ($sqlquery as $sql) {
$sql = syntablestruct(trim($sql), $db->version() > '4.1', DBCHARSET);
if ($sql != '') {
$db->query($sql, 'SILENT');
if (($sqlerror = $db->error()) && $db->errno() != 1062) {
$db->halt('MySQL Query Error', $sql);
}
}
}
$delunzip = getgpc('delunzip', 'G');
if ($delunzip) {
@unlink($datafile);
}
$datafile_next = preg_replace("/-({$dumpinfo['volume']})(\\..+)\$/", "-" . ($dumpinfo['volume'] + 1) . "\\2", $datafile);
$datafile_next = urlencode($datafile_next);
if ($dumpinfo['volume'] == 1) {
show_msg(lang('database_import_multivol_redirect', TRUE, array('volume' => $dumpinfo['volume'])), $siteurl . "restore.php?operation=import&datafile_server={$datafile_next}&autoimport=yes&importsubmit=yes&confirm=yes" . (!empty($delunzip) ? '&delunzip=yes' : ''), 'redirect');
示例7: DoImport
function DoImport()
{
$this->CheckAdminPrivs('dbimport');
extract($this->Post);
extract($this->Get);
$readerror = 0;
$datafile = '';
if($from == 'server') {
$datafile = ROOT_PATH.'./'.$datafile_server;
}
$dbcharset = $this->DatabaseHandler->Charset;
if(@$fp = fopen($datafile, 'rb')) {
$sqldump = fgets($fp, 256);
$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", $sqldump)));
$dumpinfo = array('method' => $identify[3], 'volume' => intval($identify[4]));
if($dumpinfo['method'] == 'multivol') {
$sqldump .= fread($fp, filesize($datafile));
}
fclose($fp);
} else {
if($autoimport) {
clearcache();
$this->Messager('分卷数据成功导入数据库。',null);
} else {
$this->Messager('数据文件不存在: 可能服务器不允许上传文件或尺寸超过限制。',null);
}
}
if($dumpinfo['method'] == 'multivol') {
$sqlquery = splitsql($sqldump);
unset($sqldump);
$supetablepredot = strpos($supe['tablepre'], '.');
$supe['dbname'] = $supetablepredot !== FALSE ? substr($supe['tablepre'], 0, $supetablepredot) : '';
foreach($sqlquery as $sql) {
$sql = syntablestruct(trim($sql), $this->DatabaseHandler->GetVersion() > '4.1', $dbcharset);
if(substr($sql, 0, 11) == 'INSERT INTO') {
$sqldbname = substr($sql, 12, 20);
$dotpos = strpos($sqldbname, '.');
if($dotpos !== FALSE) {
if(empty($supe['dbmode'])) {
$sql = 'INSERT INTO `'.$supe['dbname'].'`.'.substr($sql, 13 + $dotpos);
} else {
}
}
}
if($sql != '') {
$this->DatabaseHandler->Query($sql, 'SKIP_ERROR');
if(($sqlerror = $this->DatabaseHandler->GetLastErrorString()) && $this->DatabaseHandler->GetLastErrorNo() != 1062) {
die('MySQL Query Error'.$sql);
}
}
}
if($delunzip) {
@unlink($datafile_server);
}
$datafile_next = preg_replace("/-($dumpinfo[volume])(\..+)$/", "-".($dumpinfo['volume'] + 1)."\\2", $datafile_server);
if($dumpinfo['volume'] == 1) {
$to="admin.php?mod=db&code=doimport&from=server&datafile_server=".urlencode($datafile_next)."&autoimport=yes&importsubmit=yes".(!empty($delunzip) ? '&delunzip=yes' : '');
$msg=' <form method="post" action="'.$to.'">
<br /><br /><br />分卷数据成功导入数据库,您需要自动导入本次其它的备份吗?<br /><br /><br /><br />
<input type="hidden" name="FORMHASH" value="'.FORMHASH.'">
<input class="button" type="submit" name="confirmed" value=" 确 定 ">
<input class="button" type="button" value=" 取 消 " onClick="history.go(-1);">
</form><br />';
$this->Messager($msg,null);
} elseif($autoimport) {
$this->Messager("数据文件 #{$dumpinfo['volume']} 成功导入,程序将自动继续。", "admin.php?mod=db&code=doimport&from=server&datafile_server=".urlencode($datafile_next)."&autoimport=yes&importsubmit=yes".(!empty($delunzip) ? '&delunzip=yes' : ''));
} else {
clearcache();
$this->Messager('数据成功导入数据库。',null);
}
} elseif($dumpinfo['method'] == 'shell') {
require './config.inc.php';
list($dbhost, $dbport) = explode(':', $dbhost);
$query = $this->DatabaseHandler->Query("SHOW VARIABLES LIKE 'basedir'");
list(, $mysql_base) = $db->fetch_array($query, MYSQL_NUM);
$mysqlbin = $mysql_base == '/' ? '' : addslashes($mysql_base).'bin/';
shell_exec($mysqlbin.'mysql -h"'.$dbhost.($dbport ? (is_numeric($dbport) ? ' -P'.$dbport : ' -S"'.$dbport.'"') : '').
'" -u"'.$dbuser.'" -p"'.$dbpw.'" "'.$dbname.'" < '.$datafile);
clearcache();
$this->Messager('数据成功导入数据库。',null);
} else {
$this->Messager('数据文件非 天天团购 格式,无法导入。');
}
}
示例8: DoImport
function DoImport()
{
if (true !== JISHIGOU_FOUNDER) {
$this->Messager("为安全起见,只有网站创始人才能执行数据恢复操作。", null);
}
$readerror = 0;
$datafile = '';
$from = get_param('from');
$datafile_server = get_param('datafile_server');
$datafile_server = dir_safe($datafile_server);
if (false == preg_match('~^\\.\\/data\\/backup\\/db\\/([\\w\\d\\-\\_]+)\\/\\1(\\-\\d+)?\\.sql$~i', $datafile_server)) {
$this->Messager("文件名参数传递有误,请返回重试", null);
}
$autoimport = get_param('autoimport');
$supe = get_param('supe');
$delunzip = get_param('delunzip');
if ($from == 'server') {
$datafile = RELATIVE_ROOT_PATH . './' . $datafile_server;
}
$dbcharset = $this->DatabaseHandler->Charset;
if ($datafile && false != ($fp = @fopen($datafile, 'rb'))) {
$sqldump = fgets($fp, 256);
$identify = explode(',', base64_decode(preg_replace("/^# Identify:\\s*(\\w+).*/s", "\\1", $sqldump)));
$dumpinfo = array('method' => $identify[3], 'volume' => intval($identify[4]));
if ($dumpinfo['method'] == 'multivol') {
$sqldump .= @fread($fp, filesize($datafile));
}
fclose($fp);
} else {
if ($autoimport) {
cache_clear();
$this->Messager('分卷数据成功导入数据库。', null);
} else {
$this->Messager('数据文件不存在: 可能服务器不允许上传文件或尺寸超过限制。', null);
}
}
if ($dumpinfo['method'] == 'multivol') {
$sqlquery = splitsql($sqldump);
unset($sqldump);
$supetablepredot = strpos($supe['tablepre'], '.');
$supe['dbname'] = $supetablepredot !== FALSE ? substr($supe['tablepre'], 0, $supetablepredot) : '';
foreach ($sqlquery as $sql) {
$sql = syntablestruct(trim($sql), $this->DatabaseHandler->GetVersion() > '4.1', $dbcharset);
if (substr($sql, 0, 11) == 'INSERT INTO') {
$sqldbname = substr($sql, 12, 20);
$dotpos = strpos($sqldbname, '.');
if ($dotpos !== FALSE) {
if (empty($supe['dbmode'])) {
$sql = 'INSERT INTO `' . $supe['dbname'] . '`.' . substr($sql, 13 + $dotpos);
} else {
}
} else {
$sql = 'REPLACE INTO ' . substr($sql, 11);
}
}
if ($sql != '') {
$this->DatabaseHandler->Query($sql, 'SKIP_ERROR');
if (($sqlerror = $this->DatabaseHandler->GetLastErrorString()) && $this->DatabaseHandler->GetLastErrorNo() != 1062) {
die('MySQL Query Error' . $sql);
}
}
}
if ($delunzip) {
@unlink($datafile_server);
}
$datafile_next = preg_replace("/\\-({$dumpinfo['volume']})(\\.sql)\$/i", "-" . ($dumpinfo['volume'] + 1) . "\\2", $datafile_server);
if ($dumpinfo['volume'] == 1) {
$to = "admin.php?mod=db&code=doimport&from=server&datafile_server=" . urlencode($datafile_next) . "&autoimport=yes&importsubmit=yes" . (!empty($delunzip) ? '&delunzip=yes' : '');
$msg = '<form method="post" action="' . $to . '">
<input type="hidden" name="FORMHASH" value="' . FORMHASH . '" />
<br /><br /><br />分卷数据成功导入数据库,您需要自动导入本次其它的备份吗?<br /><br /><br /><br />
<input class="button" type="submit" name="confirmed" value=" 确 定 ">
<input class="button" type="button" value=" 取 消 " onClick="history.go(-1);">
</form><br />';
$this->Messager($msg, null);
} elseif ($autoimport) {
$this->Messager("数据文件 #{$dumpinfo['volume']} 成功导入,程序将自动继续。", "admin.php?mod=db&code=doimport&from=server&datafile_server=" . urlencode($datafile_next) . "&autoimport=yes&importsubmit=yes" . (!empty($delunzip) ? '&delunzip=yes' : ''));
} else {
cache_clear();
$this->Messager('数据成功导入数据库。', null);
}
} else {
$this->Messager('数据文件非 JishiGou 格式,无法导入。');
}
}