易截截图软件、单文件、免安装、纯绿色、仅160KB

php 手机下载 POST 类

由于最近在与SP合作,开发手机业务下载,数据提交采用POST方式提交,现与大家分亨比较成熟类.
function uc_api_post($url, $action, $sendmsg='') {
$postdata = "corpMsg=$sendmsg";
return uc_fopen(UC_URL, 500000, $postdata, '', TRUE, UC_IP, 20);
}
function uc_fopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE) {
$return = '';
$matches = parse_url($url);
!isset($matches['host']) && $matches['host'] = '';
!isset($matches['path']) && $matches['path'] = '';
!isset($matches['query']) && $matches['query'] = '';
!isset($matches['port']) && $matches['port'] = '';
$host = $matches['host'];
$path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';
$port = !empty($matches['port']) ? $matches['port'] : 80;
if($post) {
$out = "POST $path HTTP/1.0\r\n";
$out .= "Accept: */*\r\n";
//$out .= "Referer: $boardurl\r\n";
$out .= "Accept-Language: zh-cn\r\n";
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$out .= "Host: $host\r\n";
$out .= 'Content-Length: '.strlen($post)."\r\n";
$out .= "Connection: Close\r\n";
$out .= "Cache-Control: no-cache\r\n";
$out .= "Cookie: $cookie\r\n\r\n";
$out .= $post;
} else {
$out = "GET $path HTTP/1.0\r\n";
$out .= "Accept: */*\r\n";
//$out .= "Referer: $boardurl\r\n";
$out .= "Accept-Language: zh-cn\r\n";
$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$out .= "Host: $host\r\n";
$out .= "Connection: Close\r\n";
$out .= "Cookie: $cookie\r\n\r\n";
}
$fp = @fsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout);
if(!$fp) {
return '';
} else {
stream_set_blocking($fp, $block);
stream_set_timeout($fp, $timeout);
@fwrite($fp, $out);
$status = stream_get_meta_data($fp);
if(!$status['timed_out']) {
while (!feof($fp)) {
if(($header = @fgets(


相关文档:

PHP:路在何方?

PHP4:奇迹背后
1995年时,Rasmus在用PHP写他的个人主页;今天,PHP成为风靡全球的脚本语言,越来越多的站点选择使用PHP,连Yahoo都放弃了自己的脚本而改用PHP支持它的网站。可以说,PHP是一个奇迹。我一直认为,任何奇迹背后都有它的原因。现在,就让我们透过这个奇迹,来看看PHP的成功之道。
1 简单易用
PHP的入门门槛 ......

PHP如何设置、取得、删除Cookie值?

PHP函数setcookie()用来设置cookie.
setcookie()函数必须在<html>标签之前调用,语法是setcookie (name, value, expire,
path, domain) 例如:
<?php
setcookie(”user”, “Alex
Porter”, time()+3600);
?>
<?php
setcookie(”url”, “http://www.mianwww. ......

PHP 实现多服务器共享SESSION数据

一、问题起源
稍大一些的网站,通常都会有好几个服务器,每个服务器运行着不同功能的模块,使用不同的二级域名,而一个整体性强的网站,用户系统是统一的,即一套
用户名、密码在整个网站的各个模块中都是可以登录使用的。各个服务器共享用户数据是比较容易实现的,只需要在后端放个数据库服务器,各个服务器通过统一接
......

php+AJAX传送中文会导致乱码的问题的解决方法

关于在AJAX中GET回的ResponseText中文乱码的最简解决办法
//如果传送参数是直接赋予的,就会产生乱码!
代码如下:
http_request.open("POST",url,true);
http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
http_request.send("action="+strName+"&val="+val); //如果val的 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号