HTMLHEAD; if ($_POST["submit"]) $queryn = htmlspecialchars($_POST["queryname"]); else if ($_GET["queryname"]) $queryn = htmlspecialchars($_GET["queryname"]); if (isset($queryn)) { $queryname = str_replace(" ", "%20", trim($queryn)); $queryname = str_replace(array("/", "."), "", $queryname); if (!$queryname || $queryname == "") { $output_str .= "

Error with queryname!

\n\n"; unset($queryname); } } if (isset($queryname)) { $ch = curl_init(); $mini_url = "http://$queryname.myminicity.com/xml"; curl_setopt($ch, CURLOPT_URL, $mini_url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $curl_result = curl_exec($ch); curl_close($ch); # Process result try { $citydata = new SimpleXMLElement($curl_result); } catch (Exception $e) { $e_msg = $e->getMessage(); if ($e_msg == "String could not be parsed as XML") { $output_str .= "

Error! The most likely cause for this error is that you specified a city that doesn't exist! Please recheck the name "$queryname" for correctness.

\n\n"; } else $output_str .= "

Unexpected error! Message: $e_msg

\n\n

Please notify the maintainer of this script and provide the message above.

\n\n"; $output_str .= "\n\n"; exit($output_str); } # City "mechanics" $trouble_array = array("unemployment" => true, "transport" => false, "criminality" => true, "pollution" => true); $target = array("unemployment" => 0, "transport" => 100, "criminality" => 0, "pollution" => 0); $short_urls = array("unemployment" => "ind", "transport" => "tra", "criminality" => "sec", "pollution" => "env"); $extra_urls = array("population" => "", "incomes" => "com"); $extra_mins = array("population" => 0, "incomes" => 1000); $cityname = "name"; $citylink = "host"; $city_pop = "population"; # Initialize and process $extra_avail = true; $output_str .= "

{$citydata->$cityname}

\n\n"; foreach($trouble_array as $trouble_type => $goes_down) { $provide_url = false; if ($goes_down) { if ($citydata->$trouble_type > $target[$trouble_type]) $provide_url = true; } else { if ($citydata->$trouble_type < $target[$trouble_type]) $provide_url = true; } if ($provide_url) { $most_trouble = $trouble_type; $extra_avail = false; } } if (isset($most_trouble)) { header("Location: http://" . $citydata->$citylink . "/" . $short_urls[$most_trouble]); $redirect_flag = true; } else { $output_str .= "

Your city has no specific problems, so you are free to increase its growth and other positive factors with the following links.

\n\n"; foreach($extra_urls as $extra_type => $extra_url) { if ($citydata->$city_pop >= $extra_mins[$extra_type]) { $output_str .= "

{$citydata->$cityname} $extra_type: {$citydata->$extra_type} - $citylink}/$extra_url\">Increase $extra_type

\n\n"; } else $output_str .= "

You will be able to increase $extra_type once your $city_pop reaches {$extra_mins[$extra_type]}.

\n\n"; } } } else { $output_str .= <<Chaoseed Miniauto v.2

This web utility is designed to automatically choose the best stat to increase for a MyMiniCity city. To use, provide the city's name as the value of the GET parameter "queryname". For example, if your city name was "cobweb":

http://chaoseed.com/miniaut2.php?queryname=cobweb

Anyone visiting this URL will cause your city to improve or grow automatically.

You may also fill in the query name in this form.

City name:

HTMLINNER; } if (!$redirect_flag) { $output_str .= "\n\n"; exit($output_str); } ?>