aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Tools.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/poche/Tools.class.php')
-rw-r--r--inc/poche/Tools.class.php56
1 files changed, 55 insertions, 1 deletions
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
193 193
194 public static function logm($message) 194 public static function logm($message)
195 { 195 {
196 if (DEBUG_POCHE) { 196 if (DEBUG_POCHE && php_sapi_name() != 'cli') {
197 $t = strval(date('Y/m/d_H:i:s')) . ' - ' . $_SERVER["REMOTE_ADDR"] . ' - ' . strval($message) . "\n"; 197 $t = strval(date('Y/m/d_H:i:s')) . ' - ' . $_SERVER["REMOTE_ADDR"] . ' - ' . strval($message) . "\n";
198 file_put_contents(CACHE . '/log.txt', $t, FILE_APPEND); 198 file_put_contents(CACHE . '/log.txt', $t, FILE_APPEND);
199 error_log('DEBUG POCHE : ' . $message); 199 error_log('DEBUG POCHE : ' . $message);
@@ -251,4 +251,58 @@ class Tools
251 251
252 exit; 252 exit;
253 } 253 }
254
255 public static function getPageContent(Url $url)
256 {
257 // Saving and clearing context
258 $REAL = array();
259 foreach( $GLOBALS as $key => $value ) {
260 if( $key != 'GLOBALS' && $key != '_SESSION' && $key != 'HTTP_SESSION_VARS' ) {
261 $GLOBALS[$key] = array();
262 $REAL[$key] = $value;
263 }
264 }
265 // Saving and clearing session
266 $REAL_SESSION = array();
267 foreach( $_SESSION as $key => $value ) {
268 $REAL_SESSION[$key] = $value;
269 unset($_SESSION[$key]);
270 }
271
272 // Running code in different context
273 $scope = function() {
274 extract( func_get_arg(1) );
275 $_GET = $_REQUEST = array(
276 "url" => $url->getUrl(),
277 "max" => 5,
278 "links" => "preserve",
279 "exc" => "",
280 "format" => "json",
281 "submit" => "Create Feed"
282 );
283 ob_start();
284 require func_get_arg(0);
285 $json = ob_get_flush();
286 return $json;
287 };
288 $json = $scope( "inc/3rdparty/makefulltextfeed.php", array("url" => $url) );
289
290 // Clearing and restoring context
291 foreach( $GLOBALS as $key => $value ) {
292 if( $key != "GLOBALS" && $key != "_SESSION" ) {
293 unset($GLOBALS[$key]);
294 }
295 }
296 foreach( $REAL as $key => $value ) {
297 $GLOBALS[$key] = $value;
298 }
299 // Clearing and restoring session
300 foreach( $_SESSION as $key => $value ) {
301 unset($_SESSION[$key]);
302 }
303 foreach( $REAL_SESSION as $key => $value ) {
304 $_SESSION[$key] = $value;
305 }
306 return json_decode($json, true);
307 }
254} 308}