Ejemplo n.º 1
0
if (submitcheck('notesubmit', 1)) {
    if (!empty($_GET['noteid']) && is_numeric($_GET['noteid'])) {
        C::t('common_adminnote')->delete($_GET['noteid'], $isfounder ? '' : $_G['username']);
    }
    if (!empty($_GET['newmessage'])) {
        $newaccess = 0;
        $_GET['newexpiration'] = TIMESTAMP + (intval($_GET['newexpiration']) > 0 ? intval($_GET['newexpiration']) : 30) * 86400;
        $_GET['newmessage'] = nl2br(dhtmlspecialchars($_GET['newmessage']));
        $data = array('admin' => $_G['username'], 'access' => 0, 'adminid' => $_G['adminid'], 'dateline' => $_G['timestamp'], 'expiration' => $_GET['newexpiration'], 'message' => $_GET['newmessage']);
        C::t('common_adminnote')->insert($data);
    }
}
$serverinfo = PHP_OS . ' / PHP v' . PHP_VERSION;
$serverinfo .= @ini_get('safe_mode') ? ' Safe Mode' : NULL;
$serversoft = $_SERVER['SERVER_SOFTWARE'];
$dbversion = helper_dbtool::dbversion();
if (@ini_get('file_uploads')) {
    $fileupload = ini_get('upload_max_filesize');
} else {
    $fileupload = '<font color="red">' . $lang['no'] . '</font>';
}
$dbsize = helper_dbtool::dbsize();
$dbsize = $dbsize ? sizecount($dbsize) : $lang['unknown'];
if (isset($_GET['attachsize'])) {
    $attachsize = C::t('forum_attachment_n')->get_total_filesize();
    $attachsize = is_numeric($attachsize) ? sizecount($attachsize) : $lang['unknown'];
} else {
    $attachsize = '<a href="' . ADMINSCRIPT . '?action=index&attachsize">[ ' . $lang['detail'] . ' ]</a>';
}
$membersmod = C::t('common_member_validate')->count_by_status(0);
$threadsdel = C::t('forum_thread')->count_by_displayorder(-1);
Ejemplo n.º 2
0
 function updatetable($sql)
 {
     global $_G;
     $config = array('dbcharset' => $_G['config']['db']['1']['dbcharset'], 'charset' => $_G['config']['output']['charset'], 'tablepre' => $_G['config']['db']['1']['tablepre']);
     preg_match_all("/CREATE\\s+TABLE.+?pre\\_(.+?)\\s*\\((.+?)\\)\\s*(ENGINE|TYPE)\\s*=\\s*(\\w+)/is", $sql, $matches);
     $newtables = empty($matches[1]) ? array() : $matches[1];
     $newsqls = empty($matches[0]) ? array() : $matches[0];
     if (empty($newtables) || empty($newsqls)) {
         return array(1);
     }
     foreach ($newtables as $i => $newtable) {
         $newcols = updatetable_getcolumn($newsqls[$i]);
         //获取当前SQL
         if (!($query = DB::query("SHOW CREATE TABLE " . DB::table($newtable), 'SILENT'))) {
             //添加表
             preg_match("/(CREATE TABLE .+?)\\s*(ENGINE|TYPE)\\s*=\\s*(\\w+)/is", $newsqls[$i], $maths);
             $maths[3] = strtoupper($maths[3]);
             if ($maths[3] == 'MEMORY' || $maths[3] == 'HEAP') {
                 $type = helper_dbtool::dbversion() > '4.1' ? " ENGINE=MEMORY" . (empty($config['dbcharset']) ? '' : " DEFAULT CHARSET={$config['dbcharset']}") : " TYPE=HEAP";
             } else {
                 $type = helper_dbtool::dbversion() > '4.1' ? " ENGINE=MYISAM" . (empty($config['dbcharset']) ? '' : " DEFAULT CHARSET={$config['dbcharset']}") : " TYPE=MYISAM";
             }
             $usql = $maths[1] . $type;
             $usql = str_replace("CREATE TABLE IF NOT EXISTS pre_", 'CREATE TABLE IF NOT EXISTS ' . $config['tablepre'], $usql);
             $usql = str_replace("CREATE TABLE pre_", 'CREATE TABLE ' . $config['tablepre'], $usql);
             if (!DB::query($usql, 'SILENT')) {
                 return array(-1, $newtable);
             }
         } else {
             $value = DB::fetch($query);
             $oldcols = updatetable_getcolumn($value['Create Table']);
             //获取升级SQL文
             $updates = array();
             $allfileds = array_keys($newcols);
             foreach ($newcols as $key => $value) {
                 if ($key == 'PRIMARY') {
                     if ($value != $oldcols[$key]) {
                         if (!empty($oldcols[$key])) {
                             $usql = "RENAME TABLE " . DB::table($newtable) . " TO " . DB::table($newtable . '_bak');
                             if (!DB::query($usql, 'SILENT')) {
                                 return array(-1, $newtable);
                             }
                         }
                         $updates[] = "ADD PRIMARY KEY {$value}";
                     }
                 } elseif ($key == 'KEY') {
                     foreach ($value as $subkey => $subvalue) {
                         if (!empty($oldcols['KEY'][$subkey])) {
                             if ($subvalue != $oldcols['KEY'][$subkey]) {
                                 $updates[] = "DROP INDEX `{$subkey}`";
                                 $updates[] = "ADD INDEX `{$subkey}` {$subvalue}";
                             }
                         } else {
                             $updates[] = "ADD INDEX `{$subkey}` {$subvalue}";
                         }
                     }
                 } elseif ($key == 'UNIQUE') {
                     foreach ($value as $subkey => $subvalue) {
                         if (!empty($oldcols['UNIQUE'][$subkey])) {
                             if ($subvalue != $oldcols['UNIQUE'][$subkey]) {
                                 $updates[] = "DROP INDEX `{$subkey}`";
                                 $updates[] = "ADD UNIQUE INDEX `{$subkey}` {$subvalue}";
                             }
                         } else {
                             $usql = "ALTER TABLE  " . DB::table($newtable) . " DROP INDEX `{$subkey}`";
                             DB::query($usql, 'SILENT');
                             $updates[] = "ADD UNIQUE INDEX `{$subkey}` {$subvalue}";
                         }
                     }
                 } else {
                     if (!empty($oldcols[$key])) {
                         if (strtolower($value) != strtolower($oldcols[$key])) {
                             $updates[] = "CHANGE `{$key}` `{$key}` {$value}";
                         }
                     } else {
                         $i = array_search($key, $allfileds);
                         $fieldposition = $i > 0 ? 'AFTER `' . $allfileds[$i - 1] . '`' : 'FIRST';
                         $updates[] = "ADD `{$key}` {$value} {$fieldposition}";
                     }
                 }
             }
             //升级处理
             if (!empty($updates)) {
                 $usql = "ALTER TABLE " . DB::table($newtable) . " " . implode(', ', $updates);
                 if (!DB::query($usql, 'SILENT')) {
                     return array(-1, $newtable);
                 }
             }
         }
     }
     return array(1);
 }
Ejemplo n.º 3
0
function create_table($sql, $dbcharset) {
	$type = strtoupper(preg_replace("/^\s*CREATE TABLE\s+.+\s+\(.+?\).*(ENGINE|TYPE)\s*=\s*([a-z]+?).*$/isU", "\\2", $sql));
	$type = in_array($type, array('MYISAM', 'HEAP', 'MEMORY')) ? $type : 'MYISAM';
	return preg_replace("/^\s*(CREATE TABLE\s+.+\s+\(.+?\)).*$/isU", "\\1", $sql).
	(helper_dbtool::dbversion() > '4.1' ? " ENGINE=$type DEFAULT CHARSET=".$dbcharset : " TYPE=$type");
}