PageRenderTime 24ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/SyntaxTree/phpsyntaxtree_src/src/log.php

https://github.com/prometoys/fourtree
PHP | 62 lines | 31 code | 11 blank | 20 comment | 2 complexity | f05efbe1bd9cce8d4d5028422b1cab73 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. // log.php - Log helper functions
  3. // Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
  4. //
  5. // log.php is part of phpSyntaxTree.
  6. //
  7. // This program is free software; you can redistribute it and/or modify
  8. // it under the terms of the GNU General Public License as published by
  9. // the Free Software Foundation; either version 2 of the License, or
  10. // (at your option) any later version.
  11. //
  12. // This program is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. // GNU General Public License for more details.
  16. //
  17. // You should have received a copy of the GNU General Public License
  18. // along with this program; if not, write to the Free Software
  19. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. //
  21. // $Id: log.php,v 1.3 2005/08/22 23:35:48 int2str Exp $
  22. define( 'LOG_PHRASE_FNAME', "var/phpst.log" );
  23. define( 'LOG_LANG_FNAME', "var/lang.log" );
  24. function LogPhrase( $phrase )
  25. {
  26. $fh = @fopen( LOG_PHRASE_FNAME, "a" );
  27. if ( $fh )
  28. {
  29. $ip = isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : 'unknown';
  30. $date = date( "Y-m-d H:i" );
  31. $phrase = trim( $phrase );
  32. $phrase = str_replace( "\n", "", $phrase );
  33. $phrase = str_replace( "\r", "", $phrase );
  34. $msg = sprintf( "%s %s - %s\n", $date, $ip, $phrase );
  35. fwrite( $fh, $msg );
  36. fclose( $fh );
  37. }
  38. }
  39. function LogLangSettings()
  40. {
  41. $fh = @fopen( LOG_LANG_FNAME, "a" );
  42. if ( $fh )
  43. {
  44. $a_lang = isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : 'unknown';
  45. $a_char = isset( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ? $_SERVER['HTTP_ACCEPT_CHARSET'] : 'unknown';
  46. $msg = sprintf( "%s %s\n", $a_lang, $a_char );
  47. fwrite( $fh, $msg );
  48. fclose( $fh );
  49. }
  50. }
  51. ?>