From 45e9e0f5653993d5f463209691953e7a41527267 Mon Sep 17 00:00:00 2001 From: Dmitry Sandalov Date: Tue, 5 Nov 2013 12:13:55 +0300 Subject: fix #270 access from remote machine Replacing SERVER_NAME with HTTP_HOST allows me to use Poche on remote machines --- inc/poche/Tools.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/poche/Tools.class.php') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 1d092823..030d75ba 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -53,12 +53,12 @@ class Tools $scriptname = str_replace('/index.php', '/', $_SERVER["SCRIPT_NAME"]); - if (!isset($_SERVER["SERVER_NAME"])) { + if (!isset($_SERVER["HTTP_HOST"])) { return $scriptname; } return 'http' . ($https ? 's' : '') . '://' - . $_SERVER["SERVER_NAME"] . $serverport . $scriptname; + . $_SERVER["HTTP_HOST"] . $serverport . $scriptname; } public static function redirect($url = '') -- cgit v1.2.3 From f2d3ee98a6a3137f8c3edd62294d34a8ff4700b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Wed, 13 Nov 2013 15:17:34 +0100 Subject: [fix] bug fix #287: test if open_basedir & safe_mode are active to use CURLOPT_FOLLOWLOCATION --- inc/poche/Tools.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'inc/poche/Tools.class.php') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 1d092823..7a872e7d 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -133,7 +133,9 @@ class Tools $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_TIMEOUT, $timeout); - curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); + if (!ini_get('open_basedir') && !ini_get('safe_mode')) { + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); + } curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, false); -- cgit v1.2.3 From 2e2ebe5ec767dcbee90394d12b03298592c87805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 13:15:06 +0100 Subject: [add] create tags page --- inc/poche/Tools.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'inc/poche/Tools.class.php') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 750553f1..5bb65fe9 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -103,14 +103,15 @@ class Tools case 'config': $tpl_file = 'config.twig'; break; + case 'tags': + $tpl_file = 'tags.twig'; + break; case 'view': $tpl_file = 'view.twig'; break; - case 'login': $tpl_file = 'login.twig'; break; - case 'error': $tpl_file = 'error.twig'; break; -- cgit v1.2.3 From 6cab59c3409f4edc9b309b76295cb4061bff3fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 14:03:14 +0100 Subject: [add] edit tags page --- inc/poche/Tools.class.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'inc/poche/Tools.class.php') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 5bb65fe9..9d911699 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -106,6 +106,9 @@ class Tools case 'tags': $tpl_file = 'tags.twig'; break; + case 'edit-tags': + $tpl_file = 'edit-tags.twig'; + break; case 'view': $tpl_file = 'view.twig'; break; -- cgit v1.2.3 From 74ec445a662aa31f713bc50e74c9366da336538a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 14:07:00 +0100 Subject: [change] simplify Tools::getTplFile --- inc/poche/Tools.class.php | 45 +++++++++------------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) (limited to 'inc/poche/Tools.class.php') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 9d911699..b0ef55f5 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -88,43 +88,16 @@ class Tools public static function getTplFile($view) { - $default_tpl = 'home.twig'; - - switch ($view) { - case 'install': - $tpl_file = 'install.twig'; - break; - case 'import'; - $tpl_file = 'import.twig'; - break; - case 'export': - $tpl_file = 'export.twig'; - break; - case 'config': - $tpl_file = 'config.twig'; - break; - case 'tags': - $tpl_file = 'tags.twig'; - break; - case 'edit-tags': - $tpl_file = 'edit-tags.twig'; - break; - case 'view': - $tpl_file = 'view.twig'; - break; - case 'login': - $tpl_file = 'login.twig'; - break; - case 'error': - $tpl_file = 'error.twig'; - break; - - default: - $tpl_file = $default_tpl; - break; + $views = array( + 'install', 'import', 'export', 'config', 'tags', + 'edit-tags', 'view', 'login', 'error' + ); + + if (in_array($view, $views)) { + return $view . '.twig'; } - - return $tpl_file; + + return 'home.twig'; } public static function getFile($url) -- cgit v1.2.3 From 4886ed6d3637df0b3e16e672d58d4ef8f17dc432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 14:22:29 +0100 Subject: [add] page which lists entries for a tag --- inc/poche/Tools.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/poche/Tools.class.php') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index b0ef55f5..6da53023 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -90,7 +90,7 @@ class Tools { $views = array( 'install', 'import', 'export', 'config', 'tags', - 'edit-tags', 'view', 'login', 'error' + 'edit-tags', 'view', 'login', 'error', 'tag' ); if (in_array($view, $views)) { -- cgit v1.2.3 From d460914f65254d201911a8346792d680218c8dc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 12 Dec 2013 09:42:19 +0100 Subject: [add] download database if sqlite is on --- inc/poche/Tools.class.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'inc/poche/Tools.class.php') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 750553f1..9d8e1fd6 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -249,4 +249,28 @@ class Tools $lang = explode('.', $userlanguage); return str_replace('_', '-', $lang[0]); } + + public static function status($status_code) + { + if (strpos(php_sapi_name(), 'apache') !== false) { + + header('HTTP/1.0 '.$status_code); + } + else { + + header('Status: '.$status_code); + } + } + + + public static function download_db() { + header('Content-Disposition: attachment; filename="poche.sqlite.gz"'); + self::status(200); + + header('Content-Transfer-Encoding: binary'); + header('Content-Type: application/octet-stream'); + echo gzencode(file_get_contents(STORAGE_SQLITE)); + + exit; + } } -- cgit v1.2.3