[Phpfreechat-svn] SF.net SVN: phpfreechat: [1070] trunk
Status: Beta
Brought to you by:
kerphi
From: <gpi...@us...> - 2007-08-01 15:59:01
|
Revision: 1070 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1070&view=rev Author: gpinzone Date: 2007-08-01 08:59:02 -0700 (Wed, 01 Aug 2007) Log Message: ----------- Updated log and debug code to use standard file handling functions. Modified Paths: -------------- trunk/debug/console.php trunk/src/pfci18n.class.php trunk/src/proxies/log.class.php Modified: trunk/debug/console.php =================================================================== --- trunk/debug/console.php 2007-08-01 14:37:04 UTC (rev 1069) +++ trunk/debug/console.php 2007-08-01 15:59:02 UTC (rev 1070) @@ -9,13 +9,9 @@ { $filename = dirname(__FILE__)."/../data/private/debug".$section."_".$chatid.".log"; $xml_reponse = new xajaxResponse(); - if (file_exists($filename)) + if (false !== $html = @file_get_contents_flock($filename)) { - $fp = fopen($filename, "r"); - $html = "<pre>"; - $html .= fread($fp, filesize($filename)); - $html .= "</pre>"; - fclose($fp); + $html = "<pre>" . $html . "</pre>"; unlink($filename); $xml_reponse->addAppend("debug".$section, "innerHTML", $html); } Modified: trunk/src/pfci18n.class.php =================================================================== --- trunk/src/pfci18n.class.php 2007-08-01 14:37:04 UTC (rev 1069) +++ trunk/src/pfci18n.class.php 2007-08-01 15:59:02 UTC (rev 1070) @@ -123,11 +123,11 @@ } closedir($dh); $i18n_accepted_lang_str = "array('" . implode("','", $i18n_accepted_lang) . "');"; - $data = file_get_contents(__FILE__); + $data = file_get_contents_flock(__FILE__); $data = preg_replace("/(\/\*<GetAcceptedLanguage>\*\/)(.*)(\/\*<\/GetAcceptedLanguage>\*\/)/", "$1".$i18n_accepted_lang_str."$3", $data); - file_put_contents(__FILE__,$data); + file_put_contents(__FILE__, $data, FILE_EX); // Now scan the source code in order to find "_pfc" patterns $files = array(); @@ -170,7 +170,7 @@ foreach( $dst_filenames as $dst_filename ) { // filter lines to keep, line to add - $old_content = file_get_contents($dst_filename); + $old_content = file_get_contents_flock($dst_filename); // remove php tags to keep only real content $old_content = preg_replace("/^\<\?php/", "", $old_content); $old_content = preg_replace("/\?\>$/", "", $old_content); @@ -187,7 +187,7 @@ $content = "<?php" . $old_content . $new_content . "?>"; //echo $content; - file_put_contents($dst_filename, $content); + file_put_contents($dst_filename, $content, FILE_EX); } } } Modified: trunk/src/proxies/log.class.php =================================================================== --- trunk/src/proxies/log.class.php 2007-08-01 14:37:04 UTC (rev 1069) +++ trunk/src/proxies/log.class.php 2007-08-01 15:59:02 UTC (rev 1070) @@ -51,19 +51,15 @@ if (file_exists($logpath) && is_writable($logpath)) { $logfile = $logpath."/chat.log"; - $f_exists = file_exists($logfile); - if (($f_exists && is_writable($logpath)) || - !$f_exists) + if (is_writable($logpath)) { - $fp = fopen($logfile, $f_exists ? 'a' : 'w'); // @todo write logs in a cleaner structured language (xml, html ... ?) $log = $recipient."\t"; $log .= date("d/m/Y")."\t"; $log .= date("H:i:s")."\t"; $log .= $sender."\t"; $log .= $param."\n"; - fwrite($fp, $log); - fclose($fp); + file_put_contents($logfile, $log, FILE_APPEND); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |