diff options
author | nicosomb <nicolas@loeuillet.org> | 2013-04-17 13:38:12 +0200 |
---|---|---|
committer | nicosomb <nicolas@loeuillet.org> | 2013-04-17 13:38:12 +0200 |
commit | 713b2d69910c1221bc86992ca08d6036d2e71bb6 (patch) | |
tree | 5148927575440e1955a753a1ac19a05008717e5e /inc | |
parent | 0753bfefd7444712a20cee28fdb057e48602b2eb (diff) | |
download | wallabag-713b2d69910c1221bc86992ca08d6036d2e71bb6.tar.gz wallabag-713b2d69910c1221bc86992ca08d6036d2e71bb6.tar.zst wallabag-713b2d69910c1221bc86992ca08d6036d2e71bb6.zip |
fonction logm() ajoutée (from shaarli)
Diffstat (limited to 'inc')
-rwxr-xr-x | inc/functions.php | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/inc/functions.php b/inc/functions.php index 464410cb..1b8db084 100755 --- a/inc/functions.php +++ b/inc/functions.php | |||
@@ -52,7 +52,6 @@ function get_external_file($url, $timeout) | |||
52 | 52 | ||
53 | // only download page lesser than 4MB | 53 | // only download page lesser than 4MB |
54 | $data = @file_get_contents($url, false, $context, -1, 4000000); // We download at most 4 MB from source. | 54 | $data = @file_get_contents($url, false, $context, -1, 4000000); // We download at most 4 MB from source. |
55 | // echo "<pre>http_response_header : ".print_r($http_response_header); | ||
56 | 55 | ||
57 | if(isset($http_response_header) and isset($http_response_header[0])) { | 56 | if(isset($http_response_header) and isset($http_response_header[0])) { |
58 | $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)); | 57 | $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) | |||
144 | $sql_action = "DELETE FROM entries WHERE id=?"; | 143 | $sql_action = "DELETE FROM entries WHERE id=?"; |
145 | $params_action = array($id); | 144 | $params_action = array($id); |
146 | } | 145 | } |
147 | else die('CSRF problem'); | 146 | else logm('csrf problem while deleting entry'); |
148 | break; | 147 | break; |
149 | case 'toggle_fav' : | 148 | case 'toggle_fav' : |
150 | if (verif_token($token)) { | 149 | if (verif_token($token)) { |
151 | $sql_action = "UPDATE entries SET is_fav=~is_fav WHERE id=?"; | 150 | $sql_action = "UPDATE entries SET is_fav=~is_fav WHERE id=?"; |
152 | $params_action = array($id); | 151 | $params_action = array($id); |
153 | } | 152 | } |
154 | else die('CSRF problem'); | 153 | else logm('csrf problem while fav entry'); |
155 | break; | 154 | break; |
156 | case 'toggle_archive' : | 155 | case 'toggle_archive' : |
157 | if (verif_token($token)) { | 156 | if (verif_token($token)) { |
158 | $sql_action = "UPDATE entries SET is_read=~is_read WHERE id=?"; | 157 | $sql_action = "UPDATE entries SET is_read=~is_read WHERE id=?"; |
159 | $params_action = array($id); | 158 | $params_action = array($id); |
160 | } | 159 | } |
161 | else die('CSRF problem'); | 160 | else logm('csrf problem while archive entry'); |
162 | break; | 161 | break; |
163 | default: | 162 | default: |
164 | break; | 163 | break; |
@@ -175,7 +174,7 @@ function action_to_do($action, $id, $url, $token) | |||
175 | } | 174 | } |
176 | catch (Exception $e) | 175 | catch (Exception $e) |
177 | { | 176 | { |
178 | die('action query error : '.$e->getMessage()); | 177 | logm('action query error : '.$e->getMessage()); |
179 | } | 178 | } |
180 | } | 179 | } |
181 | 180 | ||
@@ -230,7 +229,7 @@ function display_view($view) | |||
230 | } | 229 | } |
231 | catch (Exception $e) | 230 | catch (Exception $e) |
232 | { | 231 | { |
233 | die('view query error : '.$e->getMessage()); | 232 | logm('view query error : '.$e->getMessage()); |
234 | } | 233 | } |
235 | 234 | ||
236 | return $entries; | 235 | return $entries; |
@@ -256,7 +255,7 @@ function get_article($id) | |||
256 | } | 255 | } |
257 | catch (Exception $e) | 256 | catch (Exception $e) |
258 | { | 257 | { |
259 | die('query error : '.$e->getMessage()); | 258 | logm('get article query error : '.$e->getMessage()); |
260 | } | 259 | } |
261 | 260 | ||
262 | return $entry; | 261 | return $entry; |
@@ -278,9 +277,22 @@ function verif_token($token) | |||
278 | } | 277 | } |
279 | else { | 278 | else { |
280 | session_destroy(); | 279 | session_destroy(); |
280 | logm('session expired'); | ||
281 | } | 281 | } |
282 | } | 282 | } |
283 | else return FALSE; | 283 | else { |
284 | logm('token error : the token is different'); | ||
285 | return FALSE; | ||
286 | } | ||
287 | } | ||
288 | else { | ||
289 | logm('token error : the token is not here'); | ||
290 | return FALSE; | ||
284 | } | 291 | } |
285 | else return FALSE; | 292 | } |
293 | |||
294 | function logm($message) | ||
295 | { | ||
296 | $t = strval(date('Y/m/d_H:i:s')).' - '.$_SERVER["REMOTE_ADDR"].' - '.strval($message)."\n"; | ||
297 | file_put_contents($GLOBALS['config']['DATADIR'].'/log.txt',$t,FILE_APPEND); | ||
286 | } \ No newline at end of file | 298 | } \ No newline at end of file |