" . 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=[]; 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 (!strstr($uniquecountries, "," . urlencode($thosetwobits[0]) . ",")) { $uniquecountries .= urlencode($thosetwobits[0]) . ","; } } } $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", "", $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() . "  
"; ?>