]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
fonction logm() ajoutée (from shaarli)
authornicosomb <nicolas@loeuillet.org>
Wed, 17 Apr 2013 11:38:12 +0000 (13:38 +0200)
committernicosomb <nicolas@loeuillet.org>
Wed, 17 Apr 2013 11:38:12 +0000 (13:38 +0200)
import.php
inc/functions.php
view.php

index 7a657c21b0f6760190ba1812c67fed4c6a87eaf4..97072437cbeff601a57b9dbda7c16639d5ee5a6e 100644 (file)
@@ -42,7 +42,7 @@ else {
             }
             catch (Exception $e)
             {
-                $errors[] = $e->getMessage();
+                logm('error during pocket import : ' . $e->getMessage());
             }
         }
         # Pocket génère un fichier HTML avec deux <ul>
@@ -52,4 +52,5 @@ else {
     }
 
     echo 'Import from Pocket completed. <a href="index.php">Welcome to #poche !</a>';
+    logm('import from pocket completed');
 }
\ No newline at end of file
index 464410cb56d6f7f5b819996a4dfc250ce08776e3..1b8db08486e4bf4a60cd2cfd04dc604f1bfb9375 100755 (executable)
@@ -52,7 +52,6 @@ function get_external_file($url, $timeout)
 
         // only download page lesser than 4MB
         $data = @file_get_contents($url, false, $context, -1, 4000000); // We download at most 4 MB from source.
-        //  echo "<pre>http_response_header : ".print_r($http_response_header);
 
         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));
@@ -144,21 +143,21 @@ function action_to_do($action, $id, $url, $token)
                 $sql_action     = "DELETE FROM entries WHERE id=?";
                 $params_action  = array($id);
             }
-            else die('CSRF problem');
+            else logm('csrf problem while deleting entry');
             break;
         case 'toggle_fav' :
             if (verif_token($token)) {
                 $sql_action     = "UPDATE entries SET is_fav=~is_fav WHERE id=?";
                 $params_action  = array($id);
             }
-            else die('CSRF problem');
+            else logm('csrf problem while fav entry');
             break;
         case 'toggle_archive' :
             if (verif_token($token)) {
                 $sql_action     = "UPDATE entries SET is_read=~is_read WHERE id=?";
                 $params_action  = array($id);
             }
-            else die('CSRF problem');
+            else logm('csrf problem while archive entry');
             break;
         default:
             break;
@@ -175,7 +174,7 @@ function action_to_do($action, $id, $url, $token)
     }
     catch (Exception $e)
     {
-        die('action query error : '.$e->getMessage());
+        logm('action query error : '.$e->getMessage());
     }
 }
 
@@ -230,7 +229,7 @@ function display_view($view)
     }
     catch (Exception $e)
     {
-        die('view query error : '.$e->getMessage());
+        logm('view query error : '.$e->getMessage());
     }
 
     return $entries;
@@ -256,7 +255,7 @@ function get_article($id)
     }
     catch (Exception $e)
     {
-        die('query error : '.$e->getMessage());
+        logm('get article query error : '.$e->getMessage());
     }
 
     return $entry;
@@ -278,9 +277,22 @@ function verif_token($token)
             }
             else {
                 session_destroy();
+                logm('session expired');
             }
         }
-        else return FALSE;
+        else {
+            logm('token error : the token is different');
+            return FALSE;
+        }
+    }
+    else {
+        logm('token error : the token is not here');
+        return FALSE;
     }
-    else return FALSE;
+}
+
+function logm($message)
+{
+    $t = strval(date('Y/m/d_H:i:s')).' - '.$_SERVER["REMOTE_ADDR"].' - '.strval($message)."\n";
+    file_put_contents($GLOBALS['config']['DATADIR'].'/log.txt',$t,FILE_APPEND);
 }
\ No newline at end of file
index dbafec6bcd8d5bdca99ba8e17aed3eac291bbbb8..9ba6f62dab7049e5f83290b885c42329efcda129 100755 (executable)
--- a/view.php
+++ b/view.php
@@ -28,9 +28,9 @@ if(!empty($id)) {
         $tpl->draw('view');
     }
     else {
-        die('error in view call');
+        logm('error in view call : entry is NULL');
     }
 }
 else {
-    die('error in view call');
+    logm('error in view call : id is empty');
 }
\ No newline at end of file