Last active
January 5, 2022 06:42
-
-
Save silverfoxy/780995e3553b8059eb73ca29a6cb2df5 to your computer and use it in GitHub Desktop.
Extended logs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // gather_logs(); | |
| function gather_logs() { | |
| if (!isset($_SESSION)) { session_start(); } | |
| $session_keys = array_keys($_SESSION); | |
| $session = []; | |
| foreach ($session_keys as $key) { | |
| $session[$key] = "dummy"; | |
| } | |
| $cookie_keys = array_keys($_COOKIE); | |
| $cookie = []; | |
| foreach ($cookie_keys as $key) { | |
| $cookie[$key] = "dummy"; | |
| } | |
| $post_keys = array_keys($_POST); | |
| $post = []; | |
| foreach ($post_keys as $key) { | |
| $post[$key] = "dummy"; | |
| } | |
| $files_keys = array_keys($_FILES); | |
| $files = []; | |
| foreach ($files_keys as $key) { | |
| $files[$key] = "dummy"; | |
| } | |
| $log_line = ['request_method'=>$_SERVER['REQUEST_METHOD'], | |
| 'request_uri'=>$_SERVER['REQUEST_URI'], | |
| 'script_filename'=>$_SERVER['SCRIPT_FILENAME'], | |
| 'session'=>$session, | |
| 'cookie'=>$cookie, | |
| 'get'=>$_GET, | |
| 'post'=>$post, | |
| 'files'=>$files]; | |
| file_put_contents('/var/www/html/log.txt', serialize($log_line).PHP_EOL, FILE_APPEND); | |
| file_put_contents('/var/www/html/log.txt', '----'.PHP_EOL, FILE_APPEND); | |
| } | |
| register_shutdown_function('gather_logs'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment