1<?php 2function getContinent($countryCode2) { 3 require_once ('default.php'); 4 5 $continents = array( 6 'AF' => "africa", 7 'AS' => "asia", 8 'EU' => "europe", 9 'NA' => "north-america", 10 'SA' => "south-america", 11 'OC' => "oceania", 12 'AN' => "antarctica"); 13 14 // 15 // Connect to the database 16 // 17 $db = sqlite_open('../db/test.sqlite', 0666, $error); 18 if (!$db) { 19 $renderer->doc .= '<div class="error"> The database error is '. $error .'</div>'; 20 return FALSE; 21 } 22 // Get continent 23 $query = "SELECT * FROM continents WHERE code_2 = '".$countryCode2."'"; 24 $result = sqlite_query($db, $query); 25 if (!$result) { 26 $renderer->doc .= '<div class="error"> Cannot execute query. </div>'; 27 return FALSE; 28 } 29 $row = sqlite_fetch_array($result, SQLITE_ASSOC); 30 sqlite_close($db); 31 $str = $continents[$row['continent']]; 32 $contName = str_replace(array("<", ">"), array("<", ">"), htmlentities($str, ENT_NOQUOTES)); 33 $ctryName = $row['short_name']; 34 return array ($contName, $ctryName); 35} 36 37function convToFile($string) { 38 $string = iconv('UTF-8', 'ASCII//TRANSLIT', $string); 39 $search = array('_', ' ', '^'); 40 $replace = array('-', '-', ''); 41 $string = str_replace($search, $replace, $string); 42 $string = ereg_replace("[^A-Za-z0-9-]", "", $string); 43 $string = strtolower($string); 44 return $string; 45} 46?>