]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - inc/poche/Tools.class.php
travis
[github/wallabag/wallabag.git] / inc / poche / Tools.class.php
index c277035febdcb0b972d8c69f880a37b4141c3663..d0e431663dcf5f9dc07aa1e904edf78bfe789cb7 100644 (file)
@@ -77,6 +77,7 @@ class Tools
                 $url = $ref;
             }
         }
+        self::logm('redirect to ' . $url);
         header('Location: '.$url);
         exit();
     }
@@ -197,7 +198,8 @@ class Tools
     {
         if (DEBUG_POCHE) {
             $t = strval(date('Y/m/d_H:i:s')) . ' - ' . $_SERVER["REMOTE_ADDR"] . ' - ' . strval($message) . "\n";
-            file_put_contents('./log.txt', $t, FILE_APPEND);
+            file_put_contents(CACHE . '/log.txt', $t, FILE_APPEND);
+            error_log('DEBUG POCHE : ' . $message);
         }
     }
 
@@ -205,4 +207,20 @@ class Tools
     {
         return sha1($string . SALT);
     }
+
+    public static function checkVar($var, $default = '')
+    {
+        return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : $default);
+    }
+
+    public static function getDomain($url)
+    {
+      $pieces = parse_url($url);
+      $domain = isset($pieces['host']) ? $pieces['host'] : '';
+      if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
+        return $regs['domain'];
+      }
+      
+      return FALSE;
+    }
 }
\ No newline at end of file