📄 admin.php
字号:
mysql_query("delete from ".$mysql_table_prefix."link_keyword where link_id=$link_id");
echo mysql_error();
print "<br><center><b>Page deleted</b></center>";
}
function cleanTemp() {
global $mysql_table_prefix;
$result = mysql_query("delete from ".$mysql_table_prefix."temp where level >= 0");
echo mysql_error();
$del = mysql_affected_rows();
print "<br><center><b>Temp table cleared, $del items deleted.</b></center>";
}
function clearLog() {
global $mysql_table_prefix;
$result = mysql_query("delete from ".$mysql_table_prefix."query_log where time >= 0");
echo mysql_error();
$del = mysql_affected_rows();
print "<br><center><b>Search log cleared, $del items deleted.</b></center>";
}
function cleanLinks() {
global $mysql_table_prefix;
$query = "select site_id from ".$mysql_table_prefix."sites";
$result = mysql_query($query);
echo mysql_error();
$todelete = array();
if (mysql_num_rows($result)>0) {
while ($row=mysql_fetch_array($result)) {
$todelete[]=$row['site_id'];
}
$todelete = implode(",", $todelete);
$sql_end = " not in ($todelete)";
}
$result = mysql_query("select link_id from ".$mysql_table_prefix."links where site_id".$sql_end);
echo mysql_error();
$del = mysql_num_rows($result);
while ($row=mysql_fetch_array($result)) {
$link_id=$row[link_id];
mysql_query("delete from ".$mysql_table_prefix."link_keyword where link_id=$link_id");
echo mysql_error();
mysql_query("delete from ".$mysql_table_prefix."links where link_id=$link_id");
echo mysql_error();
}
$result = mysql_query("select link_id from ".$mysql_table_prefix."links where site_id is NULL");
echo mysql_error();
$del += mysql_num_rows($result);
while ($row=mysql_fetch_array($result)) {
$link_id=$row[link_id];
mysql_query("delete from ".$mysql_table_prefix."link_keyword where link_id=$link_id");
echo mysql_error();
mysql_query("delete from ".$mysql_table_prefix."links where link_id=$link_id");
echo mysql_error();
}
print "<br><center><b>Links table cleaned, $del links deleted.</b></center>";
}
function cleanKeywords() {
global $mysql_table_prefix;
$query = "select keyword_id from ".$mysql_table_prefix."keywords";
$result = mysql_query($query);
echo mysql_error();
$del = 0;
while ($row=mysql_fetch_array($result)) {
$keyId=$row['keyword_id'];
$query = "select keyword_id from ".$mysql_table_prefix."link_keyword where keyword_id = $keyId";
$result2 = mysql_query($query);
echo mysql_error();
if (mysql_num_rows($result2) < 1) {
mysql_query("delete from ".$mysql_table_prefix."keywords where keyword_id=$keyId");
echo mysql_error();
$del++;
}
}
print "<br><center><b>Keywords table cleaned, $del keywords deleted.</b></center>";
}
function getStatistics() {
global $mysql_table_prefix;
$stats = array();
$keywordQuery = "select count(keyword_id) from ".$mysql_table_prefix."keywords";
$linksQuery = "select count(url) from ".$mysql_table_prefix."links";
$siteQuery = "select count(site_id) from ".$mysql_table_prefix."sites";
$indexQuery = "select count(link_id) from ".$mysql_table_prefix."link_keyword";
$categoriesQuery = "select count(category_id) from ".$mysql_table_prefix."categories";
$result = mysql_query($keywordQuery);
echo mysql_error();
if ($row=mysql_fetch_array($result)) {
$stats['keywords']=$row[0];
}
$result = mysql_query($linksQuery);
echo mysql_error();
if ($row=mysql_fetch_array($result)) {
$stats['links']=$row[0];
}
$result = mysql_query($indexQuery);
echo mysql_error();
if ($row=mysql_fetch_array($result)) {
$stats['index']=$row[0];
}
$result = mysql_query($siteQuery);
echo mysql_error();
if ($row=mysql_fetch_array($result)) {
$stats['sites']=$row[0];
}
$result = mysql_query($categoriesQuery);
echo mysql_error();
if ($row=mysql_fetch_array($result)) {
$stats['categories']=$row[0];
}
return $stats;
}
function addsite ($url, $title, $short_desc, $cat) {
global $mysql_table_prefix;
$short_desc = addslashes($short_desc);
$title = addslashes($title);
$url = $url;
$result = mysql_query("select site_ID from ".$mysql_table_prefix."sites where url='$url'");
echo mysql_error();
$rows = mysql_numrows($result);
if ($rows==0 ) {
$compurl=parse_url("".$url);
if ($compurl['path']=='')
$url=$url."/";
mysql_query("INSERT INTO ".$mysql_table_prefix."sites (url, title, short_desc) VALUES ('$url', '$title', '$short_desc')");
echo mysql_error();
$result = mysql_query("select site_ID from ".$mysql_table_prefix."sites where url='$url'");
echo mysql_error();
$row = mysql_fetch_row($result);
$site_id = $row[0];
$result=mysql_query("select category_id from ".$mysql_table_prefix."categories");
echo mysql_error();
while ($row=mysql_fetch_row($result)) {
$cat_id=$row[0];
if ($cat[$cat_id]=='on') {
mysql_query("INSERT INTO ".$mysql_table_prefix."site_category (site_id, category_id) values ('$site_id', '$cat_id')");
echo mysql_error();
}
}
} else {
print "<center><b>Site already in database</b></center>";
}
If (!mysql_error())
{
print "<br><center><b>Site added</b></center>" ;
} else {
echo mysql_error();
}
}
function indexscreen ($url, $reindex) {
global $mysql_table_prefix;
$check = "";
$spider_depth = 2;
if ($url=="") {
$url = "http://";
$advurl = "";
} else {
$advurl = $url;
$result = mysql_query("select spider_depth, required, disallowed from ".$mysql_table_prefix."sites " .
"where url='$url'");
echo mysql_error();
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_row($result);
$spider_depth = $row[0];
$must = $row[1];
$mustnot = $row[2];
}
}
?>
<div align="center"><center><table><tr><td valign="top" align="center" colspan="2">
<p> </p></td></tr>
<form action="spider.php" method="post">
<tr><td><b>地址:</b></td><td> <input type="text" name="url" size="48" value=<?print "\"$url\"";?></td></tr>
<tr><td><b>索引选项:</b></td><td>
<input type="radio" name="soption" value="full"> 全部<br>
<input type="radio" name="soption" value="level" checked>深度: <input type="text" name="maxlevel" size="2" value="<?print $spider_depth;?>"><br>
<?if ($reindex==1) $check="checked"?>
<input type="checkbox" name="reindex" value="1" <?print $check;?>> 蜘蛛再爬一次<br>
</td></tr>
<?
if ($_SESSION['index_advanced']==1){
?>
<tr><td></td><td><input type="checkbox" name="domaincb" value="1" > 蜘蛛能离开域名 <!--a href="javascript:;" onClick="window.open('hmm','newWindow','width=300,height=300,left=600,top=200,resizable');" >?</a--><br></td></tr>
<tr><td><b>URL 必须包括:</b></td><td><textarea name=in cols=35 rows=2 wrap="virtual"><?print $must;?></textarea></td></tr>
<tr><td><b>URL 必须排除:</b></td><td><textarea name=out cols=35 rows=2 wrap="virtual"><?print $mustnot;?></textarea></td></tr>
<?
}
?>
<tr><td></td><td><input type="submit" value="Start indexing"></td></tr>
<tr><td>
<?
if ($_SESSION['index_advanced']==1){
print "<a href='admin.php?f=12&adv=0&url=$advurl'>Hide advanced options</a>";
} else {
print "<a href='admin.php?f=12&adv=1&url=$advurl'>Advanced options</a>";
}
?>
</td><td></td></tr>
</form></table></center></div>
<?
}
function siteScreen($site_id) {
global $mysql_table_prefix;
$result = mysql_query("SELECT site_id, url, title, short_desc, indexdate from ".$mysql_table_prefix."sites where site_id=$site_id");
echo mysql_error();
$row=mysql_fetch_array($result);
if ($row['indexdate']=='') {
$indexstatus="<font color=\"red\">Not indexed</font>";
$indexoption="<a href=\"admin.php?f=12&url=$row[url]\">Index</a>";
} else {
$site_id = $row['site_id'];
$result2 = mysql_query("SELECT site_id from ".$mysql_table_prefix."pending where site_id =$site_id");
echo mysql_error();
$row2=mysql_fetch_array($result2);
if ($row2['site_id'] == $row['site_id']) {
$indexstatus = "Unfinished";
$indexoption="<a href=\"admin.php?f=12&url=$row[url]\">Continue indexing</a>";
} else {
$indexstatus = $row['indexdate'];
$indexoption="<a href=\"admin.php?f=12&url=$row[url]&reindex=1\">Re-index</a>";
}
}
?>
<br>
<center>
<table cellpadding="3" cellspacing="0" width="640">
<tr>
<td width="80%" valign="top">
<table cellspacing ="0" cellpadding="0" class="darkgrey" width ="100%"><tr><td>
<table cellpadding="5" cellspacing="1" width="100%">
<tr >
<td class="grey" valign="top">URL:</td>
<td class="white"><a href="<?print $row['url']; print "\">"; print $row['url'];?></a></td>
</tr>
<tr>
<td class="grey" valign="top">标题:</td>
<td class="white"><b><?print $row['title'];?></b></td>
</tr>
<tr>
<td class="grey" valign="top">描述:</td>
<td width="80%" class="white"><?print $row['short_desc'];?></td>
</tr>
<tr>
<td class="grey" valign="top">最后一次索引:</td>
<td class="white"><?print $indexstatus;?></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td valign="top">
<table cellspacing ="0" cellpadding="0" class="darkgrey" width ="100%"><tr><td>
<table cellpadding="2" cellspacing="1" width="100%">
<tr>
<td width="100%" class="grey"><a href=admin.php?f=3&site_id=<?print $row['site_id']?>>编辑</a></td>
</tr>
<tr>
<td width="100%" class="grey">
<?
print $indexoption;
?>
</td>
</tr>
<tr>
<td width="100%" class="grey"><a href=admin.php?f=21&site_id=<?print $row['site_id']?>>浏览网页</a></td>
</tr>
<tr>
<td width="100%" class="grey"><a href=admin.php?f=5&site_id=<?print $row['site_id'];?>
onclick="return confirm('Are you sure you want to delete? Index will be lost.')">删除</a></td>
</tr>
<tr>
<td width="100%" class="grey"><a href=admin.php?f=19&site_id=<?print $row['site_id'];?>>统计</a></td>
</tr>
</table></td></tr></table>
</td>
</tr>
</table>
</center>
<?
}
function siteStats($site_id) {
global $mysql_table_prefix;
$result = mysql_query("select url from ".$mysql_table_prefix."sites where site_id=$site_id");
echo mysql_error();
if ($row=mysql_fetch_array($result)) {
$url=$row[0];
$lastIndexQuery = "SELECT indexdate from ".$mysql_table_prefix."sites where site_id = $site_id";
$sumSizeQuery = "select sum(length(fulltxt)) from ".$mysql_table_prefix."links where site_id = $site_id";
$siteSizeQuery = "select sum(size) from ".$mysql_table_prefix."links where site_id = $site_id";
$linksQuery = "select count(*) from ".$mysql_table_prefix."links where site_id = $site_id";
$indexQuery = "select count(*) from ".$mysql_table_prefix."links, ".$mysql_table_prefix."link_keyword where ".$mysql_table_prefix."links.link_id=".$mysql_table_prefix."link_keyword.link_id and ".$mysql_table_prefix."links.site_id = $site_id";
$wordQuery = "select count(distinct keyword) from ".$mysql_table_prefix."keywords, ".$mysql_table_prefix."links, ".$mysql_table_prefix."link_keyword where ".$mysql_table_prefix."links.link_id=".$mysql_table_prefix."link_keyword.link_id and ".$mysql_table_prefix."links.site_id = $site_id and ".$mysql_table_prefix."keywords.keyword_id = ".$mysql_table_prefix."link_keyword.keyword_id";
$result = mysql_query($lastIndexQuery);
echo mysql_error();
if ($row=mysql_fetch_array($result)) {
$stats['lastIndex']=$row[0];
}
$result = mysql_query($sumSizeQuery);
echo mysql_error();
if ($row=mysql_fetch_array($result)) {
$stats['sumSize']=$row[0];
}
$result = mysql_query($linksQuery);
echo mysql_error();
if ($row=mysql_fetch_array($result)) {
$stats['links']=$row[0];
}
$result = mysql_query($indexQuery);
echo mysql_error();
if ($row=mysql_fetch_array($result)) {
$stats['index']=$row[0];
}
$result = mysql_query($wordQuery);
echo mysql_error();
if ($row=mysql_fetch_array($result)) {
$stats['words']=$row[0];
}
$result = mysql_query($siteSizeQuery);
echo mysql_error();
if ($row=mysql_fetch_array($result)) {
$stats['siteSize']=$row[0];
}
if ($stats['siteSize']=="")
$stats['siteSize'] = 0;
$stats['siteSize'] = number_format($stats['siteSize'], 2);
print "<br><center><table cellspacing =\"0\" cellpadding=\"0\" class=\"darkgrey\"><tr><td><table cellpadding=\"3\" cellspacing = \"1\"><tr class=\"grey\"><td colspan=\"2\">";
print "Statistics for site <a href=\"admin.php?f=20&site_id=$site_id\">$url</a>";
print "<tr class=\"white\"><td>Last indexed:</td><td align=\"center\"> ".$stats['lastIndex']."</td></tr>";
print "<tr class=\"grey\"><td>Pages indexed:</td><td align=\"center\"> ".$stats['links']."</td></tr>";
print "<tr class=\"white\"><td>Total index size:</td><td align=\"center\"> ".$stats['index']."</td></tr>";
$sum = number_format($stats['sumSize']/1024, 2);
print "<tr class=\"grey\"><td>Cached texts:</td><td align=\"center\"> ".$sum."kb</td></tr>";
print "<tr class=\"white\"><td>Total number of keywords:</td><td align=\"center\"> ".$stats['words']."</td></tr>";
print "<tr class=\"grey\"><td>Site size:</td><td align=\"center\"> ".$stats['siteSize']."kb</td></tr>";
print "</table></td></tr></table></center>";
}
}
function browsePages($site_id, $start, $filter, $per_page) {
global $mysql_table_prefix;
$result = mysql_query("select url from ".$mysql_table_prefix."sites where site_id=$site_id");
echo mysql_error();
$row = mysql_fetch_row($result);
$url = $row[0];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -