首页 > PHP教程

PHP CURL模拟GET及POST函数代码


<?php教程
function vcurl($url, $post = , $cookie = , $cookiejar = , $referer = ){
$tmpInfo = ;
$cookiepath = getcwd()../.$cookiejar;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER[HTTP_USER_AGENT]);
if($referer) {
curl_setopt($curl, CURLOPT_REFERER, $referer);
} else {
curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
}
if($post) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
}
if($cookie) {
curl_setopt($curl, CURLOPT_COOKIE, $cookie);
}
if($cookiejar) {
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookiepath);
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookiepath);
}
//curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 100);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$tmpInfo = curl_exec($curl);
if (curl_errno($curl)) {
echo <pre><b>错误:</b><br />.curl_error($curl);
}
curl_close($curl);
return $tmpInfo;
}
?>

阅读全文

PHP截取指定图片大小实例代码

header("Content-type: image/jpeg"); 
$filename = book_rabbit_rule.jpg;
/* 读取图档 */
$im = imagecreatefromjpeg($filename); 
/* 图片要截多少, 长/宽 */
$new_img_width = 120;
$new_img_height = 42; 
/* 先建立一个 新的空白图档 */
$newim = imagecreate($new_img_width, $new_img_height); 
// 输出图要从哪边开始 x, y ,原始图要从哪边开始 x, y ,要画多大 x, y(resize) , 要抓多大 x, y
imagecopyresampled($newim, $im, 0, 0, 7, 174, 120, 42, $new_img_width, $new_img_height); 
/* 放大成 500 x 500 的图 */
// imagecopyresampled($newim, $im, 0, 0, 100, 30, 500, 500, $new_img_width, $new_img_height); 
/* 将图印出来 */
imagejpeg($newim); 
/* 资源回收 */
imagedestroy($newim);
imagedestroy($im);
?>

阅读全文

php 文件下载实例代码

php教程 文件下载实例代码
function xiazai($file_dir,$file_name)
//参数说明:
//file_dir:文件所在目录
//file_name:文件名
{
     $file_dir = chop($file_dir);//去掉路径中多余的空格
     //得出要下载的文件的路径
     if($file_dir != )
     {
         $file_path = $file_dir;
         if(substr($file_dir,strlen($file_dir)-1,strlen($file_dir)) != /)
             $file_path .= /;
         $file_path .= $file_name;
     }           
     else
         $file_path = $file_name;   
   
     //判断要下载的文件是否存在
     if(!file_exists($file_path))
     {
         alert(对不起,你要下载的文件不存在);
         return false;
     }

阅读全文

php fsockopen 伪造 post和get方法

本文章为你提供一款php教程 fsockopen 伪造 post和get方法哦,如果你正在找 伪造 post和get方法的php处理代码这款不错哦。

<?php
//fsocket模拟post提交
$purl = "http://localhost/netphp/test2.php?uu=rrrrrrrrrrrr";
print_r(parse_url(http://pic1.phprm.com/2013/09/05/http://pic1.phprm.com/2013/09/05/http://pic1.phprm.com/2013/09/05/$url.jpg.jpg.jpg));
sock_post($purl,"uu=55555555555555555");

阅读全文

查百度—百度网站权重SEO工具查询

查百度—百度网站权重SEO工具查询
<html>
<title>查百度—百度网站权重SEO工具查询</title>
<meta http-equiv=Content-Language content=zh-cn>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name=keywords content="百度关键字,关键字排名,关键字查询">
<meta name="description" content="百度关键字查询系统的主要功能是:查询百度搜索引擎教程某个关键字的搜索结果中是否包含您的网页,并且能够查询出您的网页排在第几页.">
<meta name="robots" content="index, follow" />
<meta name="googlebot" content="index, follow" />

阅读全文