<?php
include("head.php");
////////////////////////////////////////MAIN PAGE
if($action=="main")
{
addonline(getuid_sid($sid),"Lottery!","");
echo "<card id=\"main\" title=\"wapirate\">";
echo "<p align=\"center\">";
echo "<b>Lottery</b><br/>";
echo "<img src=\"/images/lotto.gif\" alt=\"lotto\"/><br/>";
echo "<br/>";
echo "<a href=\"lotto.php?action=result&sid=$sid&result=lotto\">Lotto</a><br/>";
echo "<a href=\"lotto.php?action=result&sid=$sid&result=euro\">EuroMillions</a><br/>";
echo "<a href=\"lotto.php?action=result&sid=$sid&result=dailyplay\">Daily Play</a><br/>";
echo "<a href=\"lotto.php?action=result&sid=$sid&result=thunderball\">Thunderball</a><br/>";
echo "<a href=\"lotto.php?action=result&sid=$sid&result=hotpicks\">HotPicks</a><br/>";
echo "<a href=\"index.php?action=main&sid=$sid\"><img src=\"images$folder/home.gif\" alt=\"*\"/>Home</a><br/><br/>";
echo "</p>\n";
echo "</card>";
}
/////////////////////////////Result
if($action=="result")
{
addonline(getuid_sid($sid),"Lottery-$result!","");
echo "<card id=\"main\" title=\"wapirate\">";
$url="http://wap.national-lottery.co.uk/results.php?game=$result";
preg_match("/^(https?:\/\/)?([^\/]*)(.*)/i", "$url", $matches);
$domain = "http://" . $matches[2];
$page = $matches[3];
$code = file_get_contents($domain.$page);
if($result=="lotto"){
$start= strpos($code, "<b>Lotto Results</b>");
}else if($result=="euro"){
$start= strpos($code, "<b>EuroMillions Results</b>");
}else if($result=="dailyplay"){
$start= strpos($code, "<b>Daily Play Results</b>");
}else if($result=="thunderball"){
$start= strpos($code, "<b>Thunderball Results</b>");
}else if($result=="hotpicks"){
$start= strpos($code, "<b>HotPicks Results</b>");
}
$finish= strpos($code, "<small><a href=\"results.php?game=$result&start=4\">- Further Draws</a>");
$length= $finish-$start;
$code=substr($code, $start, $length);
$newcode = preg_replace("/(href=\"?)(\/[^\"\/]+)/", "\\1" . $domain . "\\2", $code);
$newcode = str_replace("<small><a href=\"results.php?game=$result&start=4\">- Further Draws</a>","",$newcode);
$newcode = str_replace("Results</b>","Results</b><br/>",$newcode);
$newcode = str_replace("</p>","",$newcode);
$newcode = str_replace("<p>","",$newcode);
$newcode = str_replace("<small>","",$newcode);
$newcode = str_replace("</small>","",$newcode);
$newcode = str_replace(".php","",$newcode);
$newcode = str_replace("results/$result/","lotto.php?action=result2&sid=$sid&result=$result&date=",$newcode);
echo "<p align=\"center\">";
echo "<b>Lottery</b><br/>";
echo "<img src=\"/images/lotto.gif\" alt=\"lotto\"/><br/>";
echo "<br/>";
echo "$newcode<br/>";
echo "<br/><a href=\"lotto.php?action=main&sid=$sid\">Back</a><br/><br/>";
echo "<a href=\"index.php?action=main&sid=$sid\"><img src=\"images$folder/home.gif\" alt=\"*\"/>Home</a><br/><br/>";
echo "</p>\n";
echo "</card>";
}
/////////////////////////////////
if($action=="result2")
{
addonline(getuid_sid($sid),"Lottery-$result!","");
echo "<card id=\"main\" title=\"wapirate\">";
$url="http://wap.national-lottery.co.uk/results/$result/$date.php";
preg_match("/^(https?:\/\/)?([^\/]*)(.*)/i", "$url", $matches);
$domain = "http://" . $matches[2];
$page = $matches[3];
$code = file_get_contents($domain.$page);
if($result=="lotto"){
$start= strpos($code, "<b>Lotto Results</b>");
}else if($result=="euro"){
$start= strpos($code, "<b>EuroMillions Results</b>");
}else if($result=="dailyplay"){
$start= strpos($code, "<b>Daily Play Results</b>");
}else if($result=="thunderball"){
$start= strpos($code, "<b>Thunderball Results</b>");
}else if($result=="hotpicks"){
$start= strpos($code, "<b>HotPicks Results</b>");
}
$finish= strpos($code, "Breakdown</a>");
$length= $finish-$start;
$code=substr($code, $start, $length);
$newcode = preg_replace("/(href=\"?)(\/[^\"\/]+)/", "\\1" . $domain . "\\2", $code);
$newcode = str_replace("Results</b>","Results</b><br/>",$newcode);
$newcode = str_replace("</p>","",$newcode);
$newcode = str_replace("<p>","",$newcode);
$newcode = str_replace("<small>","",$newcode);
$newcode = str_replace("</small>","<br/>",$newcode);
$newcode = str_replace("<p align=\"center\">","",$newcode);
$newcode = str_replace(".php","",$newcode);
$newcode = str_replace("<a href=\"","<a href=\"lotto.php?action=prize&result=$result&sid=$sid&date=",$newcode);
echo "<p align=\"center\">";
echo "<b>Lottery</b><br/>";
echo "<img src=\"/images/lotto.gif\" alt=\"lotto\"/><br/>";
echo "<br/>";
echo "$newcode Breakdown</a><br/>";
echo "<br/><a href=\"lotto.php?action=main&sid=$sid\">Back</a><br/><br/>";
echo "<a href=\"index.php?action=main&sid=$sid\"><img src=\"images$folder/home.gif\" alt=\"*\"/>Home</a><br/><br/>";
echo "</p>\n";
echo "</card>";
}
/////////////////////////////////
if($action=="prize")
{
addonline(getuid_sid($sid),"Lottery-$result!","");
echo "<card id=\"main\" title=\"wapirate\">";
$url="http://wap.national-lottery.co.uk/results/$result/$date.php";
preg_match("/^(https?:\/\/)?([^\/]*)(.*)/i", "$url", $matches);
$domain = "http://" . $matches[2];
$page = $matches[3];
$code = file_get_contents($domain.$page);
if($result=="lotto"){
$start= strpos($code, "<b>Lotto Prizes</b><br/>");
}else if($result=="euro"){
$start= strpos($code, "<b>EuroMillions Prizes</b><br/>");
}else if($result=="dailyplay"){
$start= strpos($code, "<b>Daily Play Prizes</b><br/>");
}else if($result=="thunderball"){
$start= strpos($code, "<b>Thunderball Prizes</b><br/>");
}else if($result=="hotpicks"){
$start= strpos($code, "<b>HotPicks Prizes</b><br/>");
}
$finish= strpos($code, "<a href=\"/results/$result");
$length= $finish-$start;
$code=substr($code, $start, $length);
$newcode = preg_replace("/(href=\"?)(\/[^\"\/]+)/", "\\1" . $domain . "\\2", $code);
$newcode = str_replace("Results</b>","Results</b><br/>",$newcode);
$newcode = str_replace("</p>","",$newcode);
$newcode = str_replace("<p>","",$newcode);
$newcode = str_replace("<small>","",$newcode);
$newcode = str_replace("</small>","<br/>",$newcode);
$newcode = str_replace("<p align=\"center\">","",$newcode);
$newcode = str_replace(".php","",$newcode);
$newcode = str_replace("<a href=\"/results/$result","",$newcode);
$newcode = str_replace("Match","<br/>Match",$newcode);
echo "<p align=\"center\">";
echo "<b>Lottery</b><br/>";
echo "<img src=\"/images/lotto.gif\" alt=\"lotto\"/><br/>";
echo "<br/>";
echo "$newcode<br/>";
echo "<br/><a href=\"lotto.php?action=main&sid=$sid\">Back</a><br/><br/>";
echo "<a href=\"index.php?action=main&sid=$sid\"><img src=\"images$folder/home.gif\" alt=\"*\"/>Home</a><br/><br/>";
echo "</p>\n";
echo "</card>";
}
?>
</wml>