PHP a safe and fast log writing function

From , 2 Years ago, written in PHP, viewed 250 times.
URL https://pastebin.vip/view/f44ee263
  1. <?php
  2.  
  3. /**
  4.  * 直接记录日志
  5.  * @param <type> $lvevel
  6.  * @param string $level
  7.  *  http://www.phpqee.com
  8.  */
  9. function Write($msg, $level) {
  10.     $arr_level = explode(',', YUC_LOG_TYPE);
  11.     if (in_array($level, $arr_level)) {
  12.         $record = date('Y-m-d H:m:s') . " >>> " . number_format(microtime(TRUE), 5, ".", "") . ' ' . " : " . $level . "\\t" . $msg;
  13.         $base = M_PRO_DIR . "/Log";
  14.         $dest = $base . "/" . date("YmdH", time()) . 'log.php';
  15.         if (!file_exists($dest)) {
  16.             @mkdir($base, 0777, TRUE);
  17.             @file_put_contents($dest, "<?php die('Access Defined!');?>\\r\\n", FILE_APPEND);
  18.         }
  19.         if (file_exists($dest)) {
  20.             @file_put_contents($dest, $record . "\\r\\n", FILE_APPEND);
  21.         }
  22.     }
  23. }
  24. //该片段来自于http://yuncode.net
  25.  

Reply to "PHP a safe and fast log writing function"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website