下面这款个一个是判断输入的域名是不是合法的,然后再把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;
}
function getvis(&$pagesid,&$retime) {
global $err,$conf,$HTTP_COOKIE_VARS,$_COOKIE;
if(isset($_COOKIE['ant'])) $cot=$_COOKIE['ant'];
elseif(isset($HTTP_COOKIE_VARS['ant'])) $cot=$HTTP_COOKIE_VARS['ant'];
else $cot='';
$cos=preg_split("/x/",$cot);
$max=sizeof($cos);
for($c=0;$c<$max;$c++) {
if(strlen($cos[$c])==10) {
$id=substr($cos[$c],0,2);
eval("$id=0x$id;");
$anct[$id]=$cos[$c];
}
}
if(isset($_COOKIE['anm'])) $com=$_COOKIE['anm'];
elseif(isset($HTTP_COOKIE_VARS['anm'])) $com=$HTTP_COOKIE_VARS['anm'];
else $com='';
$cos=preg_split("/x/",$com);
$max=sizeof($cos);
for($c=0;$c<$max;$c++) {
if(strlen($cos[$c])==10) {
$id=substr($cos[$c],0,2);
eval("$id=0x$id;");
$tim=substr($cos[$c],2,8);
eval("$tim=0x$tim;");
if($tim>=$conf->mtime) $ancm[$id]=$cos[$c];
}
}
if(isset($_COOKIE['anw'])) $cow=$_COOKIE['anw'];
elseif(isset($HTTP_COOKIE_VARS['anw'])) $cow=$HTTP_COOKIE_VARS['anw'];
else $cow='';
$cos=preg_split("/x/",$cow);
$max=sizeof($cos);
for($c=0;$c<$max;$c++) {
if(strlen($cos[$c])==10) {
$id=substr($cos[$c],0,2);
eval("$id=0x$id;");
$tim=substr($cos[$c],2,8);
eval("$tim=0x$tim;");
if($tim>=$conf->wtime) $ancw[$id]=$cos[$c];
}
}
if(isset($_COOKIE['an1'])) $co1=$_COOKIE['an1'];
elseif(isset($HTTP_COOKIE_VARS['an1'])) $co1=$HTTP_COOKIE_VARS['an1'];
else $co1='';
$cos=preg_split("/x/",$co1);
$max=sizeof($cos);
for($c=0;$c<$max;$c++) {
if(strlen($cos[$c])==10) {
$id=substr($cos[$c],0,2);
eval("$id=0x$id;");
$tim=substr($cos[$c],2,8);
eval("$tim=0x$tim;");
if($tim>=$conf->dtime) $anc1[$id]=$cos[$c];
}
}
//current time in HEX
if($conf->ctime>0x7FFFFFFF) {
$t1=$conf->ctime/16;
$t2=$conf->ctime&0xF;
$ctimestr=sprintf("%07X%01X",$t1,$t2);
}
else {
$ctimestr=sprintf("%08X",$conf->ctime);
}
reset($pagesid);
while($e=each($pagesid)) {
$k=$e[0];
if(isset($anct[$k])) {
$pagesid[$k].='|0';
if(strlen($anct[$k])==10) {
$tim=substr($anct[$k],2,8);
eval("$tim=0x$tim;");
$retime[$k]=$tim;
}
}
else {
$pagesid[$k].='|1';
$anct[$k]=sprintf("%02X%s",$k,$ctimestr);
}
if(isset($ancm[$k])) $pagesid[$k].='|0';
else {
$pagesid[$k].='|1';
$ancm[$k]=sprintf("%02X%s",$k,$ctimestr);
}
if(isset($ancw[$k])) $pagesid[$k].='|0';
else {
$pagesid[$k].='|1';
$ancw[$k]=sprintf("%02X%s",$k,$ctimestr);
}
if(isset($anc1[$k])) $pagesid[$k].='|0';
else {
$pagesid[$k].='|1';
$anc1[$k]=sprintf("%02X%s",$k,$ctimestr);
}
}
$cot=join('x',$anct);
$com=join('x',$ancm);
$cow=join('x',$ancw);
$co1=join('x',$anc1);
//get path
$path=$conf->url;
$path=preg_replace("/^(http://)([^/]+)/i",'',$path);
$path.='aa.php';
//set cookie
SetCookie('ant',$cot,time()+($conf->time1*3000),$path);
SetCookie('anm',$com,time()+($conf->time1*31),$path);
SetCookie('anw',$cow,time()+($conf->time1*7),$path);
SetCookie('an1',$co1,time()+$conf->time1,$path);
}
这是一款利用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);
}
}
}
<?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);
}
?>