Thread: [Phpfreechat-svn] SF.net SVN: phpfreechat: [587] trunk/src (Page 2)
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-06-15 12:42:05
|
Revision: 587 Author: kerphi Date: 2006-06-15 05:32:11 -0700 (Thu, 15 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=587&view=rev Log Message: ----------- Simply and optimize the code (about nickid) Modified Paths: -------------- trunk/src/commands/privmsg.class.php trunk/src/phpfreechat.class.php trunk/src/proxys/auth.class.php trunk/src/proxys/noflood.class.php Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2006-06-15 12:23:54 UTC (rev 586) +++ trunk/src/commands/privmsg.class.php 2006-06-15 12:32:11 UTC (rev 587) @@ -14,7 +14,7 @@ // check the pvname exists on the server $container =& $c->getContainerInstance(); $pvnickid = $container->getNickId($pvname); - $nickid = $container->getNickId($u->nick); + $nickid = $u->nickid; // error: can't speak to myself if ($pvnickid == $nickid) Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-06-15 12:23:54 UTC (rev 586) +++ trunk/src/phpfreechat.class.php 2006-06-15 12:32:11 UTC (rev 587) @@ -360,7 +360,7 @@ // before playing the wanted command // play the found commands into the meta 'cmdtoplay' $container =& $c->getContainerInstance(); - $nickid = $container->getNickId($u->nick); + $nickid = $u->nickid; $morecmd = true; while($morecmd) { Modified: trunk/src/proxys/auth.class.php =================================================================== --- trunk/src/proxys/auth.class.php 2006-06-15 12:23:54 UTC (rev 586) +++ trunk/src/proxys/auth.class.php 2006-06-15 12:32:11 UTC (rev 587) @@ -40,15 +40,15 @@ if ( in_array($this->name, $admincmd) ) { $container =& $c->getContainerInstance(); - $nickid = $container->getNickId($sender); + $nickid = $u->nickid; $isadmin = $container->getMeta("isadmin", "nickname", $nickid); if (!$isadmin) { $xml_reponse->addScript("alert('".addslashes(_pfc("You are not allowed to run '%s' command", $this->name))."');"); return; } - } - + } + // channels protection if ($this->name == "join") { @@ -59,7 +59,7 @@ $chanid = pfcCommand_join::GetRecipientId($channame); $banlist = $container->getMeta("banlist_nickid", "channel", $chanid); if ($banlist == NULL) $banlist = array(); else $banlist = unserialize($banlist); - $nickid = $container->getNickId($u->nick); + $nickid = $u->nickid; if (in_array($nickid,$banlist)) { // the user is banished, show a message and don't forward the /join command Modified: trunk/src/proxys/noflood.class.php =================================================================== --- trunk/src/proxys/noflood.class.php 2006-06-15 12:23:54 UTC (rev 586) +++ trunk/src/proxys/noflood.class.php 2006-06-15 12:32:11 UTC (rev 587) @@ -39,7 +39,7 @@ if ( in_array($this->name, $cmdtocheck) ) { $container =& $c->getContainerInstance(); - $nickid = $container->getNickId($sender); + $nickid = $u->nickid; $isadmin = $container->getMeta("isadmin", "nickname", $nickid); $lastfloodtime = $container->getMeta("floodtime", "nickname", $nickid); $nbflood = $container->getMeta("nbflood", "nickname", $nickid); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-15 13:19:06
|
Revision: 588 Author: kerphi Date: 2006-06-15 06:18:55 -0700 (Thu, 15 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=588&view=rev Log Message: ----------- Remove the corresponding cache lock file when the cache is destroyed. Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php trunk/testcase/container_generic.php Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-06-15 12:32:11 UTC (rev 587) +++ trunk/src/pfcglobalconfig.class.php 2006-06-15 13:18:55 UTC (rev 588) @@ -376,6 +376,10 @@ if (!file_exists($cachefile)) return false; $this->is_init = false; + // destroy the cache lock file + $cachefile_lock = $cachefile."_lock"; + if (file_exists($cachefile_lock)) @unlink($cachefile_lock); + // destroy the cache file return @unlink($cachefile); } Modified: trunk/testcase/container_generic.php =================================================================== --- trunk/testcase/container_generic.php 2006-06-15 12:32:11 UTC (rev 587) +++ trunk/testcase/container_generic.php 2006-06-15 13:18:55 UTC (rev 588) @@ -41,9 +41,8 @@ // here function tearDown() { - $ct =& $this->ct; - // remove the created files and directories - $this->ct->clear(); + $this->ct->clear(); + $this->c->destroyCache(); } function testCreateNick_Generic() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-17 10:58:51
|
Revision: 614 Author: kerphi Date: 2006-06-17 03:58:45 -0700 (Sat, 17 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=614&view=rev Log Message: ----------- Refactoring: rename copyr to copy_r Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php trunk/src/pfctools.php Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-06-17 10:54:12 UTC (rev 613) +++ trunk/src/pfcglobalconfig.class.php 2006-06-17 10:58:45 UTC (rev 614) @@ -199,29 +199,29 @@ $this->errors = array_merge($this->errors, @install_dir($this->jspath, $this->data_public_path."/javascript")); $this->errors = array_merge($this->errors, @test_writable_dir($this->data_private_path."/cache", "data_private_path/cache")); - // check the copyr and rm_r function works + // check the copy_r and rm_r function works if (count($this->errors) == 0) { - $copyr_ok = true; - $dir1 = $this->data_private_path."/copyr1"; + $copy_r_ok = true; + $dir1 = $this->data_private_path."/copy_r1"; $file1 = $dir1."/dummy"; - $dir2 = $this->data_private_path."/copyr2"; + $dir2 = $this->data_private_path."/copy_r2"; $file2 = $dir2."/dummy"; // create a dummy directory mkdir($dir1); // check the directory exists - if (!file_exists($dir1) || !is_dir($dir1)) $copyr_ok = false; + if (!file_exists($dir1) || !is_dir($dir1)) $copy_r_ok = false; // create a dummy file touch($file1); // check the file exists - if (!file_exists($file1)) $copyr_ok = false; - // copyr the dummy dir - copyr($dir1,$dir2); + if (!file_exists($file1)) $copy_r_ok = false; + // copy_r the dummy dir + copy_r($dir1,$dir2); // check the directory exists - if (!file_exists($dir2) || !is_dir($dir2)) $copyr_ok = false; + if (!file_exists($dir2) || !is_dir($dir2)) $copy_r_ok = false; // check the file exists - if (!file_exists($file2)) $copyr_ok = false; - if (!$copyr_ok) + if (!file_exists($file2)) $copy_r_ok = false; + if (!$copy_r_ok) $this->errors[] = _pfc("Recursive copy doesn't works"); // try to remove recursively the directory @@ -232,7 +232,7 @@ if (file_exists($dir1) || file_exists($dir2)) $rm_r_ok = false; // check the file doesn't exists if (file_exists($file1) || file_exists($file2)) $rm_r_ok = false; - if (!$copyr_ok) + if (!$copy_r_ok) $this->errors[] = _pfc("Recursive remove doesn't works"); } Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2006-06-17 10:54:12 UTC (rev 613) +++ trunk/src/pfctools.php 2006-06-17 10:58:45 UTC (rev 614) @@ -137,7 +137,7 @@ * @param string $dest Destination path * @return bool Returns TRUE on success, FALSE on failure */ -function copyr($source, $dest, $mode = 0700) +function copy_r($source, $dest, $mode = 0700) { // Simple copy for a file if (is_file($source)) { @@ -166,7 +166,7 @@ if ($e == '.' || $e == '..' || $e == '.svn') continue; // Deep copy directories if ($dest !== $source . DIRECTORY_SEPARATOR . $e) - copyr($source . DIRECTORY_SEPARATOR . $e, $dest . DIRECTORY_SEPARATOR . $e, $mode); + copy_r($source . DIRECTORY_SEPARATOR . $e, $dest . DIRECTORY_SEPARATOR . $e, $mode); } // Clean up @@ -239,7 +239,7 @@ if (!is_readable($src_dir)) $errors[] = _pfc("%s is not readable", $src_dir); - copyr( $src_dir, $dst_dir ); + copy_r( $src_dir, $dst_dir ); return $errors; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-24 20:09:52
|
Revision: 625 Author: kerphi Date: 2006-06-24 13:09:32 -0700 (Sat, 24 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=625&view=rev Log Message: ----------- new command: "/identify {password}" used to take admin rights Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php trunk/themes/default/templates/pfcclient.js.tpl.php Added Paths: ----------- trunk/src/commands/identify.class.php Added: trunk/src/commands/identify.class.php =================================================================== --- trunk/src/commands/identify.class.php (rev 0) +++ trunk/src/commands/identify.class.php 2006-06-24 20:09:32 UTC (rev 625) @@ -0,0 +1,67 @@ +<?php +/** + * identify.class.php + * + * Copyright © 2006 Stephane Gully <ste...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +require_once(dirname(__FILE__)."/../pfccommand.class.php"); + +/** + * pfcCommand_identify + * this command will identify the user admin rights + * @author Stephane Gully <ste...@gm...> + */ +class pfcCommand_identify extends pfcCommand +{ + var $usage = "/identify {password}"; + + function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + { + $c =& $this->c; + $u =& $this->u; + + $password = trim($param); + $isadmin = false; + + // @todo simplify the search in the admins config array using a native php function (array_search?) + foreach($c->admins as $a_nick => $a_pass) + { + if ($a_nick == $sender && $a_pass == $password) + $isadmin = true; + } + + $msg = ""; + if ($isadmin) + { + // ok the current user is an admin, just save the isadmin flag in the metadata + $container =& $c->getContainerInstance(); + $container->setMeta($isadmin, "isadmin", "nickname", $u->nickid); + + $msg .= _pfc("Succesfully identified"); + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', '".$msg."');"); + } + else + { + $msg .= _pfc("Identification failure"); + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ko', '".$msg."');"); + } + } +} + +?> \ No newline at end of file Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-06-24 20:08:36 UTC (rev 624) +++ trunk/src/pfcglobalconfig.class.php 2006-06-24 20:09:32 UTC (rev 625) @@ -35,6 +35,7 @@ // these parameters are dynamic (not cached) var $nick = ""; // the initial nickname ("" means the user will be queried) var $isadmin = false; + var $admins = array("admin" => ""); // nicknames is the key, password is the value // these parameters are static (cached) var $proxys = array("auth", "noflood"); Modified: trunk/themes/default/templates/pfcclient.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcclient.js.tpl.php 2006-06-24 20:08:36 UTC (rev 624) +++ trunk/themes/default/templates/pfcclient.js.tpl.php 2006-06-24 20:09:32 UTC (rev 625) @@ -390,6 +390,10 @@ var container = this.gui.getChatContentFromTabId(tabid); container.innerHTML = ""; } + else if (cmd == "identify") + { + this.displayMsg( cmd, param ); + } else alert(cmd + "-"+resp+"-"+param); }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-28 14:27:53
|
Revision: 633 Author: kerphi Date: 2006-06-28 07:27:42 -0700 (Wed, 28 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=633&view=rev Log Message: ----------- First step to remove prototype dependencies. Why ? because prototype override some default javascript behaviors (Array) and break compatibility with others javascript libraries (example: ie7) Modified Paths: -------------- trunk/src/phpfreechat.class.php trunk/themes/default/templates/pfcclient.js.tpl.php trunk/themes/default/templates/pfcgui.js.tpl.php Added Paths: ----------- trunk/lib/javascript/myprototype.js Added: trunk/lib/javascript/myprototype.js =================================================================== --- trunk/lib/javascript/myprototype.js (rev 0) +++ trunk/lib/javascript/myprototype.js 2006-06-28 14:27:42 UTC (rev 633) @@ -0,0 +1,1520 @@ +/* Prototype JavaScript framework, version 1.4.0 + * (c) 2005 Sam Stephenson <sa...@co...> + * + * Prototype is freely distributable under the terms of an MIT-style license. + * For details, see the Prototype web site: http://prototype.conio.net/ + * +/*--------------------------------------------------------------------------*/ + +var Prototype = { + Version: '1.4.0', + ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', + + emptyFunction: function() {}, + K: function(x) {return x} +} + +var Class = { + create: function() { + return function() { + this.initialize.apply(this, arguments); + } + } +} + +var Abstract = new Object(); + +Object.extend = function(destination, source) { + for (property in source) { + destination[property] = source[property]; + } + return destination; +} + +Object.inspect = function(object) { + try { + if (object == undefined) return 'undefined'; + if (object == null) return 'null'; + return object.inspect ? object.inspect() : object.toString(); + } catch (e) { + if (e instanceof RangeError) return '...'; + throw e; + } +} + +Function.prototype.bind = function() { + var __method = this, args = $A(arguments), object = args.shift(); + return function() { + return __method.apply(object, args.concat($A(arguments))); + } +} + +Function.prototype.bindAsEventListener = function(object) { + var __method = this; + return function(event) { + return __method.call(object, event || window.event); + } +} + +Object.extend(Number.prototype, { + toColorPart: function() { + var digits = this.toString(16); + if (this < 16) return '0' + digits; + return digits; + }, + + succ: function() { + return this + 1; + }, + + times: function(iterator) { + $R(0, this, true).each(iterator); + return this; + } +}); + +var Try = { + these: function() { + var returnValue; + + for (var i = 0; i < arguments.length; i++) { + var lambda = arguments[i]; + try { + returnValue = lambda(); + break; + } catch (e) {} + } + + return returnValue; + } +} + +/*--------------------------------------------------------------------------*/ + +var PeriodicalExecuter = Class.create(); +PeriodicalExecuter.prototype = { + initialize: function(callback, frequency) { + this.callback = callback; + this.frequency = frequency; + this.currentlyExecuting = false; + + this.registerCallback(); + }, + + registerCallback: function() { + setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); + }, + + onTimerEvent: function() { + if (!this.currentlyExecuting) { + try { + this.currentlyExecuting = true; + this.callback(); + } finally { + this.currentlyExecuting = false; + } + } + } +} + +/*--------------------------------------------------------------------------*/ + +function $() { + var elements = new Array(); + + for (var i = 0; i < arguments.length; i++) { + var element = arguments[i]; + if (typeof element == 'string') + element = document.getElementById(element); + + if (arguments.length == 1) + return element; + + elements.push(element); + } + + return elements; +} +Object.extend(String.prototype, { + stripTags: function() { + return this.replace(/<\/?[^>]+>/gi, ''); + }, + + stripScripts: function() { + return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); + }, + + extractScripts: function() { + var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); + var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); + return (this.match(matchAll) || []).map(function(scriptTag) { + return (scriptTag.match(matchOne) || ['', ''])[1]; + }); + }, + + evalScripts: function() { + return this.extractScripts().map(eval); + }, + + escapeHTML: function() { + var div = document.createElement('div'); + var text = document.createTextNode(this); + div.appendChild(text); + return div.innerHTML; + }, + + unescapeHTML: function() { + var div = document.createElement('div'); + div.innerHTML = this.stripTags(); + return div.childNodes[0] ? div.childNodes[0].nodeValue : ''; + }, + + toQueryParams: function() { + var pairs = this.match(/^\??(.*)$/)[1].split('&'); + return pairs.inject({}, function(params, pairString) { + var pair = pairString.split('='); + params[pair[0]] = pair[1]; + return params; + }); + }, + + toArray: function() { + return this.split(''); + }, + + camelize: function() { + var oStringList = this.split('-'); + if (oStringList.length == 1) return oStringList[0]; + + var camelizedString = this.indexOf('-') == 0 + ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) + : oStringList[0]; + + for (var i = 1, len = oStringList.length; i < len; i++) { + var s = oStringList[i]; + camelizedString += s.charAt(0).toUpperCase() + s.substring(1); + } + + return camelizedString; + }, + + inspect: function() { + return "'" + this.replace('\\', '\\\\').replace("'", '\\\'') + "'"; + } +}); + +String.prototype.parseQuery = String.prototype.toQueryParams; + +var $break = new Object(); +var $continue = new Object(); + +var Enumerable = { + each: function(iterator) { + var index = 0; + try { + this._each(function(value) { + try { + iterator(value, index++); + } catch (e) { + if (e != $continue) throw e; + } + }); + } catch (e) { + if (e != $break) throw e; + } + }, + + all: function(iterator) { + var result = true; + this.each(function(value, index) { + result = result && !!(iterator || Prototype.K)(value, index); + if (!result) throw $break; + }); + return result; + }, + + any: function(iterator) { + var result = true; + this.each(function(value, index) { + if (result = !!(iterator || Prototype.K)(value, index)) + throw $break; + }); + return result; + }, + + collect: function(iterator) { + var results = []; + this.each(function(value, index) { + results.push(iterator(value, index)); + }); + return results; + }, + + detect: function (iterator) { + var result; + this.each(function(value, index) { + if (iterator(value, index)) { + result = value; + throw $break; + } + }); + return result; + }, + + findAll: function(iterator) { + var results = []; + this.each(function(value, index) { + if (iterator(value, index)) + results.push(value); + }); + return results; + }, + + grep: function(pattern, iterator) { + var results = []; + this.each(function(value, index) { + var stringValue = value.toString(); + if (stringValue.match(pattern)) + results.push((iterator || Prototype.K)(value, index)); + }) + return results; + }, + + include: function(object) { + var found = false; + this.each(function(value) { + if (value == object) { + found = true; + throw $break; + } + }); + return found; + }, + + inject: function(memo, iterator) { + this.each(function(value, index) { + memo = iterator(memo, value, index); + }); + return memo; + }, + + invoke: function(method) { + var args = $A(arguments).slice(1); + return this.collect(function(value) { + return value[method].apply(value, args); + }); + }, + + max: function(iterator) { + var result; + this.each(function(value, index) { + value = (iterator || Prototype.K)(value, index); + if (value >= (result || value)) + result = value; + }); + return result; + }, + + min: function(iterator) { + var result; + this.each(function(value, index) { + value = (iterator || Prototype.K)(value, index); + if (value <= (result || value)) + result = value; + }); + return result; + }, + + partition: function(iterator) { + var trues = [], falses = []; + this.each(function(value, index) { + ((iterator || Prototype.K)(value, index) ? + trues : falses).push(value); + }); + return [trues, falses]; + }, + + pluck: function(property) { + var results = []; + this.each(function(value, index) { + results.push(value[property]); + }); + return results; + }, + + reject: function(iterator) { + var results = []; + this.each(function(value, index) { + if (!iterator(value, index)) + results.push(value); + }); + return results; + }, + + sortBy: function(iterator) { + return this.collect(function(value, index) { + return {value: value, criteria: iterator(value, index)}; + }).sort(function(left, right) { + var a = left.criteria, b = right.criteria; + return a < b ? -1 : a > b ? 1 : 0; + }).pluck('value'); + }, + + toArray: function() { + return this.collect(Prototype.K); + }, + + zip: function() { + var iterator = Prototype.K, args = $A(arguments); + if (typeof args.last() == 'function') + iterator = args.pop(); + + var collections = [this].concat(args).map($A); + return this.map(function(value, index) { + iterator(value = collections.pluck(index)); + return value; + }); + }, + + inspect: function() { + return '#<Enumerable:' + this.toArray().inspect() + '>'; + } +} + +Object.extend(Enumerable, { + map: Enumerable.collect, + find: Enumerable.detect, + select: Enumerable.findAll, + member: Enumerable.include, + entries: Enumerable.toArray + }); + +var $A = Array.from = function(iterable) { + if (!iterable) return []; + if (iterable.toArray) { + return iterable.toArray(); + } else { + var results = []; + for (var i = 0; i < iterable.length; i++) + results.push(iterable[i]); + return results; + } +} + +//Array.prototype._reverse = Array.prototype.reverse; + +//Object.extend(Array.prototype, Enumerable); +/* +Array.prototype._reverse = Array.prototype.reverse; + + +Object.extend(Array.prototype, { + _each: function(iterator) { + for (var i = 0; i < this.length; i++) + iterator(this[i]); + }, + + clear: function() { + this.length = 0; + return this; + }, + + first: function() { + return this[0]; + }, + + last: function() { + return this[this.length - 1]; + }, + + compact: function() { + return this.select(function(value) { + return value != undefined || value != null; + }); + }, + + flatten: function() { + return this.inject([], function(array, value) { + return array.concat(value.constructor == Array ? + value.flatten() : [value]); + }); + }, + + without: function() { + var values = $A(arguments); + return this.select(function(value) { + return !values.include(value); + }); + }, + + indexOf: function(object) { + for (var i = 0; i < this.length; i++) + if (this[i] == object) return i; + return -1; + }, + + reverse: function(inline) { + return (inline !== false ? this : this.toArray())._reverse(); + }, + + shift: function() { + var result = this[0]; + for (var i = 0; i < this.length - 1; i++) + this[i] = this[i + 1]; + this.length--; + return result; + }, + + inspect: function() { + return '[' + this.map(Object.inspect).join(', ') + ']'; + } +}); +*/ + + +var Hash = { + _each: function(iterator) { + for (key in this) { + var value = this[key]; + if (typeof value == 'function') continue; + + var pair = [key, value]; + pair.key = key; + pair.value = value; + iterator(pair); + } + }, + + keys: function() { + return this.pluck('key'); + }, + + values: function() { + return this.pluck('value'); + }, + + merge: function(hash) { + return $H(hash).inject($H(this), function(mergedHash, pair) { + mergedHash[pair.key] = pair.value; + return mergedHash; + }); + }, + + toQueryString: function() { + return this.map(function(pair) { + return pair.map(encodeURIComponent).join('='); + }).join('&'); + }, + + inspect: function() { + return '#<Hash:{' + this.map(function(pair) { + return pair.map(Object.inspect).join(': '); + }).join(', ') + '}>'; + } +} + +function $H(object) { + var hash = Object.extend({}, object || {}); + Object.extend(hash, Enumerable); + Object.extend(hash, Hash); + return hash; +} +ObjectRange = Class.create(); +Object.extend(ObjectRange.prototype, Enumerable); +Object.extend(ObjectRange.prototype, { + initialize: function(start, end, exclusive) { + this.start = start; + this.end = end; + this.exclusive = exclusive; + }, + + _each: function(iterator) { + var value = this.start; + do { + iterator(value); + value = value.succ(); + } while (this.include(value)); + }, + + include: function(value) { + if (value < this.start) + return false; + if (this.exclusive) + return value < this.end; + return value <= this.end; + } +}); + +var $R = function(start, end, exclusive) { + return new ObjectRange(start, end, exclusive); +} + +document.getElementsByClassName = function(className, parentElement) { + var children = ($(parentElement) || document.body).getElementsByTagName('*'); + return $A(children).inject([], function(elements, child) { + if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) + elements.push(child); + return elements; + }); +} + +/*--------------------------------------------------------------------------*/ + +if (!window.Element) { + var Element = new Object(); +} + +Object.extend(Element, { + visible: function(element) { + return $(element).style.display != 'none'; + }, + + toggle: function() { + for (var i = 0; i < arguments.length; i++) { + var element = $(arguments[i]); + Element[Element.visible(element) ? 'hide' : 'show'](element); + } + }, + + hide: function() { + for (var i = 0; i < arguments.length; i++) { + var element = $(arguments[i]); + element.style.display = 'none'; + } + }, + + show: function() { + for (var i = 0; i < arguments.length; i++) { + var element = $(arguments[i]); + element.style.display = ''; + } + }, + + remove: function(element) { + element = $(element); + element.parentNode.removeChild(element); + }, + + update: function(element, html) { + $(element).innerHTML = html.stripScripts(); + setTimeout(function() {html.evalScripts()}, 10); + }, + + getHeight: function(element) { + element = $(element); + return element.offsetHeight; + }, + + classNames: function(element) { + return new Element.ClassNames(element); + }, + + hasClassName: function(element, className) { + if (!(element = $(element))) return; + return Element.classNames(element).include(className); + }, + + addClassName: function(element, className) { + if (!(element = $(element))) return; + return Element.classNames(element).add(className); + }, + + removeClassName: function(element, className) { + if (!(element = $(element))) return; + return Element.classNames(element).remove(className); + }, + + // removes whitespace-only text node children + cleanWhitespace: function(element) { + element = $(element); + for (var i = 0; i < element.childNodes.length; i++) { + var node = element.childNodes[i]; + if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) + Element.remove(node); + } + }, + + empty: function(element) { + return $(element).innerHTML.match(/^\s*$/); + }, + + scrollTo: function(element) { + element = $(element); + var x = element.x ? element.x : element.offsetLeft, + y = element.y ? element.y : element.offsetTop; + window.scrollTo(x, y); + }, + + getStyle: function(element, style) { + element = $(element); + var value = element.style[style.camelize()]; + if (!value) { + if (document.defaultView && document.defaultView.getComputedStyle) { + var css = document.defaultView.getComputedStyle(element, null); + value = css ? css.getPropertyValue(style) : null; + } else if (element.currentStyle) { + value = element.currentStyle[style.camelize()]; + } + } + + if (window.opera && ['left', 'top', 'right', 'bottom'].include(style)) + if (Element.getStyle(element, 'position') == 'static') value = 'auto'; + + return value == 'auto' ? null : value; + }, + + setStyle: function(element, style) { + element = $(element); + for (name in style) + element.style[name.camelize()] = style[name]; + }, + + getDimensions: function(element) { + element = $(element); + if (Element.getStyle(element, 'display') != 'none') + return {width: element.offsetWidth, height: element.offsetHeight}; + + // All *Width and *Height properties give 0 on elements with display none, + // so enable the element temporarily + var els = element.style; + var originalVisibility = els.visibility; + var originalPosition = els.position; + els.visibility = 'hidden'; + els.position = 'absolute'; + els.display = ''; + var originalWidth = element.clientWidth; + var originalHeight = element.clientHeight; + els.display = 'none'; + els.position = originalPosition; + els.visibility = originalVisibility; + return {width: originalWidth, height: originalHeight}; + }, + + makePositioned: function(element) { + element = $(element); + var pos = Element.getStyle(element, 'position'); + if (pos == 'static' || !pos) { + element._madePositioned = true; + element.style.position = 'relative'; + // Opera returns the offset relative to the positioning context, when an + // element is position relative but top and left have not been defined + if (window.opera) { + element.style.top = 0; + element.style.left = 0; + } + } + }, + + undoPositioned: function(element) { + element = $(element); + if (element._madePositioned) { + element._madePositioned = undefined; + element.style.position = + element.style.top = + element.style.left = + element.style.bottom = + element.style.right = ''; + } + }, + + makeClipping: function(element) { + element = $(element); + if (element._overflow) return; + element._overflow = element.style.overflow; + if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden') + element.style.overflow = 'hidden'; + }, + + undoClipping: function(element) { + element = $(element); + if (element._overflow) return; + element.style.overflow = element._overflow; + element._overflow = undefined; + } +}); + +var Toggle = new Object(); +Toggle.display = Element.toggle; + +/*--------------------------------------------------------------------------*/ + +Abstract.Insertion = function(adjacency) { + this.adjacency = adjacency; +} + +Abstract.Insertion.prototype = { + initialize: function(element, content) { + this.element = $(element); + this.content = content.stripScripts(); + + if (this.adjacency && this.element.insertAdjacentHTML) { + try { + this.element.insertAdjacentHTML(this.adjacency, this.content); + } catch (e) { + if (this.element.tagName.toLowerCase() == 'tbody') { + this.insertContent(this.contentFromAnonymousTable()); + } else { + throw e; + } + } + } else { + this.range = this.element.ownerDocument.createRange(); + if (this.initializeRange) this.initializeRange(); + this.insertContent([this.range.createContextualFragment(this.content)]); + } + + setTimeout(function() {content.evalScripts()}, 10); + }, + + contentFromAnonymousTable: function() { + var div = document.createElement('div'); + div.innerHTML = '<table><tbody>' + this.content + '</tbody></table>'; + return $A(div.childNodes[0].childNodes[0].childNodes); + } +} + +var Insertion = new Object(); + +Insertion.Before = Class.create(); +Insertion.Before.prototype = Object.extend(new Abstract.Insertion('beforeBegin'), { + initializeRange: function() { + this.range.setStartBefore(this.element); + }, + + insertContent: function(fragments) { + fragments.each((function(fragment) { + this.element.parentNode.insertBefore(fragment, this.element); + }).bind(this)); + } +}); + +Insertion.Top = Class.create(); +Insertion.Top.prototype = Object.extend(new Abstract.Insertion('afterBegin'), { + initializeRange: function() { + this.range.selectNodeContents(this.element); + this.range.collapse(true); + }, + + insertContent: function(fragments) { + fragments.reverse(false).each((function(fragment) { + this.element.insertBefore(fragment, this.element.firstChild); + }).bind(this)); + } +}); + +Insertion.Bottom = Class.create(); +Insertion.Bottom.prototype = Object.extend(new Abstract.Insertion('beforeEnd'), { + initializeRange: function() { + this.range.selectNodeContents(this.element); + this.range.collapse(this.element); + }, + + insertContent: function(fragments) { + fragments.each((function(fragment) { + this.element.appendChild(fragment); + }).bind(this)); + } +}); + +Insertion.After = Class.create(); +Insertion.After.prototype = Object.extend(new Abstract.Insertion('afterEnd'), { + initializeRange: function() { + this.range.setStartAfter(this.element); + }, + + insertContent: function(fragments) { + fragments.each((function(fragment) { + this.element.parentNode.insertBefore(fragment, + this.element.nextSibling); + }).bind(this)); + } +}); + +/*--------------------------------------------------------------------------*/ + +Element.ClassNames = Class.create(); +Element.ClassNames.prototype = { + initialize: function(element) { + this.element = $(element); + }, + + _each: function(iterator) { + this.element.className.split(/\s+/).select(function(name) { + return name.length > 0; + })._each(iterator); + }, + + set: function(className) { + this.element.className = className; + }, + + add: function(classNameToAdd) { + if (this.include(classNameToAdd)) return; + this.set(this.toArray().concat(classNameToAdd).join(' ')); + }, + + remove: function(classNameToRemove) { + if (!this.include(classNameToRemove)) return; + this.set(this.select(function(className) { + return className != classNameToRemove; + }).join(' ')); + }, + + toString: function() { + return this.toArray().join(' '); + } +} + +Object.extend(Element.ClassNames.prototype, Enumerable); +var Field = { + clear: function() { + for (var i = 0; i < arguments.length; i++) + $(arguments[i]).value = ''; + }, + + focus: function(element) { + $(element).focus(); + }, + + present: function() { + for (var i = 0; i < arguments.length; i++) + if ($(arguments[i]).value == '') return false; + return true; + }, + + select: function(element) { + $(element).select(); + }, + + activate: function(element) { + element = $(element); + element.focus(); + if (element.select) + element.select(); + } +} + +/*--------------------------------------------------------------------------*/ + +var Form = { + serialize: function(form) { + var elements = Form.getElements($(form)); + var queryComponents = new Array(); + + for (var i = 0; i < elements.length; i++) { + var queryComponent = Form.Element.serialize(elements[i]); + if (queryComponent) + queryComponents.push(queryComponent); + } + + return queryComponents.join('&'); + }, + + getElements: function(form) { + form = $(form); + var elements = new Array(); + + for (tagName in Form.Element.Serializers) { + var tagElements = form.getElementsByTagName(tagName); + for (var j = 0; j < tagElements.length; j++) + elements.push(tagElements[j]); + } + return elements; + }, + + getInputs: function(form, typeName, name) { + form = $(form); + var inputs = form.getElementsByTagName('input'); + + if (!typeName && !name) + return inputs; + + var matchingInputs = new Array(); + for (var i = 0; i < inputs.length; i++) { + var input = inputs[i]; + if ((typeName && input.type != typeName) || + (name && input.name != name)) + continue; + matchingInputs.push(input); + } + + return matchingInputs; + }, + + disable: function(form) { + var elements = Form.getElements(form); + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + element.blur(); + element.disabled = 'true'; + } + }, + + enable: function(form) { + var elements = Form.getElements(form); + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + element.disabled = ''; + } + }, + + findFirstElement: function(form) { + return Form.getElements(form).find(function(element) { + return element.type != 'hidden' && !element.disabled && + ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); + }); + }, + + focusFirstElement: function(form) { + Field.activate(Form.findFirstElement(form)); + }, + + reset: function(form) { + $(form).reset(); + } +} + +Form.Element = { + serialize: function(element) { + element = $(element); + var method = element.tagName.toLowerCase(); + var parameter = Form.Element.Serializers[method](element); + + if (parameter) { + var key = encodeURIComponent(parameter[0]); + if (key.length == 0) return; + + if (parameter[1].constructor != Array) + parameter[1] = [parameter[1]]; + + return parameter[1].map(function(value) { + return key + '=' + encodeURIComponent(value); + }).join('&'); + } + }, + + getValue: function(element) { + element = $(element); + var method = element.tagName.toLowerCase(); + var parameter = Form.Element.Serializers[method](element); + + if (parameter) + return parameter[1]; + } +} + +Form.Element.Serializers = { + input: function(element) { + switch (element.type.toLowerCase()) { + case 'submit': + case 'hidden': + case 'password': + case 'text': + return Form.Element.Serializers.textarea(element); + case 'checkbox': + case 'radio': + return Form.Element.Serializers.inputSelector(element); + } + return false; + }, + + inputSelector: function(element) { + if (element.checked) + return [element.name, element.value]; + }, + + textarea: function(element) { + return [element.name, element.value]; + }, + + select: function(element) { + return Form.Element.Serializers[element.type == 'select-one' ? + 'selectOne' : 'selectMany'](element); + }, + + selectOne: function(element) { + var value = '', opt, index = element.selectedIndex; + if (index >= 0) { + opt = element.options[index]; + value = opt.value; + if (!value && !('value' in opt)) + value = opt.text; + } + return [element.name, value]; + }, + + selectMany: function(element) { + var value = new Array(); + for (var i = 0; i < element.length; i++) { + var opt = element.options[i]; + if (opt.selected) { + var optValue = opt.value; + if (!optValue && !('value' in opt)) + optValue = opt.text; + value.push(optValue); + } + } + return [element.name, value]; + } +} + +/*--------------------------------------------------------------------------*/ + +var $F = Form.Element.getValue; + +/*--------------------------------------------------------------------------*/ + +Abstract.TimedObserver = function() {} +Abstract.TimedObserver.prototype = { + initialize: function(element, frequency, callback) { + this.frequency = frequency; + this.element = $(element); + this.callback = callback; + + this.lastValue = this.getValue(); + this.registerCallback(); + }, + + registerCallback: function() { + setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); + }, + + onTimerEvent: function() { + var value = this.getValue(); + if (this.lastValue != value) { + this.callback(this.element, value); + this.lastValue = value; + } + } +} + +Form.Element.Observer = Class.create(); +Form.Element.Observer.prototype = Object.extend(new Abstract.TimedObserver(), { + getValue: function() { + return Form.Element.getValue(this.element); + } +}); + +Form.Observer = Class.create(); +Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(), { + getValue: function() { + return Form.serialize(this.element); + } +}); + +/*--------------------------------------------------------------------------*/ + +Abstract.EventObserver = function() {} +Abstract.EventObserver.prototype = { + initialize: function(element, callback) { + this.element = $(element); + this.callback = callback; + + this.lastValue = this.getValue(); + if (this.element.tagName.toLowerCase() == 'form') + this.registerFormCallbacks(); + else + this.registerCallback(this.element); + }, + + onElementEvent: function() { + var value = this.getValue(); + if (this.lastValue != value) { + this.callback(this.element, value); + this.lastValue = value; + } + }, + + registerFormCallbacks: function() { + var elements = Form.getElements(this.element); + for (var i = 0; i < elements.length; i++) + this.registerCallback(elements[i]); + }, + + registerCallback: function(element) { + if (element.type) { + switch (element.type.toLowerCase()) { + case 'checkbox': + case 'radio': + Event.observe(element, 'click', this.onElementEvent.bind(this)); + break; + case 'password': + case 'text': + case 'textarea': + case 'select-one': + case 'select-multiple': + Event.observe(element, 'change', this.onElementEvent.bind(this)); + break; + } + } + } +} + +Form.Element.EventObserver = Class.create(); +Form.Element.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), { + getValue: function() { + return Form.Element.getValue(this.element); + } +}); + +Form.EventObserver = Class.create(); +Form.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), { + getValue: function() { + return Form.serialize(this.element); + } +}); +if (!window.Event) { + var Event = new Object(); +} + +Object.extend(Event, { + KEY_BACKSPACE: 8, + KEY_TAB: 9, + KEY_RETURN: 13, + KEY_ESC: 27, + KEY_LEFT: 37, + KEY_UP: 38, + KEY_RIGHT: 39, + KEY_DOWN: 40, + KEY_DELETE: 46, + + element: function(event) { + return event.target || event.srcElement; + }, + + isLeftClick: function(event) { + return (((event.which) && (event.which == 1)) || + ((event.button) && (event.button == 1))); + }, + + pointerX: function(event) { + return event.pageX || (event.clientX + + (document.documentElement.scrollLeft || document.body.scrollLeft)); + }, + + pointerY: function(event) { + return event.pageY || (event.clientY + + (document.documentElement.scrollTop || document.body.scrollTop)); + }, + + stop: function(event) { + if (event.preventDefault) { + event.preventDefault(); + event.stopPropagation(); + } else { + event.returnValue = false; + event.cancelBubble = true; + } + }, + + // find the first node with the given tagName, starting from the + // node the event was triggered on; traverses the DOM upwards + findElement: function(event, tagName) { + var element = Event.element(event); + while (element.parentNode && (!element.tagName || + (element.tagName.toUpperCase() != tagName.toUpperCase()))) + element = element.parentNode; + return element; + }, + + observers: false, + + _observeAndCache: function(element, name, observer, useCapture) { + if (!this.observers) this.observers = []; + if (element.addEventListener) { + this.observers.push([element, name, observer, useCapture]); + element.addEventListener(name, observer, useCapture); + } else if (element.attachEvent) { + this.observers.push([element, name, observer, useCapture]); + element.attachEvent('on' + name, observer); + } + }, + + unloadCache: function() { + if (!Event.observers) return; + for (var i = 0; i < Event.observers.length; i++) { + Event.stopObserving.apply(this, Event.observers[i]); + Event.observers[i][0] = null; + } + Event.observers = false; + }, + + observe: function(element, name, observer, useCapture) { + var element = $(element); + useCapture = useCapture || false; + + if (name == 'keypress' && + (navigator.appVersion.match(/Konqueror|Safari|KHTML/) + || element.attachEvent)) + name = 'keydown'; + + this._observeAndCache(element, name, observer, useCapture); + }, + + stopObserving: function(element, name, observer, useCapture) { + var element = $(element); + useCapture = useCapture || false; + + if (name == 'keypress' && + (navigator.appVersion.match(/Konqueror|Safari|KHTML/) + || element.detachEvent)) + name = 'keydown'; + + if (element.removeEventListener) { + element.removeEventListener(name, observer, useCapture); + } else if (element.detachEvent) { + element.detachEvent('on' + name, observer); + } + } +}); + +/* prevent memory leaks in IE */ +Event.observe(window, 'unload', Event.unloadCache, false); +var Position = { + // set to true if needed, warning: firefox performance problems + // NOT neeeded for page scrolling, only if draggable contained in + // scrollable elements + includeScrollOffsets: false, + + // must be called before calling withinIncludingScrolloffset, every time the + // page is scrolled + prepare: function() { + this.deltaX = window.pageXOffset + || document.documentElement.scrollLeft + || document.body.scrollLeft + || 0; + this.deltaY = window.pageYOffset + || document.documentElement.scrollTop + || document.body.scrollTop + || 0; + }, + + realOffset: function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.scrollTop || 0; + valueL += element.scrollLeft || 0; + element = element.parentNode; + } while (element); + return [valueL, valueT]; + }, + + cumulativeOffset: function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + element = element.offsetParent; + } while (element); + return [valueL, valueT]; + }, + + positionedOffset: function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + element = element.offsetParent; + if (element) { + p = Element.getStyle(element, 'position'); + if (p == 'relative' || p == 'absolute') break; + } + } while (element); + return [valueL, valueT]; + }, + + offsetParent: function(element) { + if (element.offsetParent) return element.offsetParent; + if (element == document.body) return element; + + while ((element = element.parentNode) && element != document.body) + if (Element.getStyle(element, 'position') != 'static') + return element; + + return document.body; + }, + + // caches x/y coordinate pair to use with overlap + within: function(element, x, y) { + if (this.includeScrollOffsets) + return this.withinIncludingScrolloffsets(element, x, y); + this.xcomp = x; + this.ycomp = y; + this.offset = this.cumulativeOffset(element); + + return (y >= this.offset[1] && + y < this.offset[1] + element.offsetHeight && + x >= this.offset[0] && + x < this.offset[0] + element.offsetWidth); + }, + + withinIncludingScrolloffsets: function(element, x, y) { + var offsetcache = this.realOffset(element); + + this.xcomp = x + offsetcache[0] - this.deltaX; + this.ycomp = y + offsetcache[1] - this.deltaY; + this.offset = this.cumulativeOffset(element); + + return (this.ycomp >= this.offset[1] && + this.ycomp < this.offset[1] + element.offsetHeight && + this.xcomp >= this.offset[0] && + this.xcomp < this.offset[0] + element.offsetWidth); + }, + + // within must be called directly before + overlap: function(mode, element) { + if (!mode) return 0; + if (mode == 'vertical') + return ((this.offset[1] + element.offsetHeight) - this.ycomp) / + element.offsetHeight; + if (mode == 'horizontal') + return ((this.offset[0] + element.offsetWidth) - this.xcomp) / + element.offsetWidth; + }, + + clone: function(source, target) { + source = $(source); + target = $(target); + target.style.position = 'absolute'; + var offsets = this.cumulativeOffset(source); + target.style.top = offsets[1] + 'px'; + target.style.left = offsets[0] + 'px'; + target.style.width = source.offsetWidth + 'px'; + target.style.height = source.offsetHeight + 'px'; + }, + + page: function(forElement) { + var valueT = 0, valueL = 0; + + var element = forElement; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + + // Safari fix + if (element.offsetParent==document.body) + if (Element.getStyle(element,'position')=='absolute') break; + + } while (element = element.offsetParent); + + element = forElement; + do { + valueT -= element.scrollTop || 0; + valueL -= element.scrollLeft || 0; + } while (element = element.parentNode); + + return [valueL, valueT]; + }, + + clone: function(source, target) { + var options = Object.extend({ + setLeft: true, + setTop: true, + setWidth: true, + setHeight: true, + offsetTop: 0, + offsetLeft: 0 + }, arguments[2] || {}) + + // find page position of source + source = $(source); + var p = Position.page(source); + + // find coordinate system to use + target = $(target); + var delta = [0, 0]; + var parent = null; + // delta [0,0] will do fine with position: fixed elements, + // position:absolute needs offsetParent deltas + if (Element.getStyle(target,'position') == 'absolute') { + parent = Position.offsetParent(target); + delta = Position.page(parent); + } + + // correct by body offsets (fixes Safari) + if (parent == document.body) { + delta[0] -= document.body.offsetLeft; + delta[1] -= document.body.offsetTop; + } + + // set position + if(options.setLeft) target.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px'; + if(options.setTop) target.style.top = (p[1] - delta[1] + options.offsetTop) + 'px'; + if(options.setWidth) target.style.width = source.offsetWidth + 'px'; + if(options.setHeight) target.style.height = source.offsetHeight + 'px'; + }, + + absolutize: function(element) { + element = $(element); + if (element.style.position == 'absolute') return; + Position.prepare(); + + var offsets = Position.positionedOffset(element); + var top = offsets[1]; + var left = offsets[0]; + var width = element.clientWidth; + var height = element.clientHeight; + + element._originalLeft = left - parseFloat(element.style.left || 0); + element._originalTop = top - parseFloat(element.style.top || 0); + element._originalWidth = element.style.width; + element._originalHeight = element.style.height; + + element.style.position = 'absolute'; + element.style.top = top + 'px';; + element.style.left = left + 'px';; + element.style.width = width + 'px';; + element.style.height = height + 'px';; + }, + + relativize: function(element) { + element = $(element); + if (element.style.position == 'relative') return; + Position.prepare(); + + element.style.position = 'relative'; + var top = parseFloat(element.style.top || 0) - (element._originalTop || 0); + var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0); + + element.style.top = top + 'px'; + element.style.left = left + 'px'; + element.style.height = element._originalHeight; + element.style.width = element._originalWidth; + } +} + +// Safari returns margins on body which is incorrect if the child is absolutely +// positioned. For performance reasons, redefine Position.cumulativeOffset for +// KHTML/WebKit only. +if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) { + Position.cumulativeOffset = function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + if (element.offsetParent == document.body) + if (Element.getStyle(element, 'position') == 'absolute') break; + + element = element.offsetParent; + } while (element); + + return [valueL, valueT]; + } +} + + +function indexOf(array, object) +{ + for (var i = 0; i < array.length; i++) + if (array[i] == object) return i; + return -1; +} + +function without(array,value) { + var res = Array(); + for( var i = 0 ; i < array.length; i++) + { + if (array[i] != value) res.push(array[i]); + } + return res; +} Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-06-28 13:18:35 UTC (rev 632) +++ trunk/src/phpfreechat.class.php 2006-06-28 14:27:42 UTC (rev 633) @@ -91,7 +91,7 @@ $output .= "<script type=\"text/javascript\" src=\"".$js_path."/md5.js\"></script>"; $output .= "<script type=\"text/javascript\" src=\"".$js_path."/cookie.js\"></script>"; $output .= "<script type=\"text/javascript\" src=\"".$js_path."/image_preloader.js\"></script>"; - $output .= "<script type=\"text/javascript\" src=\"".$js_path."/prototype.js\"></script>"; + $output .= "<script type=\"text/javascript\" src=\"".$js_path."/myprototype.js\"></script>"; $output .= "<script type=\"text/javascript\" src=\"".$js_path."/regex.js\"></script>"; $output .= "<script type=\"text/javascript\" src=\"".$js_path."/utf8.js\"></script>"; Modified: trunk/themes/default/templates/pfcclient.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcclient.js.tpl.php 2006-06-28 13:18:35 UTC (rev 632) +++ trunk/themes/default/templates/pfcclient.js.tpl.php 2006-06-28 14:27:42 UTC (rev 633) @@ -241,9 +241,9 @@ // synchronize the privmsg client arrays index = -1; - index = this.privmsgids.indexOf(tabid); - this.privmsgids = this.privmsgids.without(tabid); - this.privmsgs = this.privmsgs.without(this.privmsgs[index]); + index = indexOf(this.privmsgids, tabid); + this.privmsgids = without(this.privmsgids, tabid); + this.privmsgs = without(this.privmsgs, this.privmsgs[index]); } } @@ -412,7 +412,7 @@ for (var i=0; i<ul_online.childNodes.length; i++) { var nick = ul_online.childNodes[i].innerHTML; - if (nick.indexOf(nick_src) == 0) + if (indexOf(nick, nick_src) == 0) w.value = w.value.replace(nick_src, nick); } } @@ -807,8 +807,11 @@ span.pfc_nick = nicks[i]; span.onclick = function(){pfc.insert_text(this.pfc_nick+", ",""); return false;} span.appendChild(document.createTextNode(nicks[i])); - Element.addClassName(span, '<?php echo $prefix; ?>nickmarker'); - Element.addClassName(span, '<?php echo $prefix; ?>nick_'+ hex_md5(_to_utf8(nicks[i]))); + span.setAttribute('class', '<?php echo $prefix; ?>nickmarker <?php echo $prefix; ?>nick_'+ hex_md5(_to_utf8(nicks[i]))); + span.setAttribute('className', '<?php echo $prefix; ?>nickmarker <?php echo $prefix; ?>nick_'+ hex_md5(_to_utf8(nicks[i]))); // for IE6 + + // Element.addClassName(span, '<?php echo $prefix; ?>nickmarker'); + // Element.addClassName(span, '<?php echo $prefix; ?>nick_'+ hex_md5(_to_utf8(nicks[i]))); nobr.appendChild(span); li.appendChild(nobr); li.style.borderBottom = '1px solid #AAA'; @@ -1450,12 +1453,16 @@ if (!this.showwhosonline) { style['width'] = '100%'; - Element.setStyle(chatdiv, style); + chatdiv.setAttribute('style', 'width:100%'); + chatdiv.setAttribute('cssText', 'width:100%'); // for IE6 + // Element.setStyle(chatdiv, style); } else { style['width'] = ''; - Element.setStyle(chatdiv, style); + chatdiv.setAttribute('style', ''); + chatdiv.setAttribute('cssText', ''); // for IE6 + // Element.setStyle(chatdiv, style); } } } Modified: trunk/themes/default/templates/pfcgui.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcgui.js.tpl.php 2006-06-28 13:18:35 UTC (rev 632) +++ trunk/themes/default/templates/pfcgui.js.tpl.php 2006-06-28 14:27:42 UTC (rev 633) @@ -39,7 +39,14 @@ isCreated: function(tabid) { - return (this.tabids.indexOf(tabid) >= 0); + /* + for (var i = 0; i < this.tabids.length ; i++) + { + if (this.tabids[i] == tabid) return true; + } + return false; + */ + return (indexOf(this.tabids, tabid) >= 0); }, setTabById: function(tabid) @@ -60,7 +67,9 @@ if (this.tabids[i] == tabid) { // select the tab - Element.addClassName(tabtitle, 'selected'); + tabtitle.setAttribute('class', 'selected'); + tabtitle.setAttribute('className', 'selected'); // for IE6 + //Element.addClassName(tabtitle, 'selected'); tab_to_show = tabcontent; this.current_tab = this.tabs[i]; this.current_tab_id = tabid; @@ -68,7 +77,9 @@ else { // unselect the tab - Element.removeClassName(tabtitle, 'selected'); + tabtitle.setAttribute('class', ''); + tabtitle.setAttribute('className', ''); // for IE6 + //Element.removeClassName(tabtitle, 'selected'); tabcontent.style.display = 'none'; } } @@ -107,7 +118,10 @@ // if the chat content doesn't exists yet, just create a cached one cc = document.createElement('div'); cc.setAttribute('id', '<?php echo $prefix; ?>chat_'+tabid); - Element.addClassName(cc, '<?php echo $prefix; ?>chat'); + cc.setAttribute('class', '<?php echo $prefix; ?>chat'); + cc.setAttribute('className', '<?php echo $prefix; ?>chat'); // for IE6 + + // Element.addClassName(cc, '<?php echo $prefix; ?>chat'); cc.style.display = "block"; // needed by IE6 to show the online div at startup (first loaded page) // cc.style.marginLeft = "5px"; @@ -122,7 +136,9 @@ oc = document.createElement('div'); oc.setAttribute('id', '<?php echo $prefix; ?>online_'+tabid); - Element.addClassName(oc, '<?php echo $prefix; ?>online'); + oc.setAttribute('class', '<?php echo $prefix; ?>online'); + oc.setAttribute('className', '<?php echo $prefix; ?>online'); // for IE6 + //Element.addClassName(oc, '<?php echo $prefix; ?>online'); // I set the border style here because seting it in the CSS is not taken in account // oc.style.borderLeft = "1px solid #555"; oc.style.display = "block"; // needed by IE6 to show the online div at startup (first loaded page) @@ -151,12 +167,12 @@ div_chat.innerHTML = ''; // remove the tab from the list - var tabpos = this.tabids.indexOf(tabid); + var tabpos = indexOf(this.tabids, tabid); var name = this.tabs[tabpos]; - this.tabids = this.tabids.without(this.tabids[tabpos]); - this.tabs = this.tabs.without(this.tabs[tabpos]); - this.tabtypes = this.tabtypes.without(this.tabtypes[tabpos]); - tabpos = this.tabids.indexOf(this.getTabId()); + this.tabids = without(this.tabids, this.tabids[tabpos]); + this.tabs = without(this.tabs, this.tabs[tabpos]); + this.tabtypes = without(this.tabtypes, this.tabtypes[tabpos]); + tabpos = indexOf(this.tabids, this.getTabId()); if (tabpos<0) tabpos = 0; this.setTabById(this.tabids[tabpos]); return name; @@ -182,13 +198,15 @@ // do not create twice a the same tab if (this.isCreated(tabid)) return; - + // var tabid = hex_md5(_to_utf8(name)); //alert(name+'='+tabid); this.tabs.push(name); this.tabids.push(tabid); this.tabtypes.push(type); + //alert(this.tabs.toString()); + var li_title = document.createElement('li'); li_title.setAttribute('id', '<?php echo $prefix; ?>channel_title'+tabid); @@ -202,7 +220,9 @@ if (type == 'pv') img.setAttribute('src', '<?php echo $c->getFileUrlFromTheme('images/pv.gif'); ?>'); var a1 = document.createElement('a'); - Element.addClassName(a1, '<?php echo $prefix; ?>tabtitle'); + // Element.addClassName(a1, '<?php echo $prefix; ?>tabtitle'); + a1.setAttribute('class', '<?php echo $prefix; ?>tabtitle'); + a1.setAttribute('className', '<?php echo $prefix; ?>tabtitle'); // for IE6 a1.appendChild(img); a1.appendChild(document.createTextNode(name)); a1.setAttribute('href', '#'); @@ -218,7 +238,9 @@ } a2.alt = this.i18n._('Close this tab'); a2.title = a2.alt; - Element.addClassName(a2, '<?php echo $prefix; ?>tabclose'); + // Element.addClassName(a2, '<?php echo $prefix; ?>tabclose'); + a2.setAttribute('class', '<?php echo $prefix; ?>tabclose'); + a2.setAttribute('className', '<?php echo $prefix; ?>tabclose'); // for IE6 var img = document.createElement('img'); img.setAttribute('src', '<?php echo $c->getFileUrlFromTheme('images/tab_remove.gif'); ?>'); a2.appendChild(img); @@ -226,7 +248,9 @@ var div_content = document.createElement('div'); div_content.setAttribute('id', '<?php echo $prefix; ?>channel_content'+tabid); - Element.addClassName(div_content, '<?php echo $prefix; ?>content'); + // Element.addClassName(div_content, '<?php echo $prefix; ?>content'); + div_content.setAttribute('class', '<?php echo $prefix; ?>content'); + div_content.setAttribute('className', '<?php echo $prefix; ?>content'); // for IE6 div_content.style.display = 'none'; var div_chat = this.getChatContentFromTabId(tabid); @@ -245,7 +269,7 @@ */ notifyTab: function(tabid) { - var tabpos = this.tabids.indexOf(tabid); + var tabpos = indexOf(this.tabids, tabid); var tabtype = this.tabtypes[tabpos]; var img = $('<?php echo $prefix; ?>tabimg'+tabid); if (img) @@ -262,7 +286,7 @@ */ unnotifyTab: function(tabid) { - var tabpos = this.tabids.indexOf(tabid); + var tabpos = indexOf(this.tabids, tabid); var tabtype = this.tabtypes[tabpos]; var img = $('<?php echo $prefix; ?>tabimg'+tabid); if (img) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-30 16:28:13
|
Revision: 635 Author: kerphi Date: 2006-06-30 09:28:03 -0700 (Fri, 30 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=635&view=rev Log Message: ----------- New proxy: a censor proxy used to filter bad words in posted messages Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php Added Paths: ----------- trunk/src/proxys/censor.class.php Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-06-28 19:59:12 UTC (rev 634) +++ trunk/src/pfcglobalconfig.class.php 2006-06-30 16:28:03 UTC (rev 635) @@ -38,9 +38,10 @@ var $admins = array("admin" => ""); // nicknames is the key, password is the value // these parameters are static (cached) - var $proxys = array("auth", "noflood"); + var $proxys = array("auth", "noflood", "censor"); var $proxys_cfg = array("auth" => array(), - "noflood" => array("limit"=>10,"delay"=>5)); + "noflood" => array("limit"=>10,"delay"=>5), + "censor" => array("words"=>array("fuck","sex","bitch"),"replaceby"=>"*")); var $title = ""; // default is _pfc("My Chat") var $channels = array(); // the default joined channels when opening the chat var $frozen_channels = array(); // by default allow users to create there own channels Added: trunk/src/proxys/censor.class.php =================================================================== --- trunk/src/proxys/censor.class.php (rev 0) +++ trunk/src/proxys/censor.class.php 2006-06-30 16:28:03 UTC (rev 635) @@ -0,0 +1,59 @@ +<?php +/** + * censor.class.php + * + * Copyright © 2006 Stephane Gully <ste...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + */ +require_once dirname(__FILE__)."/../pfci18n.class.php"; +require_once dirname(__FILE__)."/../pfcuserconfig.class.php"; +require_once dirname(__FILE__)."/../pfcproxycommand.class.php"; + +/** + * pfcProxyCommand_censor + * this proxy will filter bad words from messages + * @author Stephane Gully <ste...@gm...> + */ +class pfcProxyCommand_censor extends pfcProxyCommand +{ + function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + { + $c =& $this->c; + $u =& $this->u; + + $cmdtocheck = array("send", "nick", "me"); + if ( in_array($this->name, $cmdtocheck) ) + { + $words = $c->proxys_cfg[$this->proxyname]["words"]; + $replaceby = $c->proxys_cfg[$this->proxyname]["replaceby"]; + + $patterns = array(); + $replacements = array(); + foreach($words as $w) + { + $patterns[] = "/".preg_quote($w)."/i"; + $replacements[] = str_repeat($replaceby,strlen($w)); + } + $param = preg_replace($patterns, $replacements, $param); + } + + // forward the command to the next proxy or to the final command + $this->next->run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + } +} + +?> \ 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...> - 2006-06-30 17:04:06
|
Revision: 636 Author: kerphi Date: 2006-06-30 10:02:35 -0700 (Fri, 30 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=636&view=rev Log Message: ----------- Work in progress: create an API to query from external scripts the chat data (who is online, last posted messages) Modified Paths: -------------- trunk/demo/demo31_show_who_is_online-whoisonline.php trunk/demo/demo32_show_last_messages-config.php trunk/demo/demo32_show_last_messages-showlastmsg.php trunk/demo/index.php trunk/src/pfcinfo.class.php Modified: trunk/demo/demo31_show_who_is_online-whoisonline.php =================================================================== --- trunk/demo/demo31_show_who_is_online-whoisonline.php 2006-06-30 16:28:03 UTC (rev 635) +++ trunk/demo/demo31_show_who_is_online-whoisonline.php 2006-06-30 17:02:35 UTC (rev 636) @@ -2,7 +2,9 @@ require_once dirname(__FILE__)."/../src/pfcinfo.class.php"; $info = new pfcInfo( md5("Whois online demo") ); -$users = $info->getOnlineNick(); +// NULL is used to get all the connected users, but you can specify +// a channel name to get only the connected user on a specific channel +$users = $info->getOnlineNick(NULL); echo "<h1>A demo which explains how to get the connected users list</h1>"; @@ -10,10 +12,10 @@ $info = ""; $nb_users = count($users); if ($nb_users <= 1) - $info = "<strong>%d</strong> user is connected to the <strong>'%s'</strong> channel !"; + $info = "<strong>%d</strong> user is connected to the server !"; else - $info = "<strong>%d</strong> users are connected to the <strong>'%s'</strong> channel !"; -echo "<p>".sprintf($info, $nb_users, "")."</p>"; + $info = "<strong>%d</strong> users are connected to the server !"; +echo "<p>".sprintf($info, $nb_users)."</p>"; echo "<p>Here is the nicknames' list:</p>"; echo "<ul>"; Modified: trunk/demo/demo32_show_last_messages-config.php =================================================================== --- trunk/demo/demo32_show_last_messages-config.php 2006-06-30 16:28:03 UTC (rev 635) +++ trunk/demo/demo32_show_last_messages-config.php 2006-06-30 17:02:35 UTC (rev 636) @@ -1,9 +1,10 @@ <?php require_once dirname(__FILE__)."/../src/phpfreechat.class.php"; -$params["serverid"] = md5(__FILE__); // calculate a unique id for this chat $params["title"] = "Show last posted messages channel"; -$params["max_msg"] = 1; +$params["serverid"] = md5($params["title"]); // calculate a unique id for this chat +$params["max_msg"] = 20; +$params["channels"] = "channel1"; $pfc_config =& pfcGlobalConfig::Instance( $params ); -?> +?> \ No newline at end of file Modified: trunk/demo/demo32_show_last_messages-showlastmsg.php =================================================================== --- trunk/demo/demo32_show_last_messages-showlastmsg.php 2006-06-30 16:28:03 UTC (rev 635) +++ trunk/demo/demo32_show_last_messages-showlastmsg.php 2006-06-30 17:02:35 UTC (rev 636) @@ -1,8 +1,9 @@ <?php require_once dirname(__FILE__)."/../src/pfcinfo.class.php"; -$info = new pfcInfo( md5("Show last messages demo") ); -$lastmsg_raw = $info->getLastMsg(10); +$info = new pfcInfo( md5("Show last posted messages channel") ); +$lastmsg_raw = $info->getLastMsg("channel1", 10); +print_r($lastmsg_raw); echo "<h1>A demo which explains how to get the last posted messages</h1>"; Modified: trunk/demo/index.php =================================================================== --- trunk/demo/index.php 2006-06-30 16:28:03 UTC (rev 635) +++ trunk/demo/index.php 2006-06-30 17:02:35 UTC (rev 636) @@ -95,12 +95,12 @@ <li><a href="demo21_with_hardcoded_urls.php">demo21 - with hardcoded url: data_public_url, client_script_url ... (interesting for strange server configuration)</a></li> <li><a href="demo27_customized_command.php">demo27 - a customized command (/roll)</a></li> <li><a href="demo34_add_a_link_on_nicknames.php">demo34 - Shows how to add a link on the nicknames list</a></li> -<!-- + <li><a href="demo31_show_who_is_online-chat.php">demo31 - demo which show how to get the connected users list (chat script)</a></li> <li><a href="demo31_show_who_is_online-whoisonline.php">demo31 - demo which show how to get the connected users list (whoisonline script)</a></li> <li><a href="demo32_show_last_messages-chat.php">demo32 - demo which show how to get the last posted messages (chat script)</a></li> <li><a href="demo32_show_last_messages-showlastmsg.php">demo32 - demo which show how to get the last posted messages (showlastmsg script)</a></li> ---> + <li><a href="demo35_shared_memory.php">demo35 - demo which show how to use the shared memory container</a></li> <li><a href="demo43_change_the_nicknames_colors.php">demo43 - demo which show how to change the nicknames automatic colors</a></li> </ul> Modified: trunk/src/pfcinfo.class.php =================================================================== --- trunk/src/pfcinfo.class.php 2006-06-30 16:28:03 UTC (rev 635) +++ trunk/src/pfcinfo.class.php 2006-06-30 17:02:35 UTC (rev 636) @@ -14,18 +14,27 @@ $this->$key = $val; } - function getOnlineNick() + /** + * @return array(string) a list of online nicknames + */ + function getOnlineNick($channel = NULL) { $container =& $this->getContainerInstance(); - $users = $container->getOnlineNick(); + $res = $container->getOnlineNick($channel); + $users = array(); + if (isset($res["nickid"])) + foreach($res["nickid"] as $nickid) + $users[] = $container->getNickname($nickid); return $users; } - function getLastMsg($nb) + function getLastMsg($channel, $nb) { $container =& $this->getContainerInstance(); - $lastmsg_id = $container->getLastMsgId(); - $lastmsg_raw = $container->readNewMsg($lastmsg_id-10); + $lastmsg_id = $container->getLastId($channel); + echo $lastmsg_id; + die(); + $lastmsg_raw = $container->read($channel, $lastmsg_id-10); return $lastmsg_raw; } } 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:17:25
|
Revision: 637 Author: kerphi Date: 2006-07-03 06:17:20 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=637&view=rev Log Message: ----------- Change the default directory creation rights to 755 in order to allow incorrect configured web servers to access to these directories. Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php trunk/src/pfctools.php Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-06-30 17:02:35 UTC (rev 636) +++ trunk/src/pfcglobalconfig.class.php 2006-07-03 13:17:20 UTC (rev 637) @@ -210,15 +210,15 @@ $dir2 = $this->data_private_path."/copy_r2"; $file2 = $dir2."/dummy"; // create a dummy directory - mkdir($dir1); + @mkdir($dir1); // check the directory exists if (!file_exists($dir1) || !is_dir($dir1)) $copy_r_ok = false; // create a dummy file - touch($file1); + @touch($file1); // check the file exists if (!file_exists($file1)) $copy_r_ok = false; // copy_r the dummy dir - copy_r($dir1,$dir2); + @copy_r($dir1,$dir2); // check the directory exists if (!file_exists($dir2) || !is_dir($dir2)) $copy_r_ok = false; // check the file exists @@ -228,8 +228,8 @@ // try to remove recursively the directory $rm_r_ok = true; - rm_r($dir2); - rm_r($dir1); + @rm_r($dir2); + @rm_r($dir1); // check the directory doesn't exists if (file_exists($dir1) || file_exists($dir2)) $rm_r_ok = false; // check the file doesn't exists Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2006-06-30 17:02:35 UTC (rev 636) +++ trunk/src/pfctools.php 2006-07-03 13:17:20 UTC (rev 637) @@ -119,13 +119,14 @@ 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); } /** @@ -137,7 +138,7 @@ * @param string $dest Destination path * @return bool Returns TRUE on success, FALSE on failure */ -function copy_r($source, $dest, $modedir = 0700, $modefile = 0644) +function copy_r($source, $dest, $modedir = 0755, $modefile = 0644) { // Simple copy for a file if (is_file($source)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-07-04 15:34:08
|
Revision: 641 Author: kerphi Date: 2006-07-04 08:33:50 -0700 (Tue, 04 Jul 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=641&view=rev Log Message: ----------- Finish the work on the API used to query the chat infos from external scripts Modified Paths: -------------- trunk/demo/demo32_show_last_messages-chat.php trunk/demo/demo32_show_last_messages-config.php trunk/demo/demo32_show_last_messages-showlastmsg.php trunk/src/pfcglobalconfig.class.php trunk/src/pfcinfo.class.php Modified: trunk/demo/demo32_show_last_messages-chat.php =================================================================== --- trunk/demo/demo32_show_last_messages-chat.php 2006-07-03 16:43:41 UTC (rev 640) +++ trunk/demo/demo32_show_last_messages-chat.php 2006-07-04 15:33:50 UTC (rev 641) @@ -1,10 +1,8 @@ <?php require_once dirname(__FILE__)."/../src/phpfreechat.class.php"; -$params["serverid"] = md5("Show last messages demo"); // calculate a unique id for this chat -$params["title"] = "Show last posted messages channel"; -//$params["max_msg"] = 1; -$chat = new phpFreeChat($params); +require_once dirname(__FILE__)."/demo32_show_last_messages-config.php"; +$chat = new phpFreeChat($pfc_config); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> @@ -40,4 +38,4 @@ ?> </body> -</html> +</html> \ No newline at end of file Modified: trunk/demo/demo32_show_last_messages-config.php =================================================================== --- trunk/demo/demo32_show_last_messages-config.php 2006-07-03 16:43:41 UTC (rev 640) +++ trunk/demo/demo32_show_last_messages-config.php 2006-07-04 15:33:50 UTC (rev 641) @@ -4,7 +4,7 @@ $params["title"] = "Show last posted messages channel"; $params["serverid"] = md5($params["title"]); // calculate a unique id for this chat $params["max_msg"] = 20; -$params["channels"] = "channel1"; +$params["channels"] = array("channel1"); $pfc_config =& pfcGlobalConfig::Instance( $params ); ?> \ No newline at end of file Modified: trunk/demo/demo32_show_last_messages-showlastmsg.php =================================================================== --- trunk/demo/demo32_show_last_messages-showlastmsg.php 2006-07-03 16:43:41 UTC (rev 640) +++ trunk/demo/demo32_show_last_messages-showlastmsg.php 2006-07-04 15:33:50 UTC (rev 641) @@ -1,27 +1,32 @@ <?php require_once dirname(__FILE__)."/../src/pfcinfo.class.php"; -$info = new pfcInfo( md5("Show last posted messages channel") ); -$lastmsg_raw = $info->getLastMsg("channel1", 10); -print_r($lastmsg_raw); +$pfcinfo = new pfcInfo( md5("Show last posted messages channel") ); +$errors = $pfcinfo->getErrors(); +if (count($errors)) +{ + foreach($errors as $e) + echo $e; +} +$lastmsg_raw = $pfcinfo->getLastMsg("channel1", 10); -echo "<h1>A demo which explains how to get the last posted messages</h1>"; +echo "<h1>A demo which explains how to get the last posted messages on a given channel</h1>"; echo '<div style="margin: auto; width: 70%; border: 1px solid red; background-color: #FDD; padding: 1em;">'; -$nbmsg = count($lastmsg_raw["messages"]); -$info = "<strong>%d</strong> last messages on <strong>'%s'</strong> channel are:"; -echo "<p>".sprintf($info, $nbmsg, "")."</p>"; +$nbmsg = count($lastmsg_raw["data"]); +$info = "<strong>%d</strong> last messages on <strong>'%s'</strong> are:"; +echo "<p>".sprintf($info, $nbmsg, "channel1")."</p>"; $bg = 1; echo '<table style="margin: auto; width: 70%; border: 1px solid red; background-color: #FEE;">'; // format messages to a readable string // be carreful ! this format will change in future -foreach($lastmsg_raw["messages"] as $m) +foreach($lastmsg_raw["data"] as $m) { - echo '<tr style="background-color: '.($bg == 1 ? "#FFE;" : "#EEF;").'">'; - echo '<td>'.$m[2].'</td>'; - echo '<td style="color:#F75; text-align: right;">'.$m[3].'</td>'; - echo "<td>".$m[4]."</td>"; + echo '<tr style="background-color:'.($bg == 1 ? "#FFE;" : "#EEF;").'">'; + echo '<td style="width:100px;">'.$m["date"].'</td>'; + echo '<td style="width:80px;color:#F55;text-align:right;font-weight:bold;">'.$m["sender"].'</td>'; + echo '<td>'.$m["param"].'</td>'; echo "</tr>"; if ($bg == 1) $bg = 2; Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-07-03 16:43:41 UTC (rev 640) +++ trunk/src/pfcglobalconfig.class.php 2006-07-04 15:33:50 UTC (rev 641) @@ -103,6 +103,21 @@ // setup the local for translated messages pfcI18N::Init(isset($params["language"]) ? $params["language"] : ""); + // check the serverid is really defined + if (!isset($params["serverid"])) + $this->errors[] = _pfc("'%s' parameter is mandatory by default use '%s' value", "serverid", "md5(__FILE__)"); + $this->serverid = $params["serverid"]; + + // _getCacheFile needs data_private_path + if (!isset($params["data_private_path"])) + $this->data_private_path = dirname(__FILE__)."/../data/private"; + else + $this->data_private_path = $params["data_private_path"]; + if (!isset($params["data_public_path"])) + $this->data_public_path = dirname(__FILE__)."/../data/public"; + else + $this->data_public_path = $params["data_public_path"]; + // check if a cached configuration allready exists // don't load parameters if the cache exists $cachefile = $this->_getCacheFile(); @@ -136,9 +151,6 @@ else $this->$k = $v; } - - if ($this->data_private_path == "") $this->data_private_path = dirname(__FILE__)."/../data/private"; - if ($this->data_public_path == "") $this->data_public_path = dirname(__FILE__)."/../data/public"; } // now load or save the configuration in the cache @@ -325,10 +337,6 @@ // load debug url $this->debugurl = relativePath($this->client_script_path, dirname(__FILE__)."/../debug"); - // check the serverid is really defined - if ($this->serverid == "") - $this->errors[] = _pfc("'%s' parameter is mandatory by default use '%s' value", "serverid", "md5(__FILE__)"); - // check if channels parameter is a strings array if (!is_array($this->channels)) $this->errors[] = _pfc("'%s' parameter must be an array", "channels"); @@ -414,9 +422,11 @@ return $this->serverid; } - function _getCacheFile() + function _getCacheFile($serverid = "", $data_private_path = "") { - return $this->data_private_path."/cache/pfcglobalconfig_".$this->getId(); + if ($serverid == "") $serverid = $this->getId(); + if ($data_private_path == "") $data_private_path = $this->data_private_path; + return $data_private_path."/cache/pfcglobalconfig_".$serverid; } function destroyCache() Modified: trunk/src/pfcinfo.class.php =================================================================== --- trunk/src/pfcinfo.class.php 2006-07-03 16:43:41 UTC (rev 640) +++ trunk/src/pfcinfo.class.php 2006-07-04 15:33:50 UTC (rev 641) @@ -1,20 +1,41 @@ <?php require_once dirname(__FILE__)."/pfcglobalconfig.class.php"; +require_once dirname(__FILE__)."/pfci18n.class.php"; +require_once dirname(__FILE__)."/commands/join.class.php"; class pfcInfo extends pfcGlobalConfig { var $container; + var $errors = array(); - function pfcInfo( $serverid ) + function pfcInfo( $serverid, $data_private_path = "" ) { - $cachefile = dirname(__FILE__)."/../data/private/cache/pfcglobalconfig_".$serverid; - $pfc_configvar = unserialize(file_get_contents($cachefile)); - foreach($pfc_configvar as $key => $val) - $this->$key = $val; + // check if the cache allready exists + // if it doesn't exists, just stop the process + // because we can't initialize the chat from the external API + if ($data_private_path == "") $data_private_path = dirname(__FILE__)."/../data/private"; + $cachefile = $this->_getCacheFile( $serverid, $data_private_path ); + if (!file_exists($cachefile)) + { + $this->errors[] = _pfc("Error: the cached config file doesn't exists"); + return; + } + // then intitialize the pfcglobalconfig + $params["serverid"] = $serverid; + $params["data_private_path"] = $data_private_path; + pfcGlobalConfig::pfcGlobalConfig($params); } - + /** + * @return array(string) a list of errors + */ + function getErrors() + { + return $this->errors; + } + + /** * @return array(string) a list of online nicknames */ function getOnlineNick($channel = NULL) @@ -30,13 +51,15 @@ function getLastMsg($channel, $nb) { - $container =& $this->getContainerInstance(); + // to get the channel recipient name + // @todo must use another function to get a private message last messages + $channel = pfcCommand_join::GetRecipient($channel); + + $container =& $this->getContainerInstance(); $lastmsg_id = $container->getLastId($channel); - echo $lastmsg_id; - die(); $lastmsg_raw = $container->read($channel, $lastmsg_id-10); return $lastmsg_raw; } } -?> +?> \ 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...> - 2006-07-07 11:45:20
|
Revision: 652 Author: kerphi Date: 2006-07-07 04:45:12 -0700 (Fri, 07 Jul 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=652&view=rev Log Message: ----------- New proxy : the lock proxy can be used to lock the chat and redirect all the online users to a given url (use the $params["islocked"] and $params["lockurl"] parameters). Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php Added Paths: ----------- trunk/src/proxys/lock.class.php Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-07-07 07:48:48 UTC (rev 651) +++ trunk/src/pfcglobalconfig.class.php 2006-07-07 11:45:12 UTC (rev 652) @@ -36,9 +36,12 @@ var $nick = ""; // the initial nickname ("" means the user will be queried) var $isadmin = false; var $admins = array("admin" => ""); // nicknames is the key, password is the value + + var $islocked = false; // set this parameter to true to lock the chat for all users + var $lockurl = "http://www.phpfreechat.net"; // this is the url where the users must be redirected when the chat is locked // these parameters are static (cached) - var $proxys = array("auth", "noflood", "censor"); + var $proxys = array("lock", "auth", "noflood", "censor"); var $proxys_cfg = array("auth" => array(), "noflood" => array("limit"=>10,"delay"=>5), "censor" => array("words"=>array("fuck","sex","bitch"),"replaceby"=>"*")); @@ -459,9 +462,10 @@ $pfc_configvar = unserialize(file_get_contents($cachefile)); foreach($pfc_configvar as $key => $val) { - // the 'nick' and 'isadmin' are dynamic parameters, it must not be cached + // the 'nick', 'isadmin', and 'islocked' are dynamic parameters, it must not be cached if ($key != "nick" && - $key != "isadmin") + $key != "isadmin" && + $key != "islocked" ) $this->$key = $val; } Added: trunk/src/proxys/lock.class.php =================================================================== --- trunk/src/proxys/lock.class.php (rev 0) +++ trunk/src/proxys/lock.class.php 2006-07-07 11:45:12 UTC (rev 652) @@ -0,0 +1,51 @@ +<?php +/** + * lock.class.php + * + * Copyright © 2006 Stephane Gully <ste...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + */ +require_once dirname(__FILE__)."/../pfci18n.class.php"; +require_once dirname(__FILE__)."/../pfcuserconfig.class.php"; +require_once dirname(__FILE__)."/../pfcproxycommand.class.php"; + +/** + * pfcProxyCommand_lock + * if the chat is locked, redirect users to a given url + * @author Stephane Gully <ste...@gm...> + */ +class pfcProxyCommand_lock extends pfcProxyCommand +{ + function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + { + $c =& $this->c; + $u =& $this->u; + + // check if the chat is locked + if ($c->islocked) + { + $xml_reponse->addRedirect($c->lockurl); + } + else + { + // forward the command to the next proxy or to the final command + $this->next->run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + } + } +} + +?> \ 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...> - 2006-07-17 15:21:07
|
Revision: 658 Author: kerphi Date: 2006-07-17 08:20:41 -0700 (Mon, 17 Jul 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=658&view=rev Log Message: ----------- Bug fix: the /identify command was broken Modified Paths: -------------- trunk/src/commands/identify.class.php trunk/src/pfcglobalconfig.class.php Modified: trunk/src/commands/identify.class.php =================================================================== --- trunk/src/commands/identify.class.php 2006-07-17 14:57:01 UTC (rev 657) +++ trunk/src/commands/identify.class.php 2006-07-17 15:20:41 UTC (rev 658) @@ -38,14 +38,15 @@ $password = trim($param); $isadmin = false; - - // @todo simplify the search in the admins config array using a native php function (array_search?) - foreach($c->admins as $a_nick => $a_pass) - { - if ($a_nick == $sender && $a_pass == $password) - $isadmin = true; - } +// $xml_reponse->addScript("alert('sender=".$sender."');"); +// $xml_reponse->addScript("alert('password=".$password."');"); +// $xml_reponse->addScript("alert('admins=".var_export($c->admins, true)."');"); + + if( isset($c->admins[$sender]) && + $c->admins[$sender] == $password ) + $isadmin = true; + $msg = ""; if ($isadmin) { Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-07-17 14:57:01 UTC (rev 657) +++ trunk/src/pfcglobalconfig.class.php 2006-07-17 15:20:41 UTC (rev 658) @@ -35,7 +35,7 @@ // these parameters are dynamic (not cached) var $nick = ""; // the initial nickname ("" means the user will be queried) var $isadmin = false; - var $admins = array("admin" => ""); // nicknames is the key, password is the value + var $admins = array("admin" => ""); // the key is the nickname, the value is the password var $islocked = false; // set this parameter to true to lock the chat for all users var $lockurl = "http://www.phpfreechat.net"; // this is the url where the users must be redirected when the chat is locked @@ -159,7 +159,8 @@ // load dynamic parameter even if the config exists in the cache foreach ( $this->dyn_params as $dp ) - $this->$dp = $params[$dp]; + if (isset($params[$dp])) + $this->$dp = $params[$dp]; // now load or save the configuration in the cache $this->synchronizeWithCache(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-08-01 18:31:50
|
Revision: 662 Author: kerphi Date: 2006-08-01 11:30:44 -0700 (Tue, 01 Aug 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=662&view=rev Log Message: ----------- Refactoring + Bug fix: the shownotice parameter was broken, this refactoring fixes it. I moved the commands parameters list into a indexed array in order to be able to add a new parameter easily (example: the flag parameter for the notice command). Modified Paths: -------------- trunk/src/commands/asknick.class.php trunk/src/commands/ban.class.php trunk/src/commands/banlist.class.php trunk/src/commands/clear.class.php trunk/src/commands/connect.class.php trunk/src/commands/debug.class.php trunk/src/commands/deop.class.php trunk/src/commands/error.class.php trunk/src/commands/getnewmsg.class.php trunk/src/commands/getonlinenick.class.php trunk/src/commands/identify.class.php trunk/src/commands/init.class.php trunk/src/commands/join.class.php trunk/src/commands/kick.class.php trunk/src/commands/leave.class.php trunk/src/commands/me.class.php trunk/src/commands/nick.class.php trunk/src/commands/notice.class.php trunk/src/commands/op.class.php trunk/src/commands/privmsg.class.php trunk/src/commands/quit.class.php trunk/src/commands/rehash.class.php trunk/src/commands/send.class.php trunk/src/commands/unban.class.php trunk/src/commands/update.class.php trunk/src/commands/updatemynick.class.php trunk/src/pfccommand.class.php trunk/src/pfcproxycommand.class.php trunk/src/phpfreechat.class.php trunk/src/proxys/auth.class.php trunk/src/proxys/censor.class.php trunk/src/proxys/lock.class.php trunk/src/proxys/noflood.class.php Modified: trunk/src/commands/asknick.class.php =================================================================== --- trunk/src/commands/asknick.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/asknick.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,8 +4,14 @@ class pfcCommand_asknick extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; @@ -14,8 +20,10 @@ if ($c->frozen_nick) { // assign a random nick + $cmdp = $p; + $cmdp["param"] = $nicktochange."".rand(1,1000); $cmd =& pfcCommand::Factory("nick"); - $cmd->run($xml_reponse, $clientid, $nicktochange."".rand(1,1000)); + $cmd->run($xml_reponse, $cmdp); } else { Modified: trunk/src/commands/ban.class.php =================================================================== --- trunk/src/commands/ban.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/ban.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -6,7 +6,7 @@ { var $usage = "/ban {nickname}"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { $c =& $this->c; $u =& $this->u; @@ -14,26 +14,27 @@ if (trim($param) == "") { // error - $msg = _pfc("Missing parameter"); - $msg .= " (".$this->usage.")"; + $cmdp = $p; + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); return; } $container =& $c->getContainerInstance(); - $nickid = $container->getNickId($param); + $nickid = $container->getNickId($p["param"]); if ($nickid != "undefined") { $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); $cmdtmp = array("leave", /* cmdname */ - $recipientid,/* param */ - $sender, /* sender */ - $recipient, /* recipient */ - $recipientid,/* recipientid */ + $p["recipientid"],/* param */ + $p["sender"], /* sender */ + $p["recipient"], /* recipient */ + $p["recipientid"],/* recipientid */ ); //_pfc("banished from %s by %s", $recipient, $sender); $cmdtoplay[] = $cmdtmp; // ban the user from the current channel @@ -41,13 +42,13 @@ } // update the recipient banlist - $banlist = $container->getMeta("banlist_nickid", "channel", $recipientid); + $banlist = $container->getMeta("banlist_nickid", "channel", $p["recipientid"]); if ($banlist == NULL) $banlist = array(); else $banlist = unserialize($banlist); $banlist[] = $nickid; // append the nickid to the banlist - $container->setMeta(serialize($banlist), "banlist_nickid", "channel", $recipientid); + $container->setMeta(serialize($banlist), "banlist_nickid", "channel", $p["recipientid"]); } } Modified: trunk/src/commands/banlist.class.php =================================================================== --- trunk/src/commands/banlist.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/banlist.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -11,13 +11,13 @@ { var $desc = "This command list the banished users on the given channel"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { $c =& $this->c; $u =& $this->u; $container =& $c->getContainerInstance(); - $banlist = $container->getMeta("banlist_nickid", "channel", $recipientid); + $banlist = $container->getMeta("banlist_nickid", "channel", $p["recipientid"]); if ($banlist == NULL) $banlist = array(); else $banlist = unserialize($banlist); $msg = ""; $msg .= "<p>"._pfc("The banished user's id list is:")."</p>"; Modified: trunk/src/commands/clear.class.php =================================================================== --- trunk/src/commands/clear.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/clear.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,7 +4,7 @@ class pfcCommand_clear extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { $c =& $this->c; $u =& $this->u; Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/connect.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,8 +4,14 @@ class pfcCommand_connect extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; @@ -52,8 +58,6 @@ $container->setMeta($isadmin, "isadmin", "nickname", $nickid); // connect to the server $xml_reponse->addScript("pfc.handleResponse('connect', 'ok', '');"); - - return $clientid; } } Modified: trunk/src/commands/debug.class.php =================================================================== --- trunk/src/commands/debug.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/debug.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,12 +4,12 @@ class pfcCommand_debug extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { $c =& $this->c; $u =& $this->u; - if ($param == "userconfig") + if ($p["param"] == "userconfig") { $msg = ""; $msg .= var_export($u, true); @@ -17,14 +17,14 @@ $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', '".$msg."');"); } - if ($param == "globalconfig") + if ($p["param"] == "globalconfig") { $msg = ""; $msg .= var_export($c, true); $msg = str_replace("\n","",addslashes(nl2br($msg))); $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', '".$msg."');"); } - if ($param == "phpserver") + if ($p["param"] == "phpserver") { $msg = ""; $msg .= var_export($_SERVER, true); Modified: trunk/src/commands/deop.class.php =================================================================== --- trunk/src/commands/deop.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/deop.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -6,23 +6,24 @@ { var $usage = "/deop {nickname}"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { $c =& $this->c; $u =& $this->u; - if (trim($param) == "") + if (trim($p["param"]) == "") { // error - $msg = _pfc("Missing parameter"); - $msg .= " (".$this->usage.")"; + $cmdp = $p; + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); return; } // just change the "isadmin" meta flag - $nicktodeop = trim($param); + $nicktodeop = trim($p["param"]); $container =& $c->getContainerInstance(); $nicktodeopid = $container->getNickId($nicktodeop); $container->setMeta(false, "isadmin", "nickname", $nicktodeopid); Modified: trunk/src/commands/error.class.php =================================================================== --- trunk/src/commands/error.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/error.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,9 +4,10 @@ class pfcCommand_error extends pfcCommand { - function run(&$xml_reponse, $clientid, $errors, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { $c =& $this->c; + $errors = $p["param"]; if (is_array($errors)) { $error_ids = ""; $error_str = ""; Modified: trunk/src/commands/getnewmsg.class.php =================================================================== --- trunk/src/commands/getnewmsg.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/getnewmsg.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,10 +4,15 @@ class pfcCommand_getnewmsg extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; - // do nothing if the recipient is not defined if ($recipient == "") return; Modified: trunk/src/commands/getonlinenick.class.php =================================================================== --- trunk/src/commands/getonlinenick.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/getonlinenick.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,8 +4,14 @@ class pfcCommand_getonlinenick extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $container =& $c->getContainerInstance(); @@ -14,8 +20,11 @@ if (isset($disconnected_users["nick"])) foreach ($disconnected_users["nick"] as $n) { + $cmdp = $p; + $cmdp["param"] = _pfc("%s quit (timeout)", $n); + $cmdp["flag"] = 2; $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $clientid, _pfc("%s quit (timeout)", $n), $sender, $recipient, $recipientid, 2); + $cmd->run($xml_reponse, $cmdp); } // get the cached nickname list Modified: trunk/src/commands/identify.class.php =================================================================== --- trunk/src/commands/identify.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/identify.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -31,8 +31,14 @@ { var $usage = "/identify {password}"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; Modified: trunk/src/commands/init.class.php =================================================================== --- trunk/src/commands/init.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/init.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,13 +4,19 @@ class pfcCommand_init extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; $cmd =& pfcCommand::Factory("quit"); - $cmd->run($xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $p); $u->destroy(); } Modified: trunk/src/commands/join.class.php =================================================================== --- trunk/src/commands/join.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/join.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -6,8 +6,14 @@ { var $usage = "/join {channelname}"; - function run(&$xml_reponse, $clientid, &$param, &$sender, &$recipient, &$recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; @@ -17,10 +23,11 @@ if ($channame == "") { - $msg = _pfc("Missing parameter"); - $msg .= " (".$this->usage.")"; + $cmdp = $p; + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); return; } @@ -36,8 +43,13 @@ } // show a join message + $cmdp = $p; + $cmdp["param"] = _pfc("%s joins %s",$u->nick, $channame); + $cmdp["recipient"] = $chanrecip; + $cmdp["recipientid"] = $chanid; + $cmdp["flag"] = 2; $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $clientid, _pfc("%s joins %s",$u->nick, $channame), $sender, $chanrecip, $chanid, 1); + $cmd->run($xml_reponse, $cmdp); //$xml_reponse->addScript("alert('join: chan=".$channame.", from_id=".$from_id."');"); Modified: trunk/src/commands/kick.class.php =================================================================== --- trunk/src/commands/kick.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/kick.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -6,18 +6,25 @@ { var $usage = "/kick {nickname}"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; if (trim($param) == "") { // error - $msg = _pfc("Missing parameter"); - $msg .= " (".$this->usage.")"; + $cmdp = $p; + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); return; } Modified: trunk/src/commands/leave.class.php =================================================================== --- trunk/src/commands/leave.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/leave.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -6,8 +6,14 @@ { var $usage = "/leave [{recipientid} {reason}]"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; @@ -54,10 +60,14 @@ if ($leavech) { // show a leave message with the showing the reason if present - $msg = _pfc("%s quit",$u->nick); - if ($reason != "") $msg .= " (".$reason.")"; + $cmdp = $p; + $cmdp["recipient"] = $leave_recip; + $cmdp["recipientid"] = $leave_id; + $cmdp["flag"] = 2; + $cmdp["param"] = _pfc("%s quit",$u->nick); + if ($reason != "") $cmdp["param"] .= " (".$reason.")"; $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $leave_recip, $leave_id, 1); + $cmd->run($xml_reponse, $cmdp); } // remove the nickname from the channel/pv @@ -71,10 +81,11 @@ else { // error - $msg = _pfc("Missing parameter"); - $msg .= " (".$this->usage.")"; + $cmdp = $p; + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); } } } Modified: trunk/src/commands/me.class.php =================================================================== --- trunk/src/commands/me.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/me.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,8 +4,14 @@ class pfcCommand_me extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; Modified: trunk/src/commands/nick.class.php =================================================================== --- trunk/src/commands/nick.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/nick.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -6,18 +6,25 @@ { var $usage = "/nick {newnickname}"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; if (trim($param) == "") { // error - $msg = _pfc("Missing parameter"); - $msg .= " (".$this->usage.")"; + $cmdp = $p; + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); return; } @@ -61,12 +68,22 @@ $u->saveInCache(); // notify all the joined channels/privmsg + $cmdp = $p; + $cmdp["param"] = _pfc("%s changes his nickname to %s",$oldnick,$newnick); + $cmdp["flag"] = 1; $cmd =& pfcCommand::Factory("notice"); foreach($u->channels as $id => $chan) - $cmd->run($xml_reponse, $clientid, _pfc("%s changes his nickname to %s",$oldnick,$newnick), $sender, $chan["recipient"], $id, 1); + { + $cmdp["recipient"] = $chan["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); + } foreach( $u->privmsg as $id => $pv ) - $cmd->run($xml_reponse, $clientid, _pfc("%s changes his nickname to %s",$oldnick,$newnick), $sender, $pv["recipient"], $id, 1); - + { + $cmdp["recipient"] = $pv["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); + } $xml_reponse->addScript("pfc.handleResponse('nick', 'changed', '".$newnick."');"); } @@ -85,16 +102,7 @@ $u->active = true; $u->saveInCache(); - $xml_reponse->addScript("alert('join: u->nick=".$u->nick); - - /* - $cmd =& pfcCommand::Factory("notice"); - foreach($u->channels as $id => $chan) - $cmd->run($xml_reponse, $clientid, _pfc("%s is connected", $u->nick), $sender, $chan["recipient"], $id, 2); - foreach($u->privmsg as $id => $pv) - $cmd->run($xml_reponse, $clientid, _pfc("%s is connected", $u->nick), $sender, $pv["recipient"], $id, 2); - */ - + $xml_reponse->addScript("alert('TODO?! remove this unused code ?');"); $xml_reponse->addScript("pfc.handleResponse('nick', 'connected', '".$newnick."');"); if ($c->debug) Modified: trunk/src/commands/notice.class.php =================================================================== --- trunk/src/commands/notice.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/notice.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,19 +4,26 @@ class pfcCommand_notice extends pfcCommand { - function run(&$xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid, $flags = 3) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $msg = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $flag = isset($p["flag"]) ? $p["flag"] : 3; + $c =& $this->c; $u =& $this->u; - + if ($c->shownotice > 0 && - ($c->shownotice & $flags) == $flags) + ($c->shownotice & $flag) == $flag) { $container =& $c->getContainerInstance(); $msg = phpFreeChat::FilterSpecialChar($msg); $container->write($recipient, $u->nick, "notice", $msg); } - if ($c->debug) pxlog("/notice ".$msg." (flags=".$flags.")", "chat", $c->getId()); + if ($c->debug) pxlog("/notice ".$msg." (flag=".$flag.")", "chat", $c->getId()); } } Modified: trunk/src/commands/op.class.php =================================================================== --- trunk/src/commands/op.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/op.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -6,18 +6,25 @@ { var $usage = "/op {nickname}"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; if (trim($param) == "") { // error - $msg = _pfc("Missing parameter"); - $msg .= " (".$this->usage.")"; + $cmdp = $p; + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); return; } Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/privmsg.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,8 +4,14 @@ class pfcCommand_privmsg extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; Modified: trunk/src/commands/quit.class.php =================================================================== --- trunk/src/commands/quit.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/quit.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,8 +4,14 @@ class pfcCommand_quit extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; @@ -21,15 +27,23 @@ foreach( $u->channels as $id => $chandetail ) if ($container->removeNick($chandetail["recipient"], $u->nick)) { + $cmdp = $p; + $cmdp["param"] = $id; + $cmdp["recipient"] = $chandetail["recipient"]; + $cmdp["recipientid"] = $id; $cmd =& pfcCommand::Factory("leave"); - $cmd->run($xml_reponse, $clientid, $id, $sender, $chandetail["recipient"], $id, 2); + $cmd->run($xml_reponse, $cmdp); } // from the private messages foreach( $u->privmsg as $id => $pvdetail ) if ($container->removeNick($pvdetail["recipient"], $u->nick)) { + $cmdp = $p; + $cmdp["param"] = $id; + $cmdp["recipient"] = $pvdetail["recipient"]; + $cmdp["recipientid"] = $id; $cmd =& pfcCommand::Factory("leave"); - $cmd->run($xml_reponse, $clientid, $id, $sender, $pvdetail["recipient"], $id, 2); + $cmd->run($xml_reponse, $cmdp); } // from the server $container->removeNick(NULL, $u->nick); Modified: trunk/src/commands/rehash.class.php =================================================================== --- trunk/src/commands/rehash.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/rehash.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -11,11 +11,19 @@ { var $desc = "This command deletes the cached configuration. Uses it to take into account new parameters."; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; - $destroyed = $c->destroyCache(); - $synchro = $c->synchronizeWithCache(); + // just destroy the cache + // do not synchronizeWithCache() because it will reload the same parameters as the current one + // the right way is to wait for the next page reload and the new parameters will be taken into account + $destroyed = $c->destroyCache(); if ($destroyed && $synchro) $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ko', '');"); Modified: trunk/src/commands/send.class.php =================================================================== --- trunk/src/commands/send.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/send.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,8 +4,14 @@ class pfcCommand_send extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; $nick = phpFreeChat::FilterSpecialChar($sender); @@ -15,8 +21,10 @@ // send an error because the current user is not connected if (!$u->active) { + $cmdp = $p; + $cmdp["param"] = _pfc("Your must be connected to send a message"); $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, _pfc("Your must be connected to send a message"), $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); return; } @@ -38,8 +46,10 @@ if (!in_array($pvnickid, $onlineusers["nickid"])) { // send an error because the user is not online + $cmdp = $p; + $cmdp["param"] = _pfc("Can't send the message, %s is offline", $pvnick); $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, _pfc("Can't send the message, %s is offline", $pvnick), $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); $can_send = false; } } @@ -54,8 +64,10 @@ // an error occured, just ignore the message and display errors foreach($errors as $e) if ($c->debug) pxlog("error /send, user can't send a message -> nick=".$u->nick." err=".$e, "chat", $c->getId()); + $cmdp = $p; + $cmdp["param"] = $errors; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $errors, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); if (isset($errors[$c->prefix."handle"])) // the nick is empty so give it focus $xml_reponse->addScript("$('".$c->prefix."handle').focus();"); $can_send = false; Modified: trunk/src/commands/unban.class.php =================================================================== --- trunk/src/commands/unban.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/unban.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -6,8 +6,14 @@ { var $usage = "/unban {id}"; - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; @@ -16,10 +22,11 @@ if (trim($param) == "") { // error - $msg = _pfc("Missing parameter"); - $msg .= " (".$this->usage.")"; + $cmdp = $p; + $cmdp["param"] = _pfc("Missing parameter"); + $cmdp["param"] .= " (".$this->usage.")"; $cmd =& pfcCommand::Factory("error"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); return; } Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/update.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,35 +4,68 @@ class pfcCommand_update extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; // do not update if user isn't active (didn't connect) if ($u->active) - { + { + $cmdp = $p; // update the user nickname timestamp $cmd =& pfcCommand::Factory("updatemynick"); foreach( $u->channels as $id => $chan ) - $cmd->run($xml_reponse, $clientid, $param, $sender, $chan["recipient"], $id); + { + $cmdp["recipient"] = $chan["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); + } foreach( $u->privmsg as $id => $pv ) - $cmd->run($xml_reponse, $clientid, $param, $sender, $pv["recipient"], $id); - $cmd->run($xml_reponse, $clientid, $param, $sender, NULL, NULL); + { + $cmdp["recipient"] = $pv["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); + } + $cmdp["recipient"] = NULL; + $cmdp["recipientid"] = NULL; + $cmd->run($xml_reponse, $cmdp); // get other online users on each channels $cmd =& pfcCommand::Factory("getonlinenick"); foreach( $u->channels as $id => $chan ) - $cmd->run($xml_reponse, $clientid, $param, $sender, $chan["recipient"], $id); + { + $cmdp["recipient"] = $chan["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); + } foreach( $u->privmsg as $id => $pv ) - $cmd->run($xml_reponse, $clientid, $param, $sender, $pv["recipient"], $id); + { + $cmdp["recipient"] = $pv["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); + } // get new message posted on each channels $cmd =& pfcCommand::Factory("getnewmsg"); foreach( $u->channels as $id => $chan ) - $cmd->run($xml_reponse, $clientid, $param, $sender, $chan["recipient"], $id); + { + $cmdp["recipient"] = $chan["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); + } foreach( $u->privmsg as $id => $pv ) - $cmd->run($xml_reponse, $clientid, $param, $sender, $pv["recipient"], $id); + { + $cmdp["recipient"] = $pv["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); + } // take care to disconnect timeouted users on the server $container =& $c->getContainerInstance(); Modified: trunk/src/commands/updatemynick.class.php =================================================================== --- trunk/src/commands/updatemynick.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/commands/updatemynick.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -4,8 +4,14 @@ class pfcCommand_updatemynick extends pfcCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; Modified: trunk/src/pfccommand.class.php =================================================================== --- trunk/src/pfccommand.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/pfccommand.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -121,7 +121,7 @@ * Virtual methode which must be implemented by concrete commands * It is called by the phpFreeChat::HandleRequest function to execute the wanted command */ - function run(&$xml_reponse, $clientid, &$param, &$sender, &$recipient, &$recipientid) + function run(&$xml_reponse, $p) { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } Modified: trunk/src/pfcproxycommand.class.php =================================================================== --- trunk/src/pfcproxycommand.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/pfcproxycommand.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -52,13 +52,6 @@ { $this->next = $cmd; } - - /* - function run(&$xml_reponse, $clientid, &$param, &$sender, &$recipient, &$recipientid) - { - die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); - } - */ } ?> \ No newline at end of file Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/phpfreechat.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -375,10 +375,16 @@ // play the command $cmd =& pfcCommand::Factory($cmdtmp[0]); + $cmdp = array(); + $cmdp["clientid"] = $clientid; + $cmdp["param"] = $cmdtmp[1]; + $cmdp["sender"] = $cmdtmp[2]; + $cmdp["recipient"] = $cmdtmp[3]; + $cmdp["recipientid"] = $cmdtmp[4]; if ($c->debug) - $cmd->run($xml_reponse, $clientid, $cmdtmp[1], $cmdtmp[2], $cmdtmp[3], $cmdtmp[4]); + $cmd->run($xml_reponse, $cmdp); else - @$cmd->run($xml_reponse, $clientid, $cmdtmp[1], $cmdtmp[2], $cmdtmp[3], $cmdtmp[4]); + @$cmd->run($xml_reponse, $cmdp); // if the cmdtoplay is a 'leave' command, then show an alert to the kicked or banished user if ($cmdtmp[0] == "leave") @@ -395,28 +401,35 @@ $morecmd = (count($cmdtoplay) > 0); } - - - - - $cmd =& pfcCommand::Factory($rawcmd); + $cmdp = array(); + $cmdp["clientid"] = $clientid; + $cmdp["param"] = $param; + $cmdp["sender"] = $sender; + $cmdp["recipient"] = $recipient; + $cmdp["recipientid"] = $recipientid; if ($cmd != NULL) { // call the command if ($c->debug) - $cmd->run($xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); else - @$cmd->run($xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + @$cmd->run($xml_reponse, $cmdp); } else { $cmd =& pfcCommand::Factory("error"); + $cmdp = array(); + $cmdp["clientid"] = $clientid; + $cmdp["param"] = _pfc("Unknown command [%s]",stripslashes("/".$rawcmd." ".$param)); + $cmdp["sender"] = $sender; + $cmdp["recipient"] = $recipient; + $cmdp["recipientid"] = $recipientid; if ($c->debug) - $cmd->run($xml_reponse, $clientid, _pfc("Unknown command [%s]",stripslashes("/".$rawcmd." ".$param)), $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); else - @$cmd->run($xml_reponse, $clientid, _pfc("Unknown command [%s]",stripslashes("/".$rawcmd." ".$param)), $sender, $recipient, $recipientid); + @$cmd->run($xml_reponse, $cmdp); } // do not update twice @@ -428,10 +441,16 @@ // force an update just after a command is sent // thus the message user just poster is really fastly displayed $cmd =& pfcCommand::Factory("update"); + $cmdp = array(); + $cmdp["clientid"] = $clientid; + $cmdp["param"] = $param; + $cmdp["sender"] = $sender; + $cmdp["recipient"] = $recipient; + $cmdp["recipientid"] = $recipientid; if ($c->debug) - $cmd->run($xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $cmdp); else - @$cmd->run($xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + @$cmd->run($xml_reponse, $cmdp); } if ($c->debug) Modified: trunk/src/proxys/auth.class.php =================================================================== --- trunk/src/proxys/auth.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/proxys/auth.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -30,8 +30,14 @@ */ class pfcProxyCommand_auth extends pfcProxyCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; @@ -93,7 +99,12 @@ } // forward the command to the next proxy or to the final command - $this->next->run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + $p["clientid"] = $clientid; + $p["param"] = $param; + $p["sender"] = $sender; + $p["recipient"] = $recipient; + $p["recipientid"] = $recipientid; + $this->next->run(&$xml_reponse, $p); } } Modified: trunk/src/proxys/censor.class.php =================================================================== --- trunk/src/proxys/censor.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/proxys/censor.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -30,8 +30,14 @@ */ class pfcProxyCommand_censor extends pfcProxyCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; @@ -52,7 +58,12 @@ } // forward the command to the next proxy or to the final command - $this->next->run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + $p["clientid"] = $clientid; + $p["param"] = $param; + $p["sender"] = $sender; + $p["recipient"] = $recipient; + $p["recipientid"] = $recipientid; + $this->next->run(&$xml_reponse, $p); } } Modified: trunk/src/proxys/lock.class.php =================================================================== --- trunk/src/proxys/lock.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/proxys/lock.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -30,8 +30,14 @@ */ class pfcProxyCommand_lock extends pfcProxyCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; @@ -43,7 +49,12 @@ else { // forward the command to the next proxy or to the final command - $this->next->run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + $p["clientid"] = $clientid; + $p["param"] = $param; + $p["sender"] = $sender; + $p["recipient"] = $recipient; + $p["recipientid"] = $recipientid; + $this->next->run(&$xml_reponse, $p); } } } Modified: trunk/src/proxys/noflood.class.php =================================================================== --- trunk/src/proxys/noflood.class.php 2006-08-01 18:03:47 UTC (rev 661) +++ trunk/src/proxys/noflood.class.php 2006-08-01 18:30:44 UTC (rev 662) @@ -30,8 +30,14 @@ */ class pfcProxyCommand_noflood extends pfcProxyCommand { - function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + function run(&$xml_reponse, $p) { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; $u =& $this->u; @@ -52,18 +58,16 @@ if ($nbflood>$c->proxys_cfg[$this->proxyname]["limit"]) { - // kick the flooder + // warn the flooder $msg = _pfc("Please don't post so many message, flood is not tolerated"); $xml_reponse->addScript("alert('".addslashes($msg)."');"); - // @todo kick the user - - $msg = $recipientid." "; - $msg .=_pfc("kicked from %s by %s", $u->channels[$recipientid]["name"], "noflood"); + // kick the flooder + $cmdp = $p; + $cmdp["param"] = $recipientid." "; + $cmdp["param"] .=_pfc("kicked from %s by %s", $u->channels[$recipientid]["name"], "noflood"); $cmd =& pfcCommand::Factory("leave"); - $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); - - + $cmd->run($xml_reponse, $cmdp); return; } @@ -73,7 +77,12 @@ } // forward the command to the next proxy or to the final command - $this->next->run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); + $p["clientid"] = $clientid; + $p["param"] = $param; + $p["sender"] = $sender; + $p["recipient"] = $recipient; + $p["recipientid"] = $recipientid; + $this->next->run(&$xml_reponse, $p); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-08-17 21:10:38
|
Revision: 677 Author: kerphi Date: 2006-08-17 14:10:14 -0700 (Thu, 17 Aug 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=677&view=rev Log Message: ----------- # Big refactoring: * Set the prefix parameter value to "pfc_". Now this parameter can't be changed because it simplify the new developments. * Change the manner how resources are manager. Resources were copied into a public directory. Now resources are just delivered by the proxy.php file which is placed into the publix directory. * Remove php code into each resources files (javascript, css). So now the chat page size is lighter from -50% (80ko to 30ko). * No more chat-post.js.tpl.php, chat-pre.js.tpl.php, and pfcclient-custo.js.tpl.php. All these redundant files are now merged into one unique file : customize.js. * The chat is now generated by Javascript routines. # Redesign the default skin (it's nicer for me, maybe for you too ?). Modified Paths: -------------- trunk/demo/demo15_multiple_channel.php trunk/src/commands/nick.class.php trunk/src/pfcglobalconfig.class.php trunk/src/pfcuserconfig.class.php trunk/src/phpfreechat.class.php trunk/themes/default/images/oldmsg.gif Added Paths: ----------- trunk/demo/demo5_customized_style_data/mytheme/style.css trunk/src/client/ trunk/src/client/chat.js.tpl.php trunk/src/client/pfcclient.js trunk/src/client/pfcgui.js trunk/src/client/pfcresource.js trunk/src/client/proxy.php.tpl trunk/themes/default/customize.js trunk/themes/default/images/background.gif trunk/themes/default/images/newmsg.gif trunk/themes/default/style.css Removed Paths: ------------- trunk/demo/demo5_customized_style_data/mytheme/templates/ trunk/themes/default/images/shade.gif trunk/themes/default/templates/ Modified: trunk/demo/demo15_multiple_channel.php =================================================================== --- trunk/demo/demo15_multiple_channel.php 2006-08-17 17:55:00 UTC (rev 676) +++ trunk/demo/demo15_multiple_channel.php 2006-08-17 21:10:14 UTC (rev 677) @@ -5,7 +5,7 @@ $params["serverid"] = md5(__FILE__); // calculate a unique id for this chat $params["title"] = "A simple chat with multiple/dynamic channels (rooms)"; $params["nick"] = "guest"; // setup the intitial nickname -$params["channel"] = isset($_GET["channel"]) ? $_GET["channel"] : "room1"; +//$params["channel"] = isset($_GET["channel"]) ? $_GET["channel"] : "room1"; $chat = new phpFreeChat( $params ); ?> @@ -23,14 +23,10 @@ <body> <p>Rooms list:</p> <ul> - <li><a href="?channel=room1">#room1</a></li> - <li><a href="?channel=room2">#room2</a></li> + <li><a href="#" onclick="pfc.sendRequest('/join', 'room1');">room1</a></li> + <li><a href="#" onclick="pfc.sendRequest('/join', 'room2');">room2</a></li> </ul> -<?php - $c =& pfcGlobalConfig::Instance(); - echo "<p>You are in #".$c->channel."</p>"; -?> <?php $chat->printChat(); ?> <?php Added: trunk/demo/demo5_customized_style_data/mytheme/style.css =================================================================== --- trunk/demo/demo5_customized_style_data/mytheme/style.css (rev 0) +++ trunk/demo/demo5_customized_style_data/mytheme/style.css 2006-08-17 21:10:14 UTC (rev 677) @@ -0,0 +1,66 @@ + +div#pfc_container { + border: black double 5px; + background-image: url("proxy.php?p=mytheme/images/brick.jpg"); + background-repeat: repeat; + padding: 20px; + color: black; + margin: auto; +} +div#pfc_chat { + background-color: #FFF; +} + +div#pfc_content { + border: none; +} + +div.pfc_message { + background-color: transparent; + background-image: url("proxy.php?p=mytheme/images/newmsg.gif"); + background-repeat: no-repeat; + background-position: right center; +} + +div.pfc_oldmsg { + background-image: url("proxy.php?p=mytheme/images/oldmsg.gif"); +} + +span.pfc_heure { + margin-left: 25px; + color: #888; +} + +span.pfc_date { + display: none; +} + +span.pfc_pseudo { + color: black; + font-weight: bold; +} + +input#pfc_handle { + color: black; + font-weight: bold; +} + +div#pfc_online { +} + +div.pfc_btn img { + border: 1px solid #FFF; /* same as container color */ +} +div.pfc_btn img:hover { + border: 1px solid #000; + background-color: #CCC; +} + + +/* commands */ +.pfc_cmd_notice { + color: red; +} +.pfc_cmd_msg { + color: #555; +} \ No newline at end of file Added: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php (rev 0) +++ trunk/src/client/chat.js.tpl.php 2006-08-17 21:10:14 UTC (rev 677) @@ -0,0 +1,149 @@ +var pfc_nickname = '<?php echo addslashes($u->nick); ?>'; +var pfc_clientid = '<?php echo md5(uniqid(rand(), true)); ?>'; +var pfc_title = '<?php echo addslashes($title); ?>'; +var pfc_refresh_delay = <?php echo $refresh_delay; ?>; +var pfc_start_minimized = <?php echo $start_minimized ? "true" : "false"; ?>; +var pfc_nickmarker = <?php echo $nickmarker ? "true" : "false"; ?>; +var pfc_clock = <?php echo $clock ? "true" : "false"; ?>; +var pfc_showsmileys = <?php echo $showsmileys ? "true" : "false"; ?>; +var pfc_showwhosonline = <?php echo $showwhosonline ? "true" : "false"; ?>; +var pfc_focus_on_connect = <?php echo $focus_on_connect ? "true" : "false"; ?>; +var pfc_max_text_len = <?php echo $max_text_len; ?>; +var pfc_quit_on_closedwindow = <?php echo $quit_on_closedwindow ? "true" : "false"; ?>; +var pfc_debug = <?php echo $debug ? "true" : "false"; ?>; +var pfc_max_text_len = <?php echo $max_text_len; ?>; +var pfc_btn_sh_smileys = <?php echo $btn_sh_smileys ? "true" : "false"; ?>; +var pfc_btn_sh_whosonline = <?php echo $btn_sh_whosonline ? "true" : "false"; ?>; +var pfc_connect_at_startup = <?php echo $connect_at_startup ? "true" : "false"; ?>; +var pfc_defaultchan = Array(<?php + function quoteandescape($v) { return "'".addslashes($v)."'"; } + $list = array(); foreach($c->channels as $ch) {$list[] = $ch; } + $list = array_map("quoteandescape",$list); + echo implode(",", $list); + ?>); +var pfc_userchan = Array(<?php + $list = array(); foreach($u->channels as $ch) {$list[] = $ch["name"];} + $list = array_map("quoteandescape",$list); + echo implode(",", $list); + ?>); +var pfc_privmsg = Array(<?php + $list = array(); foreach($u->privmsg as $pv) {$list[] = $pv["name"];} + $list = array_map("quoteandescape",$list); + echo implode(",", $list); + ?>); +var pfc_openlinknewwindow = <?php echo $openlinknewwindow ? "true" : "false"; ?>; +<?php +$bbcode_clist = array("FFFFFF","000000","000055","008000","FF0000","800000","800080","FF5500","FFFF00","00FF00","008080","00FFFF","0000FF","FF00FF","7F7F7F","D2D2D2"); +?> +var pfc_bbcode_color_list = Array(<?php + $list = array(); foreach($bbcode_clist as $v) {$list[] = $v;} + $list = array_map("quoteandescape",$list); + echo implode(",", $list); + ?>); +<?php +$nickname_clist = array('#CCCCCC','#000000','#3636B2','#2A8C2A','#C33B3B','#C73232','#80267F','#66361F','#D9A641','#3DCC3D','#1A5555','#2F8C74','#4545E6','#B037B0','#4C4C4C','#959595'); +?> +var pfc_nickname_color_list = Array(<?php + $list = array(); foreach($nickname_clist as $v) {$list[] = $v;} + $list = array_map("quoteandescape",$list); + echo implode(",", $list); + ?>); +var pfc_proxy_url = '<?php echo $data_public_url."/".$serverid."/proxy.php"; ?>'; + + +/* create our client which will do all the work on the client side ! */ +var pfc = new pfcClient(); +<?php + +$labels_to_load = +array( "Do you really want to leave this room ?", + "Hide nickname marker", + "Show nickname marker", + "Hide dates and hours", + "Show dates and hours", + "Disconnect", + "Connect", + "Magnify", + "Cut down", + "Hide smiley box", + "Show smiley box", + "Hide online users box", + "Show online users box", + "Please enter your nickname", + "Private message", + "Close this tab", + "Enter your message here", + "Enter your nickname here", + "Bold", + "Italics", + "Underline", + "Delete", + "Mail", + "Color", + ); +foreach($labels_to_load as $l) +{ + echo "pfc.res.setLabel('".$l."','".addslashes(_pfc($l))."');\n"; +} + +$fileurl_to_load = +array( 'images/ch.gif', + 'images/pv.gif', + 'images/tab_remove.gif', + 'images/ch-active.gif', + 'images/pv-active.gif', + 'images/user.gif', + 'images/user-me.gif', + 'images/color-on.gif', + 'images/color-off.gif', + 'images/clock-on.gif', + 'images/clock-off.gif', + 'images/logout.gif', + 'images/login.gif', + 'images/maximize.gif', + 'images/minimize.gif', + 'images/smiley-on.gif', + 'images/smiley-off.gif', + 'images/online-on.gif', + 'images/online-off.gif', + 'images/bt_strong.gif', + 'images/bt_em.gif', + 'images/bt_ins.gif', + 'images/bt_del.gif', + 'images/bt_mail.gif', + 'images/bt_color.gif', + ); + +// convert bbcode color value list to a bbcode color url list +function get_bbcode_color_url($v) { return 'images/color_'.$v.'.gif'; } +$bbcode_clist = array_map("get_bbcode_color_url",$bbcode_clist); + +$fileurl_to_load = array_merge($fileurl_to_load, $bbcode_clist); +foreach($fileurl_to_load as $f) +{ + echo "pfc.res.setFileUrl('".$f."',pfc_proxy_url+'".$c->getFileUrlByProxy($f,false)."');\n"; +} + +foreach($smileys as $s_file => $s_str) { + for($j = 0; $j<count($s_str) ; $j++) { + echo "pfc.res.setSmiley('".$s_str[$j]."',pfc_proxy_url+'".$c->getFileUrlByProxy($s_file,false)."');\n"; + } +} + +?> + +pfc.gui.buildChat(); +pfc.connectListener(); +pfc.refreshGUI(); +if (pfc_connect_at_startup) pfc.connect_disconnect(); + +<?php if ($debugxajax) { ?> +xajax.DebugMessage = function(text) +{ + var s = new String(text); + text = s.escapeHTML(); + rx = new RegExp('<','g'); + text = text.replace(rx, '\n<'); + $('debugxajax').innerHTML += '\n---------------\n' + text; +} +<?php } ?> Added: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js (rev 0) +++ trunk/src/client/pfcclient.js 2006-08-17 21:10:14 UTC (rev 677) @@ -0,0 +1,1367 @@ +var is_ie = navigator.appName.match("Explorer"); +var is_khtml = navigator.appName.match("Konqueror") || navigator.appVersion.match("KHTML"); +var is_ff = navigator.appName.match("Netscape"); + +/** + * This class is the client part of phpFreeChat + * (depends on prototype library) + * @author Stephane Gully + */ +var pfcClient = Class.create(); + +//defining the rest of the class implmentation +pfcClient.prototype = { + + initialize: function() + { + // load the graphical user interface builder + this.gui = new pfcGui(); + // load the resources manager (labels and urls) + this.res = new pfcResource(); + + this.nickname = pfc_nickname; + + // this array contains all the sent command + // used the up and down key to navigate in the history + // (doesn't work on IE6) + this.cmdhistory = Array(); + this.cmdhistoryid = -1; + this.cmdhistoryissearching = false; + + /* + this.channels = Array(); + this.channelids = Array(); + */ + this.privmsgs = Array(); + this.privmsgids = Array(); + + this.timeout = null; + this.refresh_delay = pfc_refresh_delay; + /* unique client id for each windows used to identify a open window + * this id is passed every time the JS communicate with server + * (2 clients can use the same session: then only the nickname is shared) */ + this.clientid = pfc_clientid; + + this.isconnected = false; + this.nicklist = $H(); + this.nickcolor = Array(); + this.colorlist = Array(); + + this.blinktmp = Array(); + this.blinkloop = Array(); + this.blinktimeout = Array(); + + }, + + connectListener: function() + { + this.el_words = $('pfc_words'); + this.el_handle = $('pfc_handle'); + this.el_container = $('pfc_container'); + this.el_online = $('pfc_online'); + this.el_errors = $('pfc_errors'); + + /* the events callbacks */ + this.el_words.onkeypress = this.callbackWords_OnKeypress.bindAsEventListener(this); + this.el_words.onkeydown = this.callbackWords_OnKeydown.bindAsEventListener(this); + this.el_words.onfocus = this.callbackWords_OnFocus.bindAsEventListener(this); + this.el_handle.onkeydown = this.callbackHandle_OnKeydown.bindAsEventListener(this); + this.el_handle.onchange = this.callbackHandle_OnChange.bindAsEventListener(this); + this.el_container.onmousemove = this.callbackContainer_OnMousemove.bindAsEventListener(this); + this.el_container.onmousedown = this.callbackContainer_OnMousedown.bindAsEventListener(this); + this.el_container.onmouseup = this.callbackContainer_OnMouseup.bindAsEventListener(this); + document.body.onunload = this.callback_OnUnload.bindAsEventListener(this); + }, + + refreshGUI: function() + { + this.minmax_status = pfc_start_minimized; + var cookie = getCookie('pfc_minmax_status'); + if (cookie != null) + this.minmax_status = (cookie == 'true'); + + cookie = getCookie('pfc_nickmarker'); + this.nickmarker = (cookie == 'true'); + if (cookie == '' || cookie == null) + this.nickmarker = pfc_nickmarker; + + cookie = getCookie('pfc_clock'); + this.clock = (cookie == 'true'); + if (cookie == '' || cookie == null) + this.clock = pfc_clock; + + cookie = getCookie('pfc_showsmileys'); + this.showsmileys = (cookie == 'true'); + if (cookie == '' || cookie == null) + this.showsmileys = pfc_showsmileys; + + cookie = getCookie('pfc_showwhosonline'); + this.showwhosonline = (cookie == 'true'); + if (cookie == '' || cookie == null) + this.showwhosonline = pfc_showwhosonline; + + // '' means no forced color, let CSS choose the text color + this.current_text_color = ''; + cookie = getCookie('pfc_current_text_color'); + if (cookie != null) + this.switch_text_color(cookie); + + this.refresh_loginlogout(); + this.refresh_minimize_maximize(); + this.refresh_Smileys(); + this.refresh_nickmarker(); + }, + + /** + * Show a popup dialog to ask user to choose a nickname + */ + askNick: function(nickname) + { + // ask to choose a nickname + if (nickname == '') nickname = this.nickname; + var newnick = prompt(this.res.getLabel('Please enter your nickname'), nickname); + if (newnick) + this.sendRequest('/nick', newnick); + }, + + /** + * Reacte to the server response + */ + handleResponse: function(cmd, resp, param) + { + if (cmd == "connect") + { + //alert(cmd + "-"+resp+"-"+param); + if (resp == "ok") + { + if (this.nickname == '') + // ask to choose a nickname + this.askNick(this.nickname); + else + { + this.sendRequest('/nick', this.nickname); + } + + // give focus the the input text box if wanted + if (pfc_focus_on_connect) this.el_words.focus(); + + this.isconnected = true; + + // start the polling system + this.updateChat(true); + } + else + this.isconnected = false; + this.refresh_loginlogout(); + } + else if (cmd == "quit") + { + if (resp =="ok") + { + // stop updates + this.updateChat(false); + this.isconnected = false; + this.refresh_loginlogout(); + } + } + else if (cmd == "join") + { + if (resp =="ok") + { + // create the new channel + var tabid = param[0]; + var name = param[1]; + this.gui.createTab(name, tabid, "ch"); + this.gui.setTabById(tabid); + /* + this.channels.push(name); + this.channelids.push(tabid); + */ + this.refresh_Smileys(); + this.refresh_WhosOnline(); + } + else + alert(cmd + "-"+resp+"-"+param); + } + else if (cmd == "join2") + { + if (resp =="ok") + { + // create the new channel + var tabid = param[0]; + var name = param[1]; + this.gui.createTab(name, tabid, "ch"); + // do not switch to the new created tab + // keep it in the background + // this.gui.setTabById(tabid); + this.refresh_WhosOnline(); + } + else + alert(cmd + "-"+resp+"-"+param); + } + else if (cmd == "leave") + { + //alert(cmd + "-"+resp+"-"+param); + if (resp =="ok") + { + // remove the channel + var tabid = param; + this.gui.removeTabById(tabid); + + // synchronize the channel client arrays + /* + var index = -1; + index = this.channelids.indexOf(tabid); + this.channelids = this.channelids.without(tabid); + this.channels = this.channels.without(this.channels[index]); + */ + + // synchronize the privmsg client arrays + index = -1; + index = indexOf(this.privmsgids, tabid); + this.privmsgids = without(this.privmsgids, tabid); + this.privmsgs = without(this.privmsgs, this.privmsgs[index]); + + } + } + else if (cmd == "privmsg") + { + if (resp == "ok") + { + // create the new channel + var tabid = param[0]; + var name = param[1]; + this.gui.createTab(name, tabid, "pv"); + this.gui.setTabById(tabid); + + this.privmsgs.push(name); + this.privmsgids.push(tabid); + + } + else if (resp == "unknown") + { + // speak to unknown user + } + else + alert(cmd + "-"+resp+"-"+param); + } + else if (cmd == "privmsg2") + { + if (resp == "ok") + { + // create the new channel + var tabid = param[0]; + var name = param[1]; + this.gui.createTab(name, tabid, "pv"); + // do not switch to the new created tab + // keep it in the background + // this.gui.setTabById(tabid); + + this.privmsgs.push(name); + this.privmsgids.push(tabid); + } + else if (resp == "unknown") + { + // speak to unknown user + } + else + alert(cmd + "-"+resp+"-"+param); + } + else if (cmd == "nick") + { + if (resp == "connected" || resp == "notchanged") + { + // now join channels comming from sessions + // or the default one + cmd = ''; + if (pfc_userchan.length == 0) + { + for (var i=0; i<pfc_defaultchan.length; i++) + { + if (i<pfc_defaultchan.length-1) + cmd = "/join2"; + else + cmd = "/join"; + this.sendRequest(cmd, pfc_defaultchan[i]); + } + } + for (var i=0; i<pfc_userchan.length; i++) + { + if (i<pfc_userchan.length-1) + cmd = "/join2"; + else + cmd = "/join"; + this.sendRequest(cmd, pfc_userchan[i]); + } + for (var i=0; i<pfc_privmsg.length; i++) + { + this.sendRequest("/privmsg", pfc_privmsg[i]); + } + } + + if (resp == "ok" || resp == "notchanged" || resp == "changed" || resp == "connected") + { + this.el_handle.value = param; + this.nickname = param; + } + else if (resp == "isused") + { + this.askNick(param); + } + else + alert(cmd + "-"+resp+"-"+param); + } + else if (cmd == "update") + { + if (resp == "ok") + { + } + } + else if (cmd == "rehash") + { + if (resp == "ok") + { + this.displayMsg( cmd, this.res.getLabel('Configuration has been rehashed') ); + } + else if (resp == "ko") + { + this.displayMsg( cmd, this.res.getLabel('A problem occurs during rehash') ); + } + } + else if (cmd == "banlist") + { + if (resp == "ok" || resp == "ko") + { + this.displayMsg( cmd, param ); + } + } + else if (cmd == "unban") + { + if (resp == "ok" || resp == "ko") + { + this.displayMsg( cmd, param ); + } + } + else if (cmd == "auth") + { + if (resp == "ban") + { + alert(param); + } + if (resp == "frozen") + { + alert(param); + } + else if (resp == "nick") + { + this.displayMsg( cmd, param ); + } + } + else if (cmd == "debug") + { + if (resp == "ok" || resp == "ko") + { + this.displayMsg( cmd, param ); + } + } + else if (cmd == "clear") + { + var tabid = this.gui.getTabId(); + var container = this.gui.getChatContentFromTabId(tabid); + container.innerHTML = ""; + } + else if (cmd == "identify") + { + this.displayMsg( cmd, param ); + } + else + alert(cmd + "-"+resp+"-"+param); + }, + + /** + * Try to complete a nickname like on IRC when pressing the TAB key + * @todo: improve the algorithme, it should take into account the cursor position + */ + completeNick: function() + { + var w = this.el_words; + var nick_src = w.value.substring(w.value.lastIndexOf(' ')+1,w.value.length); + if (nick_src != '') + { + var ul_online = this.el_online.firstChild; + for (var i=0; i<ul_online.childNodes.length; i++) + { + var nick = ul_online.childNodes[i].innerHTML; + if (indexOf(nick, nick_src) == 0) + w.value = w.value.replace(nick_src, nick); + } + } + }, + + /** + * Handle the pressed keys + * see also callbackWords_OnKeydown + */ + callbackWords_OnKeypress: function(evt) + { + var code = (evt.which) ? evt.which : evt.keyCode; + if (code == Event.KEY_TAB) /* tab key */ + { + /* FF & Konqueror workaround : ignore TAB key here */ + /* do the nickname completion work like on IRC */ + this.completeNick(); + return false; /* do not leave the tab key default behavior */ + } + else if (code == Event.KEY_RETURN) /* enter key */ + { + var w = this.el_words; + var wval = w.value; + + // append the string to the history + this.cmdhistory.push(wval); + this.cmdhistoryid = this.cmdhistory.length; + this.cmdhistoryissearching = false; + + // send the string to the server + re = new RegExp("^(\/[a-z0-9]+)( (.*)|)"); + if (wval.match(re)) + { + /* a user command */ + cmd = wval.replace(re, '$1'); + param = wval.replace(re, '$3'); + this.sendRequest(cmd, param.substr(0, pfc_max_text_len + this.clientid.length)); + } + else + { + /* a classic 'send' command*/ + + // empty messages with only spaces + rx = new RegExp('^[ ]*$','g'); + wval = wval.replace(rx,''); + + /* truncate the text length */ + wval = wval.substr(0,pfc_max_text_len); + + /* colorize the text with current_text_color */ + if (this.current_text_color != '' && wval.length != '') + wval = '[color=#' + this.current_text_color + '] ' + wval + ' [/color]'; + + this.sendRequest('/send', wval); + } + w.value = ''; + return false; + } + else if (code == 33 && false) // page up key + { + // write the last command in the history + if (this.cmdhistory.length>0) + { + var w = this.el_words; + if (this.cmdhistoryissearching == false && w.value != "") + this.cmdhistory.push(w.value); + this.cmdhistoryissearching = true; + this.cmdhistoryid = this.cmdhistoryid-1; + if (this.cmdhistoryid<0) this.cmdhistoryid = this.cmdhistory.length-1; + w.value = this.cmdhistory[this.cmdhistoryid]; + } + } + else if (code == 34 && false) // page down key + { + // write the next command in the history + if (this.cmdhistory.length>0) + { + var w = this.el_words; + if (this.cmdhistoryissearching == false && w.value != "") + this.cmdhistory.push(w.value); + this.cmdhistoryissearching = true; + this.cmdhistoryid = this.cmdhistoryid+1; + if (this.cmdhistoryid>=this.cmdhistory.length) this.cmdhistoryid = 0; + w.value = this.cmdhistory[this.cmdhistoryid]; + } + } + else + { + /* allow other keys */ + return true; + } + }, + /** + * Handle the pressed keys + * see also callbackWords_OnKeypress + */ + callbackWords_OnKeydown: function(evt) + { + if (!this.isconnected) return false; + this.clearError(Array(this.el_words)); + var code = (evt.which) ? evt.which : event.keyCode + if (code == 9) /* tab key */ + { + /* IE workaround : ignore TAB key here */ + /* do the nickname completion work like on IRC */ + this.completeNick(); + return false; /* do not leave the tab key default behavior */ + } + else + { + return true; + } + }, + callbackWords_OnFocus: function(evt) + { + // if (this.el_handle && this.el_handle.value == '' && !this.minmax_status) + // this.el_handle.focus(); + }, + callbackHandle_OnKeydown: function(evt) + { + }, + callbackHandle_OnChange: function(evt) + { + }, + callback_OnUnload: function(evt) + { + /* don't disconnect users when they reload the window + * this event doesn't only occurs when the page is closed but also when the page is reloaded */ + if (pfc_quit_on_closedwindow) + { + if (!this.isconnected) return false; + this.sendRequest('/quit'); + } + }, + + callbackContainer_OnMousemove: function(evt) + { + this.isdraging = true; + }, + callbackContainer_OnMousedown: function(evt) + { + if ( ((is_ie || is_khtml) && evt.button == 1) || (is_ff && evt.button == 0) ) + this.isdraging = false; + }, + callbackContainer_OnMouseup: function(evt) + { + if ( ((is_ie || is_khtml) && evt.button == 1) || (is_ff && evt.button == 0) ) + if (!this.isdraging) + if (this.el_words && !this.minmax_status) + this.el_words.focus(); + }, + + /** + * hide error area and stop blinking fields + */ + clearError: function(ids) + { + this.el_errors.style.display = 'none'; + for (var i=0; i<ids.length; i++) + this.blink(ids[i].id, 'stop'); + }, + + /** + * show error area and assign to it an error message and start the blinking of given fields + */ + setError: function(str, ids) + { + this.el_errors.innerHTML = str; + this.el_errors.style.display = 'block'; + for (var i=0; i<ids.length; i++) + this.blink(ids[i].id, 'start'); + }, + + /** + * blink routines used by Error functions + */ + blink: function(id, action) + { + clearTimeout(this.blinktimeout[id]); + if ($(id) == null) return; + if (action == 'start') + { + this.blinktmp[id] = $(id).style.backgroundColor; + clearTimeout(this.blinktimeout[id]); + this.blinktimeout[id] = setTimeout('pfc.blink(\'' + id + '\',\'loop\')', 500); + } + if (action == 'stop') + { + $(id).style.backgroundColor = this.blinktmp[id]; + } + if (action == 'loop') + { + if (this.blinkloop[id] == 1) + { + $(id).style.backgroundColor = '#FFDFC0'; + this.blinkloop[id] = 2; + } + else + { + $(id).style.backgroundColor = '#FFFFFF'; + this.blinkloop[id] = 1; + } + this.blinktimeout[id] = setTimeout('pfc.blink(\'' + id + '\',\'loop\')', 500); + } + }, + + displayMsg: function( cmd, msg ) + { + // get the current selected tab container + var tabid = this.gui.getTabId(); + var container = this.gui.getChatContentFromTabId(tabid); + + div = document.createElement('div'); + div.style.padding = "2px 5px 2px 5px"; + + pre = document.createElement('pre'); + pre.setAttribute('class', 'pfc_info pfc_info_'+cmd); + pre.setAttribute('className', 'pfc_info pfc_info_'+cmd); // for IE6 + // Element.addClassName(pre, 'pfc_info'); + // Element.addClassName(pre, 'pfc_info_'+cmd); + pre.style.border = "1px solid #555"; + pre.style.padding = "5px"; + pre.innerHTML = msg; + div.appendChild(pre); + + // finaly append this to the message list + container.appendChild(div); + this.gui.scrollDown(tabid, div); + }, + + handleComingRequest: function( cmds ) + { + var msg_html = $H(); + + //alert(cmds.inspect()); + + // var html = ''; + for(var mid = 0; mid < cmds.length ; mid++) + { + var id = cmds[mid][0]; + var date = cmds[mid][1]; + var time = cmds[mid][2]; + var sender = cmds[mid][3]; + var recipientid = cmds[mid][4]; + var cmd = cmds[mid][5]; + var param = cmds[mid][6]; + var fromtoday = cmds[mid][7]; + var oldmsg = cmds[mid][8]; + + // format and post message + var line = ''; + line += '<div id="pfc_msg'+ id +'" class="pfc_cmd_'+ cmd +' pfc_message'; + if (oldmsg == 1) line += ' pfc_oldmsg'; + line += '">'; + line += '<span class="pfc_date'; + if (fromtoday == 1) line += ' pfc_invisible'; + line += '">'+ date +'</span> '; + line += '<span class="pfc_heure">'+ time +'</span> '; + if (cmd == 'send') + { + line += ' <span class="pfc_nick">'; + line += '‹'; + line += '<span '; + line += 'onclick="pfc.insert_text(\'' + sender + ', \',\'\')" '; + line += 'class="pfc_nickmarker pfc_nick_'+ hex_md5(_to_utf8(sender)) +'">'; + line += sender; + line += '</span>'; + line += '›'; + line += '</span> '; + } + if (cmd == 'notice' || cmd == 'me') + line += '<span class="pfc_words">* '+ this.parseMessage(param) +'</span> '; + else + line += '<span class="pfc_words">'+ this.parseMessage(param) +'</span> '; + line += '</div>'; + + // notify the hidden tab a message has been received + if (cmd == 'send' || cmd == 'me') + { + var tabid = recipientid; + if (this.gui.getTabId() != tabid) + this.gui.notifyTab(tabid); + } + + if (msg_html[recipientid] == null) + msg_html[recipientid] = line; + else + msg_html[recipientid] += line; + } + + // loop on all recipients and post messages + var keys = msg_html.keys(); + for( var i=0; i<keys.length; i++) + { + var recipientid = keys[i]; + var tabid = recipientid; + + // create the tab if it doesn't exists yet + var recipientdiv = this.gui.getChatContentFromTabId(tabid); + + // create a dummy div to avoid konqueror bug when setting nickmarkers + var m = document.createElement('div'); + m.innerHTML = msg_html[recipientid]; + this.colorizeNicks(m); + this.refresh_clock(m); + // finaly append this to the message list + recipientdiv.appendChild(m); + this.gui.scrollDown(tabid, m); + } + }, + + /** + * Call the ajax request function + * Will query the server + */ + sendRequest: function(cmd, param) + { + var recipientid = this.gui.getTabId(); + var req = cmd+" "+this.clientid+" "+(recipientid==''?'0':recipientid)+(param?" "+param : ""); + if (pfc_debug) + if (cmd != "/update") alert(req); + return eval('pfc_handleRequest(req);'); + }, + + /** + * update function to poll the server each 'refresh_delay' time + */ + updateChat: function(start) + { + clearTimeout(this.timeout); + if (start) + { + var res = this.sendRequest('/update'); + // adjust the refresh_delay if the connection was lost + if (res == false) { this.refresh_delay = this.refresh_delay * 2; } + // setup the next update + this.timeout = setTimeout('pfc.updateChat(true)', this.refresh_delay); + } + }, + + /** + * insert a smiley + */ + insertSmiley: function(s) + { + this.el_words.value += s; + this.el_words.focus(); + }, + + /** + * fill the nickname list with connected nicknames + */ + updateNickList: function(tabid,lst) + { + // alert('updateNickList: tabid='+tabid+"-lst="+lst.inspect()); + //var tabid = hex_md5(_to_utf8("ch_"+recipient)); + + this.nicklist[tabid] = lst; + var nicks = lst; + var nickdiv = this.gui.getOnlineContentFromTabId(tabid).firstChild; + var ul = document.createElement('ul'); + for (var i=0; i<nicks.length; i++) + { + var li = document.createElement('li'); + if (nicks[i] != this.nickname) + { + // this is someone -> create a privmsg link + var img = document.createElement('img'); + img.setAttribute('src', this.res.getFileUrl('images/user.gif')); + img.alt = this.res.getLabel('Private message'); + img.title = img.alt; + img.style.marginRight = '5px'; + var a = document.createElement('a'); + a.setAttribute('href', ''); + a.pfc_nick = nicks[i]; + a.onclick = function(){pfc.sendRequest('/privmsg', this.pfc_nick); return false;} + a.appendChild(img); + li.appendChild(a); + } + else + { + // this is myself -> do not create a privmsg link + var img = document.createElement('img'); + img.setAttribute('src', this.res.getFileUrl('images/user-me.gif')); + img.alt = ''; + img.title = img.alt; + img.style.marginRight = '5px'; + li.appendChild(img); + } + + + // nobr is not xhtml valid but it's a workeround + // for IE which doesn't support 'white-space: pre' css rule + var nobr = document.createElement('nobr'); + var span = document.createElement('span'); + span.pfc_nick = nicks[i]; + span.onclick = function(){pfc.insert_text(this.pfc_nick+", ",""); return false;} + span.appendChild(document.createTextNode(nicks[i])); + span.setAttribute('class', 'pfc_nickmarker pfc_nick_'+ hex_md5(_to_utf8(nicks[i]))); + span.setAttribute('className', 'pfc_nickmarker pfc_nick_'+ hex_md5(_to_utf8(nicks[i]))); // for IE6 + + // Element.addClassName(span, 'pfc_nickmarker'); + // Element.addClassName(span, 'pfc_nick_'+ hex_md5(_to_utf8(nicks[i]))); + nobr.appendChild(span); + li.appendChild(nobr); + li.style.borderBottom = '1px solid #AAA'; + + ul.appendChild(li); + } + var fc = nickdiv.firstChild; + if (fc) + nickdiv.replaceChild(ul,fc); + else + nickdiv.appendChild(ul,fc); + this.colorizeNicks(nickdiv); + }, + + /** + * clear the nickname list + */ + clearNickList: function() + { + /* + var nickdiv = this.el_online; + var fc = nickdiv.firstChild; + if (fc) nickdiv.removeChild(fc); + */ + }, + + + /** + * clear the message list history + */ + clearMessages: function() + { + //var msgdiv = $('pfc_chat'); + //msgdiv.innerHTML = ''; + }, + + /** + * parse the message + */ + parseMessage: function(msg) + { + var rx = null; + + // parse urls + var rx_url = new RegExp('(^|[^\\"])([a-z]+\:\/\/[a-z0-9.\\/\\?\\=\\&\\-\\_\\#:;]*)([^\\"]|$)','ig'); + var ttt = msg.split(rx_url); + if (ttt.length > 1 && + !navigator.appName.match("Explorer|Konqueror") && + !navigator.appVersion.match("KHTML")) + { + msg = ''; + for( var i = 0; i<ttt.length; i++) + { + var offset = (ttt[i].length - 7) / 2; + var delta = (ttt[i].length - 7 - 60); + var range1 = 7+offset-delta; + var range2 = 7+offset+delta; + if (ttt[i].match(rx_url)) + { + msg = msg + '<a href="' + ttt[i] + '"'; + if (pfc_openlinknewwindow) + msg = msg + ' onclick="window.open(this.href,\'_blank\');return false;"'; + msg = msg + '>' + (delta>0 ? ttt[i].substring(7,range1)+ ' ... ' + ttt[i].substring(range2,ttt[i].length) : ttt[i]) + '</a>'; + } + else + { + msg = msg + ttt[i]; + } + } + } + else + { + // fallback for IE6/Konqueror which do not support split with regexp + replace = '$1<a href="$2"'; + if (pfc_openlinknewwindow) + replace = replace + ' onclick="window.open(this.href,\'_blank\');return false;"'; + replace = replace + '>$2</a>$3'; + msg = msg.replace(rx_url, replace); + } + + // replace double spaces by entity + rx = new RegExp(' ','g'); + msg = msg.replace(rx, ' '); + + // try to parse bbcode + rx = new RegExp('\\[b\\](.+?)\\[\/b\\]','ig'); + msg = msg.replace(rx, '<span style="font-weight: bold">$1</span>'); + rx = new RegExp('\\[i\\](.+?)\\[\/i\\]','ig'); + msg = msg.replace(rx, '<span style="font-style: italic">$1</span>'); + rx = new RegExp('\\[u\\](.+?)\\[\/u\\]','ig'); + msg = msg.replace(rx, '<span style="text-decoration: underline">$1</span>'); + rx = new RegExp('\\[s\\](.+?)\\[\/s\\]','ig'); + msg = msg.replace(rx, '<span style="text-decoration: line-through">$1</span>'); + // rx = new RegExp('\\[pre\\](.+?)\\[\/pre\\]','ig'); + // msg = msg.replace(rx, '<pre>$1</pre>'); + rx = new RegExp('\\[email\\]([A-z0-9][\\w.-]*@[A-z0-9][\\w\\-\\.]+\\.[A-z0-9]{2,6})\\[\/email\\]','ig'); + msg = msg.replace(rx, '<a href="mailto: $1">$1</a>'); + rx = new RegExp('\\[email=([A-z0-9][\\w.-]*@[A-z0-9][\\w\\-\\.]+\\.[A-z0-9]{2,6})\\](.+?)\\[\/email\\]','ig'); + msg = msg.replace(rx, '<a href="mailto: $1">$2</a>'); + rx = new RegExp('\\[color=([a-zA-Z]+|\\#?[0-9a-fA-F]{6}|\\#?[0-9a-fA-F]{3})](.+?)\\[\/color\\]','ig'); + msg = msg.replace(rx, '<span style="color: $1">$2</span>'); + // parse bbcode colors twice because the current_text_color is a bbcolor + // so it's possible to have a bbcode color imbrication + rx = new RegExp('\\[color=([a-zA-Z]+|\\#?[0-9a-fA-F]{6}|\\#?[0-9a-fA-F]{3})](.+?)\\[\/color\\]','ig'); + msg = msg.replace(rx, '<span style="color: $1">$2</span>'); + + // try to parse smileys + var smileys = this.res.getSmileyHash(); + var sl = smileys.keys(); + for(var i = 0; i < sl.length; i++) + { + rx = new RegExp(RegExp.escape(sl[i]),'g'); + msg = msg.replace(rx, '<img src="'+ smileys[sl[i]] +'" alt="' + sl[i] + '" title="' + sl[i] + '" />'); + } + + // try to parse nickname for highlighting + rx = new RegExp('(^|[ :,;])'+RegExp.escape(this.nickname)+'([ :,;]|$)','gi'); + msg = msg.replace(rx, '$1<strong>'+ this.nickname +'</strong>$2'); + + // don't allow to post words bigger than 65 caracteres + // doesn't work with crappy IE and Konqueror ! + rx = new RegExp('([^ \\:\\<\\>\\/\\&\\;]{60})','ig'); + var ttt = msg.split(rx); + if (ttt.length > 1 && + !navigator.appName.match("Explorer|Konqueror") && + !navigator.appVersion.match("KHTML")) + { + msg = ''; + for( var i = 0; i<ttt.length; i++) + { + msg = msg + ttt[i] + ' '; + } + } + return msg; + }, + + /** + * apply nicknames color to the root childs + */ + colorizeNicks: function(root) + { + if (this.nickmarker) + { + var nicklist = this.getElementsByClassName(root, 'pfc_nickmarker', ''); + for(var i = 0; i < nicklist.length; i++) + { + var cur_nick = nicklist[i].innerHTML; + var cur_color = this.getAndAssignNickColor(cur_nick); + nicklist[i].style.color = cur_color; + } + } + }, + + /** + * Initialize the color array used to colirize the nicknames + */ + reloadColorList: function() + { + this.colorlist = pfc_nickname_color_list; + }, + + + /** + * get the corresponding nickname color + */ + getAndAssignNickColor: function(nick) + { + /* check the nickname is colorized or not */ + var allready_colorized = false; + var nc = ''; + for(var j = 0; j < this.nickcolor.length; j++) + { + if (this.nickcolor[j][0] == nick) + { + allready_colorized = true; + nc = this.nickcolor[j][1]; + } + } + if (!allready_colorized) + { + /* reload the color stack if it's empty */ + if (this.colorlist.length == 0) this.reloadColorList(); + /* take the next color from the list and colorize this nickname */ + var cid = Math.round(Math.random()*(this.colorlist.length-1)); + nc = this.colorlist[cid]; + this.colorlist.splice(cid,1); + this.nickcolor.push(new Array(nick, nc)); + } + + return nc; + }, + + + /** + * Colorize with 'color' all the nicknames found as a 'root' child + */ + applyNickColor: function(root, nick, color) + { + + var nicktochange = this.getElementsByClassName(root, 'pfc_nick_'+ hex_md5(_to_utf8(nick)), '') + for(var i = 0; nicktochange.length > i; i++) + nicktochange[i].style.color = color; + + }, + + /** + * Returns a list of elements which have a clsName class + */ + getElementsByClassName: function( root, clsName, clsIgnore ) + { + var i, matches = new Array(); + var els = root.getElementsByTagName('*'); + var rx1 = new RegExp('.*'+clsName+'.*'); + var rx2 = new RegExp('.*'+clsIgnore+'.*'); + for(i=0; i<els.length; i++) { + if(els.item(i).className.match(rx1) && + (clsIgnore == '' || !els.item(i).className.match(rx2)) ) { + matches.push(els.item(i)); + } + } + return matches; + }, + + showClass: function(root, clsName, clsIgnore, show) + { + var elts = this.getElementsByClassName(root, clsName, clsIgnore); + for(var i = 0; elts.length > i; i++) + if (show) + elts[i].style.display = 'inline'; + else + elts[i].style.display = 'none'; + }, + + + /** + * Nickname marker show/hide + */ + nickmarker_swap: function() + { + if (this.nickmarker) { + this.nickmarker = false; + } else { + this.nickmarker = true; + } + this.refresh_nickmarker() + setCookie('pfc_nickmarker', this.nickmarker); + }, + refresh_nickmarker: function(root) + { + var nickmarker_icon = $('pfc_nickmarker'); + if (!root) root = $('pfc_channels_content'); + if (this.nickmarker) + { + nickmarker_icon.src = this.res.getFileUrl('images/color-on.gif'); + nickmarker_icon.alt = this.res.getLabel("Hide nickname marker"); + nickmarker_icon.title = nickmarker_icon.alt; + this.colorizeNicks(root); + } + else + { + nickmarker_icon.src = this.res.getFileUrl('images/color-off.gif'); + nickmarker_icon.alt = this.res.getLabel("Show nickname marker"); + nickmarker_icon.title = nickmarker_icon.alt; + var elts = this.getElementsByClassName(root, 'pfc_nickmarker', ''); + for(var i = 0; elts.length > i; i++) + { + // this is not supported in konqueror =>>> elts[i].removeAttribute('style'); + elts[i].style.color = ''; + } + } + }, + + + /** + * Date/Hour show/hide + */ + clock_swap: function() + { + if (this.clock) { + this.clock = false; + } else { + this.clock = true; + } + this.refresh_clock(); + setCookie('pfc_clock', this.clock); + }, + refresh_clock: function( root ) + { + var clock_icon = $('pfc_clock'); + if (!root) root = $('pfc_channels_content'); + if (this.clock) + { + clock_icon.src = this.res.getFileUrl('images/clock-on.gif'); + clock_icon.alt = this.res.getLabel('Hide dates and hours'); + clock_icon.title = clock_icon.alt; + this.showClass(root, 'pfc_date', 'pfc_invisible', true); + this.showClass(root, 'pfc_heure', 'pfc_invisible', true); + } + else + { + clock_icon.src = this.res.getFileUrl('images/clock-off.gif'); + clock_icon.alt = this.res.getLabel('Show dates and hours'); + clock_icon.title = clock_icon.alt; + this.showClass(root, 'pfc_date', 'pfc_invisible', false); + this.showClass(root, 'pfc_heure', 'pfc_invisible', false); + } + // browser automaticaly scroll up misteriously when showing the dates + // $('pfc_chat').scrollTop += 30; + }, + + /** + * Connect/disconnect button + */ + connect_disconnect: function() + { + if (this.isconnected) + this.sendRequest('/quit'); + else + this.sendRequest('/connect'); + }, + refresh_loginlogout: function() + { + var loginlogout_icon = $('pfc_loginlogout'); + if (this.isconnected) + { + // this.updateNickList(this.nicklist); + loginlogout_icon.src = this.res.getFileUrl('images/logout.gif'); + loginlogout_icon.alt = this.res.getLabel('Disconnect'); + loginlogout_icon.title = loginlogout_icon.alt; + } + else + { + this.clearMessages(); + this.clearNickList(); + loginlogout_icon.src = this.res.getFileUrl('images/login.gif'); + loginlogout_icon.alt = this.res.getLabel('Connect'); + loginlogout_icon.title = loginlogout_icon.alt; + } + }, + + + + /** + * Minimize/Maximized the chat zone + */ + swap_minimize_maximize: function() + { + if (this.minmax_status) { + this.minmax_status = false; + } else { + this.minmax_status = true; + } + setCookie('pfc_minmax_status', this.minmax_status); + this.refresh_minimize_maximize(); + }, + refresh_minimize_maximize: function() + { + var content = $('pfc_content_expandable'); + var btn = $('pfc_minmax'); + if (this.minmax_status) + { + btn.src = this.res.getFileUrl('images/maximize.gif'); + btn.alt = this.res.getLabel('Magnify'); + btn.title = btn.alt; + content.style.display = 'none'; + } + else + { + btn.src = this.res.getFileUrl('images/minimize.gif'); + btn.alt = this.res.getLabel('Cut down'); + btn.title = btn.alt; + content.style.display = 'block'; + } + }, + + /** + * BBcode ToolBar + */ + insert_text: function(open, close) + { + var msgfield = $('pfc_words'); + + // IE support + if (document.selection && document.selection.createRange) + { + msgfield.focus(); + sel = document.selection.createRange(); + sel.text = open + sel.text + close; + msgfield.focus(); + } + + // Moz support + else if (msgfield.selectionStart || msgfield.selectionStart == '0') + { + var startPos = msgfield.selectionStart; + var endPos = msgfield.selectionEnd; + + msgfield.value = msgfield.value.substring(0, startPos) + open + msgfield.value.substring(startPos, endPos) + close + msgfield.value.substring(endPos, msgfield.value.length); + msgfield.selectionStart = msgfield.selectionEnd = endPos + open.length + close.length; + msgfield.focus(); + } + + // Fallback support for other browsers + else + { + msgfield.value += open + close; + msgfield.focus(); + } + return; + }, + + /** + * Minimize/Maximize none/inline + */ + minimize_maximize: function(idname, type) + { + var element = $(idname); + if(element.style) + { + if(element.style.display == type ) + { + element.style.display = 'none'; + } + else + { + element.style.display = type; + } + } + }, + + switch_text_color: function(color) + { + /* clear any existing borders on the color buttons */ + var colorbtn = this.getElementsByClassName($('pfc_colorlist'), 'pfc_color', ''); + for(var i = 0; colorbtn.length > i; i++) + colorbtn[i].style.border = 'none'; + + /* assign the new border style to the selected button */ + this.current_text_color = color; + setCookie('pfc_current_text_color', this.current_text_color); + var idname = 'pfc_color_' + color; + $(idname).style.border = '1px solid #666'; + $(idname).style.padding = '1px'; + + // assigne the new color to the input text box + this.el_words.style.color = '#'+color; + this.el_words.focus(); + }, + + /** + * Smiley show/hide + */ + showHideSmileys: function() + { + if (this.showsmileys) + { + this.showsmileys = false; + } + else + { + this.showsmileys = true; + } + setCookie('pfc_showsmileys', this.showsmileys); + this.refresh_Smileys(); + }, + refresh_Smileys: function() + { + // first of all : show/hide the smiley box + var content = $('pfc_smileys'); + if (this.showsmileys) + content.style.display = 'block'; + else + content.style.display = 'none'; + + // then switch the button icon + var btn = $('pfc_showHideSmileysbtn'); + if (this.showsmileys) + { + if (btn) + { + btn.src = this.res.getFileUrl('images/smiley-on.gif'); + btn.alt = this.res.getLabel('Hide smiley box'); + btn.title = btn.alt; + } + } + else + { + if (btn) + { + btn.src = this.res.getFileUrl('images/smiley-off.gif'); + btn.alt = this.res.getLabel('Show smiley box'); + btn.title = btn.alt; + } + } + }, + + + /** + * Show Hide who's online + */ + showHideWhosOnline: function() + { + if (this.showwhosonline) + { + this.showwhosonline = false; + } + else + { + this.showwhosonline = true; + } + setCookie('pfc_showwhosonline', this.showwhosonline); + this.refresh_WhosOnline(); + }, + refresh_WhosOnline: function() + { + // first of all : show/hide the nickname list box + var root = $('pfc_channels_content'); + var contentlist = this.getElementsByClassName(root, 'pfc_online', ''); + for(var i = 0; i < contentlist.length; i++) + { + var content = contentlist[i]; + if (this.showwhosonline) + content.style.display = 'block'; + else + content.style.display = 'none'; + content.style.zIndex = '100'; // for IE6, force the nickname list borders to be shown + } + + // then refresh the button icon + var btn = $('pfc_showHideWhosOnlineBtn'); + if (!btn) return; + if (this.showwhosonline) + { + btn.src = this.res.getFileUrl('images/online-on.gif'); + btn.alt = this.res.getLabel('Hide online users box'); + btn.title = btn.alt; + } + else + { + btn.src = this.res.getFileUrl('images/online-off.gif'); + btn.alt = this.res.getLabel('Show online users box'); + btn.title = btn.alt; + } + this.refresh_Chat(); + }, + + /** + * Resize chat + */ + refresh_Chat: function() + { + // resize all the tabs content + var root = $('pfc_channels_content'); + var contentlist = this.getElementsByClassName(root, 'pfc_chat', ''); + for(var i = 0; i < contentlist.length; i++) + { + var chatdiv = contentlist[i]; + var style = $H(); + if (!this.showwhosonline) + { + chatdiv.style.width = '100%'; + } + else + { + chatdiv.style.width = ''; + } + } + } +}; Added: trunk/src/client/pfcgui.js =================================================================== --- trunk/src/client/pfcgui.js (rev 0) +++ trunk/src/client/pfcgui.js 2006-08-17 21:10:14 UTC (rev 677) @@ -0,0 +1,568 @@ +/** + * This class centralize the pfc' Graphic User Interface manipulations + * (depends on prototype library) + * @author Stephane Gully + */ +var pfcGui = Class.create(); +pfcGui.prototype = { + + initialize: function() + { + this.current_tab = ''; + this.current_tab_id = ''; + this.tabs = Array(); + this.tabids = Array(); + this.tabtypes = Array(); + this.chatcontent = $H(); + this.onlinecontent = $H(); + this.scrollpos = $H(); + this.elttoscroll = $H(); + }, + + /** + * scroll down from the posted message height + */ + scrollDown: function(tabid, elttoscroll) + { + if (this.getTabId() != tabid) + { + if (!this.elttoscroll[tabid]) this.elttoscroll[tabid] = Array(); + this.elttoscroll[tabid].push(elttoscroll); + return; + } + var content = this.getChatContentFromTabId(tabid); + content.scrollTop += elttoscroll.offsetHeight+2; + this.scrollpos[tabid] = content.scrollTop; + }, + + isCreated: function(tabid) + { + /* + for (var i = 0; i < this.tabids.length ; i++) + { + if (this.tabids[i] == tabid) return true; + } + return false; + */ + return (indexOf(this.tabids, tabid) >= 0); + }, + + setTabById: function(tabid) + { + // first of all save the scroll pos of the visible tab + var content = this.getChatContentFromTabId(this.current_tab_id); + this.scrollpos[this.current_tab_id] = content.scrollTop; + + // start without selected tabs + this.current_tab = ''; + this.current_tab_id = ''; + var tab_to_show = null; + // try to fine the tab to select and select it! + for (var i=0; i<this.tabids.length; i++) + { + var tabtitle = $('pfc_channel_title'+this.tabids[i]); + var tabcontent = $('pfc_channel_content'+this.tabids[i]); + if (this.tabids[i] == tabid) + { + // select the tab + tabtitle.setAttribute('class', 'selected'); + tabtitle.setAttribute('className', 'selected'); // for IE6 + //Element.addClassName(tabtitle, 'selected'); + tab_to_show = tabcontent; + this.current_tab = this.tabs[i]; + this.current_tab_id = tabid; + } + else + { + // unselect the tab + tabtitle.setAttribute('class', ''); + tabtitle.setAttribute('className', ''); // for IE6 + //Element.removeClassName(tabtitle, 'selected'); + tabcontent.style.display = 'none'; + } + } + + // show the new selected tab + tab_to_show.style.display = 'block'; + + // restore the scroll pos + var content = this.getChatContentFromTabId(tabid); + content.scrollTop = this.scrollpos[tabid]; + + // scroll the new posted message + if (this.elttoscroll[tabid] && + this.elttoscroll[tabid].length > 0) + { + // on by one + for (var i=0; i<this.elttoscroll[tabid].length; i++) + this.scrollDown(tabid,this.elttoscroll[tabid][i]); + this.elttoscroll[tabid] = Array(); + } + + this.unnotifyTab(tabid); + }, + + getTabId: function() + { + return this.current_tab_id; + }, + + getChatContentFromTabId: function(tabid) + { + // return the chat content if it exists + var cc = this.chatcontent[tabid]; + if (cc) return cc; + + // if the chat content doesn't exists yet, just create a cached one + cc = document.createElement('div'); + cc.setAttribute('id', 'pfc_chat_'+tabid); + cc.setAttribute('class', 'pfc_chat'); + cc.setAttribute('className', 'pfc_chat'); // for IE6 + + // Element.addClassName(cc, 'pfc_chat'); + cc.style.display = "block"; // needed by IE6 to show the online div at startup (first loaded page) + // cc.style.marginLeft = "5px"; + + this.chatcontent[tabid] = cc; + return cc; + }, + getOnlineContentFromTabId: function(tabid) + { + // return the online content if it exists + var oc = this.onlinecontent[tabid]; + if (oc) return oc; + + oc = document.createElement('div'); + oc.setAttribute('id', 'pfc_online_'+tabid); + oc.setAttribute('class', 'pfc_online'); + oc.setAttribute('className', 'pfc_online'); // for IE6 + //Element.addClassName(oc, 'pfc_online'); + // I set the border style here because seting it in the CSS is not taken in account + // oc.style.borderLeft = "1px solid #555"; + oc.style.display = "block"; // needed by IE6 to show the online div at startup (first loaded page) + + // Create a dummy div to add padding + var div = document.createElement('div'); + div.style.padding = "5px"; + oc.appendChild(div); + + this.onlinecontent[tabid] = oc; + return oc; + }, + + removeTabById: function(tabid) + { + // remove the widgets + var tabparent_t = $('pfc_channels_list'); + var tabparent_c = $('pfc_channels_content'); + var tab_t = $('pfc_channel_title'+tabid); + var tab_c = $('pfc_channel_content'+tabid); + tabparent_t.removeChild(tab_t); + tabparent_c.removeChild(tab_c); + + // empty the chat div content + var div_chat = this.getChatContentFromTabId(tabid); + div_chat.innerHTML = ''; + + // remove the tab from the list + var tabpos = indexOf(this.tabids, tabid); + var name = this.tabs[tabpos]; + this.tabids = without(this.tabids, this.tabids[tabpos]); + this.tabs = without(this.tabs, this.tabs[tabpos]); + this.tabtypes = without(this.tabtypes, this.tabtypes[tabpos]); + tabpos = indexOf(this.tabids, this.getTabId()); + if (tabpos<0) tabpos = 0; + this.setTabById(this.tabids[tabpos]); + return name; + }, + + /* + removeTabByName: function(name) + { + var tabid = hex_md5(_to_utf8(name)); + var ret = this.removeTabById(tabid); + if (ret == name) + return tabid; + else + return 0; + }, + */ + + createTab: function(name, tabid, type) + { + // do not create empty tabs + if(name == '') return; + if(tabid == '') return; + + // do not create twice a the same tab + if (this.isCreated(tabid)) return; + + // var tabid = hex_md5(_to_utf8(name)); + //alert(name+'='+tabid); + this.tabs.push(name); + this.tabids.push(tabid); + this.tabtypes.push(type); + + //alert(this.tabs.toString()); + + var li_title = document.createElement('li'); + li_title.setAttribute('id', 'pfc_channel_title'+tabid); + + var li_div = document.createElement('div'); + li_title.appendChild(li_div); + + var img = document.createElement('img'); + img.setAttribute('id', 'pfc_tabimg'+tabid); + if (type == 'ch') + img.setAttribute('src', pfc.res.getFileUrl('images/ch.gif')); + if (type == 'pv') + img.setAttribute('src', pfc.res.getFileUrl('images/pv.gif')); + var a1 = document.createElement('a'); + // Element.addClassName(a1, 'pfc_tabtitle'); + a1.setAttribute('class', 'pfc_tabtitle'); + a1.setAttribute('className', 'pfc_tabtitle'); // for IE6 + a1.appendChild(img); + a1.appendChild(document.createTextNode(name)); + a1.setAttribute('href', '#'); + a1.pfc_tabid = tabid; + a1.onclick = function(){pfc.gui.setTabById(this.pfc_tabid); return false;} + li_div.appendChild(a1); + + var a2 = document.createElement('a'); + a2.pfc_tabid = tabid; + a2.onclick = function(){ + var res = confirm(pfc.res.getLabel('Do you really want to leave this room ?')); + if (res == true) pfc.sendRequest('/leave', this.pfc_tabid); return false; + } + a2.alt = pfc.res.getLabel('Close this tab'); + a2.title = a2.alt; + // Element.addClassName(a2, 'pfc_tabclose'); + a2.setAttribute('class', 'pfc_tabclose'); + a2.setAttribute('className', 'pfc_tabclose'); // for IE6 + var img = document.createElement('img'); + img.setAttribute('src', pfc.res.getFileUrl('images/tab_remove.gif')); + a2.appendChild(img); + li_div.appendChild(a2); + + var div_content = document.createElement('div'); + div_content.setAttribute('id', 'pfc_channel_content'+tabid); + // Element.addClassName(div_content, 'pfc_content'); + div_content.setAttribute('class', 'pfc_content'); + div_content.setAttribute('className', 'pfc_content'); // for IE6 + div_content.style.display = 'none'; + + var div_chat = this.getChatContentFromTabId(tabid); + var div_online = this.getOnlineContentFromTabId(tabid); + div_content.appendChild(div_chat); + div_content.appendChild(div_online); + + $('pfc_channels_list').appendChild(li_title); + $('pfc_channels_content').appendChild(div_content); + + return tabid; + }, + + /** + * This function change the tab icon in order to catch the attention + */ + notifyTab: function(tabid) + { + var tabpos = indexOf(this.tabids, tabid); + var tabtype = this.tabtypes[tabpos]; + var img = $('pfc_tabimg'+tabid); + if (img) ... [truncated message content] |
From: <ke...@us...> - 2006-08-18 16:40:33
|
Revision: 679 Author: kerphi Date: 2006-08-18 09:40:23 -0700 (Fri, 18 Aug 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=679&view=rev Log Message: ----------- - Bug fix: the phpfreechat logo was hidden on IE6 - Add an error message in the static html if no javascript is loaded. This error message is just removed by the javascript code if the chat is created correctly. Modified Paths: -------------- trunk/src/client/chat.js.tpl.php trunk/src/client/pfcgui.js trunk/src/pfci18n.class.php trunk/src/phpfreechat.class.php Modified: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php 2006-08-18 15:03:13 UTC (rev 678) +++ trunk/src/client/chat.js.tpl.php 2006-08-18 16:40:23 UTC (rev 679) @@ -1,3 +1,4 @@ +var pfc_version = '<?php echo $version; ?>'; var pfc_nickname = '<?php echo addslashes($u->nick); ?>'; var pfc_clientid = '<?php echo md5(uniqid(rand(), true)); ?>'; var pfc_title = '<?php echo addslashes($title); ?>'; @@ -80,10 +81,11 @@ "Delete", "Mail", "Color", + "PHP FREE CHAT [powered by phpFreeChat-%s]", ); foreach($labels_to_load as $l) { - echo "pfc.res.setLabel('".$l."','".addslashes(_pfc($l))."');\n"; + echo "pfc.res.setLabel('".$l."','".addslashes(_pfc2($l))."');\n"; } $fileurl_to_load = Modified: trunk/src/client/pfcgui.js =================================================================== --- trunk/src/client/pfcgui.js 2006-08-18 15:03:13 UTC (rev 678) +++ trunk/src/client/pfcgui.js 2006-08-18 16:40:23 UTC (rev 679) @@ -320,8 +320,7 @@ { var container = $('pfc_container'); - // move the logo - var logo = $('pfc_logo'); + // clean the chat box container.innerHTML = ''; // minimize/maximize button @@ -378,8 +377,18 @@ inputcontainer.appendChild(cmdcontainer); // move the phpfreechat logo into the cmd container box - cmdcontainer.appendChild(logo); - + var a = document.createElement('a'); + a.setAttribute('id', 'pfc_logo'); + a.setAttribute('href','http://www.phpfreechat.net'); + if (pfc_openlinknewwindow) + a.onclick = function(){ window.open(this.href,'_blank'); return false; } + var img = document.createElement('img'); + img.setAttribute('src', 'http://www.phpfreechat.net/pub/logo_80x15.gif'); + img.setAttribute('alt', pfc.res.getLabel("PHP FREE CHAT [powered by phpFreeChat-%s]",pfc_version)); + img.title = img.alt; + a.appendChild(img); + cmdcontainer.appendChild(a); + // handle box : <input id="pfc_handle" type="button" ... var handle = document.createElement('p'); handle.setAttribute('id', 'pfc_handle'); Modified: trunk/src/pfci18n.class.php =================================================================== --- trunk/src/pfci18n.class.php 2006-08-18 15:03:13 UTC (rev 678) +++ trunk/src/pfci18n.class.php 2006-08-18 16:40:23 UTC (rev 679) @@ -32,6 +32,20 @@ "_".$args[0]."_"; return call_user_func_array('sprintf', $args); } +/** + * Just like _pfc but just return the raw translated string, keeping the %s into it + * (used byt the javascript resources (i18n) class) + */ +function _pfc2() +{ + $args = func_get_args(); + $args[0] = isset($GLOBALS["i18n"][$args[0]]) && $GLOBALS["i18n"][$args[0]] != "" ? + ($GLOBALS["output_encoding"] == "UTF-8" ? + $GLOBALS["i18n"][$args[0]] : + iconv("UTF-8", $GLOBALS["output_encoding"], $GLOBALS["i18n"][$args[0]])) : + "_".$args[0]."_"; + return $args[0]; +} class pfcI18N { Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-08-18 15:03:13 UTC (rev 678) +++ trunk/src/phpfreechat.class.php 2006-08-18 16:40:23 UTC (rev 679) @@ -175,7 +175,8 @@ // or keep a backling to http://www.phpfreechat on your partner page // it helps phpfreechat promotion over the Web. // (remember it's a free program) - $output .= "<a href=\"http://www.phpfreechat.net\" id=\"pfc_logo\"".($c->openlinknewwindow ? ' onclick="window.open(this.href,\'_blank\');return false;"' : '')."><img src=\"http://www.phpfreechat.net/pub/logo_80x15.gif\" alt=\""._pfc("PHP FREE CHAT [powered by phpFreeChat-%s]", $c->version)."\" title=\""._pfc("PHP FREE CHAT [powered by phpFreeChat-%s]", $c->version)."\" /></a>"; + $output .= "<p>"._pfc("Error: the chat cannot be loaded, check the public directory rights or ask some help on the forum")." <a href=\"http://www.phpfreechat.net/forum/\">www.phpfreechat.net/forum</a></p>"; + $output .= "<a href=\"http://www.phpfreechat.net\"><img src=\"http://www.phpfreechat.net/pub/logo_80x15.gif\" alt=\"PHP FREE CHAT [powered by phpFreeChat-".$c->version."]\" title=\"PHP FREE CHAT [powered by phpFreeChat-".$c->version."]\" /></a>"; $output .= "</div>"; $output .= "<script type=\"text/javascript\">\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-08-18 21:45:00
|
Revision: 680 Author: kerphi Date: 2006-08-18 14:44:47 -0700 (Fri, 18 Aug 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=680&view=rev Log Message: ----------- Now the pfcResource::getLabel javascript method can handle multi-parameters. Modified Paths: -------------- trunk/src/client/pfcresource.js trunk/src/phpfreechat.class.php Added Paths: ----------- trunk/lib/javascript/sprintf2.js Added: trunk/lib/javascript/sprintf2.js =================================================================== --- trunk/lib/javascript/sprintf2.js (rev 0) +++ trunk/lib/javascript/sprintf2.js 2006-08-18 21:44:47 UTC (rev 680) @@ -0,0 +1,27 @@ +function sprintf2(arg) { + if( arg.length < 2 ) { + return arg[0]; + } + var data = arg[ 0 ]; + for( var k=1; k<arg.length; ++k ) { + switch( typeof( arg[ k ] ) ) + { + case 'string': + data = data.replace( /%s/, arg[ k ] ); + break; + case 'number': + data = data.replace( /%d/, arg[ k ] ); + break; + case 'boolean': + data = data.replace( /%b/, arg[ k ] ? 'true' : 'false' ); + break; + default: + /// function | object | undefined + break; + } + } + return( data ); +} +if( !String.sprintf2 ) { + String.sprintf2 = sprintf2; +} \ No newline at end of file Modified: trunk/src/client/pfcresource.js =================================================================== --- trunk/src/client/pfcresource.js 2006-08-18 16:40:23 UTC (rev 679) +++ trunk/src/client/pfcresource.js 2006-08-18 21:44:47 UTC (rev 680) @@ -19,10 +19,11 @@ this.labels[key] = value; }, - getLabel: function(key, params) + getLabel: function() { + var key = this.getLabel.arguments[0]; if (this.labels[key]) - return this.labels[key]; + return String.sprintf2(this.getLabel.arguments); //this.labels[key]; else return ""; }, @@ -62,3 +63,20 @@ } }; + + + + + + + + + + + + + + + + + Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-08-18 16:40:23 UTC (rev 679) +++ trunk/src/phpfreechat.class.php 2006-08-18 21:44:47 UTC (rev 680) @@ -108,6 +108,7 @@ $js[] = "lib/javascript/myprototype.js"; $js[] = "lib/javascript/regex.js"; $js[] = "lib/javascript/utf8.js"; + $js[] = "lib/javascript/sprintf2.js"; $js[] = "src/client/pfcclient.js"; $js[] = "src/client/pfcgui.js"; $js[] = "src/client/pfcresource.js"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-08-22 14:34:40
|
Revision: 695 Author: kerphi Date: 2006-08-22 07:34:33 -0700 (Tue, 22 Aug 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=695&view=rev Log Message: ----------- fix miniblune theme (width parameter) Modified Paths: -------------- trunk/demo/demo44_green_theme.php trunk/src/phpfreechat.class.php Modified: trunk/demo/demo44_green_theme.php =================================================================== --- trunk/demo/demo44_green_theme.php 2006-08-22 14:29:51 UTC (rev 694) +++ trunk/demo/demo44_green_theme.php 2006-08-22 14:34:33 UTC (rev 695) @@ -12,7 +12,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> - <title>Blune PHPFreeChat</title> + <title> PHPFreeChat - Green theme</title> <?php $chat->printJavascript(); ?> <?php $chat->printStyle(); ?> </head> Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-08-22 14:29:51 UTC (rev 694) +++ trunk/src/phpfreechat.class.php 2006-08-22 14:34:33 UTC (rev 695) @@ -170,7 +170,7 @@ $u =& pfcUserConfig::Instance(); - $output = "<div id=\"pfc_container\">"; + $output = "<div id=\"pfc_container\"".($c->width != "" ? "style=\"width:".$c->width."\"": "").">"; // Please do not remove these lines, // or keep a backling to http://www.phpfreechat on your partner page This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-08-23 16:37:09
|
Revision: 698 Author: kerphi Date: 2006-08-23 09:36:49 -0700 (Wed, 23 Aug 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=698&view=rev Log Message: ----------- Add a basic log proxy which store all chat messages into a simple file (chat.log) Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php Added Paths: ----------- trunk/src/proxys/log.class.php Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-08-23 09:44:16 UTC (rev 697) +++ trunk/src/pfcglobalconfig.class.php 2006-08-23 16:36:49 UTC (rev 698) @@ -41,10 +41,11 @@ var $lockurl = "http://www.phpfreechat.net"; // this is the url where the users must be redirected when the chat is locked // these parameters are static (cached) - var $proxys = array("lock", "auth", "noflood", "censor"); + var $proxys = array("lock", "auth", "noflood", "censor", "log"); var $proxys_cfg = array("auth" => array(), "noflood" => array("limit"=>10,"delay"=>5), - "censor" => array("words"=>array("fuck","sex","bitch"),"replaceby"=>"*")); + "censor" => array("words"=>array("fuck","sex","bitch"),"replaceby"=>"*"), + "log" => array("path"=>"")); var $title = ""; // default is _pfc("My Chat") var $channels = array(); // the default joined channels when opening the chat var $frozen_channels = array(); // by default allow users to create there own channels Added: trunk/src/proxys/log.class.php =================================================================== --- trunk/src/proxys/log.class.php (rev 0) +++ trunk/src/proxys/log.class.php 2006-08-23 16:36:49 UTC (rev 698) @@ -0,0 +1,66 @@ +<?php +/** + * log.class.php + * + * Copyright © 2006 Stephane Gully <ste...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + */ +require_once dirname(__FILE__)."/../pfci18n.class.php"; +require_once dirname(__FILE__)."/../pfcuserconfig.class.php"; +require_once dirname(__FILE__)."/../pfcproxycommand.class.php"; + +/** + * pfcProxyCommand_log + * this proxy will log "everything" from the chat + * @author Stephane Gully <ste...@gm...> + */ +class pfcProxyCommand_log extends pfcProxyCommand +{ + function run(&$xml_reponse, $p) + { + $cmdtocheck = array("send", "me", "notice"); + if ( in_array($this->name, $cmdtocheck) ) + { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; + $u =& $this->u; + + $logpath = ($c->proxys_cfg[$this->proxyname]["path"] == "" ? $c->data_public_path : + $c->proxys_cfg[$this->proxyname]["path"]); + $logfile = $logpath."/".$c->getId()."/chat.log"; + + if (!is_writable($logpath)) + { + if ((file_exists($logfile) && is_writable($logpath)) || + (!file_exists($logfile))) + { + $fp = fopen($logfile, 'a'); + fwrite($fp, $recipient." -> ".$param."\n"); + } + } + } + + // forward the command to the next proxy or to the final command + $this->next->run($xml_reponse, $p); + } +} + +?> \ 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...> - 2006-08-25 19:40:48
|
Revision: 702 Author: kerphi Date: 2006-08-25 12:40:39 -0700 (Fri, 25 Aug 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=702&view=rev Log Message: ----------- [en] New parameters to easily customize the nickname color list and the bbcode text colors: nickname_colorlist and bbcode_colorlist. [fr] Nouveaux param?\195?\168ters permettant de personnaliser facilement la liste des couleurs des pseudonymes et du texte (bbcode)?\194?\160: nickname_colorlist and bbcode_colorlist. Modified Paths: -------------- trunk/src/client/chat.js.tpl.php trunk/src/pfcglobalconfig.class.php Modified: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php 2006-08-25 19:37:08 UTC (rev 701) +++ trunk/src/client/chat.js.tpl.php 2006-08-25 19:40:39 UTC (rev 702) @@ -33,19 +33,13 @@ echo implode(",", $list); ?>); var pfc_openlinknewwindow = <?php echo $openlinknewwindow ? "true" : "false"; ?>; -<?php -$bbcode_clist = array("FFFFFF","000000","000055","008000","FF0000","800000","800080","FF5500","FFFF00","00FF00","008080","00FFFF","0000FF","FF00FF","7F7F7F","D2D2D2"); -?> var pfc_bbcode_color_list = Array(<?php - $list = array(); foreach($bbcode_clist as $v) {$list[] = $v;} - $list = array_map("quoteandescape",$list); - echo implode(",", $list); - ?>); -<?php -$nickname_clist = array('#CCCCCC','#000000','#3636B2','#2A8C2A','#C33B3B','#C73232','#80267F','#66361F','#D9A641','#3DCC3D','#1A5555','#2F8C74','#4545E6','#B037B0','#4C4C4C','#959595'); -?> + $list = array(); foreach($bbcode_colorlist as $v) {$list[] = substr($v,1);} + $list = array_map("quoteandescape",$list); + echo implode(",", $list); + ?>); var pfc_nickname_color_list = Array(<?php - $list = array(); foreach($nickname_clist as $v) {$list[] = $v;} + $list = array(); foreach($nickname_colorlist as $v) {$list[] = $v;} $list = array_map("quoteandescape",$list); echo implode(",", $list); ?>); @@ -118,9 +112,8 @@ ); // convert bbcode color value list to a bbcode color url list -function get_bbcode_color_url($v) { return 'images/color_'.$v.'.gif'; } -$bbcode_clist = array_map("get_bbcode_color_url",$bbcode_clist); - +function get_bbcode_color_url($v) { return 'images/color_'.substr($v,1).'.gif'; } +$bbcode_clist = array_map("get_bbcode_color_url", $bbcode_colorlist); $fileurl_to_load = array_merge($fileurl_to_load, $bbcode_clist); foreach($fileurl_to_load as $f) { Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-08-25 19:37:08 UTC (rev 701) +++ trunk/src/pfcglobalconfig.class.php 2006-08-25 19:40:39 UTC (rev 702) @@ -70,7 +70,9 @@ var $showsmileys = true; var $btn_sh_whosonline = true; // display show/hide button for who is online var $btn_sh_smileys = true; // display show/hide button for smileys - + var $bbcode_colorlist = array("#FFFFFF","#000000","#000055","#008000","#FF0000","#800000","#800080","#FF5500","#FFFF00","#00FF00","#008080","#00FFFF","#0000FF","#FF00FF","#7F7F7F","#D2D2D2"); + var $nickname_colorlist = array('#CCCCCC','#000000','#3636B2','#2A8C2A','#C33B3B','#C73232','#80267F','#66361F','#D9A641','#3DCC3D','#1A5555','#2F8C74','#4545E6','#B037B0','#4C4C4C','#959595'); + var $theme = "default"; var $themepath = ""; var $themeurl = ""; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-08-28 21:08:29
|
Revision: 712 Author: kerphi Date: 2006-08-28 14:08:22 -0700 (Mon, 28 Aug 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=712&view=rev Log Message: ----------- remove csstidy library Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php Removed Paths: ------------- trunk/lib/csstidy-1.1/ Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-08-28 21:06:30 UTC (rev 711) +++ trunk/src/pfcglobalconfig.class.php 2006-08-28 21:08:22 UTC (rev 712) @@ -89,8 +89,6 @@ var $server_script_url = ""; // default is calculated from 'server_script_path' var $xajaxpath = ""; // default is dirname(__FILE__)."/../lib/xajax_0.2.3"; var $jspath = ""; // default is dirname(__FILE__)."/../lib/javascript"; - var $usecsstidy = false; - var $csstidypath = ""; // default is dirname(__FILE__)."/../lib/csstidy-1.1"; var $data_private_path = ""; // default is dirname(__FILE__)."/../data/private"; var $data_public_path = ""; // default is dirname(__FILE__)."/../data/public"; var $data_public_url = ""; // default is calculated from 'data_public_path' path @@ -217,7 +215,6 @@ if ($this->title == "") $this->title = _pfc("My Chat"); if ($this->xajaxpath == "") $this->xajaxpath = dirname(__FILE__)."/../lib/xajax_0.2.3"; if ($this->jspath == "") $this->jspath = dirname(__FILE__)."/../lib/javascript"; - if ($this->csstidypath == "") $this->csstidypath = dirname(__FILE__)."/../lib/csstidy-1.1"; if (is_array($this->channels) && count($this->channels) == 0) $this->channels = array(_pfc("My room")); // first of all, check the used functions This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-02 20:15:12
|
Revision: 723 http://svn.sourceforge.net/phpfreechat/?rev=723&view=rev Author: kerphi Date: 2006-09-02 13:14:57 -0700 (Sat, 02 Sep 2006) Log Message: ----------- The proxy log data must be saved by default in the private directory Modified Paths: -------------- trunk/src/pfctools.php trunk/src/proxys/log.class.php Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2006-09-01 15:11:27 UTC (rev 722) +++ trunk/src/pfctools.php 2006-09-02 20:14:57 UTC (rev 723) @@ -112,7 +112,7 @@ } -function mkdir_r($path, $modedir = 0700) +function mkdir_r($path, $modedir = 0775) { // This function creates the specified directory using mkdir(). Note // that the recursive feature on mkdir() is broken with PHP 5.0.4 for @@ -146,7 +146,7 @@ * @param string $dest Destination path * @return bool Returns TRUE on success, FALSE on failure */ -function copy_r($source, $dest, $modedir = 0755, $modefile = 0644) +function copy_r($source, $dest, $modedir = 0775, $modefile = 0664) { // Simple copy for a file if (is_file($source)) { Modified: trunk/src/proxys/log.class.php =================================================================== --- trunk/src/proxys/log.class.php 2006-09-01 15:11:27 UTC (rev 722) +++ trunk/src/proxys/log.class.php 2006-09-02 20:14:57 UTC (rev 723) @@ -43,23 +43,31 @@ $c =& $this->c; $u =& $this->u; - $logpath = ($c->proxys_cfg[$this->proxyname]["path"] == "" ? $c->data_public_path : - $c->proxys_cfg[$this->proxyname]["path"]); - $logfile = $logpath."/".$c->getId()."/chat.log"; - if (is_writable($logpath)) + $logpath = ($c->proxys_cfg[$this->proxyname]["path"] == "" ? $c->data_private_path."/logs" : + $c->proxys_cfg[$this->proxyname]["path"]); + $logpath .= "/".$c->getId(); + + if (!file_exists($logpath)) @mkdir_r($logpath); + if (file_exists($logpath) && is_writable($logpath)) { + $logfile = $logpath."/chat.log"; $f_exists = file_exists($logfile); if (($f_exists && is_writable($logpath)) || !$f_exists) { $fp = fopen($logfile, $f_exists ? 'a' : 'w'); // @todo write logs in a cleaner structured language (xml, html ... ?) - fwrite($fp, $recipient."\t".$sender."\t".$param."\n"); + $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); } } } - + // forward the command to the next proxy or to the final command $this->next->run($xml_reponse, $p); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-02 21:20:35
|
Revision: 726 http://svn.sourceforge.net/phpfreechat/?rev=726&view=rev Author: kerphi Date: 2006-09-02 14:20:15 -0700 (Sat, 02 Sep 2006) Log Message: ----------- Now display the errors when messages can't be written in the default file container Modified Paths: -------------- trunk/src/commands/notice.class.php trunk/src/commands/send.class.php trunk/src/containers/file.class.php Modified: trunk/src/commands/notice.class.php =================================================================== --- trunk/src/commands/notice.class.php 2006-09-02 20:42:09 UTC (rev 725) +++ trunk/src/commands/notice.class.php 2006-09-02 21:20:15 UTC (rev 726) @@ -21,7 +21,15 @@ { $container =& $c->getContainerInstance(); $msg = phpFreeChat::FilterSpecialChar($msg); - $container->write($recipient, $u->nick, "notice", $msg); + $res = $container->write($recipient, $u->nick, "notice", $msg); + if (is_array($res)) + { + $cmdp = $p; + $cmdp["param"] = implode(",",$res); + $cmd =& pfcCommand::Factory("error"); + $cmd->run($xml_reponse, $cmdp); + return; + } } if ($c->debug) pxlog("/notice ".$msg." (flag=".$flag.")", "chat", $c->getId()); } Modified: trunk/src/commands/send.class.php =================================================================== --- trunk/src/commands/send.class.php 2006-09-02 20:42:09 UTC (rev 725) +++ trunk/src/commands/send.class.php 2006-09-02 21:20:15 UTC (rev 726) @@ -79,6 +79,14 @@ { $container =& $c->getContainerInstance(); $msgid = $container->write($recipient, $nick, "send", $text); + if (is_array($msgid)) + { + $cmdp = $p; + $cmdp["param"] = implode(",",$msgid); + $cmd =& pfcCommand::Factory("error"); + $cmd->run($xml_reponse, $cmdp); + return; + } if ($c->debug) pxlog("/send ".$text." (a user just sent a message -> nick=".$u->nick.")", "chat", $c->getId()); // a message has been posted so : Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2006-09-02 20:42:09 UTC (rev 725) +++ trunk/src/containers/file.class.php 2006-09-02 21:20:15 UTC (rev 726) @@ -459,9 +459,11 @@ $c->container_cfg_server_dir."/messages"; // check the messages directory exists $errors = @test_writable_dir($msg_dir, $chan."/messages"); + if (count($errors) > 0) return $errors; // an error occurs ? // request a unique id for this new message $msg_id = $this->_requestMsgId($chan); + if (is_array($msg_id)) return $msg_id; // an error occurs ? $msg_filename = $msg_dir."/".$msg_id; // format message @@ -706,6 +708,7 @@ $c->container_cfg_server_dir; // check the directory exists $errors = @test_writable_dir($chan_dir, $chan_dir); + if (count($errors) > 0) return $errors; $index_filename = $chan_dir . "/messages.index"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-05 16:24:35
|
Revision: 734 http://svn.sourceforge.net/phpfreechat/?rev=734&view=rev Author: kerphi Date: 2006-09-05 09:24:23 -0700 (Tue, 05 Sep 2006) Log Message: ----------- [en] - Makes possible to use frozen_nick with a empty nick parameter. So it's possible to choose the nick at beginning of the session then it's impossible to change it. [fr] - Rend possible l'utilisation de frozen_nick avec un pseudonyme vide. Ainsi c'est possible de choisir son pseudo a la premi?\195?\168re connexion et ensuite c'est impossible de le changer. [en] - Make possible to change dynamicaly the user nickname using the parameter array (however, frozen_nick must be on) [fr] - On peut maintenant forcer un utilisateur ?\195?\160 changer de pseudo dynamiquement (ex: si l'utilisateur change de pseudo dans le syst?\195?\168me d'authentification hote). Pour cela il suffit d'assigner un nouveau nick dans les parametres en plein milieur de l'execution. Bien sur frozen_nick doit ?\195?\170tre activ?\195?\169! Modified Paths: -------------- trunk/src/client/chat.js.tpl.php trunk/src/client/pfcclient.js trunk/src/commands/nick.class.php trunk/src/pfcglobalconfig.class.php trunk/src/pfcuserconfig.class.php trunk/src/phpfreechat.class.php trunk/src/proxys/auth.class.php Added Paths: ----------- trunk/src/proxys/checknickchange.class.php Modified: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php 2006-09-04 20:41:46 UTC (rev 733) +++ trunk/src/client/chat.js.tpl.php 2006-09-05 16:24:23 UTC (rev 734) @@ -1,5 +1,6 @@ +<?php $nick = $u->nick != "" ? addslashes($u->nick) : addslashes($c->nick); ?> +var pfc_nickname = '<?php echo ($GLOBALS["output_encoding"]=="UTF-8" ? $nick : iconv("UTF-8", $GLOBALS["output_encoding"],$nick)); ?>'; var pfc_version = '<?php echo $version; ?>'; -var pfc_nickname = '<?php echo ($GLOBALS["output_encoding"]=="UTF-8" ? addslashes($u->nick) : iconv("UTF-8", $GLOBALS["output_encoding"],addslashes($u->nick))); ?>'; var pfc_clientid = '<?php echo md5(uniqid(rand(), true)); ?>'; var pfc_title = '<?php echo addslashes($title); ?>'; var pfc_refresh_delay = <?php echo $refresh_delay; ?>; @@ -78,6 +79,7 @@ "Enter the text to format", // _pfc "Configuration has been rehashed", // _pfc "A problem occurs during rehash", // _pfc + "Choosen nickname is allready used", //_pfc ); foreach($labels_to_load as $l) { Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-09-04 20:41:46 UTC (rev 733) +++ trunk/src/client/pfcclient.js 2006-09-05 16:24:23 UTC (rev 734) @@ -306,7 +306,7 @@ } else if (resp == "isused") { - this.askNick(param); + this.displayMsg( cmd, this.res.getLabel('Choosen nickname is allready used') ); } else alert(cmd + "-"+resp+"-"+param); @@ -374,6 +374,10 @@ { this.displayMsg( cmd, param ); } + else if (cmd == "checknickchange") + { + this.displayMsg( cmd, param ); + } else alert(cmd + "-"+resp+"-"+param); }, Modified: trunk/src/commands/nick.class.php =================================================================== --- trunk/src/commands/nick.class.php 2006-09-04 20:41:46 UTC (rev 733) +++ trunk/src/commands/nick.class.php 2006-09-05 16:24:23 UTC (rev 734) @@ -31,111 +31,64 @@ $newnick = phpFreeChat::FilterNickname($param); $oldnick = $u->nick; - if ($c->debug) pxlog("/nick ".$newnick, "chat", $c->getId()); - $container =& $c->getContainerInstance(); $newnickid = $container->getNickId($newnick); - $oldnickid = $container->getNickId($u->nick); + $oldnickid = $container->getNickId($oldnick); - // now check unsensitive case - // 'BoB' and 'bob' must be considered same nicknames - $nick_in_use = false; - $online_users = $container->getOnlineNick(NULL); - if (isset($online_users["nickid"])) - foreach($online_users["nickid"] as $nid) - { - if (preg_match("/^".preg_quote($container->getNickname($nid))."$/i",$newnick)) - { - // the nick match - // just allow the owner to change his capitalised letters - if ($nid != $oldnickid) - $nick_in_use = true; - } - } + if ($c->debug) pxlog("/nick ".$newnick, "chat", $c->getId()); - if ( $newnickid == "undefined" && !$nick_in_use ) + // new nickname is undefined (not used) and + // current nickname (oldnick) is mine and + // oldnick is different from new nick + // -> this is a nickname change + if ($oldnickid == $u->nickid && + $oldnick != $newnick && $oldnick != "") { - // new nickname is undefined (not used) and - // current nickname (oldnick) is mine and - // oldnick is different from new nick - // -> this is a nickname change - if ($oldnickid == $u->nickid && - $oldnick != $newnick && $oldnick != "") - { - // really change the nick (rename it) - $container->changeNick($newnick, $oldnick); - $u->nick = $newnick; - $u->saveInCache(); + // really change the nick (rename it) + $container->changeNick($newnick, $oldnick); + $u->nick = $newnick; + $u->saveInCache(); - // notify all the joined channels/privmsg - $cmdp = $p; - $cmdp["param"] = _pfc("%s changes his nickname to %s",$oldnick,$newnick); - $cmdp["flag"] = 1; - $cmd =& pfcCommand::Factory("notice"); - foreach($u->channels as $id => $chan) - { - $cmdp["recipient"] = $chan["recipient"]; - $cmdp["recipientid"] = $id; - $cmd->run($xml_reponse, $cmdp); - } - foreach( $u->privmsg as $id => $pv ) - { - $cmdp["recipient"] = $pv["recipient"]; - $cmdp["recipientid"] = $id; - $cmd->run($xml_reponse, $cmdp); - } - $xml_reponse->addScript("pfc.handleResponse('nick', 'changed', '".addslashes($newnick)."');"); + // notify all the joined channels/privmsg + $cmdp = $p; + $cmdp["param"] = _pfc("%s changes his nickname to %s",$oldnick,$newnick); + $cmdp["flag"] = 1; + $cmd =& pfcCommand::Factory("notice"); + foreach($u->channels as $id => $chan) + { + $cmdp["recipient"] = $chan["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); } - - // new nickname is undefined (not used) and - // current nickname (oldnick) is not mine or is undefined - // -> this is a first connection - if ($oldnickid != $u->nickid) + foreach( $u->privmsg as $id => $pv ) { - // this is a first connection (create the nickname) - $container->createNick(NULL, $newnick, $u->nickid); - foreach($u->channels as $chan) - $container->createNick($chan["recipient"], $newnick, $u->nickid); - foreach($u->privmsg as $pv) - $container->createNick($pv["recipient"], $newnick, $u->nickid); - $u->nick = $newnick; - $u->active = true; - $u->saveInCache(); - - $xml_reponse->addScript("pfc.handleResponse('nick', 'connected', '".addslashes($newnick)."');"); - - if ($c->debug) - pxlog("/nick ".$newnick." (first connection, oldnick=".$oldnick.")", "chat", $c->getId()); + $cmdp["recipient"] = $pv["recipient"]; + $cmdp["recipientid"] = $id; + $cmd->run($xml_reponse, $cmdp); } - - // force the handle field to be uptodate - // $xml_reponse->addAssign($c->prefix."handle", "value", $newnick); - //$xml_reponse->addScript("$('".$c->prefix."words').focus();"); - + $xml_reponse->addScript("pfc.handleResponse('nick', 'changed', '".addslashes($newnick)."');"); } - else if ($newnickid == $u->nickid) + + // new nickname is undefined (not used) and + // current nickname (oldnick) is not mine or is undefined + // -> this is a first connection + if ($oldnickid != $u->nickid) { - // user didn't change his nickname - //$xml_reponse->addAssign($c->prefix."handle", "value", $newnick); - $xml_reponse->addScript("pfc.handleResponse('nick', 'notchanged', '".addslashes($newnick)."');"); + // this is a first connection (create the nickname) + $container->createNick(NULL, $newnick, $u->nickid); + foreach($u->channels as $chan) + $container->createNick($chan["recipient"], $newnick, $u->nickid); + foreach($u->privmsg as $pv) + $container->createNick($pv["recipient"], $newnick, $u->nickid); + $u->nick = $newnick; + $u->active = true; + $u->saveInCache(); + $xml_reponse->addScript("pfc.handleResponse('nick', 'connected', '".addslashes($newnick)."');"); + if ($c->debug) - pxlog("/nick ".$newnick." (user just reloded the page so let him keep his nickname without any warnings -> nickid=".$newnickid.")", "chat", $c->getId()); + pxlog("/nick ".$newnick." (first connection, oldnick=".$oldnick.")", "chat", $c->getId()); } - else - { - // the wanted nick is allready used, just ask again the user - //$cmd =& pfcCommand::Factory("asknick"); - //$cmd->run($xml_reponse, $clientid, $newnick, $sender, $recipient); - - $xml_reponse->addScript("pfc.handleResponse('nick', 'isused', '".addslashes($newnick)."');"); - - if ($c->debug) - pxlog("/nick ".$newnick." (wanted nick is allready in use -> wantednickid=".$newnickid.")", "chat", $c->getId()); - } - - // refresh users info on client side - //$xml_reponse->addScript("pfc.nickname = '".$u->nick."';"); } } Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-09-04 20:41:46 UTC (rev 733) +++ trunk/src/pfcglobalconfig.class.php 2006-09-05 16:24:23 UTC (rev 734) @@ -41,7 +41,7 @@ var $lockurl = "http://www.phpfreechat.net"; // this is the url where the users must be redirected when the chat is locked // these parameters are static (cached) - var $proxys = array("lock", "auth", "noflood", "censor", "log"); + var $proxys = array("lock", "auth", "checknickchange", "noflood", "censor", "log"); var $proxys_cfg = array("auth" => array(), "noflood" => array("limit"=>10,"delay"=>5), "censor" => array("words"=>array("fuck","sex","bitch"),"replaceby"=>"*"), @@ -398,11 +398,6 @@ // load debug url $this->debugurl = relativePath($this->client_script_path, dirname(__FILE__)."/../debug"); - - // check the frozen_nick parameter is used with a none empty nickname - if ($this->frozen_nick && $this->nick == "") - $this->errors[] = _pfc("frozen_nick can't be used with a empty nick"); - // check the language is known $lg_list = pfcI18N::GetAcceptedLanguage(); if ( $this->language != "" && !in_array($this->language, $lg_list) ) @@ -433,10 +428,6 @@ // load smileys from file $this->loadSmileyTheme(); - // do not froze nickname if it has not be specified - if ($this->nick == "" && $this->frozen_nick) - $this->frozen_nick = false; - // load version number from file $this->version = trim(file_get_contents(dirname(__FILE__)."/../version")); Modified: trunk/src/pfcuserconfig.class.php =================================================================== --- trunk/src/pfcuserconfig.class.php 2006-09-04 20:41:46 UTC (rev 733) +++ trunk/src/pfcuserconfig.class.php 2006-09-05 16:24:23 UTC (rev 734) @@ -30,7 +30,7 @@ // user parameters are cached in sessions $this->_getParam("nick"); - if (!isset($this->nick)) $this->_setParam("nick",$c->nick); + if (!isset($this->nick)) $this->_setParam("nick",""); // setup a blank nick if it is not yet in session $this->_getParam("active"); if (!isset($this->active)) $this->_setParam("active",false); $this->_getParam("channels"); @@ -57,8 +57,7 @@ function _setParam($p, $v) { $c =& pfcGlobalConfig::Instance(); - $nickid = "pfcuserconfig_".$c->getId(); - $nickid_param = $nickid."_".$p; + $nickid_param = "pfcuserconfig_".$c->getId()./*"_".$this->nickid.*/"_".$p; $_SESSION[$nickid_param] = $v; $this->$p = $v; } @@ -66,8 +65,7 @@ function _rmParam($p) { $c =& pfcGlobalConfig::Instance(); - $nickid = "pfcuserconfig_".$c->getId(); - $nickid_param = $nickid."_".$p; + $nickid_param = "pfcuserconfig_".$c->getId()./*"_".$this->nickid.*/"_".$p; unset($_SESSION[$nickid_param]); unset($this->$p); } Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-09-04 20:41:46 UTC (rev 733) +++ trunk/src/phpfreechat.class.php 2006-09-05 16:24:23 UTC (rev 734) @@ -247,9 +247,9 @@ foreach ($s_strs as $s_str) { $s_str = stripslashes($s_str); /* the :'( smileys needs this filter */ - $query .= preg_quote($s_str,'/')."|"; - $search[] = "/".preg_quote($s_str,'/')."/"; - $replace[] = '<img src="'.$s_file.'" alt="'.$s_str.'" title="'.$s_str.'" />'; + $query .= preg_quote($s_str,'/')."|"; + $search[] = "/".preg_quote($s_str,'/')."/"; + $replace[] = '<img src="'.$s_file.'" alt="'.$s_str.'" title="'.$s_str.'" />'; } } $query = substr($query, 0, strlen($query)-1); @@ -425,9 +425,9 @@ { // call the command if ($c->debug) - $cmd->run($xml_reponse, $cmdp); + $cmd->run($xml_reponse, $cmdp); else - @$cmd->run($xml_reponse, $cmdp); + @$cmd->run($xml_reponse, $cmdp); } else { @@ -447,8 +447,8 @@ // do not update twice // do not update when the user just quit if ($rawcmd != "update" && - $rawcmd != "quit" && - $u->nick != "") + $rawcmd != "quit" && + $u->nick != "") { // force an update just after a command is sent // thus the message user just poster is really fastly displayed @@ -460,9 +460,9 @@ $cmdp["recipient"] = $recipient; $cmdp["recipientid"] = $recipientid; if ($c->debug) - $cmd->run($xml_reponse, $cmdp); + $cmd->run($xml_reponse, $cmdp); else - @$cmd->run($xml_reponse, $cmdp); + @$cmd->run($xml_reponse, $cmdp); } if ($c->debug) Modified: trunk/src/proxys/auth.class.php =================================================================== --- trunk/src/proxys/auth.class.php 2006-09-04 20:41:46 UTC (rev 733) +++ trunk/src/proxys/auth.class.php 2006-09-05 16:24:23 UTC (rev 734) @@ -85,18 +85,6 @@ } } } - - // disallow to change nickname if frozen_nick is true - if ($this->name == "nick") - { - if ($param != $c->nick && - $c->frozen_nick == true) - { - $msg = _pfc("You are not allowed to change your nickname", $param); - $xml_reponse->addScript("pfc.handleResponse('".$this->proxyname."', 'nick', '".addslashes($msg)."');"); - return; - } - } // forward the command to the next proxy or to the final command $p["clientid"] = $clientid; Added: trunk/src/proxys/checknickchange.class.php =================================================================== --- trunk/src/proxys/checknickchange.class.php (rev 0) +++ trunk/src/proxys/checknickchange.class.php 2006-09-05 16:24:23 UTC (rev 734) @@ -0,0 +1,128 @@ +<?php +/** + * checknickchange.class.php + * + * Copyright © 2006 Stephane Gully <ste...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + */ +require_once dirname(__FILE__)."/../pfci18n.class.php"; +require_once dirname(__FILE__)."/../pfcuserconfig.class.php"; +require_once dirname(__FILE__)."/../pfcproxycommand.class.php"; + +/** + * pfcProxyCommand_checknickchange + * + * @author Stephane Gully <ste...@gm...> + */ +class pfcProxyCommand_checknickchange extends pfcProxyCommand +{ + function run(&$xml_reponse, $p) + { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + + $c =& $this->c; + $u =& $this->u; + + if ( $this->name == "nick") + { + $newnick = phpFreeChat::FilterNickname($param); + $oldnick = $u->nick; + + if ($newnick == $oldnick) + { + $xml_reponse->addScript("pfc.handleResponse('nick', 'notchanged', '".addslashes($newnick)."');"); + if ($c->debug) + pxlog("/nick ".$newnick." (user just reloded the page so let him keep his nickname without any warnings -> nickid=".$newnickid.")", "chat", $c->getId()); + return; + } + + // if the user want to change his nickname but the frozen_nick is enable + // then send him a warning + if ( $this->name == "nick" && + $u->nick != "" && + $param != $u->nick && + $c->frozen_nick == true && + $p["owner"] != "checknickchange" ) + { + $msg = _pfc("You are not allowed to change your nickname"); + $xml_reponse->addScript("pfc.handleResponse('".$this->proxyname."', 'nick', '".addslashes($msg)."');"); + return; + } + + $container =& $c->getContainerInstance(); + $newnickid = $container->getNickId($newnick); + $oldnickid = $container->getNickId($oldnick); + + // now check the nickname is not yet used (unsensitive case) + // 'BoB' and 'bob' must be considered same nicknames + $nick_in_use = false; + $online_users = $container->getOnlineNick(NULL); + if (isset($online_users["nickid"])) + foreach($online_users["nickid"] as $nid) + { + if (preg_match("/^".preg_quote($container->getNickname($nid))."$/i",$newnick)) + { + // the nick match + // just allow the owner to change his capitalised letters + if ($nid != $oldnickid) + $nick_in_use = true; + } + } + if ($nick_in_use) + { + $xml_reponse->addScript("pfc.handleResponse('nick', 'isused', '".addslashes($newnick)."');"); + if ($c->debug) + pxlog("/nick ".$newnick." (wanted nick is allready in use -> wantednickid=".$newnickid.")", "chat", $c->getId()); + return; + } + + if ( $newnickid != "undefined" ) + { + // @todo notify the user ? + return; + } + + } + + // allow nick changes only from the parameters array (server side) + if ($c->frozen_nick == true && + $u->nick != $c->nick && + $c->nick != "" && // don't change the nickname to empty or the asknick popup will loop indefinatly + $p["owner"] != "checknickchange") + { + // change the user nickname + $cmdp = $p; + $cmdp["param"] = $c->nick; + $cmdp["owner"] = "checknickchange"; + $cmd =& pfcCommand::Factory("nick"); + $cmd->run($xml_reponse, $cmdp); + return; + } + + + + + // forward the command to the next proxy or to the final command + $this->next->run($xml_reponse, $p); + } +} + +?> \ 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...> - 2006-09-08 20:59:09
|
Revision: 741 http://svn.sourceforge.net/phpfreechat/?rev=741&view=rev Author: kerphi Date: 2006-09-08 13:58:59 -0700 (Fri, 08 Sep 2006) Log Message: ----------- [en] New checktimeout proxy used to disconnect timeouted users before playing a command. [fr] Nouveau proxy checktimeout dont la fonction est de d?\195?\169connecter les utilisateurs qui sont en timeout. Modified Paths: -------------- trunk/src/commands/connect.class.php trunk/src/commands/getonlinenick.class.php trunk/src/commands/update.class.php trunk/src/pfcglobalconfig.class.php Added Paths: ----------- trunk/src/proxys/checktimeout.class.php Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-09-08 20:56:24 UTC (rev 740) +++ trunk/src/commands/connect.class.php 2006-09-08 20:58:59 UTC (rev 741) @@ -14,10 +14,7 @@ $c =& $this->c; $u =& $this->u; - - // disconnect last connected users from the server if necessary $container =& $c->getContainerInstance(); - $disconnected_users = $container->removeObsoleteNick(NULL, $c->timeout); // reset the message id indicator (see getnewmsg.class.php) // i.e. be ready to re-get all last posted messages Modified: trunk/src/commands/getonlinenick.class.php =================================================================== --- trunk/src/commands/getonlinenick.class.php 2006-09-08 20:56:24 UTC (rev 740) +++ trunk/src/commands/getonlinenick.class.php 2006-09-08 20:58:59 UTC (rev 741) @@ -14,18 +14,6 @@ $c =& $this->c; $container =& $c->getContainerInstance(); - - // take care to disconnect timeouted users on this channel - $disconnected_users = $container->removeObsoleteNick($recipient,$c->timeout); - if (isset($disconnected_users["nick"])) - foreach ($disconnected_users["nick"] as $n) - { - $cmdp = $p; - $cmdp["param"] = _pfc("%s quit (timeout)", $n); - $cmdp["flag"] = 2; - $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $cmdp); - } // get the cached nickname list $nicklist_sid = $c->prefix."nicklist_".$c->getId()."_".$clientid."_".$recipientid; Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-09-08 20:56:24 UTC (rev 740) +++ trunk/src/commands/update.class.php 2006-09-08 20:58:59 UTC (rev 741) @@ -67,19 +67,7 @@ $cmd->run($xml_reponse, $cmdp); } - // take care to disconnect timeouted users on the server - $container =& $c->getContainerInstance(); - $disconnected_users = $container->removeObsoleteNick(NULL,$c->timeout); - // if whould be possible to echo these disconnected users on a server tab - // server tab is not yet available so I just commente the code - // foreach ($disconnected_users as $u) - // { - // $cmd =& pfcCommand::Factory("notice"); - // $cmd->run($xml_reponse, $clientid, _pfc("%s quit (timeout)",$u), $sender, $recipient, $recipientid, 2); - // } - - // do not send a response in order to save some bandwidth - // $xml_reponse->addScript("pfc.handleResponse('update', 'ok', '');"); + $xml_reponse->addScript("pfc.handleResponse('update', 'ok', '');"); } else $xml_reponse->addScript("pfc.handleResponse('update', 'ko', '');"); Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-09-08 20:56:24 UTC (rev 740) +++ trunk/src/pfcglobalconfig.class.php 2006-09-08 20:58:59 UTC (rev 741) @@ -41,7 +41,7 @@ var $lockurl = "http://www.phpfreechat.net"; // this is the url where the users must be redirected when the chat is locked // these parameters are static (cached) - var $proxys = array("lock", "auth", "checknickchange", "noflood", "censor", "log"); + var $proxys = array("lock", "checktimeout", "checknickchange", "auth", "noflood", "censor", "log"); var $proxys_cfg = array("auth" => array(), "noflood" => array("limit"=>10,"delay"=>5), "censor" => array("words"=>array("fuck","sex","bitch"),"replaceby"=>"*"), Added: trunk/src/proxys/checktimeout.class.php =================================================================== --- trunk/src/proxys/checktimeout.class.php (rev 0) +++ trunk/src/proxys/checktimeout.class.php 2006-09-08 20:58:59 UTC (rev 741) @@ -0,0 +1,74 @@ +<?php +/** + * checktimeout.class.php + * + * Copyright © 2006 Stephane Gully <ste...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + */ +require_once dirname(__FILE__)."/../pfci18n.class.php"; +require_once dirname(__FILE__)."/../pfcuserconfig.class.php"; +require_once dirname(__FILE__)."/../pfcproxycommand.class.php"; + +/** + * pfcProxyCommand_checktimeout + * this command disconnect obsolete users (timouted) + * an obsolete user is an user which didn't update his stats since more than 20 seconds (timeout value) + * @author Stephane Gully <ste...@gm...> + */ +class pfcProxyCommand_checktimeout extends pfcProxyCommand +{ + function run(&$xml_reponse, $p) + { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + + $c =& $this->c; + $u =& $this->u; + + if ( $this->name == 'update' || + $this->name == 'connect' ) + { + // disconnect users from the server pool + $container =& $c->getContainerInstance(); + $disconnected_users = $container->removeObsoleteNick(NULL,$c->timeout); + } + + if ( $this->name == 'getonlinenick' ) + { + // disconnect users from specific channels + $container =& $c->getContainerInstance(); + $disconnected_users = $container->removeObsoleteNick($recipient,$c->timeout); + if (isset($disconnected_users["nick"])) + foreach ($disconnected_users["nick"] as $n) + { + $cmdp = $p; + $cmdp["param"] = _pfc("%s quit (timeout)", $n); + $cmdp["flag"] = 2; + $cmd =& pfcCommand::Factory("notice"); + $cmd->run($xml_reponse, $cmdp); + } + } + + // forward the command to the next proxy or to the final command + $this->next->run($xml_reponse, $p); + } +} + +?> \ 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...> - 2006-09-10 17:27:33
|
Revision: 746 http://svn.sourceforge.net/phpfreechat/?rev=746&view=rev Author: kerphi Date: 2006-09-10 10:27:25 -0700 (Sun, 10 Sep 2006) Log Message: ----------- [en] Add a new /version command used to get the current phpfreechat version. [fr] Ajoute une nouvelle commande /version permettant d'afficher le num?\195?\169ro de version de la version courante de phpfreechat Modified Paths: -------------- trunk/src/client/chat.js.tpl.php trunk/src/client/pfcclient.js Added Paths: ----------- trunk/src/commands/version.class.php Modified: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php 2006-09-10 16:11:02 UTC (rev 745) +++ trunk/src/client/chat.js.tpl.php 2006-09-10 17:27:25 UTC (rev 746) @@ -79,7 +79,8 @@ "Enter the text to format", // _pfc "Configuration has been rehashed", // _pfc "A problem occurs during rehash", // _pfc - "Choosen nickname is allready used", //_pfc + "Choosen nickname is allready used", // _pfc + "phpfreechat current version is %s", // _pfc ); foreach($labels_to_load as $l) { Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-09-10 16:11:02 UTC (rev 745) +++ trunk/src/client/pfcclient.js 2006-09-10 17:27:25 UTC (rev 746) @@ -317,6 +317,13 @@ { } } + else if (cmd == "version") + { + if (resp == "ok") + { + this.displayMsg( cmd, this.res.getLabel('phpfreechat current version is %s',param) ); + } + } else if (cmd == "rehash") { if (resp == "ok") Added: trunk/src/commands/version.class.php =================================================================== --- trunk/src/commands/version.class.php (rev 0) +++ trunk/src/commands/version.class.php 2006-09-10 17:27:25 UTC (rev 746) @@ -0,0 +1,24 @@ +<?php + +require_once(dirname(__FILE__)."/../pfccommand.class.php"); + +class pfcCommand_version extends pfcCommand +{ + var $usage = "/version"; + + function run(&$xml_reponse, $p) + { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + + $c =& $this->c; + $u =& $this->u; + + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', '".$c->version."');"); + } +} + +?> \ 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...> - 2006-09-10 19:18:45
|
Revision: 747 http://svn.sourceforge.net/phpfreechat/?rev=747&view=rev Author: kerphi Date: 2006-09-10 12:18:38 -0700 (Sun, 10 Sep 2006) Log Message: ----------- [en] New /help command use to list available commands (in future, it's planned to display command syntax/description). [fr] Nouvelle commande /help permettan de lister les commandes disponibles (dans le future elle permettra egalement de donner une description de chaque commandes) Modified Paths: -------------- trunk/src/client/pfcclient.js Added Paths: ----------- trunk/src/commands/help.class.php Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-09-10 17:27:25 UTC (rev 746) +++ trunk/src/client/pfcclient.js 2006-09-10 19:18:38 UTC (rev 747) @@ -324,6 +324,13 @@ this.displayMsg( cmd, this.res.getLabel('phpfreechat current version is %s',param) ); } } + else if (cmd == "help") + { + if (resp == "ok") + { + this.displayMsg( cmd, param); + } + } else if (cmd == "rehash") { if (resp == "ok") Added: trunk/src/commands/help.class.php =================================================================== --- trunk/src/commands/help.class.php (rev 0) +++ trunk/src/commands/help.class.php 2006-09-10 19:18:38 UTC (rev 747) @@ -0,0 +1,38 @@ +<?php + +require_once(dirname(__FILE__)."/../pfccommand.class.php"); + +class pfcCommand_help extends pfcCommand +{ + var $usage = "/help"; + + function run(&$xml_reponse, $p) + { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + + $c =& $this->c; + $u =& $this->u; + + $ignore = array("updatemynick", "getnewmsg", "notice", "getonlinenick", "error", "update", "asknick"); + + $cmdlist = array(); + $dh = opendir(dirname(__FILE__)); + while (false !== ($file = readdir($dh))) + { + if (!preg_match("/^([a-z]+).class.php$/i",$file,$res)) continue; + if (!in_array($res[1],$ignore)) $cmdlist[] = $res[1]; + } + sort($cmdlist); + + $str = _pfc("Here is the command list:")."<br/>"; + $str .= implode("<br/>", $cmdlist); + + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', '".$str."');"); + } +} + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |