" . str_replace("+"," ",urldecode($_POST['thiscity'])) . " is in " . str_replace("+"," ",urldecode($_POST['eanswer'])) . " but is not in " . str_replace("+"," ",urldecode($_POST['ucountry'])) . "."; } if (isset($_POST['emailfrom'])) { $emdef=str_replace("+"," ",urldecode($_POST['emailfrom'])); } } else if (isset($_GET['thiscity']) && isset($_GET['ucountry']) && isset($_GET['eanswer'])) { if ($_GET['ucountry'] == $_GET['eanswer']) { $egoes="1 Well done! " . str_replace("+"," ",urldecode($_GET['thiscity'])) . " is indeed in " . str_replace("+"," ",urldecode($_GET['eanswer'])) . "."; $escore="1"; } else { $egoes="1 Sorry, " . str_replace("+"," ",urldecode($_GET['thiscity'])) . " is in " . str_replace("+"," ",urldecode($_GET['eanswer'])) . " but is not in " . str_replace("+"," ",urldecode($_GET['ucountry'])) . "."; } if (isset($_GET['emailfrom'])) { $emdef=str_replace("+"," ",urldecode($_GET['emailfrom'])); } } $citiesarr=[]; $uniquecountries=","; $countriesarr=[]; $countriesisotwo=[]; $ctyisotwo=file_get_contents("http://www.nationsonline.org/oneworld/country_code_list.htm"); $ctyisotwo=str_replace("Lao People's Democratic Republic","Laos",$ctyisotwo); $ctyisotwo=str_replace("Tanzania, United Republic of","Tanzania",$ctyisotwo); $ctyisotwo=str_replace("Iran, Islamic Republic of","Iran",$ctyisotwo); $ctyisotwo=str_replace("Macedonia, the Former Yugoslav Republic of","Macedonia",$ctyisotwo); $ctyisotwo=str_replace("North Korea","Korea, Democratic People's Republic of",$ctyisotwo); $ctyisotwo=str_replace("Korea, Republic of","South Korea",$ctyisotwo); // //
// Afghanistan // AF // AFG // 004 // foreach (glob("*cities*.xml") as $filename) { $fchunk=file_get_contents($filename); $bits=explode("", $fchunk); for ($i=1; $i", $bits[-1 + $i]); $thosetwobits=explode("<", $thistwobits[-1 + sizeof($thistwobits)]); $countriesarr[sizeof($countriesarr)]=$thosetwobits[0]; if (strpos($ctyisotwo, ">" . $thosetwobits[0]) !== false) { $countriesisotwo[sizeof($countriesisotwo)]=getih(trim(explode("<",explode('">', explode(">" . $thosetwobits[0],$ctyisotwo)[1])[1])[0])); } else { $countriesisotwo[sizeof($countriesisotwo)]=trim(" "); } if (!strstr($uniquecountries, "," . urlencode($thosetwobits[0] . $countriesisotwo[-1 + sizeof($countriesisotwo)]) . ",")) { $uniquecountries .= urlencode($thosetwobits[0] . $countriesisotwo[-1 + sizeof($countriesisotwo)]) . ","; } $countriesarr[-1 + sizeof($countriesarr)].=$countriesisotwo[-1 + sizeof($countriesisotwo)]; $countriesisotwo[-1 + sizeof($countriesisotwo)]=''; } } $caplist=file_get_contents("http://www.rjmprogramming.com.au/PHP/country_capital_quiz.php"); // countries.push("Afghanistan"); countryids.push("Afghanistan"); capitals.push("Kabul"); num++; // countries.push("Albania"); countryids.push("Albania"); capitals.push("Tirana"); num++; $clarr=explode('countries.push("', $caplist); for ($ihg=1; $ihg" . explode('"', $clarr[$ihg])[0]) !== false) { $countriesisotwo[sizeof($countriesisotwo)]=getih(trim(explode("<",explode('">', explode(">" . explode('"', $clarr[$ihg])[0],$ctyisotwo)[1])[1])[0])); } else { $countriesisotwo[sizeof($countriesisotwo)]=trim(" "); } if (!strstr($uniquecountries, "," . urlencode(explode('"', $clarr[$ihg])[0] . $countriesisotwo[-1 + sizeof($countriesisotwo)]) . ",")) { $uniquecountries .= urlencode(explode('"', $clarr[$ihg])[0] . $countriesisotwo[-1 + sizeof($countriesisotwo)]) . ","; } $countriesarr[-1 + sizeof($countriesarr)].=$countriesisotwo[-1 + sizeof($countriesisotwo)]; $countriesisotwo[-1 + sizeof($countriesisotwo)]=''; $citiesarr[sizeof($citiesarr)]=explode('"', explode('capitals.push("', $clarr[$ihg])[1])[0]; } function cmp($a, $b) { // alphabetical comparison method $ta=explode("title=", $a); $tb=explode("title=", $b); if ($ta[sizeof($ta) - 1] == $tb[sizeof($tb) - 1]) { return 0; } return ($ta[sizeof($ta) - 1] < $tb[sizeof($tb) - 1]) ? -1 : 1; } function showucountries() { global $uniquecountries; $ret=""; $ucountriesarr=explode(",", $uniquecountries); usort($ucountriesarr, "cmp"); for ($i=0; $i", "", $ret); } return $ret; } function notshowucities() { global $citiesarr, $countriesarr; $ret=""; for ($i=0; $i", "", $ret); } return $ret; } function shownextcity() { global $citiesarr, $countriesarr, $egoes, $escore, $emdef; $ret="\n var urlprefix='//www.google.com.au/search?tbm=isch&q='; \n var emdef='" . $emdef . "'; \n var firstgo=true; \n var goes=" . explode(" ", $egoes)[0] . "; \n var score=" . $escore . "; \n var lcity=''; \n var oucity=null; var numc=" . sizeof($citiesarr) . ";\n var ans=false; var lastg=-1;\n var ccountry=''; \n function askemail() { if (document.getElementById('emailto').value.indexOf('@') == -1) { var emis=prompt('Please enter Email To address?',emdef); if (emis) { if (emis.indexOf('@') != -1) { document.getElementById('emailto').value=emis; } } } if (document.getElementById('emailto').value.indexOf('@') != -1) { document.getElementById('htmlis').value=document.getElementById('htmlis').value.replace(' value=\" \"', ' value=\"' + emis + '\"'); document.getElementById('contact').click(); } } function woit(incity) { window.open(urlprefix + encodeURIComponent(incity), '_blank', 'top=50,left=50,width=400,height=400'); } function gethtmlready(incval) { var huhsel='')[0] + '>'; document.getElementById('htmlis').value='

City Guess Country Game

Which Country is City In?

' + document.getElementById('cgcform').outerHTML.replace(' action=\"//',' action=\"https://').replace(' value=\"\"',' value=\"' + incval + '\"').replace(huhsel + '','').replace(huhsel,'').replace('display:none','display:inline-block').replace('>','>') + ''; } function picked(gcountry) { if (document.getElementById('bemail')) { document.getElementById('bemail').style.display='inline-block'; } goes++; if (gcountry == ccountry) { score++; document.getElementById('score').innerHTML='Score: ' + score + ' Goes: ' + goes; if (firstgo) { ans=confirm('Well done. OK does a Google (image) search.'); } } else { document.getElementById('score').innerHTML='Score: ' + score + ' Goes: ' + goes; ans=confirm('Sorry, but answer is ' + ccountry + '. OK does a Google (image) search.'); } firstgo=false; if (ans == true) { window.open(urlprefix + encodeURIComponent(lcity), '_blank', 'top=50,left=50,width=400,height=400'); } document.getElementById('ucountry').value=''; getnext(); } \n function getnext() { if (document.getElementById('bemail')) { document.getElementById('bemail').style.display='inline-block'; } if (!oucity) { oucity=document.getElementById('ucity'); } var rnum=lastg; while (rnum == lastg) { rnum=Math.floor(Math.random() * numc); } \n lastg=rnum; var ois=document.getElementById('o' + rnum); \n document.getElementById('ucity').value=ois.value; \n lcity=ois.value; \n document.getElementById('thiscity').value=ois.value; ccountry=ois.innerHTML; gethtmlready(ois.value); \n } \n
"; return $ret; } echo "City Guess Country Game" . shownextcity() . "

City Guess Country Game


Which Country is City In?


Score: " . $escore . " Goes: " . $egoes . "


" . notshowucities() . "
CityCountry
" . showucountries() . "  
"; ?>