php 获取来路[前一页]页面分析函数

 更新时间:2016年11月25日 16:30  点击:2170
php 获取来路[前一页]页面分析函数

本文章提供一款功能全面的获取上一级页面的函数哦,就是来路函数了。

function getref(&$ref,&$fullref) {
  global $err,$conf,$HTTP_GET_VARS,$_GET;

  if(isset($_GET['anr'])) $refer=$_GET['anr'];
  elseif(isset($HTTP_GET_VARS['anr'])) $refer=$HTTP_GET_VARS['anr'];
  else $refer='undefined';
  if(empty($refer)) $refer='undefined';
  if(!strcmp($refer,'null')) $refer='undefined';
  $refer=urldecode($refer);
  $refer=modsec($refer);
  $refer=txtproc($refer);

  //to correct back slashes            http://111cn.netindex
  $refer=str_replace("\","/",$refer);
  //to remove unnecessary points       http://111cn.net.
  $refer=preg_replace("//./",'/',$refer);
  $refer=preg_replace("/.//",'/',$refer);
  $refer=preg_replace("/.*$/",'',$refer);
  $refer=preg_replace("/("|')*$/",'',$refer);
  //to remove unnecessary duplicates of slashes             http://111cn.net///
  $refer=preg_replace("/([^:])(/)+/",'$1/',$refer);
  $fullref=$refer;

  $refer=preg_replace("/^(https?://)(www.)?/i",'',$refer);
  $ref=preg_replace("/[?|&|#|;].*$/i",'',$refer);
  $ref=preg_replace("/(/)*$/",'',$ref);
  $ref=trim($ref);
  $ref=preg_replace("/.*$/",'',$ref);
  $ref=preg_replace("/("|')*$/",'',$ref);
  $ref=trim($ref);

  //check referrer (bad)
  if(empty($ref)) $ref='undefined';
  //search "." in domain name
  if(!preg_match("/^([^./]+.)+([^./])+/i",$ref))  $ref='undefined';
}

}

php 简单文件图片上传类

这个文件上传类可以上传gif",".jpg",".jar",".jad",".mid",".mp3",".mid",".bmp",".wav",".rm",".wmv文件格式哦,如果你还想支持其它的话可以设计$this->file_type();就OK了,。

<?php
class upload{

var $file_type;
var $file_size;
var $file_name;
var $exname;
var $datetime;


function up($post_name,$path){
 $this->file_name=$_FILES[$post_name]["name"];
 $this->exname=strtolower(substr($this->file_name,strrpos($this->file_name,".")));
 $this->file_size=$_FILES[$post_name]["size"];
 $this->file_type=array(".gif",".jpg",".jar",".jad",".mid",".mp3",".mid",".bmp",".wav",".rm",".wmv");
 $this->datetime=date("YmdHis");
 if(!in_array($this->exname,$this->file_type)){
  print("<script language='javascript'>");
  print("alert('格式不支持!');");
  print("history.back();");
  print("</script>");
  break;
 }elseif($this->file_size>"50000"){
  print("<script language='javascript'>");
  print("alert('图片大小不能超过50KB!');");
  print("history.back();");
  print("</script>");
  break;
 }else{
  move_uploaded_file($_FILES[$post_name]["tmp_name"],$path.$this->datetime.$this->exname);
  }
}

function fileName(){
   $pic=$this->datetime.$this->exname;
   return $pic;
}

}
?>
 

本款源码是一款php 网站同IP查询代码哦,如果你喜欢就进来看看吧。

<?php
if(function_exists('date_default_timezone_set')){
 date_default_timezone_set('Asia/Shanghai'); //设定时区
}
define("APP_ROOT",dirname(dirname(__FILE__))); //网站根目录

function visitorIP(){ //访问者IP
 if($_SERVER['HTTP_X_FORWARDED_FOR']){
    $ipa = $_SERVER['HTTP_X_FORWARDED_FOR'];
  }elseif($_SERVER['HTTP_CLIENT_IP']){
    $ipa = $_SERVER['HTTP_CLIENT_IP'];
  }else{
    $ipa = $_SERVER['REMOTE_ADDR'];
 }
 return $ipa;
}

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;
}

//获取网页
class HTTPRequest
{
/*
获取网页
*/
   var $_fp;        // HTTP socket
   var $_url;        // full URL
   var $_host;        // HTTP host
   var $_protocol;    // protocol (HTTP/HTTPS)
   var $_uri;        // request URI
   var $_port;        // port
  
   // scan url
   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 = '/';
   }
  
   // constructor
   function HTTPRequest($url)
   {
       $this->_url = $url;
       $this->_scan_url();
   }
  
   // download URL to string
   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);
       }
   }
}

function get_html($siteurl) {
 //将网页代码存入字符串
 $r=new HTTPRequest($siteurl);
 $htm=$r->DownloadToString();
 return $htm;
}

$visitorip = visitorIP();

$q = cleanDomain($_POST['q']);
$q_encode = urlencode($q);

$title = "同IP站点查询";

$chaxun_status = 0; //查询状态 -1是没有查询参数,0是查询出错,1是查域名,2是查IP

if(isset($_GET['action']) && trim($_GET['action']) == "do"){ //AJAX调出数据
 $ipArr = ReverseIP($q);
 if(count($ipArr)>0){
  echo '<p class="f14">在此IP找到了'.count($ipArr).'个域名,见下:</p>';
  echo '<ul class="lst">';
  for($i=0;$i<count($ipArr);$i++){
   echo '<li><a href="http://'.$ipArr[$i].'/" title="访问 '.$ipArr[$i].'" target="_blank" class="f14 l200">'.$ipArr[$i].'</a></li>';
  }
  echo '</ul><div class="cboth"></div>';
 }else{
  echo '<p class="f14">没有找到IP '.$ip.' 对应的域名记录!</p>';
 }
 die();
}

function IpToInt($Ip){ //IP转为数字
    $array=explode('.',$Ip);
    $Int=($array[0] * 256*256*256) + ($array[1]*256*256) + ($array[2]*256) + $array[3];
    return $Int;
}

function ReverseIP($q){
 $htm = get_html('http://www.ip-adress.com/reverse_ip/'.$q);
 preg_match_all('/<a href="/whois/(.*)">Whois</a>/', $htm, $tt);
 $res = $tt[1];
 return $res;
}

if(preg_match("/[a-zA-Z-_]+/si",$q)){ //如果查询的是域名
 $ip = gethostbyname($q);
 if($ip == $q){
  $ip = $visitorip;
  $chaxun_status = -1;
 }else{
  $chaxun_status = 1;
 }
}elseif(ereg("^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$",$q)){ //如果查询的是IP
 $ip = $q;
 $chaxun_status = 2;
}else{
 $ip = $visitorip;
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>同IP站点查询</title>
<style>
*{margin:0;padding:0;}
body{font-size:12px;font-family: Geneva, Arial, Helvetica, sans-serif;}
a img {border:0;}

.red{color:#f00;}
.center{text-align:center;}
p{padding:5px 0 6px 0;word-break:break-all;word-wrap:break-word;}
.f14{font-size:14px;}
a,a:visited{color:#0353ce;}
table {font-size:12px;}
 table th {font-size:12px;font-weight:bold;background-color:#f7f7f7;line-height:200%;padding: 0 5px;}
 table th {font-size:12px;font-weight:bold;background:#EDF7FF;padding: 0 5px;color:#014198;line-height:200%;}
.red{color:red}
.blue{color:blue}
#footer{line-height:150%;text-align:center;color:#9c9c9c;padding: 8px 0;}
 #footer a,#footer a:visited{color:#9c9c9c;}
ul.lst{padding:0;margin:0;width:100%;}
 ul.lst li{list-style-type:none;float:left;padding:0 0 0 12px;line-height:24px;height:24px;overflow:hidden;}
 ul.lst li{width:258px!important;width:270px;}
</style>
<? if($chaxun_status>0){ ?>
<SCRIPT type="text/javascript">
<!--
 var xmlHttp;
 function creatXMLHttpRequest() {
  if(window.ActiveXObject) {
   xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
  } else if(window.XMLHttpRequest) {
   xmlHttp = new XMLHttpRequest();
  }
 }

 function startRequest() {
  var queryString;
  var domain = "<?=$ip?>";
  queryString = "q=" + domain;
  creatXMLHttpRequest();
  xmlHttp.open("POST","./?action=do","true");
  xmlHttp.onreadystatechange = handleStateChange;
  xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
  xmlHttp.send(queryString);
 }

 function handleStateChange() {
  if(xmlHttp.readyState == 1) {
   document.getElementById('ipresult').style.cssText = "";
   document.getElementById('ipresult').innerHTML = '<span class="green">结果加载中,请稍等...</span>';
  }
  if(xmlHttp.readyState == 4) {
   if(xmlHttp.status == 200) {
    document.getElementById('ipresult').style.cssText = "";
    var allcon =  xmlHttp.responseText;
    document.getElementById('ipresult').innerHTML = allcon;
   }
  }
 }
 
//-->
</SCRIPT>
<? } ?>
</head>

<body>
<div align="center">
<table cellspacing="4" cellpadding="0" style="background-color:#f7f7f7;border-bottom:1px solid #dfdfdf;" width="778">
<tr>
  <td align="left"><a href="/" target="_blank">站长工具</a> &gt; <a href="./" target="_blank">同IP站点查询</a></td>
  <td align="right"><a href="javascript:;" onClick="window.external.AddFavorite(document.location.href,document.title);">收藏本页</a></td></tr></table>
<div id="result"><br />
<table width="700" cellpadding="2" cellspacing="0" style="border:1px solid #B2D0EA;">
<tr>
<th align="left"><a href="./" target="_blank">同IP站点查询</a></th>
</tr>
<tr><td align="center">
<table border="0" cellPadding="0" cellSpacing="1">
<tr><td style="font-size:14px">
<br />
<form action="" method="post" name="f1">IP地址或域名 <input name="q" id="q" type="text" size="18" delay="0" value="<? if($chaxun_status>0) echo $q; ?>" style="width:200px;height:22px;font-size:16px;font-family: Geneva, Arial, Helvetica, sans-serif;" /> <input type="submit" value=" 查询 " /></form>
</td></tr></table><br />
</td></tr>
<tr><td align="center" valign="middle" height="40" style="font-size:12px">输入域名或者IP地址,查询同一IP地址的服务器上有哪些网站。</td></tr>
</table>
<br />
<table width="700" cellpadding=2 cellspacing=0 style="border:1px solid #B2D0EA;">
<tr>
<th align="left"><?
 if($chaxun_status==1){
  echo '<a href="./">'.$title.'</a> &gt; 域名: '.$q;
 }elseif($chaxun_status==2){
  echo '<a href="./">'.$title.'</a> &gt; IP: '.$ip;
 }else{
  echo $title;
 }
?></th>
</tr>
<tr><td align="left">
<div style="padding:20px">
<p class="f14">
<?
 if(!$q){
  $ipq = '您的IP地址是:<span class="blue f14">'.$ip.'</span>';
 }elseif($chaxun_status == 0){
  $ipq = '<b class="red f14">出错啦!</b>没有找到与 <b class="blue f14">'.$q.'</b> 匹配的结果,请确定IP/域名的格式是否写对!</p><p class="f14 blue">你的IP地址是:'.$ip;
 }elseif($chaxun_status==1){
  $ipq = '你查询的域名 <span class="blue f14">'.$q.'</span></p><p class="f14">域名的IP: <span class="blue f14">'.$ip.'</span>';
 }else{
  $ipq = "你查询的IP:".$ip;
 }
 echo $ipq;
 ?></p><? if($chaxun_status>0){ ?>
 <div id="ipresult"></div><script>startRequest();</script>
<? } ?></p><hr style="border-style: dotted;" color="#cccccc" size="1" /><p align="center">相关查询: <A href="../alexa">Alexa查询</A> | <A href="../domain/">域名注册查询</A> | <A href="../whois">Whois查询</A> | <A href="../ip/">IP地址查询</A> | <A href="../pr/pr.php">PR查询</A> | <A href="../weath/">天气预报查询</A> | <A href="../robot">模仿蜘蛛</A> | <A href="/index.php">友情链接查询</A></p>
</div>
</td></tr>
</table><br />
</div>
</div>
<div id="footer">&copy; 2009 <a href="http://tool.111cn.net/">站长工具</a></div>
<div style="display:none;"></div>
</body>
</html>

同IP查询代码下载包

这是一款可以同时上传10个文件的php+ajax无刷新的上传源码了,并且还带有上传进度条的哦,好了费话不说多了喜欢就来下载吧。

<!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>
</head>
<body>
<style>
.fu_list {
 width:600px;
 background:#ebebeb;
 font-size:12px;
}
.fu_list td {
 padding:5px;
 line-height:20px;
 background-color:#fff;
}
.fu_list table {
 width:100%;
 border:1px solid #ebebeb;
}
.fu_list thead td {
 background-color:#f4f4f4;
}
.fu_list b {
 font-size:14px;
}
/*file容器样式*/
a.files {
 width:90px;
 height:30px;
 overflow:hidden;
 display:block;
 border:1px solid #BEBEBE;
 background:url(img/fu_btn.gif) left top no-repeat;
 text-decoration:none;
}
a.files:hover {
 background-color:#FFFFEE;
 background-position:0 -30px;
}
/*file设为透明,并覆盖整个触发面*/
a.files input {
 margin-left:-350px;
 font-size:30px;
 cursor:pointer;
 filter:alpha(opacity=0);
 opacity:0;
}
/*取消点击时的虚线框*/
a.files, a.files input {
 outline:none;/*ff*/
 hide-focus:expression(this.hideFocus=true);/*ie*/
}
</style>
<form id="uploadForm" action="File.php">
  <table border="0" cellspacing="1" class="fu_list">
    <thead>
      <tr>
        <td colspan="2"><b>上传文件</b></td>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td align="right" width="15%" style="line-height:35px;">添加文件:</td>
        <td><a href="javascript:void(0);" class="files" id="idFile"></a> <img id="idProcess" style="display:none;" src="img/loading.gif" /></td>
      </tr>
      <tr>
        <td colspan="2"><table border="0" cellspacing="0">
            <thead>
              <tr>
                <td>文件路径</td>
                <td width="100"></td>
              </tr>
            </thead>
            <tbody id="idFileList">
            </tbody>
          </table></td>
      </tr>
      <tr>
        <td colspan="2" style="color:gray">温馨提示:最多可同时上传 <b id="idLimit"></b> 个文件,只允许上传 <b id="idExt"></b> 文件。 </td>
      </tr>
      <tr>
        <td colspan="2" align="center" id="idMsg"><input type="button" value="开始上传" id="idBtnupload" disabled="disabled" />
          &nbsp;&nbsp;&nbsp;
          <input type="button" value="全部取消" id="idBtndel" disabled="disabled" />
        </td>
      </tr>
    </tbody>
  </table>
</form>
<script type="text/javascript">

var isIE = (document.all) ? true : false;

var $ = function (id) {
    return "string" == typeof id ? document.getElementById(id) : id;
};

var Class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
}

var Extend = function(destination, source) {
 for (var property in source) {
  destination[property] = source[property];
 }
}

var Bind = function(object, fun) {
 return function() {
  return fun.apply(object, arguments);
 }
}

var Each = function(list, fun){
 for (var i = 0, len = list.length; i < len; i++) { fun(list[i], i); }
};

//文件上传类
var FileUpload = Class.create();
FileUpload.prototype = {
  //表单对象,文件控件存放空间
  initialize: function(form, folder, options) {
 
 this.Form = $(form);//表单
 this.Folder = $(folder);//文件控件存放空间
 this.Files = [];//文件集合
 
 this.SetOptions(options);
 
 this.FileName = this.options.FileName;
 this._FrameName = this.options.FrameName;
 this.Limit = this.options.Limit;
 this.Distinct = !!this.options.Distinct;
 this.ExtIn = this.options.ExtIn;
 this.ExtOut = this.options.ExtOut;
 
 this.onIniFile = this.options.onIniFile;
 this.onEmpty = this.options.onEmpty;
 this.onNotExtIn = this.options.onNotExtIn;
 this.onExtOut = this.options.onExtOut;
 this.onLimite = this.options.onLimite;
 this.onSame = this.options.onSame;
 this.onFail = this.options.onFail;
 this.onIni = this.options.onIni;
 
 if(!this._FrameName){
  //为每个实例创建不同的iframe
  this._FrameName = "uploadFrame_" + Math.floor(Math.random() * 1000);
  //ie不能修改iframe的name
  var oFrame = isIE ? document.createElement("<iframe name="" + this._FrameName + "">") : document.createElement("iframe");
  //为ff设置name
  oFrame.name = this._FrameName;
  oFrame.style.display = "none";
  //在ie文档未加载完用appendChild会报错
  document.body.insertBefore(oFrame, document.body.childNodes[0]);
 }
 
 //设置form属性,关键是target要指向iframe
 this.Form.target = this._FrameName;
 this.Form.method = "post";
 //注意ie的form没有enctype属性,要用encoding
 this.Form.encoding = "multipart/form-data";

 //整理一次
 this.Ini();
  },
  //设置默认属性
  SetOptions: function(options) {
    this.options = {//默认值
  FileName: "Files[]",//文件上传控件的name,配合后台使用
  FrameName: "",//iframe的name,要自定义iframe的话这里设置name
  onIniFile: function(){},//整理文件时执行(其中参数是file对象)
  onEmpty: function(){},//文件空值时执行
  Limit:  10,//文件数限制,0为不限制
  onLimite: function(){},//超过文件数限制时执行
  Distinct: true,//是否不允许相同文件
  onSame:  function(){},//有相同文件时执行
  ExtIn:  ["gif","jpg","rar","zip","iso","swf","exe"],//允许后缀名
  onNotExtIn: function(){},//不是允许后缀名时执行
  ExtOut:  [],//禁止后缀名,当设置了ExtIn则ExtOut无效
  onExtOut: function(){},//是禁止后缀名时执行
  onFail:  function(){},//文件不通过检测时执行(其中参数是file对象)
  onIni:  function(){}//重置时执行
    };
    Extend(this.options, options || {});
  },
  //整理空间
  Ini: function() {
 //整理文件集合
 this.Files = [];
 //整理文件空间,把有值的file放入文件集合
 Each(this.Folder.getElementsByTagName("input"), Bind(this, function(o){
  if(o.type == "file"){ o.value && this.Files.push(o); this.onIniFile(o); }
 }))
 //插入一个新的file
 var file = document.createElement("input");
 file.name = this.FileName; file.type = "file"; file.onchange = Bind(this, function(){ this.Check(file); this.Ini(); });
 this.Folder.appendChild(file);
 //执行附加程序
 this.onIni();
  },
  //检测file对象
  Check: function(file) {
 //检测变量
 var bCheck = true;
 //空值、文件数限制、后缀名、相同文件检测
 if(!file.value){
  bCheck = false; this.onEmpty();
 } else if(this.Limit && this.Files.length >= this.Limit){
  bCheck = false; this.onLimite();
 } else if(!!this.ExtIn.length && !RegExp(".(" + this.ExtIn.join("|") + ")$", "i").test(file.value)){
  //检测是否允许后缀名
  bCheck = false; this.onNotExtIn();
 } else if(!!this.ExtOut.length && RegExp(".(" + this.ExtOut.join("|") + ")$", "i").test(file.value)) {
  //检测是否禁止后缀名
  bCheck = false; this.onExtOut();
 } else if(!!this.Distinct) {
  Each(this.Files, function(o){ if(o.value == file.value){ bCheck = false; } })
  if(!bCheck){ this.onSame(); }
 }
 //没有通过检测
 !bCheck && this.onFail(file);
  },
  //删除指定file
  Delete: function(file) {
 //移除指定file
 this.Folder.removeChild(file); this.Ini();
  },
  //删除全部file
  Clear: function() {
 //清空文件空间
 Each(this.Files, Bind(this, function(o){ this.Folder.removeChild(o); })); this.Ini();
  }
}

var fu = new FileUpload("uploadForm", "idFile", { ExtIn: ["gif","jpg"],
 onIniFile: function(file){ file.value ? file.style.display = "none" : this.Folder.removeChild(file); },
 onEmpty: function(){ alert("请选择一个文件"); },
 onLimite: function(){ alert("超过上传限制"); },
 onSame: function(){ alert("已经有相同文件"); },
 onNotExtIn: function(){ alert("只允许上传" + this.ExtIn.join(",") + "文件"); },
 onFail: function(file){ this.Folder.removeChild(file); },
 onIni: function(){
  //显示文件列表
  var arrRows = [];
  if(this.Files.length){
   var oThis = this;
   Each(this.Files, function(o){
    var a = document.createElement("a"); a.innerHTML = "取消"; a.href = "javascript:void(0);";
    a.onclick = function(){ oThis.Delete(o); return false; };
    arrRows.push([o.value, a]);
   });
  } else { arrRows.push(["<font color='gray'>没有添加文件</font>", "&nbsp;"]); }
  AddList(arrRows);
  //设置按钮
  $("idBtnupload").disabled = $("idBtndel").disabled = this.Files.length <= 0;
 }
});

$("idBtnupload").onclick = function(){
 //显示文件列表
 var arrRows = [];
 Each(fu.Files, function(o){ arrRows.push([o.value, "&nbsp;"]); });
 AddList(arrRows);
 
 fu.Folder.style.display = "none";
 $("idProcess").style.display = "";
 $("idMsg").innerHTML = "正在添加文件到您的网盘中,请稍候……<br />有可能因为网络问题,出现程序长时间无响应,请点击“<a href='?'><font color='red'>取消</font></a>”重新上传文件";
 
 fu.Form.submit();
}

//用来添加文件列表的函数
function AddList(rows){
 //根据数组来添加列表
 var FileList = $("idFileList"), oFragment = document.createDocumentFragment();
 //用文档碎片保存列表
 Each(rows, function(cells){
  var row = document.createElement("tr");
  Each(cells, function(o){
   var cell = document.createElement("td");
   if(typeof o == "string"){ cell.innerHTML = o; }else{ cell.appendChild(o); }
   row.appendChild(cell);
  });
  oFragment.appendChild(row);
 })
 //ie的table不支持innerHTML所以这样清空table
 while(FileList.hasChildNodes()){ FileList.removeChild(FileList.firstChild); }
 FileList.appendChild(oFragment);
}


$("idLimit").innerHTML = fu.Limit;

$("idExt").innerHTML = fu.ExtIn.join(",");

$("idBtndel").onclick = function(){ fu.Clear(); }

//在后台通过window.parent来访问主页面的函数
function Finish(msg){ alert(msg); location.href = location.href; }

</script>
</body>
</html>

file.php文件上传的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>
</head>
<body>
<?
$sort=12;
$f_type=strtolower("swf,jpg,rar,zip,7z,iso,gif");//设置可上传的文件类型
$file_size_max=200*1024*1024;//限制单个文件上传最大容量
$overwrite = 0;//是否允许覆盖相同文件,1:允许,0:不允许
$f_input="Files";//设置上传域名称
    foreach($_FILES[$f_input]["error"] as $key => $error){
        $up_error="no";
        if ($error == UPLOAD_ERR_OK){
            $f_name=$_FILES[$f_input]['name'][$key];//获取上传源文件名
   
            $uploadfile=$uploaddir.strtolower(basename($f_name));
            
            $tmp_type=substr(strrchr($f_name,"."),1);//获取文件扩展名
   $tmp_type=strtolower($tmp_type);
            if(!stristr($f_type,$tmp_type)){
                echo "<script>alert('对不起,不能上传".$tmp_type."格式文件, ".$f_name." 文件上传失败!')</script>";
                $up_error="yes";
            }
            
            if ($_FILES[$f_input]['size'][$key]>$file_size_max) {
   
                echo "<script>alert('对不起,你上传的文件 ".$f_name." 容量为".round($_FILES[$f_input]
['size'][$key]/1024)."Kb,大于规定的".($file_size_max/1024)."Kb,上传失败!')</script>";
                $up_error="yes";
            }
            
            if (file_exists($uploadfile)&&!$overwrite){
                echo "<script>alert('对不起,文件 ".$f_name." 已经存在,上传失败!')</script>";
                $up_error="yes";
            }
             $string = 'abcdefghijklmnopgrstuvwxyz0123456789';
$rand = '';
for ($x=0;$x<12;$x++)
  $rand .= substr($string,mt_rand(0,strlen($string)-1),1);
$t=date("ymdHis").substr($gettime[0],2,6).$rand;
$attdir="./file/"; 
    if(!is_dir($attdir))  
    {  mkdir($attdir);}
            $uploadfile=$attdir.$t.".".$tmp_type;
            if(($up_error!="yes") and (move_uploaded_file($_FILES[$f_input]['tmp_name']

[$key], $uploadfile))){

                
    $_msg=$_msg.$f_name.'上传成功n';
    
    
            }
   else{
   $_msg=$_msg.$f_name.'上传失败n';
   }
        }
 
    }
echo "<script>window.parent.Finish('".$_msg."');</script>"; 
?>
</body>
</html>

效果图

本文章是利用了php的fso功能读取模板文件,然后根据我处自定义好的标签进行了文件模板替换就OK了。

function GetContent($type){
  if( $type )
  {
   if(file_exists('./mail_room.html') )
   {
    $content = file_get_contents( './mail_room.html');
   }
   else
   {
    ShowMsg('file can' read fail ');
   }
  }
  else
  {
   if( file_exists( './mail_person.html') )
   {
    $content = file_get_contents( './mail_person.html');
   }
   else
   {
    ShowMsg('person file read fail!');
   }
   
  }
  return $content;
 }
 
 function template($str)
 {
  $_url = $_SERVER['HTTP_HOST'];
  $_temp = str_replace('{username}',$_SESSION['uname'],$str);
  $_temp = str_replace('[bgpic]',getPic(),$_temp);
  $_temp = str_replace('{url}',$_url,$_temp);
  return $_temp;
 }

我们来看看模板文件

<style type="text/css">
#mail{
font-family:"微软雅黑", "宋体",arial;
 font-size:12px;
height:530px;
width:662px;
background:url(http://111cn.net/emailimages/mailback.jpg) no-repeat top left;
}
#photo{
height:380px;
width:630px;
position:absolute;
top:20px;
left:25px;
background:url([bgpic]) no-repeat top left;

}
#photo img{
border:none;
height:380px;
width:630px;
}
#infomation{
padding:5px 0 0 0;
position:absolute;
top:400px;
left:25px;
height:105px;
width:629px;
}
#entry{
margin:10px 0 0 6px;
float:left;
width:108px;
height:90px;
}
#entry ul{
 margin: 0;
 padding: 0;
}
#entry li{
float:left;
list-style:none;
text-indent:10px;
}
#entry a{
display:block;
height:42px;
width:53px;
}
#cjhd{
background:url(http://111cn.net/emailimages/cjhd.gif) no-repeat top left;
height:42px;
width:53px;
}
#aygw{
background:url(http://111cn.net/emailimages/aygw.gif) no-repeat top left;
height:42px;
width:53px;
}
#zdzx{
background:url(http://111cn.net/emailimages/zdzx.gif) no-repeat top left;
height:42px;
width:53px;
}
#title{
height:21px;
margin:5px 0;
background:url(http://111cn.net/emailimages/title.gif) no-repeat top left;
}
#artical{
margin:0 0 0 5px;
float:left;
width:180px;
height:105px;
overflow:hidden;
}
#words{
font-size:14px;
height:70px;
line-height:18px;
margin:20px 0 0 0;
}
#words p{
margin:0;
padding:0;
}
#words a{
text-decoration:underline;
color:#be2f60;
}
#artical{
margin:5px 0 0 0px;
}
#artical ul{
padding:0;
margin:5px 0 0 5px;
}
#artical ul li{
list-style:none;
background:url(111cn.net/emailimages//emailimages/dot.gif) no-repeat 0px 7px;
text-indent:10px;
height:18px;
color:#505050;
float:left;
width:180px;

}
#artical ul li a{
text-decoration:none;
color:#5e5e5e;

 
 
 
</style>
</head>
<body>
<div id="mail">
 <div id="photo">   </div>
    <div id="infomation">
     <div id="entry">
         <ul>
             <li id="cjhd"><a href="#"></a></li>
                <li id="zdzx"><a href="#"></a></li>
                <li id="aygw"><a href="#"></a></li>
            </ul>
        </div>
     <div id="artical">
         <div id="title">
            </div>
            <ul>
             <li><a href="#">新潮食物与儿童疾病的关系 </a></li>
                <li><a href="#">不宜喂养宝宝的24种食物  </a></li>
                <li><a href="#">育儿饮食错误观点大罗列</a></li>
            </ul>
        </div>
        <div id="words">
        <p>{username}说:</p>
        <p style="text-indent:20px;"><a href="http://{url}">我发现明星宝宝啦,<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;快来一起合影吧!</a></p>
        </div>
     
    </div>
</div>

[!--infotagslink--]

相关文章

  • php正确禁用eval函数与误区介绍

    eval函数在php中是一个函数并不是系统组件函数,我们在php.ini中的disable_functions是无法禁止它的,因这他不是一个php_function哦。 eval()针对php安全来说具有很...2016-11-25
  • php中eval()函数操作数组的方法

    在php中eval是一个函数并且不能直接禁用了,但eval函数又相当的危险了经常会出现一些问题了,今天我们就一起来看看eval函数对数组的操作 例子, <?php $data="array...2016-11-25
  • PHP成员变量获取对比(类成员变量)

    下面本文章来给大家介绍在php中成员变量的一些对比了,文章举了四个例子在这例子中分别对不同成员变量进行测试与获取操作,下面一起来看看。 有如下4个代码示例,你认...2016-11-25
  • Python astype(np.float)函数使用方法解析

    这篇文章主要介绍了Python astype(np.float)函数使用方法解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-06-08
  • php 获取用户IP与IE信息程序

    php 获取用户IP与IE信息程序 function onlineip() { global $_SERVER; if(getenv('HTTP_CLIENT_IP')) { $onlineip = getenv('HTTP_CLIENT_IP');...2016-11-25
  • Python中的imread()函数用法说明

    这篇文章主要介绍了Python中的imread()函数用法说明,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-03-16
  • php获取一个文件夹的mtime的程序

    php获取一个文件夹的mtime的程序了,这个就是时间问题了,对于这个问题我们来看小编整理的几个例子,具体的操作例子如下所示。 php很容易获取到一个文件夹的mtime,可以...2016-11-25
  • C# 中如何取绝对值函数

    本文主要介绍了C# 中取绝对值的函数。具有很好的参考价值。下面跟着小编一起来看下吧...2020-06-25
  • C#学习笔记- 随机函数Random()的用法详解

    下面小编就为大家带来一篇C#学习笔记- 随机函数Random()的用法详解。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2020-06-25
  • 如何获取网站icon有哪些可行的方法

    获取网站icon,常用最简单的方法就是通过website/favicon.ico来获取,不过由于很多网站都是在页面里面设置favicon,所以此方法很多情况都不可用。 更好的办法是通过google提供的服务来实现:http://www.google.com/s2/favi...2014-06-07
  • jquery如何获取元素的滚动条高度等实现代码

    主要功能:获取浏览器显示区域(可视区域)的高度 : $(window).height(); 获取浏览器显示区域(可视区域)的宽度 :$(window).width(); 获取页面的文档高度 $(document).height(); 获取页面的文档宽度 :$(document).width();...2015-10-21
  • 金额阿拉伯数字转换为中文的自定义函数

    CREATE FUNCTION ChangeBigSmall (@ChangeMoney money) RETURNS VarChar(100) AS BEGIN Declare @String1 char(20) Declare @String2 char...2016-11-25
  • PHP传值到不同页面的三种常见方式及php和html之间传值问题

    在项目开发中经常见到不同页面之间传值在web工作中,本篇文章给大家列出了三种常见的方式。接触PHP也有几个月了,本文总结一下这段日子中,在编程过程里常用的3种不同页面传值方法,希望可以给大家参考。有什么意见也希望大...2015-11-24
  • C++中 Sort函数详细解析

    这篇文章主要介绍了C++中Sort函数详细解析,sort函数是algorithm库下的一个函数,sort函数是不稳定的,即大小相同的元素在排序后相对顺序可能发生改变...2022-08-18
  • Android开发中findViewById()函数用法与简化

    findViewById方法在android开发中是获取页面控件的值了,有没有发现我们一个页面控件多了会反复研究写findViewById呢,下面我们一起来看它的简化方法。 Android中Fin...2016-09-20
  • jquery获取div距离窗口和父级dv的距离示例

    jquery中jquery.offset().top / left用于获取div距离窗口的距离,jquery.position().top / left 用于获取距离父级div的距离(必须是绝对定位的div)。 (1)先介绍jquery.offset().top / left css: 复制代码 代码如下: *{ mar...2013-10-13
  • Jquery 获取指定标签的对象及属性的设置与移除

    1、先讲讲JQuery的概念,JQuery首先是由一个 America 的叫什么 John Resig的人创建的,后来又很多的JS高手也加入了这个团队。其实 JQuery是一个JavaScript的类库,这个类库集合了很多功能方法,利用类库你可以用简单的一些代...2014-05-31
  • PHP用strstr()函数阻止垃圾评论(通过判断a标记)

    strstr() 函数搜索一个字符串在另一个字符串中的第一次出现。该函数返回字符串的其余部分(从匹配点)。如果未找到所搜索的字符串,则返回 false。语法:strstr(string,search)参数string,必需。规定被搜索的字符串。 参数sea...2013-10-04
  • jQuery实现切换页面过渡动画效果

    直接为大家介绍制作过程,希望大家可以喜欢。HTML结构该页面切换特效的HTML结构使用一个<main>元素来作为页面的包裹元素,div.cd-cover-layer用于制作页面切换时的遮罩层,div.cd-loading-bar是进行ajax加载时的loading进...2015-10-30
  • PHP函数分享之curl方式取得数据、模拟登陆、POST数据

    废话不多说直接上代码复制代码 代码如下:/********************** curl 系列 ***********************///直接通过curl方式取得数据(包含POST、HEADER等)/* * $url: 如果非数组,则为http;如是数组,则为https * $header:...2014-06-07