首页 > 编程技术 > php

dedecms ajax 下载统计代码

发布时间:2016-11-25 16:02

dedecms ajax 下载统计代码

<?php
require_once (dirname(__FILE__) . "/include/common.inc.php");
require_once(DEDEINC."/channelunit.class.php");

 $aid = (isset($aid) && is_numeric($aid)) ? $aid : 0;
 
  $rand =mt_rand(10,80);
  
  $query = "select count(*) as dd from #@__downloads where id='$aid'";
  
  $row = $dsql->GetOne($query); 
 
  if($row['dd'] > 0)
  {
   $query = "update #@__downloads set downloads=downloads+$rand where id='$aid'";
   $dsql->ExecNoneQuery($query);
  }else {
   $query = "insert into #@__downloads(hash,id,downloads) values('null$aid','$aid',1)";
   $dsql->ExecNoneQuery($query);
  }
  

下面是实例方法。

<!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" />
<script" width=100% src="http://pstatic.xunlei.com/js/webThunderDetect.js"></script>
<script" width=100% src="http://pstatic.xunlei.com/js/base64.js"></script>
<script language="javascript"  type="text/javascript">
var xmlHttp = false;

function ajaxcreate(){

try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
try {
  xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
 } catch (e2) {
  xmlHttp = false;
 }
 }

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
 }
if(!xmlHttp){alert('Create Xmlhttp Fail ');return false;}
}


function ajax_add(){ 
 ajaxcreate();
 var url="/ajax_down.php?aid="+encodeURI(5396)+"&rd="+Math.random();
 xmlHttp.open("POST",url,true);
 xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
 xmlHttp.send(null); 
}

</script>
<title>绿色版Apache+Php+Mysql V1.3 自动安装版_下载地址列表_网站源码下载-整站源码下载-站长常用工具下载</title>
<link href="/templets/style/search.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>

<div class="header">
 <div class="toplogo">
  <h1><a href="http://down.111cn.net/">网站源码下载-整站源码下载-站长常用工具下载</a></h1>
 </div>
</div>

<div class="msgbar">
 <p>
  <strong>软件名称:<a href='/down/soft/server/2009/0629/5396.html'>绿色版Apache+Php+Mysql V1.3 自动安装版</a></strong>
 </p>
</div>
<div class="advancedsearch">
  <table width="100%" border="0" align="center" cellspacing="2">
    <tr>
      <td height="30" bgcolor="#F2F7E6">下载地址列表:</td>
    </tr>
    <tr>
      <td height="78"><script language="javascript"" width=100% src="/js/gg_bottom.js"></script>
<a href="#" class="red" thunderHref="thunder://QUFodHRwOi8vemp0ZWxlNC5za3ljbi5jb20vZG93bi9nZ2dBUE1zZXJ2ZXIuemlwWlo=" thunderPid="85957" thunderType="" thunderResTitle="" onClick="ajax_add();return OnDownloadClick_Simple(this,2);" oncontextmenu="ThunderNetwork_SetHref(this)" >[迅雷专用下载]</a>

<script type="text/javascript"><!--
google_ad_client = "pub-6219414158063594";
/* 336x280, 创建于 09-3-29 */
google_ad_slot = "8019903307";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

<script type="text/javascript"><!--
  google_ad_client = "pub-6219414158063594";
  google_ad_format = "configurable_sdo";
  google_link_target = 2;
  google_color_bg = "ffffff";
  google_color_link = "000000";
  google_color_text = "000000";
  google_encoding = "GB2312";
  google_ad_channel = "5161927073";
  google_box_len = 40;
  google_logo_pos = "left";
  google_rs_pos = "below";
  google_ad_height = 65;
  google_ad_width = 500;
//-->
</script>
<script type="text/javascript"
 " width=100% src="http://pagead2.googlesyndication.com/pagead/show_sdo.js">
</script>

</td>
    </tr>
  </table>
</div>
<div class="footer">
<p class="link">
  网站版权信息及免责声明
  </p>

 <p class="powered">
  Copyright <a href="http://down.111cn.net" title="" target="_blank"><strong>down.<span>111cn.net</span></strong></a> &copy; 2004-2008  Inc.
<script language="javascript"" width=100% src="/js/count.js"></script> 
</p><!-- /powered -->
 
</div>
<div id="tt" ></div>

</body>
</html>
 

php 简单file_get_contents fopen教程

<!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>
<?php
 $content =file_get_contents('http://down.111cn.net/');
 if( !empty( $content ) ){
  $info = fopen('down.txt','w+');
  fwrite($info,$content);
  fclose($info);
  print_r(file('down.txt') );
 }

 ?>
</body>
</html>

php html转换成text文本函数

文章为各位提供一个哦,如果喜欢就行了。

<?php
if(!defined('DEDEINC'))
{
 exit("Request Error!");
}

function SpHtml2Text($str)
{
 $str = preg_replace("/<sty(.*)\/style>|<scr(.*)\/script>|<!--(.*)-->/isU","",$str);
 $alltext = "";
 $start = 1;
 for($i=0;$i<strlen($str);$i++)
 {
  if($start==0 && $str[$i]==">")
  {
   $start = 1;
  }
  else if($start==1)
  {
   if($str[$i]=="<")
   {
    $start = 0;
    $alltext .= " ";
   }
   else if(ord($str[$i])>31)
   {
    $alltext .= $str[$i];
   }
  }
 }
 $alltext = str_replace(" "," ",$alltext);
 $alltext = preg_replace("/&([^;&]*)(;|&)/","",$alltext);
 $alltext = preg_replace("/[ ]+/s"," ",$alltext);
 return $alltext;
}

?>

php 字符截取与图片过滤函数

本文章免费为各位朋友提供一款哦,如果你喜欢的话不防进来看看这款图片过滤正则表达试

function msubstr($str, $start, $len) {
 $tmpstr = "";
 $strlen = $start + $len;
 for($i = 0; $i < $strlen; $i++) {
       if(ord(substr($str, $i, 1)) > 0xa0) {
         $tmpstr .= substr($str, $i, 2);
         $i++;
       } else
         $tmpstr .= substr($str, $i, 1);
  }
 return $tmpstr;
 }
 
 //过滤图片
 function img_empty($content){
  $content=eregi_replace("<IMG ([a-zA-Z0-9~!& ?:"/._#=~&%]+)>","",$content);
  return $content;
 }

php 设置cookie高级用法

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

标签:[!--infotagslink--]

您可能感兴趣的文章: