private static function fetchAllStationsFromDB($lang) { APICall::connectToDB(); $station = array(); try { $lang = mysql_real_escape_string(strtoupper($lang)); $query = "SELECT `ID`,`X`, `Y`, `STD`,`{$lang}` FROM stations WHERE `ID` LIKE 'BE.NMBS.%' ORDER BY `{$lang}`"; $result = mysql_query($query) or die("Could not get stationslist from DB"); $i = 0; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { $station[$i] = new Station(); $station[$i]->id = $line["ID"]; $station[$i]->locationX = $line["X"]; $station[$i]->locationY = $line["Y"]; if ($line[$lang] != "") { $station[$i]->name = $line[$lang]; } else { $station[$i]->name = $line["STD"]; } $station[$i]->standardname = $line["STD"]; $i++; } } catch (Exception $e) { throw new Exception("Error reading from the database.", 3); } return $station; }
/** * @param $lang * @return array * @throws Exception */ private static function fetchAllStationsFromDB($lang) { if ($lang == "EN") { $lang = "STD"; } APICall::connectToDB(); mysql_query("SET NAMES utf8"); $station = []; try { $lang = mysql_real_escape_string(strtoupper($lang)); $query = "SELECT `ID`,`X`, `Y`, `STD`,`{$lang}` FROM mivb ORDER BY `{$lang}`"; $result = mysql_query($query) || die("Could not get stationslist from DB"); $i = 0; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { $station[$i] = new Station(); $station[$i]->id = $line["ID"]; $station[$i]->locationX = $line["X"]; $station[$i]->locationY = $line["Y"]; $station[$i]->name = $line[$lang]; $station[$i]->standardname = $line["STD"]; $i++; } } catch (Exception $e) { throw new Exception("Error reading from the database.", 300); } return $station; }
protected function writeLog($ua, $from, $to, $err, $ip) { // get time + date in rfc2822 format date_default_timezone_set('Europe/Brussels'); $now = date('D, d M Y H:i:s'); if ($from == "") { $from = "EMPTY"; } if ($to == "") { $to = "EMPTY"; } if ($ua == "") { $ua = "-"; } APICall::connectToDB(); $from = mysql_real_escape_string($from); $to = mysql_real_escape_string($to); $err = mysql_real_escape_string($err); $ip = mysql_real_escape_string($ip); $ua = mysql_real_escape_string($ua); // insert in db try { include "../includes/dbConfig.php"; $query = "INSERT INTO {$api_table} ({$api_c2}, {$api_c3}, {$api_c4}, {$api_c5}, {$api_c6}, {$api_c7}, {$api_c8}) VALUES('{$now}', '{$ua}', '{$from}', '{$to}', '{$err}', '{$ip}', '{$api_server_name}')"; $result = mysql_query($query); } catch (Exception $e) { echo "Error writing to the database."; } }
/** * @param $ua * @param $from * @param $to * @param $err * @param $ip * @throws Exception */ protected function writeLog($ua, $from, $to, $err, $ip) { // get time + date in rfc2822 format date_default_timezone_set('Europe/Brussels'); $now = date('D, d M Y H:i:s'); if ($from == "") { $from = "EMPTY"; } if ($to == "") { $to = "EMPTY"; } if ($ua == "") { $ua = "-"; } APICall::connectToDB(); $from = mysql_real_escape_string($from); $to = mysql_real_escape_string($to); $err = mysql_real_escape_string($err); $ip = mysql_real_escape_string($ip); $ua = mysql_real_escape_string($ua); // insert in db try { $dotenv = new Dotenv(dirname(__DIR__)); $dotenv->load(); $query = "\n INSERT INTO {$api_table} ({$api_c2}, {$api_c3}, {$api_c4}, {$api_c5}, {$api_c6}, {$api_c7}, {$api_c8})\n VALUES('{$now}', '{$ua}', '{$from}', '{$to}', '{$err}', '{$ip}', '" . $_ENV['apiServerName'] . "')"; $result = mysql_query($query); } catch (Exception $e) { echo "Error writing to the database."; } }