1<?php
2require_once ('getWikiData.php');
3require_once ('getContinent.php');
4require_once ('getErrors.php');
5require_once ('default.php');
6
7   $countryCode=$_GET["ctry"];
8   $q=$_GET["q"];
9   $topic=$_GET["p"];
10   //
11   // get Continent
12   list ($continent, $country) = getContinent($countryCode);
13
14   $html = '<h1> '.ucwords($topic).'</h1>';
15   $html .= '<h2 class="indent">' . $q . "</h2>";
16
17   $region = convToFile($q);
18   $countryCode = strtolower($countryCode);
19
20   //
21   // First try to connect to the temporary database
22   //
23   $db = sqlite_open('../db/'.$tempdb.'.sqlite', 0666, $error);
24   if (!$db) {
25      $renderer->doc .= '<div class="error"> The database error is '. $error .'</div>';
26	  return FALSE;
27   }
28   $query = "SELECT * FROM states WHERE state_abbr = '".$q."'";
29   $result = sqlite_query($db, $query);
30   if (!$result) {
31       $renderer->doc .= '<div class="error"> Cannot execute query. </div>';
32       return FALSE;
33   }
34   $row = sqlite_fetch_array($result, SQLITE_ASSOC);
35   sqlite_close($db);
36   $state = $row['state'];
37   $id = $row['state_id'];
38
39   $countryCode = strtolower($countryCode);
40   $namespace = $topic;
41   $path = $topic . ':earth:' . $continent . ':' . $countryCode . ':' . $region;
42   $wikiData = pullInWikiData($path, $namespace, $topic);
43   if ($wikiData != '')
44       $html .= $wikiData;
45   else
46       $html .=  '<p>'. htmlentities($exploreErrors['editPg']['en'], ENT_NOQUOTES) . htmlentities($exploreErrors['ckBack']['en'], ENT_NOQUOTES) .'</p> ';
47   $html  .= '<br /><p><a href="doku.php?id='.$path.'"><input type="button" class="button" value="Go to Edit" title="Go To Edit" /></a></p>';
48   $html .= htmlentities($exploreErrors['update']['en'], ENT_NOQUOTES);
49
50   echo $html;
51?>