Генератор паролей

AddMessage2Log на php

function AddMessage2Log( $sText, $sModule = "" ){  
  if ( defined( "LOG_FILENAME" ) && strlen( LOG_FILENAME ) > 0 ) {
    if(is_array($sText)){
        $sText = print_r($sText, true);
    }
    if ( strlen( $sText ) > 0 ) {
      ignore_user_abort( true );
      if ( $fp = @fopen( LOG_FILENAME, "ab+" ) ) {
        if ( flock( $fp, LOCK_EX ) ) {
          @fwrite( $fp, date( "Y-m-d H:i:s" ) . " - " . $sModule . " - " . $sText . "\n" );
          if ( function_exists( "debug_backtrace" ) ) {
            $arBacktrace      = debug_backtrace();
            $strFunctionStack = "";
            $iterationsCount  = min( count( $arBacktrace ), 4 );
            for ( $i = 1; $i < $iterationsCount; $i++ ) {
              if ( strlen( $strFunctionStack ) > 0 ) {
                $strFunctionStack .= " < ";
              }
              if ( strlen( $arBacktrace[ $i ][ "class" ] ) > 0 ) {
                $strFunctionStack .= $arBacktrace[ $i ][ "class" ] . "::";
              }
              $strFunctionStack .= $arBacktrace[ $i ][ "function" ];
            }
            if ( strlen( $strFunctionStack ) > 0 ) {
              @fwrite( $fp, "    " . $strFunctionStack . "\n" );
            }
          }
          @fwrite( $fp, "----------\n" );
          @fflush( $fp );
          @flock( $fp, LOCK_UN );
          @fclose( $fp );
        }
      }
      ignore_user_abort( false );
    }
  }
}

define("LOG_FILENAME", $_SERVER["DOCUMENT_ROOT"]."/log.txt");
AddMessage2Log($data); //string or array