[Phpfreechat-svn] SF.net SVN: phpfreechat: [1008] trunk/src/pfccommand.class.php
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2007-03-25 16:55:12
|
Revision: 1008 http://svn.sourceforge.net/phpfreechat/?rev=1008&view=rev Author: kerphi Date: 2007-03-25 09:55:12 -0700 (Sun, 25 Mar 2007) Log Message: ----------- code cleaning Modified Paths: -------------- trunk/src/pfccommand.class.php Modified: trunk/src/pfccommand.class.php =================================================================== --- trunk/src/pfccommand.class.php 2007-03-25 15:58:22 UTC (rev 1007) +++ trunk/src/pfccommand.class.php 2007-03-25 16:55:12 UTC (rev 1008) @@ -301,13 +301,41 @@ $params = array_values($params); $params = array_map("trim",$params); $params = array_merge(array($clientid,$recipientid), $params); + + $result['cmdstr'] = $cmd_str; + $result['cmdname'] = $cmd; + $result['params'] = $params; + } + return $result; + } + + /* + // THIS IS ANOTHER WAY TO PARSE THE PARAMETERS + // IT'S NOT SIMPLIER BUT MAYBE FASTER + // @todo : take the faster methode + function ParseCommand($cmd_str, $one_parameter = false) + { + $pattern_command = '/^\/([a-z0-9]+)\s*([a-z0-9]+)\s*([a-z0-9]+)\s*(.*)/'; + $result = array(); + + // parse the command name (ex: '/invite') + if (preg_match($pattern_command, $cmd_str, $res)) + { + $cmd = $res[1]; + $clientid = $res[2]; + $recipientid = $res[3]; + $params_str = $res[4]; + // don't parse multiple parameters for special commands with only one parameter + // this make possible to send double quotes (") in these commands + if ($one_parameter || $cmd == 'send' || $cmd == 'notice' || $cmd == 'me') + { + $result['cmdstr'] = $cmd_str; + $result['cmdname'] = $cmd; + $result['params'] = array($clientid, $recipientid, $params_str); + return $result; + } - // THIS IS ANOTHER WAY TO PARSE THE PARAMETERS - // IT'S NOT SIMPLIER BUT MAYBE FASTER - // @todo : take the faster methode - /* - $params = array($clientid, $recipientid); $sep = preg_match('/[^\\\\]"/',$params_str) ? '"' : ' '; if ($sep == ' ') $params_str = ' ' . $params_str; @@ -345,8 +373,6 @@ // append the tail if ($offset < strlen($params_str)) $params[] = substr($params_str,$offset); - */ - $result['cmdstr'] = $cmd_str; $result['cmdname'] = $cmd; @@ -354,6 +380,8 @@ } return $result; } +*/ + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |