📄 maintain.php
字号:
<?php/*======================================================================*\|| #################################################################### |||| # VirtuaNews - 1.0.4 Pro License ID - [WDYL-WTN]|| # ---------------------------------------------------------------- # |||| # All code in this file is ?2002 VirtuaSystems . # |||| # This file may not be redistributed in whole or significant part. # |||| # --------------- VIRTUANEWS IS NOT FREE SOFTWARE ---------------- # |||| # http://www.virtuanews.co.uk # |||| # http://www.virtuanews.co.uk/license.php # |||| #################################################################### ||\*======================================================================*/if (preg_match("/(admin\/maintain.php)/i",$PHP_SELF)) { header("location:../admin.php"); exit;}updateadminlog();function dumptable($table) { $sqldump = "# Table structure for $table\n\nDROP TABLE IF EXISTS $table;\n"; $sqldump .= "CREATE TABLE $table (\n"; // Get field list $tablefields = 1; $getfields = query("SHOW FIELDS FROM $table"); while ($field_arr = fetch_array($getfields)) { $sqldump .= iif($tablefields == 1,"",",\n"); $sqldump .= " $field_arr[Field] ".strtoupper($field_arr[Type]); if ($field_arr["Default"] != "") { $sqldump .= " DEFAULT '$field[Default]'"; } if ($field_arr['Null'] != "YES") { $sqldump .= " NOT NULL"; } if ($field_arr[Extra] != "") { $sqldump .= " $field_arr[Extra]"; } $tablefields ++; } free_result($getfields); // Get keys list $getkeys = query("SHOW KEYS FROM $table"); while ($key_arr = fetch_array($getkeys)) { $kname = $key_arr['Key_name']; if (($kname != "PRIMARY") & ($key_arr['Non_unique'] == 0)) { $kname = "UNIQUE|$kname"; } if(!is_array($index[$kname])) { $index[$kname] = array(); } $index[$kname][] = $key_arr['Column_name']; } free_result($getkeys); // get each key info if ($index) { while(list($kname,$columns) = each($index)){ $sqldump .= ",\n"; $colnames = implode($columns,","); if ($kname == "PRIMARY"){ $sqldump .= " PRIMARY KEY ($colnames)"; } else { if (substr($kname,0,6) == "UNIQUE") { $sqldump .= " UNIQUE KEY ".substr($kname,7)." ($colnames)"; } else { $sqldump .= " KEY $kname ($colnames)"; } } } } $sqldump .= "\n);\n\n"; $sqldump .= "# Dumping data for table $table\n\n"; // get data $getrows = query("SELECT * FROM $table"); $numfields = countfields($getrows); while ($row_arr = fetch_array($getrows)) { $sqldump .= "INSERT INTO $table VALUES("; $fieldcounter = 1; // get each field's data while ($fieldcounter <= $numfields) { $sqldump .= iif($fieldcounter == 1,"",","); if (isset($row_arr[$fieldcounter-1]) == 0) { $sqldump .= "NULL"; } else { $sqldump .= "'".mysql_escape_string($row_arr[$fieldcounter-1])."'"; } $fieldcounter ++; } $sqldump .= ");\n"; } free_result($getrows); $sqldump .= "\n\n"; return $sqldump;}switch ($action) {case "maintain": echohtmlheader(); echotableheader("剪除数据"); echotabledescription("这你能剪除新闻帖子和评论并备份数据, 使用它能大规模删除旧的帖子并保存数据",1); echotabledescription("请注意, this can be a very server intensive process if you are deleting or backing up alot of data",1); $tablerows .= returnminitablerow("备份数据",returnlinkcode("这","admin.php?action=maintain_backup")); $tablerows .= returnminitablerow("剪除评论",returnlinkcode("这","admin.php?action=maintain_comments")); $tablerows .= returnminitablerow("剪除新闻",returnlinkcode("这","admin.php?action=maintain_news")); echotabledescription("\n".returnminitable($tablerows,0,25)." "); echotablefooter(); echohtmlfooter();break;case "maintain_import": if (!empty($script)) { if ($script == "membersarea") { header_redirect("http://safeurl.de/?http://members.virtuanews.co.uk","Members area"); } include("importers/importfunctions.php"); if (!@include("importers/".$script.".php")) { adminerror("Invalid Import Script","You have specified an invalid import script."); } exit; } else { echohtmlheader(); echoformheader("maintain_import","数据导入"); echotabledescription("你能使用这个设置导入数据到你的VirtuaNews数据库."); echotabledescription("Once you have chosen an import script, proceed through the import routine. <span class=\"red\">DO NOT</span> press your browser's 'back' button, or refresh any pages, as this can lead to items being imported twice."); echotabledescription("It is highly recommended the you <span class=\"red\">备份你的数据</span> before proceeding with this process."); unset($scriptoptions); if ($handle = @opendir("importers")) { while ($file = readdir($handle)) { if (($file != ".") & ($file != "..") & ($file != "importfunctions.php") & is_file("importers/$file")) { $importfile = file("importers/$file"); $scriptoptions .= " <option value=\"".preg_replace("/\.php$/","",$file)."\">".htmlspecialchars(str_replace("// ","",trim($importfile[1])))."</option>\n"; } } closedir($handle); } if (empty($scriptoptions)) { $scriptoptions = " <option value=\"membersarea\">You do not have any import scripts to use.</option>\n"; $scriptoptions .= " <option value=\"membersarea\">To get more please visit the VirtuaNews.</option>\n"; $scriptoptions .= " <option value=\"membersarea\">members area.</option>\n"; } echotablerow("Choose an import script:<br />".returnlinkcode("Get More Import Scripts","http://safeurl.de/?http://members.virtuanews.co.uk",1),"\n <select name=\"script\" size=\"5\" class=\"form\">\n$scriptoptions </script>\n ","",25); echoformfooter(); echohtmlfooter(); }break;case "maintain_comments": foreach ($cat_arr AS $key => $val) { $checkboxes .= returncheckboxcode("categories[$key]",1,$val[name]); } echohtmlheader(); echoformheader("maintain_comments_kill","剪除新闻评论"); echotabledescription("使用这个设置,从数据库中删除过期的你指定的评论。"); echotablerow("删除下列分类:","\n$checkboxes "); echoinputcode("删除相对较旧的评论: <span class=\"red\">(天数)</span>","num_days"); echoyesnocode("更新用户发帖数:","updatepostcounts",1); echoformfooter(); echohtmlfooter();break;case "maintain_comments_kill": settype($num_days,"integer"); if ($num_days == 0) { adminerror("无效的日期类型","天数必须是一个有效的整数"); } unset($cat_ids); unset($comment_ids); unset($news_ids); unset($user_ids); foreach ($cat_arr AS $key => $val) { if ($categories[$key]) { $cat_ids[] = $key; } } if ($cat_ids) { $getdata = query("SELECT news_comment.id, news_comment.newsid, news_comment.userid FROM news_comment LEFT JOIN news_news ON news_comment.newsid = news_news.id WHERE (news_comment.time < ".(time()-($num_days*86400)).") AND (news_news.catid IN (".join(",",$cat_ids)."))"); while ($data_arr = fetch_array($getdata)) { $comment_ids[] = $data_arr[id]; $news_ids[$data_arr[newsid]] ++; if ($data_arr[userid] & $updatepostcounts) { $user_ids[$data_arr[userid]] ++; } } if ($comment_ids) { query("DELETE FROM news_comment WHERE id IN (".join(",",$comment_ids).")"); foreach ($news_ids AS $key => $val) { $temp = query_first("SELECT news_comment.userid, news_comment.username AS name, ".$foruminfo[user_table].".".$foruminfo[username_field]." AS username FROM news_comment LEFT JOIN ".$foruminfo[user_table]." ON news_comment.userid = ".$foruminfo[user_table].".".$foruminfo[userid_field]." WHERE (news_comment.newsid = $key) ORDER BY news_comment.time DESC LIMIT 1"); query("UPDATE news_news SET lastcommentuser = '".iif($temp[userid],$temp[username],$temp[name])."' , commentcount = commentcount - '$val' WHERE id = $key"); } if ($user_ids) { foreach ($user_ids AS $key => $val) { query("UPDATE $foruminfo[user_table] SET $foruminfo[posts_field] = $foruminfo[posts_field] -'$val' WHERE $foruminfo[userid_field] = $key"); } } } } writeallpages();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -