Thread: [Phpfreechat-svn] SF.net SVN: phpfreechat: [434] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-04-16 17:00:21
|
Revision: 434 Author: kerphi Date: 2006-04-16 10:00:13 -0700 (Sun, 16 Apr 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=434&view=rev Log Message: ----------- new command : rehash (This command deletes the cached configuration. Uses it to take into account new parameters.) Modified Paths: -------------- trunk/src/commands/init.class.php trunk/src/pfccommand.class.php trunk/src/pfcglobalconfig.class.php Added Paths: ----------- trunk/src/commands/rehash.class.php This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-04-16 20:09:23
|
Revision: 436 Author: kerphi Date: 2006-04-16 13:09:13 -0700 (Sun, 16 Apr 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=436&view=rev Log Message: ----------- i18n refactoring client side rehash command improvments Modified Paths: -------------- trunk/src/commands/rehash.class.php trunk/src/phpfreechat.class.php trunk/themes/default/templates/pfcclient.js.tpl.php trunk/themes/default/templates/pfcgui.js.tpl.php trunk/themes/default/templates/style.css.tpl.php Added Paths: ----------- trunk/themes/default/templates/pfci18n.js.tpl.php This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-04-16 20:09:24
|
Revision: 436 Author: kerphi Date: 2006-04-16 13:09:13 -0700 (Sun, 16 Apr 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=436&view=rev Log Message: ----------- i18n refactoring client side rehash command improvments Modified Paths: -------------- trunk/src/commands/rehash.class.php trunk/src/phpfreechat.class.php trunk/themes/default/templates/pfcclient.js.tpl.php trunk/themes/default/templates/pfcgui.js.tpl.php trunk/themes/default/templates/style.css.tpl.php Added Paths: ----------- trunk/themes/default/templates/pfci18n.js.tpl.php Modified: trunk/src/commands/rehash.class.php =================================================================== --- trunk/src/commands/rehash.class.php 2006-04-16 17:00:59 UTC (rev 435) +++ trunk/src/commands/rehash.class.php 2006-04-16 20:09:13 UTC (rev 436) @@ -15,6 +15,7 @@ { $c =& $this->c; $synchro = $c->synchronizeWithCache(true); // true => destroy the cache + if ($synchro) $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ko', '');"); else Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-04-16 17:00:59 UTC (rev 435) +++ trunk/src/phpfreechat.class.php 2006-04-16 20:09:13 UTC (rev 436) @@ -100,6 +100,8 @@ $t->assignObject($c,"c"); $t->assignObject($u,"u"); $output .= "<script type=\"text/javascript\">\n // <![CDATA[\n"; + $t->setTemplate($c->getFilePathFromTheme("templates/pfci18n.js.tpl.php")); + $output .= $t->getOutput(); $t->setTemplate($c->getFilePathFromTheme("templates/pfcgui.js.tpl.php")); $output .= $t->getOutput(); $t->setTemplate($c->getFilePathFromTheme("templates/pfcclient.js.tpl.php")); Modified: trunk/themes/default/templates/pfcclient.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcclient.js.tpl.php 2006-04-16 17:00:59 UTC (rev 435) +++ trunk/themes/default/templates/pfcclient.js.tpl.php 2006-04-16 20:09:13 UTC (rev 436) @@ -9,9 +9,7 @@ pfcClient.prototype = { initialize: function() - { - this.gui = new pfcGui(); - + { /* user description */ this.nickname = '<?php echo $u->nick; ?>'; @@ -86,26 +84,27 @@ this.el_container.onmouseup = this.callbackContainer_OnMouseup.bindAsEventListener(this); document.body.onunload = this.callback_OnUnload.bindAsEventListener(this); - /* the i18n translations */ - var i18n = { - hide_nickname_color: '<?php echo _pfc("Hide nickname marker"); ?>', - show_nickname_color: '<?php echo _pfc("Show nickname marker"); ?>', - hide_clock: '<?php echo _pfc("Hide dates and hours"); ?>', - show_clock: '<?php echo _pfc("Show dates and hours"); ?>', - logout: '<?php echo _pfc("Disconnect"); ?>', - login: '<?php echo _pfc("Connect"); ?>', - maximize: '<?php echo _pfc("Magnify"); ?>', - minimize: '<?php echo _pfc("Cut down"); ?>', - hidesmiley: '<?php echo _pfc("Hide smiley box"); ?>', - showsmiley: '<?php echo _pfc("Show smiley box"); ?>', - hideonline: '<?php echo _pfc("Hide online users box"); ?>', - showonline: '<?php echo _pfc("Show online users box"); ?>', + // the i18n translations + this.i18n = new pfcI18N(); + this.i18n.setLabel('hide_nickname_color', '<?php echo _pfc("Hide nickname marker"); ?>'); + this.i18n.setLabel('show_nickname_color', '<?php echo _pfc("Show nickname marker"); ?>'); + this.i18n.setLabel('hide_clock', '<?php echo _pfc("Hide dates and hours"); ?>'); + this.i18n.setLabel('show_clock', '<?php echo _pfc("Show dates and hours"); ?>'); + this.i18n.setLabel('logout', '<?php echo _pfc("Disconnect"); ?>'); + this.i18n.setLabel('login', '<?php echo _pfc("Connect"); ?>'); + this.i18n.setLabel('maximize', '<?php echo _pfc("Magnify"); ?>'); + this.i18n.setLabel('minimize', '<?php echo _pfc("Cut down"); ?>'); + this.i18n.setLabel('hidesmiley', '<?php echo _pfc("Hide smiley box"); ?>'); + this.i18n.setLabel('showsmiley', '<?php echo _pfc("Show smiley box"); ?>'); + this.i18n.setLabel('hideonline', '<?php echo _pfc("Hide online users box"); ?>'); + this.i18n.setLabel('showonline', '<?php echo _pfc("Show online users box"); ?>'); + this.i18n.setLabel('enter_nickname', '<?php echo _pfc("Please enter your nickname"); ?>'); + this.i18n.setLabel('Private message', '<?php echo _pfc("Private message"); ?>'); + this.i18n.setLabel('Close this tab', '<?php echo _pfc("Close this tab"); ?>'); - enter_nickname: '<?php echo _pfc("Please enter your nickname"); ?>', - private_message: '<?php echo _pfc("Private message"); ?>' - }; - this.i18n = $H(i18n); - + // the graphical user interface + this.gui = new pfcGui(this.i18n); + /* the smileys */ var smileys = { <?php @@ -130,7 +129,7 @@ { // ask to choose a nickname if (nickname == '') nickname = this.nickname; - var newnick = prompt(this.i18n.enter_nickname, nickname); + var newnick = prompt(this.i18n._('enter_nickname'), nickname); if (newnick) this.sendRequest('/nick', newnick); }, @@ -304,11 +303,17 @@ } else if (cmd == "rehash") { + if (resp == "ok") + { + this.displayMsg( 'rehash', this.i18n._('Configuration has been rehashed') ); + } + else if (resp == "ko") + { + this.displayMsg( 'rehash', this.i18n._('A problem occurs during rehash') ); + } + } + else alert(cmd + "-"+resp+"-"+param); - } - - //if( cmd != "update") - // alert(cmd + "-"+resp+"-"+param); }, /** @@ -494,6 +499,20 @@ } }, + displayMsg: function( cmd, msg ) + { + // get the current selected tab container + var tabid = this.gui.getTabId(); + var container = this.gui.getChatContentFromTabId(tabid); + + // create a dummy div to avoid konqueror bug when setting nickmarkers + var m = document.createElement('div'); + m.innerHTML = '<pre class="<?php echo $prefix; ?>cmd_'+cmd+'">'+msg+'</pre>'; + // finaly append this to the message list + container.appendChild(m); + this.gui.scrollDown(tabid, m); + }, + handleComingRequest: function( cmds ) { var msg_html = $H(); @@ -560,28 +579,15 @@ var recipientid = keys[i]; var tabid = recipientid; - /* create the tab if it doesn't exists yet */ + // 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 */ + // create a dummy div to avoid konqueror bug when setting nickmarkers var m = document.createElement('div'); m.innerHTML = msg_html[recipientid]; - /* finaly append this to the message list */ + // finaly append this to the message list recipientdiv.appendChild(m); - - // var a = msg_ids[recipientid]; - //alert(a.inspect()); - // for(var j = 0; j < msg_ids[recipientid].length ; j++) - { - - this.gui.scrollDown(tabid, m/*$('<?php echo $prefix; ?>msg'+ msg_ids[recipientid][j])*/); - - // colorize messages nicknames - //var root = $('<?php echo $prefix; ?>msg'+ msg_ids[j]); - //this.refresh_nickmarker(root); - //this.refresh_clock(root); - } - + this.gui.scrollDown(tabid, m); } }, @@ -645,7 +651,7 @@ // this is someone -> create a privmsg link var img = document.createElement('img'); img.setAttribute('src', '<?php echo $c->getFileUrlFromTheme('images/user.gif'); ?>'); - img.alt = this.i18n.private_message; + img.alt = this.i18n._('Private message'); img.title = img.alt; img.style.marginRight = '5px'; var a = document.createElement('a'); @@ -1009,7 +1015,7 @@ if (this.nickmarker) { nickmarker_icon.src = "<?php echo $c->getFileUrlFromTheme('images/color-on.gif'); ?>"; - nickmarker_icon.alt = this.i18n.hide_nickname_color; + nickmarker_icon.alt = this.i18n._('hide_nickname_color'); nickmarker_icon.title = nickmarker_icon.alt; this.colorizeNicks(root); this.colorizeNicks($('<?php echo $prefix; ?>online')); @@ -1017,7 +1023,7 @@ else { nickmarker_icon.src = "<?php echo $c->getFileUrlFromTheme('images/color-off.gif'); ?>"; - nickmarker_icon.alt = this.i18n.show_nickname_color; + nickmarker_icon.alt = this.i18n._('show_nickname_color'); nickmarker_icon.title = nickmarker_icon.alt; var elts = this.getElementsByClassName(root, '<?php echo $prefix; ?>nickmarker', ''); for(var i = 0; elts.length > i; i++) @@ -1056,7 +1062,7 @@ if (this.clock) { clock_icon.src = "<?php echo $c->getFileUrlFromTheme('images/clock-on.gif'); ?>"; - clock_icon.alt = this.i18n.hide_clock; + clock_icon.alt = this.i18n._('hide_clock'); clock_icon.title = clock_icon.alt; this.showClass(root, '<?php echo $prefix; ?>date', '<?php echo $prefix; ?>invisible', true); this.showClass(root, '<?php echo $prefix; ?>heure', '<?php echo $prefix; ?>invisible', true); @@ -1064,7 +1070,7 @@ else { clock_icon.src = "<?php echo $c->getFileUrlFromTheme('images/clock-off.gif'); ?>"; - clock_icon.alt = this.i18n.show_clock; + clock_icon.alt = this.i18n._('show_clock'); clock_icon.title = clock_icon.alt; this.showClass(root, '<?php echo $prefix; ?>date', '<?php echo $prefix; ?>invisible', false); this.showClass(root, '<?php echo $prefix; ?>heure', '<?php echo $prefix; ?>invisible', false); @@ -1091,7 +1097,7 @@ { // this.updateNickList(this.nicklist); loginlogout_icon.src = "<?php echo $c->getFileUrlFromTheme('images/logout.gif'); ?>"; - loginlogout_icon.alt = this.i18n.logout; + loginlogout_icon.alt = this.i18n._('logout'); loginlogout_icon.title = loginlogout_icon.alt; } else @@ -1099,7 +1105,7 @@ this.clearMessages(); this.clearNickList(); loginlogout_icon.src = "<?php echo $c->getFileUrlFromTheme('images/login.gif'); ?>"; - loginlogout_icon.alt = this.i18n.login; + loginlogout_icon.alt = this.i18n._('login'); loginlogout_icon.title = loginlogout_icon.alt; } }, @@ -1126,14 +1132,14 @@ if (this.minmax_status) { btn.src = "<?php echo $c->getFileUrlFromTheme('images/maximize.gif'); ?>"; - btn.alt = this.i18n.maximize; + btn.alt = this.i18n._('maximize'); btn.title = btn.alt; content.style.display = 'none'; } else { btn.src = "<?php echo $c->getFileUrlFromTheme('images/minimize.gif'); ?>"; - btn.alt = this.i18n.minimize; + btn.alt = this.i18n._('minimize'); btn.title = btn.alt; content.style.display = 'block'; } @@ -1238,7 +1244,7 @@ if (btn) { btn.src = "<?php echo $c->getFileUrlFromTheme('images/smiley-on.gif'); ?>"; - btn.alt = this.i18n.hidesmiley; + btn.alt = this.i18n._('hidesmiley'); btn.title = btn.alt; } content.style.display = 'block'; @@ -1248,7 +1254,7 @@ if (btn) { btn.src = "<?php echo $c->getFileUrlFromTheme('images/smiley-off.gif'); ?>"; - btn.alt = this.i18n.showsmiley; + btn.alt = this.i18n._('showsmiley'); btn.title = btn.alt; } content.style.display = 'none'; @@ -1282,14 +1288,14 @@ if (this.showwhosonline) { btn.src = "<?php echo $c->getFileUrlFromTheme('images/online-on.gif'); ?>"; - btn.alt = this.i18n.hideonline; + btn.alt = this.i18n._('hideonline'); btn.title = btn.alt; content.style.display = 'block'; } else { btn.src = "<?php echo $c->getFileUrlFromTheme('images/online-off.gif'); ?>"; - btn.alt = this.i18n.showonline; + btn.alt = this.i18n._('showonline'); btn.title = btn.alt; content.style.display = 'none'; } Modified: trunk/themes/default/templates/pfcgui.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcgui.js.tpl.php 2006-04-16 17:00:59 UTC (rev 435) +++ trunk/themes/default/templates/pfcgui.js.tpl.php 2006-04-16 20:09:13 UTC (rev 436) @@ -6,8 +6,10 @@ var pfcGui = Class.create(); pfcGui.prototype = { - initialize: function() + initialize: function(i18n) { + this.i18n = i18n; + this.current_tab = ''; this.current_tab_id = ''; this.tabs = Array(); @@ -211,7 +213,7 @@ var a2 = document.createElement('a'); a2.pfc_tabid = tabid; a2.onclick = function(){pfc.sendRequest('/leave', this.pfc_tabid); return false;} - a2.alt = '<?php echo _pfc("Close this tab"); ?>'; + a2.alt = this.i18n._('Close this tab'); a2.title = a2.alt; Element.addClassName(a2, '<?php echo $prefix; ?>tabclose'); var img = document.createElement('img'); Added: trunk/themes/default/templates/pfci18n.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfci18n.js.tpl.php (rev 0) +++ trunk/themes/default/templates/pfci18n.js.tpl.php 2006-04-16 20:09:13 UTC (rev 436) @@ -0,0 +1,40 @@ +/** + * This class centralize the pfc' translated messages + * (depends on prototype library) + * @author Stephane Gully + */ +var pfcI18N = Class.create(); +pfcI18N.prototype = { + + initialize: function() + { + this.labels = $H(); + this.elts = $H(); + }, + + setLabel: function(key, value) + { + this.labels[key] = value; + }, + + _: function(key, param) + { + if (this.labels[key]) + return this.labels[key]; + else + return '_'+key+'_'; + }, + + /** + * Register element can be used to change dynamicaly the client language + */ + registerElement: function(key, element, attribute) + { + // store the assigned element + element = $(element); + if (!this.elts[key]) + this.elts[key] = [ [element, attribute] ]; + else + this.elts[key].push( [element, attribute] ); + } +}; Modified: trunk/themes/default/templates/style.css.tpl.php =================================================================== --- trunk/themes/default/templates/style.css.tpl.php 2006-04-16 17:00:59 UTC (rev 435) +++ trunk/themes/default/templates/style.css.tpl.php 2006-04-16 20:09:13 UTC (rev 436) @@ -231,6 +231,12 @@ font-style: italic; color: #888; } +pre.<?php echo $prefix; ?>cmd_rehash, +pre.<?php echo $prefix; ?>cmd_help +{ + color: #888; + font-style: italic; +} div#<?php echo $prefix; ?>colorlist { display: none; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ne...@us...> - 2006-04-25 10:15:48
|
Revision: 471 Author: nemako Date: 2006-04-25 03:15:32 -0700 (Tue, 25 Apr 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=471&view=rev Log Message: ----------- Change in the admin interface. Add language choose. Modified Paths: -------------- trunk/admin/inc.conf.php trunk/admin/index.php trunk/i18n/en_US/admin.php trunk/i18n/fr_FR/admin.php trunk/src/pfci18n.class.php Modified: trunk/admin/inc.conf.php =================================================================== --- trunk/admin/inc.conf.php 2006-04-25 07:51:34 UTC (rev 470) +++ trunk/admin/inc.conf.php 2006-04-25 10:15:32 UTC (rev 471) @@ -1,4 +1,4 @@ <?php session_start(); -$lang = isset($_GET["lang"]) ? $_GET["lang"] : (isset($_SESSION["lang"]) ? $_SESSION["lang"] : "en_US" ); $_SESSION["lang"] = $lang; +$lang = isset($_POST["lang"]) ? $_POST["lang"] : (isset($_SESSION["lang"]) ? $_SESSION["lang"] : "en_US" ); $_SESSION["lang"] = $lang; ?> \ No newline at end of file Modified: trunk/admin/index.php =================================================================== --- trunk/admin/index.php 2006-04-25 07:51:34 UTC (rev 470) +++ trunk/admin/index.php 2006-04-25 10:15:32 UTC (rev 471) @@ -4,7 +4,6 @@ require_once("inc.conf.php"); pfcI18N::Init($lang,"admin"); - # version class require_once("version.class.php"); $version = new version(); @@ -18,41 +17,63 @@ <div class="content"> <h2><?php echo _pfc("Administration"); ?></h2> -<?php -if ($version->getPFCOfficialCurrentVersion()==0){ -?> - <div><h3><?php echo _pfc("Internet connection is not possible"); ?></h3> + <div><h3><?php echo _pfc("Available Languages"); ?></h3> <ul> - <li><?php echo _pfc("PFC version"); ?> : <?php echo $version->getLocalVersion(); ?></li> + <li><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> + <select name="lang"> + <?php + $available_admin_lang = pfcI18N::GetAcceptedAdminLanguage(); + for($i=0;$i<count($available_admin_lang);$i++) { + if ($lang==$available_admin_lang[$i]) + $selected ="selected=\"selected\""; + else + $selected =""; + echo "<option value=\"$available_admin_lang[$i]\" $selected>$available_admin_lang[$i]</option>"; + } + ?> + </select> + <input type="submit" name="submit" value="Ok"/> + </form> + </li> </ul> </div> -<?php -} -elseif (($version->getLocalVersion())==($version->getPFCOfficialCurrentVersion())){ -?> - <div class="ok"><h3><img src="style/check_on.png" alt="<?php echo _pfc("PFC is update"); ?>"> <?php echo _pfc("PFC is update"); ?></h3> + <div><h3><?php echo _pfc("PFC version verification"); ?></h3> + <?php + if ($version->getPFCOfficialCurrentVersion()==0){ + ?> <ul> + <li><?php echo _pfc("Internet connection is not possible"); ?></li> <li><?php echo _pfc("PFC version"); ?> : <?php echo $version->getLocalVersion(); ?></li> </ul> </div> -<?php -} -else{ -?> - <div class="ko"><h3><img src="style/check_off.png" alt="<?php echo _pfc("PFC is not update"); ?>"> <?php echo _pfc("PFC is not update"); ?></h3> + <?php + } + elseif (($version->getLocalVersion())==($version->getPFCOfficialCurrentVersion())){ + ?> <ul> + <li><span style="color:#339933;"><img src="style/check_on.png" alt="<?php echo _pfc("PFC is update"); ?>"> <?php echo _pfc("PFC is update"); ?></span></li> + <li><?php echo _pfc("PFC version"); ?> : <?php echo $version->getLocalVersion(); ?></li> + </ul> + + <?php + } + else{ + ?> + <ul> + <li><span style="color:#FF0000;"><img src="style/check_off.png" alt="<?php echo _pfc("PFC is not update"); ?>"> <?php echo _pfc("PFC is not update"); ?></span></li> <li><?php echo _pfc("Your version"); ?> : <?php echo $version->getLocalVersion(); ?></li> <li><?php echo _pfc("The last official version"); ?> : <?php echo $version->getPFCOfficialCurrentVersion(); ?></li> <li><?php echo _pfc("Download the last version %s here %s.","<a href=\"http://sourceforge.net/project/showfiles.php?group_id=158880\">","</a>"); ?></li> </ul> - </div> <?php } -?> +?> + </div> + </div> <?php Modified: trunk/i18n/en_US/admin.php =================================================================== --- trunk/i18n/en_US/admin.php 2006-04-25 07:51:34 UTC (rev 470) +++ trunk/i18n/en_US/admin.php 2006-04-25 10:15:32 UTC (rev 471) @@ -26,15 +26,19 @@ * @author Nemako <fr...@ne...> */ +$GLOBALS["i18n"]["lang"] = "English"; + // admin/index.php $GLOBALS["i18n"]["Administration"] = "Administration"; +$GLOBALS["i18n"]["Available Languages"] = "Available Languages"; +$GLOBALS["i18n"]["PFC version verification"] = "PFC version verification"; $GLOBALS["i18n"]["Internet connection is not possible"] = "Internet connection is not possible"; $GLOBALS["i18n"]["PFC is update"] = "PFC is update"; $GLOBALS["i18n"]["PFC version"] = "PFC version"; $GLOBALS["i18n"]["The last official version"] = "The last official version"; $GLOBALS["i18n"]["PFC is not update"] = "PFC is not update"; $GLOBALS["i18n"]["Your version"] = "Your version"; -$GLOBALS["i18n"]["Download the last version %s here %s."] = "Télécharger la dernière version %s ici %s."; +$GLOBALS["i18n"]["Download the last version %s here %s."] = "Download the last version %s here %s."; // admin/user.php Modified: trunk/i18n/fr_FR/admin.php =================================================================== --- trunk/i18n/fr_FR/admin.php 2006-04-25 07:51:34 UTC (rev 470) +++ trunk/i18n/fr_FR/admin.php 2006-04-25 10:15:32 UTC (rev 471) @@ -26,10 +26,14 @@ * @author Stephane Gully <ste...@gm...> */ +$GLOBALS["i18n"]["lang"] = "Français"; + // admin/index.php $GLOBALS["i18n"]["Administration"] = "Administration"; +$GLOBALS["i18n"]["Available Languages"] = "Langues disponibles"; +$GLOBALS["i18n"]["PFC version verification"] = "Verification de la version de PFC"; $GLOBALS["i18n"]["Internet connection is not possible"] = "La connexion à Internet n'est pas possible"; -$GLOBALS["i18n"]["PFC is update"] = "PFC est pas à jour"; +$GLOBALS["i18n"]["PFC is update"] = "PFC est à jour"; $GLOBALS["i18n"]["PFC version"] = "version de PFC"; $GLOBALS["i18n"]["The last official version"] = "La dernière version officielle"; $GLOBALS["i18n"]["PFC is not update"] = "PFC n'est pas à jour"; Modified: trunk/src/pfci18n.class.php =================================================================== --- trunk/src/pfci18n.class.php 2006-04-25 07:51:34 UTC (rev 470) +++ trunk/src/pfci18n.class.php 2006-04-25 10:15:32 UTC (rev 471) @@ -35,8 +35,12 @@ { function Init($language,$type='main') { + if ($type=="admin") + if (!in_array($language, pfcI18N::GetAcceptedAdminLanguage())) + $language = pfcI18N::GetDefaultLanguage(); if (!in_array($language, pfcI18N::GetAcceptedLanguage())) $language = pfcI18N::GetDefaultLanguage(); + if ($type=="admin") require_once(dirname(__FILE__)."/../i18n/".$language."/admin.php"); else @@ -90,6 +94,27 @@ } return $GLOBALS["accepted_languages"]; } + + /** + * Return the language list supported bye i18n system + * (content of the i18n directory) + */ + function GetAcceptedAdminLanguage() + { + if (isset($GLOBALS["accepted_admin_languages"])) + return $GLOBALS["accepted_admin_languages"]; // restore the cached languages list + $GLOBALS["accepted_admin_languages"] = array(); + $dir_handle = opendir(dirname(__FILE__)."/../i18n"); + while (false !== ($file = readdir($dir_handle))) + { + // skip . and .. generic files + // skip also .svn directory + if ($file == "." || $file == ".." || preg_match("/^\..*/", $file)) continue; + if (file_exists(dirname(__FILE__)."/../i18n/".$file."/admin.php")) + $GLOBALS["accepted_admin_languages"][] = $file; + } + return $GLOBALS["accepted_admin_languages"]; + } /** * Parse the source-code and update the i18n ressources files This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ne...@us...> - 2006-04-25 13:01:00
|
Revision: 473 Author: nemako Date: 2006-04-25 06:00:45 -0700 (Tue, 25 Apr 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=473&view=rev Log Message: ----------- Replace preg_match("/^\..*/", $file) by strpos($file,".")===0. It is faster. Modified Paths: -------------- trunk/admin/index.php trunk/admin/themes.class.php trunk/src/pfci18n.class.php Modified: trunk/admin/index.php =================================================================== --- trunk/admin/index.php 2006-04-25 12:16:50 UTC (rev 472) +++ trunk/admin/index.php 2006-04-25 13:00:45 UTC (rev 473) @@ -22,7 +22,7 @@ <li><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <select name="lang"> <?php - $available_admin_lang = pfcI18N::GetAcceptedAdminLanguage(); + $available_admin_lang = pfcI18N::GetAcceptedLanguage("admin"); for($i=0;$i<count($available_admin_lang);$i++) { if ($lang==$available_admin_lang[$i]) $selected ="selected=\"selected\""; Modified: trunk/admin/themes.class.php =================================================================== --- trunk/admin/themes.class.php 2006-04-25 12:16:50 UTC (rev 472) +++ trunk/admin/themes.class.php 2006-04-25 13:00:45 UTC (rev 473) @@ -22,7 +22,7 @@ $i=0; $dir = opendir($this->dir_themes); while ($f = readdir($dir)) { - if(is_dir($this->dir_themes.$f) && $f!="." && $f!=".." && strpos($f,".")===false) { + if(is_dir($this->dir_themes.$f) && $f!="." && $f!=".." && strpos($f,".")!==0) { $themes_list[$i] = $f; $i++; } Modified: trunk/src/pfci18n.class.php =================================================================== --- trunk/src/pfci18n.class.php 2006-04-25 12:16:50 UTC (rev 472) +++ trunk/src/pfci18n.class.php 2006-04-25 13:00:45 UTC (rev 473) @@ -33,10 +33,10 @@ class pfcI18N { - function Init($language,$type='main') + function Init($language,$type="main") { if ($type=="admin") - if (!in_array($language, pfcI18N::GetAcceptedAdminLanguage())) + if (!in_array($language, pfcI18N::GetAcceptedLanguage("admin"))) $language = pfcI18N::GetDefaultLanguage(); if (!in_array($language, pfcI18N::GetAcceptedLanguage())) $language = pfcI18N::GetDefaultLanguage(); @@ -79,41 +79,37 @@ * Return the language list supported bye i18n system * (content of the i18n directory) */ - function GetAcceptedLanguage() + function GetAcceptedLanguage($type="main") { - if (isset($GLOBALS["accepted_languages"])) - return $GLOBALS["accepted_languages"]; // restore the cached languages list - $GLOBALS["accepted_languages"] = array(); - $dir_handle = opendir(dirname(__FILE__)."/../i18n"); - while (false !== ($file = readdir($dir_handle))) - { - // skip . and .. generic files - // skip also .svn directory - if ($file == "." || $file == ".." || preg_match("/^\..*/", $file)) continue; - $GLOBALS["accepted_languages"][] = $file; + if ($type=="admin"){ + if (isset($GLOBALS["accepted_admin_languages"])) + return $GLOBALS["accepted_admin_languages"]; // restore the cached languages list + $GLOBALS["accepted_admin_languages"] = array(); + $dir_handle = opendir(dirname(__FILE__)."/../i18n"); + while (false !== ($file = readdir($dir_handle))) + { + // skip . and .. generic files + // skip also .svn directory + if ($file == "." || $file == ".." || strpos($file,".")===0) continue; + if (file_exists(dirname(__FILE__)."/../i18n/".$file."/admin.php")) + $GLOBALS["accepted_admin_languages"][] = $file; + } + return $GLOBALS["accepted_admin_languages"]; } - return $GLOBALS["accepted_languages"]; - } - - /** - * Return the language list supported bye i18n system - * (content of the i18n directory) - */ - function GetAcceptedAdminLanguage() - { - if (isset($GLOBALS["accepted_admin_languages"])) - return $GLOBALS["accepted_admin_languages"]; // restore the cached languages list - $GLOBALS["accepted_admin_languages"] = array(); - $dir_handle = opendir(dirname(__FILE__)."/../i18n"); - while (false !== ($file = readdir($dir_handle))) - { - // skip . and .. generic files - // skip also .svn directory - if ($file == "." || $file == ".." || preg_match("/^\..*/", $file)) continue; - if (file_exists(dirname(__FILE__)."/../i18n/".$file."/admin.php")) - $GLOBALS["accepted_admin_languages"][] = $file; + else{ + if (isset($GLOBALS["accepted_languages"])) + return $GLOBALS["accepted_languages"]; // restore the cached languages list + $GLOBALS["accepted_languages"] = array(); + $dir_handle = opendir(dirname(__FILE__)."/../i18n"); + while (false !== ($file = readdir($dir_handle))) + { + // skip . and .. generic files + // skip also .svn directory + if ($file == "." || $file == ".." || strpos($file,".")===0) continue; + $GLOBALS["accepted_languages"][] = $file; + } + return $GLOBALS["accepted_languages"]; } - return $GLOBALS["accepted_admin_languages"]; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-04-29 17:59:35
|
Revision: 485 Author: kerphi Date: 2006-04-29 10:59:27 -0700 (Sat, 29 Apr 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=485&view=rev Log Message: ----------- Now a private chat is identified by the both nicknames ids. (it fixes a security hole : private chat takeover) Modified Paths: -------------- trunk/src/commands/privmsg.class.php trunk/src/commands/update.class.php trunk/src/phpfreechat.class.php Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2006-04-29 17:57:20 UTC (rev 484) +++ trunk/src/commands/privmsg.class.php 2006-04-29 17:59:27 UTC (rev 485) @@ -57,6 +57,7 @@ { $u->privmsg[$pvrecipientid]["recipient"] = $pvrecipient; $u->privmsg[$pvrecipientid]["name"] = $pvname; + $u->privmsg[$pvrecipientid]["pvnickid"] = $pvnickid; $u->saveInCache(); // clear the cached nicknames list for the given channel Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-04-29 17:57:20 UTC (rev 484) +++ trunk/src/commands/update.class.php 2006-04-29 17:59:27 UTC (rev 485) @@ -15,12 +15,13 @@ // ----- // check if other user talk to me or not $container =& $c->getContainerInstance(); - $pvnicks = $container->getMeta("privmsg", "nickname", $u->nick); + $nickid = $container->getNickId($u->nick); + $pvnicks = $container->getMeta("privmsg", "nickname", $nickid); if (is_string($pvnicks)) $pvnicks = unserialize($pvnicks); if (!is_array($pvnicks)) $pvnicks = array(); for( $i=0; $i < count($pvnicks); $i++) $xml_reponse->addScript("pfc.handleResponse('update', 'privmsg', '".addslashes($pvnicks[$i])."');"); - $container->rmMeta("privmsg", "nickname", $u->nick); + $container->rmMeta("privmsg", "nickname", $nickid); // ----- // update the user nickname timestamp Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-04-29 17:57:20 UTC (rev 484) +++ trunk/src/phpfreechat.class.php 2006-04-29 17:59:27 UTC (rev 485) @@ -348,14 +348,14 @@ // alert the other from the new pv // (warn other user that someone talk to him) $container =& $c->getContainerInstance(); - $pvs = $container->getMeta("privmsg", "nickname", $u->privmsg[$recipientid]["name"]); + $pvs = $container->getMeta("privmsg", "nickname", $u->privmsg[$recipientid]["pvnickid"]); if (is_string($pvs)) $pvs = unserialize($pvs); if (!is_array($pvs)) $pvs = array(); if (!in_array($u->nick,$pvs)) { $pvs[] = $u->nick; // $xml_reponse->addScript("alert('pvs[]=".serialize($pvs)."');"); - $container->setMeta(serialize($pvs), "privmsg", "nickname", $u->privmsg[$recipientid]["name"]); + $container->setMeta(serialize($pvs), "privmsg", "nickname", $u->privmsg[$recipientid]["pvnickid"]); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-05-12 13:55:25
|
Revision: 492 Author: kerphi Date: 2006-05-12 06:55:14 -0700 (Fri, 12 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=492&view=rev Log Message: ----------- - Bug fix: the cached nickname list was not correctly updated - add a new function in the container API : isNickOnline Modified Paths: -------------- trunk/src/containers/file.class.php trunk/src/pfctools.php trunk/testcase/container_file.php trunk/testcase/container_generic.php Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2006-05-11 16:56:06 UTC (rev 491) +++ trunk/src/containers/file.class.php 2006-05-12 13:55:14 UTC (rev 492) @@ -118,6 +118,15 @@ flock ($fp, LOCK_UN); // unlock fclose($fp); + // append the nickname to the cached nickname list + $id = $this->isNickOnline($chan, $nick); + $_chan = ($chan == NULL) ? "SERVER" : $chan; + if ($id<0) + { + $this->_users[$_chan][] = array("nick" => $nick, + "timestamp" => filemtime($nick_filename)); + } + return true; } @@ -126,6 +135,7 @@ * Notice: The caller must take care to update all joined channels. * @param $chan if NULL then remove the user on the server (disconnect), otherwise just remove the user from the given channel (quit) * @param $nick the nickname to remove + * @return true if the nickname was correctly removed */ function removeNick($chan, $nick) { @@ -144,27 +154,21 @@ pxlog("removeNick(".$nick.") - Error: the nickname data file to remove doesn't exists", "chat", $c->getId()); } - @unlink($nick_filename); + $ok = @unlink($nick_filename); - // remove the nickname from the cache list - if (isset($this->_users[$chan])) + if ($c->debug) { - $uid = 0; $isonline = false; - while($uid < count($this->_users[$chan]) && !$isonline) - { - if ($this->_users[$chan][$uid]["nick"] == $nick) - $isonline = true; - else - $uid++; - } - if ($isonline) - { - $key = $uid; - unset($this->_users[$chan][$key]); - } + // check the nickname file is correctly deleted + if (file_exists($nick_filename)) + pxlog("removeNick(".$nick.") - Error: the nickname data file yet exists", "chat", $c->getId()); } + + // remove the nickname from the cache list + $id = $this->isNickOnline($chan, $nick); + $_chan = ($chan == NULL) ? "SERVER" : $chan; + if ($id >= 0) unset($this->_users[$_chan][$id]); - return true; + return $ok; } /** @@ -189,22 +193,18 @@ @chmod($nick_filename, 0777); // append the nickname to the cache list - if (isset($this->_users[$chan])) + $_chan = ($chan == NULL) ? "SERVER" : $chan; + $id = $this->isNickOnline($chan, $nick); + if ($id < 0) { - $uid = 0; $isonline = false; - while($uid < count($this->_users[$chan]) && !$isonline) - { - if ($this->_users[$chan][$uid]["nick"] == $nick) - $isonline = true; - else - $uid++; - } - if (!$isonline) - { - $this->_users[$chan][] = array("nick" => $nick, - "timestamp" => filemtime($nick_filename)); - } + $this->_users[$_chan][] = array("nick" => $nick, + "timestamp" => filemtime($nick_filename)); } + else + { + // just update the timestamp if the nickname is allready present in the cached list + $this->_users[$_chan][$id]["timestamp"] = filemtime($nick_filename); + } return $there; } @@ -231,22 +231,12 @@ // update the nick cache list if($ok) { - if (isset($this->_users[$chan])) + $_chan = ($chan == NULL) ? "SERVER" : $chan; + $id = $this->isNickOnline($chan, $oldnick); + if ($id >= 0) { - $uid = 0; $isonline = false; - while($uid < count($this->_users[$chan]) && !$isonline) - { - if ($this->_users[$chan][$uid]["nick"] == $oldnick) - $isonline = true; - else - $uid++; - } - if ($isonline) - { - $key = $uid; - $this->_users[$chan][$key]["nick"] = $newnick; - $this->_users[$chan][$key]["timestamp"] = filemtime($newnick_filename); - } + $this->_users[$_chan][$id]["nick"] = $newnick; + $this->_users[$_chan][$id]["timestamp"] = filemtime($newnick_filename); } } @@ -323,7 +313,8 @@ } // cache the updated user list - $this->_users[$chan] =& $users; + $_chan = ($chan == NULL) ? "SERVER" : $chan; + $this->_users[$_chan] =& $users; return $deleted_user; } @@ -331,14 +322,14 @@ /** * Returns the nickname list on the given channel or on the whole server * @param $chan if NULL then returns all connected user, otherwise just returns the channel nicknames - * @return array() contains a nickname list + * @return array(array("nick"=>???,"timestamp"=>???) contains the nickname list with the associated timestamp (laste update time) */ function getOnlineNick($chan) { // return the cached user list if it exists - if (isset($this->_users[$chan]) && - is_array($this->_users[$chan])) - return $this->_users[$chan]; + $_chan = ($chan == NULL) ? "SERVER" : $chan; + if (isset($this->_users[$_chan]) && is_array($this->_users[$_chan])) + return $this->_users[$_chan]; $c =& $this->c; @@ -356,11 +347,37 @@ } // cache the user list - $this->_users[$chan] =& $users; + $this->_users[$_chan] =& $users; - return $users; + return $this->_users[$_chan]; } + + /** + * Returns returns a positive number if the nick is online + * @param $chan if NULL then check if the user is online on the server, otherwise check if the user has joined the channel + * @return -1 if the user is off line, a positive (>=0) if the user is online + */ + function isNickOnline($chan, $nick) + { + // get the nickname list + $_chan = ($chan == NULL) ? "SERVER" : $chan; + $online_users = isset($this->_users[$_chan]) ? $this->_users[$_chan] : $this->getOnlineNick($chan); + $uid = 0; + $isonline = false; + while($uid < count($online_users) && !$isonline) + { + if ($online_users[$uid]["nick"] == $nick) + $isonline = true; + else + $uid++; + } + if ($isonline) + return $uid; + else + return -1; + } + /** * Write a command to the given channel or to the server * Notice: a message is very generic, it can be a misc command (notice, me, ...) @@ -401,10 +418,10 @@ /** * Read the last posted commands from a channel or from the server + * Notice: the returned array must be ordered by id * @param $chan if NULL then read from the server, otherwise read from the given channel * @param $from_id read all message with a greater id * @return array() contains the command list - * @todo use one file (filename = msgid) for one message */ function read($chan, $from_id) { @@ -428,7 +445,8 @@ if ($file == "." || $file == "..") continue; // skip . and .. generic files if ($file>$from_id) { - $new_from_id = $file; + if ($file > $new_from_id) + $new_from_id = $file; $newmsg[] = $file; } } @@ -448,10 +466,11 @@ $data["sender"]= $formated_line[3]; $data["cmd"] = $formated_line[4]; $data["param"] = $formated_line[5]; - $datalist[] = $data; + $datalist[$data["id"]] = $data; } } - + ksort($datalist); + return array("data" => $datalist, "new_from_id" => $new_from_id ); } Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2006-05-11 16:56:06 UTC (rev 491) +++ trunk/src/pfctools.php 2006-05-12 13:55:14 UTC (rev 492) @@ -125,7 +125,7 @@ if($obj=='.' || $obj=='..') continue; if (!@unlink($dir.'/'.$obj)) rm_r($dir.'/'.$obj); } - rmdir($dir); + @rmdir($dir); } /** Modified: trunk/testcase/container_file.php =================================================================== --- trunk/testcase/container_file.php 2006-05-11 16:56:06 UTC (rev 491) +++ trunk/testcase/container_file.php 2006-05-12 13:55:14 UTC (rev 492) @@ -26,7 +26,7 @@ { pfcContainerTestcase::tearDown(); } - + // this is a specific test for the File container function testCreateNick_File() { @@ -47,7 +47,7 @@ } // on desactive le timeout car se script peut mettre bcp de temps a s'executer -ini_set('max_execution_time', -1); +ini_set('max_execution_time', 0); $suite = new PHPUnit_TestSuite(); $suite->addTestSuite("pfcContainerTestcase_File"); Modified: trunk/testcase/container_generic.php =================================================================== --- trunk/testcase/container_generic.php 2006-05-11 16:56:06 UTC (rev 491) +++ trunk/testcase/container_generic.php 2006-05-12 13:55:14 UTC (rev 492) @@ -45,7 +45,7 @@ // remove the created files and directories $this->ct->clear(); } - + function testCreateNick_Generic() { $c =& $this->c; @@ -56,14 +56,14 @@ // create on the channel $this->ct->createNick($chan, $nick, $nickid); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "nickname should be online on the channel"); + $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); + $this->assertTrue($isonline, "nickname should be online on the channel"); // create on the server $chan = NULL; $this->ct->createNick($chan, $nick, $nickid); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "nickname should be online on the server"); + $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); + $this->assertTrue($isonline, "nickname should be online on the server"); } function testRemoveNick_Generic() @@ -76,22 +76,18 @@ // on the channel $this->ct->createNick($chan, $nick, $nickid); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "nickname should be online on the channel"); - $this->ct->removeNick($chan,$nick); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertFalse(in_array($nick, $online_nick), "nickname should not be online on the channel"); + $this->ct->removeNick($chan, $nick); + $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); + $this->assertFalse($isonline, "nickname shouldn't be online on the channel"); // on the server $chan = NULL; $this->ct->createNick($chan, $nick, $nickid); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "nickname should be online on the server"); - $this->ct->removeNick($chan,$nick); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertFalse(in_array($nick, $online_nick), "nickname should not be online on the server"); + $this->ct->removeNick($chan, $nick); + $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); + $this->assertFalse($isonline, "nickname shouldn't be online on the server"); } - + function testGetNickId_Generic() { $c =& $this->c; @@ -104,7 +100,7 @@ $ret = $this->ct->getNickId($nick); $this->assertEquals($nickid, $ret, "created nickname doesn't have a correct nickid"); } - + function testRemoveObsoleteNick_Generic() { $c =& $this->c; @@ -115,24 +111,20 @@ // on the channel $this->ct->createNick($chan, $nick, $nickid); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "nickname should be online on the channel"); sleep(2); $ret = $this->ct->removeObsoleteNick($chan, "1000"); $this->assertTrue(in_array($nick, $ret), "nickname should be removed from the channel"); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertFalse(in_array($nick, $online_nick), "nickname should not be online on the channel"); - + $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); + $this->assertFalse($isonline, "nickname shouldn't be online on the channel"); + // on the server $chan = NULL; $this->ct->createNick($chan, $nick, $nickid); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "nickname should be online on the server"); sleep(2); $ret = $this->ct->removeObsoleteNick($chan, "1000"); $this->assertTrue(in_array($nick, $ret), "nickname should be removed from the server"); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertFalse(in_array($nick, $online_nick), "nickname should not be online on the server"); + $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); + $this->assertFalse($isonline, "nickname shouldn't be online on the server"); } function testSetGetRmMeta_Generic() @@ -177,61 +169,55 @@ // on the channel $this->ct->createNick($chan, $nick, $nickid); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "1-nickname should be online on the channel"); sleep(2); $ret = $this->ct->updateNick($chan, $nick); - $this->assertTrue($ret, "2-nickname should be correctly updated on the channel"); + $this->assertTrue($ret, "nickname should be correctly updated"); $ret = $this->ct->removeObsoleteNick($chan, "1000"); - $this->assertFalse(in_array($nick, $ret), "3-nickname should not be removed from the channel because it has been updated"); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "4-nickname should be online on the channel"); - + $this->assertFalse(in_array($nick, $ret), "nickname shouldn't be removed because it has been updated"); + $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); + $this->assertTrue($isonline, "nickname should be online"); + // on the server $chan = NULL; $this->ct->createNick($chan, $nick, $nickid); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "5-nickname should be online on the server"); sleep(2); $ret = $this->ct->updateNick($chan, $nick); - $this->assertTrue($ret, "6-nickname should be correctly updated on the server"); + $this->assertTrue($ret, "nickname should be correctly updated"); $ret = $this->ct->removeObsoleteNick($chan, "1000"); - $this->assertFalse(in_array($nick, $ret), "7-nickname should not be removed from the server because it has been updated"); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "8-nickname should be online on the server"); + $this->assertFalse(in_array($nick, $ret), "nickname shouldn't be removed because it has been updated"); + $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); + $this->assertTrue($isonline, "nickname should be online"); } function testchangeNick_Generic() { $c =& $this->c; $ct =& $this->ct; - $nick = $this->nick; + $nick1 = $this->nick; $nick2 = $this->nick."2"; $nickid = $this->nickid; $chan = $this->chan; // create on the channel - $this->ct->createNick($chan, $nick, $nickid); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "1-nickname should be online on the channel"); - $ret = $this->ct->changeNick($chan, $nick2, $nick); - $this->assertTrue($ret, "2-nickname change function should returns true (succes)"); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertFalse(in_array($nick, $online_nick), "3-nickname should not be online on the channel"); - $this->assertTrue(in_array($nick2, $online_nick), "4-nickname should be online on the channel"); - + $this->ct->createNick($chan, $nick1, $nickid); + $ret = $this->ct->changeNick($chan, $nick2, $nick1); + $this->assertTrue($ret, "nickname change function should returns true (success)"); + $isonline1 = ($this->ct->isNickOnline($chan, $nick1) >= 0); + $isonline2 = ($this->ct->isNickOnline($chan, $nick2) >= 0); + $this->assertFalse($isonline1, "nickname shouldn't be online"); + $this->assertTrue($isonline2, "nickname shouldn't be online"); + // create on the server $chan = NULL; - $this->ct->createNick($chan, $nick, $nickid); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "5-nickname should be online"); - $ret = $this->ct->changeNick($chan, $nick2, $nick); - $this->assertTrue($ret, "6-nickname change function should returns true (succes)"); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertFalse(in_array($nick, $online_nick), "7-nickname should not be online"); - $this->assertTrue(in_array($nick2, $online_nick), "8-nickname should be online on the channel"); + $this->ct->createNick($chan, $nick1, $nickid); + $ret = $this->ct->changeNick($chan, $nick2, $nick1); + $this->assertTrue($ret, "nickname change function should returns true (success)"); + $isonline1 = ($this->ct->isNickOnline($chan, $nick1) >= 0); + $isonline2 = ($this->ct->isNickOnline($chan, $nick2) >= 0); + $this->assertFalse($isonline1, "nickname shouldn't be online"); + $this->assertTrue($isonline2, "nickname shouldn't be online"); } - + function testwrite_Generic() { $c =& $this->c; @@ -244,28 +230,24 @@ // create message on the channel $this->ct->createNick($chan, $nick, $nickid); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "1-nickname should be online on the channel"); $msgid = $this->ct->write($chan, $nick, $cmd, $msg); - $this->assertEquals($msgid, 1,"2- generated msg_id is not correct"); + $this->assertEquals($msgid, 1,"generated msg_id is not correct"); $res = $this->ct->read($chan, 0); - $this->assertEquals(1, count($res["data"]), "3- 1 messages should be read"); - $this->assertEquals($msg, $res["data"][0]["param"] ,"4- messages data is not the same as the sent one"); - $this->assertEquals($res["new_from_id"], 1 ,"6- new_from_id is not correct"); + $this->assertEquals(1, count($res["data"]), "1 messages should be read"); + $this->assertEquals($msg, $res["data"][1]["param"] ,"messages data is not the same as the sent one"); + $this->assertEquals($res["new_from_id"], 1 ,"new_from_id is not correct"); // create message on the server $chan = NULL; $this->ct->createNick($chan, $nick, $nickid); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "7-nickname should be online on the channel"); $msgid = $this->ct->write($chan, $nick, $cmd, $msg); - $this->assertEquals($msgid, 1,"8- generated msg_id is not correct"); + $this->assertEquals($msgid, 1,"generated msg_id is not correct"); $res = $this->ct->read($chan, 0); - $this->assertEquals(1, count($res["data"]), "9- 1 messages should be read"); - $this->assertEquals($msg, $res["data"][0]["param"] ,"10- messages data is not the same as the sent one"); - $this->assertEquals($res["new_from_id"], 1 ,"11- new_from_id is not correct"); + $this->assertEquals(1, count($res["data"]), "1 messages should be read"); + $this->assertEquals($msg, $res["data"][1]["param"] ,"messages data is not the same as the sent one"); + $this->assertEquals($res["new_from_id"], 1 ,"new_from_id is not correct"); } - + function testread_Generic() { $c =& $this->c; @@ -278,28 +260,25 @@ // create on the channel $this->ct->createNick($chan, $nick, $nickid); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "1-nickname should be online on the channel"); for($i = 0; $i < 10; $i++) { $msgid = $this->ct->write($chan, $nick, $cmd ,$msg . $i); - $this->assertEquals($msgid, $i+1,"2- generated msg_id is not correct"); + $this->assertEquals($msgid, $i+1, "generated msg_id is not correct"); } $res = $this->ct->read($chan, 0); - $this->assertEquals(10, count($res["data"]), "3- 10 messages should be read"); - $this->assertEquals($msg."0", $res["data"][0]["param"] ,"4- messages data is not the same as the sent one"); - $this->assertEquals($msg."9", $res["data"][9]["param"] ,"5- messages data is not the same as the sent one"); - $this->assertEquals($res["new_from_id"], 10 ,"6- new_from_id is not correct"); - + $this->assertEquals(10, count($res["data"]), "10 messages should be read"); + $this->assertEquals($msg."0", $res["data"][1]["param"] ,"messages data is not the same as the sent one"); + $this->assertEquals($msg."8", $res["data"][9]["param"] ,"messages data is not the same as the sent one"); + $this->assertEquals($res["new_from_id"], 10 ,"new_from_id is not correct"); + $res = $this->ct->read($chan, 5); - $this->assertEquals(5, count($res["data"]), "7- 5 messages should be read"); - $this->assertEquals($msg."5", $res["data"][0]["param"] ,"8- messages data is not the same as the sent one"); - $this->assertEquals($msg."9", $res["data"][4]["param"] ,"9- messages data is not the same as the sent one"); - $this->assertEquals($res["new_from_id"], 10 ,"10- new_from_id is not correct"); + $this->assertEquals(5, count($res["data"]), "5 messages should be read"); + $this->assertEquals($msg."5", $res["data"][6]["param"] ,"messages data is not the same as the sent one"); + $this->assertEquals($msg."9", $res["data"][10]["param"] ,"messages data is not the same as the sent one"); + $this->assertEquals($res["new_from_id"], 10 ,"new_from_id is not correct"); } - function testgetLastId_Generic() { $c =& $this->c; @@ -312,28 +291,24 @@ // on the channel $this->ct->createNick($chan, $nick, $nickid); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "1-nickname should be online on the channel"); for($i = 0; $i < 10; $i++) { $msgid = $this->ct->write($chan, $nick, $cmd ,$msg . $i); - $this->assertEquals($msgid, $i+1,"2- generated msg_id is not correct"); + $this->assertEquals($msgid, $i+1,"generated msg_id is not correct"); } $msgid = $this->ct->getLastId($chan); - $this->assertEquals(10, $msgid, "3- last msgid is not correct"); + $this->assertEquals(10, $msgid, "last msgid is not correct"); // on the server $chan = NULL; $this->ct->createNick($chan, $nick, $nickid); - $online_nick = $this->ct->getOnlineNick($chan); - $this->assertTrue(in_array($nick, $online_nick), "4-nickname should be online on the channel"); for($i = 0; $i < 10; $i++) { $msgid = $this->ct->write($chan, $nick, $cmd ,$msg . $i); - $this->assertEquals($msgid, $i+1,"5- generated msg_id is not correct"); + $this->assertEquals($msgid, $i+1,"generated msg_id is not correct"); } $msgid = $this->ct->getLastId($chan); - $this->assertEquals(10, $msgid, "6- last msgid is not correct"); + $this->assertEquals(10, $msgid, "last msgid is not correct"); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-05-23 20:34:28
|
Revision: 500 Author: kerphi Date: 2006-05-23 13:34:13 -0700 (Tue, 23 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=500&view=rev Log Message: ----------- Bug fix: the nick parameters passed in the parameter array was not take into account Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php trunk/src/pfcuserconfig.class.php Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-05-23 20:33:23 UTC (rev 499) +++ trunk/src/pfcglobalconfig.class.php 2006-05-23 20:34:13 UTC (rev 500) @@ -31,7 +31,14 @@ class pfcGlobalConfig { var $serverid = ""; // this is the chat server id (comparable to the server host in IRC) + + // these parameters are dynamic (not cached) var $nick = ""; // the initial nickname ("" means the user will be queried) + var $channels = array(); // the default joined channels when opening the chat + var $privmsg = array(); // the default privmsg chat to lauch when opening the chat + var $active = false; // by default the user is not connected + + // these parameters are static (cached) var $title = ""; // default is _pfc("My Chat") var $channel = ""; // default is _pfc("My room") var $frozen_nick = false; @@ -124,6 +131,9 @@ if ($this->data_public_path == "") $this->data_public_path = dirname(__FILE__)."/../data/public"; $this->synchronizeWithCache(); + + // the nickname is not global, it must not be cached + $this->nick = $params["nick"]; } function &Instance( $params = array() ) @@ -428,52 +438,6 @@ else die(_pfc("Error: '%s' could not be found, please check your themepath '%s' and your theme '%s' are correct", $file, $this->themepath, $this->theme)); } - - - - - /* ---------------------------- */ - /* TO DELETE */ - - - /** - * save the pfcglobalconfig object into sessions if necessary - * else restore the old pfcglobalconfig object - */ - function synchronizeWithSession() - { - $session_id = $this->prefix."chatconfig_".$this->getId(); - if (isset($_SESSION[$session_id])) - { - $pfc_configvar = unserialize($_SESSION[$session_id]); - foreach($pfc_configvar as $key => $val) - $this->$key = $val; - if ($this->debug) pxlog("synchronizeWithSession[".$this->getId()."]: restore chatconfig from session nick=".$this->nick, "chatconfig", $this->getId()); - } - else - { - if (!$this->isInit()) - $this->init(); - $errors =& $this->getErrors(); - if (count($errors) > 0) - { - echo "<ul>"; foreach( $errors as $e ) echo "<li>".$e."</li>"; echo "</ul>"; - exit; - } - // save the validated config in session - $this->saveInSession(); - } - } - - function saveInSession() - { - $session_id = $this->prefix."chatconfig_".$this->getId(); - $_SESSION[$session_id] = serialize(get_object_vars($this)); - if ($this->debug) pxlog("saveInSession[".$this->getId()."]: nick=".$this->nick, "chatconfig", $this->getId()); - } - - - } ?> Modified: trunk/src/pfcuserconfig.class.php =================================================================== --- trunk/src/pfcuserconfig.class.php 2006-05-23 20:33:23 UTC (rev 499) +++ trunk/src/pfcuserconfig.class.php 2006-05-23 20:34:13 UTC (rev 500) @@ -10,7 +10,6 @@ var $active; var $timeout; - var $sessionid; var $is_init = false; // used internaly to know if the chat config is initialized @@ -27,6 +26,7 @@ $this->sessionid = session_id(); + // user parameters are cached in sessions $this->_getParam("nick"); if (!isset($this->nick)) $this->_setParam("nick",""); $this->_getParam("active"); @@ -35,9 +35,6 @@ if (!isset($this->channels)) $this->_setParam("channels",array()); $this->_getParam("privmsg"); if (!isset($this->privmsg)) $this->_setParam("privmsg",array()); - - //@ todo: save the nickname config into the cache - //$this->synchronizeWithCache(); } function &_getParam($p) @@ -49,6 +46,8 @@ $sessionid_param = $sessionid."_".$p; if (isset($_SESSION[$sessionid_param])) $this->$p = $_SESSION[$sessionid_param]; + else + $this->$p = $c->$p; // take the default parameter from the global config } return $this->$p; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-05-23 21:16:09
|
Revision: 501 Author: kerphi Date: 2006-05-23 14:16:00 -0700 (Tue, 23 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=501&view=rev Log Message: ----------- firt proxy command implementation (will be used for moderation, logging, ...) Modified Paths: -------------- trunk/src/pfccommand.class.php trunk/src/pfcglobalconfig.class.php Added Paths: ----------- trunk/src/pfcproxycommand.class.php trunk/src/proxys/ trunk/src/proxys/auth.class.php Modified: trunk/src/pfccommand.class.php =================================================================== --- trunk/src/pfccommand.class.php 2006-05-23 20:34:13 UTC (rev 500) +++ trunk/src/pfccommand.class.php 2006-05-23 21:16:00 UTC (rev 501) @@ -58,18 +58,36 @@ */ function &Factory($name) { - $cmd = NULL; - $name = strtolower($name); - $classname = "pfcCommand_".$name; - $filename = dirname(__FILE__)."/commands/".$name.".class.php"; - - if (file_exists($filename)) require_once($filename); - if(class_exists($classname)) + $c =& pfcGlobalConfig::Instance(); + + // instanciate the real command + $cmd = NULL; + $cmd_name = strtolower($name); + $cmd_classname = "pfcCommand_".$name; + $cmd_filename = dirname(__FILE__)."/commands/".$cmd_name.".class.php"; + if (file_exists($cmd_filename)) require_once($cmd_filename); + if (class_exists($cmd_classname)) { - $cmd =& new $classname(); - $cmd->name = $name; + $cmd =& new $cmd_classname(); + $cmd->name = $cmd_name; } - return $cmd; + + // instanciate the proxy chains + $proxy = NULL; + $proxy_name = strtolower($c->proxy[0]); + $proxy_classname = "pfcProxyCommand_" . $proxy_name; + $proxy_filename = dirname(__FILE__)."/proxys/".$proxy_name.".class.php"; + if (file_exists($proxy_filename)) require_once($proxy_filename); + if (class_exists($proxy_classname)) + { + $proxy =& new $proxy_classname(); + $proxy->name = $cmd_name; + $proxy->proxyname = $proxy_name; + $proxy->linkTo($cmd); + } + + // return the proxy, not the command (the proxy will forward the request to the real command) + return $proxy; } /** Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-05-23 20:34:13 UTC (rev 500) +++ trunk/src/pfcglobalconfig.class.php 2006-05-23 21:16:00 UTC (rev 501) @@ -32,12 +32,15 @@ { var $serverid = ""; // this is the chat server id (comparable to the server host in IRC) + var $admins = array(); + var $proxy = array("auth"); + // these parameters are dynamic (not cached) var $nick = ""; // the initial nickname ("" means the user will be queried) var $channels = array(); // the default joined channels when opening the chat var $privmsg = array(); // the default privmsg chat to lauch when opening the chat var $active = false; // by default the user is not connected - + // these parameters are static (cached) var $title = ""; // default is _pfc("My Chat") var $channel = ""; // default is _pfc("My room") Added: trunk/src/pfcproxycommand.class.php =================================================================== --- trunk/src/pfcproxycommand.class.php (rev 0) +++ trunk/src/pfcproxycommand.class.php 2006-05-23 21:16:00 UTC (rev 501) @@ -0,0 +1,64 @@ +<?php +/** + * pfcproxycommand.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__)."/pfccommand.class.php"; + +/** + * pfcProxyCommand is an abstract class (interface) which must be inherited by each concrete proxy commands + * + * @author Stephane Gully <ste...@gm...> + */ +class pfcProxyCommand extends pfcCommand +{ + /** + * Next proxy command + */ + var $next; + + /** + * The proxy name (similare to the command name) + */ + var $proxyname; + + /** + * Constructor + */ + function pfcProxyCommand() + { + pfcCommand::pfcCommand(); + } + + function linkTo(&$cmd) + { + $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 Added: trunk/src/proxys/auth.class.php =================================================================== --- trunk/src/proxys/auth.class.php (rev 0) +++ trunk/src/proxys/auth.class.php 2006-05-23 21:16:00 UTC (rev 501) @@ -0,0 +1,45 @@ +<?php +/** + * auth.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_auth + * + * @author Stephane Gully <ste...@gm...> + */ +class pfcProxyCommand_auth extends pfcProxyCommand +{ + function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + { + // $xml_reponse->addScript("alert('proxy auth');"); + + // if ($this->name == "send") + // $xml_reponse->addScript("alert('proxy auth');"); + + // on passe la main a au prochain proxy (ou a la command finale) + $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-05-25 11:47:36
|
Revision: 506 Author: kerphi Date: 2006-05-25 04:47:21 -0700 (Thu, 25 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=506&view=rev Log Message: ----------- + Bug fix: when speaking to someone the new open tab is now open in the background (/privmsg2 command) + As for the /privmsg2 command, a new command /join2 has been created in order to supporte invitation to a channel in the future. Modified Paths: -------------- trunk/src/commands/join.class.php trunk/src/commands/privmsg.class.php trunk/src/phpfreechat.class.php trunk/themes/default/templates/pfcclient.js.tpl.php Added Paths: ----------- trunk/src/commands/join2.class.php trunk/src/commands/privmsg2.class.php Modified: trunk/src/commands/join.class.php =================================================================== --- trunk/src/commands/join.class.php 2006-05-25 11:45:57 UTC (rev 505) +++ trunk/src/commands/join.class.php 2006-05-25 11:47:21 UTC (rev 506) @@ -40,7 +40,7 @@ // return ok to the client // then the client will create a new tab - $xml_reponse->addScript("pfc.handleResponse('join', 'ok', Array('".$chanid."','".addslashes($channame)."'));"); + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', Array('".$chanid."','".addslashes($channame)."'));"); } } Added: trunk/src/commands/join2.class.php =================================================================== --- trunk/src/commands/join2.class.php (rev 0) +++ trunk/src/commands/join2.class.php 2006-05-25 11:47:21 UTC (rev 506) @@ -0,0 +1,34 @@ +<?php +/** + * join2.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__)."/join.class.php"); + +/** + * Same as join command but open the tab in the background + * + * @author Stephane Gully <ste...@gm...> + */ +class pfcCommand_join2 extends pfcCommand_join +{ +} + +?> \ No newline at end of file Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2006-05-25 11:45:57 UTC (rev 505) +++ trunk/src/commands/privmsg.class.php 2006-05-25 11:47:21 UTC (rev 506) @@ -8,7 +8,7 @@ { $c =& $this->c; $u =& $this->u; - + $pvname = $param; // check the pvname exists on the server @@ -19,7 +19,7 @@ // error: can't speak to myself if ($pvnickid == $nickid) { - $xml_reponse->addScript("pfc.handleResponse('privmsg', 'ko', Array('".addslashes($pvname)."','speak to myself'));"); + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ko', Array('".addslashes($pvname)."','speak to myself'));"); return; } @@ -39,7 +39,7 @@ $u->saveInCache(); } - $xml_reponse->addScript("pfc.handleResponse('privmsg', 'unknown', Array('".addslashes($pvname)."','speak to unknown'));"); + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'unknown', Array('".addslashes($pvname)."','speak to unknown'));"); return; } @@ -73,7 +73,7 @@ // return ok to the client // then the client will create a new tab - $xml_reponse->addScript("pfc.handleResponse('privmsg', 'ok', Array('".$pvrecipientid."','".addslashes($pvname)."'));"); + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', Array('".$pvrecipientid."','".addslashes($pvname)."'));"); } } Added: trunk/src/commands/privmsg2.class.php =================================================================== --- trunk/src/commands/privmsg2.class.php (rev 0) +++ trunk/src/commands/privmsg2.class.php 2006-05-25 11:47:21 UTC (rev 506) @@ -0,0 +1,34 @@ +<?php +/** + * privmsg2.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__)."/privmsg.class.php"); + +/** + * Same as privmsg command but open the tab in the background + * + * @author Stephane Gully <ste...@gm...> + */ +class pfcCommand_privmsg2 extends pfcCommand_privmsg +{ +} + +?> \ No newline at end of file Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-05-25 11:45:57 UTC (rev 505) +++ trunk/src/phpfreechat.class.php 2006-05-25 11:47:21 UTC (rev 506) @@ -315,7 +315,7 @@ $sender = ""; //if (preg_match("/^\/([a-z]*) ([0-9a-f]*) ([0-9a-f]*)( (.*)|)/", $request, $res)) //if (preg_match("/^\/([a-z]+) ([0-9a-f]+) ([0-9a-f]+) (.*)/", $request, $res)) - if (preg_match("/^\/([a-z]+) ([0-9a-f]+) ([0-9a-f]+)( (.*)|)/", $request, $res)) + if (preg_match("/^\/([a-z0-9]+) ([0-9a-f]+) ([0-9a-f]+)( (.*)|)/", $request, $res)) { $rawcmd = isset($res[1]) ? $res[1] : ""; Modified: trunk/themes/default/templates/pfcclient.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcclient.js.tpl.php 2006-05-25 11:45:57 UTC (rev 505) +++ trunk/themes/default/templates/pfcclient.js.tpl.php 2006-05-25 11:47:21 UTC (rev 506) @@ -14,8 +14,10 @@ this.nickname = '<?php echo $u->nick; ?>'; + /* this.channels = Array(); this.channelids = Array(); + */ this.privmsgs = Array(); this.privmsgids = Array(); @@ -203,6 +205,22 @@ 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); + alert("ccc"); + } + else + alert(cmd + "-"+resp+"-"+param); + } else if (cmd == "leave") { //alert(cmd + "-"+resp+"-"+param); @@ -213,11 +231,13 @@ 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 = this.privmsgids.indexOf(tabid); @@ -247,6 +267,28 @@ 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") @@ -286,8 +328,8 @@ var index = this.privmsgs.indexOf(param); if (index == -1) { - // it doesn't exists, create it - this.sendRequest('/privmsg', param); + // it doesn't exists, create it in the background + this.sendRequest('/privmsg2', param); } else { @@ -355,7 +397,7 @@ { var w = this.el_words; var wval = w.value; - re = new RegExp("^(\/[a-z]+)( (.*)|)"); + re = new RegExp("^(\/[a-z0-9]+)( (.*)|)"); if (wval.match(re)) { /* a user command */ @@ -607,7 +649,7 @@ { var recipientid = this.gui.getTabId(); var req = cmd+" "+this.clientid+" "+(recipientid==''?'0':recipientid)+(param?" "+param : ""); - // if (cmd != "/update") alert(req); + if (cmd != "/update") alert(req); return <?php echo $prefix; ?>handleRequest(req); }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-05-26 14:32:21
|
Revision: 507 Author: kerphi Date: 2006-05-26 07:32:01 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=507&view=rev Log Message: ----------- Change the directory and file creation rights to 0700 (thanks to Thomas Lu?\195?\159nig for the notice) Modified Paths: -------------- branches/0.x/src/pfctools.php branches/0.x/src/phpfreechatcontainerfile.class.php trunk/src/containers/file.class.php trunk/src/pfctools.php Modified: branches/0.x/src/pfctools.php =================================================================== --- branches/0.x/src/pfctools.php 2006-05-25 11:47:21 UTC (rev 506) +++ branches/0.x/src/pfctools.php 2006-05-26 14:32:01 UTC (rev 507) @@ -103,7 +103,7 @@ } -function mkdir_r($path, $mode = 0777) +function mkdir_r($path, $mode = 0700) { // This function creates the specified directory using mkdir(). Note // that the recursive feature on mkdir() is broken with PHP 5.0.4 for @@ -128,7 +128,7 @@ * @param string $dest Destination path * @return bool Returns TRUE on success, FALSE on failure */ -function copyr($source, $dest, $mode = 0777) +function copyr($source, $dest, $mode = 0700) { // Simple copy for a file if (is_file($source)) { Modified: branches/0.x/src/phpfreechatcontainerfile.class.php =================================================================== --- branches/0.x/src/phpfreechatcontainerfile.class.php 2006-05-25 11:47:21 UTC (rev 506) +++ branches/0.x/src/phpfreechatcontainerfile.class.php 2006-05-26 14:32:01 UTC (rev 507) @@ -78,7 +78,7 @@ if ($ok && !file_exists($c->container_cfg_data_file)) { @touch($c->container_cfg_data_file); - @chmod($c->container_cfg_data_file, 0777); + @chmod($c->container_cfg_data_file, 0700); } if ($ok && !file_exists($c->container_cfg_data_file)) { @@ -113,7 +113,7 @@ if ($ok && !file_exists($c->container_cfg_index_file)) { @touch($c->container_cfg_index_file); - @chmod($c->container_cfg_index_file, 0777); + @chmod($c->container_cfg_index_file, 0700); } if ($ok && !file_exists($c->container_cfg_index_file)) { @@ -168,7 +168,7 @@ $my_filename = $c->container_cfg_nickname_dir."/".$this->_encode($c->nick); if (file_exists($my_filename)) $there = true; touch($my_filename); - @chmod($my_filename, 0777); + @chmod($my_filename, 0700); return $there; } Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2006-05-25 11:47:21 UTC (rev 506) +++ trunk/src/containers/file.class.php 2006-05-26 14:32:01 UTC (rev 507) @@ -190,7 +190,7 @@ $nick_filename = $nick_dir."/".$this->_encode($nick); if (file_exists($nick_filename)) $there = true; @touch($nick_filename); - @chmod($nick_filename, 0777); + @chmod($nick_filename, 0700); // append the nickname to the cache list $_chan = ($chan == NULL) ? "SERVER" : $chan; Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2006-05-25 11:47:21 UTC (rev 506) +++ trunk/src/pfctools.php 2006-05-26 14:32:01 UTC (rev 507) @@ -103,7 +103,7 @@ } -function mkdir_r($path, $mode = 0777) +function mkdir_r($path, $mode = 0700) { // This function creates the specified directory using mkdir(). Note // that the recursive feature on mkdir() is broken with PHP 5.0.4 for @@ -138,7 +138,7 @@ * @param string $dest Destination path * @return bool Returns TRUE on success, FALSE on failure */ -function copyr($source, $dest, $mode = 0777) +function copyr($source, $dest, $mode = 0700) { // 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-05-26 20:56:42
|
Revision: 509 Author: kerphi Date: 2006-05-26 13:56:29 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=509&view=rev Log Message: ----------- Code refactoring : change the specific "privmsg" metadata key to a more generic "cmdtoplay" Modified Paths: -------------- trunk/src/commands/nick.class.php trunk/src/commands/update.class.php trunk/src/phpfreechat.class.php trunk/src/proxys/auth.class.php trunk/themes/default/templates/pfcclient.js.tpl.php Added Paths: ----------- trunk/src/commands/kick.class.php trunk/src/commands/op.class.php Added: trunk/src/commands/kick.class.php =================================================================== --- trunk/src/commands/kick.class.php (rev 0) +++ trunk/src/commands/kick.class.php 2006-05-26 20:56:29 UTC (rev 509) @@ -0,0 +1,16 @@ +<?php + +require_once(dirname(__FILE__)."/../pfccommand.class.php"); + +class pfcCommand_kick extends pfcCommand +{ + function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + { + $c =& $this->c; + $u =& $this->u; + + $xml_reponse->addScript("alert('/kick $param command');"); + } +} + +?> \ No newline at end of file Modified: trunk/src/commands/nick.class.php =================================================================== --- trunk/src/commands/nick.class.php 2006-05-26 20:54:59 UTC (rev 508) +++ trunk/src/commands/nick.class.php 2006-05-26 20:56:29 UTC (rev 509) @@ -130,4 +130,4 @@ } } -?> +?> \ No newline at end of file Added: trunk/src/commands/op.class.php =================================================================== --- trunk/src/commands/op.class.php (rev 0) +++ trunk/src/commands/op.class.php 2006-05-26 20:56:29 UTC (rev 509) @@ -0,0 +1,16 @@ +<?php + +require_once(dirname(__FILE__)."/../pfccommand.class.php"); + +class pfcCommand_op extends pfcCommand +{ + function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + { + $c =& $this->c; + $u =& $this->u; + + $xml_reponse->addScript("alert('op command');"); + } +} + +?> \ No newline at end of file Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-05-26 20:54:59 UTC (rev 508) +++ trunk/src/commands/update.class.php 2006-05-26 20:56:29 UTC (rev 509) @@ -23,18 +23,21 @@ // $cmd =& pfcCommand::Factory("notice"); // $cmd->run($xml_reponse, $clientid, _pfc("%s quit (timeout)",$u), $sender, $recipient, $recipientid, 2); // } - - // ----- - // check if other user talk to me or not + + + // --- + // play the other commands $nickid = $container->getNickId($u->nick); - $pvnicks = $container->getMeta("privmsg", "nickname", $nickid); - if (is_string($pvnicks)) $pvnicks = unserialize($pvnicks); - if (!is_array($pvnicks)) $pvnicks = array(); - for( $i=0; $i < count($pvnicks); $i++) - $xml_reponse->addScript("pfc.handleResponse('update', 'privmsg', '".addslashes($pvnicks[$i])."');"); - $container->rmMeta("privmsg", "nickname", $nickid); - // ----- + $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); + if (is_string($cmdtoplay)) $cmdtoplay = unserialize($cmdtoplay); + if (!is_array($cmdtoplay)) $cmdtoplay = array(); + foreach($cmdtoplay as $cmdstr => $cmdparams) + foreach($cmdparams as $cmdparam) + $xml_reponse->addScript("pfc.handleResponse('update', 'cmdtoplay', Array('".$cmdstr."','".addslashes($cmdparam)."'));"); + $container->rmMeta("cmdtoplay", "nickname", $nickid); + // --- + // update the user nickname timestamp $cmd =& pfcCommand::Factory("updatemynick"); foreach( $u->channels as $id => $chan ) Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-05-26 20:54:59 UTC (rev 508) +++ trunk/src/phpfreechat.class.php 2006-05-26 20:56:29 UTC (rev 509) @@ -343,22 +343,27 @@ { $recipient = $u->privmsg[$recipientid]["recipient"]; + + // @todo: move this code in a proxy if ($rawcmd != "update" && - $rawcmd != "leave") // do not open the pv tab when other user close the tab + $rawcmd != "leave" && // do not open the pv tab when other user close the tab + $rawcmd != "privmsg2") { // alert the other from the new pv // (warn other user that someone talk to him) $container =& $c->getContainerInstance(); - $pvs = $container->getMeta("privmsg", "nickname", $u->privmsg[$recipientid]["pvnickid"]); - if (is_string($pvs)) $pvs = unserialize($pvs); - if (!is_array($pvs)) $pvs = array(); - if (!in_array($u->nick,$pvs)) + $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $u->privmsg[$recipientid]["pvnickid"]); + if (is_string($cmdtoplay)) $cmdtoplay = unserialize($cmdtoplay); + if (!is_array($cmdtoplay)) $cmdtoplay = array(); + if (!isset($cmdtoplay["privmsg2"])) $cmdtoplay["privmsg2"] = array(); + if (!in_array($u->nick, $cmdtoplay["privmsg2"])) { - $pvs[] = $u->nick; - // $xml_reponse->addScript("alert('pvs[]=".serialize($pvs)."');"); - $container->setMeta(serialize($pvs), "privmsg", "nickname", $u->privmsg[$recipientid]["pvnickid"]); + $cmdtoplay["privmsg2"][] = $u->nick; + $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $u->privmsg[$recipientid]["pvnickid"]); + // $xml_reponse->addScript("alert('cmdtoplay[]=".serialize($cmdtoplay)."');"); } } + } $cmd =& pfcCommand::Factory($rawcmd); Modified: trunk/src/proxys/auth.class.php =================================================================== --- trunk/src/proxys/auth.class.php 2006-05-26 20:54:59 UTC (rev 508) +++ trunk/src/proxys/auth.class.php 2006-05-26 20:56:29 UTC (rev 509) @@ -32,10 +32,22 @@ { function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) { + $c =& $this->c; + $u =& $this->u; + // $xml_reponse->addScript("alert('proxy auth');"); // if ($this->name == "send") // $xml_reponse->addScript("alert('proxy auth');"); + + if ($this->name == "op") + { + if (!in_array($u->nick, $c->admins)) + { + $xml_reponse->addScript("alert('not allowed to do /op');"); + } + } + // on passe la main a au prochain proxy (ou a la command finale) $this->next->run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); Modified: trunk/themes/default/templates/pfcclient.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcclient.js.tpl.php 2006-05-26 20:54:59 UTC (rev 508) +++ trunk/themes/default/templates/pfcclient.js.tpl.php 2006-05-26 20:56:29 UTC (rev 509) @@ -322,24 +322,22 @@ if (resp == "ok") { } - else if (resp == "privmsg") + else if (resp == "cmdtoplay") { - // check if the wanted privmsg exists or not - var index = this.privmsgs.indexOf(param); - if (index == -1) + if (param[0] == "privmsg2") { - // it doesn't exists, create it in the background - this.sendRequest('/privmsg2', param); - } - else - { - var tabid = this.privmsgids[index]; - if (this.gui.getTabId() != tabid) + // do not open the same tab twice + // (it's not necessary to speak to the server if the tab is allready open) + // so we check if the wanted privmsg tab exists or not + var index = this.privmsgs.indexOf(param[1]); + if (index == -1) { - // alert user something occurs in the pv tab - // alert("todo: highlight the '"+param+"' tab (tabid="+tabid+")"); + // it doesn't exists, create it in the background + this.sendRequest("/"+param[0],param[1]); } } + else + this.sendRequest("/"+param[0],param[1]); } // else // alert(cmd + "-"+resp+"-"+param); @@ -649,7 +647,7 @@ { var recipientid = this.gui.getTabId(); var req = cmd+" "+this.clientid+" "+(recipientid==''?'0':recipientid)+(param?" "+param : ""); - if (cmd != "/update") alert(req); + <?php if ($debug) { ?> if (cmd != "/update") alert(req);<?php } ?> return <?php echo $prefix; ?>handleRequest(req); }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-05-28 12:23:51
|
Revision: 520 Author: kerphi Date: 2006-05-28 05:23:40 -0700 (Sun, 28 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=520&view=rev Log Message: ----------- Refactoring on the 'cmdtoplay' code Modified Paths: -------------- trunk/src/commands/ban.class.php trunk/src/commands/kick.class.php trunk/src/commands/update.class.php trunk/src/phpfreechat.class.php Modified: trunk/src/commands/ban.class.php =================================================================== --- trunk/src/commands/ban.class.php 2006-05-28 11:56:07 UTC (rev 519) +++ trunk/src/commands/ban.class.php 2006-05-28 12:23:40 UTC (rev 520) @@ -15,10 +15,8 @@ if ($nickid != "undefined") { $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); - if (is_string($cmdtoplay)) $cmdtoplay = unserialize($cmdtoplay); - if (!is_array($cmdtoplay)) $cmdtoplay = array(); - if (!isset($cmdtoplay["leave"])) $cmdtoplay["leave"] = array(); - $cmdtoplay["leave"][] = $recipientid; // ban the user from the current channel //_pfc("banished by %s", $sender); + $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); + $cmdtoplay[] = array("leave",$recipientid); // ban the user from the current channel //_pfc("banished by %s", $sender); $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $nickid); } Modified: trunk/src/commands/kick.class.php =================================================================== --- trunk/src/commands/kick.class.php 2006-05-28 11:56:07 UTC (rev 519) +++ trunk/src/commands/kick.class.php 2006-05-28 12:23:40 UTC (rev 520) @@ -16,10 +16,8 @@ if ($nickid != "undefined") { $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); - if (is_string($cmdtoplay)) $cmdtoplay = unserialize($cmdtoplay); - if (!is_array($cmdtoplay)) $cmdtoplay = array(); - if (!isset($cmdtoplay["leave"])) $cmdtoplay["leave"] = array(); - $cmdtoplay["leave"][] = $recipientid; // kick the user from the current channel //_pfc("kicked by %s", $sender); + $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); + $cmdtoplay[] = array("leave", $recipientid); // kick the user from the current channel //_pfc("kicked by %s", $sender); $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $nickid); } } Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-05-28 11:56:07 UTC (rev 519) +++ trunk/src/commands/update.class.php 2006-05-28 12:23:40 UTC (rev 520) @@ -29,11 +29,9 @@ // play the other commands $nickid = $container->getNickId($u->nick); $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); - if (is_string($cmdtoplay)) $cmdtoplay = unserialize($cmdtoplay); - if (!is_array($cmdtoplay)) $cmdtoplay = array(); - foreach($cmdtoplay as $cmdstr => $cmdparams) - foreach($cmdparams as $cmdparam) - $xml_reponse->addScript("pfc.handleResponse('update', 'cmdtoplay', Array('".$cmdstr."','".addslashes($cmdparam)."'));"); + $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); + foreach($cmdtoplay as $cmdtmp) + $xml_reponse->addScript("pfc.handleResponse('update', 'cmdtoplay', Array('".$cmdtmp[0]."','".addslashes($cmdtmp[1])."'));"); $container->rmMeta("cmdtoplay", "nickname", $nickid); // --- Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-05-28 11:56:07 UTC (rev 519) +++ trunk/src/phpfreechat.class.php 2006-05-28 12:23:40 UTC (rev 520) @@ -353,19 +353,53 @@ // (warn other user that someone talk to him) $container =& $c->getContainerInstance(); $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $u->privmsg[$recipientid]["pvnickid"]); - if (is_string($cmdtoplay)) $cmdtoplay = unserialize($cmdtoplay); - if (!is_array($cmdtoplay)) $cmdtoplay = array(); - if (!isset($cmdtoplay["privmsg2"])) $cmdtoplay["privmsg2"] = array(); - if (!in_array($u->nick, $cmdtoplay["privmsg2"])) + $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); + //if (!isset($cmdtoplay["privmsg2"])) $cmdtoplay["privmsg2"] = array(); + if (!in_array(array("privmsg2", $u->nick), $cmdtoplay)) { - $cmdtoplay["privmsg2"][] = $u->nick; + $cmdtoplay[] = array("privmsg2", $u->nick); $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $u->privmsg[$recipientid]["pvnickid"]); - // $xml_reponse->addScript("alert('cmdtoplay[]=".serialize($cmdtoplay)."');"); + //$xml_reponse->addScript("alert('cmdtoplay[]=".serialize($cmdtoplay)."');"); } } - + } + + /* + // before playing the wanted command + // play the found commands into the meta 'cmdtoplay' + $container =& $c->getContainerInstance(); + $nickid = $container->getNickId($u->nick); + $morecmd = true; + while($morecmd) + { + // take a command from the list + $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); + $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); + $cmdtmp = array_pop($cmdtoplay); + if ($cmdtmp != NULL) + { + // store the new cmdtoplay list (-1 item) + $cmdtoplay = $container->setMeta("cmdtoplay", "nickname", $nickid); + + // play the command + + // check if there is other command to play + $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); + $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); + } + + $morecmd = (count($cmdtoplay) > 0); + } + + + */ + + + + + $cmd =& pfcCommand::Factory($rawcmd); if ($cmd != NULL) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-05-28 14:59:27
|
Revision: 521 Author: kerphi Date: 2006-05-28 07:59:14 -0700 (Sun, 28 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=521&view=rev Log Message: ----------- Refactoring on the 'cmdtoplay' code : remove the command call from the client side (security issue) Modified Paths: -------------- trunk/src/commands/update.class.php trunk/src/phpfreechat.class.php Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-05-28 12:23:40 UTC (rev 520) +++ trunk/src/commands/update.class.php 2006-05-28 14:59:14 UTC (rev 521) @@ -25,6 +25,7 @@ // } + /* // --- // play the other commands $nickid = $container->getNickId($u->nick); @@ -34,7 +35,7 @@ $xml_reponse->addScript("pfc.handleResponse('update', 'cmdtoplay', Array('".$cmdtmp[0]."','".addslashes($cmdtmp[1])."'));"); $container->rmMeta("cmdtoplay", "nickname", $nickid); // --- - + */ // update the user nickname timestamp $cmd =& pfcCommand::Factory("updatemynick"); Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-05-28 12:23:40 UTC (rev 520) +++ trunk/src/phpfreechat.class.php 2006-05-28 14:59:14 UTC (rev 521) @@ -365,7 +365,6 @@ } - /* // before playing the wanted command // play the found commands into the meta 'cmdtoplay' @@ -381,20 +380,27 @@ if ($cmdtmp != NULL) { // store the new cmdtoplay list (-1 item) - $cmdtoplay = $container->setMeta("cmdtoplay", "nickname", $nickid); + $cmdtoplay = $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $nickid); // play the command + $cmd =& pfcCommand::Factory($cmdtmp[0]); + if ($c->debug) + $cmd->run($xml_reponse, $clientid, $cmdtmp[1], $sender, $recipient, $recipientid); + else + @$cmd->run($xml_reponse, $clientid, $cmdtmp[1], $sender, $recipient, $recipientid); + + if ($cmdtmp[0] == "leave") + $xml_reponse->addScript("alert('KICK');"); // check if there is other command to play $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); - $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); + $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); } $morecmd = (count($cmdtoplay) > 0); } - */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-05-28 15:47:07
|
Revision: 523 Author: kerphi Date: 2006-05-28 08:46:57 -0700 (Sun, 28 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=523&view=rev Log Message: ----------- Refactoring on the 'cmdtoplay' command: Now all the command parameters are stored in the user meta. Now a reason is available for the /leave command, it is used by the kick and ban command Modified Paths: -------------- trunk/src/commands/ban.class.php trunk/src/commands/join.class.php trunk/src/commands/kick.class.php trunk/src/commands/leave.class.php trunk/src/commands/unban.class.php trunk/src/commands/update.class.php trunk/src/pfccommand.class.php trunk/src/phpfreechat.class.php Modified: trunk/src/commands/ban.class.php =================================================================== --- trunk/src/commands/ban.class.php 2006-05-28 15:44:30 UTC (rev 522) +++ trunk/src/commands/ban.class.php 2006-05-28 15:46:57 UTC (rev 523) @@ -4,19 +4,39 @@ class pfcCommand_ban extends pfcCommand { + var $usage = "/ban {nickname}"; + function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) { $c =& $this->c; $u =& $this->u; + if (trim($param) == "") + { + // error + $msg = _pfc("Missing parameter"); + $msg .= " (".$this->usage.")"; + $cmd =& pfcCommand::Factory("error"); + $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + return; + } + $container =& $c->getContainerInstance(); $nickid = $container->getNickId($param); if ($nickid != "undefined") { $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); - $cmdtoplay[] = array("leave",$recipientid); // ban the user from the current channel //_pfc("banished by %s", $sender); + + $cmdtmp = array("leave", /* cmdname */ + $recipientid,/* param */ + $sender, /* sender */ + $recipient, /* recipient */ + $recipientid,/* recipientid */ + ); + //_pfc("banished from %s by %s", $recipient, $sender); + $cmdtoplay[] = $cmdtmp; // ban the user from the current channel $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $nickid); } Modified: trunk/src/commands/join.class.php =================================================================== --- trunk/src/commands/join.class.php 2006-05-28 15:44:30 UTC (rev 522) +++ trunk/src/commands/join.class.php 2006-05-28 15:46:57 UTC (rev 523) @@ -4,15 +4,26 @@ class pfcCommand_join extends pfcCommand { + var $usage = "/join {channelname}"; + function run(&$xml_reponse, $clientid, &$param, &$sender, &$recipient, &$recipientid) { $c =& $this->c; $u =& $this->u; - $channame = $param; + $channame = trim($param); $chanrecip = pfcCommand_join::GetRecipient($channame); $chanid = pfcCommand_join::GetRecipientId($channame); + if ($channame == "") + { + $msg = _pfc("Missing parameter"); + $msg .= " (".$this->usage.")"; + $cmd =& pfcCommand::Factory("error"); + $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + return; + } + if(!isset($u->channels[$chanid])) { $u->channels[$chanid]["recipient"] = $chanrecip; Modified: trunk/src/commands/kick.class.php =================================================================== --- trunk/src/commands/kick.class.php 2006-05-28 15:44:30 UTC (rev 522) +++ trunk/src/commands/kick.class.php 2006-05-28 15:46:57 UTC (rev 523) @@ -4,11 +4,22 @@ class pfcCommand_kick extends pfcCommand { + var $usage = "/kick {nickname}"; + function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) { $c =& $this->c; $u =& $this->u; + if (trim($param) == "") + { + // error + $msg = _pfc("Missing parameter"); + $msg .= " (".$this->usage.")"; + $cmd =& pfcCommand::Factory("error"); + $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + return; + } // kicking a user just add a command to play to the aimed user metadata. $container =& $c->getContainerInstance(); @@ -17,7 +28,14 @@ { $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); - $cmdtoplay[] = array("leave", $recipientid); // kick the user from the current channel //_pfc("kicked by %s", $sender); + $reason = _pfc("kicked from %s by %s", $u->channels[$recipientid]["name"], $sender); + $cmdtmp = array("leave", /* cmdname */ + $recipientid." ".$reason, /* param */ + $sender, /* sender */ + $recipient, /* recipient */ + $recipientid,/* recipientid */ + ); + $cmdtoplay[] = $cmdtmp; // kick the user from the current channel $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $nickid); } } Modified: trunk/src/commands/leave.class.php =================================================================== --- trunk/src/commands/leave.class.php 2006-05-28 15:44:30 UTC (rev 522) +++ trunk/src/commands/leave.class.php 2006-05-28 15:46:57 UTC (rev 523) @@ -4,13 +4,22 @@ class pfcCommand_leave extends pfcCommand { + var $usage = "/leave [{recipientid} {reason}]"; + function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) { $c =& $this->c; $u =& $this->u; // tab to leave can be passed in the parameters - $id = ($param != "") ? $param : $recipientid; + // a reason can also be present (used for kick and ban commands) + $id = ""; $reason = ""; + if (preg_match("/([a-z0-9]*) (.*)/i", $param, $res)) + { + $id = $res[1]; + $reason = $res[2]; + } + if ($id == "") $id = $recipientid; // be default this is the current tab to leave // $xml_reponse->addScript("alert('sender=".addslashes($sender)."');"); // $xml_reponse->addScript("alert('recipientid=".addslashes($id)."');"); @@ -44,9 +53,11 @@ { if ($leavech) { - // show a leave message + // show a leave message with the showing the reason if present + $msg = _pfc("%s quit",$u->nick); + if ($reason != "") $msg .= " (".$reason.")"; $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $clientid, _pfc("%s quit",$u->nick), $sender, $leave_recip, $leave_id, 1); + $cmd->run($xml_reponse, $clientid, $msg, $sender, $leave_recip, $leave_id, 1); } // remove the nickname from the channel/pv @@ -60,7 +71,10 @@ else { // error - $xml_reponse->addScript("alert('error leaving ".$id."');"); + $msg = _pfc("Missing parameter"); + $msg .= " (".$this->usage.")"; + $cmd =& pfcCommand::Factory("error"); + $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); } } } Modified: trunk/src/commands/unban.class.php =================================================================== --- trunk/src/commands/unban.class.php 2006-05-28 15:44:30 UTC (rev 522) +++ trunk/src/commands/unban.class.php 2006-05-28 15:46:57 UTC (rev 523) @@ -4,6 +4,8 @@ class pfcCommand_unban extends pfcCommand { + var $usage = "/unban {id}"; + function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) { $c =& $this->c; @@ -11,7 +13,16 @@ $container =& $c->getContainerInstance(); - + if (trim($param) == "") + { + // error + $msg = _pfc("Missing parameter"); + $msg .= " (".$this->usage.")"; + $cmd =& pfcCommand::Factory("error"); + $cmd->run($xml_reponse, $clientid, $msg, $sender, $recipient, $recipientid); + return; + } + $updated = false; $msg = "<p>"._pfc("Nobody has been unbanished")."</p>"; Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-05-28 15:44:30 UTC (rev 522) +++ trunk/src/commands/update.class.php 2006-05-28 15:46:57 UTC (rev 523) @@ -23,19 +23,6 @@ // $cmd =& pfcCommand::Factory("notice"); // $cmd->run($xml_reponse, $clientid, _pfc("%s quit (timeout)",$u), $sender, $recipient, $recipientid, 2); // } - - - /* - // --- - // play the other commands - $nickid = $container->getNickId($u->nick); - $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); - $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); - foreach($cmdtoplay as $cmdtmp) - $xml_reponse->addScript("pfc.handleResponse('update', 'cmdtoplay', Array('".$cmdtmp[0]."','".addslashes($cmdtmp[1])."'));"); - $container->rmMeta("cmdtoplay", "nickname", $nickid); - // --- - */ // update the user nickname timestamp $cmd =& pfcCommand::Factory("updatemynick"); Modified: trunk/src/pfccommand.class.php =================================================================== --- trunk/src/pfccommand.class.php 2006-05-28 15:44:30 UTC (rev 522) +++ trunk/src/pfccommand.class.php 2006-05-28 15:46:57 UTC (rev 523) @@ -35,6 +35,11 @@ * Command name (lowercase) */ var $name; + + /** + * Contains the command syntaxe (how to use the command) + */ + var $usage; /** * Not used for now Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-05-28 15:44:30 UTC (rev 522) +++ trunk/src/phpfreechat.class.php 2006-05-28 15:46:57 UTC (rev 523) @@ -354,10 +354,15 @@ $container =& $c->getContainerInstance(); $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $u->privmsg[$recipientid]["pvnickid"]); $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); - //if (!isset($cmdtoplay["privmsg2"])) $cmdtoplay["privmsg2"] = array(); - if (!in_array(array("privmsg2", $u->nick), $cmdtoplay)) + $cmdtmp = array("privmsg2", /* cmdname */ + $u->nick, /* param */ + $sender, /* sender */ + $recipient, /* recipient */ + $recipientid,/* recipientid */ + ); + if (!in_array($cmdtmp, $cmdtoplay)) { - $cmdtoplay[] = array("privmsg2", $u->nick); + $cmdtoplay[] = $cmdtmp; $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $u->privmsg[$recipientid]["pvnickid"]); //$xml_reponse->addScript("alert('cmdtoplay[]=".serialize($cmdtoplay)."');"); } @@ -385,12 +390,16 @@ // play the command $cmd =& pfcCommand::Factory($cmdtmp[0]); if ($c->debug) - $cmd->run($xml_reponse, $clientid, $cmdtmp[1], $sender, $recipient, $recipientid); + $cmd->run($xml_reponse, $clientid, $cmdtmp[1], $cmdtmp[2], $cmdtmp[3], $cmdtmp[4]); else - @$cmd->run($xml_reponse, $clientid, $cmdtmp[1], $sender, $recipient, $recipientid); + @$cmd->run($xml_reponse, $clientid, $cmdtmp[1], $cmdtmp[2], $cmdtmp[3], $cmdtmp[4]); + // if the cmdtoplay is a 'leave' command, then show an alert to the kicked or banished user if ($cmdtmp[0] == "leave") - $xml_reponse->addScript("alert('KICK');"); + { + if (preg_match("/([a-z0-9]*) (.*)/i", $cmdtmp[1], $res)) + $xml_reponse->addScript("alert('".$res[2]."');"); + } // check if there is other command to play $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-05-28 18:36:14
|
Revision: 529 Author: kerphi Date: 2006-05-28 11:36:08 -0700 (Sun, 28 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=529&view=rev Log Message: ----------- remove 'admins' parameter array add 'isadmin' parameter rename 'proxy' to 'proxys' parameter Modified Paths: -------------- trunk/src/commands/connect.class.php trunk/src/pfccommand.class.php trunk/src/pfcglobalconfig.class.php Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-05-28 17:09:31 UTC (rev 528) +++ trunk/src/commands/connect.class.php 2006-05-28 18:36:08 UTC (rev 529) @@ -20,11 +20,7 @@ // store the user ip $container->setMeta($_SERVER["REMOTE_ADDR"], "ip", "nickname", $nickid); // store the admin flag - if (in_array($c->nick, $c->admins)) - $container->setMeta(true, "isadmin", "nickname", $nickid); - else - $container->setMeta(false, "isadmin", "nickname", $nickid); - + $container->setMeta($c->isadmin, "isadmin", "nickname", $nickid); // connect to the server $xml_reponse->addScript("pfc.handleResponse('connect', 'ok', '');"); Modified: trunk/src/pfccommand.class.php =================================================================== --- trunk/src/pfccommand.class.php 2006-05-28 17:09:31 UTC (rev 528) +++ trunk/src/pfccommand.class.php 2006-05-28 18:36:08 UTC (rev 529) @@ -79,7 +79,7 @@ // instanciate the proxy chains $proxy = NULL; - $proxy_name = strtolower($c->proxy[0]); + $proxy_name = strtolower($c->proxys[0]); $proxy_classname = "pfcProxyCommand_" . $proxy_name; $proxy_filename = dirname(__FILE__)."/proxys/".$proxy_name.".class.php"; if (file_exists($proxy_filename)) require_once($proxy_filename); Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-05-28 17:09:31 UTC (rev 528) +++ trunk/src/pfcglobalconfig.class.php 2006-05-28 18:36:08 UTC (rev 529) @@ -31,17 +31,16 @@ class pfcGlobalConfig { var $serverid = ""; // this is the chat server id (comparable to the server host in IRC) - - var $admins = array(); - var $proxy = array("auth"); // these parameters are dynamic (not cached) var $nick = ""; // the initial nickname ("" means the user will be queried) + var $isadmin = false; var $channels = array(); // the default joined channels when opening the chat var $privmsg = array(); // the default privmsg chat to lauch when opening the chat var $active = false; // by default the user is not connected // these parameters are static (cached) + var $proxys = array("auth"); var $title = ""; // default is _pfc("My Chat") var $channel = ""; // default is _pfc("My room") var $frozen_nick = false; @@ -135,8 +134,10 @@ $this->synchronizeWithCache(); - // the nickname is not global, it must not be cached - if (isset($params["nick"])) $this->nick = $params["nick"]; + // the 'nick' is dynamic, it must not be cached + if (isset($params["nick"])) $this->nick = $params["nick"]; + // the 'isadmin' flag is dynamic, it must not be cached + if (isset($params["isadmin"])) $this->isadmin = $params["isadmin"]; } function &Instance( $params = array() ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-05-28 18:54:52
|
Revision: 531 Author: kerphi Date: 2006-05-28 11:54:30 -0700 (Sun, 28 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=531&view=rev Log Message: ----------- Bug fix: unknown command error handling was broken Modified Paths: -------------- trunk/src/pfccommand.class.php trunk/src/proxys/auth.class.php Modified: trunk/src/pfccommand.class.php =================================================================== --- trunk/src/pfccommand.class.php 2006-05-28 18:47:04 UTC (rev 530) +++ trunk/src/pfccommand.class.php 2006-05-28 18:54:30 UTC (rev 531) @@ -75,24 +75,25 @@ { $cmd =& new $cmd_classname(); $cmd->name = $cmd_name; + + // instanciate the proxy chains + $proxy = NULL; + $proxy_name = strtolower($c->proxys[0]); + $proxy_classname = "pfcProxyCommand_" . $proxy_name; + $proxy_filename = dirname(__FILE__)."/proxys/".$proxy_name.".class.php"; + if (file_exists($proxy_filename)) require_once($proxy_filename); + if (class_exists($proxy_classname)) + { + $proxy =& new $proxy_classname(); + $proxy->name = $cmd_name; + $proxy->proxyname = $proxy_name; + $proxy->linkTo($cmd); + } + + // return the proxy, not the command (the proxy will forward the request to the real command) + return $proxy; } - - // instanciate the proxy chains - $proxy = NULL; - $proxy_name = strtolower($c->proxys[0]); - $proxy_classname = "pfcProxyCommand_" . $proxy_name; - $proxy_filename = dirname(__FILE__)."/proxys/".$proxy_name.".class.php"; - if (file_exists($proxy_filename)) require_once($proxy_filename); - if (class_exists($proxy_classname)) - { - $proxy =& new $proxy_classname(); - $proxy->name = $cmd_name; - $proxy->proxyname = $proxy_name; - $proxy->linkTo($cmd); - } - - // return the proxy, not the command (the proxy will forward the request to the real command) - return $proxy; + return $cmd; } /** Modified: trunk/src/proxys/auth.class.php =================================================================== --- trunk/src/proxys/auth.class.php 2006-05-28 18:47:04 UTC (rev 530) +++ trunk/src/proxys/auth.class.php 2006-05-28 18:54:30 UTC (rev 531) @@ -75,7 +75,7 @@ } } - // on passe la main a au prochain proxy (ou a la command finale) + // forward the command to the next proxy or to the final command $this->next->run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-07 20:07:33
|
Revision: 553 Author: kerphi Date: 2006-06-06 10:34:11 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=553&view=rev Log Message: ----------- New feature: add a new parameter "frozen_channels" which is a list of channels users are allowed to join. Modified Paths: -------------- trunk/i18n/en_US/main.php trunk/i18n/fr_FR/main.php trunk/src/pfcglobalconfig.class.php trunk/src/proxys/auth.class.php trunk/themes/default/templates/pfcclient.js.tpl.php Modified: trunk/i18n/en_US/main.php =================================================================== --- trunk/i18n/en_US/main.php 2006-06-06 17:21:08 UTC (rev 552) +++ trunk/i18n/en_US/main.php 2006-06-06 17:34:11 UTC (rev 553) @@ -234,4 +234,7 @@ // line 79 in auth.class.php $GLOBALS["i18n"]["You are not allowed to change your nickname"] = "You are not allowed to change your nickname"; +// line 76 in auth.class.php +$GLOBALS["i18n"]["Can't join %s because the channels list is restricted"] = "Can't join %s because the channels list is restricted"; + ?> \ No newline at end of file Modified: trunk/i18n/fr_FR/main.php =================================================================== --- trunk/i18n/fr_FR/main.php 2006-06-06 17:21:08 UTC (rev 552) +++ trunk/i18n/fr_FR/main.php 2006-06-06 17:34:11 UTC (rev 553) @@ -234,4 +234,7 @@ // line 79 in auth.class.php $GLOBALS["i18n"]["You are not allowed to change your nickname"] = "Vous n'êtes pas autorisé à changer votre pseudonyme"; +// line 76 in auth.class.php +$GLOBALS["i18n"]["Can't join %s because the channels list is restricted"] = "Vous ne pouvez pas rejoindre %s car il n'est pas dans la liste des salons autorisés"; + ?> \ No newline at end of file Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-06-06 17:21:08 UTC (rev 552) +++ trunk/src/pfcglobalconfig.class.php 2006-06-06 17:34:11 UTC (rev 553) @@ -40,7 +40,7 @@ var $proxys = array("auth"); var $title = ""; // default is _pfc("My Chat") var $channels = array(); // the default joined channels when opening the chat - var $privmsg = array(); // the default privmsg chat to lauch when opening the chat + var $frozen_channels = array(); // by default allow users to create there own channels var $frozen_nick = false; var $max_nick_len = 15; var $max_text_len = 400; Modified: trunk/src/proxys/auth.class.php =================================================================== --- trunk/src/proxys/auth.class.php 2006-06-06 17:21:08 UTC (rev 552) +++ trunk/src/proxys/auth.class.php 2006-06-06 17:34:11 UTC (rev 553) @@ -49,25 +49,35 @@ } } - // protect channel from the banished users + // channels protection if ($this->name == "join") { - // check the user is not listed in the banished channel list $container =& $c->getContainerInstance(); $channame = $param; + + // check the user is not listed in the banished channel list $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); if (in_array($nickid,$banlist)) { - // the user is banished, show a message and don't forward the /join command $msg = _pfc("Can't join %s because you are banished", $param); $xml_reponse->addScript("pfc.handleResponse('".$this->proxyname."', 'ban', '".addslashes($msg)."');"); return; } + + if (count($c->frozen_channels)>0) + { + if (!in_array($channame,$c->frozen_channels)) + { + // the user is banished, show a message and don't forward the /join command + $msg = _pfc("Can't join %s because the channels list is restricted", $param); + $xml_reponse->addScript("pfc.handleResponse('".$this->proxyname."', 'frozen', '".addslashes($msg)."');"); + return; + } + } } // disallow to change nickname if frozen_nick is true Modified: trunk/themes/default/templates/pfcclient.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcclient.js.tpl.php 2006-06-06 17:21:08 UTC (rev 552) +++ trunk/themes/default/templates/pfcclient.js.tpl.php 2006-06-06 17:34:11 UTC (rev 553) @@ -388,6 +388,10 @@ { alert(param); } + if (resp == "frozen") + { + alert(param); + } else if (resp == "nick") { this.displayMsg( cmd, param ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-07 20:11:34
|
Revision: 552 Author: kerphi Date: 2006-06-06 10:21:08 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=552&view=rev Log Message: ----------- Bug fix: the "channels" parameter didn't work as expected Modified Paths: -------------- trunk/src/commands/init.class.php trunk/src/commands/rehash.class.php trunk/src/pfcglobalconfig.class.php trunk/src/pfcuserconfig.class.php trunk/themes/default/templates/pfcclient.js.tpl.php Modified: trunk/src/commands/init.class.php =================================================================== --- trunk/src/commands/init.class.php 2006-06-06 17:19:21 UTC (rev 551) +++ trunk/src/commands/init.class.php 2006-06-06 17:21:08 UTC (rev 552) @@ -7,14 +7,12 @@ function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) { $c =& $this->c; - + $u =& $this->u; + $cmd =& pfcCommand::Factory("quit"); $cmd->run($xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); - if (isset($_COOKIE[session_name()])) - { - setcookie(session_name(), '', time()-42000, '/'); - } // clobber the cookie + $u->destroy(); } } Modified: trunk/src/commands/rehash.class.php =================================================================== --- trunk/src/commands/rehash.class.php 2006-06-06 17:19:21 UTC (rev 551) +++ trunk/src/commands/rehash.class.php 2006-06-06 17:21:08 UTC (rev 552) @@ -14,7 +14,8 @@ function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) { $c =& $this->c; - $synchro = $c->synchronizeWithCache(true); // true => destroy the cache + $c->destroy(); + $synchro = $c->synchronizeWithCache(); if ($synchro) $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ko', '');"); Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-06-06 17:19:21 UTC (rev 551) +++ trunk/src/pfcglobalconfig.class.php 2006-06-06 17:21:08 UTC (rev 552) @@ -35,14 +35,12 @@ // these parameters are dynamic (not cached) var $nick = ""; // the initial nickname ("" means the user will be queried) var $isadmin = false; - var $channels = array(); // the default joined channels when opening the chat - var $privmsg = array(); // the default privmsg chat to lauch when opening the chat - var $active = false; // by default the user is not connected // these parameters are static (cached) var $proxys = array("auth"); var $title = ""; // default is _pfc("My Chat") - var $channel = ""; // default is _pfc("My room") + var $channels = array(); // the default joined channels when opening the chat + var $privmsg = array(); // the default privmsg chat to lauch when opening the chat var $frozen_nick = false; var $max_nick_len = 15; var $max_text_len = 400; @@ -182,12 +180,12 @@ if ($this->debug) pxlog("pfcGlobalConfig::init()", "chatconfig", $this->getId()); if ($this->title == "") $this->title = _pfc("My Chat"); - if ($this->channel == "") $this->channel = _pfc("My room"); if ($this->ie7path == "") $this->ie7path = dirname(__FILE__)."/../lib/IE7_0_9"; 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 (count($this->channels) == 0) $this->channels = array(_pfc("My room")); + // first of all, check the used functions $f_list["file_get_contents"] = _pfc("You need %s", "PHP 4 >= 4.3.0 or PHP 5"); $err_session_x = "You need PHP 4 or PHP 5"; @@ -374,23 +372,22 @@ function getId() { - /* channel is concatenated because it dynamic parameters - * further these parameter must be separated from global pfcconfig - * and can be changed dynamicaly in the user session */ return $this->serverid; } - + function destroy() + { + $cachefile = $this->data_private_path."/cache/pfcglobalconfig_".$this->getId(); + @unlink($cachefile); + } + /** * save the pfcConfig object into cache if it doesn't exists yet * else restore the old pfcConfig object */ - function synchronizeWithCache($destroy = false) + function synchronizeWithCache() { $cachefile = $this->data_private_path."/cache/pfcglobalconfig_".$this->getId(); - - // destroy the cache if init parameter is present into the url - if (isset($_GET["init"]) || $destroy) @unlink($cachefile); if (file_exists($cachefile)) { Modified: trunk/src/pfcuserconfig.class.php =================================================================== --- trunk/src/pfcuserconfig.class.php 2006-06-06 17:19:21 UTC (rev 551) +++ trunk/src/pfcuserconfig.class.php 2006-06-06 17:21:08 UTC (rev 552) @@ -17,9 +17,10 @@ function pfcUserConfig() { + $c =& pfcGlobalConfig::Instance(); + // start the session : session is used for locking purpose and cache purpose session_name( "phpfreechat" ); - if (isset($_GET["init"])) unset($_COOKIE[session_name()]); if(session_id() == "") session_start(); // echo "pfcUserConfig()<br>"; @@ -28,7 +29,7 @@ // user parameters are cached in sessions $this->_getParam("nick"); - if (!isset($this->nick)) $this->_setParam("nick",""); + if (!isset($this->nick)) $this->_setParam("nick",$c->nick); $this->_getParam("active"); if (!isset($this->active)) $this->_setParam("active",false); $this->_getParam("channels"); @@ -46,8 +47,6 @@ $sessionid_param = $sessionid."_".$p; if (isset($_SESSION[$sessionid_param])) $this->$p = $_SESSION[$sessionid_param]; - else - $this->$p = $c->$p; // take the default parameter from the global config } return $this->$p; } @@ -60,6 +59,15 @@ $_SESSION[$sessionid_param] = $v; $this->$p = $v; } + + function _rmParam($p) + { + $c =& pfcGlobalConfig::Instance(); + $sessionid = "pfcuserconfig_".$c->getId(); + $sessionid_param = $sessionid."_".$p; + unset($_SESSION[$sessionid_param]); + unset($this->$p); + } function &Instance() { @@ -149,6 +157,14 @@ } } */ + + function destroy() + { + $this->_rmParam("nick"); + $this->_rmParam("active"); + $this->_rmParam("channels"); + $this->_rmParam("privmsg"); + } function saveInCache() { Modified: trunk/themes/default/templates/pfcclient.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcclient.js.tpl.php 2006-06-06 17:19:21 UTC (rev 551) +++ trunk/themes/default/templates/pfcclient.js.tpl.php 2006-06-06 17:21:08 UTC (rev 552) @@ -162,7 +162,8 @@ // or the default one <?php if (count($u->channels) == 0) - echo "this.sendRequest('/join', '".addslashes($c->channel)."');\n"; + foreach($c->channels as $ch) + echo "this.sendRequest('/join', '".addslashes($ch)."');\n"; foreach($u->channels as $ch) echo "this.sendRequest('/join', '".addslashes($ch["name"])."');\n"; foreach($u->privmsg as $pv) @@ -306,7 +307,8 @@ // or the default one <?php if (count($u->channels) == 0) - echo "this.sendRequest('/join', '".addslashes($c->channel)."');\n"; + foreach($c->channels as $ch) + echo "this.sendRequest('/join', '".addslashes($ch)."');\n"; foreach($u->channels as $ch) echo "this.sendRequest('/join', '".addslashes($ch["name"])."');\n"; foreach($u->privmsg as $pv) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-08 19:45:25
|
Revision: 557 Author: kerphi Date: 2006-06-08 12:45:18 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=557&view=rev Log Message: ----------- Bug fix: the /rehash command was broken Bug fix: the themes were not installed in the public directory, now they are copied Modified Paths: -------------- trunk/src/commands/rehash.class.php trunk/src/pfcglobalconfig.class.php Modified: trunk/src/commands/rehash.class.php =================================================================== --- trunk/src/commands/rehash.class.php 2006-06-08 19:35:08 UTC (rev 556) +++ trunk/src/commands/rehash.class.php 2006-06-08 19:45:18 UTC (rev 557) @@ -14,10 +14,10 @@ function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) { $c =& $this->c; - $c->destroy(); - $synchro = $c->synchronizeWithCache(); + $destroyed = $c->destroy(); + $synchro = $c->synchronizeWithCache(); - if ($synchro) + if ($destroyed && $synchro) $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ko', '');"); else $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', '');"); Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-06-08 19:35:08 UTC (rev 556) +++ trunk/src/pfcglobalconfig.class.php 2006-06-08 19:45:18 UTC (rev 557) @@ -244,17 +244,6 @@ if ($this->client_script_url == "") $this->client_script_url = "./".basename($filetotest); - // set the default theme path - if ($this->themepath_default == "") - $this->themepath_default = dirname(__FILE__)."/../themes"; - if ($this->themepath == "") - $this->themepath = $this->themepath_default; - - // calculate the default theme url - if ($this->themeurl_default == "") - $this->themeurl_default = relativePath($this->client_script_path, $this->themepath_default); - if ($this->themeurl == "") - $this->themeurl = relativePath($this->client_script_path, $this->themepath); // calculate datapublic url if ($this->data_public_url == "") @@ -275,6 +264,24 @@ $this->errors[] = _pfc("%s doesn't exist", $filetotest); if ($this->server_script_url == "") $this->server_script_url = relativePath($this->client_script_path, $this->server_script_path)."/".basename($filetotest); + + // check if the themepath parameter are correctly setup + if ($this->themepath_default == "" || !is_dir($this->themepath_default)) + $this->themepath_default = dirname(__FILE__)."/../themes"; + if ($this->themepath == "" || !is_dir($this->themepath)) + $this->themepath = $this->themepath_default; + // copy the themes into the public directory + $this->errors = array_merge($this->errors, @install_dir($this->themepath_default, $this->data_public_path."/themes")); + $this->errors = array_merge($this->errors, @install_dir($this->themepath, $this->data_public_path."/themes")); + // now it's copied, so update the themepath parameters to the new location + $this->themepath_default = $this->data_public_path."/themes"; + $this->themepath = $this->data_public_path."/themes"; + // calculate the corresponding theme url + if ($this->themeurl_default == "") + $this->themeurl_default = relativePath($this->client_script_path, $this->data_public_path."/themes"); + if ($this->themeurl == "") + $this->themeurl = relativePath($this->client_script_path, $this->data_public_path."/themes"); + // --- // run specific container initialisation @@ -356,7 +363,7 @@ { if (preg_match("/^#.*/",$line)) continue; - else if (preg_match("/^([a-z_0-9]*(\.gif|\.png))(.*)$/i",$line,$res)) + else if (preg_match("/^([a-z_\-0-9]*(\.gif|\.png))(.*)$/i",$line,$res)) { $smiley_file = $this->getFileUrlFromTheme('smileys/'.$res[1]); $smiley_str = trim($res[3])."\n"; @@ -378,7 +385,10 @@ function destroy() { $cachefile = $this->data_private_path."/cache/pfcglobalconfig_".$this->getId(); - @unlink($cachefile); + if (!file_exists($cachefile)) + return false; + $this->is_init = false; + return @unlink($cachefile); } /** @@ -388,7 +398,7 @@ function synchronizeWithCache() { $cachefile = $this->data_private_path."/cache/pfcglobalconfig_".$this->getId(); - + if (file_exists($cachefile)) { $pfc_configvar = unserialize(file_get_contents($cachefile)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-11 21:22:29
|
Revision: 562 Author: kerphi Date: 2006-06-11 14:22:17 -0700 (Sun, 11 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=562&view=rev Log Message: ----------- - add the "noflood" proxy : don't allow flooders - fix the proxy chaine generation Modified Paths: -------------- trunk/src/pfccommand.class.php trunk/src/pfcglobalconfig.class.php Added Paths: ----------- trunk/src/proxys/noflood.class.php Modified: trunk/src/pfccommand.class.php =================================================================== --- trunk/src/pfccommand.class.php 2006-06-09 11:21:03 UTC (rev 561) +++ trunk/src/pfccommand.class.php 2006-06-11 21:22:17 UTC (rev 562) @@ -69,30 +69,40 @@ $cmd = NULL; $cmd_name = strtolower($name); $cmd_classname = "pfcCommand_".$name; - $cmd_filename = dirname(__FILE__)."/commands/".$cmd_name.".class.php"; - if (file_exists($cmd_filename)) require_once($cmd_filename); + if (!class_exists($cmd_classname)) + { + $cmd_filename = dirname(__FILE__)."/commands/".$cmd_name.".class.php"; + if (file_exists($cmd_filename)) require_once($cmd_filename); + } if (class_exists($cmd_classname)) { $cmd =& new $cmd_classname(); $cmd->name = $cmd_name; - // instanciate the proxy chains - // @todo instanciate the whole chain (from the 'proxys' parameter array) - $proxy = NULL; - $proxy_name = strtolower($c->proxys[0]); - $proxy_classname = "pfcProxyCommand_" . $proxy_name; - $proxy_filename = dirname(__FILE__)."/proxys/".$proxy_name.".class.php"; - if (file_exists($proxy_filename)) require_once($proxy_filename); - if (class_exists($proxy_classname)) + // instanciate the proxys chaine + $firstproxy =& $cmd; + for($i = count($c->proxys)-1; $i >= 0; $i--) { - $proxy =& new $proxy_classname(); - $proxy->name = $cmd_name; - $proxy->proxyname = $proxy_name; - $proxy->linkTo($cmd); + $proxy_name = strtolower($c->proxys[$i]); + $proxy_classname = "pfcProxyCommand_" . $proxy_name; + if (!class_exists($proxy_classname)) + { + // try to include the proxy class file + $proxy_filename = dirname(__FILE__)."/proxys/".$proxy_name.".class.php"; + if (file_exists($proxy_filename)) require_once($proxy_filename); + } + if (class_exists($proxy_classname)) + { + // instanciate the proxy + $proxy =& new $proxy_classname(); + $proxy->name = $cmd_name; + $proxy->proxyname = $proxy_name; + $proxy->linkTo($firstproxy); + $firstproxy =& $proxy; + } } - // return the proxy, not the command (the proxy will forward the request to the real command) - return $proxy; + return $firstproxy; } return $cmd; } Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-06-09 11:21:03 UTC (rev 561) +++ trunk/src/pfcglobalconfig.class.php 2006-06-11 21:22:17 UTC (rev 562) @@ -37,7 +37,9 @@ var $isadmin = false; // these parameters are static (cached) - var $proxys = array("auth"); + var $proxys = array("auth", "noflood"); + var $proxys_cfg = array("auth" => array(), + "noflood" => array("limit"=>10,"delay"=>5)); 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/noflood.class.php =================================================================== --- trunk/src/proxys/noflood.class.php (rev 0) +++ trunk/src/proxys/noflood.class.php 2006-06-11 21:22:17 UTC (rev 562) @@ -0,0 +1,71 @@ +<?php +/** + * noflood.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_noflood + * this proxy will protect the chat from flooders + * @author Stephane Gully <ste...@gm...> + */ +class pfcProxyCommand_noflood extends pfcProxyCommand +{ + function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + { + $c =& $this->c; + $u =& $this->u; + + $cmdtocheck = array("send", "nick", "me", "notice"); + if ( in_array($this->name, $cmdtocheck) ) + { + $container =& $c->getContainerInstance(); + $nickid = $container->getNickId($sender); + $isadmin = $container->getMeta("isadmin", "nickname", $nickid); + $lastfloodtime = $container->getMeta("floodtime", "nickname", $nickid); + $nbflood = $container->getMeta("nbflood", "nickname", $nickid); + $floodtime = time(); + + if ($floodtime - $lastfloodtime <= $c->proxys_cfg[$this->proxyname]["delay"]) + $nbflood++; + else + $nbflood = 0; + + if ($nbflood>$c->proxys_cfg[$this->proxyname]["limit"]) + { + // kick the flooder + $msg = _pfc("you are a flooder"); + $xml_reponse->addScript("alert('".addslashes($msg)."');"); + return; + } + + if ($nbflood == 0) + $container->setMeta($floodtime, "floodtime", "nickname", $nickid); + $container->setMeta($nbflood, "nbflood", "nickname", $nickid); + } + + // 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-12 15:38:41
|
Revision: 564 Author: kerphi Date: 2006-06-12 08:38:25 -0700 (Mon, 12 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=564&view=rev Log Message: ----------- - remove useless ie7 script - fix problem with smiley box display - first step for IE6 display problems (chat area and nickname list are sometime hidden) Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php trunk/src/phpfreechat.class.php trunk/themes/default/templates/chat.js.tpl.php trunk/themes/default/templates/pfcgui.js.tpl.php trunk/themes/default/templates/style.css.tpl.php Removed Paths: ------------- trunk/lib/IE7_0_9/ Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-06-11 21:23:50 UTC (rev 563) +++ trunk/src/pfcglobalconfig.class.php 2006-06-12 15:38:25 UTC (rev 564) @@ -79,8 +79,6 @@ var $client_script_url = ""; // default is calculated from 'client_script_path' var $server_script_path = ""; var $server_script_url = ""; // default is calculated from 'server_script_path' - var $useie7 = true; // use IE7 lib : fix crappy IE display bugs - var $ie7path = ""; // default is dirname(__FILE__)."/../lib/IE7_0_9"; var $xajaxpath = ""; // default is dirname(__FILE__)."/../lib/xajax_0.2.3"; var $jspath = ""; // default is dirname(__FILE__)."/../lib/javascript"; var $usecsstidy = false; @@ -182,7 +180,6 @@ if ($this->debug) pxlog("pfcGlobalConfig::init()", "chatconfig", $this->getId()); if ($this->title == "") $this->title = _pfc("My Chat"); - if ($this->ie7path == "") $this->ie7path = dirname(__FILE__)."/../lib/IE7_0_9"; 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"; @@ -224,15 +221,6 @@ $this->errors = array_merge($this->errors, @install_file($this->xajaxpath."/xajax_js/xajax_uncompressed.js", $this->data_public_path."/xajax_js/xajax_uncompressed.js" )); // --- - // test ie7 lib - $dir = $this->ie7path; - if (!is_dir($dir)) - $this->errors[] = _pfc("%s doesn't exist, %s library can't be found", $dir, "IE7"); - if (!file_exists($dir."/ie7-core.js")) - $this->errors[] = _pfc("%s not found, %s library can't be found", "ie7-core.js", "IE7"); - $this->errors = array_merge($this->errors, @install_dir($this->ie7path, $this->data_public_path."/ie7/")); - - // --- // test client script // try to find the path into server configuration if ($this->client_script_path == "") Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-06-11 21:23:50 UTC (rev 563) +++ trunk/src/phpfreechat.class.php 2006-06-12 15:38:25 UTC (rev 564) @@ -111,17 +111,6 @@ // print xajax javascript $output .= $this->xajax->getJavascript($c->data_public_url, NULL, $c->data_public_url."/xajax_js/xajax.js"); - // include microsoft IE6 patches - if ($c->useie7) - { - $ie7_path = $c->data_public_url."/ie7"; - $output .= "<!-- compliance patch for microsoft browsers -->\n"; - $output .= "<!--[if lt IE 7]>\n"; - $output .= " <script type=\"text/javascript\">IE7_PNG_SUFFIX = \".png\";</script>\n"; - $output .= " <script type=\"text/javascript\" src=\"".$ie7_path."/ie7-standard-p.js\"></script>\n"; - $output .= " <script type=\"text/javascript\" src=\"".$ie7_path."/ie7-recalc.js\"></script>\n"; - $output .= "<![endif]-->\n"; - } pfcI18N::SwitchOutputEncoding(); // display output Modified: trunk/themes/default/templates/chat.js.tpl.php =================================================================== --- trunk/themes/default/templates/chat.js.tpl.php 2006-06-11 21:23:50 UTC (rev 563) +++ trunk/themes/default/templates/chat.js.tpl.php 2006-06-12 15:38:25 UTC (rev 564) @@ -2,28 +2,12 @@ <?php include($c->getFilePathFromTheme('templates/chat-pre.js.tpl.php')); ?> -/* preload smileys */ -preloadImages( - <?php foreach ($smileys as $s_file => $s_str) { ?> - '<?php echo $s_file; ?>', - <?php } ?> - '' -); - /* create our client which will do all the work on the client side ! */ var pfc = new pfcClient(); <?php if ($connect_at_startup) { ?> pfc.connect_disconnect(); <?php } ?> -/* -pfc.refresh_loginlogout(); -pfc.refresh_nickmarker(); -pfc.refresh_clock(); -pfc.refresh_minimize_maximize(); -pfc.refresh_Smileys(); -pfc.refresh_WhosOnline(); -*/ <?php if ($debugxajax) { ?> xajax.DebugMessage = function(text) Modified: trunk/themes/default/templates/pfcgui.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcgui.js.tpl.php 2006-06-11 21:23:50 UTC (rev 563) +++ trunk/themes/default/templates/pfcgui.js.tpl.php 2006-06-12 15:38:25 UTC (rev 564) @@ -66,7 +66,7 @@ tabcontent.style.display = 'none'; } } - + // show the new selected tab tab_to_show.style.display = 'block'; // restore the scroll pos @@ -91,8 +91,8 @@ cc = document.createElement('div'); cc.setAttribute('id', '<?php echo $prefix; ?>chat_'+tabid); Element.addClassName(cc, '<?php echo $prefix; ?>chat'); - // I set the border style here because seting it in the CSS is not taken in account - //cc.style.borderRight = "1px solid #555"; + cc.style.display = "block"; // needed by IE6 to show the online div at startup (first loaded page) + this.chatcontent[tabid] = cc; return cc; }, @@ -107,7 +107,8 @@ 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) + // Create a dummy div to add padding var div = document.createElement('div'); div.style.padding = "5px"; @@ -206,9 +207,9 @@ li_div.appendChild(a2); var div_content = document.createElement('div'); - div_content.style.display = 'none'; div_content.setAttribute('id', '<?php echo $prefix; ?>channel_content'+tabid); Element.addClassName(div_content, '<?php echo $prefix; ?>content'); + div_content.style.display = 'none'; var div_chat = this.getChatContentFromTabId(tabid); var div_online = this.getOnlineContentFromTabId(tabid); Modified: trunk/themes/default/templates/style.css.tpl.php =================================================================== --- trunk/themes/default/templates/style.css.tpl.php 2006-06-11 21:23:50 UTC (rev 563) +++ trunk/themes/default/templates/style.css.tpl.php 2006-06-12 15:38:25 UTC (rev 564) @@ -246,6 +246,7 @@ } div#<?php echo $prefix; ?>smileys { + display: none; /* will be shown by javascript routines */ background-color: #FFF; border: 1px solid #555; padding: 4px; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-15 09:45:44
|
Revision: 581 Author: kerphi Date: 2006-06-15 02:45:32 -0700 (Thu, 15 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=581&view=rev Log Message: ----------- Bug fix: add a lock process when running the /rehash command in order to avoid run simultaneously two global config init step. Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php trunk/src/pfctools.php Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-06-14 16:48:57 UTC (rev 580) +++ trunk/src/pfcglobalconfig.class.php 2006-06-15 09:45:32 UTC (rev 581) @@ -372,9 +372,14 @@ return $this->serverid; } + function _getCacheFile() + { + return $this->data_private_path."/cache/pfcglobalconfig_".$this->getId(); + } + function destroy() { - $cachefile = $this->data_private_path."/cache/pfcglobalconfig_".$this->getId(); + $cachefile = $this->_getCacheFile(); if (!file_exists($cachefile)) return false; $this->is_init = false; @@ -382,15 +387,19 @@ } /** - * save the pfcConfig object into cache if it doesn't exists yet + * Save the pfcConfig object into cache if it doesn't exists yet * else restore the old pfcConfig object */ function synchronizeWithCache() { - $cachefile = $this->data_private_path."/cache/pfcglobalconfig_".$this->getId(); - + $cachefile = $this->_getCacheFile(); + $cachefile_lock = $cachefile."_lock"; + if (file_exists($cachefile)) { + // if a cache file exists, remove the lock file because config has been succesfully stored + if (file_exists($cachefile_lock)) @unlink($cachefile_lock); + $pfc_configvar = unserialize(file_get_contents($cachefile)); foreach($pfc_configvar as $key => $val) $this->$key = $val; @@ -398,6 +407,11 @@ } else { + if (file_exists($cachefile_lock)) + return false; // do nothing if the lock file exists + else + @touch($cachefile_lock); // create the lockfile + if (!$this->isInit()) $this->init(); $errors =& $this->getErrors(); @@ -413,7 +427,7 @@ } function saveInCache() { - $cachefile = $this->data_private_path."/cache/pfcglobalconfig_".$this->getId(); + $cachefile = $this->_getCacheFile(); file_put_contents($cachefile, serialize(get_object_vars($this))); if ($this->debug) pxlog("pfcGlobalConfig::saveInCache()", "chatconfig", $this->getId()); } Modified: trunk/src/pfctools.php =================================================================== --- trunk/src/pfctools.php 2006-06-14 16:48:57 UTC (rev 580) +++ trunk/src/pfctools.php 2006-06-15 09:45:32 UTC (rev 581) @@ -132,7 +132,6 @@ * Copy a file, or recursively copy a folder and its contents * * @author Aidan Lister <ai...@ph...> - * @version 1.0.1 * @link http://aidanlister.com/repos/v/function.copyr.php * @param string $source Source path * @param string $dest Destination path @@ -143,7 +142,7 @@ // Simple copy for a file if (is_file($source)) { $ret = copy($source, $dest); - @chmod($dest, $mode); + chmod($dest, $mode); return $ret; } @@ -163,8 +162,8 @@ // Loop through the folder foreach ($entries as $e) { - // Skip pointers - if ($e == '.' || $e == '..') continue; + // Skip pointers and subversion directories + 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); @@ -283,7 +282,6 @@ * @package PHP_Compat * @link http://php.net/function.file_put_contents * @author Aidan Lister <ai...@ph...> - * @version $Revision: 1.25 $ * @internal resource_context is not supported * @since PHP 5 * @require PHP 4.0.0 (user_error) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-15 11:50:19
|
Revision: 583 Author: kerphi Date: 2006-06-15 04:50:12 -0700 (Thu, 15 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=583&view=rev Log Message: ----------- Bug fix: the /rehash command was not correctly fixed because the themepath was altered into the pfcglobalconfig init step. Modified Paths: -------------- trunk/src/commands/rehash.class.php trunk/src/pfcglobalconfig.class.php Modified: trunk/src/commands/rehash.class.php =================================================================== --- trunk/src/commands/rehash.class.php 2006-06-15 10:09:09 UTC (rev 582) +++ trunk/src/commands/rehash.class.php 2006-06-15 11:50:12 UTC (rev 583) @@ -14,7 +14,7 @@ function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) { $c =& $this->c; - $destroyed = $c->destroy(); + $destroyed = $c->destroyCache(); $synchro = $c->synchronizeWithCache(); if ($destroyed && $synchro) Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-06-15 10:09:09 UTC (rev 582) +++ trunk/src/pfcglobalconfig.class.php 2006-06-15 11:50:12 UTC (rev 583) @@ -263,9 +263,6 @@ // copy the themes into the public directory $this->errors = array_merge($this->errors, @install_dir($this->themepath_default, $this->data_public_path."/themes")); $this->errors = array_merge($this->errors, @install_dir($this->themepath, $this->data_public_path."/themes")); - // now it's copied, so update the themepath parameters to the new location - $this->themepath_default = $this->data_public_path."/themes"; - $this->themepath = $this->data_public_path."/themes"; // calculate the corresponding theme url if ($this->themeurl_default == "") $this->themeurl_default = relativePath($this->client_script_path, $this->data_public_path."/themes"); @@ -377,7 +374,7 @@ return $this->data_private_path."/cache/pfcglobalconfig_".$this->getId(); } - function destroy() + function destroyCache() { $cachefile = $this->_getCacheFile(); if (!file_exists($cachefile)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-15 12:10:33
|
Revision: 585 Author: kerphi Date: 2006-06-15 05:10:24 -0700 (Thu, 15 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=585&view=rev Log Message: ----------- Refactoring: rename sessionid user parameter to a more explicit nickid Modified Paths: -------------- trunk/src/commands/nick.class.php trunk/src/pfcglobalconfig.class.php trunk/src/pfcuserconfig.class.php Modified: trunk/src/commands/nick.class.php =================================================================== --- trunk/src/commands/nick.class.php 2006-06-15 11:56:43 UTC (rev 584) +++ trunk/src/commands/nick.class.php 2006-06-15 12:10:24 UTC (rev 585) @@ -51,7 +51,7 @@ // current nickname (oldnick) is mine and // oldnick is different from new nick // -> this is a nickname change - if ($oldnickid == $u->sessionid && + if ($oldnickid == $u->nickid && $oldnick != $newnick && $oldnick != "") { // really change the nick (rename it) @@ -75,14 +75,14 @@ // new nickname is undefined (not used) and // current nickname (oldnick) is not mine or is undefined // -> this is a first connection - if ($oldnickid != $u->sessionid) + if ($oldnickid != $u->nickid) { // this is a first connection (create the nickname) - $container->createNick(NULL, $newnick, $u->sessionid); + $container->createNick(NULL, $newnick, $u->nickid); foreach($u->channels as $chan) - $container->createNick($chan["recipient"], $newnick, $u->sessionid); + $container->createNick($chan["recipient"], $newnick, $u->nickid); foreach($u->privmsg as $pv) - $container->createNick($pv["recipient"], $newnick, $u->sessionid); + $container->createNick($pv["recipient"], $newnick, $u->nickid); $u->nick = $newnick; $u->active = true; $u->saveInCache(); @@ -108,7 +108,7 @@ //$xml_reponse->addScript("$('".$c->prefix."words').focus();"); } - else if ($newnickid == $u->sessionid) + else if ($newnickid == $u->nickid) { // user didn't change his nickname //$xml_reponse->addAssign($c->prefix."handle", "value", $newnick); Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-06-15 11:56:43 UTC (rev 584) +++ trunk/src/pfcglobalconfig.class.php 2006-06-15 12:10:24 UTC (rev 585) @@ -90,18 +90,14 @@ var $smileys = array(); var $errors = array(); var $prefix = "pfc_"; - // var $active = false; // used internaly var $is_init = false; // used internaly to know if the chat config is initialized var $version = ""; // the phpfreechat version: taken from the 'version' file content - // var $sessionid = 0; // the client sessionid, this is automatically set by phpfreechat instance var $debugurl = ""; var $debug = false; var $debugxajax = false; function pfcGlobalConfig( $params = array() ) { - // $params["sessionid"] = session_id(); - // setup the local for translated messages pfcI18N::Init(isset($params["language"]) ? $params["language"] : ""); Modified: trunk/src/pfcuserconfig.class.php =================================================================== --- trunk/src/pfcuserconfig.class.php 2006-06-15 11:56:43 UTC (rev 584) +++ trunk/src/pfcuserconfig.class.php 2006-06-15 12:10:24 UTC (rev 585) @@ -10,7 +10,7 @@ var $active; var $timeout; - var $sessionid; + var $nickid; // var $is_init = false; // used internaly to know if the chat config is initialized // var $errors = array(); @@ -25,7 +25,7 @@ // echo "pfcUserConfig()<br>"; - $this->sessionid = session_id(); + $this->nickid = session_id(); // user parameters are cached in sessions $this->_getParam("nick"); @@ -43,10 +43,10 @@ if (!isset($this->$p)) { $c =& pfcGlobalConfig::Instance(); - $sessionid = "pfcuserconfig_".$c->getId(); - $sessionid_param = $sessionid."_".$p; - if (isset($_SESSION[$sessionid_param])) - $this->$p = $_SESSION[$sessionid_param]; + $nickid = "pfcuserconfig_".$c->getId(); + $nickid_param = $nickid."_".$p; + if (isset($_SESSION[$nickid_param])) + $this->$p = $_SESSION[$nickid_param]; } return $this->$p; } @@ -54,18 +54,18 @@ function _setParam($p, $v) { $c =& pfcGlobalConfig::Instance(); - $sessionid = "pfcuserconfig_".$c->getId(); - $sessionid_param = $sessionid."_".$p; - $_SESSION[$sessionid_param] = $v; + $nickid = "pfcuserconfig_".$c->getId(); + $nickid_param = $nickid."_".$p; + $_SESSION[$nickid_param] = $v; $this->$p = $v; } function _rmParam($p) { $c =& pfcGlobalConfig::Instance(); - $sessionid = "pfcuserconfig_".$c->getId(); - $sessionid_param = $sessionid."_".$p; - unset($_SESSION[$sessionid_param]); + $nickid = "pfcuserconfig_".$c->getId(); + $nickid_param = $nickid."_".$p; + unset($_SESSION[$nickid_param]); unset($this->$p); } @@ -182,11 +182,11 @@ /* // save nickname and active status into sessions - $sessionid = $c->prefix."pfcuserconfig_".$c->getId(); - $sessionid_nick = $sessionid."_nick"; - $sessionid_active = $sessionid."_active"; - $_SESSION[$sessionid_nick] = $this->nick; - $_SESSION[$sessionid_active] = $this->active; + $nickid = $c->prefix."pfcuserconfig_".$c->getId(); + $nickid_nick = $nickid."_nick"; + $nickid_active = $nickid."_active"; + $_SESSION[$nickid_nick] = $this->nick; + $_SESSION[$nickid_active] = $this->active; */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |