php 读取远程网站内容[反盗连]
这是一款利用php fsockopen来读取远程服务器的内容哦,下面这段程序的做法就是可以反盗连呢,好了下面来看看吧。
function DownloadToString()
{
$crlf = "rn";
$response="";
// generate request
$req = 'GET ' . $this->_uri . ' HTTP/1.0' . $crlf
. 'Host: ' . $this->_host . $crlf
. $crlf;
// fetch
$this->_fp = @fsockopen(($this->_protocol == 'https' ? 'ssl://' : '') . $this->_host, $this->_port);
@fwrite($this->_fp, $req);
while(is_resource($this->_fp) && $this->_fp && !feof($this->_fp))
$response .= fread($this->_fp, 1024);
@fclose($this->_fp);
// split header and body
$pos = strpos($response, $crlf . $crlf);
if($pos === false)
return($response);
$header = substr($response, 0, $pos);
$body = substr($response, $pos + 2 * strlen($crlf));
// parse headers
$headers = array();
$lines = explode($crlf, $header);
foreach($lines as $line)
if(($pos = strpos($line, ':')) !== false)
$headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos+1));
// redirection?
if(isset($headers['location']))
{
$http = new HTTPRequest($headers['location']);
return($http->DownloadToString($http));
}
else
{
return($body);
}
}
}
下面这款个一个是判断输入的域名是不是合法的,然后再把http,https,ftp进行处理,分析再发送
function _scan_url()
{
$req = $this->_url;
$pos = strpos($req, '://');
$this->_protocol = strtolower(substr($req, 0, $pos));
$req = substr($req, $pos+3);
$pos = strpos($req, '/');
if($pos === false)
$pos = strlen($req);
$host = substr($req, 0, $pos);
if(strpos($host, ':') !== false)
{
list($this->_host, $this->_port) = explode(':', $host);
}
else
{
$this->_host = $host;
$this->_port = ($this->_protocol == 'https') ? 443 : 80;
}
$this->_uri = substr($req, $pos);
if($this->_uri == '')
$this->_uri = '/';
}
function cleanDomain($q,$w=0){ //整理域名 $w=1过滤www.前缀 $w=0不过滤
$q = htmlspecialchars(strtolower(trim($q)));
if(substr($q,0,7) == "http://" || substr($q,0,8) == "https://" || substr($q,0,6) == "ftp://"){
$q = str_replace("http:/","",$q);
$q = str_replace("https:/","",$q);
$q = str_replace("ftp:/","",$q);
}
if(substr($q,0,4) == "www." && $w==1) {
$q = str_replace("www.","",$q);
}
$q = trim($q,"/");
return $q;
}
<?php
include_once(dirname(__FILE__).'../../Inc/Conn.php');
include_once(dirname(__FILE__).'../../photo/Inc/function.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
height:17px;
padding:8px 0px 0px 0px;
text-align:center;
}
body {
margin-left: 0px;
margin-top: 10px;
margin-right: 0px;
margin-bottom: 0px;
}
td{
border:1px solid #333;
}
-->
</style></head>
<body>
<div style="height:26px;text-align:left; width:98%;font-size:16px; font-weight:bold; margin:0px auto;"><a href="export.php" target="_blank">导出Execel表格</a></div>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="8%"><strong>帐号</strong></td>
<td width="14%"><strong>邮箱</strong></td>
<td width="5%"><strong>性别</strong></td>
<td width="9%"><strong>宝宝出生日期</strong></td>
<td width="12%"><strong>省份</strong></td>
<td width="9%"><strong>真实姓名</strong></td>
<td width="12%"><strong>邮编</strong></td>
<td width="10%"><strong>手机</strong></td>
<td width="21%"><strong>地址</strong></td>
</tr>
<?php
$sql ="Select * from tablename";
$result =mysql_query($sql) or die('fail1'.mysql_error());
$rs =mysql_fetch_array($result);
$rdcount =mysql_num_rows($result);
if($rdcount){
$pagesize =20;
$pagecount=($rdcount % $pagesize)?(int)($rdcount / $pagesize)+1:$rdcount/$pagesize;//统计总页面
$page =isset($_GET['page'])?$_GET['page']:1;//取得当前页面
$start =($page>=1 && $page<=$pagecount)?$start=$pagesize*($page-1):$start=1;//取得超始记录
$start =$start;
$sql =$sql." order by add_date desc limit $start,$pagesize";
$result =mysql_query($sql) or die(mysql_error());
while($rs =mysql_fetch_array($result) ){
echo"<tr>
<td>".$rs['User_Name']."</td>
<td>".$rs['User_Mail']."</td>
<td>".$rs['User_Baby_Sex']."</td>
<td>".$rs['User_Baby_Birth']." </td>
<td>".$rs['sheng']." </td>
<td>".$rs['User_rname']." </td>
<td>".$rs['User_Zip']." </td>
<td>".$rs['User_Hand']." </td>
<td>".$rs['User_Address']." </td>
</tr>
";
}
echo "<tr> <td colspan=9>";
pagelist1($page,$pagecount,$rdcount,'?page=',$pagesize);
echo "</td> </tr> ";
}else{
echo '暂时没有信息!';
}
function pagelist1($page,$pagecount,$totalrecord,$url,$pagesize)
{
if($page=="" || $page>$pagecount)
{
$page=1;
}
echo("记录".$totalrecord."条 每页".$pagesize."条 共".$pagecount."页 <a href=".$url."1> <<</a> ");
if($page>1)
{
echo("<a href=".$url.($page-1)."> < </a> ");
}
if($page+9>$pagecount)
{
$current = $pagecount;
}
else
{
$current = $page+9;
}
for($i=$page;$i<=$current;$i++)
{
echo("<a href=".$url."$i class='sf'>$i</a> ");
}
if($pagecount>$page)
{
echo("<a href=".$url.($page+1)."> > </a> ");
}
echo("<a href=".$url.$pagecount."> >></a> ");
}
?>
</table>
</body>
</html>
<?php
include_once(dirname(__FILE__).'../../Inc/Conn.php');
include_once(dirname(__FILE__).'../../photo/Inc/function.php');
$Date = date("Y-m-d");
$Filename = $Date.'_'.date("h_i_s").".csv";
$a = "帐号,邮箱,性别,宝宝出生日期,省份,真实姓名,邮编,手机,地址 rn";
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=".$Filename);
$Sql = "Select * from oy_use";
$Result = mysql_query($Sql) or die(mysql_error());
while($rs = mysql_fetch_array($Result) ){
// if(get_days($rs['m_time'])<= $Table ){
$a.=$rs['User_Name'].','. $rs['User_Mail'].",".($rs['User_Baby_Sex']?'男':'女').",". $rs['User_Baby_Birth'].",";
$a.="".$rs['sheng'].",". $rs['User_rname'].",".$rs['User_Zip'].",".$rs['User_Hand'].",".$rs['User_Address']." rn ";
// }
}
echo $a;
function get_days($base){
$Date_1=date("Y-m-d");//格式也可以是:$Date_1="2003-6-25 23:29:14";
$Date_2=substr($base,0,10);
$Date_List_a1=explode("-",$Date_1);
$Date_List_a2=explode("-",$Date_2);
//print_r($Date_List_a2);
$d1=mktime(0,0,0,$Date_List_a1[1],$Date_List_a1[2],$Date_List_a1[0]);
$d2=mktime(0,0,0,$Date_List_a2[1],$Date_List_a2[2],$Date_List_a2[0]);
//echo round(($d1-$d2)/3600/24),'<br>';
return round(($d1-$d2)/3600/24);
}
?>
list函数的作用list() 实际上是一种语言结构,不是函数。 ... 提示和注释. 注释:该函数只用于数字索引的数组
我们来看个list实例
list($arr,$ar2) =array('aa','66');
list ($status, $host_count, $records) = db_get_records($onadb, 'hosts', $where, "", 0);
list ($status, $dns_count, $records) = db_get_records($onadb, 'dns', $where, "", 0);
list ($status, $interface_count, $records) = db_get_records($onadb, 'interfaces', $where, "", 0);
list ($status, $domain_count, $records) = db_get_records($onadb, 'domains', $where, "", 0);
list ($status, $subnet_count, $records) = db_get_records($onadb, 'subnets', $where, "", 0);
list ($status, $pool_count, $records) = db_get_records($onadb, 'dhcp_pools', $where, "", 0);
list ($status, $block_count, $records) = db_get_records($onadb, 'blocks', $where, "", 0);
list ($status, $vlan_campus_count, $records) = db_get_records($onadb, 'vlan_campuses', $where, "", 0);
list ($status, $config_archive_count, $records) = db_get_records($onadb, 'configurations', $where, "", 0);
相关文章
- 这篇文章主要介绍了C#从数据库读取图片并保存的方法,帮助大家更好的理解和使用c#,感兴趣的朋友可以了解下...2021-01-16
- 获取网站icon,常用最简单的方法就是通过website/favicon.ico来获取,不过由于很多网站都是在页面里面设置favicon,所以此方法很多情况都不可用。 更好的办法是通过google提供的服务来实现:http://www.google.com/s2/favi...2014-06-07
- 在php中解析xml文档用专门的函数domdocument来处理,把json在php中也有相关的处理函数,我们要把数据xml 数据存到一个数据再用json_encode直接换成json数据就OK了。...2016-11-25
mac下Apache + MySql + PHP搭建网站开发环境
首先为什不自己分别搭建Apache,PHP和MySql的环境呢?这样自己可以了解更多知识,说起来也更酷。可也许因为我懒吧,我是那种“既然有现成的,用就是了”的人。君子生非异也,善假于物也。两千年前的荀子就教导我们,要善于利用工具...2014-06-07- 这篇文章主要介绍了c# 如何对CSV文件操作,帮助大家更好的理解和学习C#,感兴趣的朋友可以了解下...2020-11-03
- 本文主要介绍了python读取和保存mat文件的方法,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-08-25
- 我要实现的就是下图的这种样式,可参考下面这两个网站的留言板,他们的实现原理都是一样的畅言留言板样式:网易跟帖样式:原理 需要在评论表添加两个主要字段 id 和 pid ,其他字段随意添加,比如文章id、回复时间、回复内容、...2015-11-08
- 首先如果要在程序中使用sdcard进行存储,我们必须要在AndroidManifset.xml文件进行下面的权限设置: 在AndroidManifest.xml中加入访问SDCard的权限如下: <!--...2016-09-20
网站广告怎么投放最好?首屏广告投放类型优化和广告位布局优化的案例
网站广告怎么投放最好?一个网站中广告位置最好的是哪几个地方呢,许多的朋友都不知道如何让自己的网站广告收效最好了,今天我们就一起来看看吧。 在说到联盟优化前,...2016-10-10PowerShell读取文件内容、替换文件内容、读取限定行的例子
这篇文章主要介绍了PowerShell读取文件内容、替换文件内容、读取限定行的例子,本文使用3个例子来说明实现这3个需求的操作技巧,需要的朋友可以参考下...2020-06-30- perl CPAN中有一个Tie-File 模块极大方便了对大文件的操作...2020-06-29
使用MSScriptControl 在 C# 中读取json数据的方法
下面小编就为大家带来一篇使用MSScriptControl 在 C# 中读取json数据的方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2020-06-25- 这篇文章主要介绍了C#实现appSettings节点读取与修改的方法,是非常实用的技巧,需要的朋友可以参考下...2020-06-25
- 个人网站建设应该考虑哪些问题呢?这个问题我们先在这里不说,下文会一一列出来,希望这些建义能帮助到各位同学哦。 我相信VIP成员里面有很多站长,每个人几乎都拥有一个...2016-10-10
- 本文主要介绍了jQuery中取消后续执行内容的实例,代码通俗易懂。需要的朋友来看下吧...2016-12-02
- 本文主要介绍了Java读取PDF中的表格的方法示例,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-10-22
- 这篇文章主要介绍了R语言读取csv文件出错的解决方案,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-05-06
- 下在看一个利用fopen,file_get_contents读取本地服务器中.php文件的代码并显示的一些方法总结 如我有两个文件a.php,b.php。 a.php文件中的语句是: 代码如...2016-11-25
- 分享一篇利用论坛签名提升网站权重的方法,在推广中论坛签名也是一种不错的外链推荐的方法,但现在权重越来越低了,有需要的朋友可以看看。 话说有一天在站长网上面看...2016-10-10
- 在做ajax无刷新时,我想很多朋友都会知道js innerHTML来更改 div 或table里面的值哦. JavaScript的innerHTML 永远不知道你可以改变的内容,一个HTML元素?也许你要...2016-09-20