not all requests have remote_addr

This commit is contained in:
Shish 2015-08-09 12:15:46 +01:00
parent a70ca33f96
commit 0ef8db8371
2 changed files with 10 additions and 5 deletions

View file

@ -146,7 +146,12 @@ class PostgreSQL extends DBEngine {
* @param \PDO $db
*/
public function init($db) {
$db->exec("SET application_name TO 'shimmie [{$_SERVER['REMOTE_ADDR']}]';");
if(array_key_exists('REMOTE_ADDR', $_SERVER)) {
$db->exec("SET application_name TO 'shimmie [{$_SERVER['REMOTE_ADDR']}]';");
}
else {
$db->exec("SET application_name TO 'shimmie [local]';");
}
$db->exec("SET statement_timeout TO 10000;");
}
@ -174,7 +179,7 @@ class PostgreSQL extends DBEngine {
*/
public function create_table_sql($name, $data) {
$data = $this->scoreql_to_sql($data);
return 'CREATE TABLE '.$name.' ('.$data.')';
return "CREATE TABLE $name ($data)";
}
}

View file

@ -28,9 +28,9 @@ class LinkImage extends Extension {
$text_link = trim($text_link) == "" ? null : $text_link; // null blank setting so the url gets filled in on the text links.
return array(
'thumb_src' => make_http($image->get_thumb_link()),
'image_src' => make_http($image->get_image_link()),
'post_link' => make_http($_SERVER["REQUEST_URI"]),
'thumb_src' => make_http($image->get_thumb_link()),
'image_src' => make_http($image->get_image_link()),
'post_link' => make_http(make_link("post/view/{$image->id}")),
'text_link' => $text_link);
}
}