Thread: [Phpfreechat-svn] SF.net SVN: phpfreechat: [463] trunk
Status: Beta
Brought to you by:
kerphi
From: <ne...@us...> - 2006-04-24 14:01:33
|
Revision: 463 Author: nemako Date: 2006-04-24 07:01:11 -0700 (Mon, 24 Apr 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=463&view=rev Log Message: ----------- Add pfc website templates for index.php and demo/index.php Modified Paths: -------------- trunk/demo/index.php trunk/index.php Added Paths: ----------- trunk/style/ trunk/style/bulle.png trunk/style/check_off.png trunk/style/check_on.png trunk/style/content.css trunk/style/footer.css trunk/style/generic.css trunk/style/header.css trunk/style/logo_88x31.gif trunk/style/menu.css trunk/style/show.js trunk/style/valid-css.png trunk/style/valid-xhtml.png Modified: trunk/demo/index.php =================================================================== --- trunk/demo/index.php 2006-04-20 20:26:36 UTC (rev 462) +++ trunk/demo/index.php 2006-04-24 14:01:11 UTC (rev 463) @@ -1,12 +1,53 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> + <head> + <meta http-equiv="content-type" content="text/html; charset=utf-8"> + <title>phpFreeChat Demos</title> + <link rel="stylesheet" title="classic" type="text/css" href="../style/generic.css"> + <link rel="stylesheet" title="classic" type="text/css" href="../style/header.css"> + <link rel="stylesheet" title="classic" type="text/css" href="../style/footer.css"> + <link rel="stylesheet" title="classic" type="text/css" href="../style/menu.css"> + <link rel="stylesheet" title="classic" type="text/css" href="../style/content.css"> + </head> + <body> + +<div class="header"> + <h1>phpFreeChat - Demos</h1> + <img alt="logo bulle" src="../style/bulle.png" class="logo2"> +</div> + +<div class="menu"> + <ul> + <li class="sub title">General</li> + <li> + <ul class="sub"> + <li class="item"> + <a href="../index.php">PFC Index</a> + </li> + </ul> + </li> + <li class="sub title">Demos</li> + <li> + <ul class="sub"> + <li class="item"> + <a href="#Miscellaneous">Miscellaneous</a> + </li> + <li class="item"> + <a href="#Themes">Themes</a> + </li> + <li class="item"> + <a href="#Translations">Translations</a> + </li> + </ul> + </li> + </ul> + <p class="partner"> + <a href="http://www.phpfreechat.net"><img alt="logo big" src="../style/logo_88x31.gif"></a> + </p> +</div> + +<div class="content"> - <head> - <meta http-equiv="content-type" content="text/html; charset=utf-8" /> - <title>phpFreeChat demos</title> - </head> - - <body> <h2>Miscellaneous</h2> <ul> @@ -68,6 +109,18 @@ <li><a href="demo41_in_greek.php">demo41 - the greek translation of the chat</a></li> <li><a href="demo42_in_chinese_from_taiwan.php">demo42 - the Chinese from taiwan (traditional Chinese) translation of the chat</a></li> </ul> - </body> - -</html> + +</div> + +<div class="footer"> + <div class="valid"> + <a href="http://validator.w3.org/check?uri=referer"> + <img alt="Valid XHTML 1.0!" src="../style/valid-xhtml.png"> + </a> + <a href="http://jigsaw.w3.org/css-validator/check/referer"> + <img alt="Valid CSS!" src="../style/valid-css.png"> + </a> + </div> + <p>\xA92006 phpFreeChat</p> + </div> +</body></html> \ No newline at end of file Modified: trunk/index.php =================================================================== --- trunk/index.php 2006-04-20 20:26:36 UTC (rev 462) +++ trunk/index.php 2006-04-24 14:01:11 UTC (rev 463) @@ -7,29 +7,77 @@ $chat = new phpFreeChat( $params ); ?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" - "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> - <head> - <meta http-equiv="content-type" content="text/html; charset=utf-8" /> - <title>phpFreeChat sources index</title> - <?php $chat->printJavascript(); ?> - <?php $chat->printStyle(); ?> - </head> - - <body> - <ul> - <li><a href="demo/">Demos</a></li> - <li><a href="README.en">Documentation - readme [en]</a></li> - <li><a href="README.fr">Documentation - readme [fr]</a></li> - <li><a href="INSTALL.en">Documentation - install [en]</a></li> - <li><a href="INSTALL.fr">Documentation - install [fr]</a></li> - </ul> - - <p>See the quick demo :</p> - <?php $chat->printChat(); ?> - - </body> - -</html> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html> + <head> + <meta http-equiv="content-type" content="text/html; charset=utf-8"> + <title>phpFreeChat Sources Index</title> + <link rel="stylesheet" title="classic" type="text/css" href="style/generic.css"> + <link rel="stylesheet" title="classic" type="text/css" href="style/header.css"> + <link rel="stylesheet" title="classic" type="text/css" href="style/footer.css"> + <link rel="stylesheet" title="classic" type="text/css" href="style/menu.css"> + <link rel="stylesheet" title="classic" type="text/css" href="style/content.css"> + <?php $chat->printJavascript(); ?> + <?php $chat->printStyle(); ?> + </head> + <body> + +<div class="header"> + <h1>phpFreeChat - Sources Index</h1> + <img alt="logo bulle" src="style/bulle.png" class="logo2"> +</div> + +<div class="menu"> + <ul> + <li class="sub title">General</li> + <li> + <ul class="sub"> + <li class="item"> + <a href="demo/">Demos</a> + </li> + <li class="item"> + <a href="admin/">Administration</a> + </li> + </ul> + </li> + <li class="sub title">Documentation</li> + <li> + <ul> + <li class="item"> + <a href="README.en">readme [en]</a> + </li> + <li class="item"> + <a href="README.fr">readme [fr]</a> + </li> + <li class="item"> + <a href="INSTALL.en">install [en]</a> + </li> + <li class="item"> + <a href="INSTALL.fr">install [fr]</a> + </li> + </ul> + </li> + </ul> + <p class="partner"> + <a href="http://www.phpfreechat.net"><img alt="logo big" src="style/logo_88x31.gif"></a> + </p> +</div> + +<div class="content"> + <h2>See the quick demo</h2> + <?php $chat->printChat(); ?> +</div> + +<div class="footer"> + <div class="valid"> + <a href="http://validator.w3.org/check?uri=referer"> + <img alt="Valid XHTML 1.0!" src="style/valid-xhtml.png"> + </a> + <a href="http://jigsaw.w3.org/css-validator/check/referer"> + <img alt="Valid CSS!" src="style/valid-css.png"> + </a> + </div> + <p>\xA92006 phpFreeChat</p> + </div> +</body></html> \ No newline at end of file Added: trunk/style/bulle.png =================================================================== (Binary files differ) Property changes on: trunk/style/bulle.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/style/check_off.png =================================================================== (Binary files differ) Property changes on: trunk/style/check_off.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/style/check_on.png =================================================================== (Binary files differ) Property changes on: trunk/style/check_on.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/style/content.css =================================================================== --- trunk/style/content.css (rev 0) +++ trunk/style/content.css 2006-04-24 14:01:11 UTC (rev 463) @@ -0,0 +1,22 @@ +/* --- CONTENT --- */ +div.content { + margin: 0.5em; + padding: 1em; + margin-left: 12.2em; + background-color: #FFF; + border: 1px #acd233 solid; + min-height: 40em; +} +div.content * { margin-top: 0.5em; margin-bottom: 0.5em; } +div.content h2 { border-bottom: 1px #444 solid; } +div.content h3 { text-decoration: underline; font-size: 100%; margin: 1em 0 1em 0; } +div.content a:link, div.content a:visited, div.content a:hover, div.content a:visited{ color: #0081ac; } +div.content code { background-color: #EFE; border: 1px #444 dotted; } +div.content pre { padding: 1em; background-color: #EFE; border: 1px #444 dotted; } +div.content ul { margin-left: 3em; } +div.content ol { margin-left: 3em; } +div.content dd { margin-left: 3em; } +div.content dt { font-weight: bold; margin: 2em 0 2em 0; } +div.content .abstract { border: 2px #999 solid; background-color: #EEE; padding: 1em; color: #000; text-align: justify; } + + Added: trunk/style/footer.css =================================================================== --- trunk/style/footer.css (rev 0) +++ trunk/style/footer.css 2006-04-24 14:01:11 UTC (rev 463) @@ -0,0 +1,21 @@ +/* --- FOOTER --- */ +div.footer { + position: relative; + text-align: center; + background-color: #99cc33; + color: #FFF; + border-top: 1px #acd233 solid; + border-bottom: 1px #acd233 solid; + font-size: 80%; + clear: both; + padding-left: 12em; +} +div.footer div.valid { + display: inline; + float: right; +} +div.footer div.rss { + position: absolute; + left: 5px; + float: left; +} Added: trunk/style/generic.css =================================================================== --- trunk/style/generic.css (rev 0) +++ trunk/style/generic.css 2006-04-24 14:01:11 UTC (rev 463) @@ -0,0 +1,20 @@ +/* --- GENERIC --- */ +* { padding: 0; margin: 0; } +a img { border: none; } +body { + color: #000000; + background: #339933; + font-family: Verdana, Sans-Serif; + font-size: 100%; + padding: 0; + margin: 0; +} + +a:link, a:visited, a:hover { + font-weight: bold; + text-decoration: none; +} +a:hover { + text-decoration: underline; +} +.nospace { word-spacing: -0.35em; } Added: trunk/style/header.css =================================================================== --- trunk/style/header.css (rev 0) +++ trunk/style/header.css 2006-04-24 14:01:11 UTC (rev 463) @@ -0,0 +1,23 @@ +/* --- HEADER --- */ +div.header { + position: relative; + display: block; + background-color: #99cc33; + border-bottom: 1px #acd233 solid; + height: 45px; +} +div.header h1 { + color: #FFF; + text-align: center; +} +div.header .logo2 { + position: absolute; + bottom: 0; + right: 0; +} +div.header .flags { + position: absolute; + bottom: 2px; + left: 0px; +} +div.header .flags a { margin-left: 0.5em; } Added: trunk/style/logo_88x31.gif =================================================================== (Binary files differ) Property changes on: trunk/style/logo_88x31.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/style/menu.css =================================================================== --- trunk/style/menu.css (rev 0) +++ trunk/style/menu.css 2006-04-24 14:01:11 UTC (rev 463) @@ -0,0 +1,63 @@ +/* --- MENU --- */ +div.menu { + position: absolute; + top: 55px; + left: 0.5em; +/* float: left; + margin-top: 0.5em; + margin-left: 0.4em;*/ + color: #FFF; + width: 11em; + text-align: center; +} +div.menu * { font-size: 95%; } +div.menu ul { + background-color: #99cc33; + border: 1px #acd233 solid; + text-align: left; + list-style: none; +} +div.menu li { + display: inline; +} +div.menu img { margin-top: 10px; } +div.menu .title { + padding: 4px; + text-align: center; + color: #888; + background-color: #FFF; +} +div.menu li.sub { + font-weight: bold; + padding: 0; + margin: 0; + display: block; +} +div.menu li a { + display: block; + margin: 0px; + padding: 4px; + padding-left: 10px; + width: auto; +} +div.menu li.item { + display: inline; +} +div.menu a:link, div.menu a:visited, div.menu a:hover { color: #FFF; } +div.menu a:visited { color: #FFF; } +div.menu li.item a:hover, div.menu ul.sub li.item a:hover { + display: block; + background-color: #acd233; + text-decoration: none; +} + +div.menu .partner { + margin-top: 5px; +} +div.menu div.rating { + margin-top: 10px; +} +div.menu div.rating table, div.menu div.rating table td { + text-align: center; + margin: auto; +} Added: trunk/style/show.js =================================================================== --- trunk/style/show.js (rev 0) +++ trunk/style/show.js 2006-04-24 14:01:11 UTC (rev 463) @@ -0,0 +1,34 @@ +function getE(id) +{ + if(document.getElementById) { + return document.getElementById(id); + } else if(document.all) { + return document.all[id]; + } else return; +} + +function openClose(id,mode) +{ + element = getE(id); + img = getE('img_'+id); + + if(element.style) { + if(mode == 0) { + if(element.style.display == 'block' ) { + element.style.display = 'none'; + img.src = 'pics/plus.gif'; + } else { + element.style.display = 'block'; + img.src = 'pics/moins.gif'; + } + } else if(mode == 1) { + element.style.display = 'block'; + img.src = 'pics/moins.gif'; + } else if(mode == -1) { + element.style.display = 'none'; + img.src = 'pics/plus.gif'; + } + } +} + + Added: trunk/style/valid-css.png =================================================================== (Binary files differ) Property changes on: trunk/style/valid-css.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/style/valid-xhtml.png =================================================================== (Binary files differ) Property changes on: trunk/style/valid-xhtml.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ne...@us...> - 2006-04-24 14:40:37
|
Revision: 464 Author: nemako Date: 2006-04-24 07:40:06 -0700 (Mon, 24 Apr 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=464&view=rev Log Message: ----------- Add the administration interface + admin folder with users access, version and themes management + change in src/pfci18n.class.php to support the admin parameter + add admin.php files in the i18n folder for en_US and fr_FR + add info.php description file in themes folder Modified Paths: -------------- trunk/src/pfci18n.class.php Added Paths: ----------- trunk/admin/ trunk/admin/configuration.php trunk/admin/htaccess.class.php trunk/admin/inc.conf.php trunk/admin/index.php trunk/admin/index_html_bottom.php trunk/admin/index_html_top.php trunk/admin/style/ trunk/admin/style/bulle.png trunk/admin/style/check_off.png trunk/admin/style/check_on.png trunk/admin/style/content.css trunk/admin/style/footer.css trunk/admin/style/generic.css trunk/admin/style/header.css trunk/admin/style/logo_88x31.gif trunk/admin/style/menu.css trunk/admin/style/show.js trunk/admin/style/valid-css.png trunk/admin/style/valid-xhtml.png trunk/admin/themes.class.php trunk/admin/themes.php trunk/admin/themes_avant.php trunk/admin/user.php trunk/admin/version.class.php trunk/i18n/en_US/admin.php trunk/i18n/fr_FR/admin.php trunk/themes/blune/info.php trunk/themes/cerutti/info.php trunk/themes/default/info.php Added: trunk/admin/configuration.php =================================================================== --- trunk/admin/configuration.php (rev 0) +++ trunk/admin/configuration.php 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,14 @@ +<? +// TOP // +include("index_html_top.php"); +?> + +<div class="content"> + <h2>Configuration</h2> + +</div> + +<? +// BOTTOM +include("index_html_bottom.php"); +?> \ No newline at end of file Added: trunk/admin/htaccess.class.php =================================================================== --- trunk/admin/htaccess.class.php (rev 0) +++ trunk/admin/htaccess.class.php 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,556 @@ +<? + +/** +* Class to manage .htaccess file of Apache +* @author Fred Delaunay <fr...@ne...> +*/ + +class htaccess{ + var $authType; // authentification type + var $authName; // authentification name + + var $admin_files; // array of files limited to the administrators + var $modo_files; // array of files limited to the moderators + + var $file_Htpasswd; // .htpasswd file (AuthUserFile) + var $file_Htgroup; // .htgroup file (AuthGroupFile) + var $file_Htaccess; // .htaccess file + + + + function htaccess(){ + $this->authType = "Basic"; + $this->authName = "PhpFreeChat Admin Zone"; + + $this->admin_files = array("admin.php", "admin2.php"); + $this->modo_files = array("mod.php", "mod2.php"); + + + $this->file_Htpasswd = dirname(__FILE__)."/.htpasswd"; + if(!file_exists($this->file_Htpasswd)) + touch($this->file_Htpasswd); + $this->file_Htgroup = dirname(__FILE__)."/.htgroup"; + if(!file_exists($this->file_Htgroup)) { + touch($this->file_Htgroup); + $this->addGroup("admin"); + $this->addGroup("modo"); + } + $this->file_Htaccess = dirname(__FILE__)."/.htaccess"; + + } + + /***************************************/ + /* SET AND GET */ + /***************************************/ + + /** + * Set the AuthType + * @param string $authtype - AuthType is Basic or Digest (crypted) + */ + function setAuthType($authtype){ + $this->authType=$authtype; + } + /** + * Get the AuthType + * @return string $authtype - AuthType is Basic or Digest (crypted) + */ + function getAuthType(){ + return $this->authType; + } + + /** + * Set the AuthName message + * @param string $authname - AuthName message is the text display in the dialog box + */ + function setAuthName($authname){ + $this->authName=$authname; + } + /** + * Get the AuthName message + * @return string $authname - AuthName message is the text display in the dialog box + */ + function getAuthName(){ + return $this->authName; + } + + /** + * Set the .htaccess file + * @param string $filename - absolute file-path + */ + function set_file_Htaccess($filename){ + $this->file_Htaccess=$filename; + } + /** + * Get the .htaccess file + * @return string $filename - absolute file-path + */ + function get_file_Htaccess(){ + return $this->file_Htaccess; + } + + /** + * Set the .htpasswd file (AuthUserFile) + * @param string $filename - absolute file-path + */ + function set_file_Htpasswd($filename){ + $this->file_Htpasswd=$filename; + } + /** + * Get the .htpasswd file (AuthUserFile) + * @return string $filename - absolute file-path + */ + function get_file_Htpasswd(){ + return $this->file_Htpasswd; + } + + /** + * Set the .htgroup file (AuthGroupFile) + * @param string $filename - absolute file-path + */ + function set_file_Htgroup($filename){ + $this->file_Htgroup=$filename; + } + /** + * Get the .htgroup file (AuthGroupFile) + * @return string $filename - absolute file-path + */ + function get_file_Htgroup(){ + return $this->file_Htgroup; + } + + + /***************************************/ + /* USER METHODS */ + /***************************************/ + + + /** + * Check if the user exists + * @param string $username - Username + * @return boolean $UserExist - Returns true it the user exists, false if not + */ + function isUser($username){ + $UserExist = false; + $file = fopen($this->file_Htpasswd,"r"); + + while($line = fgets($file)){ + $lineArr=explode(":",$line); + if($username==$lineArr[0]){ + fclose($file); + return true; // the user exists + } + } + fclose($file); + + return false; // the user does not exist + } + + /** + * Add a user to the password file + * @param string $username - Username + * @param string $password - Password for Username + * @return boolean $created - Returns true if ok, false if the user already exists + */ + function addUser($username,$password){ + + if($this->isUser($username)==false){ + $file=fopen($this->file_Htpasswd,"a"); + if(strtolower(substr(getenv("OS"),0,7))!="windows"){ + $password=crypt($password); + } + $newLine=$username.":".$password."\n"; + fputs($file,$newLine); + fclose($file); + return true; + } + else{ + return false; // the user already exists + } + } + + + /** + * Delete a user in the password file + * @param string $username - Username to delete + * @return boolean $deleted - Returns true if user have been deleted otherwise false + */ + function delUser($username){ + // Read names from file + $file=fopen($this->file_Htpasswd,"r"); + $i=0; + $deleted = false; + while($line=fgets($file)){ + $lineArr=explode(":",trim($line)); + if($username!=$lineArr[0]){ + $newUserlist[$i][0]=$lineArr[0]; + $newUserlist[$i][1]=$lineArr[1]; + $i++; + }else{ + $deleted=true; + } + } + fclose($file); + + if($deleted==true){ + if($i==0) { // There are no more users + unlink($this->file_Htpasswd); + touch($this->file_Htpasswd); + } + else{ // Writing names back to file (without the user to delete) + $file=fopen($this->file_Htpasswd,"w"); + for($i=0;$i<count($newUserlist);$i++){ + fputs($file,$newUserlist[$i][0].":".$newUserlist[$i][1]."\n"); + } + fclose($file); + } + return true; + } + else{ + return false; + } + } + + /** + * Return an array of all users + * @return array $users - 0 if the are no user + */ + function getUsers() { + $file=fopen($this->file_Htpasswd,"r"); + for($i=0;$line=fgets($file);$i++) { + $lineArr=explode(":",$line); + if($lineArr[0]!="") { + $userlist[$i]=$lineArr[0]; + } + } + fclose($file); + if (!empty($userlist)==0) + return 0; + else + return $userlist; + } + + /** + * Return the number of users + * @return integer - the number of users + */ + function getNumberOfUsers() { + $users=$this->getUsers(); + if($users==0) + return 0; + else + return count($users); + } + + /** + * Sets a password to the given username + * @param string $username - The name of the User for changing password + * @param string $password - New Password for the User + * @return boolean $isSet - Returns true if password have been set + */ + function setPasswd($username,$new_password){ + if($this->isUser($username)==true){ + $this->delUser($username); + $this->addUser($username,$new_password); + return true; + } + else{ + return false; + } + } + + + /***************************************/ + /* GROUP METHODS */ + /***************************************/ + + /** + * Check if the group exists + * @param string $groupname - Groupname + * @return boolean $GroupExist - Returns true it the group exists, false otherwise + */ + function isGroup($groupname){ + $GroupExist = false; + $file = fopen($this->file_Htgroup,"r"); + + while($line = fgets($file)){ + $lineArr=explode(":",trim($line)); + if($groupname==trim($lineArr[0])){ + fclose($file); + return true; // the group exists + } + } + fclose($file); + + return false; // the group does not exist + } + + /** + * Add a group to the group file + * @param string $groupname - Groupname + * @return boolean $created - Returns false if the group already exists + */ + function addGroup($groupname){ + + if($this->isGroup($groupname)==false){ + $file=fopen($this->file_Htgroup,"a"); + $newLine=$groupname.": "."\n"; // Take care, it should not have a space before : + fputs($file,$newLine); + fclose($file); + return true; + } + else{ + return false; // the group already exists + } + } + + + /** + * Delete a group in the group file + * @param string $groupname - Groupname to delete + * @return boolean $deleted - Returns true if group have been deleted otherwise false + */ + function delGroup($groupname){ + // Read names from file + $file=fopen($this->file_Htgroup,"r"); + $i=0; + $newGrouplist=0; + while($line=fgets($file)){ + $lineArr=explode(":",trim($line)); + if($groupname!=trim($lineArr[0])){ + $newGrouplist[$i]=trim($line); + $i++; + }else{ + $deleted=true; + } + } + fclose($file); + + if($deleted==true){ + if($i==0) { // There are no more users + unlink($this->file_Htpasswd); + touch($this->file_Htpasswd); + } + else{ // Writing names back to file (without the user to delete) + $file=fopen($this->file_Htgroup,"w"); + for($i=0;$i<count($newGrouplist);$i++){ + fputs($file,$newGrouplist[$i]."\n"); + } + fclose($file); + } + return true; + } + else{ + return false; + } + } + + /** + * Return an array of all groups + * @return array $groups + */ + function getGroups() { + $file=fopen($this->file_Htgroup,"r"); + for($i=0;$line=fgets($file);$i++) { + $lineArr=explode(":",trim($line)); + if($lineArr[0]!="") { + $grouplist[$i]=trim($lineArr[0]); + } + } + fclose($file); + if (!empty($grouplist)==0) + return 0; + else + return $grouplist; + } + + /***************************************/ + /* USER AND GROUP METHODs */ + /***************************************/ + + /** + * Check if the user is in the group + * @param string $username - Username + * @param string $groupname - Groupname + * @return boolean $exist - Returns true it the user is in the group + */ + function isUserInGroup($username,$groupname){ + $file = fopen($this->file_Htgroup,"r"); + + while($line = fgets($file)){ + $lineArr=explode(":",trim($line)); + if($groupname==trim($lineArr[0])){ + + $lineArrUser=explode(" ",trim($lineArr[1])); + for($i=0;$i<count($lineArrUser);$i++){ + if(trim($lineArrUser[$i])==$username) + fclose($file); + return true; // the user is in the group + } + + } + } + fclose($file); + + return false; // the user in not in the group + } + + /** + * Add a user to the group file + * @param string $username - Username + * @param string $groupname - Groupname + * @return boolean $created - Returns false if the user is already in the group + */ + function addUserInGroup($username,$groupname){ + + if($this->isGroup($groupname)==false){ + $this->addGroup($groupname); + } + + if($this->isUserInGroup($username,$groupname)==false){ + // Read names from file + $file = fopen($this->file_Htgroup,"r"); + $i=0; + while($line = fgets($file)){ + $lineArr=explode(":",trim($line)); + if($groupname==trim($lineArr[0])){ + $newlist[$i]=trim($line)." ".$username; + } + else{ + $newlist[$i]=trim($line); + } + $i++; + } + fclose($file); + + + // Writing names back to file (without the user to delete) + $file=fopen($this->file_Htgroup,"w"); + for($i=0;$i<count($newlist);$i++){ + fputs($file,$newlist[$i]."\n"); + } + fclose($file); + return true; + } + else{ + return false; // the user is already in the group + } + } + + /** + * Delete a user from the group file + * @param string $username - Username + * @param string $groupname - Groupname + * @return boolean $created - Returns false if the user was not in the group + */ + function delUserFromGroup($username,$groupname){ + + if($this->isUserInGroup($username,$groupname)==true){ + + // Read names from file + $file = fopen($this->file_Htgroup,"r"); + $i=0; + while($line = fgets($file)){ + $lineArr=explode(":",trim($line)); + if($groupname==trim($lineArr[0])){ + + $lineArrUser=explode(" ",trim($lineArr[1])); + $newlist[$i]=$groupname." : "; + + for($j=0;$j<count($lineArrUser);$j++){ + if(trim($lineArrUser[$j])!=$username) + $newlist[$i].=$lineArrUser[$j]." "; + } + + } + else{ + $newlist[$i]=trim($line); + + } + $i++; + } + fclose($file); + + + // Writing names back to file (without the user to delete) + $file=fopen($this->file_Htgroup,"w"); + for($i=0;$i<count($newlist);$i++){ + fputs($file,$newlist[$i]."\n"); + } + fclose($file); + return true; + + } + else{ + return false; // the user is not in the group + } + } + + /** + * Return an array of groups from which the user belongs to + * -- Normaly, user belongs to only one group -- + * @return array $groups or 0 if the user is in none of the groups + */ + function getGroupOfUser($username) { + $file=fopen($this->file_Htgroup,"r"); + $i=0; + //$grouplist=0; + while($line = fgets($file)){ + $lineArr=explode(":",trim($line)); + $lineArrUser=explode(" ",trim($lineArr[1])); + + for($j=0;$j<count($lineArrUser);$j++){ + if(trim($lineArrUser[$j])==$username){ + $grouplist[$i]=trim($lineArr[0]); + $i++; + } + } + } + fclose($file); + if(empty($grouplist)) + return 0; + else + return $grouplist; + } + + /***************************************/ + /* WRITE the .htaccess file */ + /***************************************/ + + + + /** + * Writes the .htaccess file + */ + function printHtaccess(){ + $file=fopen($this->file_Htaccess,"w+"); + fputs($file,"AuthName \"".$this->authName."\"\n"); + fputs($file,"AuthType ".$this->authType."\n"); + fputs($file,"AuthUserFile \"".$this->file_Htpasswd."\"\n"); + fputs($file,"AuthGroupFile \"".$this->file_Htgroup."\"\n\n"); + + fputs($file,"\nrequire valid-user\n"); + + for($i=0;$i<count($this->admin_files);$i++){ + fputs($file,"\n<Files ".$this->admin_files[$i].">\n"); + fputs($file," require group admin\n"); + fputs($file,"</Files>\n"); + } + + for($i=0;$i<count($this->modo_files);$i++){ + fputs($file,"\n<Files ".$this->modo_files[$i].">\n"); + fputs($file," require group modo\n"); + fputs($file,"</Files>\n"); + } + + fclose($file); + } + + /** + * Deletes the protection of the given directory + */ + function delHtaccess(){ + unlink($this->file_Htaccess); + } + +} +?> \ No newline at end of file Added: trunk/admin/inc.conf.php =================================================================== --- trunk/admin/inc.conf.php (rev 0) +++ trunk/admin/inc.conf.php 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,4 @@ +<? +//$lang = "en_US"; +$lang = "fr_FR"; +?> \ No newline at end of file Added: trunk/admin/index.php =================================================================== --- trunk/admin/index.php (rev 0) +++ trunk/admin/index.php 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,61 @@ +<? +# lang +require_once("../src/pfci18n.class.php"); +require_once("inc.conf.php"); +pfcI18N::Init($lang,"admin"); + + +# version class +require_once("version.class.php"); +$version = new version(); +?> + +<? +// TOP // +include("index_html_top.php"); +?> + +<div class="content"> + <h2><? echo _pfc("Administration"); ?></h2> + +<? +if ($version->getPFCOfficialCurrentVersion()==0){ +?> + <div><h3><? echo _pfc("Internet connection is not possible"); ?></h3> + <ul> + <li><? echo _pfc("PFC version"); ?> : <? echo $version->getLocalVersion(); ?></li> + </ul> + </div> + +<? +} +elseif (($version->getLocalVersion())==($version->getPFCOfficialCurrentVersion())){ +?> + + <div class="ok"><h3><img src="style/check_on.png" alt="<? echo _pfc("PFC is update"); ?>"> <? echo _pfc("PFC is update"); ?></h3> + <ul> + <li><? echo _pfc("PFC version"); ?> : <? echo $version->getLocalVersion(); ?></li> + </ul> + </div> + +<? +} +else{ +?> + <div class="ko"><h3><img src="style/check_off.png" alt="<? echo _pfc("PFC is not update"); ?>"> <? echo _pfc("PFC is not update"); ?></h3> + <ul> + <li><? echo _pfc("Your version"); ?> : <? echo $version->getLocalVersion(); ?></li> + <li><? echo _pfc("The last official version"); ?> : <? echo $version->getPFCOfficialCurrentVersion(); ?></li> + <li><? echo _pfc("Download the last version %s here %s.","<a href=\"http://sourceforge.net/project/showfiles.php?group_id=158880\">","</a>"); ?></li> + </ul> + </div> + +<? +} +?> +</div> + +<? +// BOTTOM +include("index_html_bottom.php"); +?> \ No newline at end of file Added: trunk/admin/index_html_bottom.php =================================================================== --- trunk/admin/index_html_bottom.php (rev 0) +++ trunk/admin/index_html_bottom.php 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,13 @@ + +<div class="footer"> + <div class="valid"> + <a href="http://validator.w3.org/check?uri=referer"> + <img alt="Valid XHTML 1.0!" src="style/valid-xhtml.png"> + </a> + <a href="http://jigsaw.w3.org/css-validator/check/referer"> + <img alt="Valid CSS!" src="style/valid-css.png"> + </a> + </div> + <p>\xA92006 phpFreeChat</p> + </div> +</body></html> \ No newline at end of file Added: trunk/admin/index_html_top.php =================================================================== --- trunk/admin/index_html_top.php (rev 0) +++ trunk/admin/index_html_top.php 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,57 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html> + <head> + <meta http-equiv="content-type" content="text/html; charset=utf-8"> + <title>phpFreeChat - Administration</title> + <link rel="stylesheet" title="classic" type="text/css" href="style/generic.css"> + <link rel="stylesheet" title="classic" type="text/css" href="style/header.css"> + <link rel="stylesheet" title="classic" type="text/css" href="style/footer.css"> + <link rel="stylesheet" title="classic" type="text/css" href="style/menu.css"> + <link rel="stylesheet" title="classic" type="text/css" href="style/content.css"> + <script type="text/javascript" src="style/show.js"></script> + </head> + <body> + +<div class="header"> + <h1>phpFreeChat - Administration</h1> + <img alt="logo bulle" src="style/bulle.png" class="logo2"> +</div> + +<div class="menu"> + <ul> + <li class="sub title">General</li> + <li> + <ul class="sub"> + <li class="item"> + <a href="index.php">Administration Index</a> + <li class="item"> + <a href="../index.php">PFC Index</a> + </li> + </li> + <li class="item"> + <a href="user.php">Users</a> + </li> + <li class="item"> + <a href="configuration.php">Configuration</a> + </li> + <li class="item"> + <a href="themes.php">Themes</a> + </li> + </ul> + </li> + <li class="sub title">Other</li> + <li> + <ul> + <li class="item"> + <a href="#">other</a> + </li> + <li class="item"> + <a href="#">other</a> + </li> + </ul> + </li> + </ul> + <p class="partner"> + <a href="http://www.phpfreechat.net"><img alt="logo big" src="style/logo_88x31.gif"></a> + </p> +</div> Added: trunk/admin/style/bulle.png =================================================================== (Binary files differ) Property changes on: trunk/admin/style/bulle.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/admin/style/check_off.png =================================================================== (Binary files differ) Property changes on: trunk/admin/style/check_off.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/admin/style/check_on.png =================================================================== (Binary files differ) Property changes on: trunk/admin/style/check_on.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/admin/style/content.css =================================================================== --- trunk/admin/style/content.css (rev 0) +++ trunk/admin/style/content.css 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,34 @@ +/* --- CONTENT --- */ +div.content { + margin: 0.5em; + padding: 1em; + margin-left: 12.2em; + background-color: #FFF; + border: 1px #acd233 solid; + min-height: 40em; +} +div.content * { margin-top: 0.5em; margin-bottom: 0.5em; } +div.content h2 { border-bottom: 1px #444 solid; } +div.content h3 { text-decoration: underline; font-size: 100%; margin: 1em 0 1em 0; } +div.content a:link, div.content a:visited, div.content a:hover, div.content a:visited{ color: #0081ac; } +div.content code { background-color: #EFE; border: 1px #444 dotted; } +div.content pre { padding: 1em; background-color: #EFE; border: 1px #444 dotted; } +div.content ul { margin-left: 2em; } +div.content ol { margin-left: 3em; } +div.content dd { margin-left: 3em; } +div.content dt { font-weight: bold; margin: 2em 0 2em 0; } +div.content img { vertical-align: bottom;} +div.content .abstract { border: 2px #999 solid; background-color: #EEE; padding: 1em; color: #000; text-align: justify; } + +/* ----------------- */ +div.ok h3, div.message h3 { text-decoration: none; font-size: 100%; margin: 1em 0 1em 0; color: #339933;} +div.ko h3 { text-decoration: none; font-size: 100%; margin: 1em 0 1em 0; color: #FF0000;} + +div.showbox * { margin-top: 0; margin-bottom: 0; } +div.showbox p { margin-top: 0.2em; } +div.showbox { border : 1px solid #ccc; border-top-width : 2px; padding : 0 0.5em; margin : 0 0 0.5em 0;} +div.showbox h4 { background : #eceade; margin : 0 -0.5em; padding : 0.2em 0.5em; font-size : 1em; font-family : Verdana,Arial,Helevetica,sans-serif; } +.field label { display : block; float : left; width : 10em;} + + + Added: trunk/admin/style/footer.css =================================================================== --- trunk/admin/style/footer.css (rev 0) +++ trunk/admin/style/footer.css 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,21 @@ +/* --- FOOTER --- */ +div.footer { + position: relative; + text-align: center; + background-color: #99cc33; + color: #FFF; + border-top: 1px #acd233 solid; + border-bottom: 1px #acd233 solid; + font-size: 80%; + clear: both; + padding-left: 12em; +} +div.footer div.valid { + display: inline; + float: right; +} +div.footer div.rss { + position: absolute; + left: 5px; + float: left; +} Added: trunk/admin/style/generic.css =================================================================== --- trunk/admin/style/generic.css (rev 0) +++ trunk/admin/style/generic.css 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,20 @@ +/* --- GENERIC --- */ +* { padding: 0; margin: 0; } +a img { border: none; } +body { + color: #000000; + background: #339933; + font-family: Verdana, Sans-Serif; + font-size: 100%; + padding: 0; + margin: 0; +} + +a:link, a:visited, a:hover { + font-weight: bold; + text-decoration: none; +} +a:hover { + text-decoration: underline; +} +.nospace { word-spacing: -0.35em; } Added: trunk/admin/style/header.css =================================================================== --- trunk/admin/style/header.css (rev 0) +++ trunk/admin/style/header.css 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,23 @@ +/* --- HEADER --- */ +div.header { + position: relative; + display: block; + background-color: #99cc33; + border-bottom: 1px #acd233 solid; + height: 45px; +} +div.header h1 { + color: #FFF; + text-align: center; +} +div.header .logo2 { + position: absolute; + bottom: 0; + right: 0; +} +div.header .flags { + position: absolute; + bottom: 2px; + left: 0px; +} +div.header .flags a { margin-left: 0.5em; } Added: trunk/admin/style/logo_88x31.gif =================================================================== (Binary files differ) Property changes on: trunk/admin/style/logo_88x31.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/admin/style/menu.css =================================================================== --- trunk/admin/style/menu.css (rev 0) +++ trunk/admin/style/menu.css 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,63 @@ +/* --- MENU --- */ +div.menu { + position: absolute; + top: 55px; + left: 0.5em; +/* float: left; + margin-top: 0.5em; + margin-left: 0.4em;*/ + color: #FFF; + width: 11em; + text-align: center; +} +div.menu * { font-size: 95%; } +div.menu ul { + background-color: #99cc33; + border: 1px #acd233 solid; + text-align: left; + list-style: none; +} +div.menu li { + display: inline; +} +div.menu img { margin-top: 10px; } +div.menu .title { + padding: 4px; + text-align: center; + color: #888; + background-color: #FFF; +} +div.menu li.sub { + font-weight: bold; + padding: 0; + margin: 0; + display: block; +} +div.menu li a { + display: block; + margin: 0px; + padding: 4px; + padding-left: 10px; + width: auto; +} +div.menu li.item { + display: inline; +} +div.menu a:link, div.menu a:visited, div.menu a:hover { color: #FFF; } +div.menu a:visited { color: #FFF; } +div.menu li.item a:hover, div.menu ul.sub li.item a:hover { + display: block; + background-color: #acd233; + text-decoration: none; +} + +div.menu .partner { + margin-top: 5px; +} +div.menu div.rating { + margin-top: 10px; +} +div.menu div.rating table, div.menu div.rating table td { + text-align: center; + margin: auto; +} Added: trunk/admin/style/show.js =================================================================== --- trunk/admin/style/show.js (rev 0) +++ trunk/admin/style/show.js 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,34 @@ +function getE(id) +{ + if(document.getElementById) { + return document.getElementById(id); + } else if(document.all) { + return document.all[id]; + } else return; +} + +function openClose(id,mode) +{ + element = getE(id); + img = getE('img_'+id); + + if(element.style) { + if(mode == 0) { + if(element.style.display == 'block' ) { + element.style.display = 'none'; + img.src = 'pics/plus.gif'; + } else { + element.style.display = 'block'; + img.src = 'pics/moins.gif'; + } + } else if(mode == 1) { + element.style.display = 'block'; + img.src = 'pics/moins.gif'; + } else if(mode == -1) { + element.style.display = 'none'; + img.src = 'pics/plus.gif'; + } + } +} + + Added: trunk/admin/style/valid-css.png =================================================================== (Binary files differ) Property changes on: trunk/admin/style/valid-css.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/admin/style/valid-xhtml.png =================================================================== (Binary files differ) Property changes on: trunk/admin/style/valid-xhtml.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/admin/themes.class.php =================================================================== --- trunk/admin/themes.class.php (rev 0) +++ trunk/admin/themes.class.php 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,181 @@ +<? + +/** +* Class to manage theme of pfc +* @author Fred Delaunay <fr...@ne...> +*/ + +class themes{ + var $dir_themes; // directory of themes + + + + function themes(){ + $this->dir_themes = dirname(__FILE__)."/../themes/"; + } + + /** + * Get the list of themes + * @return array $themes_list + */ + function getThemesList(){ + $i=0; + $dir = opendir($this->dir_themes); + while ($f = readdir($dir)) { + if(is_dir($this->dir_themes.$f) && $f!="." && $f!="..") { + $themes_list[$i] = $f; + $i++; + } + } + + if($i>0) + return $themes_list; + else + return 0; + } + + /** + * Get the Author of a theme + * @param string $theme + * @return string $author + */ + function getThemeAuthor($theme){ + if(file_exists($this->dir_themes.$theme."/info.php")){ + include($this->dir_themes.$theme."/info.php"); + if(empty($author)) + return 0; + else + return $author; + } + else{ + return 0; + } + } + + + /** + * Get the Website of a theme + * @param string $theme + * @return string $website + */ + function getThemeWebsite($theme){ + if(file_exists($this->dir_themes.$theme."/info.php")){ + include($this->dir_themes.$theme."/info.php"); + if(empty($website)) + return 0; + else + return $website; + } + else{ + return 0; + } + } + + /** + * Get the info of a theme + * @param string $theme + * @return string $info + */ + function getThemeInfo($theme){ + $author = $this->getThemeAuthor($theme); + $website = $this->getThemeWebsite($theme); + $screenshot = $this->getThemeScreenshot($theme); + + if ($author!='0') $info = "$author"; + if ($author!='0' && $website!='0') $info .= " - "; + if ($website!='0') $info .= "<a href=\"$website\">$website</a>"; + if (($author!='0' || $website!='0') && ($screenshot!='0')) $info .= " - "; + if ($screenshot!='0') $info .= "<a href=\"$screenshot\">"._pfc("Screenshot")."</a>"; + + if(empty($info)) + return 0; + else + return $info; + } + + + /** + * Get the screenshot of a theme + * @param string $theme + * @return string $screenshot + */ + function getThemeScreenshot($theme){ + if(file_exists($this->dir_themes.$theme."/info.php")){ + include($this->dir_themes.$theme."/info.php"); + if(empty($screenshot)) + return 0; + else + return $screenshot; + } + else{ + return 0; + } + } + + /** + * Search if the imagess folder theme is present + * @param string $theme + * @return boolean - true if the /themes/name/images folder is present + */ + function isThemeImages($theme){ + if(is_dir($this->dir_themes.$theme."/images")){ + return true; + } + else{ + return false; + } + } + + /** + * Search if the smiley theme is present + * @param string $theme + * @return boolean - true if the /themes/name/smiley/theme file is present + */ + function isThemeSmiley($theme){ + if(file_exists($this->dir_themes.$theme."/smileys/theme")){ + return true; + } + else{ + return false; + } + } + + /** + * Search if the templates folder theme is present + * @param string $theme + * @return boolean - true if the /themes/name/templates folder is present + */ + function isThemeTemplates($theme){ + if(is_dir($this->dir_themes.$theme."/templates")){ + return true; + } + else{ + return false; + } + } + + + /** + * Get the file from the templates themes/name/ directory + * @return array $templates_files_list + */ + function getThemesTemplatesFilesList($theme){ + $i=0; + $dir_templates = $this->dir_themes.$theme."/templates/"; + $dir = opendir($dir_templates); + while ($f = readdir($dir)) { + if(is_file($dir_templates.$f) && $f!="." && $f!="..") { + $templates_files_list[$i] = $f; + $i++; + } + } + + if($i>0) + return $templates_files_list; + else + return 0; + } + +} + +?> \ No newline at end of file Added: trunk/admin/themes.php =================================================================== --- trunk/admin/themes.php (rev 0) +++ trunk/admin/themes.php 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,66 @@ +<? +# lang +require_once("../src/pfci18n.class.php"); +require_once("inc.conf.php"); +pfcI18N::Init($lang,"admin"); + +# themes class +require_once("themes.class.php"); +$themes = new themes(); + +?> + +<? +// TOP // +include("index_html_top.php"); +?> + +<div class="content"> + <h2><? echo _pfc("Available themes"); ?></h2> +<? + + $themes_list = $themes->getThemesList(); + for($i=0;$i<count($themes_list);$i++) { + + echo "<div class=\"showbox\">"; + echo "<h4><a href=\"#\" onclick=\"openClose('$themes_list[$i]', 0); return false;\">".$themes_list[$i]."</a>"; + $info = $themes->getThemeInfo($themes_list[$i]); + if ($info!='0') echo " ( $info ) "; + echo "</h4>"; + + echo "<div id=\"$themes_list[$i]\" style=\"display: none;\">"; + echo "<ul>"; + + if($themes->isThemeImages($themes_list[$i])) + echo "<li>Images <img src=\"style/check_on.png\" alt=\"On\" /></li>"; + else + echo "<li>Images <img src=\"style/check_off.png\" alt=\"Off\" /></li>"; + + if($themes->isThemeSmiley($themes_list[$i])) + echo "<li>Smiley <img src=\"style/check_on.png\" alt=\"On\" /></li>"; + else + echo "<li>Smiley <img src=\"style/check_off.png\" alt=\"Off\" /></li>"; + + if($themes->isThemeTemplates($themes_list[$i])){ + echo "<li>Templates <img src=\"style/check_on.png\" alt=\"On\" /></li>"; + $templates_files_list = $themes->getThemesTemplatesFilesList($themes_list[$i]); + echo "<ul>"; + for($j=0;$j<count($templates_files_list);$j++) { + echo "<li>$templates_files_list[$j]</li>"; + } + echo "</ul>"; + } + else + echo "<li>Templates <img src=\"style/check_off.png\" alt=\"Off\" /></li>"; + echo "</ul>"; + echo "</div>"; + echo "</div>"; + } + +?> +</div> + +<? +// BOTTOM +include("index_html_bottom.php"); +?> \ No newline at end of file Added: trunk/admin/themes_avant.php =================================================================== --- trunk/admin/themes_avant.php (rev 0) +++ trunk/admin/themes_avant.php 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,61 @@ +<? +require_once("themes.class.php"); +$themes = new themes(); + + +?> + +<? +// TOP // +include("index_html_top.php"); +?> + +<div class="content"> + <h2>Liste des themes disponibles</h2> +<? + echo "<ul>"; + $themes_list = $themes->getThemesList(); + for($i=0;$i<count($themes_list);$i++) { + $author = $themes->getThemeAuthor($themes_list[$i]); + $website = $themes->getThemeWebsite($themes_list[$i]); + + echo "<li><strong>$themes_list[$i]</strong>"; + if ($author!='0' || $website!='0') echo " ( $author - <a href=\"$website\">$website</a> )"; + echo "</li>"; + echo "<ul>"; + + + + + if($themes->isThemeImages($themes_list[$i])) + echo "<li>Images <img src=\"style/check_on.png\" alt=\"On\" /></li>"; + else + echo "<li>Images <img src=\"style/check_off.png\" alt=\"Off\" /></li>"; + + if($themes->isThemeSmiley($themes_list[$i])) + echo "<li>Smiley <img src=\"style/check_on.png\" alt=\"On\" /></li>"; + else + echo "<li>Smiley <img src=\"style/check_off.png\" alt=\"Off\" /></li>"; + + if($themes->isThemeTemplates($themes_list[$i])){ + echo "<li>Templates <img src=\"style/check_on.png\" alt=\"On\" /></li>"; + $templates_files_list = $themes->getThemesTemplatesFilesList($themes_list[$i]); + echo "<ul>"; + for($j=0;$j<count($templates_files_list);$j++) { + echo "<li>$templates_files_list[$j]</li>"; + } + echo "</ul>"; + } + else + echo "<li>Templates <img src=\"style/check_off.png\" alt=\"Off\" /></li>"; + + echo "</ul>"; + } + echo "</ul>"; +?> +</div> + +<? +// BOTTOM +include("index_html_bottom.php"); +?> \ No newline at end of file Added: trunk/admin/user.php =================================================================== --- trunk/admin/user.php (rev 0) +++ trunk/admin/user.php 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,161 @@ +<?php + +# lang +require_once("../src/pfci18n.class.php"); +require_once("inc.conf.php"); +pfcI18N::Init($lang,"admin"); + +# htaccess class +require_once ('htaccess.class.php'); +$ht = new htaccess(); + +# Activate Authentification +if(!empty($_GET['active'])){ + if($_GET['active']==1 && $ht->getNumberOfUsers()>0) $ht->printHtaccess(); + elseif($_GET['active']==1 && $ht->getNumberOfUsers()==0){ + $msg = _pfc("At least one user must be declare to activate authentication."); + header('Location: '.$_SERVER['PHP_SELF'].'?msg='.rawurlencode($msg)); + exit; + } + elseif($_GET['active']==2 && file_exists($ht->get_file_Htaccess())) $ht->delHtaccess(); +} + +# Delete a user +if(!empty($_GET['del']) && !empty($_GET['username']) ) +{ + if($ht->getNumberOfUsers()==1){ + $msg = _pfc("It is not possible to delete the last user."); + header('Location: '.$_SERVER['PHP_SELF'].'?msg='.rawurlencode($msg)); + exit; + } + else{ + $username = $_GET['username']; + $ht->delUser($username); + + $groups = $ht->getGroupOfUser($username); + if ($groups!=0){ #User is not in a group + for($i=0;$i<count($groups);$i++) { + $ht->delUserFromGroup($username,$groups[$i]); + } + } + + $msg = _pfc("User %s deleted.",$username); + header('Location: '.$_SERVER['PHP_SELF'].'?msg='.rawurlencode($msg)); + exit; + } +} + +# Modification or Creation of a user +if(!empty($_POST['username'])){ + $username = $_POST['username']; + $password = $_POST['password']; + $create=0; + + if(!$ht->isUser($username)){ #Add User + if(!empty($password)) { + $ht->addUser($username,$password); + $create=1; + } + } + else{ #Modify User + if(!empty($password)) + $ht->setPasswd($username,$password); + } + + $groups= $ht->getGroups(); + for($j=0;$j<count($groups);$j++) { + $group = $_POST['group']; + if($group==$groups[$j]) + $ht->addUserInGroup($username,$groups[$j]); + else + $ht->delUserFromGroup($username,$groups[$j]); + } + + + if($create==1) + $msg = _pfc("User %s added.", $username); + else + $msg = _pfc("User %s edited.", $username); + header('Location: '.$_SERVER['PHP_SELF'].'?msg='.rawurlencode($msg)); + exit; + +} +?> + +<? +// TOP // +include("index_html_top.php"); +?> + +<div class="content"> +<h2><? echo _pfc("Users management"); ?></h2> + +<? + if(!file_exists($ht->get_file_Htaccess())) + echo "<div class=\"ko\"><h3><img src=\"style/check_off.png\" alt=\""._pfc("Authentication disable")."\"> "._pfc("Authentication disable")." - <a href=\"".$_SERVER['PHP_SELF']."?active=1\">"._pfc("Enable here")."</a></h3></div>"; + else{ + echo "<div class=\"ok\"><h3><img src=\"style/check_on.png\" alt=\""._pfc("Authentication enable")."\"> "._pfc("Authentication enable")." - <a href=\"".$_SERVER['PHP_SELF']."?active=2\">"._pfc("Disable here")."</a></h3></div>"; + + } + + + if(!empty($_GET['msg'])) + echo "<div class=\"message\"><h3>".$_GET['msg']."</h3></div>"; + + $users= $ht->getUsers(); + if($users!=0) { + for($i=0;$i<count($users);$i++) { + echo "<div class=\"showbox\">"; + echo "<h4>".$users[$i]; + echo " [ <a style=\"font-weight: normal;\" href=\"#\" onclick=\"openClose('$users[$i]', 0); return false;\">"._pfc("Edit")."</a> - <a style=\"font-weight: normal;\" href=\"".$_SERVER['PHP_SELF']."?username=$users[$i]&del=1\" onclick=\"return window.confirm('"._pfc("Do you really want to delete %s ?",$users[$i])."')\">"._pfc("Delete")."</a> ]</p>"; + echo "</h4>"; + echo "<div id=\"$users[$i]\" style=\"display: none;\">"; + echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">"; + echo " <input type=\"hidden\" name=\"username\" id=\"username\" value=\"$users[$i]\" />"; + echo " <p class=\"field\"><label for=\"password\">"._pfc("Password").": </label><input type=\"text\" size=\"30\" name=\"password\" id=\"password\" /></p>"; + + echo " <p class=\"field\"><label for=\"group\">"._pfc("Group").": </label><select name=\"group\" id=\"group\">"; + $groups= $ht->getGroups(); + for($j=0;$j<count($groups);$j++) { + if ($ht->isUserInGroup($users[$i],$groups[$j])) + $selected = "selected=\"selected\""; + else + $selected = ""; + echo "<option value=\"".$groups[$j]."\" $selected>".$groups[$j]."</option>"; + } + echo " </select></p>"; + + echo " <p class=\"field\"><input class=\"submit\" type=\"submit\" value=\"ok\"/></p>"; + echo "</form>"; + echo "</div>"; + echo "</div>"; + } + } + + + + echo "<div class=\"showbox\">"; + echo "<h4>"._pfc("Add a new user")."</h4>"; + echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">"; + echo " <p class=\"field\"><label for=\"username\" >"._pfc("Username").": </label><input type=\"text\" size=\"30\" maxlength=\"32\" name=\"username\" id=\"username\" /> </p>"; + echo " <p class=\"field\"><label for=\"password\" >"._pfc("Password").": </label><input type=\"text\" size=\"30\" name=\"password\" id=\"password\" /></p>"; + + echo " <p class=\"field\"><label for=\"group\" >"._pfc("Group").": </label><select name=\"group\" id=\"group\" >"; + $groups= $ht->getGroups(); + for($j=0;$j<count($groups);$j++) { + echo "<option value=\"".$groups[$j]."\" >".$groups[$j]."</option>"; + } + echo " </select></p>"; + + echo " <p class=\"field\"><input class=\"submit\" type=\"submit\" value=\"ok\"/></p>"; + echo "</form>"; + echo "</div>"; + +?> + +</div> + +<? +// BOTTOM +include("index_html_bottom.php"); +?> \ No newline at end of file Added: trunk/admin/version.class.php =================================================================== --- trunk/admin/version.class.php (rev 0) +++ trunk/admin/version.class.php 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,46 @@ +<? + +/** +* Class to manage theme of pfc +* @author Fred Delaunay <fr...@ne...> +*/ + +class version{ + var $local_version; // file of the user version + var $pfc_official_current_version; // file of the pfc official current version + + + function version(){ + $this->local_version = dirname(__FILE__)."/../version"; + $this->pfc_official_current_version = "http://www.phpfreechat.net/version"; + } + + /** + * Get the local version + * @return integer version + */ + function getLocalVersion(){ + $fp = fopen($this->local_version,"r"); + $version = trim(fgets($fp)); + fclose($fp); + return $version; + } + + /** + * Get the pfc official current version + * @return integer version + */ + function getPFCOfficialCurrentVersion(){ + if (file_exists($this->pfc_official_current_version)) { + $fp = fopen($this->pfc_official_current_version,"r"); + $version = trim(fgets($fp)); + fclose($fp); + return $version; + } + else + return 0; + } + +} + +?> \ No newline at end of file Added: trunk/i18n/en_US/admin.php =================================================================== --- trunk/i18n/en_US/admin.php (rev 0) +++ trunk/i18n/en_US/admin.php 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,68 @@ +<?php +/** + * i18n/en_US/main.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 + */ + +/** + * English translation of the messages (utf8 encoded!) + * + * @author Nemako <fr...@ne...> + */ + +// admin/index.php +$GLOBALS["i18n"]["Administration"] = "Administration"; +$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."; + + +// admin/user.php +$GLOBALS["i18n"]["Users management"] = "Users management"; +$GLOBALS["i18n"]["At least one user must be declare to activate authentication."] = "At least one user must be declare to activate authentication."; +$GLOBALS["i18n"]["It is not possible to delete the last user."] = "It is not possible to delete the last user."; + +$GLOBALS["i18n"]["User %s deleted."] = "User %s deleted."; +$GLOBALS["i18n"]["User %s added."] = "User %s added."; +$GLOBALS["i18n"]["User %s edited."] = "User %s edited."; + +$GLOBALS["i18n"]["Authentication disable"] = "Authentication disable"; +$GLOBALS["i18n"]["Enable here"] = "Activate here"; +$GLOBALS["i18n"]["Authentication enable"] = "Authentication enable"; +$GLOBALS["i18n"]["Disable here"] = "Disable here"; + +$GLOBALS["i18n"]["Username"] = "Username"; +$GLOBALS["i18n"]["Password"] = "Password"; +$GLOBALS["i18n"]["Group"] = "Group"; + +$GLOBALS["i18n"]["Do you really want to delete %s ?"] = "Do you really want to delete %s ?"; +$GLOBALS["i18n"]["Add a new user"] = "Add a new user"; + +$GLOBALS["i18n"]["Edit"] = "Edit"; +$GLOBALS["i18n"]["Delete"] = "Delete"; + +// admin/themes.php +$GLOBALS["i18n"]["Available themes"] = "Available themes"; +$GLOBALS["i18n"]["Screenshot"] = "Screenshot"; + +?> Added: trunk/i18n/fr_FR/admin.php =================================================================== --- trunk/i18n/fr_FR/admin.php (rev 0) +++ trunk/i18n/fr_FR/admin.php 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,70 @@ +<?php +/** + * i18n/en_US/main.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 + */ + +/** + * English translation of the messages (utf8 encoded!) + * + * @author Stephane Gully <ste...@gm...> + */ + +// admin/index.php +$GLOBALS["i18n"]["Administration"] = "Administration"; +$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 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"; +$GLOBALS["i18n"]["Your version"] = "Votre version"; +$GLOBALS["i18n"]["The last official version"] = "La dernière version officielle"; +$GLOBALS["i18n"]["Download the last version %s here %s."] = "Download the last version %s here %s."; + + +// admin/user.php +$GLOBALS["i18n"]["Users management"] = "Gestion des utilisateurs"; + +$GLOBALS["i18n"]["At least one user must be declare to activate authentication."] = "Au moins un utilisateur doit être créé pour activer une authentification."; +$GLOBALS["i18n"]["It is not possible to delete the last user."] = "Il est impossible de supprimer le dernier utilisateur."; + +$GLOBALS["i18n"]["User %s deleted."] = "Utilisateur %s supprimé."; +$GLOBALS["i18n"]["User %s added."] = "Utilisateur %s ajouté."; +$GLOBALS["i18n"]["User %s edited."] = "Utilisateur %s modifé."; + +$GLOBALS["i18n"]["Authentication disable"] = "Authentification désactivée"; +$GLOBALS["i18n"]["Enable here"] = "Activer ici"; +$GLOBALS["i18n"]["Authentication enable"] = "Authentification activée"; +$GLOBALS["i18n"]["Disable here"] = "Désactiver ici"; + +$GLOBALS["i18n"]["Username"] = "Utilisateur"; +$GLOBALS["i18n"]["Password"] = "Mot de passe"; +$GLOBALS["i18n"]["Group"] = "Groupe"; + +$GLOBALS["i18n"]["Do you really want to delete %s ?"] = "Voulez-vous vraiment supprimer %s ?"; +$GLOBALS["i18n"]["Add a new user"] = "Ajouter un nouvel utilisateur"; + +$GLOBALS["i18n"]["Edit"] = "Modifier"; +$GLOBALS["i18n"]["Delete"] = "Supprimer"; + +// admin/themes.php +$GLOBALS["i18n"]["Available themes"] = "Liste des themes disponibles"; +$GLOBALS["i18n"]["Screenshot"] = "Capture d'écran"; + +?> Modified: trunk/src/pfci18n.class.php =================================================================== --- trunk/src/pfci18n.class.php 2006-04-24 14:01:11 UTC (rev 463) +++ trunk/src/pfci18n.class.php 2006-04-24 14:40:06 UTC (rev 464) @@ -31,11 +31,14 @@ class pfcI18N { - function Init($language) + function Init($language,$type='admin') { if (!in_array($language, pfcI18N::GetAcceptedLanguage())) $language = pfcI18N::GetDefaultLanguage(); - require_once(dirname(__FILE__)."/../i18n/".$language."/main.php"); + if ($type=="admin") + require_once(dirname(__FILE__)."/../i18n/".$language."/admin.php"); + else + require_once(dirname(__FILE__)."/../i18n/".$language."/main.php"); $GLOBALS["output_encoding"] = "UTF-8"; // by default client/server communication is utf8 encoded } Added: trunk/themes/blune/info.php =================================================================== --- trunk/themes/blune/info.php (rev 0) +++ trunk/themes/blune/info.php 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,5 @@ +<? +$author = "Nemako"; +$website = "http://www.nemako.net"; +$screenshot = "http://img111.imageshack.us/img111/1681/blune1xe.png"; +?> \ No newline at end of file Added: trunk/themes/cerutti/info.php =================================================================== --- trunk/themes/cerutti/info.php (rev 0) +++ trunk/themes/cerutti/info.php 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,3 @@ +<? +$author = "Victor Cerutti"; +?> \ No newline at end of file Added: trunk/themes/default/info.php =================================================================== --- trunk/themes/default/info.php (rev 0) +++ trunk/themes/default/info.php 2006-04-24 14:40:06 UTC (rev 464) @@ -0,0 +1,4 @@ +<? +$author = "kerphi"; +$website = "http://www.phpfreechat.net"; +?> \ 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-14 12:35:38
|
Revision: 569 Author: kerphi Date: 2006-06-14 05:35:26 -0700 (Wed, 14 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=569&view=rev Log Message: ----------- add the checkmd5 call into the index.php file Modified Paths: -------------- trunk/index.php trunk/misc/checkmd5 Modified: trunk/index.php =================================================================== --- trunk/index.php 2006-06-14 12:25:31 UTC (rev 568) +++ trunk/index.php 2006-06-14 12:35:26 UTC (rev 569) @@ -66,6 +66,7 @@ <div class="content"> <h2>See the quick demo</h2> <?php $chat->printChat(); ?> + <?php if (file_exists(dirname(__FILE__)."/checkmd5.php")) require_once dirname(__FILE__)."/checkmd5.php"; ?> </div> <div class="footer"> @@ -79,4 +80,4 @@ </div> <p>\xA92006 phpFreeChat</p> </div> -</body></html> \ No newline at end of file +</body></html> Modified: trunk/misc/checkmd5 =================================================================== --- trunk/misc/checkmd5 2006-06-14 12:25:31 UTC (rev 568) +++ trunk/misc/checkmd5 2006-06-14 12:35:26 UTC (rev 569) @@ -27,7 +27,7 @@ cd $PFC_PATH echo "<?php" > $TMP -echo 'echo "<h1>Checking phpfreechat files validity</h1>";' >> $TMP +echo 'echo "<h2>Checking phpfreechat files validity</h2>";' >> $TMP echo 'echo "<pre>\n";' >> $TMP for f in `find . -type f` do This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-14 12:45:33
|
Revision: 570 Author: kerphi Date: 2006-06-14 05:45:21 -0700 (Wed, 14 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=570&view=rev Log Message: ----------- Add the rating box to the demo index Modified Paths: -------------- trunk/demo/index.php trunk/index.php Modified: trunk/demo/index.php =================================================================== --- trunk/demo/index.php 2006-06-14 12:35:26 UTC (rev 569) +++ trunk/demo/index.php 2006-06-14 12:45:21 UTC (rev 570) @@ -1,19 +1,19 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> - <meta http-equiv="content-type" content="text/html; charset=utf-8"> + <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>phpFreeChat Demos</title> - <link rel="stylesheet" title="classic" type="text/css" href="../style/generic.css"> - <link rel="stylesheet" title="classic" type="text/css" href="../style/header.css"> - <link rel="stylesheet" title="classic" type="text/css" href="../style/footer.css"> - <link rel="stylesheet" title="classic" type="text/css" href="../style/menu.css"> - <link rel="stylesheet" title="classic" type="text/css" href="../style/content.css"> + <link rel="stylesheet" title="classic" type="text/css" href="../style/generic.css" /> + <link rel="stylesheet" title="classic" type="text/css" href="../style/header.css" /> + <link rel="stylesheet" title="classic" type="text/css" href="../style/footer.css" /> + <link rel="stylesheet" title="classic" type="text/css" href="../style/menu.css" /> + <link rel="stylesheet" title="classic" type="text/css" href="../style/content.css" /> </head> <body> <div class="header"> <h1>phpFreeChat - Demos</h1> - <img alt="logo bulle" src="../style/bulle.png" class="logo2"> + <img alt="logo bulle" src="../style/bulle.png" class="logo2" /> </div> <div class="menu"> @@ -30,25 +30,58 @@ <li> <ul class="sub"> <li class="item"> - <a href="#Miscellaneous">Miscellaneous</a> + <a href="#demo-misc">Miscellaneous</a> </li> <li class="item"> - <a href="#Themes">Themes</a> + <a href="#demo-themes">Themes</a> </li> <li class="item"> - <a href="#Translations">Translations</a> + <a href="#demo-translations">Translations</a> </li> </ul> </li> </ul> <p class="partner"> - <a href="http://www.phpfreechat.net"><img alt="logo big" src="../style/logo_88x31.gif"></a> + <a href="http://www.phpfreechat.net"><img alt="logo big" src="../style/logo_88x31.gif" /></a> </p> + <div class="rating"> + <form action="http://www.hotscripts.com/rate/56184.html" method="get"> + <input type="hidden" name="RID" value="N452772"/> + <table> + <tbody> + <tr> + <td> + <table> + <tbody> + <tr> + <td>If you like our script, please rate it! <input type="hidden" name="external" value="1"/> + </td> + </tr> + <tr> + <td> + <select name="rate" size="1"> + <option value="5" selected="selected">Excellent!</option> + <option value="4">Very Good</option> + <option value="3">Good</option> + <option value="2">Fair</option> + <option value="1">Poor</option> + </select> + <input type="submit" name="submit" value="Cast My Vote!"/> + </td> + </tr> + </tbody> + </table> + </td> + </tr> + </tbody> + </table> + </form> + </div> </div> <div class="content"> -<h2>Miscellaneous</h2> +<h2 id="demo-misc">Miscellaneous</h2> <ul> <li><a href="demo1_simple.php">demo1 - demo with default parameters</a></li> @@ -73,7 +106,7 @@ </ul> -<h2>Themes</h2> +<h2 id="demo-themes">Themes</h2> <ul> <li><a href="demo11_famfamfam_smiley_theme.php">demo11 - A chat with a customized smiley theme (famfamfam theme)</a></li> @@ -85,7 +118,7 @@ <li><a href="demo44_green_theme.php">demo44 - use a customized theme (green)</a></li> </ul> -<h2>Translations</h2> +<h2 id="demo-translations">Translations</h2> <ul> <li><a href="demo6_in_french.php">demo6 - french translation of the chat</a></li> <li><a href="demo7_in_english.php">demo7 - english translation of the chat</a></li> @@ -123,6 +156,6 @@ <img alt="Valid CSS!" src="../style/valid-css.png"> </a> </div> - <p>\xA92006 phpFreeChat</p> + <p>@2006 phpFreeChat</p> </div> -</body></html> \ No newline at end of file +</body></html> Modified: trunk/index.php =================================================================== --- trunk/index.php 2006-06-14 12:35:26 UTC (rev 569) +++ trunk/index.php 2006-06-14 12:45:21 UTC (rev 570) @@ -61,6 +61,40 @@ <p class="partner"> <a href="http://www.phpfreechat.net"><img alt="logo big" src="style/logo_88x31.gif" /></a> </p> + + <div class="rating"> + <form action="http://www.hotscripts.com/rate/56184.html" method="get"> + <input type="hidden" name="RID" value="N452772"/> + <table> + <tbody> + <tr> + <td> + <table> + <tbody> + <tr> + <td>If you like our script, please rate it! <input type="hidden" name="external" value="1"/> + </td> + </tr> + <tr> + <td> + <select name="rate" size="1"> + <option value="5" selected="selected">Excellent!</option> + <option value="4">Very Good</option> + <option value="3">Good</option> + <option value="2">Fair</option> + <option value="1">Poor</option> + </select> + <input type="submit" name="submit" value="Cast My Vote!"/> + </td> + </tr> + </tbody> + </table> + </td> + </tr> + </tbody> + </table> + </form> + </div> </div> <div class="content"> @@ -78,6 +112,6 @@ <img alt="Valid CSS!" src="style/valid-css.png" /> </a> </div> - <p>\xA92006 phpFreeChat</p> + <p>@2006 phpFreeChat</p> </div> </body></html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-06-14 13:24:11
|
Revision: 573 Author: kerphi Date: 2006-06-14 06:03:59 -0700 (Wed, 14 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=573&view=rev Log Message: ----------- fix some XHTML errors Modified Paths: -------------- trunk/demo/index.php trunk/index.php trunk/themes/default/templates/chat.html.tpl.php Modified: trunk/demo/index.php =================================================================== --- trunk/demo/index.php 2006-06-14 12:55:32 UTC (rev 572) +++ trunk/demo/index.php 2006-06-14 13:03:59 UTC (rev 573) @@ -46,7 +46,7 @@ </p> <div class="rating"> <form action="http://www.hotscripts.com/rate/56184.html" method="get"> - <input type="hidden" name="RID" value="N452772"/> + <p><input type="hidden" name="RID" value="N452772"/></p> <table> <tbody> <tr> Modified: trunk/index.php =================================================================== --- trunk/index.php 2006-06-14 12:55:32 UTC (rev 572) +++ trunk/index.php 2006-06-14 13:03:59 UTC (rev 573) @@ -64,7 +64,7 @@ <div class="rating"> <form action="http://www.hotscripts.com/rate/56184.html" method="get"> - <input type="hidden" name="RID" value="N452772"/> + <p><input type="hidden" name="RID" value="N452772" /></p> <table> <tbody> <tr> Modified: trunk/themes/default/templates/chat.html.tpl.php =================================================================== --- trunk/themes/default/templates/chat.html.tpl.php 2006-06-14 12:55:32 UTC (rev 572) +++ trunk/themes/default/templates/chat.html.tpl.php 2006-06-14 13:03:59 UTC (rev 573) @@ -5,7 +5,7 @@ <div id="<?php echo $prefix; ?>content_expandable"> <div id="<?php echo $prefix; ?>channels"> - <ul id="<?php echo $prefix; ?>channels_list"></ul> + <ul id="<?php echo $prefix; ?>channels_list"><li></li></ul> <div id="<?php echo $prefix; ?>channels_content"></div> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-08-22 13:09:01
|
Revision: 686 Author: kerphi Date: 2006-08-22 06:08:50 -0700 (Tue, 22 Aug 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=686&view=rev Log Message: ----------- Add partners on the pfc index. Modified Paths: -------------- trunk/demo/index.php trunk/index.php trunk/style/content.css Added Paths: ----------- trunk/style/bulle.gif Modified: trunk/demo/index.php =================================================================== --- trunk/demo/index.php 2006-08-22 12:24:26 UTC (rev 685) +++ trunk/demo/index.php 2006-08-22 13:08:50 UTC (rev 686) @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> - <title>phpFreeChat Demos</title> + <title>phpFreeChat - Demos</title> <link rel="stylesheet" title="classic" type="text/css" href="../style/generic.css" /> <link rel="stylesheet" title="classic" type="text/css" href="../style/header.css" /> <link rel="stylesheet" title="classic" type="text/css" href="../style/footer.css" /> @@ -42,41 +42,12 @@ </li> </ul> <p class="partner"> - <a href="http://www.phpfreechat.net"><img alt="logo big" src="../style/logo_88x31.gif" /></a> + <a href="http://www.phpfreechat.net"><img alt="phpfreechat.net" src="../style/logo_88x31.gif" /></a><br/> + <a href="http://sourceforge.net/projects/phpfreechat"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=158880&type=1" alt="SourceForge.net Logo" height="31px" width="88px" /></a><br/><br/> + <a href="http://www.hotscripts.com/?RID=N452772">hotscripts.com</a><br/> + <a href="http://www.jeu-gratuit.net/?refer=phpfreechat">jeu-gratuit.net</a><br/> + <a href="http://www.pronofun.com/?refer=phpfreechat">pronofun.com</a><br/> </p> - <div class="rating"> - <form action="http://www.hotscripts.com/rate/56184.html" method="get"> - <p><input type="hidden" name="RID" value="N452772"/></p> - <table> - <tbody> - <tr> - <td> - <table> - <tbody> - <tr> - <td>If you like our script, please rate it! <input type="hidden" name="external" value="1"/> - </td> - </tr> - <tr> - <td> - <select name="rate" size="1"> - <option value="5" selected="selected">Excellent!</option> - <option value="4">Very Good</option> - <option value="3">Good</option> - <option value="2">Fair</option> - <option value="1">Poor</option> - </select> - <input type="submit" name="submit" value="Cast My Vote!"/> - </td> - </tr> - </tbody> - </table> - </td> - </tr> - </tbody> - </table> - </form> - </div> </div> <div class="content"> @@ -149,15 +120,4 @@ </div> -<div class="footer"> - <div class="valid"> - <a href="http://validator.w3.org/check?uri=referer"> - <img alt="Valid XHTML 1.0!" src="../style/valid-xhtml.png"> - </a> - <a href="http://jigsaw.w3.org/css-validator/check/referer"> - <img alt="Valid CSS!" src="../style/valid-css.png"> - </a> - </div> - <p>@2006 phpFreeChat</p> - </div> </body></html> Modified: trunk/index.php =================================================================== --- trunk/index.php 2006-08-22 12:24:26 UTC (rev 685) +++ trunk/index.php 2006-08-22 13:08:50 UTC (rev 686) @@ -2,6 +2,7 @@ require_once dirname(__FILE__)."/src/phpfreechat.class.php"; $params = array(); +$params["title"] = "Quick chat"; $params["nick"] = "guest".rand(1,10); // setup the intitial nickname $params["isadmin"] = true; // just for debug ;) $params["serverid"] = md5(__FILE__); // calculate a unique id for this chat @@ -12,7 +13,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> - <title>phpFreeChat Sources Index</title> + <title>phpFreeChat- Sources Index</title> <link rel="stylesheet" title="classic" type="text/css" href="style/generic.css" /> <link rel="stylesheet" title="classic" type="text/css" href="style/header.css" /> <link rel="stylesheet" title="classic" type="text/css" href="style/footer.css" /> @@ -25,7 +26,7 @@ <div class="header"> <h1>phpFreeChat - Sources Index</h1> - <img alt="logo bulle" src="style/bulle.png" class="logo2" /> + <img alt="logo bulle" src="style/bulle.gif" class="logo2" /> </div> <div class="menu"> @@ -36,9 +37,16 @@ <li class="item"> <a href="demo/">Demos</a> </li> + <?php if (file_exists(dirname(__FILE__)."/checkmd5.php")) { ?> + <li> + <a href="checkmd5.php">Check md5</a> + </li> + <?php } ?> + <!-- <li class="item"> <a href="admin/">Administration</a> </li> + --> </ul> </li> <li class="sub title">Documentation</li> @@ -60,59 +68,16 @@ </li> </ul> <p class="partner"> - <a href="http://www.phpfreechat.net"><img alt="logo big" src="style/logo_88x31.gif" /></a> + <a href="http://www.phpfreechat.net"><img alt="phpfreechat.net" src="style/logo_88x31.gif" /></a><br/> + <a href="http://sourceforge.net/projects/phpfreechat"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=158880&type=1" alt="SourceForge.net Logo" height="31px" width="88px" /></a><br/><br/> + <a href="http://www.hotscripts.com/?RID=N452772">hotscripts.com</a><br/> + <a href="http://www.jeu-gratuit.net/?refer=phpfreechat">jeu-gratuit.net</a><br/> + <a href="http://www.pronofun.com/?refer=phpfreechat">pronofun.com</a><br/> </p> - - <div class="rating"> - <form action="http://www.hotscripts.com/rate/56184.html" method="get"> - <p><input type="hidden" name="RID" value="N452772" /></p> - <table> - <tbody> - <tr> - <td> - <table> - <tbody> - <tr> - <td>If you like our script, please rate it! <input type="hidden" name="external" value="1"/> - </td> - </tr> - <tr> - <td> - <select name="rate" size="1"> - <option value="5" selected="selected">Excellent!</option> - <option value="4">Very Good</option> - <option value="3">Good</option> - <option value="2">Fair</option> - <option value="1">Poor</option> - </select> - <input type="submit" name="submit" value="Cast My Vote!"/> - </td> - </tr> - </tbody> - </table> - </td> - </tr> - </tbody> - </table> - </form> - </div> </div> <div class="content"> - <h2>See the quick demo</h2> <?php $chat->printChat(); ?> - <?php if (file_exists(dirname(__FILE__)."/checkmd5.php")) require_once dirname(__FILE__)."/checkmd5.php"; ?> </div> -<div class="footer"> - <div class="valid"> - <a href="http://validator.w3.org/check?uri=referer"> - <img alt="Valid XHTML 1.0!" src="style/valid-xhtml.png" /> - </a> - <a href="http://jigsaw.w3.org/css-validator/check/referer"> - <img alt="Valid CSS!" src="style/valid-css.png" /> - </a> - </div> - <p>@2006 phpFreeChat</p> - </div> </body></html> Added: trunk/style/bulle.gif =================================================================== (Binary files differ) Property changes on: trunk/style/bulle.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/style/content.css =================================================================== --- trunk/style/content.css 2006-08-22 12:24:26 UTC (rev 685) +++ trunk/style/content.css 2006-08-22 13:08:50 UTC (rev 686) @@ -5,7 +5,7 @@ margin-left: 12.2em; background-color: #FFF; border: 1px #acd233 solid; - min-height: 40em; + min-height: 15em; } div.content * { margin-top: 0.5em; margin-bottom: 0.5em; } div.content h2 { border-bottom: 1px #444 solid; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-08-29 20:55:38
|
Revision: 716 Author: kerphi Date: 2006-08-29 13:55:31 -0700 (Tue, 29 Aug 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=716&view=rev Log Message: ----------- - prepare the 1.0-beta5 - fix a prb with the version file - integrate pfcsetup in the script packager Modified Paths: -------------- trunk/misc/tarSource trunk/src/pfcglobalconfig.class.php trunk/version Modified: trunk/misc/tarSource =================================================================== --- trunk/misc/tarSource 2006-08-29 20:35:08 UTC (rev 715) +++ trunk/misc/tarSource 2006-08-29 20:55:31 UTC (rev 716) @@ -1,18 +1,43 @@ #!/bin/sh NAME=phpfreechat-`cat ../version` +PFCSETUPNAME=pfcsetup-`cat ../version` echo "-- creating archive $NAME --" echo "-> copying files" rm -rf ./$NAME svn export .. ./$NAME rm -rf ./$NAME/contrib + echo "-> creating checkmd5.php file" ./checkmd5 ./$NAME ./$NAME/checkmd5.php + echo "-> creating .tar.gz" tar czfp $NAME.tar.gz ./$NAME + echo "-> creating .zip" zip -Tq9r $NAME.zip ./$NAME + +echo "-> creating $PFCSETUPNAME" +rm -rf ./$PFCSETUPNAME +svn export ../contrib/pfcInstaller2 $PFCSETUPNAME +rm -rf ./$PFCSETUPNAME/.registry +rm -rf ./$PFCSETUPNAME/.depdblock +rm -rf ./$PFCSETUPNAME/.lock +rm -rf ./$PFCSETUPNAME/.channels +rm -rf ./$PFCSETUPNAME/tmp +rm -rf ./$PFCSETUPNAME/bin +rm -rf ./$PFCSETUPNAME/PEAR +rm -rf ./$PFCSETUPNAME/System.php +rm -rf ./$PFCSETUPNAME/peclcmd.php +rm -rf ./$PFCSETUPNAME/pearcmd.php +rm -rf ./$PFCSETUPNAME/pear.sh +rm -rf ./$PFCSETUPNAME/pearrc +rm -rf ./$PFCSETUPNAME/OS +echo "$NAME.tar.gz" > $PFCSETUPNAME/archive +tar czfp $PFCSETUPNAME.tar.gz ./$PFCSETUPNAME + echo "-> removing temporary files" rm -rf ./$NAME +rm -rf ./$PFCSETUPNAME echo "-- creating archive $NAME, done --" Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-08-29 20:35:08 UTC (rev 715) +++ trunk/src/pfcglobalconfig.class.php 2006-08-29 20:55:31 UTC (rev 716) @@ -419,7 +419,7 @@ $this->frozen_nick = false; // load version number from file - $this->version = file_get_contents(dirname(__FILE__)."/../version"); + $this->version = trim(file_get_contents(dirname(__FILE__)."/../version")); $this->is_init = (count($this->errors) == 0); } Modified: trunk/version =================================================================== --- trunk/version 2006-08-29 20:35:08 UTC (rev 715) +++ trunk/version 2006-08-29 20:55:31 UTC (rev 716) @@ -1 +1 @@ -1.0-beta4 \ No newline at end of file +1.0-beta5 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-08-30 21:06:14
|
Revision: 721 http://svn.sourceforge.net/phpfreechat/?rev=721&view=rev Author: kerphi Date: 2006-08-30 14:05:51 -0700 (Wed, 30 Aug 2006) Log Message: ----------- rename archive to archivename because of windows problem Modified Paths: -------------- trunk/contrib/pfcInstaller2/config.php trunk/misc/tarSource Added Paths: ----------- trunk/contrib/pfcInstaller2/archivename Removed Paths: ------------- trunk/contrib/pfcInstaller2/archive Deleted: trunk/contrib/pfcInstaller2/archive =================================================================== --- trunk/contrib/pfcInstaller2/archive 2006-08-29 21:18:06 UTC (rev 720) +++ trunk/contrib/pfcInstaller2/archive 2006-08-30 21:05:51 UTC (rev 721) @@ -1 +0,0 @@ -phpfreechat-1.0-beta5.tar.gz Copied: trunk/contrib/pfcInstaller2/archivename (from rev 720, trunk/contrib/pfcInstaller2/archive) =================================================================== --- trunk/contrib/pfcInstaller2/archivename (rev 0) +++ trunk/contrib/pfcInstaller2/archivename 2006-08-30 21:05:51 UTC (rev 721) @@ -0,0 +1 @@ +phpfreechat-1.0-beta5.tar.gz Modified: trunk/contrib/pfcInstaller2/config.php =================================================================== --- trunk/contrib/pfcInstaller2/config.php 2006-08-29 21:18:06 UTC (rev 720) +++ trunk/contrib/pfcInstaller2/config.php 2006-08-30 21:05:51 UTC (rev 721) @@ -3,7 +3,7 @@ require_once dirname(__FILE__).'/file_get_contents.php'; require_once dirname(__FILE__).'/file_put_contents.php'; -$archivename = trim(file_get_contents(dirname(__FILE__)."/archive")); +$archivename = trim(file_get_contents(dirname(__FILE__)."/archivename")); $archivename2 = str_replace(".tar.gz","",str_replace(".zip","",$archivename)); $mirrors = file(dirname(__FILE__)."/mirrors"); $dstpath = dirname(__FILE__)."/data"; Modified: trunk/misc/tarSource =================================================================== --- trunk/misc/tarSource 2006-08-29 21:18:06 UTC (rev 720) +++ trunk/misc/tarSource 2006-08-30 21:05:51 UTC (rev 721) @@ -33,7 +33,7 @@ rm -rf ./$PFCSETUPNAME/pear.sh rm -rf ./$PFCSETUPNAME/pearrc rm -rf ./$PFCSETUPNAME/OS -echo "$NAME.tar.gz" > $PFCSETUPNAME/archive +echo "$NAME.tar.gz" > $PFCSETUPNAME/archivename echo `pwd` >> $PFCSETUPNAME/mirrors tar czfp $PFCSETUPNAME.tar.gz ./$PFCSETUPNAME echo "-> creating $PFCSETUPNAME.zip" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-02 20:42:36
|
Revision: 725 http://svn.sourceforge.net/phpfreechat/?rev=725&view=rev Author: kerphi Date: 2006-09-02 13:42:09 -0700 (Sat, 02 Sep 2006) Log Message: ----------- Now the online documentation is automaticaly packaged by the release script (no more documentation misses). Modified Paths: -------------- trunk/misc/tarSource trunk/src/pfcglobalconfig.class.php Removed Paths: ------------- trunk/INSTALL.en trunk/INSTALL.fr trunk/README.en trunk/README.fr Deleted: trunk/INSTALL.en =================================================================== --- trunk/INSTALL.en 2006-09-02 20:38:40 UTC (rev 724) +++ trunk/INSTALL.en 2006-09-02 20:42:09 UTC (rev 725) @@ -1,298 +0,0 @@ - Install - - To install phpFreeChat you need: - - * A Web server (Apache, IIS, Xitami ...) with PHP (4 or 5) - * Write access on the Web server (SSH, FTP, or other) - - By default, you don't need a Mysql database because the system uses files - to store messages and nicknames. - - * Quick start - * Advanced configuration - - Quick start - - Using the setup (the easy way): - - 1. Download phpfreechat-x.x-setup.php[21] (lastest version) - 2. Upload the setup script on your server into a browsable directory - (public directory) - 3. Browse the script with your personnal browser, it should launch a - setup, then follow the steps ! - Tip: remove the setup when the install is finished for security - reason. - - Using the ziped archives (for those who havn't gzip module in their php): - - 1. Download phpfreechat-x.x.zip (or .tar.gz for linux users)[22] - (lastest version) - 2. Unzip the archive localy then upload the phpfreechat-x.x directory - on your server into a browsable directory (public directory). - Tip: if you have a SSH access I suggesto to untar the archives - directly on the server usign tar xzf phpfreechat-x.x.tar.gz command. - 3. Give the write rights to phpfreechat-x.x/data/public and - phpfreechat-x.x/data/private directories. - If you are using FTP: - CHMOD 777 phpfreechat-x.x/data/private - CHMOD 777 phpfreechat-x.x/data/public - - If you are using SSH: - chmod a+w phpfreechat-x.x/data/* - - 4. Browse the phpfreechat-x.x directory with your browser and enjoy ! - - Now you need surely to customize your chat. You can take a look at the - example scripts in the phpfreechat-x.x/demo directory. - - Here is the minimum script required for your chat to work (inspired from - demo1): - - <?php - - require_once "src/phpfreechat.class.php"; // adjust to your own path - $params["serverid"] = md5(__FILE__); // used to identify the chat - $chat = new phpFreeChat($params); - - ?> - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - <html> - <head> - <title>phpFreeChat demo</title> - <?php $chat->printJavascript(); ?> - <?php $chat->printStyle(); ?> - </head> - <body> - <?php $chat->printChat(); ?> - </body> - </html> - - Advanced configuration - - The chat is usable using the default configuration but a lot of options - can be tweaked to customize the chat. For exemple, to change the refresh - speed to 2 seconds, copy/paste this piece of code: - - <?php - - require_once "src/phpfreechat.class.php"; // adjust to your own path - $params["serverid"] = md5(__FILE__); - $params["refresh_delay"] = 2000; // 2000ms = 2s - $chat = new phpFreeChat($params); - - ?> - [... copy/paste here the above HTML codes ...] - - Another example, to set the initial nickname to "guest" (this can be - useful when the chat is integrated into a portal or a forum which - provides the login/password), copy/paste this piece of code: - - <?php - - require_once "src/phpfreechat.class.php"; // adjust to your own path - $params["serverid"] = md5(__FILE__); - $params["nick"] = "guest"; // it can be useful to take nicks from a database - $chat = new phpFreeChat($params); - - ?> - [... copy/paste here the above HTML codes ...] - - Now for the full parameters list: - - serverid - This is the only mandatory parameter. It is the chat server id, "its - IP" (comparable to the server host in IRC) used to identify the - chat. Two chat must have different serverid. If you don't know what - to write, just try : $params["serverid"] = md5(__FILE__); - nick - If you have already identified the user (forum, portal...) you can - force the user's nickname here, this will skip the "Please enter - your nickname" popup. - Warning : Nicknames must be encoded in UTF-8. For example, if you - get nicks from a databases where they are ISO-8859-1 encoded, you - must ocnvert it: $params["nick"] = iconv("ISO-8859-1", "UTF-8", - $bdd_nickname); (of course, change the $bdd_nickname parameter for - your needs) - ("" value by default, means users must choose a nickname when s/he - connect) - title - Used to change the chat title that is visible just above the - messages list. - ("My phpFreeChat" by default) - channel - Used to create a room. Technicaly this parameter is used to choose - the data (messages + nicknames) storage destination. For a better - explaination, see this FAQ entry[23]. - (auto-generated string based on the title parameter by default) - frozen_nick - Setting this to true will forbid the user to change his nickname - later. - (false value by default) - max_nick_len - This is the maximum nickname length, a longer nickname is forbidden. - ( 15 caracteres by default) - max_text_len - This is the maximum message length, a longer message is forbidden. - ( 250 characters by default) - refresh_delay - This is the time to wait between two refreshes. A refresh is a HTTP - request which asks the server if there are new messages to display. - If there are no new messages, then a empty HTTP response is returned. - ( 5000ms = 5s by default) - timeout - This is the time of inactivity to wait before to considere to - disconnecte user (in milliseconds). - ( 20000ms = 20s by default) - max_msg - This is the message history length. When a user connects, he can see - the history. The number of messages s/he can see is defined by this - (20 lines by default) - connect_at_startup - Setting this to false will oblige user to click on the connect - button if s/he wants to chat. - (true value by default, means when the chat web page is open, a - connection to the chat is automaticaly performed) - start_minimized - Setting it to true will start the chat minimized. - (false value by default) - height - Height of the chat area. - (440px by default) - width - Width of the chat area. - ("" by default, means it's given by the CSS) - shownotice - Setting this to 0 will disable nickname change notices and - connect/disconnect notices. Setting it to 1 will only disable - connect/disconnect notices. Setting it to 2 will show all notice - types. - (2 by default) - nickmarker - Setting it to false will disable nickname colorization. - (true value by default) - clock - Setting it to false will hide the date/hour column. - (true value by default) - openlinknewwindow - Setting it to true will add the target="_blank" into parsed links. - This attribute is used to open the followed link in a new window. - (true value by default) - showwhosonline - Used to show/hide online users at startup. - (true value by default) - showsmileys - Used to show/hide the smiley list at startup. - (true value by default) - btn_sh_whosonline - Used to display or not the showwhosonline button. - (true value by default) - btn_sh_smileys - Used to display or not the showsmileys button. - (true value by default) - themeurl - Used to specify the theme root url (useful for url rewriting) - (this parameter is automaticaly calculated by default) - themepath - The absolute theme directory path. Sub directories must contains - themes directories. - (dirname(__FILE__)."/../themes" by default) - theme - This parameter specifies which theme this chat will use. - ("default" by default) - language - Used to specify the chat labels language. Accepted values are i18n/* - sub directories names. - (by default this is the local server language) - output_encoding - Useful to set a sepcific encoding for chat labels. This is really - useful when the Web page embedding the chat is not UTF-8 encoded. - This parameter should be the same as the chat web page. - (UTF-8 by default ) - container_type - Used to specify the used container. For the moment, only a file - container has been written but in the future several containers - (mysql, irc, msn, jabber...) will surely be available. - ("File" by default) - server_script_path and server_script_url - Used to specify the script which will handle asynchronous request. - Very useful when the chat (client) script is resource consuming (ex: - forum or portal chat integration). server_script_url must point to - the server script browable url (useful when using url rewriting). - (by default these parameters are auto-calculated) - client_script_path and client_script_url - Used to specify the script path which display the chat and load - every JavaScript libraries (the client side). Useful when the php - configuration is uncommon, this option can be used to force the - automatic detection process. client_script_url must point to the - client script browable url (useful when using url rewriting). - (by default these parameters are auto-detected) - useie7 - Setting this to false will disable IE7[24] scripts used to improve - display for the crappy Internet Explorer. - (true value by default) - ie7path - Specify the IE7 path. It's useful if you allready have a IE7 library - installed and you want to save bytes on your server. - (dirname(__FILE__)."/../lib/IE7_0_9" by default) - jspath - Specify the javascript libraries path (md5, cookie ...). - (dirname(__FILE__)."/../lib/javascript" by default) - smartypath - Specify the Smarty[25] path. It's useful if you allready have a - Smarty library installed and you want to save bytes on your server. - (dirname(__FILE__)."/../lib/Smarty-2.6.7" by default) - usecsstidy - Setting this to false will disable CSSTidy library, css optimisation - (output size) will be disabled. - (false value by default because it make problems on strange server - configurations) - csstidypath - Specify the CSS Tidy[26] library path. It's useful if you allready - have a Smarty library installed and you want to save bytes on your - server. - (dirname(__FILE__)."/../lib/csstidy-1.1" by default) - xajaxpath - Specify the xajax[27] path. It's useful if you allready have a xajax - library installed and you want to save bytes on your server. - (dirname(__FILE__)."/../lib/xajax_0.2_stable" by default); - data_private_path - Used by the filesystem container to store chat data. Used by smarty - to store compiled templates. Tip: you can optimize your chat - performances, see this FAQ entry[28]. - (dirname(__FILE__)."/../data/private" by default) - data_public_path and data_public_url - This path must be reachable by your web server. IE7 scripts and - xajax JS compiled scripts will be stored here. data_public_url - parameter can be specified to help when url rewriting is used. - (dirname(__FILE__)."/../data/public" by default) - debug - For developers, setting it to true will activate logging and - debuging console. - (false value by default) - debugxajax - For developers, setting it to true will activate xajax js popup used - to trace communication between client and server during ajax - requests. Useful to discover hidden bugs like php warnings on a ajax - request. - (false value by default) - prefix - Used to prefix all javascript functions, css ids and css class in - order to avoid variables overlaps. - ("phpfreechat_" by default) - - \xA92006 phpFreeChat - - - --------------------------------------------------------------- -List of References - -Document's URL: http://www.phpfreechat.net/install.en.html -[23] faq.en.html#multiple-channels -[24] http://dean.edwards.name/IE7/ -[25] http://smarty.php.net/ -[26] http://csstidy.sourceforge.net/index.php -[27] http://www.xajaxproject.org/ -[28] faq.en.html#tmpfs - Deleted: trunk/INSTALL.fr =================================================================== --- trunk/INSTALL.fr 2006-09-02 20:38:40 UTC (rev 724) +++ trunk/INSTALL.fr 2006-09-02 20:42:09 UTC (rev 725) @@ -1,345 +0,0 @@ - Installation - - Vous avez besoin de : - - * Un serveur Web (apache, IIS ...) avec le module php (4 ou 5) - * Un acces en \xE9criture sur ce serveur Web (ssh, FTP ou autre) - - Par d\xE9faut, vous n'avez pas besoin d'une base de donn\xE9e Mysql car des - simples fichiers sont utilis\xE9s pour stoquer les informations. - - * En avant! - * Configuration avanc\xE9e - - En avant! - - Pour les feignants: - - 1. T\xE9l\xE9chargez le script d'installation auto-extractible : - phpfreechat-x.x-setup.php[21] (la derni\xE8re version de pr\xE9f\xE9rence) - 2. Uploadez le script dans un r\xE9pertoire accessible par votre - navigateur (r\xE9pertoire publique) - 3. Lancez votre navigateur et ex\xE9cutez le script d'installation que - vous venez d'uploader, ceci devrait lancer une interface - d'installation, suivez alors les \xE9tapes ! - Astuce : supprimez le scripte d'installation une fois termin\xE9 pour - des raisons de s\xE9curit\xE9. - - Pour les utilisateurs avanc\xE9s ou pour ceux qui n'ont pas gzip install\xE9 - sur leur serveur: - - 1. T\xE9l\xE9chargez l'archive zip (ou tag.gz pour les utilisateurs linux) : - phpfreechat-x.x.zip[22] (la derni\xE8re version de pr\xE9f\xE9rence) - 2. D\xE9compressez l'archive localement et uploadez le r\xE9sultat sur votre - serveur dans un r\xE9pertoire accessible par votre navigateur. - Astuce: si vous avez un acc\xE8s SSH, je vous conseil d'uploader - l'archive tar.gz puis de la d\xE9compresser directement sur le serveur - avec la commande tar xzf phpfreechat-x.x.tar.gz - 3. Donnez les droits en \xE9criture aux r\xE9pertoires - phpfreechat-x.x/data/public et phpfreechat-x.x/data/private - Si vous utilisez FTP, voici les commandes: - CHMOD 777 phpfreechat-x.x/data/private - CHMOD 777 phpfreechat-x.x/data/public - - Si vous utilisez SSH, voici les commandes: - chmod a+w phpfreechat-x.x/data/* - - 4. Pour terminer : lancez votre navigateur et ouvrez le r\xE9pertoire - phpfreechat-x.x sur votre serveur ! - - Vous d\xE9sirez certainement param\xE9trer votre propre chat, pour cela prenez - exemple sur les scriptes du r\xE9pertoire phpfreechat-x.x/demo. - - Voila le script minimum pour que le chat fonctionne (inspir\xE9 de demo1) : - - <?php - - require_once "src/phpfreechat.class.php"; // pensez \xE0 ajuster le chemin - $params["serverid"] = md5(__FILE__); // permet d'identifier ce chat - $chat = new phpFreeChat($params); - - ?> - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - <html> - <head> - <title>phpFreeChat demo</title> - <?php $chat->printJavascript(); ?> - <?php $chat->printStyle(); ?> - </head> - <body> - <?php $chat->printChat(); ?> - </body> - </html> - - Configuration avanc\xE9e - - Le chat fonctionne tr\xE8s bien en laissant les param\xE8tres par d\xE9faut mais - de nombreuses options peuvent \xEAtre r\xE9gl\xE9es. Par exemple, pour changer le - temps de rafraichissement \xE0 2 secondes (par d\xE9faut c'est 5 secondes), - voila ce qu'il faut faire : - - <?php - - require_once "src/phpfreechat.class.php"; // ajustez le chemin - $params["serverid"] = md5(__FILE__); - $params["refresh_delay"] = 2000; // 2000ms = 2s - $chat = new phpFreeChat($params); - - ?> - [... copiez/coller le code HTML vu plus haut ...] - - Un autre exemple: vous souhaitez que vos utilisateur n'entrent pas de - pseudonymes \xE0 leur arriv\xE9 sur le chat et qu'un pseudo "invit\xE9" leur oit - assign\xE9 automatiquement (ceci est tr\xE8s utile pour integrer le chat dans - un forum, un portail ou tout autre syst\xE8me o\xF9 l'utilisateur est d\xE9ja - authentifi\xE9), voila ce qu'il faut faire : - - <?php - - require_once "src/phpfreechat.class.php"; // ajustez le chemin - $params["serverid"] = md5(__FILE__); - $params["nick"] = "guest"; // ce pseudo peut-\xEAtre r\xE9cup\xE9r\xE9 depuis une base de donn\xE9es - $chat = new phpFreeChat($params); - - ?> - [... copiez/coller le code HTML vu plus haut ...] - - Maintenant voyons la liste exaustive des param\xE8tres : - - serverid - C'est leur seule param\xE8tre obligatoire. C'est l'identifiant du chat, - "son IP" (comparable \xE0 l'adresse (host) d'un serveur IRC) utilis\xE9 - pour diff\xE9rencer ce chat d'un autre. Deux chats doivent avoir des - serverid diff\xE9rents. Si vous ne savez pas quoi mettre, ceci - fonctionnera dans la majorit\xE9 des cas : $params["serverid"] = - md5(__FILE__); - nick - Ce param\xE8tre est tr\xE8s utile si vous connaissez \xE0 l'avance les - pseudonymes des utilisateurs, par exemple si vous souhaitez int\xE9grer - le chat \xE0 un forum ou a un portail qui poss\xE8de d\xE9j\xE0 un syst\xE8me - d'authentification. Il suffit de renseigner le pseudonyme de - l'utilisateur concern\xE9 dans cette option et l'utilisateur sera alors - automatiquement connect\xE9 avec son pseudonyme, il n'aura pas \xE0 - choisir son pseudo lors de la premi\xE8re connexion. - Attention : Les pseudonymes doivent \xEAtre encod\xE9s en UTF-8. Si par - exemple vos pseudo viennent d'une base de donn\xE9e o\xF9 ils sont encod\xE9s - en ISO-8859-1, vous devez les convertir : $params["nick"] = - iconv("ISO-8859-1", "UTF-8", $bdd_nickname); (bien sur changez la - variable $bdd_nickname \xE0 votre convenance) - Remarque : Cette option peut-\xEAtre utilis\xE9e conjointement \xE0 l'option - frozen_nick pour emp\xEAcher l'utilisateur de changer de nom. - ("" par d\xE9faut, signifie que les utilisateurs doivent choisir leur - pseudonymes quand ils se connectent) - title - Permet de changer le titre du chat, c'est \xE0 dire le texte qui - s'affiche en haut. - ("My phpFreeChat" est la valeur par d\xE9faut) - channel - Permet de cr\xE9er un salon. Techniquement, ce param\xE8tre permet de - choisir o\xF9 vont \xEAtre stock\xE9s les messages et les pseudonymes du - chat. Pour une explication plus d\xE9taill\xE9es voyez le paragraphe - suivant[23] dans la FAQ. - (par d\xE9faut, il est calcul\xE9 automatiquement \xE0 partir du title) - frozen_nick - Mettre cette option \xE0 true va tout simplement emp\xEAcher les - utilisateurs de changer leur pseudonymes. Cela sous entends que le - pseudonyme \xE0 \xE9t\xE9 automatiquement assign\xE9 (voir l'option nick) - (false par d\xE9faut) - max_nick_len - C'est la longeur maximale que peut avoir un pseudonyme - (15de caract\xE8res par d\xE9faut) - max_text_len - C'est la longeur maximale que peut avoir un message. - ( 250 caract\xE8res par d\xE9faut) - refresh_delay - Ceci est le temps \xE0 attendre entre chaque rafrechissements. Un - rafrechissement correspond \xE0 une requete HTTP demandant au serveur - si il y a quelque chose de nouveau \xE0 afficher ou pas. S'il n'y a - rien de nouveau alors la r\xE9ponse HTTP est vide. - ( 5000ms = 5s par d\xE9faut) - timeout - Ceci est le temps d'inactivit\xE9 \xE0 attendre avant de d\xE9connecter un - utilisateur (en millisecondes). - ( 20000ms = 20s par d\xE9faut) - max_msg - Ceci est la taille de l'historique, c'est \xE0 dire le nombre de - messages gard\xE9s en m\xE9moire. Quand un utilisateur se connect, il voit - automatiquement les messages de l'historique. Le nombre de messages - qu'il voit est d\xE9finit par ce param\xE8tre - (20 lignes par d\xE9faut) - connect_at_startup - Mettre cette option \xE0 false obligera les utilisateurs \xE0 cliquer sur - l'icone de connexion pour tchater. - (true par d\xE9faut, signifie que les utilisateurs sont automatiquement - connect\xE9s lorsque la page du chat est ouverte) - start_minimized - Mettre cette option \xE0 true minimizera le chat au premier chargement - de la page. - (false par d\xE9faut) - height - Hauteur de la zone de chat - (440px par d\xE9faut) - width - Largeur de la zone de chat - ("" par d\xE9faut, signifie que la valeur est assign\xE9es dans les CSS) - shownotice - Trois valeurs sont possibles : 0 pour ne rien afficher (ni les - notices de connexion/deconnexion, ni les changements de pseudo), 1 - pour afficher seulement les changements de pseudo, 2 pour afficher - les changements de pseudo et les connexions/deconnexions. - (2 par d\xE9faut) - nickmarker - Mettre cette option \xE0 false d\xE9sactivera la colorisation des - pseudonymes. - (true par d\xE9faut) - clock - Mettre cette option \xE0 false d\xE9sactivera l'affichage de la date et de - l'heure. - (true par d\xE9faut) - openlinknewwindow - Mettre cette option \xE0 true permettra d'ouvrire les liens des - convertations dans une nouvelle fen\xEAtre. Techniquement cela rajoute - l'attribut target="_blank" dans la balise du lien. - (true par d\xE9faut) - showwhosonline - Permet de cacher/montrer la liste des utilisateurs connect\xE9s lors du - premier affichage du chat. - Utilisez btn_sh_whosonline pour d\xE9sactiver compl\xE8tement la - possibilit\xE9 de voir la liste des pseudonymes. - (true par d\xE9faut) - showsmileys - Permet de cacher/montrer la liste des smileys lors du premier - affichage du chat. - Utilisez btn_sh_smileys pour d\xE9sactiver compl\xE8tement la possibilit\xE9 - de voir la liste des smileys. - (true par d\xE9faut) - btn_sh_whosonline - Permet de cacher ou montrer le bouton showwhosonline (celui qui - permet de cacher/montrer la liste des pseudonymes) - (true par d\xE9faut) - btn_sh_smileys - Permet de cacher ou montrer le bouton showsmileys (celui qui permet - de cacher/montrer la liste des smileys) - (true par d\xE9faut) - themeurl - Permet de sp\xE9cifier l'url \xE0 utiliser pour acceder aux themes (tr\xE8s - utile pour la r\xE9\xE9criture d'url) - (ce param\xE8tre est automatiquement calcul\xE9 en fonction de themepath - themepath - Le chemin vers les themes. Les sous r\xE9pertoires sont les diff\xE9rents - thems disponibles. - (dirname(__FILE__)."/../themes" par d\xE9faut) - theme - Ce peram\xE8tre permet de sp\xE9cifier quelle theme utiliser. La liste des - themes possible sont les nom des sous r\xE9pertoires de themepath. - ("default" par d\xE9faut) - language - Permet d'afficher le chat dans une langue donn\xE9e. Les valeurs - possibles sont les nom des sous r\xE9pertoires de i18n. - (par d\xE9faut la langue est celle du serveur qui h\xE9berge le chat) - output_encoding - Permet de sp\xE9cifier l'encodage \xE0 utiliser pour afficher les labels. - Concretement ce param\xE8tre doit correspondre \xE0 l'encodage de la page - Web contenant le chat. - (par d\xE9faut UTF-8, c'est \xE0 dire aucun transcodage car les messages - sont stoqu\xE9s en UTF-8 par d\xE9faut) - container_type - Permet de sp\xE9ficier le conteneur \xE0 utiliser. Pour le moment, seul le - conteneur File (syst\xE8me de fichier) est disponible mais dans le - future de nombreux conteneurs existerons surrement (mysql, irc, msn, - jabber...). - ("File" par d\xE9faut) - server_script_path et server_script_url - Ces param\xE8tres permettent de sp\xE9cifier un script externe qui sera - charg\xE9 des communication client/serveur du chat. Ce param\xE8tre est - tr\xE8s utile lorsque le script du chat (client) consomme beaucoup de - ressources (voyez la demo3 pour un exemple concret). Le premier - param\xE8tre sp\xE9cifie l'endroit du fichier lui m\xEAme, le second - param\xE8tre indique l'url o\xF9 est situ\xE9 le fichier (utile pour la - r\xE9\xE9criture d'url) - (par d\xE9faut on utilise le m\xEAme scripte que le script client pour les - communications) - client_script_path et client_script_url - Ces param\xE8tres sont utilis\xE9s pour sp\xE9cifier le chemin du script qui - va afficher le chat (script client). Ces options peuvent \xEAtre utile - lorsque la configuration du serveur est peu commune. Le premier - param\xE8tre sp\xE9cifie l'endroit du fichier lui m\xEAme, le second - param\xE8tre indique l'url o\xF9 est situ\xE9 le fichier (utile pour la - r\xE9\xE9criture d'url) - (par d\xE9faut pfc va essayer d'auto-detecter le script client en - fonction des variables globales du serveur) - useie7 - Mettre ce param\xE8tre \xE0 false d\xE9sactivera l'ajout des scripts IE7[24] - permettant un meilleur affichage dans Internet Explorer. - (true par d\xE9faut) - ie7path - Sp\xE9cifie le r\xE9pertoire vers la librairie IE7. Ce param\xE8tre est utile - si vous avez d\xE9j\xE0 install\xE9 une librairie smarty et que vous voulez - \xE9conomiser des octets sur votre serveur. - (dirname(__FILE__)."/../lib/IE7_0_9" par d\xE9faut) - jspath - Sp\xE9cifie le r\xE9pertoire vers les librairies javascript (md5, cookie - ...). - (dirname(__FILE__)."/../lib/javascript" par d\xE9faut) - usecsstidy - Mettre ce param\xE8tre \xE0 false d\xE9sactivera l'utilisation de la - librairie CSSTidy utilis\xE9e pour optimiser (en taille) la g\xE9n\xE9ration - des CSS. - (false par d\xE9faut car sur certains serveur la librarie CSSTidy pose - des probl\xE8mes) - csstidypath - Sp\xE9cifie le r\xE9pertoire vers la librairie CSS Tidy[25]. Ce param\xE8tre - est utile si vous avez d\xE9j\xE0 install\xE9 une librairie csstidy et que - vous voulez \xE9conomiser des octets sur votre serveur. - (dirname(__FILE__)."/../lib/csstidy-1.1" par d\xE9faut) - xajaxpath - Sp\xE9cifie le r\xE9pertoire vers la librairie xajax[26]. Ce param\xE8tre est - utile si vous avez d\xE9j\xE0 install\xE9 une librairie xajax et que vous - voulez \xE9conomiser des octets sur votre serveur. - (dirname(__FILE__)."/../lib/xajax_0.2_stable" par d\xE9faut) - data_private_path - Ce r\xE9pertoire est utilis\xE9 pour stoqu\xE9 les donn\xE9es du chat ainsi que - les templates compil\xE9s de smarty. Astuce: vous pouvez optimisez les - performances cot\xE9 serveur en sp\xE9cifiant un r\xE9pertoire en m\xE9moire - vive (RAM disk, tmpfs), voyez cette section dans la FAQ[27]. - (dirname(__FILE__)."/../data/private" par d\xE9faut) - data_public_path et data_public_url - Ce r\xE9pertoire doit \xEAtre imp\xE9rativement accessible par votre serveur - Web. Les scripts IE7 et xajax necessaires au chat y seront stock\xE9s. - Le premier param\xE8tre indique le r\xE9pertoire absolue au niveau syst\xE8me - de fichier, et le second indique l'url pour y acceder depuis le - navigateur (utile pour la r\xE9\xE9critude d'url) - (dirname(__FILE__)."/../data/public" par d\xE9faut, data_public_url lui - est calcul\xE9 automatiquement) - debug - Cette option est tr\xE8s utile pour les d\xE9veloppeurs. La mettre \xE0 true - va activer les messages de log et la console de debug. - (false par d\xE9faut) - debugxajax - Cette option est tr\xE8s utile pour d\xE9couvrire les bug cach\xE9s (warning - php lors d'une requete xajax par exemple) . Mettre cette option \xE0 - true va activer les popup javascript de xajax pour tracer la - communication client/serveur. - (false par d\xE9faut) - prefix - Ce prefix est utilis\xE9 pour chaques fonctions javascript, chaque id - CSS et chaques classes CSS de fa\xE7on \xE0 \xE9viter les recouvrements de - variables entre phpfreechat et votre site web. - ("phpfreechat_" par d\xE9faut) - - - - \xA92006 phpFreeChat - - - --------------------------------------------------------------- -List of References - -Document's URL: http://www.phpfreechat.net/install.fr.html -[23] faq.fr.html#multiple-channels -[24] http://dean.edwards.name/IE7/ -[25] http://csstidy.sourceforge.net/index.php -[26] http://www.xajaxproject.org/ -[27] faq.fr.html#tmpfs Deleted: trunk/README.en =================================================================== --- trunk/README.en 2006-09-02 20:38:40 UTC (rev 724) +++ trunk/README.en 2006-09-02 20:42:09 UTC (rev 725) @@ -1,64 +0,0 @@ -phpFreeChat, a free, simple, fast and customizable chat server - - Simple - You only have to copy/paste 3 lines of code[21] to have a nice - working chat. - No need to configure a database (Mysql), messages and nicknames are - stored in files. - No problems with firewalls, this script is based on HTTP so you only - need a web browser and an internet connection. (everyone can easily - chat!) - No problems with none-latin characteres ! Are you Russian, Japanese, - Turk, Chinese, or Arabic? Whatever language you speak, phpfreechat - will nicely display your characters because it uses XML with UTF8 to - encode characters. - Fast - AJAX technology is used to smoothly refresh (no flicker) and display - the chat and nickname zone. - Messages and nicknames are stored into a simple filesystem, so that - server resources are saved as much as possible. - Bandwidth is preserved because the server never transmits the same - data twice, only new messages are transmitted. - Customizable - You can write your own customized CSS stylesheets, to completely - change the appearance[22] of your chat. - All chat functionalities are customizable. For example, you can - change the messages refresh time, you can ban users for changing - their usernames, etc. - The plugin system[23] allows you to write your own storage routines. - For example, you can write a plugin to store the conversations into - your database. - Opensource - phpFreeChat is an opensource (LGPL) program, so that you can freely - use it and modify it. - I just ask, by gratitude, to keep the linkback logo on the pages of - your chat. - - All phpFreeChat commands are inspired by the irc[24] protocol, and its - interface is inspired by mIRC[25] and XChat[26], so that users won't be - disoriented. - - Techonologies used by phpFreeChat are: - - * PHP[27] : on the server side : conversations are simply stored in - filesystems. - * XAJAX[28] : for the asynchronous communication between the client - and the server - - (phpFreeChat does NOT require MySQL, or any SQL database) - - \xA92006 phpFreeChat - - --------------------------------------------------------------- -List of References - -Document's URL: http://www.phpfreechat.net/overview.en.html -[22] customize.en.html#cust-css -[23] customize.en.html#container-plug -[24] http://www.irc.org -[25] http://www.mirc.com/ -[26] http://www.xchat.org/ -[27] http://www.php.net/ -[28] http://www.xajaxproject.org/ - Deleted: trunk/README.fr =================================================================== --- trunk/README.fr 2006-09-02 20:38:40 UTC (rev 724) +++ trunk/README.fr 2006-09-02 20:42:09 UTC (rev 725) @@ -1,67 +0,0 @@ - -phpFreeChat un serveur de chat libre, simple, rapide et param\xE9trable - - Simple - Vous avez seulement 3 lignes de php \xE0 copier/coller[21] dans la page - de votre choix pour obtenir un chat fonctionnel. - En effet, pas besoin de param\xE9trer une base de donn\xE9e Mysql, les - conversations sont stock\xE9es simplement dans des fichiers. - Le chat fontionnera chez tout le monde car il est bas\xE9 sur HTTP, il - vous suffit donc d'avoir un navigateur Web connect\xE9 \xE0 internet pour - pouvoir chatter. - Tous les jeux de caract\xE8res sont support\xE9s ! Que vous soyez Russe, - Japonais, Turque, Chinois, ou Arabe, tous les caract\xE8res - s'afficheront car phpfreechat utilise XML coupl\xE9 \xE0 UTF8 pour encoder - les caract\xE8res. - Rapide - La technologie AJAX est utilis\xE9e pour afficher p\xE9riodiquement et - sans effets de clignotement les nouveaux messages et les nouvelles - personnes connect\xE9es. - Les conversations sont stock\xE9es dans des fichiers, les ressources du - serveur sont donc \xE9conomis\xE9es au maximum. - La bande passante est \xE9conomis\xE9e car le serveur ne transmettra - jamais deux fois les m\xEAmes informations : seulement les nouveaux - messages sont transmis. - Param\xE9trable - Vous pouvez \xE9crire vos feuilles de style (CSS) personnalis\xE9es pour - changer compl\xE8tement l'apparence[22] de votre chat. - Toutes les fonctionnalit\xE9s du chat ont \xE9t\xE9 rendues param\xE9trables. - Par exemple, vous pouvez changer le temps de mise \xE0 jour des - messages, vous pouvez interdire aux utilisateurs de changer leur - pseudo... - Vous pouvez \xE9galement, gr\xE2ce au syst\xE8me de plugin[23], \xE9crire vos - propres routines de stockage si vous pr\xE9f\xE9rez stocker les - conversations dans votre base de donn\xE9es. - Libre - phpFreeChat est d\xE9velopp\xE9 en opensource (LGPL), vous pouvez donc - librement utiliser le programme et le modifier. - Je demande juste, par gratitude, de ne pas enlever la signature logo - sur les pages de votre chat. - - Toutes les commandes de phpFreeChat sont inspir\xE9es du protocole irc[24], - et son interface est inspir\xE9e de mIRC[25] et XChat[26], vos utilisateurs - ne seront donc pas d\xE9pays\xE9s. - - Les technologies utilis\xE9es par phpFreeChat sont : - - * php[27] : pour le cot\xE9 serveur, les conversations sont simplement - enregistr\xE9es dans des fichiers - * xajax[28] : pour la communication asynchrone entre le client et le - serveur - - (phpFreeChat n'utilise PAS mysql) - - \xA92006 phpFreeChat - - --------------------------------------------------------------- -List of References - -Document's URL: http://www.phpfreechat.net/overview.fr.html -[22] customize.fr.html#custo-css -[23] customize.fr.html#container-plug -[24] http://www.irc.org -[25] http://www.mirc.com/ -[26] http://www.xchat.org/ -[27] http://www.php.net/ -[28] http://www.xajaxproject.org/ Modified: trunk/misc/tarSource =================================================================== --- trunk/misc/tarSource 2006-09-02 20:38:40 UTC (rev 724) +++ trunk/misc/tarSource 2006-09-02 20:42:09 UTC (rev 725) @@ -8,6 +8,20 @@ rm -rf ./$NAME svn export .. ./$NAME rm -rf ./$NAME/contrib +echo "-> downloading documentation" +wget http://www.phpfreechat.net/pages/fr/install.html -q -O ./$NAME/INSTALL.fr.html +wget http://www.phpfreechat.net/pages/en/install.html -q -O ./$NAME/INSTALL.en.html +wget http://www.phpfreechat.net/pages/fr/faq.html -q -O ./$NAME/FAQ.fr.html +wget http://www.phpfreechat.net/pages/en/faq.html -q -O ./$NAME/FAQ.en.html +wget http://www.phpfreechat.net/pages/fr/overview.html -q -O ./$NAME/OVERVIEW.fr.html +wget http://www.phpfreechat.net/pages/en/overview.html -q -O ./$NAME/OVERVIEW.en.html +wget http://www.phpfreechat.net/pages/ar/overview.html -q -O ./$NAME/OVERVIEW.ar.html +wget http://www.phpfreechat.net/pages/es/overview.html -q -O ./$NAME/OVERVIEW.es.html +wget http://www.phpfreechat.net/pages/zh/overview.html -q -O ./$NAME/OVERVIEW.zh.html +wget http://www.phpfreechat.net/pages/fr/customize.html -q -O ./$NAME/CUSTOMIZE.fr.html +wget http://www.phpfreechat.net/pages/en/customize.html -q -O ./$NAME/CUSTOMIZE.en.html +wget http://www.phpfreechat.net/pages/fr/changelog.html -q -O ./$NAME/CHANGELOG.fr.html +wget http://www.phpfreechat.net/pages/en/changelog.html -q -O ./$NAME/CHANGELOG.en.html echo "-> creating checkmd5.php file" ./checkmd5 ./$NAME ./$NAME/checkmd5.php Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-09-02 20:38:40 UTC (rev 724) +++ trunk/src/pfcglobalconfig.class.php 2006-09-02 20:42:09 UTC (rev 725) @@ -391,24 +391,25 @@ $this->errors[] = _pfc("'%s' parameter is not valid. Available values are : '%s'", "language", implode(", ", $lg_list)); // install the proxy file - $proxyfile = $this->_getProxyFile(); - $allowedpath_string = ""; - $allowedpath_string .= "\$allowedpath[] = '".realpath(dirname(__FILE__)."/../lib")."';\n"; - $allowedpath_string .= "\$allowedpath[] = '".realpath(dirname(__FILE__)."/../src/client")."';\n"; - $allowedpath_string .= "\$allowedpath[] = '".realpath($this->themepath_default)."/..';\n"; - $allowedpath_string .= "\$allowedpath[] = '".realpath($this->themepath_default)."';\n"; - $allowedpath_string .= "\$allowedpath[] = '".realpath($this->themepath)."/..';\n"; - $allowedpath_string .= "\$allowedpath[] = '".realpath($this->themepath)."';\n"; - $proxycontent = file_get_contents(dirname(__FILE__)."/client/proxy.php.tpl"); - $proxycontent = str_replace("//%allowedpath%", $allowedpath_string, $proxycontent); - if (!file_exists(dirname($proxyfile))) - mkdir(dirname($proxyfile)); - if (file_exists($proxyfile) && - !is_writable($proxyfile)) - $this->errors[] = _pfc("'%s' must be writable", $proxyfile); - else + if (count($this->errors) == 0) { - file_put_contents($proxyfile, $proxycontent); + $proxyfile = $this->_getProxyFile(); + $allowedpath_string = ""; + $allowedpath_string .= "\$allowedpath[] = '".realpath(dirname(__FILE__)."/../lib")."';\n"; + $allowedpath_string .= "\$allowedpath[] = '".realpath(dirname(__FILE__)."/../src/client")."';\n"; + $allowedpath_string .= "\$allowedpath[] = '".realpath($this->themepath_default)."/..';\n"; + $allowedpath_string .= "\$allowedpath[] = '".realpath($this->themepath_default)."';\n"; + $allowedpath_string .= "\$allowedpath[] = '".realpath($this->themepath)."/..';\n"; + $allowedpath_string .= "\$allowedpath[] = '".realpath($this->themepath)."';\n"; + $proxycontent = file_get_contents(dirname(__FILE__)."/client/proxy.php.tpl"); + $proxycontent = str_replace("//%allowedpath%", $allowedpath_string, $proxycontent); + if (!file_exists(dirname($proxyfile))) + @mkdir(dirname($proxyfile)); + if (file_exists($proxyfile) && + !is_writable($proxyfile)) + $this->errors[] = _pfc("'%s' must be writable", $proxyfile); + else + @file_put_contents($proxyfile, $proxycontent); } // load smileys from file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-03 09:02:31
|
Revision: 727 http://svn.sourceforge.net/phpfreechat/?rev=727&view=rev Author: kerphi Date: 2006-09-03 02:02:19 -0700 (Sun, 03 Sep 2006) Log Message: ----------- [en] Replace utf8_substr code by a less system dependant one coming from typo3 code. [fr]Remplacement de la fonction utf8_substr par du code venant de typo3 moins d?\195?\169pendant du syst?\195?\168me, en particulier l'ancien code d?\195?\169pendait de preg_match_all qui devait ?\195?\170tre compil?\195?\169 avec le support utf8. Modified Paths: -------------- trunk/src/phpfreechat.class.php Added Paths: ----------- trunk/lib/utf8/utf8_char2byte_pos.php trunk/lib/utf8/utf8_substr.php Removed Paths: ------------- trunk/lib/utf8/utf8.php Deleted: trunk/lib/utf8/utf8.php =================================================================== --- trunk/lib/utf8/utf8.php 2006-09-02 21:20:15 UTC (rev 726) +++ trunk/lib/utf8/utf8.php 2006-09-03 09:02:19 UTC (rev 727) @@ -1,820 +0,0 @@ -<?php -/** - * UTF8 helper functions - * - * @license LGPL (http://www.gnu.org/copyleft/lesser.html) - * @author Andreas Gohr <an...@sp...> - */ - -/** - * URL-Encode a filename to allow unicodecharacters - * - * Slashes are not encoded - * - * When the second parameter is true the string will - * be encoded only if non ASCII characters are detected - - * This makes it safe to run it multiple times on the - * same string (default is true) - * - * @author Andreas Gohr <an...@sp...> - * @see urlencode - */ -function utf8_encodeFN($file,$safe=true){ - if($safe && preg_match('#^[a-zA-Z0-9/_\-.%]+$#',$file)){ - return $file; - } - $file = urlencode($file); - $file = str_replace('%2F','/',$file); - return $file; -} - -/** - * URL-Decode a filename - * - * This is just a wrapper around urldecode - * - * @author Andreas Gohr <an...@sp...> - * @see urldecode - */ -function utf8_decodeFN($file){ - $file = urldecode($file); - return $file; -} - -/** - * Checks if a string contains 7bit ASCII only - * - * @author Andreas Gohr <an...@sp...> - */ -function utf8_isASCII($str){ - for($i=0; $i<strlen($str); $i++){ - if(ord($str{$i}) >127) return false; - } - return true; -} - -/** - * Strips all highbyte chars - * - * Returns a pure ASCII7 string - * - * @author Andreas Gohr <an...@sp...> - */ -function utf8_strip($str){ - $ascii = ''; - for($i=0; $i<strlen($str); $i++){ - if(ord($str{$i}) <128){ - $ascii .= $str{$i}; - } - } - return $ascii; -} - -/** - * Tries to detect if a string is in Unicode encoding - * - * @author <bm...@ss...> - * @link http://www.php.net/manual/en/function.utf8-encode.php - */ -function utf8_check($Str) { - for ($i=0; $i<strlen($Str); $i++) { - if (ord($Str[$i]) < 0x80) continue; # 0bbbbbbb - elseif ((ord($Str[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb - elseif ((ord($Str[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb - elseif ((ord($Str[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb - elseif ((ord($Str[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb - elseif ((ord($Str[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b - else return false; # Does not match any model - for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ? - if ((++$i == strlen($Str)) || ((ord($Str[$i]) & 0xC0) != 0x80)) - return false; - } - } - return true; -} - -/** - * Unicode aware replacement for strlen() - * - * utf8_decode() converts characters that are not in ISO-8859-1 - * to '?', which, for the purpose of counting, is alright - It's - * even faster than mb_strlen. - * - * @author <chernyshevsky at hotmail dot com> - * @see strlen() - * @see utf8_decode() - */ -function utf8_strlen($string){ - return strlen(utf8_decode($string)); -} - -/** - * Unicode aware replacement for substr() - * - * @author lmak at NOSPAM dot iti dot gr - * @link http://www.php.net/manual/en/function.substr.php - * @see substr() - */ -function utf8_substr($str,$start,$length=null){ - preg_match_all("/./u", $str, $ar); - - if($length != null) { - return join("",array_slice($ar[0],$start,$length)); - } else { - return join("",array_slice($ar[0],$start)); - } -} - -/** - * Unicode aware replacement for substr_replace() - * - * @author Andreas Gohr <an...@sp...> - * @see substr_replace() - */ -function utf8_substr_replace($string, $replacement, $start , $length=0 ){ - $ret = ''; - if($start>0) $ret .= utf8_substr($string, 0, $start); - $ret .= $replacement; - $ret .= utf8_substr($string, $start+$length); - return $ret; -} - -/** - * Unicode aware replacement for explode - * - * @TODO support third limit arg - * @author Harry Fuecks <hf...@gm...> - * @see explode(); - */ -function utf8_explode($sep, $str) { - if ( $sep == '' ) { - trigger_error('Empty delimiter',E_USER_WARNING); - return FALSE; - } - - return preg_split('!'.preg_quote($sep,'!').'!u',$str); -} - -/** - * Unicode aware replacement for strrepalce() - * - * @todo support PHP5 count (fourth arg) - * @author Harry Fuecks <hf...@gm...> - * @see strreplace(); - */ -function utf8_str_replace($s,$r,$str){ - if(!is_array($s)){ - $s = '!'.preg_quote($s,'!').'!u'; - }else{ - foreach ($s as $k => $v) { - $s[$k] = '!'.preg_quote($v).'!u'; - } - } - return preg_replace($s,$r,$str); -} - -/** - * Unicode aware replacement for ltrim() - * - * @author Andreas Gohr <an...@sp...> - * @see ltrim() - * @return string - */ -function utf8_ltrim($str,$charlist=''){ - if($charlist == '') return ltrim($str); - - //quote charlist for use in a characterclass - $charlist = preg_replace('!([\\\\\\-\\]\\[/])!','\\\${1}',$charlist); - - return preg_replace('/^['.$charlist.']+/u','',$str); -} - -/** - * Unicode aware replacement for rtrim() - * - * @author Andreas Gohr <an...@sp...> - * @see rtrim() - * @return string - */ -function utf8_rtrim($str,$charlist=''){ - if($charlist == '') return rtrim($str); - - //quote charlist for use in a characterclass - $charlist = preg_replace('!([\\\\\\-\\]\\[/])!','\\\${1}',$charlist); - - return preg_replace('/['.$charlist.']+$/u','',$str); -} - -/** - * Unicode aware replacement for trim() - * - * @author Andreas Gohr <an...@sp...> - * @see trim() - * @return string - */ -function utf8_trim($str,$charlist='') { - if($charlist == '') return trim($str); - - return utf8_ltrim(utf8_rtrim($str)); -} - - -/** - * This is a unicode aware replacement for strtolower() - * - * Uses mb_string extension if available - * - * @author Andreas Gohr <an...@sp...> - * @see strtolower() - * @see utf8_strtoupper() - */ -function utf8_strtolower($string){ - if(!defined('UTF8_NOMBSTRING') && function_exists('mb_strtolower')) - return mb_strtolower($string,'utf-8'); - - global $UTF8_UPPER_TO_LOWER; - $uni = utf8_to_unicode($string); - $cnt = count($uni); - for ($i=0; $i < $cnt; $i++){ - if($UTF8_UPPER_TO_LOWER[$uni[$i]]){ - $uni[$i] = $UTF8_UPPER_TO_LOWER[$uni[$i]]; - } - } - return unicode_to_utf8($uni); -} - -/** - * This is a unicode aware replacement for strtoupper() - * - * Uses mb_string extension if available - * - * @author Andreas Gohr <an...@sp...> - * @see strtoupper() - * @see utf8_strtoupper() - */ -function utf8_strtoupper($string){ - if(!defined('UTF8_NOMBSTRING') && function_exists('mb_strtolower')) - return mb_strtoupper($string,'utf-8'); - - global $UTF8_LOWER_TO_UPPER; - $uni = utf8_to_unicode($string); - $cnt = count($uni); - for ($i=0; $i < $cnt; $i++){ - if($UTF8_LOWER_TO_UPPER[$uni[$i]]){ - $uni[$i] = $UTF8_LOWER_TO_UPPER[$uni[$i]]; - } - } - return unicode_to_utf8($uni); -} - -/** - * Replace accented UTF-8 characters by unaccented ASCII-7 equivalents - * - * Use the optional parameter to just deaccent lower ($case = -1) or upper ($case = 1) - * letters. Default is to deaccent both cases ($case = 0) - * - * @author Andreas Gohr <an...@sp...> - */ -function utf8_deaccent($string,$case=0){ - if($case <= 0){ - global $UTF8_LOWER_ACCENTS; - $string = str_replace(array_keys($UTF8_LOWER_ACCENTS),array_values($UTF8_LOWER_ACCENTS),$string); - } - if($case >= 0){ - global $UTF8_UPPER_ACCENTS; - $string = str_replace(array_keys($UTF8_UPPER_ACCENTS),array_values($UTF8_UPPER_ACCENTS),$string); - } - return $string; -} - -/** - * Romanize a non-latin string - * - * @author Andreas Gohr <an...@sp...> - */ -function utf8_romanize($string){ - if(utf8_isASCII($string)) return $string; //nothing to do - - global $UTF8_ROMANIZATION; - return strtr($string,$UTF8_ROMANIZATION); -} - -/** - * Removes special characters (nonalphanumeric) from a UTF-8 string - * - * This function adds the controlchars 0x00 to 0x19 to the array of - * stripped chars (they are not included in $UTF8_SPECIAL_CHARS) - * - * @author Andreas Gohr <an...@sp...> - * @param string $string The UTF8 string to strip of special chars - * @param string $repl Replace special with this string - * @param string $additional Additional chars to strip (used in regexp char class) - */ -function utf8_stripspecials($string,$repl='',$additional=''){ - global $UTF8_SPECIAL_CHARS; - - static $specials = null; - if(is_null($specials)){ - $specials = preg_quote(unicode_to_utf8($UTF8_SPECIAL_CHARS), '/'); - } - - return preg_replace('/['.$additional.'\x00-\x19'.$specials.']/u',$repl,$string); -} - -/** - * This is an Unicode aware replacement for strpos - * - * Uses mb_string extension if available - * - * @author Harry Fuecks <hf...@gm...> - * @see strpos() - */ -function utf8_strpos($haystack, $needle,$offset=0) { - if(!defined('UTF8_NOMBSTRING') && function_exists('mb_strpos')) - return mb_strpos($haystack,$needle,$offset,'utf-8'); - - if(!$offset){ - $ar = utf8_explode($needle, $str); - if ( count($ar) > 1 ) { - return utf8_strlen($ar[0]); - } - return false; - }else{ - if ( !is_int($offset) ) { - trigger_error('Offset must be an integer',E_USER_WARNING); - return false; - } - - $str = utf8_substr($str, $offset); - - if ( false !== ($pos = utf8_strpos($str,$needle))){ - return $pos + $offset; - } - return false; - } -} - -/** - * Encodes UTF-8 characters to HTML entities - * - * @author <vpribish at shopping dot com> - * @link http://www.php.net/manual/en/function.utf8-decode.php - */ -function utf8_tohtml ($str) { - $ret = ''; - $max = strlen($str); - $last = 0; // keeps the index of the last regular character - for ($i=0; $i<$max; $i++) { - $c = $str{$i}; - $c1 = ord($c); - if ($c1>>5 == 6) { // 110x xxxx, 110 prefix for 2 bytes unicode - $ret .= substr($str, $last, $i-$last); // append all the regular characters we've passed - $c1 &= 31; // remove the 3 bit two bytes prefix - $c2 = ord($str{++$i}); // the next byte - $c2 &= 63; // remove the 2 bit trailing byte prefix - $c2 |= (($c1 & 3) << 6); // last 2 bits of c1 become first 2 of c2 - $c1 >>= 2; // c1 shifts 2 to the right - $ret .= '&#' . ($c1 * 100 + $c2) . ';'; // this is the fastest string concatenation - $last = $i+1; - } - } - return $ret . substr($str, $last, $i); // append the last batch of regular characters -} - -/** - * This function returns any UTF-8 encoded text as a list of - * Unicode values: - * - * @author Scott Michael Reynen <sc...@ra...> - * @link http://www.randomchaos.com/document.php?source=php_and_unicode - * @see unicode_to_utf8() - */ -function utf8_to_unicode( &$str ) { - $unicode = array(); - $values = array(); - $lookingFor = 1; - - for ($i = 0; $i < strlen( $str ); $i++ ) { - $thisValue = ord( $str[ $i ] ); - if ( $thisValue < 128 ) $unicode[] = $thisValue; - else { - if ( count( $values ) == 0 ) $lookingFor = ( $thisValue < 224 ) ? 2 : 3; - $values[] = $thisValue; - if ( count( $values ) == $lookingFor ) { - $number = ( $lookingFor == 3 ) ? - ( ( $values[0] % 16 ) * 4096 ) + ( ( $values[1] % 64 ) * 64 ) + ( $values[2] % 64 ): - ( ( $values[0] % 32 ) * 64 ) + ( $values[1] % 64 ); - $unicode[] = $number; - $values = array(); - $lookingFor = 1; - } - } - } - return $unicode; -} - -/** - * This function converts a Unicode array back to its UTF-8 representation - * - * @author Scott Michael Reynen <sc...@ra...> - * @link http://www.randomchaos.com/document.php?source=php_and_unicode - * @see utf8_to_unicode() - */ -function unicode_to_utf8( &$str ) { - if (!is_array($str)) return ''; - - $utf8 = ''; - foreach( $str as $unicode ) { - if ( $unicode < 128 ) { - $utf8.= chr( $unicode ); - } elseif ( $unicode < 2048 ) { - $utf8.= chr( 192 + ( ( $unicode - ( $unicode % 64 ) ) / 64 ) ); - $utf8.= chr( 128 + ( $unicode % 64 ) ); - } else { - $utf8.= chr( 224 + ( ( $unicode - ( $unicode % 4096 ) ) / 4096 ) ); - $utf8.= chr( 128 + ( ( ( $unicode % 4096 ) - ( $unicode % 64 ) ) / 64 ) ); - $utf8.= chr( 128 + ( $unicode % 64 ) ); - } - } - return $utf8; -} - -/** - * UTF-8 to UTF-16BE conversion. - * - * Maybe really UCS-2 without mb_string due to utf8_to_unicode limits - */ -function utf8_to_utf16be(&$str, $bom = false) { - $out = $bom ? "\xFE\xFF" : ''; - if(!defined('UTF8_NOMBSTRING') && function_exists('mb_convert_encoding')) - return $out.mb_convert_encoding($str,'UTF-16BE','UTF-8'); - - $uni = utf8_to_unicode($str); - foreach($uni as $cp){ - $out .= pack('n',$cp); - } - return $out; -} - -/** - * UTF-8 to UTF-16BE conversion. - * - * Maybe really UCS-2 without mb_string due to utf8_to_unicode limits - */ -function utf16be_to_utf8(&$str) { - $uni = unpack('n*',$str); - return unicode_to_utf8($uni); -} - -/** - * UTF-8 Case lookup table - * - * This lookuptable defines the upper case letters to their correspponding - * lower case letter in UTF-8 - * - * @author Andreas Gohr <an...@sp...> - */ -static $UTF8_LOWER_TO_UPPER = array( - 0x0061=>0x0041, 0x03C6=>0x03A6, 0x0163=>0x0162, 0x00E5=>0x00C5, 0x0062=>0x0042, - 0x013A=>0x0139, 0x00E1=>0x00C1, 0x0142=>0x0141, 0x03CD=>0x038E, 0x0101=>0x0100, - 0x0491=>0x0490, 0x03B4=>0x0394, 0x015B=>0x015A, 0x0064=>0x0044, 0x03B3=>0x0393, - 0x00F4=>0x00D4, 0x044A=>0x042A, 0x0439=>0x0419, 0x0113=>0x0112, 0x043C=>0x041C, - 0x015F=>0x015E, 0x0144=>0x0143, 0x00EE=>0x00CE, 0x045E=>0x040E, 0x044F=>0x042F, - 0x03BA=>0x039A, 0x0155=>0x0154, 0x0069=>0x0049, 0x0073=>0x0053, 0x1E1F=>0x1E1E, - 0x0135=>0x0134, 0x0447=>0x0427, 0x03C0=>0x03A0, 0x0438=>0x0418, 0x00F3=>0x00D3, - 0x0440=>0x0420, 0x0454=>0x0404, 0x0435=>0x0415, 0x0449=>0x0429, 0x014B=>0x014A, - 0x0431=>0x0411, 0x0459=>0x0409, 0x1E03=>0x1E02, 0x00F6=>0x00D6, 0x00F9=>0x00D9, - 0x006E=>0x004E, 0x0451=>0x0401, 0x03C4=>0x03A4, 0x0443=>0x0423, 0x015D=>0x015C, - 0x0453=>0x0403, 0x03C8=>0x03A8, 0x0159=>0x0158, 0x0067=>0x0047, 0x00E4=>0x00C4, - 0x03AC=>0x0386, 0x03AE=>0x0389, 0x0167=>0x0166, 0x03BE=>0x039E, 0x0165=>0x0164, - 0x0117=>0x0116, 0x0109=>0x0108, 0x0076=>0x0056, 0x00FE=>0x00DE, 0x0157=>0x0156, - 0x00FA=>0x00DA, 0x1E61=>0x1E60, 0x1E83=>0x1E82, 0x00E2=>0x00C2, 0x0119=>0x0118, - 0x0146=>0x0145, 0x0070=>0x0050, 0x0151=>0x0150, 0x044E=>0x042E, 0x0129=>0x0128, - 0x03C7=>0x03A7, 0x013E=>0x013D, 0x0442=>0x0422, 0x007A=>0x005A, 0x0448=>0x0428, - 0x03C1=>0x03A1, 0x1E81=>0x1E80, 0x016D=>0x016C, 0x00F5=>0x00D5, 0x0075=>0x0055, - 0x0177=>0x0176, 0x00FC=>0x00DC, 0x1E57=>0x1E56, 0x03C3=>0x03A3, 0x043A=>0x041A, - 0x006D=>0x004D, 0x016B=>0x016A, 0x0171=>0x0170, 0x0444=>0x0424, 0x00EC=>0x00CC, - 0x0169=>0x0168, 0x03BF=>0x039F, 0x006B=>0x004B, 0x00F2=>0x00D2, 0x00E0=>0x00C0, - 0x0434=>0x0414, 0x03C9=>0x03A9, 0x1E6B=>0x1E6A, 0x00E3=>0x00C3, 0x044D=>0x042D, - 0x0436=>0x0416, 0x01A1=>0x01A0, 0x010D=>0x010C, 0x011D=>0x011C, 0x00F0=>0x00D0, - 0x013C=>0x013B, 0x045F=>0x040F, 0x045A=>0x040A, 0x00E8=>0x00C8, 0x03C5=>0x03A5, - 0x0066=>0x0046, 0x00FD=>0x00DD, 0x0063=>0x0043, 0x021B=>0x021A, 0x00EA=>0x00CA, - 0x03B9=>0x0399, 0x017A=>0x0179, 0x00EF=>0x00CF, 0x01B0=>0x01AF, 0x0065=>0x0045, - 0x03BB=>0x039B, 0x03B8=>0x0398, 0x03BC=>0x039C, 0x045C=>0x040C, 0x043F=>0x041F, - 0x044C=>0x042C, 0x00FE=>0x00DE, 0x00F0=>0x00D0, 0x1EF3=>0x1EF2, 0x0068=>0x0048, - 0x00EB=>0x00CB, 0x0111=>0x0110, 0x0433=>0x0413, 0x012F=>0x012E, 0x00E6=>0x00C6, - 0x0078=>0x0058, 0x0161=>0x0160, 0x016F=>0x016E, 0x03B1=>0x0391, 0x0457=>0x0407, - 0x0173=>0x0172, 0x00FF=>0x0178, 0x006F=>0x004F, 0x043B=>0x041B, 0x03B5=>0x0395, - 0x0445=>0x0425, 0x0121=>0x0120, 0x017E=>0x017D, 0x017C=>0x017B, 0x03B6=>0x0396, - 0x03B2=>0x0392, 0x03AD=>0x0388, 0x1E85=>0x1E84, 0x0175=>0x0174, 0x0071=>0x0051, - 0x0437=>0x0417, 0x1E0B=>0x1E0A, 0x0148=>0x0147, 0x0105=>0x0104, 0x0458=>0x0408, - 0x014D=>0x014C, 0x00ED=>0x00CD, 0x0079=>0x0059, 0x010B=>0x010A, 0x03CE=>0x038F, - 0x0072=>0x0052, 0x0430=>0x0410, 0x0455=>0x0405, 0x0452=>0x0402, 0x0127=>0x0126, - 0x0137=>0x0136, 0x012B=>0x012A, 0x03AF=>0x038A, 0x044B=>0x042B, 0x006C=>0x004C, - 0x03B7=>0x0397, 0x0125=>0x0124, 0x0219=>0x0218, 0x00FB=>0x00DB, 0x011F=>0x011E, - 0x043E=>0x041E, 0x1E41=>0x1E40, 0x03BD=>0x039D, 0x0107=>0x0106, 0x03CB=>0x03AB, - 0x0446=>0x0426, 0x00FE=>0x00DE, 0x00E7=>0x00C7, 0x03CA=>0x03AA, 0x0441=>0x0421, - 0x0432=>0x0412, 0x010F=>0x010E, 0x00F8=>0x00D8, 0x0077=>0x0057, 0x011B=>0x011A, - 0x0074=>0x0054, 0x006A=>0x004A, 0x045B=>0x040B, 0x0456=>0x0406, 0x0103=>0x0102, - 0x03BB=>0x039B, 0x00F1=>0x00D1, 0x043D=>0x041D, 0x03CC=>0x038C, 0x00E9=>0x00C9, - 0x00F0=>0x00D0, 0x0457=>0x0407, 0x0123=>0x0122, -); - -/** - * UTF-8 Case lookup table - * - * This lookuptable defines the lower case letters to their correspponding - * upper case letter in UTF-8 (it does so by flipping $UTF8_LOWER_TO_UPPER) - * - * @author Andreas Gohr <an...@sp...> - */ -$UTF8_UPPER_TO_LOWER = @array_flip($UTF8_LOWER_TO_UPPER); - -/** - * UTF-8 lookup table for lower case accented letters - * - * This lookuptable defines replacements for accented characters from the ASCII-7 - * range. This are lower case letters only. - * - * @author Andreas Gohr <an...@sp...> - * @see utf8_deaccent() - */ -$UTF8_LOWER_ACCENTS = array( - 'à' => 'a', 'ô' => 'o', 'ď' => 'd', 'ḟ' => 'f', 'ë' => 'e', 'š' => 's', 'ơ' => 'o', - 'ß' => 'ss', 'ă' => 'a', 'ř' => 'r', 'ț' => 't', 'ň' => 'n', 'ā' => 'a', 'ķ' => 'k', - 'ŝ' => 's', 'ỳ' => 'y', 'ņ' => 'n', 'ĺ' => 'l', 'ħ' => 'h', 'ṗ' => 'p', 'ó' => 'o', - 'ú' => 'u', 'ě' => 'e', 'é' => 'e', 'ç' => 'c', 'ẁ' => 'w', 'ċ' => 'c', 'õ' => 'o', - 'ṡ' => 's', 'ø' => 'o', 'ģ' => 'g', 'ŧ' => 't', 'ș' => 's', 'ė' => 'e', 'ĉ' => 'c', - 'ś' => 's', 'î' => 'i', 'ű' => 'u', 'ć' => 'c', 'ę' => 'e', 'ŵ' => 'w', 'ṫ' => 't', - 'ū' => 'u', 'č' => 'c', 'ö' => 'oe', 'è' => 'e', 'ŷ' => 'y', 'ą' => 'a', 'ł' => 'l', - 'ų' => 'u', 'ů' => 'u', 'ş' => 's', 'ğ' => 'g', 'ļ' => 'l', 'ƒ' => 'f', 'ž' => 'z', - 'ẃ' => 'w', 'ḃ' => 'b', 'å' => 'a', 'ì' => 'i', 'ï' => 'i', 'ḋ' => 'd', 'ť' => 't', - 'ŗ' => 'r', 'ä' => 'ae', 'í' => 'i', 'ŕ' => 'r', 'ê' => 'e', 'ü' => 'ue', 'ò' => 'o', - 'ē' => 'e', 'ñ' => 'n', 'ń' => 'n', 'ĥ' => 'h', 'ĝ' => 'g', 'đ' => 'd', 'ĵ' => 'j', - 'ÿ' => 'y', 'ũ' => 'u', 'ŭ' => 'u', 'ư' => 'u', 'ţ' => 't', 'ý' => 'y', 'ő' => 'o', - 'â' => 'a', 'ľ' => 'l', 'ẅ' => 'w', 'ż' => 'z', 'ī' => 'i', 'ã' => 'a', 'ġ' => 'g', - 'ṁ' => 'm', 'ō' => 'o', 'ĩ' => 'i', 'ù' => 'u', 'į' => 'i', 'ź' => 'z', 'á' => 'a', - 'û' => 'u', 'þ' => 'th', 'ð' => 'dh', 'æ' => 'ae', 'µ' => 'u', -); - -/** - * UTF-8 lookup table for upper case accented letters - * - * This lookuptable defines replacements for accented characters from the ASCII-7 - * range. This are upper case letters only. - * - * @author Andreas Gohr <an...@sp...> - * @see utf8_deaccent() - */ -$UTF8_UPPER_ACCENTS = array( - 'À' => 'A', 'Ô' => 'O', 'Ď' => 'D', 'Ḟ' => 'F', 'Ë' => 'E', 'Š' => 'S', 'Ơ' => 'O', - 'Ă' => 'A', 'Ř' => 'R', 'Ț' => 'T', 'Ň' => 'N', 'Ā' => 'A', 'Ķ' => 'K', - 'Ŝ' => 'S', 'Ỳ' => 'Y', 'Ņ' => 'N', 'Ĺ' => 'L', 'Ħ' => 'H', 'Ṗ' => 'P', 'Ó' => 'O', - 'Ú' => 'U', 'Ě' => 'E', 'É' => 'E', 'Ç' => 'C', 'Ẁ' => 'W', 'Ċ' => 'C', 'Õ' => 'O', - 'Ṡ' => 'S', 'Ø' => 'O', 'Ģ' => 'G', 'Ŧ' => 'T', 'Ș' => 'S', 'Ė' => 'E', 'Ĉ' => 'C', - 'Ś' => 'S', 'Î' => 'I', 'Ű' => 'U', 'Ć' => 'C', 'Ę' => 'E', 'Ŵ' => 'W', 'Ṫ' => 'T', - 'Ū' => 'U', 'Č' => 'C', 'Ö' => 'Oe', 'È' => 'E', 'Ŷ' => 'Y', 'Ą' => 'A', 'Ł' => 'L', - 'Ų' => 'U', 'Ů' => 'U', 'Ş' => 'S', 'Ğ' => 'G', 'Ļ' => 'L', 'Ƒ' => 'F', 'Ž' => 'Z', - 'Ẃ' => 'W', 'Ḃ' => 'B', 'Å' => 'A', 'Ì' => 'I', 'Ï' => 'I', 'Ḋ' => 'D', 'Ť' => 'T', - 'Ŗ' => 'R', 'Ä' => 'Ae', 'Í' => 'I', 'Ŕ' => 'R', 'Ê' => 'E', 'Ü' => 'Ue', 'Ò' => 'O', - 'Ē' => 'E', 'Ñ' => 'N', 'Ń' => 'N', 'Ĥ' => 'H', 'Ĝ' => 'G', 'Đ' => 'D', 'Ĵ' => 'J', - 'Ÿ' => 'Y', 'Ũ' => 'U', 'Ŭ' => 'U', 'Ư' => 'U', 'Ţ' => 'T', 'Ý' => 'Y', 'Ő' => 'O', - 'Â' => 'A', 'Ľ' => 'L', 'Ẅ' => 'W', 'Ż' => 'Z', 'Ī' => 'I', 'Ã' => 'A', 'Ġ' => 'G', - 'Ṁ' => 'M', 'Ō' => 'O', 'Ĩ' => 'I', 'Ù' => 'U', 'Į' => 'I', 'Ź' => 'Z', 'Á' => 'A', - 'Û' => 'U', 'Þ' => 'Th', 'Ð' => 'Dh', 'Æ' => 'Ae', -); - -/** - * UTF-8 array of common special characters - * - * This array should contain all special characters (not a letter or digit) - * defined in the various local charsets - it's not a complete list of non-alphanum - * characters in UTF-8. It's not perfect but should match most cases of special - * chars. - * - * The controlchars 0x00 to 0x19 are _not_ included in this array. The space 0x20 is! - * These chars are _not_ in the array either: _ (0x5f), : 0x3a, . 0x2e, - 0x2d, * 0x2a - * - * @author Andreas Gohr <an...@sp...> - * @see utf8_stripspecials() - */ -$UTF8_SPECIAL_CHARS = array( - 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f, 0x0020, 0x0021, 0x0022, 0x0023, - 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002b, 0x002c, - 0x002f, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f, 0x0040, 0x005b, - 0x005c, 0x005d, 0x005e, 0x0060, 0x007b, 0x007c, 0x007d, 0x007e, - 0x007f, 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, - 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f, 0x0090, 0x0091, 0x0092, - 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, - 0x009d, 0x009e, 0x009f, 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, - 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, 0x00b0, - 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba, - 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, 0x00d7, 0x00f7, 0x02c7, 0x02d8, 0x02d9, - 0x02da, 0x02db, 0x02dc, 0x02dd, 0x0300, 0x0301, 0x0303, 0x0309, 0x0323, 0x0384, - 0x0385, 0x0387, 0x03b2, 0x03c6, 0x03d1, 0x03d2, 0x03d5, 0x03d6, 0x05b0, 0x05b1, - 0x05b2, 0x05b3, 0x05b4, 0x05b5, 0x05b6, 0x05b7, 0x05b8, 0x05b9, 0x05bb, 0x05bc, - 0x05bd, 0x05be, 0x05bf, 0x05c0, 0x05c1, 0x05c2, 0x05c3, 0x05f3, 0x05f4, 0x060c, - 0x061b, 0x061f, 0x0640, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f, 0x0650, 0x0651, - 0x0652, 0x066a, 0x0e3f, 0x200c, 0x200d, 0x200e, 0x200f, 0x2013, 0x2014, 0x2015, - 0x2017, 0x2018, 0x2019, 0x201a, 0x201c, 0x201d, 0x201e, 0x2020, 0x2021, 0x2022, - 0x2026, 0x2030, 0x2032, 0x2033, 0x2039, 0x203a, 0x2044, 0x20a7, 0x20aa, 0x20ab, - 0x20ac, 0x2116, 0x2118, 0x2122, 0x2126, 0x2135, 0x2190, 0x2191, 0x2192, 0x2193, - 0x2194, 0x2195, 0x21b5, 0x21d0, 0x21d1, 0x21d2, 0x21d3, 0x21d4, 0x2200, 0x2202, - 0x2203, 0x2205, 0x2206, 0x2207, 0x2208, 0x2209, 0x220b, 0x220f, 0x2211, 0x2212, - 0x2215, 0x2217, 0x2219, 0x221a, 0x221d, 0x221e, 0x2220, 0x2227, 0x2228, 0x2229, - 0x222a, 0x222b, 0x2234, 0x223c, 0x2245, 0x2248, 0x2260, 0x2261, 0x2264, 0x2265, - 0x2282, 0x2283, 0x2284, 0x2286, 0x2287, 0x2295, 0x2297, 0x22a5, 0x22c5, 0x2310, - 0x2320, 0x2321, 0x2329, 0x232a, 0x2469, 0x2500, 0x2502, 0x250c, 0x2510, 0x2514, - 0x2518, 0x251c, 0x2524, 0x252c, 0x2534, 0x253c, 0x2550, 0x2551, 0x2552, 0x2553, - 0x2554, 0x2555, 0x2556, 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x255c, 0x255d, - 0x255e, 0x255f, 0x2560, 0x2561, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566, 0x2567, - 0x2568, 0x2569, 0x256a, 0x256b, 0x256c, 0x2580, 0x2584, 0x2588, 0x258c, 0x2590, - 0x2591, 0x2592, 0x2593, 0x25a0, 0x25b2, 0x25bc, 0x25c6, 0x25ca, 0x25cf, 0x25d7, - 0x2605, 0x260e, 0x261b, 0x261e, 0x2660, 0x2663, 0x2665, 0x2666, 0x2701, 0x2702, - 0x2703, 0x2704, 0x2706, 0x2707, 0x2708, 0x2709, 0x270c, 0x270d, 0x270e, 0x270f, - 0x2710, 0x2711, 0x2712, 0x2713, 0x2714, 0x2715, 0x2716, 0x2717, 0x2718, 0x2719, - 0x271a, 0x271b, 0x271c, 0x271d, 0x271e, 0x271f, 0x2720, 0x2721, 0x2722, 0x2723, - 0x2724, 0x2725, 0x2726, 0x2727, 0x2729, 0x272a, 0x272b, 0x272c, 0x272d, 0x272e, - 0x272f, 0x2730, 0x2731, 0x2732, 0x2733, 0x2734, 0x2735, 0x2736, 0x2737, 0x2738, - 0x2739, 0x273a, 0x273b, 0x273c, 0x273d, 0x273e, 0x273f, 0x2740, 0x2741, 0x2742, - 0x2743, 0x2744, 0x2745, 0x2746, 0x2747, 0x2748, 0x2749, 0x274a, 0x274b, 0x274d, - 0x274f, 0x2750, 0x2751, 0x2752, 0x2756, 0x2758, 0x2759, 0x275a, 0x275b, 0x275c, - 0x275d, 0x275e, 0x2761, 0x2762, 0x2763, 0x2764, 0x2765, 0x2766, 0x2767, 0x277f, - 0x2789, 0x2793, 0x2794, 0x2798, 0x2799, 0x279a, 0x279b, 0x279c, 0x279d, 0x279e, - 0x279f, 0x27a0, 0x27a1, 0x27a2, 0x27a3, 0x27a4, 0x27a5, 0x27a6, 0x27a7, 0x27a8, - 0x27a9, 0x27aa, 0x27ab, 0x27ac, 0x27ad, 0x27ae, 0x27af, 0x27b1, 0x27b2, 0x27b3, - 0x27b4, 0x27b5, 0x27b6, 0x27b7, 0x27b8, 0x27b9, 0x27ba, 0x27bb, 0x27bc, 0x27bd, - 0x27be, 0xf6d9, 0xf6da, 0xf6db, 0xf8d7, 0xf8d8, 0xf8d9, 0xf8da, 0xf8db, 0xf8dc, - 0xf8dd, 0xf8de, 0xf8df, 0xf8e0, 0xf8e1, 0xf8e2, 0xf8e3, 0xf8e4, 0xf8e5, 0xf8e6, - 0xf8e7, 0xf8e8, 0xf8e9, 0xf8ea, 0xf8eb, 0xf8ec, 0xf8ed, 0xf8ee, 0xf8ef, 0xf8f0, - 0xf8f1, 0xf8f2, 0xf8f3, 0xf8f4, 0xf8f5, 0xf8f6, 0xf8f7, 0xf8f8, 0xf8f9, 0xf8fa, - 0xf8fb, 0xf8fc, 0xf8fd, 0xf8fe, 0xfe7c, 0xfe7d, -); - -/** - * Romanization lookup table - * - * This lookup tables provides a way to transform strings written in a language - * different from the ones based upon latin letters into plain ASCII. - * - * Please note: this is not a scientific transliteration table. It only works - * oneway from nonlatin to ASCII and it works by simple character replacement - * only. Specialities of each language are not supported. - * - * @author Andreas Gohr <an...@sp...> - * @author Vitaly Blokhin <vi...@vi...> - * @link http://www.uconv.com/translit.htm - * @author Bisqwit <bi...@ik...> - * @link http://kanjidict.stc.cx/hiragana.php?src=2 - * @link http://www.translatum.gr/converter/greek-transliteration.htm - * @link http://en.wikipedia.org/wiki/Royal_Thai_General_System_of_Transcription - * @link http://www.btranslations.com/resources/romanization/korean.asp - */ -$UTF8_ROMANIZATION = array( - //russian cyrillic - 'а'=>'a','А'=>'A','б'=>'b','Б'=>'B','в'=>'v','В'=>'V','г'=>'g','Г'=>'G', - 'д'=>'d','Д'=>'D','е'=>'e','Е'=>'E','ё'=>'jo','Ё'=>'Jo','ж'=>'zh','Ж'=>'Zh', - 'з'=>'z','З'=>'Z','и'=>'i','И'=>'I','й'=>'j','Й'=>'J','к'=>'k','К'=>'K', - 'л'=>'l','Л'=>'L','м'=>'m','М'=>'M','н'=>'n','Н'=>'N','о'=>'o','О'=>'O', - 'п'=>'p','П'=>'P','р'=>'r','Р'=>'R','с'=>'s','С'=>'S','т'=>'t','Т'=>'T', - 'у'=>'u','У'=>'U','ф'=>'f','Ф'=>'F','х'=>'x','Х'=>'X','ц'=>'c','Ц'=>'C', - 'ч'=>'ch','Ч'=>'Ch','ш'=>'sh','Ш'=>'Sh','щ'=>'th','Щ'=>'Th','ъ'=>'qh', - 'Ъ'=>'Qh','ы'=>'y','Ы'=>'Y','ь'=>'q','Ь'=>'Q','э'=>'eh','Э'=>'Eh','ю'=>'ju', - 'Ю'=>'Ju','я'=>'ja','Я'=>'Ja', - // Ukrainian cyrillic - 'Ґ'=>'Gh','ґ'=>'gh','Є'=>'Je','є'=>'je','І'=>'I','і'=>'i','Ї'=>'Ji','ї'=>'ji', - // Georgian - 'ა'=>'a','ბ'=>'b','გ'=>'g','დ'=>'d','ე'=>'e','ვ'=>'v','ზ'=>'z','თ'=>'th', - 'ი'=>'i','კ'=>'p','ლ'=>'l','მ'=>'m','ნ'=>'n','ო'=>'o','პ'=>'p','ჟ'=>'zh', - 'რ'=>'r','ს'=>'s','ტ'=>'t','უ'=>'u','ფ'=>'ph','ქ'=>'kh','ღ'=>'gh','ყ'=>'q', - 'შ'=>'sh','ჩ'=>'ch','ც'=>'c','ძ'=>'dh','წ'=>'w','ჭ'=>'j','ხ'=>'x','ჯ'=>'jh', - 'ჰ'=>'xh', - //Sanskrit - 'अ'=>'a','आ'=>'ah','इ'=>'i','ई'=>'ih','उ'=>'u','ऊ'=>'uh','ऋ'=>'ry', - 'ॠ'=>'ryh','ऌ'=>'ly','ॡ'=>'lyh','ए'=>'e','ऐ'=>'ay','ओ'=>'o','औ'=>'aw', - 'अं'=>'amh','अः'=>'aq','क'=>'k','ख'=>'kh','ग'=>'g','घ'=>'gh','ङ'=>'nh', - 'च'=>'c','छ'=>'ch','ज'=>'j','झ'=>'jh','ञ'=>'ny','ट'=>'tq','ठ'=>'tqh', - 'ड'=>'dq','ढ'=>'dqh','ण'=>'nq','त'=>'t','थ'=>'th','द'=>'d','ध'=>'dh', - 'न'=>'n','प'=>'p','फ'=>'ph','ब'=>'b','भ'=>'bh','म'=>'m','य'=>'z','र'=>'r', - 'ल'=>'l','व'=>'v','श'=>'sh','ष'=>'sqh','स'=>'s','ह'=>'x', - //Hebrew - 'ב'=>'a','ג'=>'b','ד'=>'g','ה'=>'d','ו'=>'x','ז'=>'v','ח'=>'kh','ט'=>'th', - 'י'=>'y','ך'=>'k','כ'=>'k','ל'=>'l','ם'=>'m','מ'=>'m','ן'=>'n','נ'=>'n', - 'ס'=>'s','ע'=>'ah','ף'=>'p','פ'=>'p','ץ'=>'c','צ'=>'c','ק'=>'q','ר'=>'r', - 'ש'=>'sh','ת'=>'t', - //Arabic - 'ا'=>'a','ب'=>'b','ت'=>'t','ث'=>'th','ج'=>'g','ح'=>'xh','خ'=>'x','د'=>'d', - 'ذ'=>'dh','ر'=>'r','ز'=>'z','س'=>'s','ش'=>'sh','ص'=>'s\'','ض'=>'d\'', - 'ط'=>'t\'','ظ'=>'z\'','ع'=>'y','غ'=>'gh','ف'=>'f','ق'=>'q','ك'=>'k', - 'ل'=>'l','م'=>'m','ن'=>'n','ه'=>'x\'','و'=>'u','ي'=>'i', - - // Japanese hiragana - 'あ'=>'a','え'=>'e','い'=>'i','お'=>'o','う'=>'u','ば'=>'ba','べ'=>'be', - 'び'=>'bi','ぼ'=>'bo','ぶ'=>'bu','し'=>'ci','だ'=>'da','で'=>'de','ぢ'=>'di', - 'ど'=>'do','づ'=>'du','ふぁ'=>'fa','ふぇ'=>'fe','ふぃ'=>'fi','ふぉ'=>'fo', - 'ふ'=>'fu','が'=>'ga','げ'=>'ge','ぎ'=>'gi','ご'=>'go','ぐ'=>'gu','は'=>'ha', - 'へ'=>'he','ひ'=>'hi','ほ'=>'ho','ふ'=>'hu','じゃ'=>'ja','じぇ'=>'je', - 'じ'=>'ji','じょ'=>'jo','じゅ'=>'ju','か'=>'ka','け'=>'ke','き'=>'ki', - 'こ'=>'ko','く'=>'ku','ら'=>'la','れ'=>'le','り'=>'li','ろ'=>'lo','る'=>'lu', - 'ま'=>'ma','め'=>'me','み'=>'mi','も'=>'mo','む'=>'mu','な'=>'na','ね'=>'ne', - 'に'=>'ni','の'=>'no','ぬ'=>'nu','ぱ'=>'pa','ぺ'=>'pe','ぴ'=>'pi','ぽ'=>'po', - 'ぷ'=>'pu','ら'=>'ra','れ'=>'re','り'=>'ri','ろ'=>'ro','る'=>'ru','さ'=>'sa', - 'せ'=>'se','し'=>'si','そ'=>'so','す'=>'su','た'=>'ta','て'=>'te','ち'=>'ti', - 'と'=>'to','つ'=>'tu','ヴぁ'=>'va','ヴぇ'=>'ve','ヴぃ'=>'vi','ヴぉ'=>'vo', - 'ヴ'=>'vu','わ'=>'wa','うぇ'=>'we','うぃ'=>'wi','を'=>'wo','や'=>'ya','いぇ'=>'ye', - 'い'=>'yi','よ'=>'yo','ゆ'=>'yu','ざ'=>'za','ぜ'=>'ze','じ'=>'zi','ぞ'=>'zo', - 'ず'=>'zu','びゃ'=>'bya','びぇ'=>'bye','びぃ'=>'byi','びょ'=>'byo','びゅ'=>'byu', - 'ちゃ'=>'cha','ちぇ'=>'che','ち'=>'chi','ちょ'=>'cho','ちゅ'=>'chu','ちゃ'=>'cya', - 'ちぇ'=>'cye','ちぃ'=>'cyi','ちょ'=>'cyo','ちゅ'=>'cyu','でゃ'=>'dha','でぇ'=>'dhe', - 'でぃ'=>'dhi','でょ'=>'dho','でゅ'=>'dhu','どぁ'=>'dwa','どぇ'=>'dwe','どぃ'=>'dwi', - 'どぉ'=>'dwo','どぅ'=>'dwu','ぢゃ'=>'dya','ぢぇ'=>'dye','ぢぃ'=>'dyi','ぢょ'=>'dyo', - 'ぢゅ'=>'dyu','ぢ'=>'dzi','ふぁ'=>'fwa','ふぇ'=>'fwe','ふぃ'=>'fwi','ふぉ'=>'fwo', - 'ふぅ'=>'fwu','ふゃ'=>'fya','ふぇ'=>'fye','ふぃ'=>'fyi','ふょ'=>'fyo','ふゅ'=>'fyu', - 'ぎゃ'=>'gya','ぎぇ'=>'gye','ぎぃ'=>'gyi','ぎょ'=>'gyo','ぎゅ'=>'gyu','ひゃ'=>'hya', - 'ひぇ'=>'hye','ひぃ'=>'hyi','ひょ'=>'hyo','ひゅ'=>'hyu','じゃ'=>'jya','じぇ'=>'jye', - 'じぃ'=>'jyi','じょ'=>'jyo','じゅ'=>'jyu','きゃ'=>'kya','きぇ'=>'kye','きぃ'=>'kyi', - 'きょ'=>'kyo','きゅ'=>'kyu','りゃ'=>'lya','りぇ'=>'lye','りぃ'=>'lyi','りょ'=>'lyo', - 'りゅ'=>'lyu','みゃ'=>'mya','みぇ'=>'mye','みぃ'=>'myi','みょ'=>'myo','みゅ'=>'myu', - 'ん'=>'n','にゃ'=>'nya','にぇ'=>'nye','にぃ'=>'nyi','にょ'=>'nyo','にゅ'=>'nyu', - 'ぴゃ'=>'pya','ぴぇ'=>'pye','ぴぃ'=>'pyi','ぴょ'=>'pyo','ぴゅ'=>'pyu','りゃ'=>'rya', - 'りぇ'=>'rye','りぃ'=>'ryi','りょ'=>'ryo','りゅ'=>'ryu','しゃ'=>'sha','しぇ'=>'she', - 'し'=>'shi','しょ'=>'sho','しゅ'=>'shu','すぁ'=>'swa','すぇ'=>'swe','すぃ'=>'swi', - 'すぉ'=>'swo','すぅ'=>'swu','しゃ'=>'sya','しぇ'=>'sye','しぃ'=>'syi','しょ'=>'syo', - 'しゅ'=>'syu','てゃ'=>'tha','てぇ'=>'the','てぃ'=>'thi','てょ'=>'tho','てゅ'=>'thu', - 'つゃ'=>'tsa','つぇ'=>'tse','つぃ'=>'tsi','つょ'=>'tso','つ'=>'tsu','とぁ'=>'twa', - 'とぇ'=>'twe','とぃ'=>'twi','とぉ'=>'two','とぅ'=>'twu','ちゃ'=>'tya','ちぇ'=>'tye', - 'ちぃ'=>'tyi','ちょ'=>'tyo','ちゅ'=>'tyu','ヴゃ'=>'vya','ヴぇ'=>'vye','ヴぃ'=>'vyi', - 'ヴょ'=>'vyo','ヴゅ'=>'vyu','うぁ'=>'wha','うぇ'=>'whe','うぃ'=>'whi','うぉ'=>'who', - 'うぅ'=>'whu','ゑ'=>'wye','ゐ'=>'wyi','じゃ'=>'zha','じぇ'=>'zhe','じぃ'=>'zhi', - 'じょ'=>'zho','じゅ'=>'zhu','じゃ'=>'zya','じぇ'=>'zye','じぃ'=>'zyi','じょ'=>'zyo', - 'じゅ'=>'zyu', - // Japanese katakana - 'ア'=>'a','エ'=>'e','イ'=>'i','オ'=>'o','ウ'=>'u','バ'=>'ba','ベ'=>'be','ビ'=>'bi', - 'ボ'=>'bo','ブ'=>'bu','シ'=>'ci','ダ'=>'da','デ'=>'de','ヂ'=>'di','ド'=>'do', - 'ヅ'=>'du','ファ'=>'fa','フェ'=>'fe','フィ'=>'fi','フォ'=>'fo','フ'=>'fu','ガ'=>'ga', - 'ゲ'=>'ge','ギ'=>'gi','ゴ'=>'go','グ'=>'gu','ハ'=>'ha','ヘ'=>'he','ヒ'=>'hi','ホ'=>'ho', - 'フ'=>'hu','ジャ'=>'ja','ジェ'=>'je','ジ'=>'ji','ジョ'=>'jo','ジュ'=>'ju','カ'=>'ka', - 'ケ'=>'ke','キ'=>'ki','コ'=>'ko','ク'=>'ku','ラ'=>'la','レ'=>'le','リ'=>'li','ロ'=>'lo', - 'ル'=>'lu','マ'=>'ma','メ'=>'me','ミ'=>'mi','モ'=>'mo','ム'=>'mu','ナ'=>'na','ネ'=>'ne', - 'ニ'=>'ni','ノ'=>'no','ヌ'=>'nu','パ'=>'pa','ペ'=>'pe','ピ'=>'pi','ポ'=>'po','プ'=>'pu', - 'ラ'=>'ra','レ'=>'re','リ'=>'ri','ロ'=>'ro','ル'=>'ru','サ'=>'sa','セ'=>'se','シ'=>'si', - 'ソ'=>'so','ス'=>'su','タ'=>'ta','テ'=>'te','チ'=>'ti','ト'=>'to','ツ'=>'tu','ヴァ'=>'va', - 'ヴェ'=>'ve','ヴィ'=>'vi','ヴォ'=>'vo','ヴ'=>'vu','ワ'=>'wa','ウェ'=>'we','ウィ'=>'wi', - 'ヲ'=>'wo','ヤ'=>'ya','イェ'=>'ye','イ'=>'yi','ヨ'=>'yo','ユ'=>'yu','ザ'=>'za','ゼ'=>'ze', - 'ジ'=>'zi','ゾ'=>'zo','ズ'=>'zu','ビャ'=>'bya','ビェ'=>'bye','ビィ'=>'byi','ビョ'=>'byo', - 'ビュ'=>'byu','チャ'=>'cha','チェ'=>'che','チ'=>'chi','チョ'=>'cho','チュ'=>'chu', - 'チャ'=>'cya','チェ'=>'cye','チィ'=>'cyi','チョ'=>'cyo','チュ'=>'cyu','デャ'=>'dha', - 'デェ'=>'dhe','ディ'=>'dhi','デョ'=>'dho','デュ'=>'dhu','ドァ'=>'dwa','ドェ'=>'dwe', - 'ドィ'=>'dwi','ドォ'=>'dwo','ドゥ'=>'dwu','ヂャ'=>'dya','ヂェ'=>'dye','ヂィ'=>'dyi', - 'ヂョ'=>'dyo','ヂュ'=>'dyu','ヂ'=>'dzi','ファ'=>'fwa','フェ'=>'fwe','フィ'=>'fwi', - 'フォ'=>'fwo','フゥ'=>'fwu','フャ'=>'fya','フェ'=>'fye','フィ'=>'fyi','フョ'=>'fyo', - 'フュ'=>'fyu','ギャ'=>'gya','ギェ'=>'gye','ギィ'=>'gyi','ギョ'=>'gyo','ギュ'=>'gyu', - 'ヒャ'=>'hya','ヒェ'=>'hye','ヒィ'=>'hyi','ヒョ'=>'hyo','ヒュ'=>'hyu','ジャ'=>'jya', - 'ジェ'=>'jye','ジィ'=>'jyi','ジョ'=>'jyo','ジュ'=>'jyu','キャ'=>'kya','キェ'=>'kye', - 'キィ'=>'kyi','キョ'=>'kyo','キュ'=>'kyu','リャ'=>'lya','リェ'=>'lye','リィ'=>'lyi', - 'リョ'=>'lyo','リュ'=>'lyu','ミャ'=>'mya','ミェ'=>'mye','ミィ'=>'myi','ミョ'=>'myo', - 'ミュ'=>'myu','ン'=>'n','ニャ'=>'nya','ニェ'=>'nye','ニィ'=>'nyi','ニョ'=>'nyo', - 'ニュ'=>'nyu','ピャ'=>'pya','ピェ'=>'pye','ピィ'=>'pyi','ピョ'=>'pyo','ピュ'=>'pyu', - 'リャ'=>'rya','リェ'=>'rye','リィ'=>'ryi','リョ'=>'ryo','リュ'=>'ryu','シャ'=>'sha', - 'シェ'=>'she','シ'=>'shi','ショ'=>'sho','シュ'=>'shu','スァ'=>'swa','スェ'=>'swe', - 'スィ'=>'swi','スォ'=>'swo','スゥ'=>'swu','シャ'=>'sya','シェ'=>'sye','シィ'=>'syi', - 'ショ'=>'syo','シュ'=>'syu','テャ'=>'tha','テェ'=>'the','ティ'=>'thi','テョ'=>'tho', - 'テュ'=>'thu','ツャ'=>'tsa','ツェ'=>'tse','ツィ'=>'tsi','ツョ'=>'tso','ツ'=>'tsu', - 'トァ'=>'twa','トェ'=>'twe','トィ'=>'twi','トォ'=>'two','トゥ'=>'twu','チャ'=>'tya', - 'チェ'=>'tye','チィ'=>'tyi','チョ'=>'tyo','チュ'=>'tyu','ヴャ'=>'vya','ヴェ'=>'vye', - 'ヴィ'=>'vyi','ヴョ'=>'vyo','ヴュ'=>'vyu','ウァ'=>'wha','ウェ'=>'whe','ウィ'=>'whi', - 'ウォ'=>'who','ウゥ'=>'whu','ヱ'=>'wye','ヰ'=>'wyi','ジャ'=>'zha','ジェ'=>'zhe', - 'ジィ'=>'zhi','ジョ'=>'zho','ジュ'=>'zhu','ジャ'=>'zya','ジェ'=>'zye','ジィ'=>'zyi', - 'ジョ'=>'zyo','ジュ'=>'zyu', - - // "Greeklish" - 'Γ'=>'G','Δ'=>'E','Θ'=>'Th','Λ'=>'L','Ξ'=>'X','Π'=>'P','Σ'=>'S','Φ'=>'F','Ψ'=>'Ps', - 'γ'=>'g','δ'=>'e','θ'=>'th','λ'=>'l','ξ'=>'x','π'=>'p','σ'=>'s','φ'=>'f','ψ'=>'ps', - - // Thai - 'ก'=>'k','ข'=>'kh','ฃ'=>'kh','ค'=>'kh','ฅ'=>'kh','ฆ'=>'kh','ง'=>'ng','จ'=>'ch', - 'ฉ'=>'ch','ช'=>'ch','ซ'=>'s','ฌ'=>'ch','ญ'=>'y','ฎ'=>'d','ฏ'=>'t','ฐ'=>'th', - 'ฑ'=>'d','ฒ'=>'th','ณ'=>'n','ด'=>'d','ต'=>'t','ถ'=>'th','ท'=>'th','ธ'=>'th', - 'น'=>'n','บ'=>'b','ป'=>'p','ผ'=>'ph','ฝ'=>'f','พ'=>'ph','ฟ'=>'f','ภ'=>'ph', - 'ม'=>'m','ย'=>'y','ร'=>'r','ฤ'=>'rue','ฤๅ'=>'rue','ล'=>'l','ฦ'=>'lue', - 'ฦๅ'=>'lue','ว'=>'w','ศ'=>'s','ษ'=>'s','ส'=>'s','ห'=>'h','ฬ'=>'l','ฮ'=>'h', - 'ะ'=>'a','–ั'=>'a','รร'=>'a','า'=>'a','รร'=>'an','ำ'=>'am','–ิ'=>'i','–ี'=>'i', - '–ึ'=>'ue','–ื'=>'ue','–ุ'=>'u','–ู'=>'u','เะ'=>'e','เ–็'=>'e','เ'=>'e','แะ'=>'ae', - 'แ'=>'ae','โะ'=>'o','โ'=>'o','เาะ'=>'o','อ'=>'o','เอะ'=>'oe','เ–ิ'=>'oe', - 'เอ'=>'oe','เ–ียะ'=>'ia','เ–ีย'=>'ia','เ–ือะ'=>'uea','เ–ือ'=>'uea','–ัวะ'=>'ua', - '–ัว'=>'ua','ว'=>'ua','ใ'=>'ai','ไ'=>'ai','–ัย'=>'ai','ไย'=>'ai','าย'=>'ai', - 'เา'=>'ao','าว'=>'ao','–ุย'=>'ui','โย'=>'oi','อย'=>'oi','เย'=>'oei','เ–ือย'=>'ueai', - 'วย'=>'uai','–ิว'=>'io','เ–็ว'=>'eo','เว'=>'eo','แ–็ว'=>'aeo','แว'=>'aeo', - 'เ–ียว'=>'iao', - - // Korean - 'ㄱ'=>'k','ㅋ'=>'kh','ㄲ'=>'kk','ㄷ'=>'t','ㅌ'=>'th','ㄸ'=>'tt','ㅂ'=>'p', - 'ㅍ'=>'ph','ㅃ'=>'pp','ㅈ'=>'c','ㅊ'=>'ch','ㅉ'=>'cc','ㅅ'=>'s','ㅆ'=>'ss', - 'ㅎ'=>'h','ㅇ'=>'ng','ㄴ'=>'n','ㄹ'=>'l','ㅁ'=>'m', 'ㅏ'=>'a','ㅓ'=>'e','ㅗ'=>'o', - 'ㅜ'=>'wu','ㅡ'=>'u','ㅣ'=>'i','ㅐ'=>'ay','ㅔ'=>'ey','ㅚ'=>'oy','ㅘ'=>'wa','ㅝ'=>'we', - 'ㅟ'=>'wi','ㅙ'=>'way','ㅞ'=>'wey','ㅢ'=>'uy','ㅑ'=>'ya','ㅕ'=>'ye','ㅛ'=>'oy', - 'ㅠ'=>'yu','ㅒ'=>'yay','ㅖ'=>'yey', -); - -//Setup VIM: ex: et ts=2 enc=utf-8 : - Added: trunk/lib/utf8/utf8_char2byte_pos.php =================================================================== --- trunk/lib/utf8/utf8_char2byte_pos.php (rev 0) +++ trunk/lib/utf8/utf8_char2byte_pos.php 2006-09-03 09:02:19 UTC (rev 727) @@ -0,0 +1,45 @@ +<?php + +/** + * Translates a character position into an 'absolute' byte position. + * Unit tested by Kasper. + * (http://phpxref.com/xref/moodle/lib/typo3/class.t3lib_cs.php.source.html.gz) + * + * @param string UTF-8 string + * @param integer Character position (negative values start from the end) + * @return integer Byte position + * @author Martin Kutschker <mar...@bl...> + */ +function utf8_char2byte_pos($str,$pos) { + $n = 0; // number of characters found + $p = abs($pos); // number of characters wanted + + if ($pos >= 0) { + $i = 0; + $d = 1; + } else { + $i = strlen($str)-1; + $d = -1; + } + + for( ; strlen($str{$i}) && $n<$p; $i+=$d) { + $c = (int)ord($str{$i}); + if (!($c & 0x80)) // single-byte (0xxxxxx) + $n++; + elseif (($c & 0xC0) == 0xC0) // multi-byte starting byte (11xxxxxx) + $n++; + } + if (!strlen($str{$i})) return false; // offset beyond string length + + if ($pos >= 0) { + // skip trailing multi-byte data bytes + while ((ord($str{$i}) & 0x80) && !(ord($str{$i}) & 0x40)) { $i++; } + } else { + // correct offset + $i++; + } + + return $i; +} + +?> \ No newline at end of file Added: trunk/lib/utf8/utf8_substr.php =================================================================== --- trunk/lib/utf8/utf8_substr.php (rev 0) +++ trunk/lib/utf8/utf8_substr.php 2006-09-03 09:02:19 UTC (rev 727) @@ -0,0 +1,41 @@ +<?php + +require_once dirname(__FILE__)."/utf8_char2byte_pos.php"; + +/** + * Returns a part of a UTF-8 string. + * Unit-tested by Kasper and works 100% like substr() / mb_substr() for full range of $start/$len + * (http://phpxref.com/xref/moodle/lib/typo3/class.t3lib_cs.php.source.html.gz) + * + * @param string UTF-8 string + * @param integer Start position (character position) + * @param integer Length (in characters) + * @return string The substring + * @see substr() + * @author Martin Kutschker <mar...@bl...> + */ +function utf8_substr($str,$start,$len=null) { + if (!strcmp($len,'0')) return ''; + + $byte_start = utf8_char2byte_pos($str,$start); + if ($byte_start === false) { + if ($start > 0) { + return false; // $start outside string length + } else { + $start = 0; + } + } + + $str = substr($str,$byte_start); + + if ($len!=null) { + $byte_end = utf8_char2byte_pos($str,$len); + if ($byte_end === false) // $len outside actual string length + return $len<0 ? '' : $str; // When length is less than zero and exceeds, then we return blank string. + else + return substr($str,0,$byte_end); + } + else return $str; +} + +?> \ No newline at end of file Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-09-02 21:20:15 UTC (rev 726) +++ trunk/src/phpfreechat.class.php 2006-09-03 09:02:19 UTC (rev 727) @@ -24,7 +24,7 @@ require_once dirname(__FILE__)."/pfcglobalconfig.class.php"; require_once dirname(__FILE__)."/pfcuserconfig.class.php"; require_once dirname(__FILE__)."/pfctemplate.class.php"; -require_once dirname(__FILE__)."/../lib/utf8/utf8.php"; +require_once dirname(__FILE__)."/../lib/utf8/utf8_substr.php"; /** * phpFreeChat is the entry point for developpers @@ -228,7 +228,7 @@ $c =& pfcGlobalConfig::Instance(); //$nickname = str_replace("\\", "", $nickname); // '\' is a forbidden charactere for nicknames $nickname = trim($nickname); - $nickname = @utf8_substr($nickname, 0, $c->max_nick_len); + $nickname = utf8_substr($nickname, 0, $c->max_nick_len); return $nickname; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-06 06:53:13
|
Revision: 736 http://svn.sourceforge.net/phpfreechat/?rev=736&view=rev Author: kerphi Date: 2006-09-05 23:53:04 -0700 (Tue, 05 Sep 2006) Log Message: ----------- [en] Bug fix: the width parameters was broken [fr] Bug fix : the param?\195?\168tre width ne fonctionnait pas Modified Paths: -------------- trunk/demo/demo2_simple_with_params.php trunk/src/phpfreechat.class.php Modified: trunk/demo/demo2_simple_with_params.php =================================================================== --- trunk/demo/demo2_simple_with_params.php 2006-09-05 19:24:47 UTC (rev 735) +++ trunk/demo/demo2_simple_with_params.php 2006-09-06 06:53:04 UTC (rev 736) @@ -38,9 +38,7 @@ <body> - <div style="width: 800px;"> - <?php $chat->printChat(); ?> - </div> + <?php $chat->printChat(); ?> <?php // print the current file Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-09-05 19:24:47 UTC (rev 735) +++ trunk/src/phpfreechat.class.php 2006-09-06 06:53:04 UTC (rev 736) @@ -178,7 +178,7 @@ $u =& pfcUserConfig::Instance(); - $output = "<div id=\"pfc_container\"".($c->width != "" ? "style=\"width:".$c->width."\"": "").">"; + $output = "<div id=\"pfc_container\"".($c->width != "" ? " style=\"width:".$c->width."\"": "").">"; // Please do not remove these lines, // or keep a backling to http://www.phpfreechat on your partner page This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-08 20:56:06
|
Revision: 739 http://svn.sourceforge.net/phpfreechat/?rev=739&view=rev Author: kerphi Date: 2006-09-08 13:55:53 -0700 (Fri, 08 Sep 2006) Log Message: ----------- code cleaning (php notice) Modified Paths: -------------- trunk/debug/log.php trunk/lib/utf8/utf8_substr.php trunk/src/commands/getnewmsg.class.php Modified: trunk/debug/log.php =================================================================== --- trunk/debug/log.php 2006-09-08 20:54:35 UTC (rev 738) +++ trunk/debug/log.php 2006-09-08 20:55:53 UTC (rev 739) @@ -6,9 +6,9 @@ $filename = dirname(__FILE__)."/../data/private/debug".$section."_".$id.".log"; if (!file_exists($filename)) @touch($filename); - $fp = fopen($filename, 'a'); - fwrite($fp, "[".$id."] ".date("Y/m/d H:i:s - ").$msg."\n"); - fclose($fp); + $fp = @fopen($filename, 'a'); + @fwrite($fp, "[".$id."] ".date("Y/m/d H:i:s - ").$msg."\n"); + @fclose($fp); } ?> Modified: trunk/lib/utf8/utf8_substr.php =================================================================== --- trunk/lib/utf8/utf8_substr.php 2006-09-08 20:54:35 UTC (rev 738) +++ trunk/lib/utf8/utf8_substr.php 2006-09-08 20:55:53 UTC (rev 739) @@ -17,7 +17,7 @@ function utf8_substr($str,$start,$len=null) { if (!strcmp($len,'0')) return ''; - $byte_start = utf8_char2byte_pos($str,$start); + $byte_start = @utf8_char2byte_pos($str,$start); if ($byte_start === false) { if ($start > 0) { return false; // $start outside string length @@ -29,7 +29,7 @@ $str = substr($str,$byte_start); if ($len!=null) { - $byte_end = utf8_char2byte_pos($str,$len); + $byte_end = @utf8_char2byte_pos($str,$len); if ($byte_end === false) // $len outside actual string length return $len<0 ? '' : $str; // When length is less than zero and exceeds, then we return blank string. else Modified: trunk/src/commands/getnewmsg.class.php =================================================================== --- trunk/src/commands/getnewmsg.class.php 2006-09-08 20:54:35 UTC (rev 738) +++ trunk/src/commands/getnewmsg.class.php 2006-09-08 20:55:53 UTC (rev 739) @@ -44,6 +44,7 @@ } // check if this is the first time you get messages $oldmsg_sid = $c->prefix."oldmsg_".$c->getId()."_".$clientid."_".$recipientid; + $oldmsg = false; if (isset($_SESSION[$oldmsg_sid])) { unset($_SESSION[$oldmsg_sid]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-10 16:10:28
|
Revision: 744 http://svn.sourceforge.net/phpfreechat/?rev=744&view=rev Author: kerphi Date: 2006-09-10 09:10:16 -0700 (Sun, 10 Sep 2006) Log Message: ----------- [en] Bug fix: the proxy allowed path check was broken. [fr] Bug fix: les chemins a authoriser dans le proxy ?\195?\169taient mal calcul?\195?\169s. Modified Paths: -------------- trunk/misc/sendSource trunk/src/client/proxy.php.tpl trunk/src/pfcglobalconfig.class.php trunk/src/phpfreechat.class.php Modified: trunk/misc/sendSource =================================================================== --- trunk/misc/sendSource 2006-09-08 21:46:42 UTC (rev 743) +++ trunk/misc/sendSource 2006-09-10 16:10:16 UTC (rev 744) @@ -5,7 +5,8 @@ PFCSETUP_TGZ=pfcsetup-`cat ../version`.tar.gz PFCSETUP_ZIP=pfcsetup-`cat ../version`.zip +scp ./$NAME_ZIP ./$NAME_TGZ mic...@ph...:/home/micropolia/svn/phpfreechat/prod/www/download/ lftp -c "mput -O ftp://upload.sourceforge.net/incoming/ $NAME_TGZ" lftp -c "mput -O ftp://upload.sourceforge.net/incoming/ $NAME_ZIP" -lftp -c "mput -O ftp://upload.sourceforge.net/incoming/ $PFCSETUP_TGZ" -lftp -c "mput -O ftp://upload.sourceforge.net/incoming/ $PFCSETUP_ZIP" +#lftp -c "mput -O ftp://upload.sourceforge.net/incoming/ $PFCSETUP_TGZ" +#lftp -c "mput -O ftp://upload.sourceforge.net/incoming/ $PFCSETUP_ZIP" Modified: trunk/src/client/proxy.php.tpl =================================================================== --- trunk/src/client/proxy.php.tpl 2006-09-08 21:46:42 UTC (rev 743) +++ trunk/src/client/proxy.php.tpl 2006-09-10 16:10:16 UTC (rev 744) @@ -10,18 +10,11 @@ $page = isset($_GET["p"]) ? $_GET["p"] : ""; if ($page == "") die(); $files = array(); -if (strpos($page, "/") > 0 ) +foreach($allowedpath as $ap) { - foreach($allowedpath as $ap) - { - $f = realpath($ap."/".$page); - if ($f !== FALSE) $files[] = $f; - } + $f = realpath($ap."/".$page); + if ($f !== FALSE) $files[] = $f; } -else -{ - $files = array(realpath($page)); -} $found = ""; for( $i = 0; $i < count($allowedpath) && $found == ""; $i++) { Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-09-08 21:46:42 UTC (rev 743) +++ trunk/src/pfcglobalconfig.class.php 2006-09-10 16:10:16 UTC (rev 744) @@ -410,9 +410,7 @@ $allowedpath_string = ""; $allowedpath_string .= "\$allowedpath[] = '".realpath(dirname(__FILE__)."/../lib")."';\n"; $allowedpath_string .= "\$allowedpath[] = '".realpath(dirname(__FILE__)."/../src/client")."';\n"; - $allowedpath_string .= "\$allowedpath[] = '".realpath($this->themepath_default)."/..';\n"; $allowedpath_string .= "\$allowedpath[] = '".realpath($this->themepath_default)."';\n"; - $allowedpath_string .= "\$allowedpath[] = '".realpath($this->themepath)."/..';\n"; $allowedpath_string .= "\$allowedpath[] = '".realpath($this->themepath)."';\n"; $proxycontent = file_get_contents(dirname(__FILE__)."/client/proxy.php.tpl"); $proxycontent = str_replace("//%allowedpath%", $allowedpath_string, $proxycontent); Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-09-08 21:46:42 UTC (rev 743) +++ trunk/src/phpfreechat.class.php 2006-09-10 16:10:16 UTC (rev 744) @@ -101,17 +101,17 @@ // include javascript libraries $js = array(); - $js[] = "lib/xajax_0.2.3/xajax_js/xajax.js"; - $js[] = "lib/javascript/md5.js"; - $js[] = "lib/javascript/cookie.js"; - $js[] = "lib/javascript/image_preloader.js"; - $js[] = "lib/javascript/myprototype.js"; - $js[] = "lib/javascript/regex.js"; - $js[] = "lib/javascript/utf8.js"; - $js[] = "lib/javascript/sprintf2.js"; - $js[] = "src/client/pfcclient.js"; - $js[] = "src/client/pfcgui.js"; - $js[] = "src/client/pfcresource.js"; + $js[] = "xajax_0.2.3/xajax_js/xajax.js"; + $js[] = "javascript/md5.js"; + $js[] = "javascript/cookie.js"; + $js[] = "javascript/image_preloader.js"; + $js[] = "javascript/myprototype.js"; + $js[] = "javascript/regex.js"; + $js[] = "javascript/utf8.js"; + $js[] = "javascript/sprintf2.js"; + $js[] = "pfcclient.js"; + $js[] = "pfcgui.js"; + $js[] = "pfcresource.js"; foreach( $js as $j ) { $output .= "<script type=\"text/javascript\" src=\"".$c->data_public_url."/".$c->getId()."/proxy.php?p=".$j."\"></script>\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-11 21:20:42
|
Revision: 752 http://svn.sourceforge.net/phpfreechat/?rev=752&view=rev Author: kerphi Date: 2006-09-11 14:20:26 -0700 (Mon, 11 Sep 2006) Log Message: ----------- Work in progress: window notifications Modified Paths: -------------- trunk/src/client/pfcclient.js trunk/src/client/pfcgui.js trunk/src/phpfreechat.class.php Added Paths: ----------- trunk/lib/javascript/activity.js Added: trunk/lib/javascript/activity.js =================================================================== --- trunk/lib/javascript/activity.js (rev 0) +++ trunk/lib/javascript/activity.js 2006-09-11 21:20:26 UTC (rev 752) @@ -0,0 +1,68 @@ +var DetectActivity = Class.create(); +DetectActivity.prototype = { + initialize: function(subject) + { + this.onunactivate = function() {}; + this.onactivate = function() {}; + this.isactive = true; + Event.observe(subject, 'mousemove', this._OnFocus, false); + Event.observe(subject, 'mouseout', this._OnBlur, false); + }, + _OnFocus: function(e) + { +// document.title = 'focus'; + this.isactive = true; +// this.onactivate(); + }, + _OnBlur: function(e) + { +// document.title = 'blur'; + this.isactive = false; +// this.onunactivate(); + }, + isActive: function() + { + return this.isactive; + } +} + + + +/* +// Unused code, by usefull for further auto idle features + + _launchTimeout: function(myself) + { +var oldisactive = this.isactive; + if (this.oldposx == this.posx && + this.oldposy == this.posy) + this.isactive = false; + else + this.isactive = true; +this.oldposx = this.posx; +this.oldposy = this.posy; +if (oldisactive != this.isactive) alert("switch"); + setTimeout(function() { myself._launchTimeout(myself); }, 1000); + }, + + _OnMouseMove: function(e) + { + var posx = 0; + var posy = 0; + if (!e) var e = window.event; + if (e.pageX || e.pageY) + { + posx = e.pageX; + posy = e.pageY; + } + else if (e.clientX || e.clientY) + { + posx = e.clientX + document.body.scrollLeft + + document.documentElement.scrollLeft; + posy = e.clientY + document.body.scrollTop + + document.documentElement.scrollTop; + } + this.posx = posx; + this.posy = posy; + }, +*/ Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-09-11 16:36:33 UTC (rev 751) +++ trunk/src/client/pfcclient.js 2006-09-11 21:20:26 UTC (rev 752) @@ -28,6 +28,7 @@ this.cmdhistoryid = -1; this.cmdhistoryissearching = false; + /* this.channels = Array(); this.channelids = Array(); @@ -50,7 +51,6 @@ this.blinktmp = Array(); this.blinkloop = Array(); this.blinktimeout = Array(); - }, connectListener: function() @@ -61,6 +61,9 @@ // this.el_online = $('pfc_online'); this.el_errors = $('pfc_errors'); + this.detectactivity = new DetectActivity(this.el_container); +// this.detectactivity.onunactivate = this.gui.unnotifyWindow; + /* the events callbacks */ this.el_words.onkeypress = this.callbackWords_OnKeypress.bindAsEventListener(this); this.el_words.onkeydown = this.callbackWords_OnKeydown.bindAsEventListener(this); @@ -71,6 +74,7 @@ this.el_container.onmousedown = this.callbackContainer_OnMousedown.bindAsEventListener(this); this.el_container.onmouseup = this.callbackContainer_OnMouseup.bindAsEventListener(this); document.body.onunload = this.callback_OnUnload.bindAsEventListener(this); + }, refreshGUI: function() @@ -699,7 +703,8 @@ if (this.gui.getTabId() != tabid) this.gui.notifyTab(tabid); // notify the window (change the title) - this.gui.notifyWindow(); + if (!this.detectactivity.isActive()) + this.gui.notifyWindow(); } if (msg_html[recipientid] == null) Modified: trunk/src/client/pfcgui.js =================================================================== --- trunk/src/client/pfcgui.js 2006-09-11 16:36:33 UTC (rev 751) +++ trunk/src/client/pfcgui.js 2006-09-11 21:20:26 UTC (rev 752) @@ -17,6 +17,7 @@ this.onlinecontent = $H(); this.scrollpos = $H(); this.elttoscroll = $H(); + this.windownotifynb = 0; }, /** @@ -267,11 +268,19 @@ */ notifyWindow: function() { - var el_title = document.getElementsByTagName('title'); -// el_title[0].innerHTML = '[*]'; +//alert(this.windownotifynb); + this.windownotifynb += 1; + var rx = new RegExp('^\\[[0-9]+\\](.*)','ig'); + document.title = document.title.replace(rx,'$1'); + document.title = '['+this.windownotifynb+']'+document.title; }, + unnotifyWindow: function() + { + this.windownotifynb = 0; + var rx = new RegExp('^\\[[0-9]+\\](.*)','ig'); + document.title = document.title.replace(rx,'$1'); + }, - /** * This function change the tab icon in order to catch the attention */ Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-09-11 16:36:33 UTC (rev 751) +++ trunk/src/phpfreechat.class.php 2006-09-11 21:20:26 UTC (rev 752) @@ -109,6 +109,7 @@ $js[] = "javascript/regex.js"; $js[] = "javascript/utf8.js"; $js[] = "javascript/sprintf2.js"; + $js[] = "javascript/activity.js"; $js[] = "pfcclient.js"; $js[] = "pfcgui.js"; $js[] = "pfcresource.js"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-12 07:48:26
|
Revision: 753 http://svn.sourceforge.net/phpfreechat/?rev=753&view=rev Author: kerphi Date: 2006-09-12 00:48:17 -0700 (Tue, 12 Sep 2006) Log Message: ----------- [en] New feature: when a new message is posted, the unactive window title is prefixed by the number of new messages (this can be disabled by setting to false the notify_window parameter). [fr] Nouvelle fonctionnalit?\195?\169 : lorsqu'un nouveau message est envoy?\195?\169 dans une fenetre de chat inactive, le titre de cette fenetre est prefixe par le nombre de nouveau messages envoyes (ce comportement peut etre desactive en mettant a false le parametre notify_window) Modified Paths: -------------- trunk/lib/javascript/activity.js trunk/src/client/chat.js.tpl.php trunk/src/client/pfcclient.js trunk/src/client/pfcgui.js trunk/src/pfcglobalconfig.class.php Modified: trunk/lib/javascript/activity.js =================================================================== --- trunk/lib/javascript/activity.js 2006-09-11 21:20:26 UTC (rev 752) +++ trunk/lib/javascript/activity.js 2006-09-12 07:48:17 UTC (rev 753) @@ -3,22 +3,21 @@ initialize: function(subject) { this.onunactivate = function() {}; - this.onactivate = function() {}; + this.onactivate = function() {}; + this.subject = subject; this.isactive = true; - Event.observe(subject, 'mousemove', this._OnFocus, false); - Event.observe(subject, 'mouseout', this._OnBlur, false); + Event.observe(subject, 'mousemove', this._OnFocus.bindAsEventListener(this), false); + Event.observe(subject, 'mouseout', this._OnBlur.bindAsEventListener(this), false); }, _OnFocus: function(e) { -// document.title = 'focus'; this.isactive = true; -// this.onactivate(); + if (this.onactivate) this.onactivate(); }, _OnBlur: function(e) { -// document.title = 'blur'; this.isactive = false; -// this.onunactivate(); + if (this.onunactivate) this.onunactivate(); }, isActive: function() { Modified: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php 2006-09-11 21:20:26 UTC (rev 752) +++ trunk/src/client/chat.js.tpl.php 2006-09-12 07:48:17 UTC (rev 753) @@ -16,6 +16,7 @@ var pfc_btn_sh_smileys = <?php echo $btn_sh_smileys ? "true" : "false"; ?>; var pfc_btn_sh_whosonline = <?php echo $btn_sh_whosonline ? "true" : "false"; ?>; var pfc_connect_at_startup = <?php echo $connect_at_startup ? "true" : "false"; ?>; +var pfc_notify_window = <?php echo $notify_window ? "true" : "false"; ?>; var pfc_defaultchan = Array(<?php function quoteandescape($v) { return "'".addslashes($v)."'"; } $list = array(); foreach($c->channels as $ch) {$list[] = $ch; } Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-09-11 21:20:26 UTC (rev 752) +++ trunk/src/client/pfcclient.js 2006-09-12 07:48:17 UTC (rev 753) @@ -62,19 +62,19 @@ this.el_errors = $('pfc_errors'); this.detectactivity = new DetectActivity(this.el_container); -// this.detectactivity.onunactivate = this.gui.unnotifyWindow; + // restore the window title when user come back to the active zone + if (pfc_notify_window) this.detectactivity.onunactivate = this.gui.unnotifyWindow; /* the events callbacks */ - this.el_words.onkeypress = this.callbackWords_OnKeypress.bindAsEventListener(this); - this.el_words.onkeydown = this.callbackWords_OnKeydown.bindAsEventListener(this); - this.el_words.onfocus = this.callbackWords_OnFocus.bindAsEventListener(this); - this.el_handle.onkeydown = this.callbackHandle_OnKeydown.bindAsEventListener(this); - this.el_handle.onchange = this.callbackHandle_OnChange.bindAsEventListener(this); - this.el_container.onmousemove = this.callbackContainer_OnMousemove.bindAsEventListener(this); - this.el_container.onmousedown = this.callbackContainer_OnMousedown.bindAsEventListener(this); - this.el_container.onmouseup = this.callbackContainer_OnMouseup.bindAsEventListener(this); - document.body.onunload = this.callback_OnUnload.bindAsEventListener(this); - + Event.observe(this.el_words, 'keypress', this.callbackWords_OnKeypress.bindAsEventListener(this), false); + Event.observe(this.el_words, 'keydown', this.callbackWords_OnKeydown.bindAsEventListener(this), false); + Event.observe(this.el_words, 'focus', this.callbackWords_OnFocus.bindAsEventListener(this), false); + Event.observe(this.el_handle, 'keydown', this.callbackHandle_OnKeydown.bindAsEventListener(this), false); + Event.observe(this.el_handle, 'change', this.callbackHandle_OnChange.bindAsEventListener(this), false); + Event.observe(this.el_container, 'mousemove', this.callbackContainer_OnMousemove.bindAsEventListener(this), false); + Event.observe(this.el_container, 'mousedown', this.callbackContainer_OnMousedown.bindAsEventListener(this), false); + Event.observe(this.el_container, 'mouseup', this.callbackContainer_OnMouseup.bindAsEventListener(this), false); + Event.observe(document.body, 'unload', this.callback_OnUnload.bindAsEventListener(this), false); }, refreshGUI: function() @@ -703,7 +703,7 @@ if (this.gui.getTabId() != tabid) this.gui.notifyTab(tabid); // notify the window (change the title) - if (!this.detectactivity.isActive()) + if (!this.detectactivity.isActive() && pfc_notify_window) this.gui.notifyWindow(); } Modified: trunk/src/client/pfcgui.js =================================================================== --- trunk/src/client/pfcgui.js 2006-09-11 21:20:26 UTC (rev 752) +++ trunk/src/client/pfcgui.js 2006-09-12 07:48:17 UTC (rev 753) @@ -268,7 +268,6 @@ */ notifyWindow: function() { -//alert(this.windownotifynb); this.windownotifynb += 1; var rx = new RegExp('^\\[[0-9]+\\](.*)','ig'); document.title = document.title.replace(rx,'$1'); Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-09-11 21:20:26 UTC (rev 752) +++ trunk/src/pfcglobalconfig.class.php 2006-09-12 07:48:17 UTC (rev 753) @@ -65,6 +65,7 @@ var $nickmarker = true; // show/hide nicknames colors var $clock = true; // show/hide dates and hours var $openlinknewwindow = true; // used to open the links in a new window + var $notify_window = true; // true : appends a prefix to the window title with the number of new posted messages var $showwhosonline = true; var $showsmileys = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-13 17:58:21
|
Revision: 760 http://svn.sourceforge.net/phpfreechat/?rev=760&view=rev Author: kerphi Date: 2006-09-13 10:58:11 -0700 (Wed, 13 Sep 2006) Log Message: ----------- [en] Bug fix: no more blank screen on IE6. [fr] Bug fix : termine les ecrans blancs sous IE6. Modified Paths: -------------- trunk/src/client/pfcgui.js trunk/themes/default/style.css Modified: trunk/src/client/pfcgui.js =================================================================== --- trunk/src/client/pfcgui.js 2006-09-13 07:09:16 UTC (rev 759) +++ trunk/src/client/pfcgui.js 2006-09-13 17:58:11 UTC (rev 760) @@ -256,10 +256,14 @@ var div_online = this.getOnlineContentFromTabId(tabid); div_content.appendChild(div_chat); div_content.appendChild(div_online); - + $('pfc_channels_list').appendChild(li_title); $('pfc_channels_content').appendChild(div_content); + // force the height of the chat/online zone in pixel in order fix blank screens on IE6 + div_chat.style.height = ($('pfc_channels_content').offsetHeight-1)+'px'; + div_online.style.height = ($('pfc_channels_content').offsetHeight-1)+'px'; + return tabid; }, Modified: trunk/themes/default/style.css =================================================================== --- trunk/themes/default/style.css 2006-09-13 07:09:16 UTC (rev 759) +++ trunk/themes/default/style.css 2006-09-13 17:58:11 UTC (rev 760) @@ -33,7 +33,6 @@ background-color: #FFF; margin-top: 5px; height: 300px; - font-family: serif; /* needed by IE6 in order to display correctly chinese characteres */ } div.pfc_content { } @@ -90,7 +89,8 @@ top: 0; left: 0; width: 80%; - height: 100%; +/* WARNING: do not fix height in % because it will display blank screens on IE6 */ +/* height: 100%;*/ overflow: auto; } @@ -101,7 +101,8 @@ padding: 0; overflow: auto; width: 20%; - height: 100%; +/* WARNING: do not fix height in % because it will display blank screens on IE6 */ +/* height: 100%;*/ color: #000; /* colors can be overriden by js nickname colorization */ background-color: #FFF; background-image: url("proxy.php?p=default/images/online-separator.gif"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-13 21:28:18
|
Revision: 762 http://svn.sourceforge.net/phpfreechat/?rev=762&view=rev Author: kerphi Date: 2006-09-13 14:28:09 -0700 (Wed, 13 Sep 2006) Log Message: ----------- first steps to integrate webinstaller in the command line packager script Modified Paths: -------------- trunk/contrib/pfcInstaller/engene.inc.php trunk/misc/tarSource Added Paths: ----------- trunk/misc/createwebinstaller.php Modified: trunk/contrib/pfcInstaller/engene.inc.php =================================================================== --- trunk/contrib/pfcInstaller/engene.inc.php 2006-09-13 18:08:08 UTC (rev 761) +++ trunk/contrib/pfcInstaller/engene.inc.php 2006-09-13 21:28:09 UTC (rev 762) @@ -232,7 +232,7 @@ } - protected function addInstallerPage(){ + function addInstallerPage(){ $fc = file_get_contents($this->dataDir.'/step_installer.txt'); $this->installer_page = $this->addPage('Install',$fc); echo '<div>Page: '.$this->installer_page.'</div>'; Added: trunk/misc/createwebinstaller.php =================================================================== --- trunk/misc/createwebinstaller.php (rev 0) +++ trunk/misc/createwebinstaller.php 2006-09-13 21:28:09 UTC (rev 762) @@ -0,0 +1,18 @@ +<?php + +$version = isset($_SERVER["argv"][1]) ? $_SERVER["argv"][1] : file_get_contents(dirname(__FILE__)."/../version"); +$archivename = 'phpfreechat-'.$version.'-setup.php'; +$pfcpath = dirname(__FILE__).'/phpfreechat-'.$version; +if (!file_exists($pfcpath)) die("Dont find the directory $pfcpath"); + +include(dirname(__FILE__).'/../contrib/pfcInstaller/engene.inc.php'); +$phpi = new phpInstaller(); +$phpi->dataDir(realpath(dirname(__FILE__).'/../contrib/pfcInstaller/engene_data')); +$phpi->appName = 'phpFreeChat'; +$phpi->appVersion = $version; +$phpi->ignore[] = '.svn'; +$phpi->addInstallerPage(); +$phpi->addPath($pfcpath); +$phpi->generate($archivename); + +?> Modified: trunk/misc/tarSource =================================================================== --- trunk/misc/tarSource 2006-09-13 18:08:08 UTC (rev 761) +++ trunk/misc/tarSource 2006-09-13 21:28:09 UTC (rev 762) @@ -30,30 +30,32 @@ tar czfp $NAME.tar.gz ./$NAME echo "-> creating $NAME.zip" zip -Tq9r $NAME.zip ./$NAME +echo "-> creating $NAME-setup.php" +php ./createwebinstaller.php `cat ../version` > /dev/null -echo "-> creating $PFCSETUPNAME.tar.gz" -rm -rf ./$PFCSETUPNAME -svn export ../contrib/pfcInstaller2 $PFCSETUPNAME -rm -rf ./$PFCSETUPNAME/.registry -rm -rf ./$PFCSETUPNAME/.depdblock -rm -rf ./$PFCSETUPNAME/.lock -rm -rf ./$PFCSETUPNAME/.channels -rm -rf ./$PFCSETUPNAME/tmp -rm -rf ./$PFCSETUPNAME/bin -rm -rf ./$PFCSETUPNAME/PEAR -rm -rf ./$PFCSETUPNAME/System.php -rm -rf ./$PFCSETUPNAME/peclcmd.php -rm -rf ./$PFCSETUPNAME/pearcmd.php -rm -rf ./$PFCSETUPNAME/pear.sh -rm -rf ./$PFCSETUPNAME/pearrc -rm -rf ./$PFCSETUPNAME/OS -echo "$NAME.tar.gz" > $PFCSETUPNAME/archivename -echo `pwd` >> $PFCSETUPNAME/mirrors -tar czfp $PFCSETUPNAME.tar.gz ./$PFCSETUPNAME -echo "-> creating $PFCSETUPNAME.zip" -zip -Tq9r $PFCSETUPNAME.zip ./$PFCSETUPNAME +#echo "-> creating $PFCSETUPNAME.tar.gz" +#rm -rf ./$PFCSETUPNAME +#svn export ../contrib/pfcInstaller2 $PFCSETUPNAME +#rm -rf ./$PFCSETUPNAME/.registry +#rm -rf ./$PFCSETUPNAME/.depdblock +#rm -rf ./$PFCSETUPNAME/.lock +#rm -rf ./$PFCSETUPNAME/.channels +#rm -rf ./$PFCSETUPNAME/tmp +#rm -rf ./$PFCSETUPNAME/bin +#rm -rf ./$PFCSETUPNAME/PEAR +#rm -rf ./$PFCSETUPNAME/System.php +#rm -rf ./$PFCSETUPNAME/peclcmd.php +#rm -rf ./$PFCSETUPNAME/pearcmd.php +#rm -rf ./$PFCSETUPNAME/pear.sh +#rm -rf ./$PFCSETUPNAME/pearrc +#rm -rf ./$PFCSETUPNAME/OS +#echo "$NAME.tar.gz" > $PFCSETUPNAME/archivename +#echo `pwd` >> $PFCSETUPNAME/mirrors +#tar czfp $PFCSETUPNAME.tar.gz ./$PFCSETUPNAME +#echo "-> creating $PFCSETUPNAME.zip" +#zip -Tq9r $PFCSETUPNAME.zip ./$PFCSETUPNAME +#rm -rf ./$PFCSETUPNAME echo "-> removing temporary files" rm -rf ./$NAME -rm -rf ./$PFCSETUPNAME echo "-- creating archive $NAME, done --" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-16 20:32:55
|
Revision: 764 http://svn.sourceforge.net/phpfreechat/?rev=764&view=rev Author: kerphi Date: 2006-09-16 13:32:44 -0700 (Sat, 16 Sep 2006) Log Message: ----------- [en] Proxies refactoring : I removed the 'proxy' parameter. I added 'skip_proxys' used to disable a system proxy (ex: censor). I added 'post_proxys' used to append your own proxy to the proxy chaine. I added 'pre_proxys' used to prepend your own proxy to the proxy chaine. I added 'proxys_path' used to define the location of your customized proxies. I also created demo48 to illustrate this powerfull proxy feature. [fr] Refonte des command proxies : J'ai retire les parametre 'proxy'. J'ai ajoute le parametre 'skip_proxys' utilise pour desactive un proxy systeme (ex: censor). J'ai ajoute le parametre 'post_proxys' utilise pour ajouter a la fin de la chaine son propre proxy. J'ai ajoute le parametre 'pre_proxys' utilise pour ajouter en debut de chaine son propre proxy. J'ai ajoute le parametre 'proxys_path' utilise pour indiquer le repertoire ou se trouve vos proxy. J'ai finalement ajoute la demo48 pour illustrer la puissance des proxy. Modified Paths: -------------- trunk/src/pfccommand.class.php trunk/src/pfcglobalconfig.class.php trunk/src/phpfreechat.class.php Added Paths: ----------- trunk/demo/demo48_custom_proxy/ trunk/demo/demo48_custom_proxy/myproxy.class.php trunk/demo/demo48_custom_proxy.php Added: trunk/demo/demo48_custom_proxy/myproxy.class.php =================================================================== --- trunk/demo/demo48_custom_proxy/myproxy.class.php (rev 0) +++ trunk/demo/demo48_custom_proxy/myproxy.class.php 2006-09-16 20:32:44 UTC (rev 764) @@ -0,0 +1,60 @@ +<?php +/** + * myproxy.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__)."/../../src/pfci18n.class.php"; +require_once dirname(__FILE__)."/../../src/pfcuserconfig.class.php"; +require_once dirname(__FILE__)."/../../src/pfcproxycommand.class.php"; + +/** + * pfcProxyCommand_myproxy + * this proxy will do nothing + * @author Stephane Gully <ste...@gm...> + */ +class pfcProxyCommand_myproxy extends pfcProxyCommand +{ + function run(&$xml_reponse, $p) + { + $clientid = $p["clientid"]; + $param = $p["param"]; + $sender = $p["sender"]; + $recipient = $p["recipient"]; + $recipientid = $p["recipientid"]; + $c =& $this->c; + $u =& $this->u; + + $cmdtocheck = array("send", "me"); + if ( in_array($this->name, $cmdtocheck) ) + { + // Modify the text + $param = "[this text is prepend by 'demo48_custom_proxy/myproxy.class.php'] ".$param; + } + + // forward the command to the next proxy or to the final command + $p["clientid"] = $clientid; + $p["param"] = $param; + $p["sender"] = $sender; + $p["recipient"] = $recipient; + $p["recipientid"] = $recipientid; + $this->next->run($xml_reponse, $p); + } +} + +?> \ No newline at end of file Added: trunk/demo/demo48_custom_proxy.php =================================================================== --- trunk/demo/demo48_custom_proxy.php (rev 0) +++ trunk/demo/demo48_custom_proxy.php 2006-09-16 20:32:44 UTC (rev 764) @@ -0,0 +1,39 @@ +<?php + +require_once dirname(__FILE__)."/../src/phpfreechat.class.php"; + +$params["serverid"] = md5(__FILE__); // calculate a unique id for this chat +$params["skip_proxys"] = array("censor"); // shows how to disable a proxy (try to write fuck in the chat, it should be possible) +$params["post_proxys"] = array("myproxy"); +$params["proxys_path"] = dirname(__FILE__).'/demo48_custom_proxy'; +$chat = new phpFreeChat( $params ); + +?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html> + <head> + <meta http-equiv="content-type" content="text/html; charset=utf-8" /> + <title>phpFreeChat demo</title> + + <?php $chat->printJavascript(); ?> + <?php $chat->printStyle(); ?> + + </head> + + <body> + <p>This demo shows how to create your own command proxy. Each chained proxies receive every transmitted commands. Your proxy can block the command, alterate the command, store some statistics. For example: to write a bot, just write a proxy.</p> + <?php $chat->printChat(); ?> + +<?php + // print the current file + echo "<h2>The source code</h2>"; + $filename = __FILE__; + echo "<p><code>".$filename."</code></p>"; + echo "<pre style=\"margin: 0 50px 0 50px; padding: 10px; background-color: #DDD;\">"; + $content = file_get_contents($filename); + echo htmlentities($content); + echo "</pre>"; +?> + + </body> +</html> Modified: trunk/src/pfccommand.class.php =================================================================== --- trunk/src/pfccommand.class.php 2006-09-15 18:13:17 UTC (rev 763) +++ trunk/src/pfccommand.class.php 2006-09-16 20:32:44 UTC (rev 764) @@ -81,15 +81,21 @@ // instanciate the proxys chaine $firstproxy =& $cmd; - for($i = count($c->proxys)-1; $i >= 0; $i--) + for($i = count($c->_proxys)-1; $i >= 0; $i--) { - $proxy_name = strtolower($c->proxys[$i]); + $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); + // try to include the proxy class file from the default path or from the customized path + $proxy_filename = $c->proxys_path_default.'/'.$proxy_name.".class.php"; + if (file_exists($proxy_filename)) + require_once($proxy_filename); + else + { + $proxy_filename = $c->proxys_path.'/'.$proxy_name.".class.php"; + if (file_exists($proxy_filename)) require_once($proxy_filename); + } } if (class_exists($proxy_classname)) { Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-09-15 18:13:17 UTC (rev 763) +++ trunk/src/pfcglobalconfig.class.php 2006-09-16 20:32:44 UTC (rev 764) @@ -41,14 +41,18 @@ var $lockurl = "http://www.phpfreechat.net"; // this is the url where the users must be redirected when the chat is locked // these parameters are static (cached) - var $proxys = array("lock", "checktimeout", "checknickchange", "auth", "noflood", "censor", "log"); + var $skip_proxys = array(); // these proxies will be skiped. ex: append "censor" to the list to disable words censoring + var $post_proxys = array(); // these proxies will be handled just before to process commands and just after system proxies + var $pre_proxys = array(); // these proxies will be handled before system proxies (at begining) var $proxys_cfg = array("auth" => array(), "noflood" => array("limit"=>10,"delay"=>5), "censor" => array("words"=>array("fuck","sex","bitch"),"replaceby"=>"*"), "log" => array("path"=>"")); + var $proxys_path = ""; // a custom proxies path + var $proxys_path_default = ""; // dirname(__FILE__).'/proxys' 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 + var $frozen_channels = array(); // if empty, allows users to create there own channels var $frozen_nick = false; var $max_nick_len = 15; var $max_text_len = 400; @@ -96,7 +100,6 @@ var $smileys = array(); var $errors = array(); - var $prefix = "pfc_"; 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 $debugurl = ""; @@ -104,6 +107,8 @@ var $debugxajax = false; // private parameters + var $_sys_proxys = array("lock", "checktimeout", "checknickchange", "auth", "noflood", "censor", "log"); + var $_proxys = array(); // will contains proxies to execute on each command (filled in the init step) var $_dyn_params = array("nick","isadmin","islocked","admins","frozen_channels"); var $_params_type = array(); @@ -158,6 +163,9 @@ { if (!isset($this->$k)) $this->errors[] = _pfc("Error: undefined or obsolete parameter '%s', please correct or remove this parameter", $k); + if (preg_match('/^_/',$k)) + $this->errors[] = _pfc("Error: '%s' is a private parameter, you are not allowed to change it", $k); + if ($k == "proxys_cfg") { // don't replace all the proxy_cfg parameters, just replace the specified ones @@ -386,6 +394,33 @@ else @file_put_contents($proxyfile, $proxycontent); } + + + // calculate the proxies chaine + $this->_proxys = array(); + foreach($this->pre_proxys as $px) + { + if (!in_array($px,$this->skip_proxys) && !in_array($px,$this->_proxys)) + $this->_proxys[] = $px; + + } + foreach($this->_sys_proxys as $px) + { + if (!in_array($px,$this->skip_proxys) && !in_array($px,$this->_proxys)) + $this->_proxys[] = $px; + + } + foreach($this->post_proxys as $px) + { + if (!in_array($px,$this->skip_proxys) && !in_array($px,$this->_proxys)) + $this->_proxys[] = $px; + + } + // save the proxies path + $this->proxys_path_default = dirname(__FILE__).'/proxys'; + // check the customized proxies path + if ($this->proxys_path != '' && !is_dir($this->proxys_path)) + $this->errors[] = _pfc("'%s' directory doesn't exist", $this->proxys_path); // load smileys from file $this->loadSmileyTheme(); Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-09-15 18:13:17 UTC (rev 763) +++ trunk/src/phpfreechat.class.php 2006-09-16 20:32:44 UTC (rev 764) @@ -64,7 +64,7 @@ if (file_exists($c->xajaxpath."/xajax.inc.php")) { require_once $c->xajaxpath."/xajax.inc.php"; - $this->xajax = new xajax($c->server_script_url.(isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "" ? "?".$_SERVER["QUERY_STRING"] : ""), $c->prefix); + $this->xajax = new xajax($c->server_script_url.(isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "" ? "?".$_SERVER["QUERY_STRING"] : ""), 'pfc_'); if ($c->debugxajax) $this->xajax->debugOn(); $this->xajax->waitCursorOff(); // do not show a wait cursor during chat updates $this->xajax->cleanBufferOff(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-19 15:26:05
|
Revision: 770 http://svn.sourceforge.net/phpfreechat/?rev=770&view=rev Author: kerphi Date: 2006-09-19 08:25:50 -0700 (Tue, 19 Sep 2006) Log Message: ----------- Work in progress: datamodel refactoring (don't checkout this revision it doesn't work) Modified Paths: -------------- trunk/src/commands/leave.class.php trunk/src/containers/file.class.php trunk/testcase/container_file.php trunk/testcase/container_generic.php Modified: trunk/src/commands/leave.class.php =================================================================== --- trunk/src/commands/leave.class.php 2006-09-19 06:51:13 UTC (rev 769) +++ trunk/src/commands/leave.class.php 2006-09-19 15:25:50 UTC (rev 770) @@ -72,7 +72,7 @@ // remove the nickname from the channel/pv $container =& $c->getContainerInstance(); - $container->removeNick($leave_recip, $u->nick); + $container->removeNick($chan, $u->nickid); // return ok to the client // then the client will remove the channel' tab Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2006-09-19 06:51:13 UTC (rev 769) +++ trunk/src/containers/file.class.php 2006-09-19 15:25:50 UTC (rev 770) @@ -92,61 +92,17 @@ { $c =& $this->c; - // store nickid -> nickname and nickname -> nickid correspondance - $this->setMeta($nick, "nickname", "fromnickid", $nickid); - $this->setMeta($nickid, "nickid", "fromnickname", $nick); + if ($chan == NULL) $chan = 'SERVER'; - $this->_registerUserMeta($nickid, $chan); + $this->setMeta2("nickid-to-metadata", $nickid, 'nick', $nick); + $this->setMeta2("metadata-to-nickid", 'nick', $this->_encode($nick), $nickid); - if ($c->debug) pxlog("createNick - nickname metadata created: chan=".($chan==NULL?"SERVER":$chan)." nickid=".$nickid, "chat", $c->getId()); + $this->setMeta2("nickid-to-channelid", $nickid, $this->_encode($chan)); + $this->setMeta2("channelid-to-nickid", $this->_encode($chan), $nickid); - /* - // increment the nick references (used to know when the nick is really disconnected) - $nick_ref = $this->getMeta("references", $nickid); - if ($nick_ref == NULL || !is_numeric($nick_ref)) $nick_ref = 0; - $nick_ref++; - $this->setMeta($nick_ref, "references", $nickid); - */ - + // update the SERVER channel + $this->updateNick($nickid); - $c =& $this->c; - $nick_dir = ($chan != NULL) ? - $c->container_cfg_channel_dir."/".$this->_encode($chan)."/nicknames" : - $c->container_cfg_server_dir."/nicknames"; - - // check the nickname directory exists - $errors = @test_writable_dir($nick_dir, $chan."/nicknames/".$nick); - if ($c->debug) - { - if (count($errors)>0) - pxlog("createNick(".$nick.", ".$nickid.") - Error: ".var_export($errors,true), "chat", $c->getId()); - } - - $nickid_filename = $nick_dir."/".$nickid; //$this->_encode($nick); - - // check the if the file exists only in debug mode! - if ($c->debug) - { - /* - if (file_exists($nickid_filename)) - pxlog("createNick(".$nick.", ".$nickid.") - Error: another nickname data file exists, we are overwriting it (nickname takeover)!: ".$nickid_filename, "chat", $c->getId()); - else - pxlog("createNick - nickname file created: chan=".($chan==NULL?"SERVER":$chan)." nickid=".$nickid, "chat", $c->getId()); - */ - } - - // trust the caller : this nick is not used - touch($nickid_filename); - - // append the nickname to the cached nickname list - $id = $this->isNickOnline($chan, $nick); - $_chan = ($chan == NULL) ? "SERVER" : $chan; - if ($id<0) - { - $this->_users[$_chan]["nickid"][] = $nickid; - $this->_users[$_chan]["timestamp"][] = filemtime($nickid_filename); - } - return true; } @@ -157,68 +113,49 @@ * @param $nick the nickname to remove * @return true if the nickname was correctly removed */ - function removeNick($chan, $nick) + function removeNick($chan, $nickid) { - // retrive the nickid to remove - $nickid = $this->getNickId($nick); - if ($nickid == "undefined") return false; + if ($chan == NULL) $chan = 'SERVER'; - $c =& $this->c; - $nick_dir = ($chan != NULL) ? - $c->container_cfg_channel_dir."/".$this->_encode($chan)."/nicknames" : - $c->container_cfg_server_dir."/nicknames"; - $nickid_filename = $nick_dir."/".$nickid; //$this->_encode($nick); + $ret = $this->getMeta2("channelid-to-nickid", $this->_encode('SERVER'), $nickid); + $timestamp = $ret["timestamp"][0]; + + $deleted_user = array(); + $deleted_user["nick"][] = $this->getNickname($nickid); + $deleted_user["nickid"][] = $nickid; + $deleted_user["timestamp"][] = $timestamp; - if ($c->debug) - { - // @todo: check if the removed nick is mine in debug mode! - - // check the nickname file really exists - if (!file_exists($nickid_filename)) - pxlog("removeNick(".$nick.") - Error: the nickname data file to remove doesn't exists: ".$nickid_filename, "chat", $c->getId()); - else - pxlog("removeNick - nickname file removed: chan=".($chan==NULL?"SERVER":$chan)." nickid=".$nickid, "chat", $c->getId()); - } - $ok = @unlink($nickid_filename); + // @todo ne supprimer l'utilisateur que du channel donne en parametres + // car la commande /leave va simplement supprimer l'utilisateur du channel courant + // il faut par contre faire un test sur les channels de l'utilisateur et dans le cas ou l'utilisateur + // est deconnecte du dernier channel (il se peut que ce soit SERVER) alors on supprime ses metadata. - // remove the user metadata if he is disconnected from the server + // il faudrait egalement adapter removeObsoleteNick pour qu'elle appel N fois removeNick + // N etant le nombre de channel de l'utilisateur. Ainsi l'utilisateur dera vraiment deconnecte - $this->_unregisterUserMeta($nickid, $chan); - /* - // decrement the nick references and kill the metadata if not more references is found - // (used to know when the nick is really disconnected) - $nick_ref = $this->getMeta("references", $nickid); - if ($nick_ref == NULL || !is_numeric($nick_ref)) $nick_ref = 0; - $nick_ref--; - if ($nick_ref <= 0) - { - $this->rmMeta("nickid", "fromnickname", $nick); - $this->rmMeta("nickname", "fromnickid", $nickid); - $this->rmMeta("references", $nickid); // destroy also the reference counter (by default its value is 0) - } - else - $this->setMeta($nick_ref, "references", $nickid); - */ - if ($c->debug) - { - // check the nickname file is correctly deleted - if (file_exists($nickid_filename)) - pxlog("removeNick(".$nick.") - Error: the nickname data file yet exists", "chat", $c->getId()); - } + // get the user's disconnected channels + $channels = array(); + $ret2 = $this->getMeta2("nickid-to-channelid",$nickid); + foreach($ret2["value"] as $v) + $channels[] = $this->_decode($v); + $deleted_user["channels"][] = $channels; - // remove the nickname from the cache list - $id = $this->isNickOnline($chan, $nick); - $_chan = ($chan == NULL) ? "SERVER" : $chan; - if ($id >= 0) + // get the user nickname + $nick = $this->getNickname($nickid); + // loop on user channels + foreach($channels as $ch) { - unset($this->_users[$_chan]["nickid"][$id]); - unset($this->_users[$_chan]["timestamp"][$id]); + // remove the nickname to nickid correspondance + $this->rmMeta2("metadata-to-nickid", 'nick', $this->_encode($nick)); + // remove disconnected nickname metadata + $this->rmMeta2("nickid-to-metadata", $nickid); + // remove the nickid from the channel list + $this->rmMeta2("channelid-to-nickid", $this->_encode($ch), $nickid); } - - return $ok; + return $deleted_user; } /** @@ -227,46 +164,15 @@ * @param $chan where to update the nick, if null then update the server nick * @param $nick nickname to update (raw nickname) */ - function updateNick($chan, $nick) + function updateNick($nickid) { - // retrive the nickid to update - $nickid = $this->getNickId($nick); - if ($nickid == "undefined") return false; - - // update the user metadata - $this->_registerUserMeta($nickid, $chan); - $c =& $this->c; - $there = false; - - $nick_dir = ($chan != NULL) ? - $c->container_cfg_channel_dir."/".$this->_encode($chan)."/nicknames" : - $c->container_cfg_server_dir."/nicknames"; - if (!is_dir($nick_dir)) mkdir_r($nick_dir); - - // update my online status file - $nickid_filename = $nick_dir."/".$nickid; //$this->_encode($nick); - if (file_exists($nickid_filename)) $there = true; - @touch($nickid_filename); - @chmod($nickid_filename, 0700); - if ($c->debug) pxlog("updateNick - nickname file updated: chan=".($chan==NULL?"SERVER":$chan)." nickid=".$nickid, "chat", $c->getId()); - - // append the nickname to the cache list - $_chan = ($chan == NULL) ? "SERVER" : $chan; - $id = $this->isNickOnline($chan, $nick); - if ($id < 0) - { - $this->_users[$_chan]["nickid"][] = $nickid; - $this->_users[$_chan]["timestamp"][] = filemtime($nickid_filename); - } - else - { - // just update the timestamp if the nickname is allready present in the cached list - $this->_users[$_chan]["timestamp"][$id] = filemtime($nickid_filename); - } - - return $there; + $chan = 'SERVER'; + + $this->setMeta2("nickid-to-channelid", $nickid, $this->_encode($chan)); + $this->setMeta2("channelid-to-nickid", $this->_encode($chan), $nickid); + return true; } /** @@ -278,41 +184,19 @@ */ function changeNick($newnick, $oldnick) { - $oldnickid = $this->getNickId($oldnick); - $newnickid = $this->getNickId($newnick); - if ($oldnickid == "undefined") return false; // the oldnick must be connected - if ($newnickid != "undefined") return false; // the newnick must not be inuse - - $this->rmMeta("nickid", "fromnickname", $oldnick); // remove the oldnickname -> oldnickid association - $this->setMeta($newnick, "nickname", "fromnickid", $oldnickid); - $this->setMeta($oldnickid, "nickid", "fromnickname", $newnick); - - /* $c =& $this->c; - $nick_dir = ($chan != NULL) ? - $c->container_cfg_channel_dir."/".$this->_encode($chan)."/nicknames" : - $c->container_cfg_server_dir."/nicknames"; - // $newnickid_filename = $nick_dir."/".$this->_encode($newnick); - $oldnickid_filename = $nick_dir."/".$oldnickid; //$this->_encode($oldnick); - - $ok = @rename($oldnick_filename, $newnick_filename); - */ - // update the nick cache list + $oldnickid = $this->getNickId($oldnick); + $newnickid = $this->getNickId($newnick); + if ($oldnickid == "") return false; // the oldnick must be connected + if ($newnickid != "") return false; // the newnick must not be inuse - //if($ok) - /* - { - $_chan = ($chan == NULL) ? "SERVER" : $chan; - $id = $this->isNickOnline($chan, $oldnick); - if ($id >= 0) - { - $this->_users[$_chan][$id]["nick"] = $newnick; - $this->_users[$_chan][$id]["timestamp"] = filemtime($newnick_filename); - } - } - */ + // remove the oldnick to oldnickid correspondance + $this->rmMeta2("metadata-to-nickid", 'nick', $this->_encode($oldnick)); + // update the nickname + $this->setMeta2("nickid-to-metadata", $oldnickid, 'nick', $newnick); + $this->setMeta2("metadata-to-nickid", 'nick', $this->_encode($newnick), $oldnickid); return true; } @@ -324,8 +208,8 @@ */ function getNickId($nick) { - $nickid = $this->getMeta("nickid", "fromnickname", $nick); - if ($nickid == NULL) $nickid = "undefined"; + $nickid = $this->getMeta2("metadata-to-nickid", 'nick', $this->_encode($nick), true); + $nickid = isset($nickid["value"][0]) ? $nickid["value"][0] : ""; return $nickid; } @@ -336,8 +220,8 @@ */ function getNickname($nickid) { - $nick = $this->getMeta("nickname", "fromnickid", $nickid); - if ($nick == NULL) $nick = ""; + $nick = $this->getMeta2("nickid-to-metadata", $nickid, 'nick', true); + $nick = isset($nick["value"][0]) ? $nick["value"][0] : ""; return $nick; } @@ -348,70 +232,31 @@ * @param $timeout * @return array("nickid"=>array("nickid1", ...),"timestamp"=>array(timestamp1, ...)) contains all disconnected nickids and there timestamp */ - function removeObsoleteNick($chan, $timeout) + function removeObsoleteNick($timeout) { $c =& $this->c; - $nick_dir = ($chan != NULL) ? - $c->container_cfg_channel_dir."/".$this->_encode($chan)."/nicknames" : - $c->container_cfg_server_dir."/nicknames"; - // check the nickname directory exists - $errors = @test_writable_dir($nick_dir, $chan."/nicknames"); - - $deleted_user = array(); - $online_user = array(); - $dir_handle = opendir($nick_dir); - while (false !== ($file = readdir($dir_handle))) - { - if ($file == "." || $file == "..") continue; // skip . and .. generic files - $f_time = filemtime($nick_dir."/".$file); - if (time() > ($f_time+$timeout/1000) ) // user will be disconnected after 'timeout' secondes of inactivity - { - $deleted_user["nick"][] = $this->getNickname($file); - $deleted_user["nickid"][] = $file; - $deleted_user["timestamp"][] = $f_time; - @unlink($nick_dir."/".$file); // disconnect expired user - } - else - { - // optimisation: cache user list for next getOnlineNick call - $online_user["nickid"][] = $file; - $online_user["timestamp"][] = $f_time; - } - } + $chan = 'SERVER'; - // remove the user metadata if he is disconnected from the server - if (isset($deleted_user["nickid"]) && count($deleted_user["nickid"])>0) + $deleted_user = array('nick'=>array(), + 'nickid'=>array(), + 'timestamp'=>array(), + 'channels'=>array()); + $ret = $this->getMeta2("channelid-to-nickid", $this->_encode($chan)); + for($i = 0; $i<count($ret['timestamp']); $i++) { - foreach($deleted_user["nickid"] as $du_nid) + $timestamp = $ret['timestamp'][$i]; + $nickid = $ret['value'][$i]; + if (time() > ($timestamp+$timeout/1000) ) // user will be disconnected after 'timeout' secondes of inactivity { - $du_nickid = $du_nid; - $du_nickname = $this->getNickname($du_nid); - - $this->_unregisterUserMeta($du_nickid, $chan); - - /* - // decrement the nick references and kill the metadata if not more references is found - // (used to know when the nick is really disconnected) - $nick_ref = $this->getMeta("references", $du_nickid); - if ($nick_ref == NULL || !is_numeric($nick_ref)) $nick_ref = 0; - $nick_ref--; - if ($nick_ref <= 0) - { - $this->rmMeta("nickid", "fromnickname", $du_nickname); - $this->rmMeta("nickname", "fromnickid", $du_nickid); - $this->rmMeta("references", $du_nickid); // destroy also the reference counter (by default its value is 0) - } - else - $this->setMeta($nick_ref, "references", $du_nickid); - */ + $du = $this->removeNick($nickid); + $deleted_user["nick"] = array_merge($deleted_user["nick"], $du["nick"]); + $deleted_user["nickid"] = array_merge($deleted_user["nickid"], $du["nickid"]); + $deleted_user["timestamp"] = array_merge($deleted_user["timestamp"], $du["timestamp"]); + $deleted_user["channels"] = array_merge($deleted_user["channels"], $du["channels"]); } } - - // cache the updated user list - $_chan = ($chan == NULL) ? "SERVER" : $chan; - $this->_users[$_chan] =& $online_user; - + return $deleted_user; } @@ -422,31 +267,25 @@ */ function getOnlineNick($chan) { - // return the cached user list if it exists - $_chan = ($chan == NULL) ? "SERVER" : $chan; - if (isset($this->_users[$_chan]) && is_array($this->_users[$_chan])) - return $this->_users[$_chan]; - $c =& $this->c; - - $nick_dir = ($chan != NULL) ? - $c->container_cfg_channel_dir."/".$this->_encode($chan)."/nicknames" : - $c->container_cfg_server_dir."/nicknames"; - if (!is_dir($nick_dir)) mkdir_r($nick_dir); + if ($chan == NULL) $chan = 'SERVER'; + $online_user = array(); - $dir_handle = opendir($nick_dir); - while (false !== ($file = readdir($dir_handle))) + $ret = $this->getMeta2("channelid-to-nickid", $this->_encode($chan)); + for($i = 0; $i<count($ret['timestamp']); $i++) { - if ($file == "." || $file == "..") continue; // skip . and .. generic files - $online_user["nickid"][] = $file; - $online_user["timestamp"][] = filemtime($nick_dir."/".$file); - } + $nickid = $ret['value'][$i]; - // cache the user list - $this->_users[$_chan] =& $online_user; + // get timestamp from the SERVER channel + $timestamp = $this->getMeta2("channelid-to-nickid", $this->_encode('SERVER'), $nickid); + $timestamp = $timestamp['timestamp'][0]; - return $this->_users[$_chan]; + $online_user["nick"][] = $this->getNickname($nickid); + $online_user["nickid"][] = $nickid; + $online_user["timestamp"][] = $timestamp; + } + return $online_user; } /** @@ -454,41 +293,16 @@ * @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) + function isNickOnline($chan, $nickid) { - // @todo optimise with this piece of code - /* - $nickid = $this->getNickId($nick); - if ($nickid == "undefined") return false; + if ($chan == NULL) $chan = 'SERVER'; - $nick_dir = ($chan != NULL) ? - $c->container_cfg_channel_dir."/".$this->_encode($chan)."/nicknames" : - $c->container_cfg_server_dir."/nicknames"; - if (!is_dir($nick_dir)) mkdir_r($nick_dir); - - return file_exists($nick_dir."/".$nickid); - */ - - $nickid = $this->getNickId($nick); - - // get the nickname list - $_chan = ($chan == NULL) ? "SERVER" : $chan; - $online_user = isset($this->_users[$_chan]) ? $this->_users[$_chan] : $this->getOnlineNick($chan); - - $uid = 0; - $isonline = false; - if (!isset($online_user["nickid"])) return -1; - while($uid < count($online_user["nickid"]) && !$isonline) + $ret = $this->getMeta2("channelid-to-nickid", $this->_encode($chan)); + for($i = 0; $i<count($ret['timestamp']); $i++) { - if ($online_user["nickid"][$uid] == $nickid) - $isonline = true; - else - $uid++; + if ($ret['value'][$i] == $nickid) return $i; } - if ($isonline) - return $uid; - else - return -1; + return -1; } /** @@ -501,24 +315,15 @@ * @return $msg_id the created message identifier */ function write($chan, $nick, $cmd, $param) - { + { $c =& $this->c; + if ($chan == NULL) $chan = 'SERVER'; + + $msgid = $this->_requestMsgId($chan); - $msg_dir = ($chan != NULL) ? - $c->container_cfg_channel_dir."/".$this->_encode($chan)."/messages" : - $c->container_cfg_server_dir."/messages"; - // check the messages directory exists - $errors = @test_writable_dir($msg_dir, $chan."/messages"); - if (count($errors) > 0) return $errors; // an error occurs ? - - // request a unique id for this new message - $msg_id = $this->_requestMsgId($chan); - if (is_array($msg_id)) return $msg_id; // an error occurs ? - $msg_filename = $msg_dir."/".$msg_id; - // format message $data = "\n"; - $data .= $msg_id."\t"; + $data .= $msgid."\t"; $data .= date("d/m/Y")."\t"; $data .= date("H:i:s")."\t"; $data .= $nick."\t"; @@ -526,14 +331,14 @@ $data .= $param; // write message - file_put_contents($msg_filename, $data); + $this->setMeta2("channelid-to-msg", $this->_encode($chan), $msgid, $data); // delete the obsolete message - $old_msg_id = $msg_id - $c->max_msg - 20; - if ($old_msg_id > 0 && file_exists($msg_dir."/".$old_msg_id)) - @unlink($msg_dir."/".$old_msg_id); - - return $msg_id; + $old_msgid = $msgid - $c->max_msg - 20; + if ($old_msgid > 0) + $this->rmMeta2("channelid-to-msg", $this->_encode($chan), $old_msgid); + + return $msgid; } /** @@ -546,36 +351,29 @@ function read($chan, $from_id) { $c =& $this->c; - - $msg_dir = ($chan != NULL) ? - $c->container_cfg_channel_dir."/".$this->_encode($chan)."/messages" : - $c->container_cfg_server_dir."/messages"; - // check the messages directory exists - $errors = @test_writable_dir($msg_dir, $chan."/messages"); + if ($chan == NULL) $chan = 'SERVER'; - - // read the files into the directory - // sort it by filename order (id order) - // then take only the > $from_id messages - $newmsg = array(); + // read new messages id + $new_msgid_list = array(); $new_from_id = $from_id; - $dir_handle = opendir($msg_dir); - while (false !== ($file = readdir($dir_handle))) + $msgid_list = $this->getMeta2("channelid-to-msg", $this->_encode($chan)); + for($i = 0; $i<count($msgid_list["value"]); $i++) { - if ($file == "." || $file == "..") continue; // skip . and .. generic files - if ($file>$from_id) + $msgidtmp = $msgid_list["value"][$i]; + + if ($msgidtmp > $from_id) { - if ($file > $new_from_id) - $new_from_id = $file; - $newmsg[] = $file; + if ($msgidtmp > $new_from_id) $new_from_id = $msgidtmp; + $new_msgid_list[] = $msgidtmp; } } - - // format content + + // read messages content and parse content $datalist = array(); - foreach ( $newmsg as $m ) + foreach ( $new_msgid_list as $mid ) { - $line = file_get_contents($msg_dir."/".$m); + $line = $this->getMeta2("channelid-to-msg", $this->_encode($chan), $mid, true); + $line = $line["value"][0]; if ($line != "" && $line != "\n") { $formated_line = explode( "\t", $line ); @@ -603,131 +401,17 @@ */ function getLastId($chan) { - $c =& $this->c; + if ($chan == NULL) $chan = 'SERVER'; - // calculate the messages.index location - $chan_dir = ($chan != NULL) ? - $c->container_cfg_channel_dir."/".$this->_encode($chan) : - $c->container_cfg_server_dir; - $index_filename = $chan_dir . "/messages.index"; - - // read last message id - $lastid = trim(@file_get_contents($index_filename)); - if (!is_numeric($lastid)) $lastid = 0; - - return $lastid; - } - - - /** - * Read meta data identified by a key - * As an example the default file container store metadata into metadata/type/subtype/hash(key) - * @param $key is the index which identify a metadata - * @param $type is used to "group" some metadata - * @param $subtype is used to "group" precisely some metadata, use NULL to ignore it - * @return mixed the value assigned to the key, NULL if not found - */ - function getMeta($key, $type, $subtype = NULL) - { - // encode parameters - $enc_key = $this->_encode($key); - $enc_type = $this->_encode($type); - $enc_subtype = ($subtype == NULL) ? "NULL" : $this->_encode($subtype); - if (isset($this->_meta[$enc_type][$enc_subtype][$enc_key])) - return $this->_meta[$enc_type][$enc_subtype][$enc_key]; - - // read data from metadata file - $c =& $this->c; - $dir_base = $c->container_cfg_meta_dir; - $dir = $dir_base."/".$enc_type.($enc_subtype == "NULL" ? "" : "/".$enc_subtype); - $filename = $dir."/".$enc_key; - $ret = @file_get_contents($filename); - if ($ret == false) $ret = NULL; - - // store the result in the cache - $this->_meta[$enc_type][$enc_subtype][$enc_key] = $ret; - - return $ret; - } - - /** - * Write a meta data value identified by a key - * As an example the default file container store metadata into metadata/type/subtype/hash(key) - * @param $key is the index which identify a metadata - * @param $value is the value associated to the key - * @param $type is used to "group" some metadata - * @param $subtype is used to "group" precisely some metadata, use NULL to ignore it - * @return true on success, false on error - */ - function setMeta($value, $key, $type, $subtype = NULL) - { - // encode parameters - $enc_key = $this->_encode($key); - $enc_type = $this->_encode($type); - $enc_subtype = ($subtype == NULL) ? "NULL" : $this->_encode($subtype); - - // create directories - $c =& $this->c; - $dir_base = $c->container_cfg_meta_dir; - $dir = $dir_base."/".$enc_type.($enc_subtype == "NULL" ? "" : "/".$enc_subtype); - if (!is_dir($dir)) mkdir_r($dir); - - // create or replace metadata file - $filename = $dir."/".$enc_key; - $ret = @file_put_contents($filename, $value); - - // store the value in the cache - if ($ret) $this->_meta[$enc_type][$enc_subtype][$enc_key] = $value; - - if ($ret == false) - return false; + $lastmsgid = $this->getMeta2("channelid-to-msgid", $this->_encode($chan), 'lastmsgid', true); + if (count($lastmsgid["value"]) == 0) + $lastmsgid = 0; else - return true; + $lastmsgid = $lastmsgid["value"][0]; + return $lastmsgid; } - /** - * Remove a meta data key/value couple - * Notice: if key is NULL then all the meta data must be removed - * @param $key is the key to delete, use NULL to delete all the metadata - * @param $type is used to "group" some metadata - * @param $subtype is used to "group" precisely some metadata, use NULL to ignore it - * @return true on success, false on error - */ - function rmMeta($key, $type, $subtype = NULL) - { - $c =& $this->c; - - // encode parameters - $enc_key = ($key == NULL) ? "NULL" : $this->_encode($key); - $enc_type = $this->_encode($type); - $enc_subtype = ($subtype == NULL) ? "NULL" : $this->_encode($subtype); - // rm data from metadata file - $dir_base = $c->container_cfg_meta_dir; - $dir = $dir_base."/".$enc_type.($enc_subtype == "NULL" ? "" : "/".$enc_subtype); - $ret = true; - if ($enc_key == "NULL") - { - // remove all keys (the complete directory) - @rm_r($dir); - - // remove the cached data - unset($this->_meta[$enc_type][$enc_subtype]); - } - else - { - // just remove one key - $filename = $dir."/".$enc_key; - $ret = @unlink($filename); - - // remove the cached data - if (isset($this->_meta[$enc_type][$enc_subtype][$enc_key])) - unset($this->_meta[$enc_type][$enc_subtype][$enc_key]); - } - - return $ret; - } - /** * Remove all created data for this server (identified by serverid) * Notice: for the default File container, it's just a recursive directory remove @@ -739,56 +423,11 @@ $dir = $c->container_cfg_server_dir; @rm_r($dir); // empty the cache - $this->_meta = array(); - $this->_users = array("nickid" => array(), - "timestamp" => array()); + // $this->_meta = array(); + // $this->_users = array("nickid" => array(), + // "timestamp" => array()); } - function _registerUserMeta($nickid, $chan) - { - $c =& $this->c; - // create or update the nickname references (used to know when the nick is really disconnected) - if ($chan == NULL) $chan = "SERVER"; - $ref = $this->getMeta("references", $nickid); - if ($ref == NULL) - $ref = array(); - else - $ref = explode(';',$ref); - if ($c->debug) pxlog("registerUserMeta -> ref=".implode(';',$ref), "chat", $c->getId()); - if (in_array($chan,$ref)) - return; - else - $ref[] = $chan; - $ref = implode(';',$ref); - $this->setMeta($ref, "references", $nickid); - } - - function _unregisterUserMeta($nickid, $chan) - { - $c =& $this->c; - // decrement the nick references and kill the metadata if not more references is found - // (used to know when the nick is really disconnected) - if ($chan == NULL) $chan = "SERVER"; - $nickname = $this->getNickname($nickid); - $ref = $this->getMeta("references", $nickid); - if ($ref == NULL) $ref = ''; - $ref = explode(';',$ref); - $ref = array_diff($ref, array($chan)); - if (count($ref) == 0) - { - $this->rmMeta("nickid", "fromnickname", $nickname); - $this->rmMeta("nickname", "fromnickid", $nickid); - $this->rmMeta("references", $nickid); // destroy also the reference counter - if ($c->debug) pxlog("_unregisterUserMeta -> destroy!", "chat", $c->getId()); - } - else - { - $ref = implode(';',$ref); - $this->setMeta($ref, "references", $nickid); - if ($c->debug) pxlog("_unregisterUserMeta -> ref=".$ref, "chat", $c->getId()); - } - } - /** * Return a unique id. Each time this function is called, the last id is incremented. @@ -797,38 +436,13 @@ */ function _requestMsgId($chan) { - $c =& $this->c; - - // calculate the messages.index location - $chan_dir = ($chan != NULL) ? - $c->container_cfg_channel_dir."/".$this->_encode($chan) : - $c->container_cfg_server_dir; - // check the directory exists - $errors = @test_writable_dir($chan_dir, $chan_dir); - if (count($errors) > 0) return $errors; + if ($chan == NULL) $chan = 'SERVER'; - $index_filename = $chan_dir . "/messages.index"; + $lastmsgid = $this->getLastId($chan); + $lastmsgid++; + $this->setMeta2("channelid-to-msgid", $this->_encode($chan), 'lastmsgid', $lastmsgid); - // read last message id - $msg_id = 0; - if (!file_exists($index_filename)) - file_put_contents($index_filename, "0"); - $fp = fopen($index_filename, "rw+"); - if (is_resource($fp)) - { - flock ($fp, LOCK_EX); - $msg_id = fread($fp, filesize($index_filename)); - if (!is_numeric($msg_id)) $msg_id = 0; - // increment message id and save it - $msg_id++; - ftruncate($fp, 0); - fseek($fp, 0); - fwrite($fp, $msg_id); - flock ($fp, LOCK_UN); - fclose($fp); - } - - return $msg_id; + return $lastmsgid; } /** @@ -837,6 +451,7 @@ */ function _encode($str) { + return urlencode($str); return base64_encode(urlencode($str)); } @@ -846,6 +461,7 @@ */ function _decode($str) { + return urldecode($str); return urldecode(base64_decode($str)); } @@ -873,17 +489,19 @@ $dir_base = $c->container_cfg_meta_dir; $dir = $dir_base.'/'.$group.'/'.$subgroup; if (!is_dir($dir)) mkdir_r($dir); - + // create or replace metadata file $leaffilename = $dir."/".$leaf; $leafexists = file_exists($leaffilename); if ($leafvalue == NULL) { - @touch($leaffilename); + if (file_exists($leaffilename) && + filesize($leaffilename)>0) unlink($leaffilename); + touch($leaffilename); } else { - @file_put_contents($leaffilename, $leafvalue); + file_put_contents($leaffilename, $leafvalue); } // store the value in the memory cache @@ -919,12 +537,15 @@ if ($subgroup == NULL) { - $dh = opendir($dir); - while (false !== ($file = readdir($dh))) + if (is_dir($dir)) { - if ($file == "." || $file == "..") continue; // skip . and .. generic files - $ret["timestamp"][] = @filemtime($dir.'/'.$file); - $ret["value"][] = $file; + $dh = opendir($dir); + while (false !== ($file = readdir($dh))) + { + if ($file == "." || $file == "..") continue; // skip . and .. generic files + $ret["timestamp"][] = filemtime($dir.'/'.$file); + $ret["value"][] = $file; + } } return $ret; } @@ -933,13 +554,16 @@ if ($leaf == NULL) { - $dh = opendir($dir); - $ret = array(); - while (false !== ($file = readdir($dh))) + if (is_dir($dir)) { - if ($file == "." || $file == "..") continue; // skip . and .. generic files - $ret["timestamp"][] = @filemtime($dir.'/'.$file); - $ret["value"][] = $file; + $dh = opendir($dir); + $ret = array(); + while (false !== ($file = readdir($dh))) + { + if ($file == "." || $file == "..") continue; // skip . and .. generic files + $ret["timestamp"][] = filemtime($dir.'/'.$file); + $ret["value"][] = $file; + } } return $ret; } @@ -949,12 +573,9 @@ if (!file_exists($leaffilename)) return $ret; if ($withleafvalue) { - $ret["value"][] = @file_get_contents($leaffilename); + $ret["value"][] = file_get_contents($leaffilename); } - else - { - $ret["timestamp"][] = @filemtime($leaffilename); - } + $ret["timestamp"][] = filemtime($leaffilename); // @todo // store the result in the memory cache @@ -983,7 +604,7 @@ if ($subgroup == NULL) { - @rm_r($dir); + rm_r($dir); return true; } @@ -991,14 +612,14 @@ if ($leaf == NULL) { - @rm_r($dir); + rm_r($dir); return true; } $leaffilename = $dir."/".$leaf; if (!file_exists($leaffilename)) return false; - @unlink($leaffilename); + unlink($leaffilename); return true; } Modified: trunk/testcase/container_file.php =================================================================== --- trunk/testcase/container_file.php 2006-09-19 06:51:13 UTC (rev 769) +++ trunk/testcase/container_file.php 2006-09-19 15:25:50 UTC (rev 770) @@ -25,7 +25,257 @@ function tearDown() { pfcContainerTestcase::tearDown(); - } + } + + function test_setMeta_File_1() + { + $c =& $this->c; + $ct =& $this->ct; + + $prefix = __FUNCTION__; + $group = $prefix."_nickid-to-channelid"; + $subgroup = $prefix."_nickid1"; + $leaf = $prefix."_channelid1"; + $ret = $ct->setMeta2($group, $subgroup, $leaf); + $this->assertEquals($ret, 0, "the leaf should be first time created"); + + $f = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup.'/'.$leaf; + $ret = file_exists($f); + $this->assertEquals($ret, true, "the leaf file should exists"); + + $ret = file_get_contents($f); + $this->assertEquals($ret, '', "the leaf file should contain nothing"); + } + + function test_setMeta_File_2() + { + $c =& $this->c; + $ct =& $this->ct; + + $prefix = __FUNCTION__; + $group = $prefix."_nickid-to-channelid"; + $subgroup = $prefix."_nickid1"; + $leaf = $prefix."_channelid1"; + $leafvalue = $prefix."_leafvalue1"; + $ret = $ct->setMeta2($group, $subgroup, $leaf, $leafvalue); + $this->assertEquals($ret, 0, "the leaf should be first time created"); + + $f = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup.'/'.$leaf; + $ret = file_exists($f); + $this->assertEquals($ret, true, "the leaf file should exists"); + + $ret = file_get_contents($f); + $this->assertEquals($ret, $leafvalue, "the leaf file should contain the value"); + } + + function test_setMeta_File_3() + { + $c =& $this->c; + $ct =& $this->ct; + + $prefix = __FUNCTION__; + $group = $prefix."_nickid-to-channelid"; + $subgroup = $prefix."_nickid1"; + $leaf = $prefix."_channelid1"; + $leafvalue = $prefix."_leafvalue1"; + + $ret = $ct->setMeta2($group, $subgroup, $leaf, $leafvalue); + $this->assertEquals($ret, 0, "the leaf should be first time created"); + + $leafvalue = null; + $ret = $ct->setMeta2($group, $subgroup, $leaf, $leafvalue); + $this->assertEquals($ret, 1, "the leaf should be overwritten"); + + $f = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup.'/'.$leaf; + $ret = file_exists($f); + $this->assertEquals($ret, true, "the leaf file should exists"); + + $ret = file_get_contents($f); + $this->assertEquals($ret, '', "the leaf file should contain nothing"); + } + + + function test_getMeta_File_1() + { + $c =& $this->c; + $ct =& $this->ct; + + $prefix = __FUNCTION__; + $group = $prefix."_nickid-to-channelid"; + $subgroup = $prefix."_nickid1"; + $leaf = $prefix."_channelid1"; + $ct->setMeta2($group, $subgroup, $leaf); + $time = time(); + + $ret = $ct->getMeta2($group, $subgroup, $leaf); + $this->assertEquals(count($ret["timestamp"]), 1, "number of leaf is wrong"); + $this->assertEquals($ret["timestamp"][0], $time, "the leaf timestamp is wrong"); + $this->assertEquals($ret["value"][0], null, "the leaf value is wrong"); + + $ret = $ct->getMeta2($group, $subgroup); + $this->assertEquals(count($ret["timestamp"]), 1, "number of leaf is wrong"); + $this->assertEquals($ret["timestamp"][0], $time, "the leaf timestamp is wrong"); + $this->assertEquals($ret["value"][0], $leaf, "the leaf name is wrong"); + + $leafvalue = $prefix."_leafvalue"; + $ct->setMeta2($group, $subgroup, $leaf, $leafvalue); + $time = time(); + + $ret = $ct->getMeta2($group, $subgroup, $leaf, true); + $this->assertEquals(count($ret["timestamp"]), 1, "number of leaf is wrong"); + $this->assertEquals($ret["timestamp"][0], $time, "the leaf timestamp is wrong"); + $this->assertEquals($ret["value"][0], $leafvalue, "the leaf value is wrong"); + } + + function test_getMeta_File_2() + { + $c =& $this->c; + $ct =& $this->ct; + + $prefix = __FUNCTION__; + $group = $prefix."_nickid-to-channelid"; + $subgroup = $prefix."_nickid1"; + $leaf1 = $prefix."_channelid1"; + $leaf2 = $prefix."_channelid2"; + $ct->setMeta2($group, $subgroup, $leaf1); + $ct->setMeta2($group, $subgroup, $leaf2); + $time = time(); + + $ret = $ct->getMeta2($group, $subgroup); + asort($ret["value"]); + $this->assertEquals(count($ret["timestamp"]), 2, "number of leaf is wrong"); + $this->assertEquals($ret["timestamp"][0], $time, "the leaf timestamp is wrong"); + $this->assertEquals($ret["timestamp"][1], $time, "the leaf timestamp is wrong"); + $this->assertEquals($ret["value"][0], $leaf1, "the leaf name is wrong"); + $this->assertEquals($ret["value"][1], $leaf2, "the leaf name is wrong"); + } + + function test_getMeta_File_3() + { + $c =& $this->c; + $ct =& $this->ct; + + $prefix = __FUNCTION__; + $group = $prefix."_nickid-to-channelid"; + $subgroup1 = $prefix."_nickid1"; + $subgroup2 = $prefix."_nickid2"; + $leaf1 = $prefix."_channelid1"; + $leaf2 = $prefix."_channelid2"; + $ct->setMeta2($group, $subgroup1, $leaf1); + $ct->setMeta2($group, $subgroup1, $leaf2); + $ct->setMeta2($group, $subgroup2, $leaf1); + $ct->setMeta2($group, $subgroup2, $leaf2); + $time = time(); + + $ret = $ct->getMeta2($group); + asort($ret["value"]); + $this->assertEquals(count($ret["timestamp"]), 2, "number of subgroup is wrong"); + $this->assertEquals($ret["timestamp"][0], $time, "the subgroup timestamp is wrong"); + $this->assertEquals($ret["timestamp"][1], $time, "the subgroup timestamp is wrong"); + $this->assertEquals($ret["value"][0], $subgroup1, "the subgroup name is wrong"); + $this->assertEquals($ret["value"][1], $subgroup2, "the subgroup name is wrong"); + } + + function test_rmMeta_File_1() + { + $c =& $this->c; + $ct =& $this->ct; + + $prefix = __FUNCTION__; + $group = $prefix."_nickid-to-channelid"; + $subgroup = $prefix."_nickid1"; + $leaf = $prefix."_channelid1"; + $ret = $ct->setMeta2($group, $subgroup, $leaf); + + $ret = $ct->rmMeta2($group, $subgroup, $leaf); + $this->assertEquals($ret, true, "the returned value should be true (rm success)"); + + $f = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup.'/'.$leaf; + $ret = file_exists($f); + $this->assertEquals($ret, false, "the leaf file should not exists anymore"); + } + + function test_rmMeta_File_2() + { + $c =& $this->c; + $ct =& $this->ct; + + $prefix = __FUNCTION__; + $group = $prefix."_nickid-to-channelid"; + $subgroup = $prefix."_nickid1"; + $leaf1 = $prefix."_channelid1"; + $leaf2 = $prefix."_channelid2"; + $ret = $ct->setMeta2($group, $subgroup, $leaf1); + $ret = $ct->setMeta2($group, $subgroup, $leaf2); + + $ret = $ct->rmMeta2($group, $subgroup); + $this->assertEquals($ret, true, "the returned value should be true (rm success)"); + + $f = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup.'/'.$leaf1; + $ret = file_exists($f); + $this->assertEquals($ret, false, "the leaf file should not exists anymore"); + $f = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup.'/'.$leaf2; + $ret = file_exists($f); + $this->assertEquals($ret, false, "the leaf file should not exists anymore"); + + $d = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup; + $ret = file_exists($f); + $this->assertEquals($ret, false, "the subgroup directory should not exists anymore"); + } + + function test_rmMeta_File_3() + { + $c =& $this->c; + $ct =& $this->ct; + + $prefix = __FUNCTION__; + $group = $prefix."_nickid-to-channelid"; + $subgroup = $prefix."_nickid1"; + $leaf1 = $prefix."_channelid1"; + $leaf2 = $prefix."_channelid2"; + $ret = $ct->setMeta2($group, $subgroup, $leaf1); + $ret = $ct->setMeta2($group, $subgroup, $leaf2); + + $ret = $ct->rmMeta2($group); + $this->assertEquals($ret, true, "the returned value should be true (rm success)"); + + $f = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup.'/'.$leaf1; + $ret = file_exists($f); + $this->assertEquals($ret, false, "the leaf file should not exists anymore"); + $f = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup.'/'.$leaf2; + $ret = file_exists($f); + $this->assertEquals($ret, false, "the leaf file should not exists anymore"); + + $d = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup; + $ret = file_exists($d); + $this->assertEquals($ret, false, "the subgroup directory should not exists anymore"); + + $d = $c->container_cfg_meta_dir.'/'.$group; + $ret = file_exists($d); + $this->assertEquals($ret, false, "the group directory should not exists anymore"); + } + + + function test_encodedecode_File_1() + { + $c =& $this->c; + $ct =& $this->ct; + + $string = "il était une fois C;h:!?§+ toto=}at是"; + + $prefix = __FUNCTION__; + $group = $prefix."_nickid-to-channelid"; + $subgroup = $prefix."_nickid1"; + $leaf = $prefix."_".$ct->_encode($string); + $leafvalue = $string; + $ct->setMeta2($group, $subgroup, $leaf, $leafvalue); + + $ret = $ct->getMeta2($group, $subgroup); + $this->assertEquals($ret['value'][0], $leaf, "the leaf name is wrong"); + $ret = $ct->getMeta2($group, $subgroup, $leaf, true); + $this->assertEquals($ret['value'][0], $leafvalue, "the leaf value is wrong"); + } + } // on desactive le timeout car se script peut mettre bcp de temps a s'executer Modified: trunk/testcase/container_generic.php =================================================================== --- trunk/testcase/container_generic.php 2006-09-19 06:51:13 UTC (rev 769) +++ trunk/testcase/container_generic.php 2006-09-19 15:25:50 UTC (rev 770) @@ -30,12 +30,12 @@ require_once dirname(__FILE__)."/../src/pfcglobalconfig.class.php"; $params = array(); $params["title"] = "testcase -> pfccontainer_".$this->type; - $params["serverid"] = md5(__FILE__ . time()); + $params["serverid"] = md5(__FILE__/* . time()*/); $params["container_type"] = $this->type; $this->c =& pfcGlobalConfig::Instance($params); $this->ct =& $this->c->getContainerInstance(); } - + // called after the test functions are executed // this function is defined in PHPUnit_TestCase and overwritten // here @@ -45,45 +45,48 @@ $this->c->destroyCache(); } + function testCreateNick_Generic() { $c =& $this->c; $ct =& $this->ct; - $nick = $this->nick; - $nickid = $this->nickid; - $chan = $this->chan; + $prefix = __FUNCTION__; + $nick = $prefix . '_' . $this->nick; + $nickid = $prefix . '_' . $this->nickid; + $chan = $prefix . '_' . $this->chan; // create on the channel $this->ct->createNick($chan, $nick, $nickid); - $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); + $isonline = ($this->ct->isNickOnline($chan, $nickid) >= 0); $this->assertTrue($isonline, "nickname should be online on the channel"); // create on the server $chan = NULL; $this->ct->createNick($chan, $nick, $nickid); - $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); + $isonline = ($this->ct->isNickOnline($chan, $nickid) >= 0); $this->assertTrue($isonline, "nickname should be online on the server"); } - + function testRemoveNick_Generic() { $c =& $this->c; $ct =& $this->ct; - $nick = $this->nick; - $nickid = $this->nickid; - $chan = $this->chan; + $prefix = __FUNCTION__; + $nick = $prefix . '_' . $this->nick; + $nickid = $prefix . '_' . $this->nickid; + $chan = $prefix . '_' . $this->chan; // on the channel $this->ct->createNick($chan, $nick, $nickid); - $this->ct->removeNick($chan, $nick); - $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); + $this->ct->removeNick($nickid); + $isonline = ($this->ct->isNickOnline($chan, $nickid) >= 0); $this->assertFalse($isonline, "nickname shouldn't be online on the channel"); // on the server $chan = NULL; $this->ct->createNick($chan, $nick, $nickid); - $this->ct->removeNick($chan, $nick); - $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); + $this->ct->removeNick($nickid); + $isonline = ($this->ct->isNickOnline($chan, $nickid) >= 0); $this->assertFalse($isonline, "nickname shouldn't be online on the server"); } @@ -91,159 +94,165 @@ { $c =& $this->c; $ct =& $this->ct; - $nick = $this->nick; - $nickid = $this->nickid; - $chan = $this->chan; + $prefix = __FUNCTION__; + $nick = $prefix . '_' . $this->nick; + $nickid = $prefix . '_' . $this->nickid; + $chan = $prefix . '_' . $this->chan; $this->ct->createNick(NULL, $nick, $nickid); $ret = $this->ct->getNickId($nick); $this->assertEquals($nickid, $ret, "created nickname doesn't have a correct nickid"); } - - function testRemoveObsoleteNick_Generic() + + + function testGetNickname_Generic() { $c =& $this->c; $ct =& $this->ct; - $nick = $this->nick; - $nickid = $this->nickid; - $chan = $this->chan; + $prefix = __FUNCTION__; + $nick = $prefix . '_' . $this->nick; + $nickid = $prefix . '_' . $this->nickid; + $chan = $prefix . '_' . $this->chan; // on the channel $this->ct->createNick($chan, $nick, $nickid); - sleep(2); - $ret = $this->ct->removeObsoleteNick($chan, 1000); - $this->assertEquals(count($ret["nickid"]), 1, "1 nickname should be obsolete"); - $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); - $this->assertFalse($isonline, "nickname shouldn't be online anymore"); - - // on the server - $chan = NULL; + + $ret = $this->ct->getNickname($nickid); + $this->assertEquals($nick, $ret, "nickname value is wrong"); + } + + function testGetOnlineNick_Generic() + { + $c =& $this->c; + $ct =& $this->ct; + $prefix = __FUNCTION__; + $nick = $prefix . '_' . $this->nick; + $nickid = $prefix . '_' . $this->nickid; + $chan = $prefix . '_' . $this->chan; + + // on the channel $this->ct->createNick($chan, $nick, $nickid); - sleep(2); - $ret = $this->ct->removeObsoleteNick($chan, 1000); - $this->assertEquals(count($ret["nickid"]), 1, "1 nickname should be obsolete"); - $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); - $this->assertFalse($isonline, "nickname shouldn't be online anymore"); + $time = time(); + $ret = $this->ct->getOnlineNick($chan); + $this->assertEquals(1, count($ret["nickid"]), "1 nickname should be online"); + $this->assertEquals(1, count($ret["nick"]), "1 nickname should be online"); + $this->assertEquals(1, count($ret["timestamp"]), "1 nickname should be online"); + + $this->assertEquals($time, $ret["timestamp"][0], "nickname timestamp is wrong"); + $this->assertEquals($nick, $ret["nick"][0], "nickname value is wrong"); + $this->assertEquals($nickid, $ret["nickid"][0], "nickname id is wrong"); } + - function testSetGetRmMeta_Generic() + function testRemoveObsoleteNick_Generic() { $c =& $this->c; $ct =& $this->ct; - $nick = $this->nick; - $nickid = $this->nickid; - $chan = $this->chan; + $prefix = __FUNCTION__; + $nick = $prefix . '_' . $this->nick; + $nickid = $prefix . '_' . $this->nickid; + $chan = $prefix . '_' . $this->chan; - // set / get - $this->ct->setMeta($nickid, "key1", "nickname", $nick); - $metadata = $this->ct->getMeta("key1", "nickname", $nick); - $this->assertEquals($nickid, $metadata, "metadata value is not correct"); - - // set / rm / get - $this->ct->setMeta($nickid, "key2", "nickname", $nick); - $metadata = $this->ct->getMeta("key2", "nickname", $nick); - $this->assertEquals($nickid, $metadata, "metadata value is not correct"); - $this->ct->rmMeta("key2", "nickname", $nick); - $metadata = $this->ct->getMeta("key2", "nickname", $nick); - $this->assertNull($metadata, "metadata should not exists anymore"); - - // set / rm (all) / get - $this->ct->setMeta($nickid, "key2", "nickname", $nick); - $metadata = $this->ct->getMeta("key2", "nickname", $nick); - $this->assertEquals($nickid, $metadata, "metadata value is not correct"); - $this->ct->rmMeta(NULL, "nickname", $nick); - $metadata = $this->ct->getMeta("key2", "nickname", $nick); - $this->assertNull($metadata, "metadata should not exists anymore"); - $metadata = $this->ct->getMeta("key1", "nickname", $nick); - $this->assertNull($metadata, "metadata should not exists anymore"); + $this->ct->createNick($chan, $nick, $nickid); + sleep(2); + $ret = $this->ct->removeObsoleteNick(1000); + $this->assertEquals(count($ret["nickid"]), 1, "1 nickname should be obsolete"); + $isonline = ($this->ct->isNickOnline($chan, $nickid) >= 0); + $this->assertFalse($isonline, "nickname shouldn't be online anymore"); } - + function testupdateNick_Generic() { $c =& $this->c; $ct =& $this->ct; - $nick = $this->nick; - $nickid = $this->nickid; - $chan = $this->chan; + $prefix = __FUNCTION__; + $nick = $prefix . '_' . $this->nick; + $nickid = $prefix . '_' . $this->nickid; + $chan = $prefix . '_' . $this->chan; - // on the channel $this->ct->createNick($chan, $nick, $nickid); sleep(2); - $ret = $this->ct->updateNick($chan, $nick); + $ret = $this->ct->updateNick($nickid); $this->assertTrue($ret, "nickname should be correctly updated"); - $ret = $this->ct->removeObsoleteNick($chan, 1000); - $this->assertFalse(in_array($nick, $ret), "nickname shouldn't be removed because it has been updated"); - $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); + + $ret = $this->ct->removeObsoleteNick(1000); + $this->assertFalse(in_array($nick, $ret['nick']), "nickname shouldn't be removed because it has been updated"); + $isonline = ($this->ct->isNickOnline($chan, $nickid) >= 0); $this->assertTrue($isonline, "nickname should be online"); - - // on the server - $chan = NULL; - $this->ct->createNick($chan, $nick, $nickid); - sleep(2); - $ret = $this->ct->updateNick($chan, $nick); - $this->assertTrue($ret, "nickname should be correctly updated"); - $ret = $this->ct->removeObsoleteNick($chan, 1000); - $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; - $nick1 = $this->nick; - $nick2 = $this->nick."2"; - $nickid = $this->nickid; - $chan = $this->chan; + $prefix = __FUNCTION__; + $nick1 = $prefix . '_' . $this->nick; + $nick2 = $prefix . '_' . $this->nick.'2'; + $nickid = $prefix . '_' . $this->nickid; + $chan = $prefix . '_' . $this->chan; // create a nick on a channel and change it $this->ct->createNick($chan, $nick1, $nickid); $ret = $this->ct->changeNick($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); + $isonline1 = ($this->ct->isNickOnline($chan, $this->ct->getNickId($nick1)) >= 0); + $isonline2 = ($this->ct->isNickOnline($chan, $this->ct->getNickId($nick2)) >= 0); $this->assertFalse($isonline1, "nickname shouldn't be online"); $this->assertTrue($isonline2, "nickname shouldn't be online"); } - + + function testgetLastId_Generic() + { + $c =& $this->c; + $ct =& $this->ct; + $prefix = __FUNCTION__; + $nick = $prefix . '_' . $this->nick; + $nickid = $prefix . '_' . $this->nickid; + $chan = $prefix . '_' . $this->chan; + $cmd = "send"; + $msg = "my test message"; + + // on the channel + $this->ct->createNick($chan, $nick, $nickid); + for($i = 0; $i < 10; $i++) + { + $msgid = $this->ct->write($chan, $nick, $cmd ,$msg . $i); + $this->assertEquals($msgid, $i+1,"generated msg_id is not correct"); + } + $msgid = $this->ct->getLastId($chan); + $this->assertEquals(10, $msgid, "last msgid is not correct"); + } + function testwrite_Generic() { $c =& $this->c; $ct =& $this->ct; - $nick = $this->nick; - $nickid = $this->nickid; - $chan = $this->chan; + $prefix = __FUNCTION__; + $nick = $prefix . '_' . $this->nick; + $nickid = $prefix . '_' . $this->nickid; + $chan = $prefix . '_' . $this->chan; $cmd = "send"; $msg = "my test message"; // create message on the channel $this->ct->createNick($chan, $nick, $nickid); $msgid = $this->ct->write($chan, $nick, $cmd, $msg); - $this->assertEquals($msgid, 1,"generated msg_id is not correct"); + $this->assertEquals(1, $msgid,"generated msg_id is not correct"); $res = $this->ct->read($chan, 0); $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); - $msgid = $this->ct->write($chan, $nick, $cmd, $msg); - $this->assertEquals($msgid, 1,"generated msg_id is not correct"); - $res = $this->ct->read($chan, 0); - $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"); + $this->assertEquals(1, $res["new_from_id"],"new_from_id is not correct"); } function testread_Generic() { $c =& $this->c; $ct =& $this->ct; - $nick = $this->nick; - $nickid = $this->nickid; - $chan = $this->chan; + $prefix = __FUNCTION__; + $nick = $prefix . '_' . $this->nick; + $nickid = $prefix . '_' . $this->nickid; + $chan = $prefix . '_' . $this->chan; $cmd = "send"; $msg = "my test message"; @@ -268,37 +277,6 @@ $this->assertEquals($res["new_from_id"], 10 ,"new_from_id is not correct"); } - function testgetLastId_Generic() - { - $c =& $this->c; - $ct =& $this->ct; - $nick = $this->nick; - $nickid = $this->nickid; - $chan = $this->chan; - $cmd = "send"; - $msg = "my test message"; - - // on the channel - $this->ct->createNick($chan, $nick, $nickid); - for($i = 0; $i < 10; $i++) - { - $msgid = $this->ct->write($chan, $nick, $cmd ,$msg . $i); - $this->assertEquals($msgid, $i+1,"generated msg_id is not correct"); - } - $msgid = $this->ct->getLastId($chan); - $this->assertEquals(10, $msgid, "last msgid is not correct"); - - // on the server - $chan = NULL; - $this->ct->createNick($chan, $nick, $nickid); - for($i = 0; $i < 10; $i++) - { - $msgid = $this->ct->write($chan, $nick, $cmd ,$msg . $i); - $this->assertEquals($msgid, $i+1,"generated msg_id is not correct"); - } - $msgid = $this->ct->getLastId($chan); - $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-09-19 21:33:10
|
Revision: 771 http://svn.sourceforge.net/phpfreechat/?rev=771&view=rev Author: kerphi Date: 2006-09-19 14:32:46 -0700 (Tue, 19 Sep 2006) Log Message: ----------- [en] Big containers refactoring: this make possible to handle easily user's metadata, fix a bug related to undisconnected but timeouted users and fix some memory leak in the default file container. [fr] Grosse reorganisation des containers : ceci rend possible le travail sur les metadonnees utilisateurs, regle un bug qui fesait que des utilisateurs deconnectes en timeout n'etait pas correctement deconnecte et resoud une fuitte de memoire dans le conteneur File. Modified Paths: -------------- trunk/src/commands/ban.class.php trunk/src/commands/banlist.class.php trunk/src/commands/connect.class.php trunk/src/commands/deop.class.php trunk/src/commands/identify.class.php trunk/src/commands/kick.class.php trunk/src/commands/op.class.php trunk/src/commands/privmsg.class.php trunk/src/commands/quit.class.php trunk/src/commands/unban.class.php trunk/src/commands/updatemynick.class.php trunk/src/containers/file.class.php trunk/src/phpfreechat.class.php trunk/src/proxys/auth.class.php trunk/src/proxys/checknickchange.class.php trunk/src/proxys/checktimeout.class.php trunk/src/proxys/noflood.class.php trunk/testcase/container_file.php trunk/testcase/container_generic.php Modified: trunk/src/commands/ban.class.php =================================================================== --- trunk/src/commands/ban.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/ban.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -31,9 +31,9 @@ $container =& $c->getContainerInstance(); $nickid = $container->getNickId($param); - if ($nickid != "undefined") + if ($nickid != "") { - $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); + $cmdtoplay = $container->getUserMeta($nickid, 'cmdtoplay'); $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); $cmdtmp = array("leave", /* cmdname */ @@ -44,17 +44,17 @@ ); //_pfc("banished from %s by %s", $recipient, $sender); $cmdtoplay[] = $cmdtmp; // ban the user from the current channel - $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $nickid); + $container->setUserMeta($nickid, 'cmdtoplay', serialize($cmdtoplay)); } // update the recipient banlist - $banlist = $container->getMeta("banlist_nickid", "channel", $recipientid); + $banlist = $container->getChanMeta($recipient, 'banlist_nickid'); if ($banlist == NULL) $banlist = array(); else $banlist = unserialize($banlist); $banlist[] = $nickid; // append the nickid to the banlist - $container->setMeta(serialize($banlist), "banlist_nickid", "channel", $recipientid); + $container->setChanMeta($recipient, 'banlist_nickid', serialize($banlist)); } } Modified: trunk/src/commands/banlist.class.php =================================================================== --- trunk/src/commands/banlist.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/banlist.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -17,7 +17,7 @@ $u =& $this->u; $container =& $c->getContainerInstance(); - $banlist = $container->getMeta("banlist_nickid", "channel", $p["recipientid"]); + $banlist = $container->getChanMeta($p["recipientid"], 'banlist_nickid'); if ($banlist == NULL) $banlist = array(); else $banlist = unserialize($banlist); $msg = ""; $msg .= "<p>"._pfc("The banished user's id list is:")."</p>"; Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/connect.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -50,9 +50,9 @@ // setup some user meta $nickid = $u->nickid; // store the user ip - $container->setMeta($_SERVER["REMOTE_ADDR"], "ip", "nickname", $nickid); + $container->setUserMeta($nickid, 'ip', $_SERVER["REMOTE_ADDR"]); // store the admin flag - $container->setMeta($isadmin, "isadmin", "nickname", $nickid); + $container->setUserMeta($nickid, 'isadmin', $isadmin); // connect to the server $xml_reponse->addScript("pfc.handleResponse('connect', 'ok', '');"); } Modified: trunk/src/commands/deop.class.php =================================================================== --- trunk/src/commands/deop.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/deop.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -26,7 +26,7 @@ $nicktodeop = trim($p["param"]); $container =& $c->getContainerInstance(); $nicktodeopid = $container->getNickId($nicktodeop); - $container->setMeta(false, "isadmin", "nickname", $nicktodeopid); + $container->setUserMeta($nicktodeopid, 'isadmin', false); } } Modified: trunk/src/commands/identify.class.php =================================================================== --- trunk/src/commands/identify.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/identify.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -58,7 +58,7 @@ { // ok the current user is an admin, just save the isadmin flag in the metadata $container =& $c->getContainerInstance(); - $container->setMeta($isadmin, "isadmin", "nickname", $u->nickid); + $container->setUserMeta($u->nickid, 'isadmin' $isadmin); $msg .= _pfc("Succesfully identified"); $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', '".$msg."');"); Modified: trunk/src/commands/kick.class.php =================================================================== --- trunk/src/commands/kick.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/kick.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -31,9 +31,9 @@ // kicking a user just add a command to play to the aimed user metadata. $container =& $c->getContainerInstance(); $nickid = $container->getNickId($param); - if ($nickid != "undefined") + if ($nickid != "") { - $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); + $cmdtoplay = $container->getUserMeta($nickid, 'cmdtoplay'); $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); $reason = _pfc("kicked from %s by %s", $u->channels[$recipientid]["name"], $sender); $cmdtmp = array("leave", /* cmdname */ @@ -43,7 +43,7 @@ $recipientid,/* recipientid */ ); $cmdtoplay[] = $cmdtmp; // kick the user from the current channel - $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $nickid); + $container->setUserMeta($nickid, 'cmdtoplay', serialize($cmdtoplay)); } } } Modified: trunk/src/commands/op.class.php =================================================================== --- trunk/src/commands/op.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/op.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -32,7 +32,7 @@ $nicktoop = trim($param); $container =& $c->getContainerInstance(); $nicktoopid = $container->getNickId($nicktoop); - $container->setMeta(true, "isadmin", "nickname", $nicktoopid); + $container->setUserMeta($nicktoopid, 'isadmin', true); } } Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/privmsg.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -30,7 +30,7 @@ } // error: can't speak to unknown - if ($pvnickid == "undefined") + if ($pvnickid == '') { // remove this old pv from the privmsg list $pvid_to_remove = ""; Modified: trunk/src/commands/quit.class.php =================================================================== --- trunk/src/commands/quit.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/quit.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -25,7 +25,7 @@ // from the channels foreach( $u->channels as $id => $chandetail ) - if ($container->removeNick($chandetail["recipient"], $u->nick)) + if ($container->removeNick($chandetail["recipient"], $u->nickid)) { $cmdp = $p; $cmdp["param"] = $id; @@ -36,7 +36,7 @@ } // from the private messages foreach( $u->privmsg as $id => $pvdetail ) - if ($container->removeNick($pvdetail["recipient"], $u->nick)) + if ($container->removeNick($pvdetail["recipient"], $u->nickid)) { $cmdp = $p; $cmdp["param"] = $id; @@ -46,9 +46,8 @@ $cmd->run($xml_reponse, $cmdp); } // from the server - $container->removeNick(NULL, $u->nick); + $container->removeNick(NULL, $u->nickid); - $xml_reponse->addScript("pfc.handleResponse('quit', 'ok', '');"); if ($c->debug) pxlog("/quit (a user just quit -> nick=".$u->nick.")", "chat", $c->getId()); Modified: trunk/src/commands/unban.class.php =================================================================== --- trunk/src/commands/unban.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/unban.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -34,7 +34,7 @@ $msg = "<p>"._pfc("Nobody has been unbanished")."</p>"; // update the recipient banlist - $banlist = $container->getMeta("banlist_nickid", "channel", $recipientid); + $banlist = $container->getChanMeta($recipient, 'banlist_nickid'); if ($banlist == NULL) $banlist = array(); else @@ -44,14 +44,14 @@ if (in_array($param, $banlist)) { $banlist = array_diff($banlist, array($param)); - $container->setMeta(serialize($banlist), "banlist_nickid", "channel", $recipientid); + $container->setChanMeta($recipient, 'banlist_nickid', serialize($banlist)); $updated = true; $msg = "<p>"._pfc("%s has been unbanished", $param)."</p>"; } else if ($param == "all") { $banlist = array(); - $container->setMeta(serialize($banlist), "banlist_nickid", "channel", $recipientid); + $container->setChanMeta($recipient, 'banlist_nickid', serialize($banlist)); $updated = true; $msg = "<p>"._pfc("%s users have been unbanished", $nb)."</p>"; } Modified: trunk/src/commands/updatemynick.class.php =================================================================== --- trunk/src/commands/updatemynick.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/commands/updatemynick.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -16,7 +16,9 @@ $u =& $this->u; $container =& $c->getContainerInstance(); - $was_there = $container->updateNick($recipient, $u->nick); + $container->updateNick($u->nickid); + + $was_there = ($container->isNickOnline($recipient, $nickid) >=0); if (!$was_there) { // if the user were not in the list, it must be created in order to refresh his metadata Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/containers/file.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -101,7 +101,7 @@ $this->setMeta2("channelid-to-nickid", $this->_encode($chan), $nickid); // update the SERVER channel - $this->updateNick($nickid); + if ($chan != 'SERVER') $this->updateNick($nickid); return true; } @@ -117,44 +117,30 @@ { if ($chan == NULL) $chan = 'SERVER'; - $ret = $this->getMeta2("channelid-to-nickid", $this->_encode('SERVER'), $nickid); - $timestamp = $ret["timestamp"][0]; + $timestamp = $this->getMeta2("channelid-to-nickid", $this->_encode('SERVER'), $nickid); + $timestamp = $timestamp["timestamp"][0]; $deleted_user = array(); $deleted_user["nick"][] = $this->getNickname($nickid); $deleted_user["nickid"][] = $nickid; $deleted_user["timestamp"][] = $timestamp; + // remove the nickid from the channel list + $this->rmMeta2('channelid-to-nickid', $this->_encode($chan), $nickid); + $this->rmMeta2('nickid-to-channelid', $nickid, $this->_encode($chan)); - // @todo ne supprimer l'utilisateur que du channel donne en parametres - // car la commande /leave va simplement supprimer l'utilisateur du channel courant - // il faut par contre faire un test sur les channels de l'utilisateur et dans le cas ou l'utilisateur - // est deconnecte du dernier channel (il se peut que ce soit SERVER) alors on supprime ses metadata. - - // il faudrait egalement adapter removeObsoleteNick pour qu'elle appel N fois removeNick - // N etant le nombre de channel de l'utilisateur. Ainsi l'utilisateur dera vraiment deconnecte - - - - // get the user's disconnected channels - $channels = array(); - $ret2 = $this->getMeta2("nickid-to-channelid",$nickid); - foreach($ret2["value"] as $v) - $channels[] = $this->_decode($v); - $deleted_user["channels"][] = $channels; - - // get the user nickname - $nick = $this->getNickname($nickid); - // loop on user channels - foreach($channels as $ch) + // get the current user's channels list + $channels = $this->getMeta2("nickid-to-channelid",$nickid); + $channels = $channels["value"]; + // no more joined channel, just remove the user's metadata + if (count($channels) == 0) { // remove the nickname to nickid correspondance - $this->rmMeta2("metadata-to-nickid", 'nick', $this->_encode($nick)); + $this->rmMeta2('metadata-to-nickid', 'nick', $this->_encode($this->getNickname($nickid))); // remove disconnected nickname metadata - $this->rmMeta2("nickid-to-metadata", $nickid); - // remove the nickid from the channel list - $this->rmMeta2("channelid-to-nickid", $this->_encode($ch), $nickid); + $this->rmMeta2('nickid-to-metadata', $nickid); } + return $deleted_user; } @@ -221,7 +207,7 @@ function getNickname($nickid) { $nick = $this->getMeta2("nickid-to-metadata", $nickid, 'nick', true); - $nick = isset($nick["value"][0]) ? $nick["value"][0] : ""; + $nick = isset($nick["value"][0]) ? $this->_decode($nick["value"][0]) : ""; return $nick; } @@ -249,11 +235,19 @@ $nickid = $ret['value'][$i]; if (time() > ($timestamp+$timeout/1000) ) // user will be disconnected after 'timeout' secondes of inactivity { - $du = $this->removeNick($nickid); + // get the current user's channels list + $channels = array(); + $ret2 = $this->getMeta2("nickid-to-channelid",$nickid); + foreach($ret2["value"] as $userchan) + { + // disconnect the user from each joined channels + $du = $this->removeNick($this->_decode($userchan), $nickid); + $channels[] = $this->_decode($userchan); + } $deleted_user["nick"] = array_merge($deleted_user["nick"], $du["nick"]); $deleted_user["nickid"] = array_merge($deleted_user["nickid"], $du["nickid"]); - $deleted_user["timestamp"] = array_merge($deleted_user["timestamp"], $du["timestamp"]); - $deleted_user["channels"] = array_merge($deleted_user["channels"], $du["channels"]); + $deleted_user["timestamp"] = array_merge($deleted_user["timestamp"], $du["timestamp"]); + $deleted_user["channels"] = array_merge($deleted_user["channels"], array($channels)); } } @@ -496,7 +490,7 @@ if ($leafvalue == NULL) { if (file_exists($leaffilename) && - filesize($leaffilename)>0) unlink($leaffilename); + filesize($leaffilename)>0) unlink($leaffilename); touch($leaffilename); } else @@ -520,12 +514,7 @@ * @return ... */ function getMeta2($group, $subgroup = null, $leaf = null, $withleafvalue = false) - //($key, $type, $subtype = NULL) { - // @todo read the value from the memory cache - //if (isset($this->_meta[$enc_type][$enc_subtype][$enc_key])) - // return $this->_meta[$enc_type][$enc_subtype][$enc_key]; - // read data from metadata file $ret = array(); $ret["timestamp"] = array(); @@ -557,7 +546,6 @@ if (is_dir($dir)) { $dh = opendir($dir); - $ret = array(); while (false !== ($file = readdir($dh))) { if ($file == "." || $file == "..") continue; // skip . and .. generic files @@ -572,15 +560,11 @@ if (!file_exists($leaffilename)) return $ret; if ($withleafvalue) - { $ret["value"][] = file_get_contents($leaffilename); - } + else + $ret["value"][] = NULL; $ret["timestamp"][] = filemtime($leaffilename); - // @todo - // store the result in the memory cache - //$this->_meta[$enc_type][$enc_subtype][$enc_key] = $ret; - return $ret; } @@ -623,7 +607,31 @@ return true; } - + + function getUserMeta($nickid, $key) + { + $ret = $this->getMeta2("nickid-to-metadata", $nickid, $key, true); + return isset($ret['value'][0]) ? $ret['value'][0] : NULL; + } + + function setUserMeta($nickid, $key, $value) + { + $ret = $this->setMeta2("nickid-to-metadata", $nickid, $key, $value); + return $ret; + } + + function getChanMeta($chan, $key) + { + $ret = $this->getMeta2("channelid-to-metadata", $this->_encode($chan), $key, true); + return isset($ret['value'][0]) ? $ret['value'][0] : NULL; + } + + function setChanMeta($chan, $key, $value) + { + $ret = $this->setMeta2("channelid-to-metadata", $this->_encode($chan), $key, $value); + return $ret; + } + } ?> \ No newline at end of file Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/phpfreechat.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -355,7 +355,7 @@ // alert the other from the new pv // (warn other user that someone talk to him) $container =& $c->getContainerInstance(); - $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $u->privmsg[$recipientid]["pvnickid"]); + $cmdtoplay = $container->getUserMeta($u->privmsg[$recipientid]["pvnickid"], 'cmdtoplay'); $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); $cmdtmp = array("privmsg2", /* cmdname */ $u->nick, /* param */ @@ -366,7 +366,7 @@ if (!in_array($cmdtmp, $cmdtoplay)) { $cmdtoplay[] = $cmdtmp; - $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $u->privmsg[$recipientid]["pvnickid"]); + $container->setUserMeta($u->privmsg[$recipientid]["pvnickid"], 'cmdtoplay', serialize($cmdtoplay)); //$xml_reponse->addScript("alert('cmdtoplay[]=".serialize($cmdtoplay)."');"); } } @@ -382,13 +382,13 @@ while($morecmd) { // take a command from the list - $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); + $cmdtoplay = $container->getUserMeta($nickid, 'cmdtoplay'); $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); $cmdtmp = array_pop($cmdtoplay); if ($cmdtmp != NULL) { // store the new cmdtoplay list (-1 item) - $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $nickid); + $container->setUserMeta($nickid, "cmdtoplay", serialize($cmdtoplay)); // play the command $cmd =& pfcCommand::Factory($cmdtmp[0]); @@ -411,7 +411,7 @@ } // check if there is other command to play - $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); + $cmdtoplay = $container->getUserMeta($nickid, 'cmdtoplay'); $cmdtoplay = ($cmdtoplay == NULL) ? array() : unserialize($cmdtoplay); } Modified: trunk/src/proxys/auth.class.php =================================================================== --- trunk/src/proxys/auth.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/proxys/auth.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -47,7 +47,7 @@ { $container =& $c->getContainerInstance(); $nickid = $u->nickid; - $isadmin = $container->getMeta("isadmin", "nickname", $nickid); + $isadmin = $container->getUserMeta($nickid, 'isadmin'); if (!$isadmin) { $xml_reponse->addScript("alert('".addslashes(_pfc("You are not allowed to run '%s' command", $this->name))."');"); @@ -62,8 +62,9 @@ $channame = $param; // check the user is not listed in the banished channel list + $chan = pfcCommand_join::GetRecipient($channame); $chanid = pfcCommand_join::GetRecipientId($channame); - $banlist = $container->getMeta("banlist_nickid", "channel", $chanid); + $banlist = $container->getChanMeta($chan, 'banlist_nickid'); if ($banlist == NULL) $banlist = array(); else $banlist = unserialize($banlist); $nickid = $u->nickid; if (in_array($nickid,$banlist)) Modified: trunk/src/proxys/checknickchange.class.php =================================================================== --- trunk/src/proxys/checknickchange.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/proxys/checknickchange.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -87,7 +87,7 @@ $nick_in_use = true; } } - if ($nick_in_use || $newnickid != "undefined") + if ($nick_in_use || $newnickid != '') { $xml_reponse->addScript("pfc.handleResponse('nick', 'isused', '".addslashes($newnick)."');"); if ($c->debug) Modified: trunk/src/proxys/checktimeout.class.php =================================================================== --- trunk/src/proxys/checktimeout.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/proxys/checktimeout.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -42,28 +42,26 @@ $c =& $this->c; $u =& $this->u; - if ( $this->name == 'update' || - $this->name == 'connect' ) + // disconnect users from specific channels + $container =& $c->getContainerInstance(); + $disconnected_users = $container->removeObsoleteNick($c->timeout); + for($i=0; $i<count($disconnected_users["nick"]); $i++) { - // disconnect users from the server pool - $container =& $c->getContainerInstance(); - $disconnected_users = $container->removeObsoleteNick(NULL,$c->timeout); - } - - if ( $this->name == 'getonlinenick' ) - { - // disconnect users from specific channels - $container =& $c->getContainerInstance(); - $disconnected_users = $container->removeObsoleteNick($recipient,$c->timeout); - if (isset($disconnected_users["nick"])) - foreach ($disconnected_users["nick"] as $n) + $nick = $disconnected_users["nick"][$i]; + for($j=0; $j<count($disconnected_users["channels"][$i]); $j++) + { + $chan = $disconnected_users["channels"][$i][$j]; + if ($chan != 'SERVER') { $cmdp = $p; - $cmdp["param"] = _pfc("%s quit (timeout)", $n); + $cmdp["param"] = _pfc("%s quit (timeout)", $nick); $cmdp["flag"] = 2; + $cmdp["recipient"] = $chan; + $cmdp["recipientid"] = md5($chan); // @todo: clean the recipient/recipientid notion $cmd =& pfcCommand::Factory("notice"); $cmd->run($xml_reponse, $cmdp); } + } } // forward the command to the next proxy or to the final command Modified: trunk/src/proxys/noflood.class.php =================================================================== --- trunk/src/proxys/noflood.class.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/src/proxys/noflood.class.php 2006-09-19 21:32:46 UTC (rev 771) @@ -46,9 +46,9 @@ { $container =& $c->getContainerInstance(); $nickid = $u->nickid; - $isadmin = $container->getMeta("isadmin", "nickname", $nickid); - $lastfloodtime = $container->getMeta("floodtime", "nickname", $nickid); - $nbflood = $container->getMeta("nbflood", "nickname", $nickid); + $isadmin = $container->getUserMeta($nickid, 'isadmin'); + $lastfloodtime = $container->getUserMeta($nickid, 'floodtime'); + $nbflood = $container->getUserMeta($nickid, 'nbflood'); $floodtime = time(); if ($floodtime - $lastfloodtime <= $c->proxys_cfg[$this->proxyname]["delay"]) @@ -72,8 +72,8 @@ } if ($nbflood == 0) - $container->setMeta($floodtime, "floodtime", "nickname", $nickid); - $container->setMeta($nbflood, "nbflood", "nickname", $nickid); + $container->setUserMeta($nickid, 'floodtime', $floodtime); + $container->setUserMeta($nickid, 'nbflood', $nbflood); } // forward the command to the next proxy or to the final command Modified: trunk/testcase/container_file.php =================================================================== --- trunk/testcase/container_file.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/testcase/container_file.php 2006-09-19 21:32:46 UTC (rev 771) @@ -275,7 +275,6 @@ $ret = $ct->getMeta2($group, $subgroup, $leaf, true); $this->assertEquals($ret['value'][0], $leafvalue, "the leaf value is wrong"); } - } // on desactive le timeout car se script peut mettre bcp de temps a s'executer Modified: trunk/testcase/container_generic.php =================================================================== --- trunk/testcase/container_generic.php 2006-09-19 15:25:50 UTC (rev 770) +++ trunk/testcase/container_generic.php 2006-09-19 21:32:46 UTC (rev 771) @@ -27,13 +27,14 @@ // here function setUp() { + // echo "setUp<br>"; require_once dirname(__FILE__)."/../src/pfcglobalconfig.class.php"; $params = array(); $params["title"] = "testcase -> pfccontainer_".$this->type; $params["serverid"] = md5(__FILE__/* . time()*/); $params["container_type"] = $this->type; - $this->c =& pfcGlobalConfig::Instance($params); - $this->ct =& $this->c->getContainerInstance(); + $this->c = new pfcGlobalConfig($params); + $this->ct = $this->c->getContainerInstance(); } // called after the test functions are executed @@ -41,11 +42,11 @@ // here function tearDown() { + // echo "tearDown<br>"; $this->ct->clear(); $this->c->destroyCache(); } - function testCreateNick_Generic() { $c =& $this->c; @@ -66,7 +67,7 @@ $isonline = ($this->ct->isNickOnline($chan, $nickid) >= 0); $this->assertTrue($isonline, "nickname should be online on the server"); } - + function testRemoveNick_Generic() { $c =& $this->c; @@ -78,18 +79,17 @@ // on the channel $this->ct->createNick($chan, $nick, $nickid); - $this->ct->removeNick($nickid); + $this->ct->removeNick($chan, $nickid); $isonline = ($this->ct->isNickOnline($chan, $nickid) >= 0); $this->assertFalse($isonline, "nickname shouldn't be online on the channel"); + $isonline2 = ($this->ct->isNickOnline(NULL, $nickid) >= 0); + $this->assertTrue($isonline2, "nickname should be online on the server"); - // on the server - $chan = NULL; - $this->ct->createNick($chan, $nick, $nickid); - $this->ct->removeNick($nickid); - $isonline = ($this->ct->isNickOnline($chan, $nickid) >= 0); - $this->assertFalse($isonline, "nickname shouldn't be online on the server"); + $this->ct->removeNick(NULL, $nickid); + $isonline = ($this->ct->isNickOnline(NULL, $nickid) >= 0); + $this->assertFalse($isonline, "nickname shouldn't be online on the server"); } - + function testGetNickId_Generic() { $c =& $this->c; @@ -104,7 +104,6 @@ $this->assertEquals($nickid, $ret, "created nickname doesn't have a correct nickid"); } - function testGetNickname_Generic() { $c =& $this->c; @@ -156,7 +155,8 @@ $this->ct->createNick($chan, $nick, $nickid); sleep(2); $ret = $this->ct->removeObsoleteNick(1000); - $this->assertEquals(count($ret["nickid"]), 1, "1 nickname should be obsolete"); + $this->assertEquals(1, count($ret["nickid"]), "1 nickname should be obsolete"); + $this->assertEquals(2, count($ret["channels"][0]), "nickname should be disconnected from two channels"); $isonline = ($this->ct->isNickOnline($chan, $nickid) >= 0); $this->assertFalse($isonline, "nickname shouldn't be online anymore"); } @@ -276,7 +276,6 @@ $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"); } - } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-20 08:23:33
|
Revision: 772 http://svn.sourceforge.net/phpfreechat/?rev=772&view=rev Author: kerphi Date: 2006-09-20 01:23:17 -0700 (Wed, 20 Sep 2006) Log Message: ----------- finish the container refactoring Modified Paths: -------------- trunk/src/containers/file.class.php trunk/src/pfccontainer.class.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-09-19 21:32:46 UTC (rev 771) +++ trunk/src/containers/file.class.php 2006-09-20 08:23:17 UTC (rev 772) @@ -1,6 +1,6 @@ <?php /** - * pfccontainer_file.class.php + * file.class.php * * Copyright \xA9 2006 Stephane Gully <ste...@gm...> * @@ -36,17 +36,13 @@ function pfcContainer_File(&$config) { pfcContainer::pfcContainer($config); - // $this->loadPaths(); } function loadPaths() { $c =& $this->c; - $c->container_cfg_chat_dir = $c->data_private_path."/chat"; - $c->container_cfg_server_dir = $c->container_cfg_chat_dir."/s_".$c->serverid; - $c->container_cfg_server_nickname_dir = $c->container_cfg_server_dir."/nicknames"; - $c->container_cfg_meta_dir = $c->container_cfg_server_dir."/metadata"; - $c->container_cfg_channel_dir = $c->container_cfg_server_dir."/channels"; + $c->container_cfg_chat_dir = $c->data_private_path."/chat"; + $c->container_cfg_server_dir = $c->container_cfg_chat_dir."/s_".$c->serverid; } function getDefaultConfig() @@ -54,11 +50,8 @@ $c =& $this->c; $cfg = array(); - $cfg["chat_dir"] = ""; // will be generated from the other parameters into the init step - $cfg["server_dir"] = ""; // will be generated from the other parameters into the init step - $cfg["server_nickname_dir"] = ""; // will be generated from the other parameters into the init step - $cfg["meta_dir"] = ""; // will be generated from the other parameters into the init step - $cfg["channel_dir"] = ""; // will be generated from the other parameters into the init step + $cfg["chat_dir"] = ''; // will be generated from the other parameters into the init step + $cfg["server_dir"] = ''; // will be generated from the other parameters into the init step return $cfg; } @@ -72,415 +65,18 @@ $c->container_cfg_chat_dir = $c->data_private_path."/chat"; $this->loadPaths(); - $errors = array_merge($errors, @test_writable_dir($c->container_cfg_chat_dir, "container_cfg_chat_dir")); - $errors = array_merge($errors, @test_writable_dir($c->container_cfg_server_dir, "container_cfg_chat_dir/serverid")); - $errors = array_merge($errors, @test_writable_dir($c->container_cfg_server_nickname_dir, "container_cfg_chat_dir/nicknames")); - $errors = array_merge($errors, @test_writable_dir($c->container_cfg_meta_dir, "container_cfg_chat_dir/metadata")); - $errors = array_merge($errors, @test_writable_dir($c->container_cfg_channel_dir, "container_cfg_chat_dir/channels")); + $errors = array_merge($errors, @test_writable_dir($c->container_cfg_chat_dir, "container_cfg_chat_dir")); + $errors = array_merge($errors, @test_writable_dir($c->container_cfg_server_dir, "container_cfg_chat_dir/serverid")); return $errors; } - /** - * Create (connect/join) the nickname into the server or the channel locations - * Notice: the caller must take care to update all channels the users joined (use stored channel list into metadata) - * @param $chan if NULL then create the user on the server (connect), otherwise create the user on the given channel (join) - * @param $nick the nickname to create - * @param $nickid is the corresponding nickname id (taken from session) - */ - function createNick($chan, $nick, $nickid) - { - $c =& $this->c; - if ($chan == NULL) $chan = 'SERVER'; - - $this->setMeta2("nickid-to-metadata", $nickid, 'nick', $nick); - $this->setMeta2("metadata-to-nickid", 'nick', $this->_encode($nick), $nickid); - - $this->setMeta2("nickid-to-channelid", $nickid, $this->_encode($chan)); - $this->setMeta2("channelid-to-nickid", $this->_encode($chan), $nickid); - - // update the SERVER channel - if ($chan != 'SERVER') $this->updateNick($nickid); - - return true; - } - - /** - * Remove (disconnect/quit) the nickname from the server or from a channel - * 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, $nickid) + function setMeta($group, $subgroup, $leaf, $leafvalue = NULL) { - if ($chan == NULL) $chan = 'SERVER'; - - $timestamp = $this->getMeta2("channelid-to-nickid", $this->_encode('SERVER'), $nickid); - $timestamp = $timestamp["timestamp"][0]; - - $deleted_user = array(); - $deleted_user["nick"][] = $this->getNickname($nickid); - $deleted_user["nickid"][] = $nickid; - $deleted_user["timestamp"][] = $timestamp; - - // remove the nickid from the channel list - $this->rmMeta2('channelid-to-nickid', $this->_encode($chan), $nickid); - $this->rmMeta2('nickid-to-channelid', $nickid, $this->_encode($chan)); - - // get the current user's channels list - $channels = $this->getMeta2("nickid-to-channelid",$nickid); - $channels = $channels["value"]; - // no more joined channel, just remove the user's metadata - if (count($channels) == 0) - { - // remove the nickname to nickid correspondance - $this->rmMeta2('metadata-to-nickid', 'nick', $this->_encode($this->getNickname($nickid))); - // remove disconnected nickname metadata - $this->rmMeta2('nickid-to-metadata', $nickid); - } - - return $deleted_user; - } - - /** - * Store/update the alive user status somewhere - * The default File container will just touch (update the date) the nickname file. - * @param $chan where to update the nick, if null then update the server nick - * @param $nick nickname to update (raw nickname) - */ - function updateNick($nickid) - { - $c =& $this->c; - - $chan = 'SERVER'; - - $this->setMeta2("nickid-to-channelid", $nickid, $this->_encode($chan)); - $this->setMeta2("channelid-to-nickid", $this->_encode($chan), $nickid); - return true; - } - - /** - * Change the user' nickname - * Notice: the caller will just call this function one time, this function must take care to update if necessary all channels the user joined - * @param $newnick - * @param $oldnick - * @return true on success, false on failure - */ - function changeNick($newnick, $oldnick) - { - $c =& $this->c; - - $oldnickid = $this->getNickId($oldnick); - $newnickid = $this->getNickId($newnick); - if ($oldnickid == "") return false; // the oldnick must be connected - if ($newnickid != "") return false; // the newnick must not be inuse - - // remove the oldnick to oldnickid correspondance - $this->rmMeta2("metadata-to-nickid", 'nick', $this->_encode($oldnick)); - - // update the nickname - $this->setMeta2("nickid-to-metadata", $oldnickid, 'nick', $newnick); - $this->setMeta2("metadata-to-nickid", 'nick', $this->_encode($newnick), $oldnickid); - return true; - } - - /** - * Returns the nickid corresponding to the given nickname - * The nickid is a unique id used to identify a user (generated from the browser sessionid) - * @param $nick - * @return string the nick id - */ - function getNickId($nick) - { - $nickid = $this->getMeta2("metadata-to-nickid", 'nick', $this->_encode($nick), true); - $nickid = isset($nickid["value"][0]) ? $nickid["value"][0] : ""; - return $nickid; - } - - /** - * Returns the nickname corresponding the the given nickid - * @param $nickid - * @return string the corresponding nickname - */ - function getNickname($nickid) - { - $nick = $this->getMeta2("nickid-to-metadata", $nickid, 'nick', true); - $nick = isset($nick["value"][0]) ? $this->_decode($nick["value"][0]) : ""; - return $nick; - } - - /** - * Remove (disconnect/quit) the timeouted nickname from the server or from a channel - * Notice: this function must remove all nicknames which are not uptodate from the given channel or from the server - * @param $chan if NULL then check obsolete nick on the server, otherwise just check obsolete nick on the given channel - * @param $timeout - * @return array("nickid"=>array("nickid1", ...),"timestamp"=>array(timestamp1, ...)) contains all disconnected nickids and there timestamp - */ - function removeObsoleteNick($timeout) - { - $c =& $this->c; - - $chan = 'SERVER'; - - $deleted_user = array('nick'=>array(), - 'nickid'=>array(), - 'timestamp'=>array(), - 'channels'=>array()); - $ret = $this->getMeta2("channelid-to-nickid", $this->_encode($chan)); - for($i = 0; $i<count($ret['timestamp']); $i++) - { - $timestamp = $ret['timestamp'][$i]; - $nickid = $ret['value'][$i]; - if (time() > ($timestamp+$timeout/1000) ) // user will be disconnected after 'timeout' secondes of inactivity - { - // get the current user's channels list - $channels = array(); - $ret2 = $this->getMeta2("nickid-to-channelid",$nickid); - foreach($ret2["value"] as $userchan) - { - // disconnect the user from each joined channels - $du = $this->removeNick($this->_decode($userchan), $nickid); - $channels[] = $this->_decode($userchan); - } - $deleted_user["nick"] = array_merge($deleted_user["nick"], $du["nick"]); - $deleted_user["nickid"] = array_merge($deleted_user["nickid"], $du["nickid"]); - $deleted_user["timestamp"] = array_merge($deleted_user["timestamp"], $du["timestamp"]); - $deleted_user["channels"] = array_merge($deleted_user["channels"], array($channels)); - } - } - - return $deleted_user; - } - - /** - * 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("nickid"=>array("nickid1", ...),"timestamp"=>array(timestamp1, ...)) contains the nickid list with the associated timestamp (laste update time) - */ - function getOnlineNick($chan) - { - $c =& $this->c; - - if ($chan == NULL) $chan = 'SERVER'; - - $online_user = array(); - $ret = $this->getMeta2("channelid-to-nickid", $this->_encode($chan)); - for($i = 0; $i<count($ret['timestamp']); $i++) - { - $nickid = $ret['value'][$i]; - - // get timestamp from the SERVER channel - $timestamp = $this->getMeta2("channelid-to-nickid", $this->_encode('SERVER'), $nickid); - $timestamp = $timestamp['timestamp'][0]; - - $online_user["nick"][] = $this->getNickname($nickid); - $online_user["nickid"][] = $nickid; - $online_user["timestamp"][] = $timestamp; - } - return $online_user; - } - - /** - * 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, $nickid) - { - if ($chan == NULL) $chan = 'SERVER'; - - $ret = $this->getMeta2("channelid-to-nickid", $this->_encode($chan)); - for($i = 0; $i<count($ret['timestamp']); $i++) - { - if ($ret['value'][$i] == $nickid) return $i; - } - 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, ...) - * @param $chan if NULL then write the message on the server, otherwise just write the message on the channel message pool - * @param $nick is the sender nickname - * @param $cmd is the command name (ex: "send", "nick", "kick" ...) - * @param $param is the command' parameters (ex: param of the "send" command is the message) - * @return $msg_id the created message identifier - */ - function write($chan, $nick, $cmd, $param) - { - $c =& $this->c; - if ($chan == NULL) $chan = 'SERVER'; - - $msgid = $this->_requestMsgId($chan); - - // format message - $data = "\n"; - $data .= $msgid."\t"; - $data .= date("d/m/Y")."\t"; - $data .= date("H:i:s")."\t"; - $data .= $nick."\t"; - $data .= $cmd."\t"; - $data .= $param; - - // write message - $this->setMeta2("channelid-to-msg", $this->_encode($chan), $msgid, $data); - - // delete the obsolete message - $old_msgid = $msgid - $c->max_msg - 20; - if ($old_msgid > 0) - $this->rmMeta2("channelid-to-msg", $this->_encode($chan), $old_msgid); - - return $msgid; - } - - /** - * 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 - */ - function read($chan, $from_id) - { - $c =& $this->c; - if ($chan == NULL) $chan = 'SERVER'; - - // read new messages id - $new_msgid_list = array(); - $new_from_id = $from_id; - $msgid_list = $this->getMeta2("channelid-to-msg", $this->_encode($chan)); - for($i = 0; $i<count($msgid_list["value"]); $i++) - { - $msgidtmp = $msgid_list["value"][$i]; - - if ($msgidtmp > $from_id) - { - if ($msgidtmp > $new_from_id) $new_from_id = $msgidtmp; - $new_msgid_list[] = $msgidtmp; - } - } - - // read messages content and parse content - $datalist = array(); - foreach ( $new_msgid_list as $mid ) - { - $line = $this->getMeta2("channelid-to-msg", $this->_encode($chan), $mid, true); - $line = $line["value"][0]; - if ($line != "" && $line != "\n") - { - $formated_line = explode( "\t", $line ); - $data = array(); - $data["id"] = trim($formated_line[0]); - $data["date"] = $formated_line[1]; - $data["time"] = $formated_line[2]; - $data["sender"]= $formated_line[3]; - $data["cmd"] = $formated_line[4]; - $data["param"] = $formated_line[5]; - $datalist[$data["id"]] = $data; - } - } - ksort($datalist); - - return array("data" => $datalist, - "new_from_id" => $new_from_id ); - } - - /** - * Returns the last message id - * Notice: the default file container just returns the messages.index file content - * @param $chan if NULL then read if from the server, otherwise read if from the given channel - * @return int is the last posted message id - */ - function getLastId($chan) - { - if ($chan == NULL) $chan = 'SERVER'; - - $lastmsgid = $this->getMeta2("channelid-to-msgid", $this->_encode($chan), 'lastmsgid', true); - if (count($lastmsgid["value"]) == 0) - $lastmsgid = 0; - else - $lastmsgid = $lastmsgid["value"][0]; - return $lastmsgid; - } - - - /** - * Remove all created data for this server (identified by serverid) - * Notice: for the default File container, it's just a recursive directory remove - */ - function clear() - { - $c =& $this->c; - // remove the created files and directories - $dir = $c->container_cfg_server_dir; - @rm_r($dir); - // empty the cache - // $this->_meta = array(); - // $this->_users = array("nickid" => array(), - // "timestamp" => array()); - } - - - /** - * Return a unique id. Each time this function is called, the last id is incremented. - * used internaly - * @private - */ - function _requestMsgId($chan) - { - if ($chan == NULL) $chan = 'SERVER'; - - $lastmsgid = $this->getLastId($chan); - $lastmsgid++; - $this->setMeta2("channelid-to-msgid", $this->_encode($chan), 'lastmsgid', $lastmsgid); - - return $lastmsgid; - } - - /** - * Used to encode UTF8 strings to ASCII filenames - * @private - */ - function _encode($str) - { - return urlencode($str); - return base64_encode(urlencode($str)); - } - - /** - * Used to decode ASCII filenames to UTF8 strings - * @private - */ - function _decode($str) - { - return urldecode($str); - return urldecode(base64_decode($str)); - } - - - - - - - - - - - - - - /** - * Write a meta data value identified by a group / subgroup / leaf [with a value] - * @return 1 if the leaf allready existed, 0 if the leaf has been created - */ - function setMeta2($group, $subgroup, $leaf, $leafvalue = NULL) - // value, $key, $type, $subtype = NULL) - { // create directories $c =& $this->c; - $dir_base = $c->container_cfg_meta_dir; + $dir_base = $c->container_cfg_server_dir; $dir = $dir_base.'/'.$group.'/'.$subgroup; if (!is_dir($dir)) mkdir_r($dir); @@ -509,18 +105,14 @@ } - /** - * Read meta data identified by a group [/ subgroup [/ leaf]] - * @return ... - */ - function getMeta2($group, $subgroup = null, $leaf = null, $withleafvalue = false) + function getMeta($group, $subgroup = null, $leaf = null, $withleafvalue = false) { // read data from metadata file $ret = array(); $ret["timestamp"] = array(); $ret["value"] = array(); $c =& $this->c; - $dir_base = $c->container_cfg_meta_dir; + $dir_base = $c->container_cfg_server_dir; $dir = $dir_base.'/'.$group; @@ -568,24 +160,19 @@ return $ret; } - - /** - * Remove a meta data - * @return ... - */ - function rmMeta2($group, $subgroup = null, $leaf = null) - //($key, $type, $subtype = NULL) + function rmMeta($group, $subgroup = null, $leaf = null) { $c =& $this->c; + $dir = $c->container_cfg_server_dir; + if ($group == NULL) + { + rm_r($dir); + return true; + } + $dir .= '/'.$group; - // read data from metadata file - $c =& $this->c; - $dir_base = $c->container_cfg_meta_dir; - - $dir = $dir_base.'/'.$group; - if ($subgroup == NULL) { rm_r($dir); @@ -600,7 +187,7 @@ return true; } - $leaffilename = $dir."/".$leaf; + $leaffilename = $dir.'/'.$leaf; if (!file_exists($leaffilename)) return false; unlink($leaffilename); @@ -608,30 +195,22 @@ } - function getUserMeta($nickid, $key) + /** + * Used to encode UTF8 strings to ASCII filenames + */ + function encode($str) { - $ret = $this->getMeta2("nickid-to-metadata", $nickid, $key, true); - return isset($ret['value'][0]) ? $ret['value'][0] : NULL; + return urlencode($str); } - - function setUserMeta($nickid, $key, $value) + + /** + * Used to decode ASCII filenames to UTF8 strings + */ + function decode($str) { - $ret = $this->setMeta2("nickid-to-metadata", $nickid, $key, $value); - return $ret; + return urldecode($str); } - function getChanMeta($chan, $key) - { - $ret = $this->getMeta2("channelid-to-metadata", $this->_encode($chan), $key, true); - return isset($ret['value'][0]) ? $ret['value'][0] : NULL; - } - - function setChanMeta($chan, $key, $value) - { - $ret = $this->setMeta2("channelid-to-metadata", $this->_encode($chan), $key, $value); - return $ret; - } - } ?> \ No newline at end of file Modified: trunk/src/pfccontainer.class.php =================================================================== --- trunk/src/pfccontainer.class.php 2006-09-19 21:32:46 UTC (rev 771) +++ trunk/src/pfccontainer.class.php 2006-09-20 08:23:17 UTC (rev 772) @@ -41,74 +41,218 @@ * @param $nick the nickname to create * @param $nickid is the corresponding nickname id (taken from session) */ - function createNick($chan, $nickname, $nickid) - { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + function createNick($chan, $nick, $nickid) + { + $c =& $this->c; + if ($chan == NULL) $chan = 'SERVER'; + + $this->setMeta("nickid-to-metadata", $nickid, 'nick', $nick); + $this->setMeta("metadata-to-nickid", 'nick', $this->encode($nick), $nickid); + + $this->setMeta("nickid-to-channelid", $nickid, $this->encode($chan)); + $this->setMeta("channelid-to-nickid", $this->encode($chan), $nickid); + + // update the SERVER channel + if ($chan != 'SERVER') $this->updateNick($nickid); + + return true; + } + /** * Remove (disconnect/quit) the nickname from the server or from a channel - * 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 + * Notice: when a user quit, the caller must take care removeNick from each channels ('SERVER' included) + * This function takes care to remove all users metadata when he his disconnected from all channels + * @param $chan if NULL then remove the user from the 'SERVER' channel, otherwise just remove the user from the given channel (quit) + * @param $nickid the nickname id to remove + * @return array which contains removed user infos ('nickid', 'nick', 'timestamp') */ - function removeNick($chan, $nickname) - { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + function removeNick($chan, $nickid) + { + if ($chan == NULL) $chan = 'SERVER'; + $timestamp = $this->getMeta("channelid-to-nickid", $this->encode('SERVER'), $nickid); + $timestamp = $timestamp["timestamp"][0]; + + $deleted_user = array(); + $deleted_user["nick"][] = $this->getNickname($nickid); + $deleted_user["nickid"][] = $nickid; + $deleted_user["timestamp"][] = $timestamp; + + // remove the nickid from the channel list + $this->rmMeta('channelid-to-nickid', $this->encode($chan), $nickid); + $this->rmMeta('nickid-to-channelid', $nickid, $this->encode($chan)); + + // get the current user's channels list + $channels = $this->getMeta("nickid-to-channelid",$nickid); + $channels = $channels["value"]; + // no more joined channel, just remove the user's metadata + if (count($channels) == 0) + { + // remove the nickname to nickid correspondance + $this->rmMeta('metadata-to-nickid', 'nick', $this->encode($this->getNickname($nickid))); + // remove disconnected nickname metadata + $this->rmMeta('nickid-to-metadata', $nickid); + } + + return $deleted_user; + } + /** - * Store/update the alive user status somewhere - * The default File container will just touch (update the date) the nickname file. - * @param $chan where to update the nick, if null then update the server nick - * @param $nick nickname to update (raw nickname) + * Store/update the alive user status on the 'SERVER' channel + * The default File container will just touch (update the date) of the nickname file in the 'SERVER' channel. + * @param $nickid the nickname id to keep alive */ - function updateNick($chan, $nick) - { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + function updateNick($nickid) + { + $c =& $this->c; + $chan = 'SERVER'; + $this->setMeta("nickid-to-channelid", $nickid, $this->encode($chan)); + $this->setMeta("channelid-to-nickid", $this->encode($chan), $nickid); + return true; + } + /** - * Change the user' nickname - * Notice: this call must take care to update all channels the user joined - * @param $chan where to update the nick, if null then update the server nick + * Change the user's nickname + * As nickname value are stored in user's metadata, this function just update the 'nick' metadata * @param $newnick * @param $oldnick + * @return true on success, false on failure (if the oldnick doesn't exists) */ function changeNick($newnick, $oldnick) - { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } - + { + $c =& $this->c; + + $oldnickid = $this->getNickId($oldnick); + $newnickid = $this->getNickId($newnick); + if ($oldnickid == "") return false; // the oldnick must be connected + if ($newnickid != "") return false; // the newnick must not be inuse + + // remove the oldnick to oldnickid correspondance + $this->rmMeta("metadata-to-nickid", 'nick', $this->encode($oldnick)); + + // update the nickname + $this->setMeta("nickid-to-metadata", $oldnickid, 'nick', $newnick); + $this->setMeta("metadata-to-nickid", 'nick', $this->encode($newnick), $oldnickid); + return true; + } + /** - * Returns the nickid, this is a unique id used to identify a user (taken from session) - * By default this nickid is just stored into the user' metadata, same as :->getNickMeta("nickid") + * Returns the nickid corresponding to the given nickname + * The nickid is a unique id used to identify a user (generated from the browser sessionid) + * The nickid is stored in the container when createNick is called. * @param $nick * @return string the nick id */ - function getNickId($nickname) - { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + function getNickId($nick) + { + $nickid = $this->getMeta("metadata-to-nickid", 'nick', $this->encode($nick), true); + $nickid = isset($nickid["value"][0]) ? $nickid["value"][0] : ""; + return $nickid; + } /** + * Returns the nickname corresponding the the given nickid + * @param $nickid + * @return string the corresponding nickname + */ + function getNickname($nickid) + { + $nick = $this->getMeta("nickid-to-metadata", $nickid, 'nick', true); + $nick = isset($nick["value"][0]) ? $this->decode($nick["value"][0]) : ""; + return $nick; + } + + /** * Remove (disconnect/quit) the timeouted nickname from the server or from a channel * Notice: this function must remove all nicknames which are not uptodate from the given channel or from the server * @param $chan if NULL then check obsolete nick on the server, otherwise just check obsolete nick on the given channel * @param $timeout - * @return array("nick"=>???, "timestamp"=>???) contains all disconnected nicknames and there timestamp + * @return array("nickid"=>array("nickid1", ...),"timestamp"=>array(timestamp1, ...)) contains all disconnected nickids and there timestamp */ - function removeObsoleteNick($chan, $timeout) - { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + function removeObsoleteNick($timeout) + { + $c =& $this->c; + $chan = 'SERVER'; + + $deleted_user = array('nick'=>array(), + 'nickid'=>array(), + 'timestamp'=>array(), + 'channels'=>array()); + $ret = $this->getMeta("channelid-to-nickid", $this->encode($chan)); + for($i = 0; $i<count($ret['timestamp']); $i++) + { + $timestamp = $ret['timestamp'][$i]; + $nickid = $ret['value'][$i]; + if (time() > ($timestamp+$timeout/1000) ) // user will be disconnected after 'timeout' secondes of inactivity + { + // get the current user's channels list + $channels = array(); + $ret2 = $this->getMeta("nickid-to-channelid",$nickid); + foreach($ret2["value"] as $userchan) + { + // disconnect the user from each joined channels + $du = $this->removeNick($this->decode($userchan), $nickid); + $channels[] = $this->decode($userchan); + } + $deleted_user["nick"] = array_merge($deleted_user["nick"], $du["nick"]); + $deleted_user["nickid"] = array_merge($deleted_user["nickid"], $du["nickid"]); + $deleted_user["timestamp"] = array_merge($deleted_user["timestamp"], $du["timestamp"]); + $deleted_user["channels"] = array_merge($deleted_user["channels"], array($channels)); + } + } + + return $deleted_user; + } + /** * 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(array("nick"=>???,"timestamp"=>???) contains the nickname list with the associated timestamp (laste update time) - */ + * @return array("nickid"=>array("nickid1", ...),"timestamp"=>array(timestamp1, ...)) contains the nickid list with the associated timestamp (laste update time) + */ function getOnlineNick($chan) - { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + { + $c =& $this->c; + + if ($chan == NULL) $chan = 'SERVER'; + $online_user = array(); + $ret = $this->getMeta("channelid-to-nickid", $this->encode($chan)); + for($i = 0; $i<count($ret['timestamp']); $i++) + { + $nickid = $ret['value'][$i]; + + // get timestamp from the SERVER channel + $timestamp = $this->getMeta("channelid-to-nickid", $this->encode('SERVER'), $nickid); + $timestamp = $timestamp['timestamp'][0]; + + $online_user["nick"][] = $this->getNickname($nickid); + $online_user["nickid"][] = $nickid; + $online_user["timestamp"][] = $timestamp; + } + return $online_user; + } + /** * 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) - { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + function isNickOnline($chan, $nickid) + { + if ($chan == NULL) $chan = 'SERVER'; + $ret = $this->getMeta("channelid-to-nickid", $this->encode($chan)); + for($i = 0; $i<count($ret['timestamp']); $i++) + { + if ($ret['value'][$i] == $nickid) return $i; + } + 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, ...) @@ -118,19 +262,85 @@ * @param $param is the command' parameters (ex: param of the "send" command is the message) * @return $msg_id the created message identifier */ - function write($chan, $nick, $msg) - { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + function write($chan, $nick, $cmd, $param) + { + $c =& $this->c; + if ($chan == NULL) $chan = 'SERVER'; + + $msgid = $this->_requestMsgId($chan); + // format message + $data = "\n"; + $data .= $msgid."\t"; + $data .= date("d/m/Y")."\t"; + $data .= date("H:i:s")."\t"; + $data .= $nick."\t"; + $data .= $cmd."\t"; + $data .= $param; + + // write message + $this->setMeta("channelid-to-msg", $this->encode($chan), $msgid, $data); + + // delete the obsolete message + $old_msgid = $msgid - $c->max_msg - 20; + if ($old_msgid > 0) + $this->rmMeta("channelid-to-msg", $this->encode($chan), $old_msgid); + + return $msgid; + } + /** * Read the last posted commands from a channel or from the server - * Notice: the returned array must be ordered by id + * Notice: the returned array is 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 + * @return array() contains the formated command list */ function read($chan, $from_id) - { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + { + $c =& $this->c; + if ($chan == NULL) $chan = 'SERVER'; + // read new messages id + $new_msgid_list = array(); + $new_from_id = $from_id; + $msgid_list = $this->getMeta("channelid-to-msg", $this->encode($chan)); + for($i = 0; $i<count($msgid_list["value"]); $i++) + { + $msgidtmp = $msgid_list["value"][$i]; + + if ($msgidtmp > $from_id) + { + if ($msgidtmp > $new_from_id) $new_from_id = $msgidtmp; + $new_msgid_list[] = $msgidtmp; + } + } + + // read messages content and parse content + $datalist = array(); + foreach ( $new_msgid_list as $mid ) + { + $line = $this->getMeta("channelid-to-msg", $this->encode($chan), $mid, true); + $line = $line["value"][0]; + if ($line != "" && $line != "\n") + { + $formated_line = explode( "\t", $line ); + $data = array(); + $data["id"] = trim($formated_line[0]); + $data["date"] = $formated_line[1]; + $data["time"] = $formated_line[2]; + $data["sender"]= $formated_line[3]; + $data["cmd"] = $formated_line[4]; + $data["param"] = $formated_line[5]; + $datalist[$data["id"]] = $data; + } + } + ksort($datalist); + + return array("data" => $datalist, + "new_from_id" => $new_from_id ); + } + /** * Returns the last message id * Notice: the default file container just returns the messages.index file content @@ -138,48 +348,127 @@ * @return int is the last posted message id */ function getLastId($chan) - { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + { + if ($chan == NULL) $chan = 'SERVER'; + + $lastmsgid = $this->getMeta("channelid-to-msgid", $this->encode($chan), 'lastmsgid', true); + if (count($lastmsgid["value"]) == 0) + $lastmsgid = 0; + else + $lastmsgid = $lastmsgid["value"][0]; + return $lastmsgid; + } + /** - * Read meta data identified by a key - * As an example the default file container store metadata into metadata/type/subtype/hash(key) - * @param $key is the index which identify a metadata - * @param $type is used to "group" some metadata - * @param $subtype is used to "group" precisely some metadata, use NULL to ignore it - * @return mixed the value assigned to the key, NULL if not found + * Return a unique id. Each time this function is called, the last id is incremented. + * used internaly + * @private + */ + function _requestMsgId($chan) + { + if ($chan == NULL) $chan = 'SERVER'; + + $lastmsgid = $this->getLastId($chan); + $lastmsgid++; + $this->setMeta("channelid-to-msgid", $this->encode($chan), 'lastmsgid', $lastmsgid); + + return $lastmsgid; + } + + + /** + * Remove all created data for this server (identified by serverid) + * Notice: for the default File container, it's just a recursive directory remove */ - function getMeta($key, $type, $subtype = NULL) - { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + function clear() + { + $this->rmMeta(NULL); + } /** - * Write a meta data value identified by a key - * As an example the default file container store metadata into metadata/type/subtype/hash(key) - * @param $key is the index which identify a metadata - * @param $value is the value associated to the key - * @param $type is used to "group" some metadata - * @param $subtype is used to "group" precisely some metadata, use NULL to ignore it - * @return true on success, false on error + * In the default File container: used to encode UTF8 strings to ASCII filenames + * This method can be overridden by the concrete container + */ + function encode($str) + { + return $str; + } + + /** + * In the default File container: used to decode ASCII filenames to UTF8 strings + * This method can be overridden by the concrete container + */ + function decode($str) + { + return $str; + } + + + function getUserMeta($nickid, $key) + { + $ret = $this->getMeta("nickid-to-metadata", $nickid, $key, true); + return isset($ret['value'][0]) ? $ret['value'][0] : NULL; + } + + function setUserMeta($nickid, $key, $value) + { + $ret = $this->setMeta("nickid-to-metadata", $nickid, $key, $value); + return $ret; + } + + function getChanMeta($chan, $key) + { + $ret = $this->getMeta("channelid-to-metadata", $this->encode($chan), $key, true); + return isset($ret['value'][0]) ? $ret['value'][0] : NULL; + } + + function setChanMeta($chan, $key, $value) + { + $ret = $this->setMeta("channelid-to-metadata", $this->encode($chan), $key, $value); + return $ret; + } + + /** + * Write a meta data value identified by a group / subgroup / leaf [with a value] + * As an example in the default file container this arborescent structure is modelised by simple directories + * group1/subgroup1/leaf1 + * /leaf2 + * /subgroup2/... + * Each leaf can contain or not a value. + * However each leaf and each group/subgroup must store the lastmodified time (timestamp). + * @param $group root arborescent element + * @param $subgroup is the root first child which contains leafs + * @param $leaf is the only element which can contain values + * @param $leafvalue NULL means the leaf will not contain any values + * @return 1 if the old leaf has been overwritten, 0 if a new leaf has been created */ - function setMeta($value, $key, $type, $subtype = NULL) + function setMeta($group, $subgroup, $leaf, $leafvalue = NULL) { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + /** - * Remove a meta data key/value couple - * Notice: if key is NULL then all the meta data must be removed - * @param $key is the key to delete, use NULL to delete all the metadata - * @param $type is used to "group" some metadata - * @param $subtype is used to "group" precisely some metadata, use NULL to ignore it - * @return true on success, false on error + * Read meta data identified by a group [/ subgroup [/ leaf]] + * @param $group is mandatory, it's the arborescence's root + * @param $subgroup if null then the subgroup list names are returned + * @param $leaf if null then the leaf names are returned + * @param $withleafvalue if set to true the leaf value will be returned + * @return array which contains two subarray 'timestamp' and 'value' */ - function rmMeta($key, $type, $subtype = NULL) + function getMeta($group, $subgroup = null, $leaf = null, $withleafvalue = false) { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + /** - * Remove all created data for this server (identified by serverid) - * Notice: for the default File container, it's just a recursive directory remove + * Remove a meta data or a group of metadata + * @param $group if null then it will remove all the possible groups (all the created metadata) + * @param $subgroup if null then it will remove the $group's childs (all the subgroup contained by $group) + * @param $leaf if null then it will remove all the $subgroup's childs (all the leafs contained by $subgroup) + * @return true on success, false on error */ - function clear() + function rmMeta($group, $subgroup = null, $leaf = null) { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } + } -?> +?> \ No newline at end of file Modified: trunk/testcase/container_file.php =================================================================== --- trunk/testcase/container_file.php 2006-09-19 21:32:46 UTC (rev 771) +++ trunk/testcase/container_file.php 2006-09-20 08:23:17 UTC (rev 772) @@ -36,10 +36,10 @@ $group = $prefix."_nickid-to-channelid"; $subgroup = $prefix."_nickid1"; $leaf = $prefix."_channelid1"; - $ret = $ct->setMeta2($group, $subgroup, $leaf); + $ret = $ct->setMeta($group, $subgroup, $leaf); $this->assertEquals($ret, 0, "the leaf should be first time created"); - $f = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup.'/'.$leaf; + $f = $c->container_cfg_server_dir.'/'.$group.'/'.$subgroup.'/'.$leaf; $ret = file_exists($f); $this->assertEquals($ret, true, "the leaf file should exists"); @@ -57,10 +57,10 @@ $subgroup = $prefix."_nickid1"; $leaf = $prefix."_channelid1"; $leafvalue = $prefix."_leafvalue1"; - $ret = $ct->setMeta2($group, $subgroup, $leaf, $leafvalue); + $ret = $ct->setMeta($group, $subgroup, $leaf, $leafvalue); $this->assertEquals($ret, 0, "the leaf should be first time created"); - $f = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup.'/'.$leaf; + $f = $c->container_cfg_server_dir.'/'.$group.'/'.$subgroup.'/'.$leaf; $ret = file_exists($f); $this->assertEquals($ret, true, "the leaf file should exists"); @@ -79,14 +79,14 @@ $leaf = $prefix."_channelid1"; $leafvalue = $prefix."_leafvalue1"; - $ret = $ct->setMeta2($group, $subgroup, $leaf, $leafvalue); + $ret = $ct->setMeta($group, $subgroup, $leaf, $leafvalue); $this->assertEquals($ret, 0, "the leaf should be first time created"); $leafvalue = null; - $ret = $ct->setMeta2($group, $subgroup, $leaf, $leafvalue); + $ret = $ct->setMeta($group, $subgroup, $leaf, $leafvalue); $this->assertEquals($ret, 1, "the leaf should be overwritten"); - $f = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup.'/'.$leaf; + $f = $c->container_cfg_server_dir.'/'.$group.'/'.$subgroup.'/'.$leaf; $ret = file_exists($f); $this->assertEquals($ret, true, "the leaf file should exists"); @@ -95,87 +95,6 @@ } - function test_getMeta_File_1() - { - $c =& $this->c; - $ct =& $this->ct; - - $prefix = __FUNCTION__; - $group = $prefix."_nickid-to-channelid"; - $subgroup = $prefix."_nickid1"; - $leaf = $prefix."_channelid1"; - $ct->setMeta2($group, $subgroup, $leaf); - $time = time(); - - $ret = $ct->getMeta2($group, $subgroup, $leaf); - $this->assertEquals(count($ret["timestamp"]), 1, "number of leaf is wrong"); - $this->assertEquals($ret["timestamp"][0], $time, "the leaf timestamp is wrong"); - $this->assertEquals($ret["value"][0], null, "the leaf value is wrong"); - - $ret = $ct->getMeta2($group, $subgroup); - $this->assertEquals(count($ret["timestamp"]), 1, "number of leaf is wrong"); - $this->assertEquals($ret["timestamp"][0], $time, "the leaf timestamp is wrong"); - $this->assertEquals($ret["value"][0], $leaf, "the leaf name is wrong"); - - $leafvalue = $prefix."_leafvalue"; - $ct->setMeta2($group, $subgroup, $leaf, $leafvalue); - $time = time(); - - $ret = $ct->getMeta2($group, $subgroup, $leaf, true); - $this->assertEquals(count($ret["timestamp"]), 1, "number of leaf is wrong"); - $this->assertEquals($ret["timestamp"][0], $time, "the leaf timestamp is wrong"); - $this->assertEquals($ret["value"][0], $leafvalue, "the leaf value is wrong"); - } - - function test_getMeta_File_2() - { - $c =& $this->c; - $ct =& $this->ct; - - $prefix = __FUNCTION__; - $group = $prefix."_nickid-to-channelid"; - $subgroup = $prefix."_nickid1"; - $leaf1 = $prefix."_channelid1"; - $leaf2 = $prefix."_channelid2"; - $ct->setMeta2($group, $subgroup, $leaf1); - $ct->setMeta2($group, $subgroup, $leaf2); - $time = time(); - - $ret = $ct->getMeta2($group, $subgroup); - asort($ret["value"]); - $this->assertEquals(count($ret["timestamp"]), 2, "number of leaf is wrong"); - $this->assertEquals($ret["timestamp"][0], $time, "the leaf timestamp is wrong"); - $this->assertEquals($ret["timestamp"][1], $time, "the leaf timestamp is wrong"); - $this->assertEquals($ret["value"][0], $leaf1, "the leaf name is wrong"); - $this->assertEquals($ret["value"][1], $leaf2, "the leaf name is wrong"); - } - - function test_getMeta_File_3() - { - $c =& $this->c; - $ct =& $this->ct; - - $prefix = __FUNCTION__; - $group = $prefix."_nickid-to-channelid"; - $subgroup1 = $prefix."_nickid1"; - $subgroup2 = $prefix."_nickid2"; - $leaf1 = $prefix."_channelid1"; - $leaf2 = $prefix."_channelid2"; - $ct->setMeta2($group, $subgroup1, $leaf1); - $ct->setMeta2($group, $subgroup1, $leaf2); - $ct->setMeta2($group, $subgroup2, $leaf1); - $ct->setMeta2($group, $subgroup2, $leaf2); - $time = time(); - - $ret = $ct->getMeta2($group); - asort($ret["value"]); - $this->assertEquals(count($ret["timestamp"]), 2, "number of subgroup is wrong"); - $this->assertEquals($ret["timestamp"][0], $time, "the subgroup timestamp is wrong"); - $this->assertEquals($ret["timestamp"][1], $time, "the subgroup timestamp is wrong"); - $this->assertEquals($ret["value"][0], $subgroup1, "the subgroup name is wrong"); - $this->assertEquals($ret["value"][1], $subgroup2, "the subgroup name is wrong"); - } - function test_rmMeta_File_1() { $c =& $this->c; @@ -185,12 +104,12 @@ $group = $prefix."_nickid-to-channelid"; $subgroup = $prefix."_nickid1"; $leaf = $prefix."_channelid1"; - $ret = $ct->setMeta2($group, $subgroup, $leaf); + $ret = $ct->setMeta($group, $subgroup, $leaf); - $ret = $ct->rmMeta2($group, $subgroup, $leaf); + $ret = $ct->rmMeta($group, $subgroup, $leaf); $this->assertEquals($ret, true, "the returned value should be true (rm success)"); - $f = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup.'/'.$leaf; + $f = $c->container_cfg_server_dir.'/'.$group.'/'.$subgroup.'/'.$leaf; $ret = file_exists($f); $this->assertEquals($ret, false, "the leaf file should not exists anymore"); } @@ -205,20 +124,20 @@ $subgroup = $prefix."_nickid1"; $leaf1 = $prefix."_channelid1"; $leaf2 = $prefix."_channelid2"; - $ret = $ct->setMeta2($group, $subgroup, $leaf1); - $ret = $ct->setMeta2($group, $subgroup, $leaf2); + $ret = $ct->setMeta($group, $subgroup, $leaf1); + $ret = $ct->setMeta($group, $subgroup, $leaf2); - $ret = $ct->rmMeta2($group, $subgroup); + $ret = $ct->rmMeta($group, $subgroup); $this->assertEquals($ret, true, "the returned value should be true (rm success)"); - $f = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup.'/'.$leaf1; + $f = $c->container_cfg_server_dir.'/'.$group.'/'.$subgroup.'/'.$leaf1; $ret = file_exists($f); $this->assertEquals($ret, false, "the leaf file should not exists anymore"); - $f = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup.'/'.$leaf2; + $f = $c->container_cfg_server_dir.'/'.$group.'/'.$subgroup.'/'.$leaf2; $ret = file_exists($f); $this->assertEquals($ret, false, "the leaf file should not exists anymore"); - $d = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup; + $d = $c->container_cfg_server_dir.'/'.$group.'/'.$subgroup; $ret = file_exists($f); $this->assertEquals($ret, false, "the subgroup directory should not exists anymore"); } @@ -233,48 +152,27 @@ $subgroup = $prefix."_nickid1"; $leaf1 = $prefix."_channelid1"; $leaf2 = $prefix."_channelid2"; - $ret = $ct->setMeta2($group, $subgroup, $leaf1); - $ret = $ct->setMeta2($group, $subgroup, $leaf2); + $ret = $ct->setMeta($group, $subgroup, $leaf1); + $ret = $ct->setMeta($group, $subgroup, $leaf2); - $ret = $ct->rmMeta2($group); + $ret = $ct->rmMeta($group); $this->assertEquals($ret, true, "the returned value should be true (rm success)"); - $f = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup.'/'.$leaf1; + $f = $c->container_cfg_server_dir.'/'.$group.'/'.$subgroup.'/'.$leaf1; $ret = file_exists($f); $this->assertEquals($ret, false, "the leaf file should not exists anymore"); - $f = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup.'/'.$leaf2; + $f = $c->container_cfg_server_dir.'/'.$group.'/'.$subgroup.'/'.$leaf2; $ret = file_exists($f); $this->assertEquals($ret, false, "the leaf file should not exists anymore"); - $d = $c->container_cfg_meta_dir.'/'.$group.'/'.$subgroup; + $d = $c->container_cfg_server_dir.'/'.$group.'/'.$subgroup; $ret = file_exists($d); $this->assertEquals($ret, false, "the subgroup directory should not exists anymore"); - $d = $c->container_cfg_meta_dir.'/'.$group; + $d = $c->container_cfg_server_dir.'/'.$group; $ret = file_exists($d); $this->assertEquals($ret, false, "the group directory should not exists anymore"); } - - - function test_encodedecode_File_1() - { - $c =& $this->c; - $ct =& $this->ct; - - $string = "il était une fois C;h:!?§+ toto=}at是"; - - $prefix = __FUNCTION__; - $group = $prefix."_nickid-to-channelid"; - $subgroup = $prefix."_nickid1"; - $leaf = $prefix."_".$ct->_encode($string); - $leafvalue = $string; - $ct->setMeta2($group, $subgroup, $leaf, $leafvalue); - - $ret = $ct->getMeta2($group, $subgroup); - $this->assertEquals($ret['value'][0], $leaf, "the leaf name is wrong"); - $ret = $ct->getMeta2($group, $subgroup, $leaf, true); - $this->assertEquals($ret['value'][0], $leafvalue, "the leaf value is wrong"); - } } // on desactive le timeout car se script peut mettre bcp de temps a s'executer Modified: trunk/testcase/container_generic.php =================================================================== --- trunk/testcase/container_generic.php 2006-09-19 21:32:46 UTC (rev 771) +++ trunk/testcase/container_generic.php 2006-09-20 08:23:17 UTC (rev 772) @@ -47,7 +47,7 @@ $this->c->destroyCache(); } - function testCreateNick_Generic() + function test_createNick_Generic() { $c =& $this->c; $ct =& $this->ct; @@ -68,7 +68,7 @@ $this->assertTrue($isonline, "nickname should be online on the server"); } - function testRemoveNick_Generic() + function test_removeNick_Generic() { $c =& $this->c; $ct =& $this->ct; @@ -90,7 +90,7 @@ $this->assertFalse($isonline, "nickname shouldn't be online on the server"); } - function testGetNickId_Generic() + function test_getNickId_Generic() { $c =& $this->c; $ct =& $this->ct; @@ -104,7 +104,7 @@ $this->assertEquals($nickid, $ret, "created nickname doesn't have a correct nickid"); } - function testGetNickname_Generic() + function test_getNickname_Generic() { $c =& $this->c; $ct =& $this->ct; @@ -120,7 +120,7 @@ $this->assertEquals($nick, $ret, "nickname value is wrong"); } - function testGetOnlineNick_Generic() + function test_getOnlineNick_Generic() { $c =& $this->c; $ct =& $this->ct; @@ -143,7 +143,7 @@ } - function testRemoveObsoleteNick_Generic() + function test_removeObsoleteNick_Generic() { $c =& $this->c; $ct =& $this->ct; @@ -161,7 +161,7 @@ $this->assertFalse($isonline, "nickname shouldn't be online anymore"); } - function testupdateNick_Generic() + function test_updateNick_Generic() { $c =& $this->c; $ct =& $this->ct; @@ -182,7 +182,7 @@ } - function testchangeNick_Generic() + function test_changeNick_Generic() { $c =& $this->c; $ct =& $this->ct; @@ -202,7 +202,7 @@ $this->assertTrue($isonline2, "nickname shouldn't be online"); } - function testgetLastId_Generic() + function test_getLastId_Generic() { $c =& $this->c; $ct =& $this->ct; @@ -224,7 +224,7 @@ $this->assertEquals(10, $msgid, "last msgid is not correct"); } - function testwrite_Generic() + function test_write_Generic() { $c =& $this->c; $ct =& $this->ct; @@ -245,7 +245,7 @@ $this->assertEquals(1, $res["new_from_id"],"new_from_id is not correct"); } - function testread_Generic() + function test_read_Generic() { $c =& $this->c; $ct =& $this->ct; @@ -276,6 +276,108 @@ $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 test_encodedecode_Generic() + { + $c =& $this->c; + $ct =& $this->ct; + + $string = "il était une fois C;h:!?§+ toto=}at是"; + + $prefix = __FUNCTION__; + $group = $prefix."_nickid-to-channelid"; + $subgroup = $prefix."_nickid1"; + $leaf = $prefix."_".$ct->encode($string); + $leafvalue = $string; + $ct->setMeta($group, $subgroup, $leaf, $leafvalue); + + $ret = $ct->getMeta($group, $subgroup); + $this->assertEquals($ret['value'][0], $leaf, "the leaf name is wrong"); + $ret = $ct->getMeta($group, $subgroup, $leaf, true); + $this->assertEquals($ret['value'][0], $leafvalue, "the leaf value is wrong"); + } + + function test_getMeta_Generic_1() + { + $c =& $this->c; + $ct =& $this->ct; + + $prefix = __FUNCTION__; + $group = $prefix."_nickid-to-channelid"; + $subgroup = $prefix."_nickid1"; + $leaf = $prefix."_channelid1"; + $ct->setMeta($group, $subgroup, $leaf); + $time = time(); + + $ret = $ct->getMeta($group, $subgroup, $leaf); + $this->assertEquals(count($ret["timestamp"]), 1, "number of leaf is wrong"); + $this->assertEquals($ret["timestamp"][0], $time, "the leaf timestamp is wrong"); + $this->assertEquals($ret["value"][0], null, "the leaf value is wrong"); + + $ret = $ct->getMeta($group, $subgroup); + $this->assertEquals(count($ret["timestamp"]), 1, "number of leaf is wrong"); + $this->assertEquals($ret["timestamp"][0], $time, "the leaf timestamp is wrong"); + $this->assertEquals($ret["value"][0], $leaf, "the leaf name is wrong"); + + $leafvalue = $prefix."_leafvalue"; + $ct->setMeta($group, $subgroup, $leaf, $leafvalue); + $time = time(); + + $ret = $ct->getMeta($group, $subgroup, $leaf, true); + $this->assertEquals(count($ret["timestamp"]), 1, "number of leaf is wrong"); + $this->assertEquals($ret["timestamp"][0], $time, "the leaf timestamp is wrong"); + $this->assertEquals($ret["value"][0], $leafvalue, "the leaf value is wrong"); + } + + function test_getMeta_Generic_2() + { + $c =& $this->c; + $ct =& $this->ct; + + $prefix = __FUNCTION__; + $group = $prefix."_nickid-to-channelid"; + $subgroup = $prefix."_nickid1"; + $leaf1 = $prefix."_channelid1"; + $leaf2 = $prefix."_channelid2"; + $ct->setMeta($group, $subgroup, $leaf1); + $ct->setMeta($group, $subgroup, $leaf2); + $time = time(); + + $ret = $ct->getMeta($group, $subgroup); + asort($ret["value"]); + $this->assertEquals(count($ret["timestamp"]), 2, "number of leaf is wrong"); + $this->assertEquals($ret["timestamp"][0], $time, "the leaf timestamp is wrong"); + $this->assertEquals($ret["timestamp"][1], $time, "the leaf timestamp is wrong"); + $this->assertEquals($ret["value"][0], $leaf1, "the leaf name is wrong"); + $this->assertEquals($ret["value"][1], $leaf2, "the leaf name is wrong"); + } + + function test_getMeta_Generic_3() + { + $c =& $this->c; + $ct =& $this->ct; + + $prefix = __FUNCTION__; + $group = $prefix."_nickid-to-channelid"; + $subgroup1 = $prefix."_nickid1"; + $subgroup2 = $prefix."_nickid2"; + $leaf1 = $prefix."_channelid1"; + $leaf2 = $prefix."_channelid2"; + $ct->setMeta($group, $subgroup1, $leaf1); + $ct->setMeta($group, $subgroup1, $leaf2); + $ct->setMeta($group, $subgroup2, $leaf1); + $ct->setMeta($group, $subgroup2, $leaf2); + $time = time(); + + $ret = $ct->getMeta($group); + asort($ret["value"]); + $this->assertEquals(count($ret["timestamp"]), 2, "number of subgroup is wrong"); + $this->assertEquals($ret["timestamp"][0], $time, "the subgroup timestamp is wrong"); + $this->assertEquals($ret["timestamp"][1], $time, "the subgroup timestamp is wrong"); + $this->assertEquals($ret["value"][0], $subgroup1, "the subgroup name is wrong"); + $this->assertEquals($ret["value"][1], $subgroup2, "the subgroup name is wrong"); + } + } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-20 20:14:13
|
Revision: 776 http://svn.sourceforge.net/phpfreechat/?rev=776&view=rev Author: kerphi Date: 2006-09-20 13:14:04 -0700 (Wed, 20 Sep 2006) Log Message: ----------- add some link to documentation in the index page Modified Paths: -------------- trunk/index.php trunk/misc/tarSource Modified: trunk/index.php =================================================================== --- trunk/index.php 2006-09-20 18:31:54 UTC (rev 775) +++ trunk/index.php 2006-09-20 20:14:04 UTC (rev 776) @@ -53,17 +53,44 @@ <li> <ul> <li class="item"> - <a href="README.en">readme [en]</a> + <a href="overview.en.html">Overview [en]</a> </li> <li class="item"> - <a href="README.fr">readme [fr]</a> + <a href="overview.fr.html">Overview [fr]</a> </li> <li class="item"> - <a href="INSTALL.en">install [en]</a> + <a href="overview.es.html">Overview [es]</a> </li> <li class="item"> - <a href="INSTALL.fr">install [fr]</a> + <a href="overview.ar.html">Overview [zh]</a> </li> + <li class="item"> + <a href="overview.ar.html">Overview [ar]</a> + </li> + <li class="item"> + <a href="install.en.html">Install [en]</a> + </li> + <li class="item"> + <a href="install.fr.html">Install [fr]</a> + </li> + <li class="item"> + <a href="faq.en.html">FAQ [en]</a> + </li> + <li class="item"> + <a href="faq.fr.html">FAQ [fr]</a> + </li> + <li class="item"> + <a href="customize.en.html">Customize [en]</a> + </li> + <li class="item"> + <a href="customize.fr.html">Customize [fr]</a> + </li> + <li class="item"> + <a href="changelog.en.html">ChangeLog [en]</a> + </li> + <li class="item"> + <a href="changelog.fr.html">ChangeLog [fr]</a> + </li> </ul> </li> </ul> Modified: trunk/misc/tarSource =================================================================== --- trunk/misc/tarSource 2006-09-20 18:31:54 UTC (rev 775) +++ trunk/misc/tarSource 2006-09-20 20:14:04 UTC (rev 776) @@ -9,19 +9,19 @@ svn export .. ./$NAME rm -rf ./$NAME/contrib echo "-> downloading documentation" -wget http://www.phpfreechat.net/pages/fr/install.html -q -O ./$NAME/INSTALL.fr.html -wget http://www.phpfreechat.net/pages/en/install.html -q -O ./$NAME/INSTALL.en.html -wget http://www.phpfreechat.net/pages/fr/faq.html -q -O ./$NAME/FAQ.fr.html -wget http://www.phpfreechat.net/pages/en/faq.html -q -O ./$NAME/FAQ.en.html -wget http://www.phpfreechat.net/pages/fr/overview.html -q -O ./$NAME/OVERVIEW.fr.html -wget http://www.phpfreechat.net/pages/en/overview.html -q -O ./$NAME/OVERVIEW.en.html -wget http://www.phpfreechat.net/pages/ar/overview.html -q -O ./$NAME/OVERVIEW.ar.html -wget http://www.phpfreechat.net/pages/es/overview.html -q -O ./$NAME/OVERVIEW.es.html -wget http://www.phpfreechat.net/pages/zh/overview.html -q -O ./$NAME/OVERVIEW.zh.html -wget http://www.phpfreechat.net/pages/fr/customize.html -q -O ./$NAME/CUSTOMIZE.fr.html -wget http://www.phpfreechat.net/pages/en/customize.html -q -O ./$NAME/CUSTOMIZE.en.html -wget http://www.phpfreechat.net/pages/fr/changelog.html -q -O ./$NAME/CHANGELOG.fr.html -wget http://www.phpfreechat.net/pages/en/changelog.html -q -O ./$NAME/CHANGELOG.en.html +wget http://www.phpfreechat.net/pages/fr/install.html -q -O ./$NAME/install.fr.html +wget http://www.phpfreechat.net/pages/en/install.html -q -O ./$NAME/install.en.html +wget http://www.phpfreechat.net/pages/fr/faq.html -q -O ./$NAME/faq.fr.html +wget http://www.phpfreechat.net/pages/en/faq.html -q -O ./$NAME/faq.en.html +wget http://www.phpfreechat.net/pages/fr/overview.html -q -O ./$NAME/overview.fr.html +wget http://www.phpfreechat.net/pages/en/overview.html -q -O ./$NAME/overview.en.html +wget http://www.phpfreechat.net/pages/ar/overview.html -q -O ./$NAME/overview.ar.html +wget http://www.phpfreechat.net/pages/es/overview.html -q -O ./$NAME/overview.es.html +wget http://www.phpfreechat.net/pages/zh/overview.html -q -O ./$NAME/overview.zh.html +wget http://www.phpfreechat.net/pages/fr/customize.html -q -O ./$NAME/customize.fr.html +wget http://www.phpfreechat.net/pages/en/customize.html -q -O ./$NAME/customize.en.html +wget http://www.phpfreechat.net/pages/fr/changelog.html -q -O ./$NAME/changelog.fr.html +wget http://www.phpfreechat.net/pages/en/changelog.html -q -O ./$NAME/changelog.en.html echo "-> creating checkmd5.php file" ./checkmd5 ./$NAME ./$NAME/checkmd5.php This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-21 08:41:02
|
Revision: 778 http://svn.sourceforge.net/phpfreechat/?rev=778&view=rev Author: kerphi Date: 2006-09-21 01:40:39 -0700 (Thu, 21 Sep 2006) Log Message: ----------- [en] New parameters: 'max_channels' used to limit the number of channels tabs, 'max_privmsg' used to limit the number of private messages tabs (sponsored by Johnny Philavanh : 0 USD). [fr] Nouveaux parametres: 'max_channels' permet de limiter le nombre de channel qu'un utilisateur peut creer, 'max_privmsg' permet de limiter le nombre de messages prives par utilisateur (sponsorise par Johnny Philavanh : 0 USD) Modified Paths: -------------- trunk/demo/demo2_simple_with_params.php trunk/src/client/chat.js.tpl.php trunk/src/client/pfcclient.js trunk/src/commands/join.class.php trunk/src/commands/privmsg.class.php trunk/src/pfcglobalconfig.class.php Modified: trunk/demo/demo2_simple_with_params.php =================================================================== --- trunk/demo/demo2_simple_with_params.php 2006-09-20 20:24:30 UTC (rev 777) +++ trunk/demo/demo2_simple_with_params.php 2006-09-21 08:40:39 UTC (rev 778) @@ -10,7 +10,9 @@ $params["shownotice"] = 0; // 0 = nothing, 1 = just nickname changes, 2 = connect/quit, 3 = nick + connect/quit $params["max_nick_len"] = 20; // nickname length could not be longer than 10 caracteres $params["max_text_len"] = 300; // a message cannot be longer than 50 caracteres -$params["refresh_delay"] = 10000; // chat refresh speed is 10 secondes (10000ms) +$params["max_channels"] = 3; // limit the number of joined channels tab to 3 +$params["max_privmsg"] = 1; // limit the number of private message tab to 1 +$params["refresh_delay"] = 10000; // chat refresh speed is 10 secondes (10000ms) $params["max_msg"] = 15; // max message in the history is 15 (message seen when reloading the chat) $params["height"] = "230px"; // height of chat area is 230px $params["width"] = "800px"; // width of chat area is 800px Modified: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php 2006-09-20 20:24:30 UTC (rev 777) +++ trunk/src/client/chat.js.tpl.php 2006-09-21 08:40:39 UTC (rev 778) @@ -82,6 +82,8 @@ "A problem occurs during rehash", // _pfc "Choosen nickname is allready used", // _pfc "phpfreechat current version is %s", // _pfc + "Maximum number of joined channels has been reached", // _pfc + "Maximum number of private chat has been reached", // _pfc ); foreach($labels_to_load as $l) { Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-09-20 20:24:30 UTC (rev 777) +++ trunk/src/client/pfcclient.js 2006-09-21 08:40:39 UTC (rev 778) @@ -168,7 +168,7 @@ this.refresh_loginlogout(); } } - else if (cmd == "join") + else if (cmd == "join" || cmd == "join2") { if (resp =="ok") { @@ -176,29 +176,13 @@ var tabid = param[0]; var name = param[1]; this.gui.createTab(name, tabid, "ch"); - this.gui.setTabById(tabid); - /* - this.channels.push(name); - this.channelids.push(tabid); - */ + if (cmd != "join2") this.gui.setTabById(tabid); this.refresh_Smileys(); this.refresh_WhosOnline(); } - else - alert(cmd + "-"+resp+"-"+param); - } - else if (cmd == "join2") - { - if (resp =="ok") + else if (resp == "max_channels") { - // create the new channel - var tabid = param[0]; - var name = param[1]; - this.gui.createTab(name, tabid, "ch"); - // do not switch to the new created tab - // keep it in the background - // this.gui.setTabById(tabid); - this.refresh_WhosOnline(); + this.displayMsg( cmd, this.res.getLabel('Maximum number of joined channels has been reached') ); } else alert(cmd + "-"+resp+"-"+param); @@ -228,7 +212,7 @@ } } - else if (cmd == "privmsg") + else if (cmd == "privmsg" || cmd == "privmsg2") { if (resp == "ok") { @@ -236,34 +220,16 @@ var tabid = param[0]; var name = param[1]; this.gui.createTab(name, tabid, "pv"); - this.gui.setTabById(tabid); + if (cmd != "privmsg2") this.gui.setTabById(tabid); this.privmsgs.push(name); this.privmsgids.push(tabid); } - else if (resp == "unknown") + else if (resp == "max_privmsg") { - // speak to unknown user + this.displayMsg( cmd, this.res.getLabel('Maximum number of private chat has been reached') ); } - 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 Modified: trunk/src/commands/join.class.php =================================================================== --- trunk/src/commands/join.class.php 2006-09-20 20:24:30 UTC (rev 777) +++ trunk/src/commands/join.class.php 2006-09-21 08:40:39 UTC (rev 778) @@ -33,29 +33,31 @@ if(!isset($u->channels[$chanid])) { + if ($c->max_channels <= count($u->channels)) + { + // the maximum number of joined channels has been reached + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'max_channels', Array());"); + return; + } + $u->channels[$chanid]["recipient"] = $chanrecip; $u->channels[$chanid]["name"] = $channame; $u->saveInCache(); - + // clear the cached nicknames list for the given channel $nicklist_sid = "pfc_nicklist_".$c->getId()."_".$clientid."_".$chanid; $_SESSION[$nicklist_sid] = NULL; + + // show a join message + $cmdp = $p; + $cmdp["param"] = _pfc("%s joins %s",$u->nick, $channame); + $cmdp["recipient"] = $chanrecip; + $cmdp["recipientid"] = $chanid; + $cmdp["flag"] = 2; + $cmd =& pfcCommand::Factory("notice"); + $cmd->run($xml_reponse, $cmdp); } - // show a join message - $cmdp = $p; - $cmdp["param"] = _pfc("%s joins %s",$u->nick, $channame); - $cmdp["recipient"] = $chanrecip; - $cmdp["recipientid"] = $chanid; - $cmdp["flag"] = 2; - $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $cmdp); - - - //$xml_reponse->addScript("alert('join: chan=".$channame.", from_id=".$from_id."');"); - // $xml_reponse->addScript("alert('join: u->nick=".$u->nick." chanid=".$chanid." channame=".addslashes($channame)."');"); - // $xml_reponse->addScript("alert('join: fromidsid=".$from_id_sid."');"); - // return ok to the client // then the client will create a new tab $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', Array('".$chanid."','".addslashes($channame)."'));"); Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2006-09-20 20:24:30 UTC (rev 777) +++ trunk/src/commands/privmsg.class.php 2006-09-21 08:40:39 UTC (rev 778) @@ -61,6 +61,13 @@ // in the sessions if (!isset($u->privmsg[$pvrecipientid])) { + if ($c->max_privmsg <= count($u->privmsg)) + { + // the maximum number of private messages has been reached + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'max_privmsg', Array());"); + return; + } + $u->privmsg[$pvrecipientid]["recipient"] = $pvrecipient; $u->privmsg[$pvrecipientid]["name"] = $pvname; $u->privmsg[$pvrecipientid]["pvnickid"] = $pvnickid; Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-09-20 20:24:30 UTC (rev 777) +++ trunk/src/pfcglobalconfig.class.php 2006-09-21 08:40:39 UTC (rev 778) @@ -53,6 +53,8 @@ var $title = ""; // default is _pfc("My Chat") var $channels = array(); // the default joined channels when opening the chat var $frozen_channels = array(); // if empty, allows users to create there own channels + var $max_channels = 10; // this the max number of allowed channels by users + var $max_privmsg = 5; // this the max number of allowed privmsg by users var $frozen_nick = false; var $max_nick_len = 15; var $max_text_len = 400; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-21 12:13:35
|
Revision: 780 http://svn.sourceforge.net/phpfreechat/?rev=780&view=rev Author: kerphi Date: 2006-09-21 05:13:24 -0700 (Thu, 21 Sep 2006) Log Message: ----------- Rename bad spelled parameters name : 'skip_proxys' to 'skip_proxies', 'post_proxys' to 'post_proxies', 'pre_proxys' to 'pre_proxies', 'proxys_cfg' to 'proxies_cfg', 'proxys_path' to 'proxies_path', and 'proxys_path_default' to 'proxies_path_default'. Modified Paths: -------------- trunk/demo/demo48_custom_proxy.php trunk/src/pfccommand.class.php trunk/src/pfcglobalconfig.class.php trunk/src/pfci18n.class.php trunk/src/proxies/censor.class.php trunk/src/proxies/log.class.php trunk/src/proxies/noflood.class.php Added Paths: ----------- trunk/src/proxies/ Removed Paths: ------------- trunk/src/proxys/ Modified: trunk/demo/demo48_custom_proxy.php =================================================================== --- trunk/demo/demo48_custom_proxy.php 2006-09-21 09:10:29 UTC (rev 779) +++ trunk/demo/demo48_custom_proxy.php 2006-09-21 12:13:24 UTC (rev 780) @@ -3,9 +3,9 @@ require_once dirname(__FILE__)."/../src/phpfreechat.class.php"; $params["serverid"] = md5(__FILE__); // calculate a unique id for this chat -$params["skip_proxys"] = array("censor"); // shows how to disable a proxy (try to write fuck in the chat, it should be possible) -$params["post_proxys"] = array("myproxy"); -$params["proxys_path"] = dirname(__FILE__).'/demo48_custom_proxy'; +$params["skip_proxies"] = array("censor"); // shows how to disable a proxy (try to write fuck in the chat, it should be possible) +$params["post_proxies"] = array("myproxy"); +$params["proxies_path"] = dirname(__FILE__).'/demo48_custom_proxy'; $chat = new phpFreeChat( $params ); ?> Modified: trunk/src/pfccommand.class.php =================================================================== --- trunk/src/pfccommand.class.php 2006-09-21 09:10:29 UTC (rev 779) +++ trunk/src/pfccommand.class.php 2006-09-21 12:13:24 UTC (rev 780) @@ -79,21 +79,21 @@ $cmd =& new $cmd_classname(); $cmd->name = $cmd_name; - // instanciate the proxys chaine + // instanciate the proxies chaine $firstproxy =& $cmd; - for($i = count($c->_proxys)-1; $i >= 0; $i--) + for($i = count($c->_proxies)-1; $i >= 0; $i--) { - $proxy_name = strtolower($c->_proxys[$i]); + $proxy_name = strtolower($c->_proxies[$i]); $proxy_classname = "pfcProxyCommand_" . $proxy_name; if (!class_exists($proxy_classname)) { // try to include the proxy class file from the default path or from the customized path - $proxy_filename = $c->proxys_path_default.'/'.$proxy_name.".class.php"; + $proxy_filename = $c->proxies_path_default.'/'.$proxy_name.".class.php"; if (file_exists($proxy_filename)) require_once($proxy_filename); else { - $proxy_filename = $c->proxys_path.'/'.$proxy_name.".class.php"; + $proxy_filename = $c->proxies_path.'/'.$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-09-21 09:10:29 UTC (rev 779) +++ trunk/src/pfcglobalconfig.class.php 2006-09-21 12:13:24 UTC (rev 780) @@ -41,15 +41,15 @@ var $lockurl = "http://www.phpfreechat.net"; // this is the url where the users must be redirected when the chat is locked // these parameters are static (cached) - var $skip_proxys = array(); // these proxies will be skiped. ex: append "censor" to the list to disable words censoring - var $post_proxys = array(); // these proxies will be handled just before to process commands and just after system proxies - var $pre_proxys = array(); // these proxies will be handled before system proxies (at begining) - var $proxys_cfg = array("auth" => array(), + var $skip_proxies = array(); // these proxies will be skiped. ex: append "censor" to the list to disable words censoring + var $post_proxies = array(); // these proxies will be handled just before to process commands and just after system proxies + var $pre_proxies = array(); // these proxies will be handled before system proxies (at begining) + var $proxies_cfg = array("auth" => array(), "noflood" => array("limit"=>10,"delay"=>5), "censor" => array("words"=>array("fuck","sex","bitch"),"replaceby"=>"*"), "log" => array("path"=>"")); - var $proxys_path = ""; // a custom proxies path - var $proxys_path_default = ""; // dirname(__FILE__).'/proxys' + var $proxies_path = ""; // a custom proxies path + var $proxies_path_default = ""; // dirname(__FILE__).'/proxies' var $title = ""; // default is _pfc("My Chat") var $channels = array(); // the default joined channels when opening the chat var $frozen_channels = array(); // if empty, allows users to create there own channels @@ -109,8 +109,8 @@ var $debugxajax = false; // private parameters - var $_sys_proxys = array("lock", "checktimeout", "checknickchange", "auth", "noflood", "censor", "log"); - var $_proxys = array(); // will contains proxies to execute on each command (filled in the init step) + var $_sys_proxies = array("lock", "checktimeout", "checknickchange", "auth", "noflood", "censor", "log"); + var $_proxies = array(); // will contains proxies to execute on each command (filled in the init step) var $_dyn_params = array("nick","isadmin","islocked","admins","frozen_channels"); var $_params_type = array(); @@ -168,11 +168,11 @@ if (preg_match('/^_/',$k)) $this->errors[] = _pfc("Error: '%s' is a private parameter, you are not allowed to change it", $k); - if ($k == "proxys_cfg") + if ($k == "proxies_cfg") { // don't replace all the proxy_cfg parameters, just replace the specified ones - foreach ( $params["proxys_cfg"] as $k2 => $v2 ) - $this->proxys_cfg[$k2] = $v2; + foreach ( $params["proxies_cfg"] as $k2 => $v2 ) + $this->proxies_cfg[$k2] = $v2; } else $this->$k = $v; @@ -399,30 +399,30 @@ // calculate the proxies chaine - $this->_proxys = array(); - foreach($this->pre_proxys as $px) + $this->_proxies = array(); + foreach($this->pre_proxies as $px) { - if (!in_array($px,$this->skip_proxys) && !in_array($px,$this->_proxys)) - $this->_proxys[] = $px; + if (!in_array($px,$this->skip_proxies) && !in_array($px,$this->_proxies)) + $this->_proxies[] = $px; } - foreach($this->_sys_proxys as $px) + foreach($this->_sys_proxies as $px) { - if (!in_array($px,$this->skip_proxys) && !in_array($px,$this->_proxys)) - $this->_proxys[] = $px; + if (!in_array($px,$this->skip_proxies) && !in_array($px,$this->_proxies)) + $this->_proxies[] = $px; } - foreach($this->post_proxys as $px) + foreach($this->post_proxies as $px) { - if (!in_array($px,$this->skip_proxys) && !in_array($px,$this->_proxys)) - $this->_proxys[] = $px; + if (!in_array($px,$this->skip_proxies) && !in_array($px,$this->_proxies)) + $this->_proxies[] = $px; } // save the proxies path - $this->proxys_path_default = dirname(__FILE__).'/proxys'; + $this->proxies_path_default = dirname(__FILE__).'/proxies'; // check the customized proxies path - if ($this->proxys_path != '' && !is_dir($this->proxys_path)) - $this->errors[] = _pfc("'%s' directory doesn't exist", $this->proxys_path); + if ($this->proxies_path != '' && !is_dir($this->proxies_path)) + $this->errors[] = _pfc("'%s' directory doesn't exist", $this->proxies_path); // load smileys from file $this->loadSmileyTheme(); Modified: trunk/src/pfci18n.class.php =================================================================== --- trunk/src/pfci18n.class.php 2006-09-21 09:10:29 UTC (rev 779) +++ trunk/src/pfci18n.class.php 2006-09-21 12:13:24 UTC (rev 780) @@ -137,7 +137,7 @@ $files = array_merge($files, glob(dirname(__FILE__)."/*.php")); $files = array_merge($files, glob(dirname(__FILE__)."/commands/*.php")); $files = array_merge($files, glob(dirname(__FILE__)."/containers/*.php")); - $files = array_merge($files, glob(dirname(__FILE__)."/proxys/*.php")); + $files = array_merge($files, glob(dirname(__FILE__)."/proxies/*.php")); $files = array_merge($files, glob(dirname(__FILE__)."/../themes/default/templates/*.php")); $res = array(); Copied: trunk/src/proxies (from rev 779, trunk/src/proxys) Modified: trunk/src/proxies/censor.class.php =================================================================== --- trunk/src/proxys/censor.class.php 2006-09-21 09:10:29 UTC (rev 779) +++ trunk/src/proxies/censor.class.php 2006-09-21 12:13:24 UTC (rev 780) @@ -44,8 +44,8 @@ $cmdtocheck = array("send", "nick", "me"); if ( in_array($this->name, $cmdtocheck) ) { - $words = $c->proxys_cfg[$this->proxyname]["words"]; - $replaceby = $c->proxys_cfg[$this->proxyname]["replaceby"]; + $words = $c->proxies_cfg[$this->proxyname]["words"]; + $replaceby = $c->proxies_cfg[$this->proxyname]["replaceby"]; $patterns = array(); $replacements = array(); Modified: trunk/src/proxies/log.class.php =================================================================== --- trunk/src/proxys/log.class.php 2006-09-21 09:10:29 UTC (rev 779) +++ trunk/src/proxies/log.class.php 2006-09-21 12:13:24 UTC (rev 780) @@ -43,8 +43,8 @@ $c =& $this->c; $u =& $this->u; - $logpath = ($c->proxys_cfg[$this->proxyname]["path"] == "" ? $c->data_private_path."/logs" : - $c->proxys_cfg[$this->proxyname]["path"]); + $logpath = ($c->proxies_cfg[$this->proxyname]["path"] == "" ? $c->data_private_path."/logs" : + $c->proxies_cfg[$this->proxyname]["path"]); $logpath .= "/".$c->getId(); if (!file_exists($logpath)) @mkdir_r($logpath); Modified: trunk/src/proxies/noflood.class.php =================================================================== --- trunk/src/proxys/noflood.class.php 2006-09-21 09:10:29 UTC (rev 779) +++ trunk/src/proxies/noflood.class.php 2006-09-21 12:13:24 UTC (rev 780) @@ -51,12 +51,12 @@ $nbflood = $container->getUserMeta($nickid, 'nbflood'); $floodtime = time(); - if ($floodtime - $lastfloodtime <= $c->proxys_cfg[$this->proxyname]["delay"]) + if ($floodtime - $lastfloodtime <= $c->proxies_cfg[$this->proxyname]["delay"]) $nbflood++; else $nbflood = 0; - if ($nbflood>$c->proxys_cfg[$this->proxyname]["limit"]) + if ($nbflood>$c->proxies_cfg[$this->proxyname]["limit"]) { // warn the flooder $msg = _pfc("Please don't post so many message, flood is not tolerated"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2006-09-22 09:29:04
|
Revision: 782 http://svn.sourceforge.net/phpfreechat/?rev=782&view=rev Author: kerphi Date: 2006-09-22 02:28:51 -0700 (Fri, 22 Sep 2006) Log Message: ----------- [en] Improve noflood proxy algorithme: now it takes into account the number of posted characteres and the number of posted messages. [fr] Ammelioration du proxy noflood : maintenant il prend en compte le nombre de caracteres postes ainsi que le nombre de messsages postes. Modified Paths: -------------- trunk/src/pfcglobalconfig.class.php trunk/src/proxies/noflood.class.php Added Paths: ----------- trunk/lib/utf8/utf8_strlen.php Added: trunk/lib/utf8/utf8_strlen.php =================================================================== --- trunk/lib/utf8/utf8_strlen.php (rev 0) +++ trunk/lib/utf8/utf8_strlen.php 2006-09-22 09:28:51 UTC (rev 782) @@ -0,0 +1,24 @@ +<?php + +/** + * Counts the number of characters of a string in UTF-8. + * Unit-tested by Kasper and works 100% like strlen() / mb_strlen() + * + * @param string UTF-8 multibyte character string + * @return integer The number of characters + * @see strlen() + * @author Martin Kutschker <mar...@bl...> + */ +function utf8_strlen($str) { + $n=0; + for($i=0; strlen($str{$i}); $i++) { + $c = ord($str{$i}); + if (!($c & 0x80)) // single-byte (0xxxxxx) + $n++; + elseif (($c & 0xC0) == 0xC0) // multi-byte starting byte (11xxxxxx) + $n++; + } + return $n; +} + +?> \ No newline at end of file Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-09-22 08:12:22 UTC (rev 781) +++ trunk/src/pfcglobalconfig.class.php 2006-09-22 09:28:51 UTC (rev 782) @@ -45,7 +45,7 @@ var $post_proxies = array(); // these proxies will be handled just before to process commands and just after system proxies var $pre_proxies = array(); // these proxies will be handled before system proxies (at begining) var $proxies_cfg = array("auth" => array(), - "noflood" => array("limit"=>10,"delay"=>5), + "noflood" => array("charlimit"=>450,"msglimit"=>10,"delay"=>5), "censor" => array("words"=>array("fuck","sex","bitch"),"replaceby"=>"*"), "log" => array("path"=>"")); var $proxies_path = ""; // a custom proxies path Modified: trunk/src/proxies/noflood.class.php =================================================================== --- trunk/src/proxies/noflood.class.php 2006-09-22 08:12:22 UTC (rev 781) +++ trunk/src/proxies/noflood.class.php 2006-09-22 09:28:51 UTC (rev 782) @@ -22,6 +22,7 @@ require_once dirname(__FILE__)."/../pfci18n.class.php"; require_once dirname(__FILE__)."/../pfcuserconfig.class.php"; require_once dirname(__FILE__)."/../pfcproxycommand.class.php"; +require_once dirname(__FILE__)."/../../lib/utf8/utf8_strlen.php"; /** * pfcProxyCommand_noflood @@ -48,15 +49,26 @@ $nickid = $u->nickid; $isadmin = $container->getUserMeta($nickid, 'isadmin'); $lastfloodtime = $container->getUserMeta($nickid, 'floodtime'); - $nbflood = $container->getUserMeta($nickid, 'nbflood'); + $flood_nbmsg = $container->getUserMeta($nickid, 'flood_nbmsg'); + $flood_nbchar = $container->getUserMeta($nickid, 'flood_nbchar'); $floodtime = time(); - + + // update the number of posted message indicator if ($floodtime - $lastfloodtime <= $c->proxies_cfg[$this->proxyname]["delay"]) - $nbflood++; + $flood_nbmsg++; else - $nbflood = 0; + $flood_nbmsg = 0; + + // update the number of posted characteres indicator + if ($floodtime - $lastfloodtime <= $c->proxies_cfg[$this->proxyname]["delay"]) + $flood_nbchar += utf8_strlen($param); + else + $flood_nbchar = 0; - if ($nbflood>$c->proxies_cfg[$this->proxyname]["limit"]) + if (!$isadmin && + ($flood_nbmsg>$c->proxies_cfg[$this->proxyname]["msglimit"] || + $flood_nbchar>$c->proxies_cfg[$this->proxyname]["charlimit"]) + ) { // warn the flooder $msg = _pfc("Please don't post so many message, flood is not tolerated"); @@ -71,9 +83,10 @@ return; } - if ($nbflood == 0) + if ($flood_nbmsg == 0) $container->setUserMeta($nickid, 'floodtime', $floodtime); - $container->setUserMeta($nickid, 'nbflood', $nbflood); + $container->setUserMeta($nickid, 'flood_nbmsg', $flood_nbmsg); + $container->setUserMeta($nickid, 'flood_nbchar', $flood_nbchar); } // forward the command to the next proxy or to the final command This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |