Home > Backend Development > PHP Tutorial > An image address decomposition program (for PHP thief program), _PHP Tutorial

An image address decomposition program (for PHP thief program), _PHP Tutorial

WBOY
Release: 2016-07-13 10:20:12
Original
898 people have browsed it

A picture address decomposition program (for PHP thief program),

As in the title, an array is returned, and the base url, relative address, name, etc. of the image address can be obtained. For details, see the following example:

<&#63;
error_reporting(E_ALL ^ E_NOTICE); 
$imgurl='http://files.jb51.net/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;>
Copy after login

Run result:

array(4) {
 ["base_url"]=>
 string(14) "files.jb51.net"
 ["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"
}
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/868223.htmlTechArticleA picture address decomposition program (for PHP thief program), as the title returns an array, you can get the picture address base url, relative address, name, etc., see the following example for details: error_rep...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template