[Phpfreechat-svn] SF.net SVN: phpfreechat: [1132] trunk
Status: Beta
Brought to you by:
kerphi
|
From: <gpi...@us...> - 2007-08-20 02:19:45
|
Revision: 1132
http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1132&view=rev
Author: gpinzone
Date: 2007-08-19 19:19:47 -0700 (Sun, 19 Aug 2007)
Log Message:
-----------
Cleanup of old/bad code.
Modified Paths:
--------------
trunk/data/public/js/pfcgui.js
trunk/src/containers/file.class.php
Modified: trunk/data/public/js/pfcgui.js
===================================================================
--- trunk/data/public/js/pfcgui.js 2007-08-17 23:44:26 UTC (rev 1131)
+++ trunk/data/public/js/pfcgui.js 2007-08-20 02:19:47 UTC (rev 1132)
@@ -443,7 +443,9 @@
}
},
- buildChat: function()
+/* buildChat is not used. Use templates instead. */
+
+/* buildChat: function()
{
var container = $('pfc_container');
@@ -758,4 +760,5 @@
soundcontainerbox.setAttribute('id', 'pfc_sound_container');
container.appendChild(soundcontainerbox);
}
+ */
};
Modified: trunk/src/containers/file.class.php
===================================================================
--- trunk/src/containers/file.class.php 2007-08-17 23:44:26 UTC (rev 1131)
+++ trunk/src/containers/file.class.php 2007-08-20 02:19:47 UTC (rev 1132)
@@ -67,7 +67,6 @@
return $errors;
}
-
function setMeta($group, $subgroup, $leaf, $leafvalue = NULL)
{
$c =& pfcGlobalConfig::Instance();
@@ -217,120 +216,6 @@
return $ret;
}
-
- function popMeta($group, $subgroup, $leaf)
- {
- $c =& pfcGlobalConfig::Instance();
- if ($c->debug)
- file_put_contents("/tmp/debug", "\npopMeta(".$group.",".$subgroup.",".$leaf.")", FILE_APPEND | LOCK_EX);
-
- // create directories
- $dir_base = $c->container_cfg_server_dir;
- $dir = $dir_base.'/'.$group.'/'.$subgroup;
- if (!is_dir($dir)) mkdir_r($dir);
-
- // create or replace metadata file
- $leaffilename = $dir."/".$leaf;
-
- // create return array
- $ret = array();
- $ret["timestamp"] = array();
- $ret["value"] = array();
-
- // read and increment data from metadata file
- clearstatcache();
- if (file_exists($leaffilename))
- {
- $fh = fopen($leaffilename, 'r+');
- for($i = 0; $i < 10; $i++) // Try 10 times until an exclusive lock can be obtained
- {
- if (flock($fh, LOCK_EX))
- {
- $ret["value"][] = chop(fread($fh, filesize($leaffilename)));
- $ret["timestamp"][] = filemtime($leaffilename);
- $leafvalue = array_pop($ret);
- // check if array is now empty
- if (count($ret) == 0)
- {
- fclose($fh);
- unlink($leaffilename);
- break;
- }
- rewind($fh);
- fwrite($fh, $ret);
- fflush($fh);
- ftruncate($fh, ftell($fh));
- flock($fh, LOCK_UN);
- fclose($fh);
- break;
- }
- // If flock is working properly, this will never be reached
- $delay = rand(0, pow(2, ($i+1)) - 1) * 5000; // Exponential backoff
- usleep($delay);
- }
- $ret = $leafvalue;
- }
- else
- {
- // return empty array
- return $ret;
- }
- return $ret;
- }
-
-
- function pushMeta($group, $subgroup, $leaf, $leafvalue = NULL)
- {
- $c =& pfcGlobalConfig::Instance();
- if ($c->debug)
- file_put_contents("/tmp/debug", "\npushMeta(".$group.",".$subgroup.",".$leaf.",".$leafvalue.")", FILE_APPEND | LOCK_EX);
-
- // create directories
- $dir_base = $c->container_cfg_server_dir;
- $dir = $dir_base.'/'.$group.'/'.$subgroup;
- if (!is_dir($dir)) mkdir_r($dir);
-
- // create or replace metadata file
- $leaffilename = $dir."/".$leaf;
-
- // read and increment data from metadata file
- clearstatcache();
- if ( $leafexists = file_exists($leaffilename) )
- {
- $fh = fopen($leaffilename, 'r+');
- for($i = 0; $i < 10; $i++) // Try 10 times until an exclusive lock can be obtained
- {
- if (flock($fh, LOCK_EX))
- {
- if ( $leafvalue == NULL ) $leafvalue = '';
- $leafvaltmp = chop(fread($fh, filesize($leaffilename)));
- array_push($leafvaltmp, $leafvalue);
- rewind($fh);
- fwrite($fh, $leafvaltmp);
- fflush($fh);
- ftruncate($fh, ftell($fh));
- flock($fh, LOCK_UN);
- break;
- }
- // If flock is working properly, this will never be reached
- $delay = rand(0, pow(2, ($i+1)) - 1) * 5000; // Exponential backoff
- usleep($delay);
- }
- fclose($fh);
- }
- else
- {
- file_put_contents($leaffilename, $leafvalue, LOCK_EX);
- }
-
- if ($leafexists)
- return 1; // value overwritten
- else
- return 0; // value created
- }
-
-
-
function rmMeta($group, $subgroup = null, $leaf = null)
{
$c =& pfcGlobalConfig::Instance();
@@ -376,7 +261,6 @@
return true;
}
-
/**
* Used to encode UTF8 strings to ASCII filenames
*/
@@ -392,7 +276,5 @@
{
return urldecode($str);
}
-
}
-
?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|