1) { $gxml=$argv[1]; if (strpos($gxml, "http") !== false) { $restl=file_get_contents(str_replace('https','http',$gxml)); } else { $restl=file_get_contents("http://www.legislation.nsw.gov.au/~/search/inForceActsRegsEPIs/repealedActsRegsEPIs/customquery=FirstValidDate=" . $gxml . "&advanced=Search"); } echo $restl; exit; } } else if (isset($_GET['syear']) && isset($_GET['smonth']) && isset($_GET['sday']) && isset($_GET['eyear']) && isset($_GET['emonth']) && isset($_GET['eday'])) { $html="
NSW Legislation Search via FirstValidDate
";
$isly=28;
if (($_GET['syear'] % 4) == 0) { $isly=29; }
$thisyear=$_GET['syear'];
$maxes=[-1,31,$isly,31,30,31,30,31,31,30,31,30,31];
$sdate=$_GET['syear'] * 10000;
$sdate+=$_GET['smonth'] * 100;
$sdate+=$_GET['sday'];
$thisdate=$sdate;
$edate=$_GET['eyear'] * 10000;
$edate+=$_GET['emonth'] * 100;
$edate+=$_GET['eday'];
if ($sdate <= $edate) {
while ($thisdate <= $edate) {
$thisday=($thisdate % 100);
$thismonth=((($thisdate - $thisday) / 100) % 100);
$gm=substr(("0" . $thismonth), strlen(("0" . $thismonth)) - 2);
$gd=substr(("0" . $thisday), strlen(("0" . $thisday)) - 2);
$url="http://www.legislation.nsw.gov.au/~/search/inForceActsRegsEPIs/repealedActsRegsEPIs/customquery=FirstValidDate=" . $thisyear . "-" . $gm . "-" . $gd . "&advanced=Search";
$found=2;
$nexturl="https://www.legislation.nsw.gov.au/~/search/inForceActsRegsEPIs/repealedActsRegsEPIs/advanced=Search&customquery=FirstValidDate%3D" . $thisyear . "-" . $gm . "-" . $gd . "/page" . $found;
//file_put_contents("up.to", $url);
$html.=$url . "
";
while ($found > 0) {
$found=-$found;
$restl=@file_get_contents($url);
$bits=explode('", $bits[$i])[0] . "";
if (strpos($pline, ">Whole title<") === false && strpos($pline, ">Search title<") === false && strpos($pline, ">Hits list<") === false) {
$html.=$pline . "
";
$found=abs($found);
}
}
if ($found > 0) {
$url=$nexturl;
$found++; // /inForceActsRegsEPIs/repealedActsRegsEPIs/repealedActsRegsEPIs/
$nexturl="https://www.legislation.nsw.gov.au/~/search/inForceActsRegsEPIs/repealedActsRegsEPIs/advanced=Search&customquery=FirstValidDate%3D" . $thisyear . "-" . $gm . "-" . $gd . "/page" . $found;
}
}
if ($thisday >= $maxes[$thismonth]) {
if ($thismonth == 12) {
$thisyear++;
$thismonth=1;
$thisday=1;
$thisdate=$thisyear * 10000;
$thisdate+=$thismonth * 100;
$thisdate+=$thisday;
$isly=28;
if (($_GET['syear'] % 4) == 0) { $isly=29; }
$maxes[2]=$isly;
} else {
$thismonth++;
$thisday=1;
$thisdate=$thisyear * 10000;
$thisdate+=$thismonth * 100;
$thisdate+=$thisday;
}
} else {
$thisday++;
$thisdate++;
}
}
}
$html.="