// ----------------------------------------------------------------------
// Fast TopSites - Top List System
// Copyright (c) 2003 by Dmitry Ignatyev (ftrain@mail.ru)
// http://www.ftrain.hotbox.ru/
// ----------------------------------------------------------------------
// Original Author of file: Dmitry Ignatyev
// ----------------------------------------------------------------------
require("func.php");
require("fdb.php");
if(file_exists($VARS[DDIR]."/vars.php"))
include($VARS[DDIR]."/vars.php");
$VARS["VER"] = "1.0.1";
$time = time();
## Rerank the list
function rerankList($buildCat = false){
global $VARS;
$mem = fdbopen("$VARS[DDIR]/members", "r");
if(!$mem) err('Cannot open Members Base');
fdbclose($mem);
$hits = fdbopen("$VARS[DDIR]/hits", "r");
if(!$hits) err('Cannot open Hits Base');
fdbclose($hits);
$time = time();
$rstime = freadline("$VARS[DDIR]/times/reset");
$tpl[NUPDT] = date("m-d-y h:ia", $time + $VARS[RR] + (3600 * $VARS[TZ]));
$tpl[LUPDT] = date("m-d-y h:ia", $time + (3600 * $VARS[TZ]));
$tpl[LRSET] = date("m-d-y h:ia", $rstime + (3600 * $VARS[TZ]));
$tpl[NRSET] = date("m-d-y h:ia", $rstime + $VARS[RS] + (3600 * $VARS[TZ]));
$tpl[PURL] = $VARS[PU];
$tpl[CATP] = 'Overall';
$cats = explode(",", $VARS[CT]);
while(list($key, $val) = each($cats))
{
$tpl[CATS] .= "\n";
$tpl[$val] = 0;
}
$tpl[TOT] = 0;
$memb = array();
//print_r($mem);
//echo "
";
while(list($key, $val) = each($mem))
if(($key != "_f") && ($key != "_fname") && ($key != "_mode"))
{
$row = explode("|", $mem[$key]);
if(($row[17] != "N") && $row[18] == "N")
{
$tpl[TOT]++;
$row2 = explode("|", $hits[$key]);
if(isset($tpl[$row[9]]))
$tpl[$row[9]]++;
if(($row2[1] * $row[12]) >= $VARS[MH])
{
# $memb[$key] = $row2[1]; // old Feb 21 2004
$memb[$key] = round($row2[1] * $row[12]);
// echo $key, "-" , $row2[1] , "-", $row[12], "
";
// $memb[$key] = $row2[2];
// from category buliding
// $tpl[IN] = round($row2[1]*$row[12]);
//
}
}
}
reset($mem);
arsort($memb);
//print_r($memb);
//echo "
";
$num = sizeof($memb);
##
## Build overall pages
##
while(list($page, $range) = each($VARS[OH]))
{
//echo $page, $range, "
";
list($start, $end) = explode("-", $range);
$start = intval($start);
$end = intval($end);
getSOM($memb, $mem, range(1, $num), $tpl);
reset($memb);
include($VARS[DDIR]."/html/".$page);
$FOOT .= getMember();
$tpl[STITLE] = $VARS[TITLE];
writef($VARS[HD]."/".$page, vparseRet($HEAD, $tpl));
$tpl[ROWC] = $VARS[C1];
for($i = 1; $i <= $end; $i++)
{
if($i < $start) { next($memb); continue; }
$tpl[ORANK] = $i; // main page
## If there are more results, process them
if($i <= $num)
{
list($key, $val) = each($memb);
$row = explode("|", $mem[$key]);
$row2 = explode("|", $hits[$key]);
$crank[$row[9]]++;
$cats[$row[9]] .= "$i,";
//print_r($row);
if($VARS[TO][$i])
$tpl[FSIZE] = $VARS[TO][$i];
$tpl[CRANK] = $crank[$row[9]];
$tpl[TITLE] = strtoupper($row[7]);
$tpl[SDES] = $row[8];
$tpl[CAT] = $row[9];
$tpl[IN] = round($row2[1]*$row[12]);
//echo $key, $tpl[IN], "
";
$tpl[OUT] = $row2[2];
$tpl[TIN] = round($row2[3]*$row[12]);
$tpl[TOUT] = $row2[4];
$tpl[CATL] = $VARS[HU].'/'.htmlName($row[9], $VARS[FE]);
$tpl[OURL] = $VARS[OU]."?id=".$row[0]."&url=".urlencode($row[2]);
$tpl[USER] = $row[0];
$tpl[SURL] = $row[2];
$tpl[ICONS] = getIcons($row[10]);
$tpl[PORANK] = $row2[8] == 9999999 ? $VARS[NRANK] : $row2[8];
$tpl[PCRANK] = $row2[9] == 9999999 ? $VARS[NRANK] : $row2[9];
$tpl[PIN] = $row2[6];
$tpl[POUT] = $row2[7];
$tpl[PSORT] = $row2[5];
$tpl[IPDAY] = getAvg($tpl[TIN], $time - $row[20], 86400);
$tpl[IPWEK] = getAvg($tpl[TIN], $time - $row[20], 604800);
$tpl[IPMTH] = getAvg($tpl[TIN], $time - $row[20], 2592000);
$tpl[OPDAY] = getAvg($tpl[TOUT], $time - $row[20], 86400);
$tpl[OPWEK] = getAvg($tpl[TOUT], $time - $row[20], 604800);
$tpl[OPMTH] = getAvg($tpl[TOUT], $time - $row[20], 2592000);
$tpl['NEW'] = $time - $row[11] <= $VARS[NS] ? $VARS[NI] : '';
$tpl[BANNER] = getBanner($i, $row[3], $row[4], $row[5], $row);
$tpl[MOVE] = getMove($i, $row2[8]);
fappend($VARS[HD]."/".$page, vparseRet($TEMP, $tpl));
if($VARS[LBO][$i] && file_exists($VARS[DDIR]."/breaks/".$i.".Overall"))
fappend($VARS[HD]."/".$page, freadall($VARS[DDIR]."/breaks/".$i.".Overall"));
}
## Otherwise, (if selected) fill in the remaining ranks with filler HTML
else
{
if($VARS[OFL])
{
fappend($VARS[HD]."/".$page, vparseRet($FILL, $tpl));
if($VARS[LBO][$i] && file_exists("$VARS[DDIR]/breaks/$i.Overall"))
fappend($VARS[HD]."/".$page, freadall($VARS[DDIR]."/breaks/".$i.".Overall"));
}
}
$tpl[ROWC] = $tpl[ROWC] == $VARS[C1] ? $VARS[C2] : $VARS[C1];
} ## End for($i = $start; $i <= $end; $i++)
fappend($VARS[HD]."/".$page, vparseRet($FOOT, $tpl));
} ## End while(list($page,$range) = each($VARS[OH]))
if($i <= $num)
{
while(list($key, $val) = each($memb))
{
$row = explode("|", $mem[$key]);
$cats[$row[9]] .= "$i,";
$i++;
}
}
##
## Build category pages
##
if($VARS[GSP] && ($buildCat || $VARS[BCR]))
{
$categories = explode(",", $VARS[CT]);
while(list($key, $cat) = each($categories))
{
$cranks = explode(",", $cats[$cat]);
array_pop($cranks);
$start = 0;
$end = 0;
$c = 0;
while(list($page, $range) = @each($VARS[$cat]))
{
list($start, $end) = explode("-", $range);
$start = intval($start);
$end = intval($end);
reset($memb);
for($j = 0; $j < $start-1; $j++)
list($key, $val) = each($memb);
getSOM($memb, $mem, $cranks, $tpl);
$tpl[CATP] = $cat;
include($VARS[DDIR]."/html/".$page);
$FOOT .= getMember();
$tpl[STITLE] = $VARS[TITLE];
writef($VARS[HD]."/".$page, vparseRet($HEAD, $tpl));
$num = substr_count($cats[$cat], ",");
$tpl[ROWC] = $VARS[C1];
for($i = $start; $i <= $end; $i++)
{
$c++;
reset($memb);
for($j = 0; $j < $cranks[$i-1]-1; $j++)
next($memb);
$tpl[CRANK] = $i;
## If there are more results, process them
if($i <= $num)
{
list($key, $val) = each($memb);
$row = explode("|", $mem[$key]);
if($row[9] != $cat) continue;
$row2 = explode("|", $hits[$key]);
if($VARS[TC][$i])
$tpl[FSIZE] = $VARS[TC][$i];
//$tpl[ORANK] = $cranks[$i-1];
$tpl[ORANK] = $c;
$tpl[TITLE] = strtoupper($row[7]);
$tpl[SDES] = $row[8];
$tpl[CAT] = $row[9];
$tpl[IN] = round($row2[1]*$row[12]);
$tpl[OUT] = $row2[2];
$tpl[TIN] = round($row2[3]*$row[12]);
$tpl[TOUT] = $row2[4];
$tpl[CATL] = $VARS[HU].'/'.htmlName($row[9], $VARS[FE]);
$tpl[OURL] = $VARS[OU]."?id=".$row[0]."&url=".urlencode($row[2]);
$tpl[USER] = $row[0];
$tpl[SURL] = $row[2];
$tpl[ICONS] = getIcons($row[10]);
$tpl[PORANK] = $row2[8] == 9999999 ? $VARS[NRANK] : $row2[8];
$tpl[PCRANK] = $row2[9] == 9999999 ? $VARS[NRANK] : $row2[9];
$tpl[PIN] = $row2[6];
$tpl[POUT] = $row2[7];
$tpl[PSORT] = $row2[6];
$tpl[IPDAY] = getAvg($tpl[TIN], $time - $row[20], 86400);
$tpl[IPWEK] = getAvg($tpl[TIN], $time - $row[20], 604800);
$tpl[IPMTH] = getAvg($tpl[TIN], $time - $row[20], 2592000);
$tpl[OPDAY] = getAvg($tpl[TOUT], $time - $row[20], 86400);
$tpl[OPWEK] = getAvg($tpl[TOUT], $time - $row[20], 604800);
$tpl[OPMTH] = getAvg($tpl[TOUT], $time - $row[20], 2592000);
$tpl['NEW'] = $time - $row[11] <= $VARS[NS] ? $VARS[NI] : "";
$tpl[BANNER] = getBanner($i, $row[3], $row[4], $row[5], $row);
$tpl[MOVE] = getMove($i, $row2[9]);
fappend($VARS[HD]."/".$page, vparseRet($TEMP, $tpl));
if($VARS[LBC][$i] && file_exists($VARS[DDIR]."/breaks/".$i.".".$cat))
fappend($VARS[HD]."/".$page, freadall($VARS[DDIR]."/breaks/".$i.".".$cat));
}
## Otherwise, (if selected) fill in the remaining ranks with filler HTML
else
{
if($VARS[CFL])
{
//$tpl[ORANK]++;
// $tpl[ORANK] = $tpl[CRANK]; // mine
$tpl[ORANK] = $c;
fappend($VARS[HD]."/".$page, vparseRet($FILL, $tpl));
if($VARS[LBC][$i] && file_exists($VARS[DDIR]."/breaks/".$i.".".$cat))
fappend($VARS[HD]."/".$page, freadall($VARS[DDIR]."/breaks/".$i.".".$cat));
}
}
$tpl[ROWC] = $tpl[ROWC] == $VARS[C1] ? $VARS[C2] : $VARS[C1];
} ## End for loop
fappend($VARS[HD]."/".$page, vparseRet($FOOT, $tpl));
} ## End while each page in category
} ## End while each category
} ## End if building category pages
}
function resetList() {
global $VARS;
$count = 0;
$hits = fdbopen("$VARS[DDIR]/hits", "r+");
if(!$hits) err('Cannot open Hits Base');
while(list($key, $val) = each($hits))
if(($key != "_f") && ($key != "_fname") && ($key != "_mode")) {
$row2 = explode("|", $hits[$key]);
$hits[$key] = $row2[0]."|".$row2[1]."|".$row2[2]."|".$row2[3]."|".$row2[4]."|0|0|0|9999999|9999999|".$row2[10];
}
reset($hits);
$mem = fdbopen("$VARS[DDIR]/members", "r");
if(!$mem) err('Cannot open Members Base');
fdbclose($mem);
## Sort the members
$memb = array();
while(list($key, $val) = each($mem))
if(($key != "_f") && ($key != "_fname") && ($key != "_mode")) {
$row = explode("|", $mem[$key]);
if($row[17] != "N")
{
$row2 = explode("|", $hits[$key]);
$memb[$key] = $row2[2];
// $memb[$key] = $row2[1];
}
}
reset($mem);
arsort($memb);
mt_srand((double)microtime()*1000000);
$mstat = fdbopen("$VARS[DDIR]/mstat", "r+");
if(!$mstat) err('Cannot open Stat Base');
## For each member, setup their previous sort value,
## previous in, previous out, category rank and overall rank
while(list($key, $val) = each($memb)) {
$row = explode("|", $mem[$key]);
$row2 = explode("|", $hits[$key]);
$crank[$row[9]]++;
$count++;
$mstat[$key."_".mt_rand(0, 9999)] = $row[0]."|".time()."|".$row2[1]."|".
$row2[2]."|".$row2[3]."|".$row2[4]."|".
$count."|".$crank[$row[9]]."|".
$row[12]."|".$row[20];
$hits[$key] = $row2[0]."|0|0|".$row2[3]."|".$row2[4]."|".
($row2[1] * $row[12])."|".$row2[1]."|".$row2[2]."|".
$count."|".$crank[$row[9]]."|";
if($row2[1] == 0)
$hits[$key] .= ($row2[10] + 1);
else
$hits[$key] .= "0";
}
fdbclose($hits);
fdbclose($mstat);
}
function getSOM($res, $mem, $choices, &$tpl) {
global $VARS;
$tpl[SOMOURL] = $tpl[SOMSURL] = $tpl[SOMTITLE] = $tpl[SOMBAN] = $tpl[SOMSDES] = $tpl[SOMICONS] = "";
if(count($choices)) {
srand((double)microtime() * 10000000);
$key = array_rand($choices);
$key = $choices[$key] - 1;
reset($res);
for($i=0; $i <= $key; $i++)
list($k, $v) = each($res);
$row = explode("|", $mem[$k]);
$tpl[SOMTITLE] = strtoupper($row[7]);
$tpl[SOMOURL] = $tpl[OURL] = $VARS[OU]."?id=".$row[0]."&url=".urlencode($row[2]);
$tpl[SOMSURL] = $row[2];
$tpl[SOMBAN] = getBanner(0, $row[3], $row[4], $row[5], $row);
$tpl[SOMSDES] = $row[8];
$tpl[SOMICONS] = getIcons($row[10]);
}
}
function getIcons($ico) {
global $VARS;
$icons = explode(",", $ico);
while(list($key,$val) = each($icons))
if($val && file_exists($VARS[DDIR]."/icons/".$val))
$html .= freadall($VARS[DDIR]."/icons/".$val)." ";
return substr($html, 0, strlen($html)-6);
}
function getMove($cur, $prev) {
global $VARS;
$icon = $VARS[SI];
if($prev != 9999999) {
if($prev > $cur)
$icon = $VARS[UI];
else if($prev < $cur)
$icon = $VARS[DI];
}
return $icon;
}
function getBanner($rank, $url, $ht, $wd, &$row) {
global $VARS;
if($rank <= $VARS[OB]) {
$alt = $VARS[AT];
$alt = str_replace("#%TITLE%#", strtoupper($row[7]), $alt);
$alt = str_replace("#%SDES%#", $row[8], $alt);
$dims = $ht && $wd ? "height=\"".$ht."\" width=\"".$wd."\"" : "";
if($VARS[FBS])
$dims = "height=\"".$VARS[BH]."\" width=\"".$VARS[BW]."\"";
if($url) $banner = "
";
else if($VARS[DB] && !$url)
$banner = "
";
}
return $banner;
}
function getAvg($cnt, $age, $len) {
return sprintf("%.2f", $age >= $len ? $cnt / ($age / $len) : $cnt);
}
function mailMember(&$to, $sub, &$msg, &$from, &$row)
{
global $VARS;
if(!$sub)
{
eregi("Subject:[[:space:]]+([^\n\r]+)", $msg, $regs);
$sub = $regs[1];
$msg = eregi_replace("Subject:[[:space:]]+([^\n\r]+)[\r\n]+", "", $msg);
}
$tpl[ADMIN] = $VARS[EM];
$tpl[TURL] = $VARS[IU]."?id=".$row[0];
$tpl[LURL] = $VARS[PU]."/accounts.php?login";
$tpl[USER] = $row[0];
$tpl[EMAIL] = $row[1];
$tpl[SURL] = $row[2];
$tpl[BURL] = $row[3];
$tpl[BHT] = $row[4] == 0 ? '' : $row[4];
$tpl[BWD] = $row[5] == 0 ? '' : $row[5];
$tpl[TITLE] = $row[7];
$tpl[SDES] = $row[8];
$tpl[PASS] = $row[13];
mail($to, $sub, vparseRet($msg, $tpl), "From: ".$from);
}
function htmlName($category, $fe)
{
// $category = eregi_replace("[^[:alnum:]]", "", strtolower($category));
// $category = substr_replace($category, $GLOBALS["HTML_PREFIX"], 0, strlen($GLOBALS["HTML_PREFIX"])-1);
$category = str_replace(" ", "-", strtolower($category));
return $category.".".$fe;
}
function stripText($text) {
$text = str_replace('&', '&', $text);
$text = str_replace('<', '<', $text);
$text = str_replace('>', '>', $text);
$text = str_replace('"', '"', $text);
return $text;
}
function getMember() {/*
return base64_decode("
PGZvbnQgZmFjZT0iVmVyZGFuYSIgc2l6ZT0iMSI+
CjxkaXYgYWxpZ249Y2VudGVyPgpQb3dlcmVkIGJ5
IDxhIGhyZWY9Imh0dHA6Ly93d3cuZnRyYWluLmhv
dGJveC5ydSI+RmFzdCBUb3BTaXRlcy48L2E+PGJy
PgpDb3B5cmlnaHQgJmNvcHk7MjAwMyBieSBUcmFp
bmVyLiBBbGwgUmlnaHRzIFJlc2VydmVkLjwvZGl2
Pgo8L2ZvbnQ+CjwvYm9keT48L2h0bWw+");*/
}
?>
| Swinging Links, Swingers Links, Swingers Directories, Dogging Links, Swingers Parties, Swingers Clubs, Swingers Heaven | |
![]() | |
|
| |