iwas的源代码INDEX.PHP处理所有的操作,和我平时的编程习惯不一致,觉得比较别扭,我不是很习惯一个大文件,上网找了找MVC分层的资料,感觉不错
用PHP开始你的MVC (一)整合你的站点入口
/*
* 解析当前的访问路径,得到要进行动作
*/
function _parsePath(){
list($path, $param) = explode("?", $_SERVER["REQUEST_URI"]);
$pos = strrpos($path, "/");
$this->action = substr($path, $pos+1);
}
我改为:
list($path, $param) = explode("?", $_SERVER["REQUEST_URI"]);
$pos = strrpos($param, "=");
$m=substr($param, $pos+1);
我一直使用正常,http://http://127.0.0.1/iwas/?action=img_show
但是现在有一个解析不正常了:http://127.0.0.1/iwas/?action=img_del&id=0&name=1124846170.bmp
看来看去,原来是 strrpos?!
strpos -- Find position of first occurrence of a string
int strpos ( string haystack, mixed needle [, int offset] )
Returns the numeric position of the first occurrence of needle in the haystack string. Unlike the strrpos(), this function can take a full string as the needle parameter and the entire string will be used.
strrpos -- Find position of last occurrence of a char in a string
int strrpos ( string haystack, string needle [, int offset] )
Returns the numeric position of the last occurrence of needle in the haystack string. Note that the needle in this case can only be a single character in PHP 4. If a string is passed as the needle, then only the first character of that string will be used.
最后索性改为 $this->action=$action; 了事
2005-8-24 8:36:33 已删除 SF\shengfang GreenBrowser.ex M:\temp\Temporary Internet Files\Temporary Internet Files\Content.IE5\7Q2W3FJM\server[1].htm Exploit-MhtRedir.gen (特洛伊)
2005-8-24 8:36:33 已删除 SF\shengfang GreenBrowser.ex M:\temp\Temporary Internet Files\Temporary Internet Files\Content.IE5\7Q2W3FJM\ok[1].htm JS/Exploit-HelpXSite (特洛伊)
2005-8-24 8:36:33 已删除 SF\shengfang GreenBrowser.ex M:\temp\Temporary Internet Files\Temporary Internet Files\Content.IE5\KLTAFHVX\ok[1].htm JS/Exploit-HelpXSite (特洛伊)
2005-8-24 8:36:34 已清除 SF\shengfang GreenBrowser.ex M:\temp\Temporary Internet Files\Temporary Internet Files\Content.IE5\ALZW9GJE\hua[1].exe W32/Darro.gen (病毒)
2005-8-24 9:46:48 移动失败(清除失败) SF\shengfang msvb_default.ex M:\temp\Temporary Internet Files\Temporary Internet Files\Content.IE5\6QY99H0I\ins_33ng[1].exe Proxy-Agent.a.dr (特洛伊)
vig0
11-Jul-2005 09:03
This function takes in a string and a delimiter. It then builds an array of the data in between the delimiter then returns the array. I needed this function for something that I'm doing and thought it was somewhat useful.
function multiStrposArray($haystack, $needle){
$array = array();
$row = 0;
$var = "";
for ($i=0; $i<strlen($haystack); $i++) {
if (substr($haystack, $i, 1)==$needle) {
$array[$row] = $var;
$row++;
$var = "";
} else {
$var .= substr($haystack, $i, 1);
}
}
if ($var) $array[$row] = $var;
return $array;
}