From 0ef8db837193fbc08e61d2daab6565ecf4009b50 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 9 Aug 2015 12:15:46 +0100 Subject: [PATCH] not all requests have remote_addr --- core/database.class.php | 9 +++++++-- ext/link_image/main.php | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/core/database.class.php b/core/database.class.php index 319282ff..f0dfafce 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -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)"; } } diff --git a/ext/link_image/main.php b/ext/link_image/main.php index 75f97221..859d510f 100644 --- a/ext/link_image/main.php +++ b/ext/link_image/main.php @@ -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); } }