Code:
<?php
//Read in config file
$configfile = "admin/setup.php";
require($configfile);
if (!$inlinkvisit) {
setcookie("inlinkvisit", "1");
$cookieset = "1";
}
if ($action == "logout") {
setcookie("ilkadp" , "");
}
// rate a link
if ($action == "rate") {
// check if already voted
$voteda = explode(" ", $voted);
for ($votedan = 0; $votedan < count($voteda); ++$votedan) {
if ($voteda[$votedan] == $id) {
$novote = "1";
}
} //end checking
if ($novote != "1") {
setcookie("voted", $voted . " $id");
}
if ($novote != "1") {
$query = mysql_query("select * from links where linkid='$id'");
if ($row = mysql_fetch_array($query)) {
$rating = $row["rating"];
$votes = $row["votes"];
}
$totalrate = ($rating * $votes) + $rate;
$votes++;
$rating = $totalrate / $votes;
mysql_query("update links set rating='$rating', votes='$votes' where linkid='$id'");
}
}
if (($cat == "") || ($cat == "0")) {
$fd = fopen($ROOTTEMP, "r");
$temp = fread($fd, filesize($ROOTTEMP));
fclose($fd);
} elseif (file_exists("$FILEDIR$cat.txt")) {
$fd = fopen("$FILEDIR$cat.txt", "r");
$temp = fread($fd, filesize("$FILEDIR$cat.txt"));
fclose($fd);
} else {
$fd = fopen($MAINTEMP, "r");
$temp = fread($fd, filesize($MAINTEMP));
fclose($fd);
}
//counter
$stat = mysql_query("select * from stats where id='1'");
if ($statrow = mysql_fetch_array($stat)) {
$last_visited = $statrow["date"];
}
if ($cookieset == "1") {
mysql_query("update stats set hits=hits+1");
mysql_query("update stats set hitstoday=hitstoday+1");
}
if ($last_visited != date("ymd")) {
mysql_query("update stats set hitstoday='1'");
}
// define variables
$catq = "select * from cat where sub='$cat' order by name";
$linkq = "select * from links where catid='$cat' order by $order";
require($STATIC);
require($FUNCTIONS);
navbar();
getstats();
pagenav();
printcat();
printlink();
image($V);
//insert header footer
if (ereg("<%INSERT_HEADER%>", $temp)) {
$fd = fopen($HEADER, "r");
$header = fread($fd, filesize($HEADER));
fclose($fd);
$temp = ereg_replace("<%INSERT_HEADER%>", $header, $temp);
}
if (ereg("<%INSERT_FOOTER%>", $temp)) {
$fd = fopen($FOOTER, "r");
$footer = fread($fd, filesize($FOOTER));
fclose($fd);
$temp = ereg_replace("<%INSERT_FOOTER%>", $footer, $temp);
}
$temp = ereg_replace("<%INSERT_NAVBAR_HERE%>", $navbar, $temp);
$temp = ereg_replace("<%INSERT_SEARCH_FORM%>", $search, $temp);
$temp = ereg_replace("<%INSERT_RESULT_CATS%>", $cats, $temp);
$temp = ereg_replace("<%INSERT_RESULT_LINKS%>", $links, $temp);
$temp = ereg_replace("<%INSERT_RESULT_NAV%>", $nav, $temp);
$temp = ereg_replace("<%INSERT_FOOTER_LINKS%>", $botlinks, $temp);
$temp = ereg_replace("<%INSERT_VERSION%>", $img, $temp);
$temp = ereg_replace("<%INSERT_TOTAL_LINKS%>", $total_links, $temp);
$temp = ereg_replace("<%INSERT_TOTAL_CATS%>", $total_cats, $temp);
$temp = ereg_replace("<%INSERT_HITS_TODAY%>", $hits_today, $temp);
$temp = ereg_replace("<%INSERT_HITS_TOTAL%>", $hits_total, $temp);
//output HTML
print $temp;
?>
Bookmarks