PDA

View Full Version : Programming The Tally Engine


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=&QUOT;") && strpos(strtoupper($cmsg), "") && $cday == $tallydate && $ctime <= 2200) or (strpos(strtoupper($cmsg), "[NEGATIVE VOTE=&QUOT;") && strpos(strtoupper($cmsg), "") && $cday == $cyesterday && $ctime > 2200))
{
$cvote = substr($cmsg, strpos(strtoupper($cmsg), "[NEGATIVE VOTE=&QUOT;")+21);
$ccomment = substr($cvote, 0, strpos(strtoupper($cvote), ""));
$cvote = substr($cvote, 0, strpos(strtoupper($cvote), "&QUOT;]"));
$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.

HorNeT
03-27-2007, 05:41 PM
And this is?

Morning Star
03-27-2007, 05:43 PM
I can't believe you don't know?! me either just what the hell is that?

uniquinous
03-27-2007, 05:48 PM
i started reading, then the blue started burning my eyeballs and the lack of wordwrap made me close the window. I reopened to post this response

dirka dirka
03-27-2007, 05:50 PM
Yea, the coloring is annoying. Stupid vbulletin. Word wrap is the devil. Get a bigger monitor, as nothing there goes beyond my screen's width.

Walrus
03-27-2007, 05:54 PM
"if((strpos(strtoupper($cmsg), "[NEGATIVE VOTE=&QUOT;") && strpos(strtoupper($cmsg), "[/VOTE]") && $cday == $tallydate && $ctime <= 2200) or (strpos(strtoupper($cmsg), "[NEGATIVE VOTE=&QUOT;") && strpos(strtoupper($cmsg), "[/VOTE]") && $cday == $cyesterday && $ctime > 2200)) "

if you can see all that on one line then the size of your monitor could be interpreted as compensating for something!

dirka dirka
03-27-2007, 06:00 PM
"if((strpos(strtoupper($cmsg), "[NEGATIVE VOTE=&QUOT;") && strpos(strtoupper($cmsg), "[/VOTE]") && $cday == $tallydate && $ctime <= 2200) or (strpos(strtoupper($cmsg), "[NEGATIVE VOTE=&QUOT;") && strpos(strtoupper($cmsg), "[/VOTE]") && $cday == $cyesterday && $ctime > 2200)) "

if you can see all that on one line then the size of your monitor could be interpreted as compensating for something!

Well, its the size of two. It takes up two lines on my one monitor, and when I'm in dual monitor mode, like when I'm programming, it takes up the width of both.

Ignition
03-27-2007, 06:01 PM
Good work Dirka, keep it up.

Ol' Time
03-27-2007, 06:26 PM
i started reading, then the blue started burning my eyeballs and the lack of wordwrap made me close the window. I reopened to post this response

I usually highlight things , it's easier to read in black on white. My eyes usually burn quickly, even when the text isn't blue.

Unforgottner
03-27-2007, 08:26 PM
Erm...whats it for?

dirka dirka
03-27-2007, 08:30 PM
Erm...whats it for?

TAO Mafia

Zander
03-27-2007, 08:35 PM
How do i put this to use?

stryker
03-27-2007, 08:37 PM
You have quite the knack for this coding stuff Dirks, keep it up.

dirka dirka
03-27-2007, 08:46 PM
How do i put this to use?

It already is. (http://www.erichouck.com/tao/newmafiatally.php)

Zander
03-27-2007, 08:47 PM
I know it's already being used for TAO mafia... but were you really just posting this to show off, basically? I figured it was for people to use... or something:huh:

dirka dirka
03-27-2007, 08:54 PM
It was for people to look at. It is called open source. People can change it, they can suggest changes, and they can ask questions. That is if you're concerned about functionality and/or php coding.

Walrus
03-28-2007, 03:57 AM
I usually highlight things , it's easier to read in black on white. My eyes usually burn quickly, even when the text isn't blue.

white on black is much better on the eyes, looking at a [mostly] white screen all the time is like staring into a lightbulb for extended periods

S_K_O_F
03-28-2007, 08:30 AM
Some of you need to relax on dirka. He posted code for others to use and some of you are accusing him of showing off. You need to get familiar with the open source community.