dedecms ajax 下载统计代码
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);
}
下面是实例方法。