ok i have completed everything i want to do
i have encorpated caching and the ability to turn off items that you do not want to use below is my final product with comments and all
<?
//Created by PaPPy
//April 7 2006
//www.pappyspage.com
//itspappy at gmail dot com
$username=""; //Login Name
$password=""; //Login Password
$cookie="cookiefile"; //Place where cookie will be saved too (can be changed)
$logging="1"; //Enable logging to track output data
$log="bite.log.txt"; //Place where log goes to (can be changed)
$level="1"; //Do you want to show your level? 0 For no 1 for yes
$gold="1"; //Do you want to show how much gold you have? 0 for no 1 for yes
$booty="1"; //Do you want to show how much booty you've earned? 0 for no 1 for yes
$victories="1"; //Do you want to show your victories? 0 for no 1 for yes
$goldcap="1"; //Do you want to show how much gold you have captured? 0 for no 1 for yes
$damage="1"; //Do you want to show how much damaged you've caused? 0 for no 1 for yes
$destination="/bite/uebersicht.php"; //Where is the page we are grabbing data from?
$postdata="destination=".urlencode($destination)."&user=".urlencode($username)."&pass=".urlencode($password)."&null=Login"; //What input values correspond with username(user) and password(pass) then use what is entered in line 1 and line 2
define('CACHE_TIME', 5 * 60); // Cache time in seconds (5 mins)
define('CACHE_FILE', 'feed.cache'); // Where we store a local copy of the feed for caching purposes(can change)
if (time() - filemtime(CACHE_FILE) < CACHE_TIME) // Is our cache file new enough to use?
{
$result = file_get_contents(CACHE_FILE); // Use cache (html code from our $destination)
} else {
// Cache expired, download new copy, and grab its contents ($result)
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,"http://s2.bitefight.org/bite/login.php"); //Page we pass our login credentials to
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); //Not sure, think it means to use ssl
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); //Have to pretend to be a webbrowser
curl_setopt ($ch, CURLOPT_TIMEOUT, 20); //If you can do it in 20sec give up
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION,1); //Once you login goto page it directs you to
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); //Not sure
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); //Save cookie information to $cookie
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie); //Save cookie information to $cookie
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); //Fields we are filling in the form
curl_setopt ($ch, CURLOPT_POST, 1); //Using POST
$result = curl_exec ($ch); //Execute and save data as $result
curl_close($ch); //Close connection
$fp= fopen(CACHE_FILE, 'w'); //Dump html source code to cachfile
fwrite ($fp, $result); //Dump html source code to cachfile
fclose($fp); //Dump html source code to cachfile
}
//Begin Level
$levelb = '<td class="tdn">Level:</td><td class="tdn">';
$levele = '</td>';
if ( ( $pos1 = strpos ( $result, $levelb ) ) !== false and $level =="1")
{
$result1 = substr ( $result, ( $len1 = ( $pos1 + strlen ( $levelb ) ) ), ( strpos ( $result, $levele, $len1 ) - $len1 ) );
echo "Level is: " .$result1;
echo "<br>";
}
//End Level
//Begin Gold
$tgoldb = '<td class="tdn">Your gold:</td><td class="tdn">';
$tgolde = '<img src="img/res2.gif" alt="gold" align="absmiddle" border="0">';
if ( ( $pos2 = strpos ( $result, $tgoldb ) ) !== false and $gold =="1")
{
$result2 = substr ( $result, ( $len2 = ( $pos2 + strlen ( $tgoldb ) ) ), ( strpos ( $result, $tgolde, $len2 ) - $len2 ) );
echo "Gold is: " .$result2;
echo "<br>";
}
//End Gold
//Begin Booty
$bootyb = '<td class="tdn">Entire booty:</td><td class="tdn">';
$bootye = '</td>';
if ( ( $pos3 = strpos ( $result, $bootyb ) ) !== false and $booty =="1")
{
$result3 = substr ( $result, ( $len3 = ( $pos3 + strlen ( $bootyb ) ) ), ( strpos ( $result, $bootye, $len3 ) - $len3 ) );
echo "Booty is: " .$result3;
echo "<br>";
}
//End Booty
//Begin Victories
$victoriesb = '<td class="tdn">Victories:</td><td class="tdn">';
$victoriese = '</td>';
if ( ( $pos4 = strpos ( $result, $victoriesb ) ) !== false and $victories =="1")
{
$result4 = substr ( $result, ( $len4 = ( $pos4 + strlen ( $victoriesb ) ) ), ( strpos ( $result, $victoriese, $len4 ) - $len4 ) );
echo "Victories are: " .$result4;
echo "<br>";
}
//End Victories
//Begin Gold Captured
$goldcapb = '<td class="tdn">Gold captured:</td><td class="tdn">';
$goldcape = ' <img src="img/res2.gif" alt="C_TXT_RES2" align="absmiddle" border="0">';
if ( ( $pos5 = strpos ( $result, $goldcapb ) ) !== false and $goldcap =="1")
{
$result5 = substr ( $result, ( $len5 = ( $pos5 + strlen ( $goldcapb ) ) ), ( strpos ( $result, $goldcape, $len5 ) - $len5 ) );
echo "Gold Captured: " .$result5;
echo "<br>";
}
//End Gold Captured
//Begin Damage Caused
$damageb = '<td class="tdn">Damage caused:</td><td class="tdn">';
$damagee = '</td>';
if ( ( $pos6 = strpos ( $result, $damageb ) ) !== false and $damage =="1")
{
$result6 = substr ( $result, ( $len6 = ( $pos6 + strlen ( $damageb ) ) ), ( strpos ( $result, $damagee, $len6 ) - $len6 ) );
echo "Damaged caused: " .$result6;
}
//End Gold Captured
if ($handle = fopen($log, 'a') and $logging =="1") {
$datearray = getdate();
$year = $datearray["year"];
$month = $datearray["mon"];
$day = $datearray["mday"];
$hour = $datearray["hours"];
$minute = $datearray["minutes"];
fwrite($handle, "[$month/$day/$year, $hour:$minute] - Level: " .$result1. " Gold: " .$result2. " Booty: " .$result3. " Victories: " .$result4. " Gold Captured: " .$result5. " Damaged: " .$result5."\n");
fclose($handle);
} else {
echo "";
}
?>