From 31a10069a52c2fd2aca3a835a7bdc1accae197f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 28 Feb 2014 20:36:32 +0100 Subject: [add] upload form for import --- inc/poche/Tools.class.php | 1 - 1 file changed, 1 deletion(-) (limited to 'inc/poche/Tools.class.php') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 4ed28ed1..eed7afbd 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -241,7 +241,6 @@ class Tools } } - public static function download_db() { header('Content-Disposition: attachment; filename="poche.sqlite.gz"'); self::status(200); -- cgit v1.2.3 From 53e3158dfe697ea59da1fa0e401e8da75ae13030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 28 Feb 2014 21:49:38 +0100 Subject: [add] cron to fetch content on imported entries --- inc/poche/Tools.class.php | 56 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 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 eed7afbd..393a415d 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -193,7 +193,7 @@ class Tools public static function logm($message) { - if (DEBUG_POCHE) { + if (DEBUG_POCHE && php_sapi_name() != 'cli') { $t = strval(date('Y/m/d_H:i:s')) . ' - ' . $_SERVER["REMOTE_ADDR"] . ' - ' . strval($message) . "\n"; file_put_contents(CACHE . '/log.txt', $t, FILE_APPEND); error_log('DEBUG POCHE : ' . $message); @@ -251,4 +251,58 @@ class Tools exit; } + + public static function getPageContent(Url $url) + { + // Saving and clearing context + $REAL = array(); + foreach( $GLOBALS as $key => $value ) { + if( $key != 'GLOBALS' && $key != '_SESSION' && $key != 'HTTP_SESSION_VARS' ) { + $GLOBALS[$key] = array(); + $REAL[$key] = $value; + } + } + // Saving and clearing session + $REAL_SESSION = array(); + foreach( $_SESSION as $key => $value ) { + $REAL_SESSION[$key] = $value; + unset($_SESSION[$key]); + } + + // Running code in different context + $scope = function() { + extract( func_get_arg(1) ); + $_GET = $_REQUEST = array( + "url" => $url->getUrl(), + "max" => 5, + "links" => "preserve", + "exc" => "", + "format" => "json", + "submit" => "Create Feed" + ); + ob_start(); + require func_get_arg(0); + $json = ob_get_flush(); + return $json; + }; + $json = $scope( "inc/3rdparty/makefulltextfeed.php", array("url" => $url) ); + + // Clearing and restoring context + foreach( $GLOBALS as $key => $value ) { + if( $key != "GLOBALS" && $key != "_SESSION" ) { + unset($GLOBALS[$key]); + } + } + foreach( $REAL as $key => $value ) { + $GLOBALS[$key] = $value; + } + // Clearing and restoring session + foreach( $_SESSION as $key => $value ) { + unset($_SESSION[$key]); + } + foreach( $REAL_SESSION as $key => $value ) { + $_SESSION[$key] = $value; + } + return json_decode($json, true); + } } -- cgit v1.2.3 From f98373cc34f1826ba93fd93ae7f291726af1f933 Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Fri, 7 Mar 2014 12:54:08 +0200 Subject: getPageContent moved to Tools, fix of #426 --- inc/poche/Tools.class.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'inc/poche/Tools.class.php') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 393a415d..eeb101b4 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -263,10 +263,12 @@ class Tools } } // Saving and clearing session - $REAL_SESSION = array(); - foreach( $_SESSION as $key => $value ) { - $REAL_SESSION[$key] = $value; - unset($_SESSION[$key]); + if ( isset($_SESSION) ) { + $REAL_SESSION = array(); + foreach( $_SESSION as $key => $value ) { + $REAL_SESSION[$key] = $value; + unset($_SESSION[$key]); + } } // Running code in different context @@ -282,7 +284,8 @@ class Tools ); ob_start(); require func_get_arg(0); - $json = ob_get_flush(); + $json = ob_get_contents(); + ob_end_clean(); return $json; }; $json = $scope( "inc/3rdparty/makefulltextfeed.php", array("url" => $url) ); @@ -297,12 +300,15 @@ class Tools $GLOBALS[$key] = $value; } // Clearing and restoring session - foreach( $_SESSION as $key => $value ) { - unset($_SESSION[$key]); - } - foreach( $REAL_SESSION as $key => $value ) { - $_SESSION[$key] = $value; + if ( isset($REAL_SESSION) ) { + foreach( $_SESSION as $key => $value ) { + unset($_SESSION[$key]); + } + foreach( $REAL_SESSION as $key => $value ) { + $_SESSION[$key] = $value; + } } + return json_decode($json, true); } } -- cgit v1.2.3 From fb26cc9375ce9ef8df748eb473eb6e58884421c6 Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Mon, 10 Mar 2014 16:28:47 +0200 Subject: a lot of enhancements related to tags: tags list is now sorted, shows number of articles, autocomplete added according to #477, #542 --- inc/poche/Tools.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) mode change 100644 => 100755 inc/poche/Tools.class.php (limited to 'inc/poche/Tools.class.php') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php old mode 100644 new mode 100755 index eeb101b4..ad451fc6 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -311,4 +311,14 @@ class Tools return json_decode($json, true); } + + /** + * Returns whether we handle an AJAX (XMLHttpRequest) request. + * @return boolean whether we handle an AJAX (XMLHttpRequest) request. + */ + public static function isAjaxRequest() + { + return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest'; + } + } -- cgit v1.2.3 From 182faf2696b38502d4784efc3f84f2f00290343f Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Wed, 2 Apr 2014 20:55:19 +0300 Subject: import without cron --- inc/poche/Tools.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'inc/poche/Tools.class.php') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index ad451fc6..a130e94b 100755 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -7,7 +7,7 @@ * @copyright 2013 * @license http://www.wtfpl.net/ see COPYING file */ - + class Tools { public static function initPhp() @@ -42,7 +42,7 @@ class Tools && (strtolower($_SERVER['HTTPS']) == 'on')) || (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] == '443') // HTTPS detection. - || (isset($_SERVER["SERVER_PORT"]) //Custom HTTPS port detection + || (isset($_SERVER["SERVER_PORT"]) //Custom HTTPS port detection && $_SERVER["SERVER_PORT"] == SSL_PORT) || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'); @@ -148,7 +148,7 @@ class Tools ); # only download page lesser than 4MB - $data = @file_get_contents($url, false, $context, -1, 4000000); + $data = @file_get_contents($url, false, $context, -1, 4000000); if (isset($http_response_header) and isset($http_response_header[0])) { $httpcodeOK = isset($http_response_header) and isset($http_response_header[0]) and ((strpos($http_response_header[0], '200 OK') !== FALSE) or (strpos($http_response_header[0], '301 Moved Permanently') !== FALSE)); @@ -200,7 +200,7 @@ class Tools } } - public static function encodeString($string) + public static function encodeString($string) { return sha1($string . SALT); } -- cgit v1.2.3