Home  >  Article  >  Backend Development  >  一个图片地址分解程序(用于PHP小偷程序)_PHP

一个图片地址分解程序(用于PHP小偷程序)_PHP

WBOY
WBOYOriginal
2016-05-31 19:30:141078browse

如题,返回一个数组,可以获得图片地址的base url,相对地址,名称等,具体见下例:

<&#63;
error_reporting(E_ALL ^ E_NOTICE); 
$imgurl='http://files.bitsCN.com/file_images/article/201408/201408232212306.png';
$imgurl_dir='/img/2014/07/02/14520384.gif';
//echo getimg($imgurl,'./img');
var_dump(url_set_value($imgurl));
var_dump(url_set_value($imgurl_dir));

/**
 * function name:url_set_value
 * User: Don
 * Date: 14-8-2
 * Time: 上午12:43
 */
function url_set_value($url) 
{ 
$a=explode('/',$url);
$url_set=array();
for($n=0 ;$n<count($a);$n++)
{
	//var_dump($a);
	if($a[$n]=='http:')
	{
		$url_set['base_url']=$a[$n+2];
		for($p=$n+3 ;$p<count($a)-1;$p++)
			 $url_set['img_dir_path'].='/'.$a[$p];
		$url_set['img_path']=	$a[count($a)-1];
		$url_set['img_ful_path']=	$url_set['img_dir_path'].$url_set['img_path'];
	}
	else
	{	for($p=0 ;$p<count($a)-1;$p++)
			if($a[$p]!=='')
			$url_set['img_dir_path'].='/'.$a[$p];
			
			$url_set['img_path']=	$a[count($a)-1];
			$url_set['img_ful_path']=	$url_set['img_dir_path'].$url_set['img_path'];
		}
		return $url_set;
}
}
&#63;>

运行结果:

array(4) {
 ["base_url"]=>
 string(14) "files.bitsCN.com"
 ["img_dir_path"]=>
 string(27) "/file_images/article/201408"
 ["img_path"]=>
 string(19) "201408232212306.png"
 ["img_ful_path"]=>
 string(46) "/file_images/article/201408201408232212306.png"
}
array(3) {
 ["img_dir_path"]=>
 string(15) "/img/2014/07/02"
 ["img_path"]=>
 string(12) "14520384.gif"
 ["img_ful_path"]=>
 string(27) "/img/2014/07/0214520384.gif"
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn