function all_reset($baseDir) { //Очищаем временную папку temp if (file_exists($baseDir . 'tempFiles')) { foreach (glob($baseDir . 'tempFiles/*') as $file) { unlink($file); } } //Очищаем временную папку для граббера if (file_exists($baseDir . 'tempGrab')) { foreach (glob($baseDir . 'tempGrab/*') as $file) { unlink($file); } } //Очищаем временную папку для куков if (file_exists($baseDir . 'cookies')) { foreach (glob($baseDir . 'cookies/*') as $file) { unlink($file); } } //Приводим все ключи "в обработке" к состоянию "в ожидании" $dbconn = pg_connect(DB_CONN_STR) or die('Не могу подключиться к БД: ' . pg_last_error()); //Сбросить "занятые" аккаунты $query = 'UPDATE accounts SET busy=0 ' . "WHERE busy=1"; pg_query($query) or die('Ошибка запроса: ' . pg_last_error()); //Сбросить "занятые" прокси $query = 'UPDATE proxys SET busy=0 ' . "WHERE busy=1"; pg_query($query) or die('Ошибка запроса: ' . pg_last_error()); pg_close($dbconn); }
function disconnect() { if (!empty($this->db)) { pg_close($this->db); $this->db = null; } }
/** * @return PgSQL **/ public function disconnect() { if ($this->isConnected()) { pg_close($this->link); } return $this; }
public function disconnect() { if ($this->connection) { pg_close($this->connection); $this->connection = NULL; } }
function disconnect() { if (pg_close($this->connection)) { return 1; } return 0; }
function __destruct() { if ($this->is_connected()) { $this->query('ROLLBACK'); pg_close($this->db); } }
function getDetails($ptdb, $id, $type, $langs, $offset) { global $format, $callback; // request $wikipediarequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 9) = 'wikipedia';"; $namerequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 4) = 'name';"; // connnecting to database $connection = connectToDatabase($ptdb); // if there is no connection if (!$connection) { exit; } $wikipediaresponse = requestDetails($wikipediarequest, $connection); $nameresponse = requestDetails($namerequest, $connection); pg_close($connection); $response = tagTransform("../locales/departures.xml", getTags($ptdb, $id, $type), $type); if ($response) { if ($format == "text") { echo textDetailsOut($response, $nameresponse, $wikipediaresponse, $langs, $offset); } else { if ($format == "json") { echo jsonDetailsOut($response, $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type, $callback); } else { echo xmlDetailsOut($response, $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type); } } return true; } else { return false; } }
public function consulta($aux) { $auxcon = $this->conectar(); $resultado = pg_query($aux) or die('La consulta fallo: ' . pg_last_error()); pg_close($auxcon); return $resultado; }
function wsoBruteForce($ip, $port, $login, $pass) { $str = "host='" . $ip . "' port='" . $port . "' user='******' password='******' dbname=postgres"; $res = @pg_connect($str); @pg_close($res); return $res; }
/** * * @param type $query * @param type $type * @return type */ public function execute($query, $type = null) { $result = array(); switch ($this->db_engine) { case "pgsql": $resultado = pg_query($this->conn, $query); while ($row = pg_fetch_row($resultado)) { $result[] = $row; } pg_close($this->conn); break; case "mssql": $resultado = odbc_exec($this->conn, $query); while ($row = odbc_fetch_array($resultado)) { $result[] = $row; } break; case "mysql": $result = array(); $resultado = mysql_query($query); if (gettype($resultado) == "boolean") { $result = $resultado; } else { while ($row = mysql_fetch_row($resultado)) { $result[] = $row; } } mysql_close($this->conn); break; } return $result; }
/** * {@inheritdoc} */ public function close() { if ($this->dbHandle) { \pg_close($this->dbHandle); $this->dbHandle = null; } }
public static function close_conn() { if (self::$is_conn_set) { pg_close(self::$conn); self::$is_conn_set = false; } }
function auth($bazaj, $uid, $puid) { $uid_s = pg_escape_string($uid); $puid_s = pg_escape_string($puid); $res = pg_query($bazaj, "select username, password from users where username='******' and password='******'"); if (!$res) { print "<h2>STOP: Internal system error. Please refresh this page.</h2>"; exit; } if (pg_num_rows($res) != 1) { return "f"; } $row = pg_fetch_row($res); $j_uid = $row[0]; $j_puid = $row[1]; if ($j_uid != $uid) { pg_close($bazaj); return "f"; } else { if ($puid_s === $j_puid) { return "t"; } else { return "f"; } } return "f"; }
public function getJSON() { $conn = getConnection(); $taskid = array_key_exists("taskid", $_GET) ? $_GET["taskid"] : ""; if (empty($taskid)) { $taskid = array_key_exists("taskid", $_POST) ? $_POST["taskid"] : ""; } $year = array_key_exists("year", $_GET) ? $_GET["year"] : ""; if (empty($year)) { $year = array_key_exists("year", $_POST) ? $_POST["year"] : ""; } $quarter = array_key_exists("quarter", $_GET) ? $_GET["quarter"] : ""; if (empty($quarter)) { $quarter = array_key_exists("quarter", $_POST) ? $_POST["quarter"] : ""; } $yearquarter = $year * 10 + $quarter; $sql = "SELECT SUM(personnel_actual) AS personnel,\n\t\t\t SUM(investments_actual) AS investments, \n\t\t\t SUM(consumables_actual) AS consumables, \n\t\t\t SUM(services_actual) AS services, \n\t\t\t SUM(transport_actual) AS transport,\n\t\t\t SUM(admin) AS admin\n\t\t\tFROM budget \n\t\t\tWHERE task_id = " . (empty($taskid) ? 0 : $taskid) . " \n\t\t\t AND (year * 10) + quarter < " . $yearquarter . "\n\t\t\t AND status = 3"; $output = array(); $output["taskid"] = $taskid; $result = pg_query($conn, $sql); if ($result && pg_num_rows($result) > 0) { $row = pg_fetch_array($result); $output["personnel"] = $row["personnel"]; $output["investments"] = $row["investments"]; $output["consumables"] = $row["consumables"]; $output["services"] = $row["services"]; $output["transport"] = $row["transport"]; $output["admin"] = $row["admin"]; } return json_encode($output); pg_close($conn); return $output; }
function getDetails($db, $id, $type, $langs, $offset) { global $format; global $callback; // request $request = "SELECT\n\t\t\t\ttags->'addr:street' AS \"street\",\n\t\t\t\ttags->'addr:housenumber' AS \"housenumber\",\n\t\t\t\ttags->'addr:country' AS \"country\",\n\t\t\t\ttags->'addr:postcode' AS \"postcode\",\n\t\t\t\ttags->'addr:city' AS \"city\",\n\t\t\t\ttags->'addr:housename' AS \"housename\",\n\t\t\t\ttags->'addr:suburb' AS \"suburb\",\n\t\t\t\ttags->'addr:province' AS \"province\",\n\t\t\t\ttags->'addr:unit' AS \"unit\",\n\t\t\t\ttags->'addr:floor' AS \"floor\",\n\t\t\t\ttags->'addr:door' AS \"door\",\n\t\t\t\ttags->'wikipedia' AS \"wikipedia\",\n\t\t\t\ttags->'phone' AS \"phone1\",\n\t\t\t\ttags->'contact:phone' AS \"phone2\",\n\t\t\t\ttags->'addr:phone' AS \"phone3\",\n\t\t\t\ttags->'phone:mobile' AS \"mobilephone1\",\n\t\t\t\ttags->'contact:mobile' AS \"mobilephone2\",\n\t\t\t\ttags->'fax' AS \"fax1\",\n\t\t\t\ttags->'contact:fax' AS \"fax2\",\n\t\t\t\ttags->'addr:fax' AS \"fax3\",\n\t\t\t\ttags->'website' AS \"website1\",\n\t\t\t\ttags->'url' AS \"website2\",\n\t\t\t\ttags->'url:official' AS \"website3\",\n\t\t\t\ttags->'contact:website' AS \"website4\",\n\t\t\t\ttags->'operator' AS \"operator\",\n\t\t\t\ttags->'email' AS \"email1\",\n\t\t\t\ttags->'contact:email' AS \"email2\",\n\t\t\t\ttags->'addr:email' AS \"email3\",\n\t\t\t\ttags->'opening_hours' AS \"openinghours\",\n\t\t\t\ttags->'service_times' AS \"servicetimes\",\n\t\t\t\ttags->'fee' AS \"fee\",\n\t\t\t\ttags->'toll' AS \"toll\",\n\t\t\t\ttags->'ref' AS \"ref\",\n\t\t\t\ttags->'capacity' AS \"capacity\",\n\t\t\t\ttags->'internet_access' AS \"internet_access\",\n\t\t\t\ttags->'image' AS \"image\",\n\t\t\t\ttags->'image:panorama' AS \"panorama\",\n\t\t\t\ttags->'description' AS \"description\",\n\t\t\t\ttags->'stars' AS \"stars\",\n\t\t\t\ttags->'cuisine' AS \"cuisine\",\n\t\t\t\ttags->'smoking' AS \"smoking\",\n\t\t\t\ttags->'biergarten' AS \"biergarten\",\n\t\t\t\ttags->'beer_garden' AS \"beer_garden\",\n\t\t\t\ttags->'brewery' AS \"beer\",\n\t\t\t\ttags->'microbrewery' AS \"microbrewery\",\n\t\t\t\ttags->'fuel:diesel' AS \"diesel\",\n\t\t\t\ttags->'fuel:GTL_diesel' AS \"gtldiesel\",\n\t\t\t\ttags->'fuel:HGV_diesel' AS \"hgvdiesel\",\n\t\t\t\ttags->'fuel:biodiesel' AS \"biodiesel\",\n\t\t\t\ttags->'fuel_octane_91' AS \"octane91\",\n\t\t\t\ttags->'fuel:octane_95' AS \"octane95\",\n\t\t\t\ttags->'fuel:octane_98' AS \"octane98\",\n\t\t\t\ttags->'fuel:octane_100' AS \"octane100\",\n\t\t\t\ttags->'fuel:octane_98_leaded' AS \"octane98l\",\n\t\t\t\ttags->'fuel:1_25' AS \"fuel25\",\n\t\t\t\ttags->'fuel:1_50' AS \"fuel50\",\n\t\t\t\ttags->'fuel:alcohol' AS \"alcohol\",\n\t\t\t\ttags->'fuel:ethanol' AS \"ethanol\",\n\t\t\t\ttags->'fuel:methanol' AS \"methanol\",\n\t\t\t\ttags->'fuel:svo' AS \"svo\",\n\t\t\t\ttags->'fuel:e85' AS \"e85\",\n\t\t\t\ttags->'fuel:biogas' AS \"biogas\",\n\t\t\t\ttags->'fuel:lpg' AS \"lpg\",\n\t\t\t\ttags->'fuel:cng' AS \"cng\",\n\t\t\t\ttags->'fuel:LH2' AS \"lh2\",\n\t\t\t\ttags->'fuel:electricity' AS \"electro\",\n\t\t\t\ttags->'fuel:adblue' AS \"adblue\",\n\t\t\t\ttags->'car_wash' AS \"carwash\",\n\t\t\t\ttags->'car_repair' AS \"carrepair\",\n\t\t\t\ttags->'shop' AS \"shop\",\n\t\t\t\ttags->'kiosk' AS \"kiosk\",\n\t\t\t\ttags->'ele' AS \"ele\",\n\t\t\t\ttags->'population' AS \"population\",\n\t\t\t\ttags->'iata' AS \"iata\",\n\t\t\t\ttags->'icao' AS \"icao\",\n\t\t\t\ttags->'disused' AS \"disused\",\n\t\t\t\ttags->'wheelchair' AS \"wheelchair\",\n\t\t\t\ttags->'wheelchair:toilets' AS \"wheelchair:toilets\",\n\t\t\t\ttags->'wheelchair:rooms' AS \"wheelchair:rooms\",\n\t\t\t\ttags->'wheelchair:access' AS \"wheelchair:access\",\n\t\t\t\ttags->'wheelchair:places' AS \"wheelchair:places\"\n\t\t\tFROM " . $type . "s WHERE (id = " . $id . ");"; $wikipediarequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 9) = 'wikipedia';"; $namerequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 4) = 'name';"; // connnecting to database $connection = connectToDatabase($db); // if there is no connection if (!$connection) { exit; } $response = requestDetails($request, $connection); $wikipediaresponse = requestDetails($wikipediarequest, $connection); $nameresponse = requestDetails($namerequest, $connection); pg_close($connection); if ($response) { if ($format == "text") { echo textMoredetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset); } else { if ($format == "json") { echo jsonMoredetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type, $callback); } else { echo xmlMoredetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type); } } return true; } else { return false; } }
function importOsmFile($filename, $db) { global $offset, $offsetfactorrels, $connection; $connection = connectToDatabase($db); // if there is no connection if (!$connection) { reportError("Cannot connect to database."); return false; } $result = pg_query($connection, "TRUNCATE nodes"); $result = pg_query($connection, "TRUNCATE ways"); $result = pg_query($connection, "TRUNCATE relations"); $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); if (!($fp = fopen($filename, "r"))) { reportError("Cannot open file."); return false; } while ($data = fread($fp, 4096)) { if (!xml_parse($xml_parser, $data, feof($fp))) { reportError("XML-Error."); return false; } } xml_parser_free($xml_parser); fclose($fp); pg_close($connection); echo "Finished " . $db . "...\n"; return true; }
public function close_connection() { if (isset($this->connection)) { pg_close($this->connection); unset($this->connection); } }
/** * Check mysql connection (master & slaves). * * @return array(FALSE, "") in case of failure and array(TRUE, "") otherwise. */ function check_pgsql() { global $databases; // collect response time $time = microtime(); // check master connection $master = $databases['default']['default']; $connection_string = "host=" . $master['host'] . ' ' . "port=" . $master['port'] . ' ' . "dbname=" . $master['database'] . ' ' . "user="******"password="******"pgsql: cannot connect to postgres master"); } pg_close($db_connection); // collect response time $time_spent = microtime() - $time; $time_spent = round(1000 * $time_spent) . "ms"; // convert in ms // check slaves connections if any if (!isset($databases['default']['slave'])) { return array(TRUE, "pgsql: OK (" . $time_spent . ")"); } $slaves = $databases['default']['slave']; foreach ($slaves as $slave) { $connection_string = "host=" . $slave['host'] . ' ' . "port=" . $slave['port'] . ' ' . "dbname=" . $slave['database'] . ' ' . "user="******"password="******"PgSQL: cannot connect to PgSql slave (" . $slave['host'] . ")"); } pg_close($db_connection); } return array(TRUE, "PgSQL: OK (" . $time_spent . ")"); }
private function disconnect() { if (!is_null($this->link)) { return pg_close($this->link); } return false; }
public function __destruct() { /* | About: | -> Close the connection and returns the elapsed time. */ if (!empty($this->connection['debugMode'])) { $this->errorHandling(); } switch ($this->connection['db_type']) { case 'mysql': $this->conn->close(); break; case 'mssql': mssql_close($this->conn); break; case 'sqlserv': sqlsrv_close($this->conn); break; case 'pgsql': pg_close($this->conn); break; } return $this->elapsedTime(); }
function disconnect() { if ($this->connectionId) { @pg_close($this->connectionId); $this->connectionId = null; } }
function get_points($table_name, $show_json = FALSE) { // Connecting, selecting database $dbconn = pg_connect("host=localhost dbname=steki_db user=postgres password=password") or die('Could not connect: ' . pg_last_error()); // Performing SQL query $query = 'SELECT array_to_json(array_agg(row_to_json(t))) as ' . $table_name . '_json FROM ( SELECT id, latlong[0] as latitude, latlong[1] as longitude, brand, rating, votes, nam as name, descr as description FROM "' . $table_name . '" ) t'; //$query = 'SELECT row_to_json("'.$table_name.'") as '.$table_name.'_json FROM "'.$table_name.'"'; $result = pg_query($query) or die('Query failed: ' . pg_last_error()); // Printing results in HTML $json = pg_fetch_array($result, null, PGSQL_ASSOC); if ($show_json) { echo json_encode(array_values($json)); } else { $str = implode("*", $json); $out = htmlspecialchars($str); echo $out; } // Free resultset pg_free_result($result); // Closing connection pg_close($dbconn); //return $json; }
/** * */ protected function closeConnection() { // validate if (isset($this->connection)) { pg_close($this->connection); } }
public function connect($parameters, $selectDB = false) { $this->lastParameters = $parameters; // Note: Postgres always behaves as though $selectDB = true, ignoring // any value actually passed in. The controller passes in true for other // connectors such as PDOConnector. // Escape parameters $arguments = array($this->escapeParameter($parameters, 'server', 'host', 'localhost'), $this->escapeParameter($parameters, 'port', 'port', 5432), $this->escapeParameter($parameters, 'database', 'dbname', 'postgres'), $this->escapeParameter($parameters, 'username', 'user'), $this->escapeParameter($parameters, 'password', 'password')); // Close the old connection if ($this->dbConn) { pg_close($this->dbConn); } // Connect $this->dbConn = @pg_connect(implode(' ', $arguments)); if ($this->dbConn === false) { // Extract error details from PHP error handling $error = error_get_last(); if ($error && preg_match('/function\\.pg-connect\\<\\/a\\>\\]\\: (?<message>.*)/', $error['message'], $matches)) { $this->databaseError(html_entity_decode($matches['message'])); } else { $this->databaseError("Couldn't connect to PostgreSQL database."); } } elseif (pg_connection_status($this->dbConn) != PGSQL_CONNECTION_OK) { throw new ErrorException($this->getLastError()); } //By virtue of getting here, the connection is active: $this->databaseName = empty($parameters['database']) ? PostgreSQLDatabase::MASTER_DATABASE : $parameters['database']; }
function __destruct() { if ($this->connection) { pg_close($this->connection); } $this->connection = false; }
function makeCTFParams() { $cnx = __dbConnect(); if (!$cnx) { print "<b>DATABASE CONNECTION ERROR</b>"; exit(1); } $query = pg_query("SELECT * FROM main.ctf_map_def ORDER BY name"); if (!$query) { print "<b>DATABASE ERROR</b>"; exit(1); } $ctfMaps = array(); while ($r = pg_fetch_assoc($query)) { $ctfMaps[$r['id']] = $r; $query2 = pg_query("SELECT COUNT(*) FROM main.ctf_map_layout WHERE map={$r['id']} AND spawn_here"); if (!$query2) { print "<b>DATABASE ERROR</b>"; exit(1); } list($ctfMaps[$r['id']]['players']) = pg_fetch_array($query2); pg_free_result($query2); } pg_free_result($query); pg_close($cnx); $map = $ctfMaps[$_SESSION['lw_new_game']['ctfmap']]; $cParams = $_SESSION['lw_new_game']['ctfparams']; $params = array('usemap' => $map['id'], 'maxplayers' => $map['players'], 'norealloc' => 1, 'partialtechs' => 0, 'lockalliances' => $map['alliances'], 'alliancecap' => 0, 'victory' => 2, 'novacation' => 1); foreach ($cParams as $p => $v) { $params[$p] = $v; } return $params; }
/** * Disconnect from postgres instance */ public function disconnect() { if ($this->Resource) { pg_close($this->Resource); $this->Resource = null; } }
public static function getPrivacyData() { global $dbconn, $ixmaps_debug_mode; $sql1 = "SELECT privacy_stars.* FROM privacy_stars"; $sql2 = "SELECT privacy_scores.* FROM privacy_scores order by asn, star_id"; //echo $sql; $result1 = pg_query($dbconn, $sql1) or die('Query privacy_stars failed: ' . pg_last_error()); $result2 = pg_query($dbconn, $sql2) or die('Query privacy_scores failed: ' . pg_last_error()); // loop and format the data $stars = array(); $scores = array(); // stars while ($line1 = pg_fetch_array($result1, null, PGSQL_ASSOC)) { $stars[$line1['star_id']] = $line1; } while ($line2 = pg_fetch_array($result2, null, PGSQL_ASSOC)) { $scores[$line2['asn']][] = $line2; } //$stars = pg_fetch_all($result1); //$scores = pg_fetch_all($result2); pg_free_result($result1); pg_free_result($result2); $privacy = array('stars' => $stars, 'scores' => $scores); pg_close($dbconn); //print_r($privacy); return $privacy; }
function getDetails($db, $id, $type, $langs, $offset) { global $format, $callback; // request $request = "SELECT\n\t\t\t\ttags->'addr:street' AS \"street\",\n\t\t\t\ttags->'addr:housenumber' AS \"housenumber\",\n\t\t\t\ttags->'addr:housename' AS \"housename\",\n\t\t\t\ttags->'addr:country' AS \"country\",\n\t\t\t\ttags->'addr:postcode' AS \"postcode\",\n\t\t\t\ttags->'addr:city' AS \"city\",\n\t\t\t\ttags->'addr:suburb' AS \"suburb\",\n\t\t\t\ttags->'addr:province' AS \"province\",\n\t\t\t\ttags->'addr:unit' AS \"unit\",\n\t\t\t\ttags->'addr:floor' AS \"floor\",\n\t\t\t\ttags->'addr:door' AS \"door\",\n\t\t\t\ttags->'phone' AS \"phone1\",\n\t\t\t\ttags->'contact:phone' AS \"phone2\",\n\t\t\t\ttags->'addr:phone' AS \"phone3\",\n\t\t\t\ttags->'fax' AS \"fax1\",\n\t\t\t\ttags->'contact:fax' AS \"fax2\",\n\t\t\t\ttags->'addr:fax' AS \"fax3\",\n\t\t\t\ttags->'website' AS \"website1\",\n\t\t\t\ttags->'url' AS \"website2\",\n\t\t\t\ttags->'url:official' AS \"website3\",\n\t\t\t\ttags->'contact:website' AS \"website4\",\n\t\t\t\ttags->'operator' AS \"operator\",\n\t\t\t\ttags->'email' AS \"email1\",\n\t\t\t\ttags->'contact:email' AS \"email2\",\n\t\t\t\ttags->'addr:email' AS \"email3\",\n\t\t\t\ttags->'opening_hours' AS \"openinghours\",\n\t\t\t\ttags->'service_times' AS \"servicetimes\",\n\t\t\t\ttags->'image' AS \"image\"\n\t\t\tFROM " . $type . "s WHERE (id = " . $id . ");"; $wikipediarequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 9) = 'wikipedia';"; $namerequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 4) = 'name';"; // connnecting to database $connection = connectToDatabase($db); // if there is no connection if (!$connection) { exit; } $response = requestDetails($request, $connection); $wikipediaresponse = requestDetails($wikipediarequest, $connection); $nameresponse = requestDetails($namerequest, $connection); pg_close($connection); if ($response) { if ($format == "text") { echo textDetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset); } else { if ($format == "json") { echo jsonDetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type, $callback); } else { echo xmlDetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type); } } return true; } else { return false; } }
function close() { if ($this->conn) { return @pg_close($this->conn); } return false; }