Thread: [Phpfreechat-svn] SF.net SVN: phpfreechat: [622] trunk/src/pfctools.php
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-06-24 20:05:56
|
Revision: 622 Author: kerphi Date: 2006-06-24 13:05:49 -0700 (Sat, 24 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=622&view=rev Log Message: ----------- by default the copy_r function must give 644 rights to files Modified Paths: -------------- trunk/src/pfctools.php Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2006-06-17 20:22:04 UTC (rev 621) +++ trunk/src/pfctools.php 2006-06-24 20:05:49 UTC (rev 622) @@ -103,7 +103,7 @@ } -function mkdir_r($path, $mode = 0700) +function mkdir_r($path, $modedir = 0700) { // This function creates the specified directory using mkdir(). Note // that the recursive feature on mkdir() is broken with PHP 5.0.4 for @@ -112,8 +112,8 @@ { // The directory doesn't exist. Recurse, passing in the parent // directory so that it gets created. - mkdir_r(dirname($path), $mode); - mkdir($path, $mode); + mkdir_r(dirname($path), $modedir); + mkdir($path, $modedir); } } @@ -137,18 +137,18 @@ * @param string $dest Destination path * @return bool Returns TRUE on success, FALSE on failure */ -function copy_r($source, $dest, $mode = 0700) +function copy_r($source, $dest, $modedir = 0700, $modefile = 0644) { // Simple copy for a file if (is_file($source)) { $ret = copy($source, $dest); - chmod($dest, $mode); + chmod($dest, $modefile); return $ret; } // Make destination directory if (!is_dir($dest)) { - mkdir($dest, $mode); + mkdir($dest, $modedir); } // Take the directories entries @@ -166,7 +166,7 @@ if ($e == '.' || $e == '..' || $e == '.svn') continue; // Deep copy directories if ($dest !== $source . DIRECTORY_SEPARATOR . $e) - copy_r($source . DIRECTORY_SEPARATOR . $e, $dest . DIRECTORY_SEPARATOR . $e, $mode); + copy_r($source . DIRECTORY_SEPARATOR . $e, $dest . DIRECTORY_SEPARATOR . $e, $modedir, $modefile); } // Clean up This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-07-03 13:21:03
|
Revision: 638 Author: kerphi Date: 2006-07-03 06:20:40 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=638&view=rev Log Message: ----------- typo Modified Paths: -------------- trunk/src/pfctools.php Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2006-07-03 13:17:20 UTC (rev 637) +++ trunk/src/pfctools.php 2006-07-03 13:20:40 UTC (rev 638) @@ -119,14 +119,13 @@ function rm_r($dir) { - $dir = realpath($dir); if(!$dh = @opendir($dir)) return; while (($obj = readdir($dh))) { if($obj=='.' || $obj=='..') continue; if (!@unlink($dir.'/'.$obj)) rm_r($dir.'/'.$obj); } - rmdir($dir); + @rmdir($dir); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-07-17 14:57:14
|
Revision: 657 Author: kerphi Date: 2006-07-17 07:57:01 -0700 (Mon, 17 Jul 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=657&view=rev Log Message: ----------- Bug fix: some paths were wrongly calculated (https://sourceforge.net/support/tracker.php?aid=1523821) Modified Paths: -------------- trunk/src/pfctools.php Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2006-07-17 14:20:51 UTC (rev 656) +++ trunk/src/pfctools.php 2006-07-17 14:57:01 UTC (rev 657) @@ -64,14 +64,20 @@ $res = ""; //echo $p1."<br>"; //echo $p2."<br>"; - while( $p1 != "" && $p1 != "/" && strpos($p2, $p1) === FALSE) + while( $p1 != "" && $p1 != "/" && strpos($p2, $p1) !== 0) { $res .= "../"; $p1 = dirname($p1); } - $p2 = (isset($_SERVER["WINDIR"]) || isset($_SERVER["windir"])) ? - str_replace("\\","/",substr($p2, strlen($p1)+1, strlen($p2)-strlen($p1))) : - substr($p2, strlen($p1)+1, strlen($p2)-strlen($p1)); + if (isset($_SERVER["WINDIR"]) || isset($_SERVER["windir"])) { + $p2 = str_replace("\\","/",substr($p2, strlen($p1)+1, strlen($p2)-strlen($p1))); + } else { + if ($p1 === "/" || $p1 === "") { + $p2 = substr($p2, strlen($p1)); + } else { + $p2 = substr($p2, strlen($p1)+1); + } + } $res .= $p2; // remove the last "/" if (preg_match("/.*\/$/", $res)) $res = preg_replace("/(.*)\//","$1",$res); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-08-25 15:19:56
|
Revision: 699 Author: kerphi Date: 2006-08-25 08:19:51 -0700 (Fri, 25 Aug 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=699&view=rev Log Message: ----------- [en] Bug fix: fix an infinit loop on windows platform when calculating relative path. [fr] Bug fix?\194?\160: r?\195?\169soud une boucle infinie sous windows lorsque je calculais les chemins relatifs. Modified Paths: -------------- trunk/src/pfctools.php Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2006-08-23 16:36:49 UTC (rev 698) +++ trunk/src/pfctools.php 2006-08-25 15:19:51 UTC (rev 699) @@ -64,7 +64,10 @@ $res = ""; //echo $p1."<br>"; //echo $p2."<br>"; - while( $p1 != "" && $p1 != "/" && strpos($p2, $p1) !== 0) + while( $p1 != "" && + $p1 != "/" && // for unix root dir + !preg_match("/[a-z]\:\\\/i",$p1) && // for windows rootdir + strpos($p2, $p1) !== 0) { $res .= "../"; $p1 = dirname($p1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-04-01 13:10:17
|
Revision: 1014 http://svn.sourceforge.net/phpfreechat/?rev=1014&view=rev Author: kerphi Date: 2007-04-01 06:10:16 -0700 (Sun, 01 Apr 2007) Log Message: ----------- simplify the lock process Modified Paths: -------------- trunk/src/pfctools.php Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2007-04-01 13:06:42 UTC (rev 1013) +++ trunk/src/pfctools.php 2007-04-01 13:10:16 UTC (rev 1014) @@ -418,7 +418,7 @@ if( $fp && flock( $fp, LOCK_SH ) ) { $data = fread( $fp, $size ); - flock($fp, LOCK_UN); + // flock($fp, LOCK_UN); // will be done by fclose } fclose( $fp ); return $data; @@ -433,7 +433,7 @@ if( $fp && flock( $fp, LOCK_EX ) ) { fwrite( $fp, $data ); - flock($fp, LOCK_UN); + // flock($fp, LOCK_UN); // will be done by fclose } fclose( $fp ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-04-25 07:42:53
|
Revision: 1022 http://svn.sourceforge.net/phpfreechat/?rev=1022&view=rev Author: kerphi Date: 2007-04-25 00:42:44 -0700 (Wed, 25 Apr 2007) Log Message: ----------- try to fix http://www.phpfreechat.net/forum/viewtopic.php?pid=5844#p5844 Modified Paths: -------------- trunk/src/pfctools.php Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2007-04-18 15:30:04 UTC (rev 1021) +++ trunk/src/pfctools.php 2007-04-25 07:42:44 UTC (rev 1022) @@ -430,13 +430,15 @@ function flock_put_contents($filename, $data, $mode = "wb") { $fp = fopen( $filename, $mode ); - if( $fp && flock( $fp, LOCK_EX ) ) + if( $fp ) { - fwrite( $fp, $data ); - // flock($fp, LOCK_UN); // will be done by fclose + if ( flock( $fp, LOCK_EX ) ) + { + fwrite( $fp, $data ); + // flock($fp, LOCK_UN); // will be done by fclose + } + fclose( $fp ); } - fclose( $fp ); } - -?> +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-07-30 10:27:44
|
Revision: 1058 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1058&view=rev Author: kerphi Date: 2007-07-30 03:27:45 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Bug fix: sometimes the messages ids are corrupted (thanks to Gerard Pinzone, sf patch 1762864) Modified Paths: -------------- trunk/src/pfctools.php Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2007-07-27 07:30:58 UTC (rev 1057) +++ trunk/src/pfctools.php 2007-07-30 10:27:45 UTC (rev 1058) @@ -411,13 +411,13 @@ $data = ''; if (!file_exists($filename)) return $data; - $size = filesize($filename); - if ($size == 0) return $data; - $fp = fopen( $filename, $mode ); if( $fp && flock( $fp, LOCK_SH ) ) { - $data = fread( $fp, $size ); + clearstatcache(); + $size = filesize($filename); + if ($size > 0) + $data = fread( $fp, $size ); // flock($fp, LOCK_UN); // will be done by fclose } fclose( $fp ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-07-30 12:30:24
|
Revision: 1060 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1060&view=rev Author: kerphi Date: 2007-07-30 05:30:22 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Remove useless instruction Modified Paths: -------------- trunk/src/pfctools.php Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2007-07-30 10:36:58 UTC (rev 1059) +++ trunk/src/pfctools.php 2007-07-30 12:30:22 UTC (rev 1060) @@ -409,9 +409,7 @@ function flock_get_contents($filename, $mode = "rb") { $data = ''; - if (!file_exists($filename)) return $data; - - $fp = fopen( $filename, $mode ); + $fp = fopen( $filename, $mode ); if( $fp && flock( $fp, LOCK_SH ) ) { clearstatcache(); @@ -441,4 +439,4 @@ } } -?> \ No newline at end of file +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gpi...@us...> - 2007-08-24 00:08:51
|
Revision: 1143 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1143&view=rev Author: gpinzone Date: 2007-08-23 17:08:49 -0700 (Thu, 23 Aug 2007) Log Message: ----------- Replaced the html_entity_decode for PHP <4.3.0 with the implementation from PHP_Compat. Modified Paths: -------------- trunk/src/pfctools.php Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2007-08-23 21:02:56 UTC (rev 1142) +++ trunk/src/pfctools.php 2007-08-24 00:08:49 UTC (rev 1143) @@ -438,19 +438,52 @@ } /** - * html_entity_decode - * For users prior to PHP 4.3.0 + * Replace html_entity_decode() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.html_entity_decode + * @author David Irvine <da...@co...> + * @author Aidan Lister <ai...@ph...> + * @version $Revision: 1.8 $ + * @since PHP 4.3.0 + * @internal Setting the charset will not do anything + * @require PHP 4.0.0 (user_error) */ -if (!function_exists('html_entity_decode')) -{ - function html_entity_decode($string) + +if (!defined('ENT_NOQUOTES')) { + define('ENT_NOQUOTES', 0); +} + +if (!defined('ENT_COMPAT')) { + define('ENT_COMPAT', 2); +} + +if (!defined('ENT_QUOTES')) { + define('ENT_QUOTES', 3); +} + +if (!function_exists('html_entity_decode')) { + function html_entity_decode($string, $quote_style = ENT_COMPAT, $charset = null) { - // replace numeric entities - $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); - $string = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $string); - // replace literal entities + if (!is_int($quote_style)) { + user_error('html_entity_decode() expects parameter 2 to be long, ' . + gettype($quote_style) . ' given', E_USER_WARNING); + return; + } + $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl); + + // Add single quote to translation table; + $trans_tbl['''] = '\''; + + // Not translating double quotes + if ($quote_style & ENT_NOQUOTES) { + // Remove double quote from translation table + unset($trans_tbl['"']); + } + return strtr($string, $trans_tbl); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |