dirka dirka
03-27-2007, 05:41 PM
<title>Tally Engine</title>
<form name="formstatus">
<input type="textbox" value="Tally Engine Loading" name="status" style="width:400;border:0">
</form>
<?
$tallydate = $_GET["tallydate"];
if($tallydate == "")
{
$tallydate = date("m-d-Y");
if(date("Hi") > 2200)
{
$cm = substr($tallydate, 0, 2);
$cd = substr($tallydate, 3, 2) + 1;
$cy = substr($tallydate, 6, 4);
$tallydate = date("m-d-Y", mktime(0, 0, 0, $cm, $cd, $cy));
}
}
$cm = substr($tallydate, 0, 2);
$cd = substr($tallydate, 3, 2) - 1;
$cy = substr($tallydate, 6, 4);
$cyesterday = date("m-d-Y", mktime(0, 0, 0, $cm, $cd, $cy));
echo "<p>From $cyesterday; 10:01PM to $tallydate; 10:00 PM.</p>";
flush();
error_reporting(0);
$endofposts = "No";
$page = 33;
$thread = 31230;
while ($endofposts == "No")
{
if($errno == 0)
{
echo "<script language=JavaScript>document.formstatus.status.value = 'Loading TAO Page #$page';</script>\n";
flush();
}
$errno = 0;
$fp = fsockopen("www.tacticsarena.com", 80, $errno, $errstr, 1);
$data = "";
if (!$fp)
{
echo "<script language=JavaScript>document.formstatus.status.value = 'Retryig TAO Page #$page';</script>\n";
$errno = 1;
flush();
} else {
$url = "/forum/printthread.php?t=$thread&page=$page&pp=40";
$headers = "GET $url HTTP/1.1\r\n";
$headers .= "Host: www.tacticsarena.com\r\n";
$headers .= "Connection: Close\r\n\r\n";
fwrite($fp, $headers);
while (!feof($fp))
{
$temp = fgets($fp, 128);
$data .= $temp;
}
fclose($fp);
echo "<script language=JavaScript>document.formstatus.status.value = 'Reading TAO Page #$page';</script>\n";
flush();
$posts = preg_split("<table class=\"tborder\" cellpadding=\"6\" cellspacing=\"1\" border=\"0\" width=\"100%\">", $data, -1);
for($x = 1; $x <= count($posts)-1; $x++)
{
$cpost = $posts[$x];
$cuser = substr($cpost, strpos($cpost,"<td style=\"font-size:14pt\">")+27);
$cuser = substr($cuser, 0, strpos($cuser, "</td>"));
$cuser = strip_tags($cuser);
$cdate = substr($cpost, strpos($cpost,"<td class=\"smallfont\" align=\"right\">")+36);
$cdate = substr($cdate, 0, strpos($cdate, "</td>"));
$cdate = strip_tags($cdate);
$cday = substr($cdate, 0, strpos($cdate, " "));
$ctime = substr($cdate, strpos($cdate, " ") +1);
if(strpos($ctime, " PM"))
{
$ctime = str_replace(" PM", "", $ctime);
$ctime = str_replace(":", "", $ctime);
$ctime = $ctime + 1400;
}
if(strpos($ctime, " AM"))
{
$ctime = str_replace(" AM", "", $ctime);
$ctime = str_replace(":", "", $ctime);
$ctime = $ctime + 200;
}
if($ctime > 2400)
{
$ctime = $ctime - 2400;
$cm = substr($cdate, 0, 2);
$cd = substr($cdate, 3, 2) + 1;
$cy = substr($cdate, 6, 4);
$cday = date("m-d-Y", mktime(0, 0, 0, $cm, $cd, $cy));
}
$cmsg = strip_tags($cpost);
if((strpos(strtoupper($cmsg), "") && $cday == $tallydate && $ctime <= 2200) or (strpos(strtoupper($cmsg), ""));
$ccomment = substr($ccomment, strpos(strtoupper($ccomment), " == $cuser)
{
$votesfor[$y] = $cvote;
$votesfrom[$y] = $cuser;
$votesmsg[$y] = "$cuser voted for $cvote <i>($ccomment)</i><br>";
$existed = true;
}
}
if($existed == false)
{
$votesfor[count($votes)] = $cvote;
$votesfrom[count($votes)] = $cuser;
$votesmsg[count($votes)] = "$cuser voted for $cvote <i>($ccomment)</i><br>";
$votes[count($votes)] = $cuser;
}
}
if((strpos(strtoupper($cmsg), "[NEGATIVE VOTE="") && strpos(strtoupper($cmsg), "") && $cday == $tallydate && $ctime <= 2200) or (strpos(strtoupper($cmsg), "[NEGATIVE VOTE="") && strpos(strtoupper($cmsg), "") && $cday == $cyesterday && $ctime > 2200))
{
$cvote = substr($cmsg, strpos(strtoupper($cmsg), "[NEGATIVE VOTE="")+21);
$ccomment = substr($cvote, 0, strpos(strtoupper($cvote), ""));
$cvote = substr($cvote, 0, strpos(strtoupper($cvote), ""]"));
$ccomment = substr($ccomment, strpos(strtoupper($ccomment), "[NEGATIVE VOTE=") + strlen($cvote) + 7);
$existed = false;
for($y = 0; $y <= count($votes); $y++)
{
if($votes[$y] == $cuser)
{
$votesfor[$y] = "<i>Negative</i> $cvote";
$votesfrom[$y] = $cuser;
$votesmsg[$y] = "$cuser voted negatively for $cvote <i>($ccomment)</i><br>";
$existed = true;
}
}
if($existed == false)
{
$votesfor[count($votes)] = "<i>Negative</i> $cvote";
$votesfrom[count($votes)] = $cuser;
$votesmsg[count($votes)] = "$cuser voted negatively for $cvote <i>($ccomment)</i><br>";
$votes[count($votes)] = $cuser;
}
}
$cday = "";
$ctime = "";
$ccomment = "";
$cvote = "";
$cdate = "";
$cuser = "";
}
if(count($posts) == 1)
{
$endofposts="Yes";
echo "<script language=JavaScript>document.formstatus.status.value = 'Tally Engine Complete';</script>\n";
}
flush();
$page++;
}
}
for($y = 0; $y <= count($votes); $y++)
{
echo $votesmsg[$y]."\n";
}
echo "<p></p>";
for($y = 0; $y <= count($votes); $y++)
{
if($votesfrom[$y] != "")
{
echo "<u>" . $votesfor[$y] . "</u><br>\n";
for($z = 0; $z <= count($votes); $z++)
{
similar_text(strtoupper($votesfor[$y]), strtoupper($votesfor[$z]), $stpercent);
if($stpercent >= 70)
{
echo $votesfrom[$z] . "<br>\n";
$votesfrom[$z] = "";
}
}
echo "<p><p>";
}
}
?>
Any questions? Figured I'd post it up as open source.
<form name="formstatus">
<input type="textbox" value="Tally Engine Loading" name="status" style="width:400;border:0">
</form>
<?
$tallydate = $_GET["tallydate"];
if($tallydate == "")
{
$tallydate = date("m-d-Y");
if(date("Hi") > 2200)
{
$cm = substr($tallydate, 0, 2);
$cd = substr($tallydate, 3, 2) + 1;
$cy = substr($tallydate, 6, 4);
$tallydate = date("m-d-Y", mktime(0, 0, 0, $cm, $cd, $cy));
}
}
$cm = substr($tallydate, 0, 2);
$cd = substr($tallydate, 3, 2) - 1;
$cy = substr($tallydate, 6, 4);
$cyesterday = date("m-d-Y", mktime(0, 0, 0, $cm, $cd, $cy));
echo "<p>From $cyesterday; 10:01PM to $tallydate; 10:00 PM.</p>";
flush();
error_reporting(0);
$endofposts = "No";
$page = 33;
$thread = 31230;
while ($endofposts == "No")
{
if($errno == 0)
{
echo "<script language=JavaScript>document.formstatus.status.value = 'Loading TAO Page #$page';</script>\n";
flush();
}
$errno = 0;
$fp = fsockopen("www.tacticsarena.com", 80, $errno, $errstr, 1);
$data = "";
if (!$fp)
{
echo "<script language=JavaScript>document.formstatus.status.value = 'Retryig TAO Page #$page';</script>\n";
$errno = 1;
flush();
} else {
$url = "/forum/printthread.php?t=$thread&page=$page&pp=40";
$headers = "GET $url HTTP/1.1\r\n";
$headers .= "Host: www.tacticsarena.com\r\n";
$headers .= "Connection: Close\r\n\r\n";
fwrite($fp, $headers);
while (!feof($fp))
{
$temp = fgets($fp, 128);
$data .= $temp;
}
fclose($fp);
echo "<script language=JavaScript>document.formstatus.status.value = 'Reading TAO Page #$page';</script>\n";
flush();
$posts = preg_split("<table class=\"tborder\" cellpadding=\"6\" cellspacing=\"1\" border=\"0\" width=\"100%\">", $data, -1);
for($x = 1; $x <= count($posts)-1; $x++)
{
$cpost = $posts[$x];
$cuser = substr($cpost, strpos($cpost,"<td style=\"font-size:14pt\">")+27);
$cuser = substr($cuser, 0, strpos($cuser, "</td>"));
$cuser = strip_tags($cuser);
$cdate = substr($cpost, strpos($cpost,"<td class=\"smallfont\" align=\"right\">")+36);
$cdate = substr($cdate, 0, strpos($cdate, "</td>"));
$cdate = strip_tags($cdate);
$cday = substr($cdate, 0, strpos($cdate, " "));
$ctime = substr($cdate, strpos($cdate, " ") +1);
if(strpos($ctime, " PM"))
{
$ctime = str_replace(" PM", "", $ctime);
$ctime = str_replace(":", "", $ctime);
$ctime = $ctime + 1400;
}
if(strpos($ctime, " AM"))
{
$ctime = str_replace(" AM", "", $ctime);
$ctime = str_replace(":", "", $ctime);
$ctime = $ctime + 200;
}
if($ctime > 2400)
{
$ctime = $ctime - 2400;
$cm = substr($cdate, 0, 2);
$cd = substr($cdate, 3, 2) + 1;
$cy = substr($cdate, 6, 4);
$cday = date("m-d-Y", mktime(0, 0, 0, $cm, $cd, $cy));
}
$cmsg = strip_tags($cpost);
if((strpos(strtoupper($cmsg), "") && $cday == $tallydate && $ctime <= 2200) or (strpos(strtoupper($cmsg), ""));
$ccomment = substr($ccomment, strpos(strtoupper($ccomment), " == $cuser)
{
$votesfor[$y] = $cvote;
$votesfrom[$y] = $cuser;
$votesmsg[$y] = "$cuser voted for $cvote <i>($ccomment)</i><br>";
$existed = true;
}
}
if($existed == false)
{
$votesfor[count($votes)] = $cvote;
$votesfrom[count($votes)] = $cuser;
$votesmsg[count($votes)] = "$cuser voted for $cvote <i>($ccomment)</i><br>";
$votes[count($votes)] = $cuser;
}
}
if((strpos(strtoupper($cmsg), "[NEGATIVE VOTE="") && strpos(strtoupper($cmsg), "") && $cday == $tallydate && $ctime <= 2200) or (strpos(strtoupper($cmsg), "[NEGATIVE VOTE="") && strpos(strtoupper($cmsg), "") && $cday == $cyesterday && $ctime > 2200))
{
$cvote = substr($cmsg, strpos(strtoupper($cmsg), "[NEGATIVE VOTE="")+21);
$ccomment = substr($cvote, 0, strpos(strtoupper($cvote), ""));
$cvote = substr($cvote, 0, strpos(strtoupper($cvote), ""]"));
$ccomment = substr($ccomment, strpos(strtoupper($ccomment), "[NEGATIVE VOTE=") + strlen($cvote) + 7);
$existed = false;
for($y = 0; $y <= count($votes); $y++)
{
if($votes[$y] == $cuser)
{
$votesfor[$y] = "<i>Negative</i> $cvote";
$votesfrom[$y] = $cuser;
$votesmsg[$y] = "$cuser voted negatively for $cvote <i>($ccomment)</i><br>";
$existed = true;
}
}
if($existed == false)
{
$votesfor[count($votes)] = "<i>Negative</i> $cvote";
$votesfrom[count($votes)] = $cuser;
$votesmsg[count($votes)] = "$cuser voted negatively for $cvote <i>($ccomment)</i><br>";
$votes[count($votes)] = $cuser;
}
}
$cday = "";
$ctime = "";
$ccomment = "";
$cvote = "";
$cdate = "";
$cuser = "";
}
if(count($posts) == 1)
{
$endofposts="Yes";
echo "<script language=JavaScript>document.formstatus.status.value = 'Tally Engine Complete';</script>\n";
}
flush();
$page++;
}
}
for($y = 0; $y <= count($votes); $y++)
{
echo $votesmsg[$y]."\n";
}
echo "<p></p>";
for($y = 0; $y <= count($votes); $y++)
{
if($votesfrom[$y] != "")
{
echo "<u>" . $votesfor[$y] . "</u><br>\n";
for($z = 0; $z <= count($votes); $z++)
{
similar_text(strtoupper($votesfor[$y]), strtoupper($votesfor[$z]), $stpercent);
if($stpercent >= 70)
{
echo $votesfrom[$z] . "<br>\n";
$votesfrom[$z] = "";
}
}
echo "<p><p>";
}
}
?>
Any questions? Figured I'd post it up as open source.