ajax实现跨域访问,用php写代理页面. 服务端处理程序:statistic.php
<?php
session_start();
require_once('./includes/common.php');
Header("Content-type:text/html;charset=GBK");//加入头,防止乱码
/*
$referUrl=$_SERVER["HTTP_REFERER"];//取得上一页面地址
$referHost=$_SERVER["HTTP_HOST"];//取得当前主机名
$referFile=explode("/",$referUrl);//取得上一前面的主机名$referFile[2]
if($referFile[2]!=$referHost)//如果上一页面与本服务端程序不在同一主机则禁止执行
{
echo "服务端禁止执行";
exit();
}
*/
//判断查询类型 1查询发展数量 2每日发短信数量,电话数量,时长 3每日登录时长在线时长
//$qry="3";
$Starttime = $dt.' 00:00:00' ;
$Endtime = $edt.' 23:59:59';
$SQL="select count(*) as cnt from tb_user where registtime between '$Starttime' and '$Endtime'";
$result=$db->query($SQL);
$row=$db->fetch_array($result);
$totalput=$row['cnt'];
echo "<TABLE width=800 border=0 align=center cellPadding=5 cellSpacing=1 bgcolor='#CCCCCC'>";
echo "<TR bgcolor='#ffffff'><TD width=141>发展帐号 ".$totalput." 个</TD></TR>";
echo "</TABLE>";
$SQL="select concat(telareacode,'-',telcode) as telcode,username,sum(case serviceid when '01' then fee else 0 end) as telmoney,sum(case serviceid when '02' then fee else 0 end) as smmoney from v_tel_sm_cdruser where starttime > '$Starttime' and endtime < '$Endtime' group by telcode,username UNION select '费用合计:','-',sum(case serviceid when '01' then fee else 0 end) as telmoney,sum(case serviceid when '02' then fee else 0 end) as smmoney from v_tel_sm_cdruser where starttime > '$Starttime' and endtime < '$Endtime'";
$result=$db->query($SQL);
$cur_num=$db->num_rows($result);
for ($i=0;$i<$cur_num;$i++)
{
$row=$db->fetch_array($result);
$telcode[$i]=HtmlEncode($row['telcode']);
$username[$i]=HtmlEncode($row['username']);
$telmoney[$i]=HtmlEncode($row['telmoney']);
$smmoney[$i]=HtmlEncode($row['smmoney']);
}
echo "<br/>";
echo "<TABLE width=800 border=0 align=center cellPadding=5 cellSpacing=1 bgcolor='#CCCCCC'>";
echo "<TR bgcolor='#ffffff'><TD width='25%' align='center'>电话号码</TD><TD width='25%' align='center'>帐号名称 </TD><TD width='25%' align='center'>电话费用</TD><TD width='25%' align='center'>短信费用</TD></TR>";
for ($i=0;$i<$cur_num;$i++)
{
echo "<TR bgcolor='#ffffff'><TD width='25%'> $telcode[$i]</TD><TD width='25%'> $username[$i]</TD><TD width='25%'> $telmoney[$i]</TD><TD width='25%'> $smmoney[$i]</TD></TR>";
}
echo "</TABLE>";
$SQL="select useraccount,sum(ollength) ollength,sum(loginlength) loginlength,sum(callintimes) callintimes,sum(callinlength) callinlength,sum(calltotimes) calltotimes,sum(calltolength) calltolength,sum(smouttimes) smouttimes,sum(smoutlength) smoutlength,sum(smintimes) smintimes,sum(sminlength) sminlength from hrb_report where reporttime between '$Starttime' and '$Endtime' group by useraccount union select '总计',sum(ollength) ollength,sum(loginlength) loginlength,sum(callintimes) callintimes,sum(callinlength) callinlength,sum(calltotimes) calltotimes,sum(calltolength) calltolength,sum(smouttimes) smouttimes,sum(smoutlength) smoutlength,sum(smintimes) smintimes,sum(sminlength) sminlength from hrb_report where reporttime between '$Starttime' and '$Endtime'";
$result=$db->query($SQL);
$cur_num=$db->num_rows($result);
for ($i=0;$i<$cur_num;$i++)
{
$row=$db->fetch_array($result);
$useraccount[$i]=HtmlEncode($row['useraccount']);
$ollength[$i]=HtmlEncode($row['ollength']);
$loginlength[$i]=HtmlEncode($row['loginlength']);
$callintimes[$i]=HtmlEncode($row['callintimes']);
$callinlength[$i]=HtmlEncode($row['callinlength']);
$calltotimes[$i]=HtmlEncode($row['calltotimes']);
$calltolength[$i]=HtmlEncode($row['calltolength']);
$smouttimes[$i]=HtmlEncode($row['smouttimes']);
$smoutlength[$i]=HtmlEncode($row['smoutlength']);
$smintimes[$i]=HtmlEncode($row['smintimes']);
$sminlength[$i]=HtmlEncode($row['sminlength']);
}
echo "<br/>";
echo "<TABLE width=800 border=0 align=center cellPadding=5 cellSpacing=1 bgcolor='#CCCCCC'>";
echo "<TR bgcolor='#ffffff'><TD width='10%' align='center'> 帐号<br/>名称</TD><TD width='9%' align='center'> 在线<br/>时长</TD><TD width='9%' align='center'> 登录<br/>时长</TD><TD width='9%' align='center'> 来电<br/>次数</TD><TD width='9%' align='center'> 来电<br/>时长</TD><TD width='9%' align='center'> 去电<br/>次数</TD><TD width='9%' align='center'> 去电<br/>时长</TD><TD width='9%' align='center'> 发短信<br/>次数</TD><TD width='9%' align='center'> 发短信<br/>时长</TD><TD width='9%' align='center'> 收短信<br/>次数</TD><TD width='9%' align='center'> 收短信<br/>时长</TD></TR>";
for ($i=0;$i<$cur_num;$i++)
{
echo "<TR bgcolor='#ffffff'><TD width='10%' align='center'>$useraccount[$i]</TD><TD width='9%' align='center'>$ollength[$i]</TD><TD width='9%' align='center'>$loginlength[$i]</TD><TD width='9%' align='center'>$callintimes[$i]</TD><TD width='9%' align='center'>$callinlength[$i]</TD><TD width='9%' align='center'>$calltotimes[$i]</TD><TD width='9%' align='center'>$calltolength[$i]</TD><TD width='9%' align='center'>$smouttimes[$i]</TD><TD width='9%' align='center'>$smoutlength[$i]</TD><TD width='9%' align='center'>$smintimes[$i]</TD><TD width='9%' align='center'>$sminlength[$i]</TD></TR>";
}
echo "</TABLE>";
/*
switch($qry)
{
case "1":
{
$SQL="select count(*) as cnt from tb_user where registtime between '$Starttime' and '$Endtime'";
$result=$db->query($SQL);
$row=$db->fetch_array($result);
$totalput=$row['cnt'];
//echo $Starttime;
echo "<TABLE width=800 border=0 align=center cellPadding=5 cellSpacing=1 bgcolor='#CCCCCC'>";
echo "<TR bgcolor='#ffffff'><TD width=141>发展帐号 ".$totalput." 个</TD></TR>";
echo "</TABLE>";
break;
}
case "2":
{
$SQL="select concat(telareacode,'-',telcode) as telcode,username,sum(case serviceid when '01' then fee else 0 end) as telmoney,sum(case serviceid when '02' then fee else 0 end) as smmoney from v_tel_sm_cdruser where starttime > '$Starttime' and endtime < '$Endtime' group by telcode,username UNION select '费用合计:','-',sum(case serviceid when '01' then fee else 0 end) as telmoney,sum(case serviceid when '02' then fee else 0 end) as smmoney from v_tel_sm_cdruser where starttime > '$Starttime' and endtime < '$Endtime'";
$result=$db->query($SQL);
$cur_num=$db->num_rows($result);
for ($i=0;$i<$cur_num;$i++)
{
$row=$db->fetch_array($result);
$telcode[$i]=HtmlEncode($row['telcode']);
$username[$i]=HtmlEncode($row['username']);
$telmoney[$i]=HtmlEncode($row['telmoney']);
$smmoney[$i]=HtmlEncode($row['smmoney']);
}
echo "<TABLE width=800 border=0 align=center cellPadding=5 cellSpacing=1 bgcolor='#CCCCCC'>";
echo "<TR bgcolor='#ffffff'><TD width='25%' align='center'>电话号码</TD><TD width='25%' align='center'>帐号名称 </TD><TD width='25%' align='center'>电话费用</TD><TD width='25%' align='center'>短信费用</TD></TR>";
for ($i=0;$i<$cur_num;$i++)
{
echo "<TR bgcolor='#ffffff'><TD width='25%'> $telcode[$i]</TD><TD width='25%'> $username[$i]</TD><TD width='25%'> $telmoney[$i]</TD><TD width='25%'> $smmoney[$i]</TD></TR>";
}
echo "</TABLE>";
break;
}
case "3":
{
$SQL="select useraccount,sum(ollength) ollength,sum(loginlength) loginlength,sum(callintimes) callintimes,sum(callinlength) callinlength,sum(calltotimes) calltotimes,sum(calltolength) calltolength,sum(smouttimes) smouttimes,sum(smoutlength) smoutlength,sum(smintimes) smintimes,sum(sminlength) sminlength from hrb_report where reporttime between '$Starttime' and '$Endtime' group by useraccount union select '总计',sum(ollength) ollength,sum(loginlength) loginlength,sum(callintimes) callintimes,sum(callinlength) callinlength,sum(calltotimes) calltotimes,sum(calltolength) calltolength,sum(smouttimes) smouttimes,sum(smoutlength) smoutlength,sum(smintimes) smintimes,sum(sminlength) sminlength from hrb_report where reporttime between '$Starttime' and '$Endtime'";
$result=$db->query($SQL);
$cur_num=$db->num_rows($result);
for ($i=0;$i<$cur_num;$i++)
{
$row=$db->fetch_array($result);
$useraccount[$i]=HtmlEncode($row['useraccount']);
$ollength[$i]=HtmlEncode($row['ollength']);
$loginlength[$i]=HtmlEncode($row['loginlength']);
$callintimes[$i]=HtmlEncode($row['callintimes']);
$callinlength[$i]=HtmlEncode($row['callinlength']);
$calltotimes[$i]=HtmlEncode($row['calltotimes']);
$calltolength[$i]=HtmlEncode($row['calltolength']);
$smouttimes[$i]=HtmlEncode($row['smouttimes']);
$smoutlength[$i]=HtmlEncode($row['smoutlength']);
$smintimes[$i]=HtmlEncode($row['smintimes']);
$sminlength[$i]=HtmlEncode($row['sminlength']);
}
echo "<TABLE width=800 border=0 align=center cellPadding=5 cellSpacing=1 bgcolor='#CCCCCC'>";
echo "<TR bgcolor='#ffffff'><TD width='10%' align='center'> 帐号名称</TD><TD width='9%' align='center'> 在线时长</TD><TD width='9%' align='center'> 登录时长</TD><TD width='9%' align='center'> 来电次数</TD><TD width='9%' align='center'> 来电时长</TD><TD width='9%' align='center'> 去电次数</TD><TD width='9%' align='center'> 去电时长</TD><TD width='9%' align='center'> 发短信次数</TD><TD width='9%' align='center'> 发短信时长</TD><TD width='9%' align='center'> 收短信次数</TD><TD width='9%' align='center'> 收短信时长</TD></TR>";
for ($i=0;$i<$cur_num;$i++)
{
echo "<TR bgcolor='#ffffff'><TD width='10%' align='center'>$useraccount[$i]</TD><TD width='9%' align='center'>$ollength[$i]</TD><TD width='9%' align='center'>$loginlength[$i]</TD><TD width='9%' align='center'>$callintimes[$i]</TD><TD width='9%' align='center'>$callinlength[$i]</TD><TD width='9%' align='center'>$calltotimes[$i]</TD><TD width='9%' align='center'>$calltolength[$i]</TD><TD width='9%' align='center'>$smouttimes[$i]</TD><TD width='9%' align='center'>$smoutlength[$i]</TD><TD width='9%' align='center'>$smintimes[$i]</TD><TD width='9%' align='center'>$sminlength[$i]</TD></TR>";
}
echo "</TABLE>";
break;
}
}
*/
?>
session_start();
require_once('./includes/common.php');
Header("Content-type:text/html;charset=GBK");//加入头,防止乱码
/*
$referUrl=$_SERVER["HTTP_REFERER"];//取得上一页面地址
$referHost=$_SERVER["HTTP_HOST"];//取得当前主机名
$referFile=explode("/",$referUrl);//取得上一前面的主机名$referFile[2]
if($referFile[2]!=$referHost)//如果上一页面与本服务端程序不在同一主机则禁止执行
{
echo "服务端禁止执行";
exit();
}
*/
//判断查询类型 1查询发展数量 2每日发短信数量,电话数量,时长 3每日登录时长在线时长
//$qry="3";
$Starttime = $dt.' 00:00:00' ;
$Endtime = $edt.' 23:59:59';
$SQL="select count(*) as cnt from tb_user where registtime between '$Starttime' and '$Endtime'";
$result=$db->query($SQL);
$row=$db->fetch_array($result);
$totalput=$row['cnt'];
echo "<TABLE width=800 border=0 align=center cellPadding=5 cellSpacing=1 bgcolor='#CCCCCC'>";
echo "<TR bgcolor='#ffffff'><TD width=141>发展帐号 ".$totalput." 个</TD></TR>";
echo "</TABLE>";
$SQL="select concat(telareacode,'-',telcode) as telcode,username,sum(case serviceid when '01' then fee else 0 end) as telmoney,sum(case serviceid when '02' then fee else 0 end) as smmoney from v_tel_sm_cdruser where starttime > '$Starttime' and endtime < '$Endtime' group by telcode,username UNION select '费用合计:','-',sum(case serviceid when '01' then fee else 0 end) as telmoney,sum(case serviceid when '02' then fee else 0 end) as smmoney from v_tel_sm_cdruser where starttime > '$Starttime' and endtime < '$Endtime'";
$result=$db->query($SQL);
$cur_num=$db->num_rows($result);
for ($i=0;$i<$cur_num;$i++)
{
$row=$db->fetch_array($result);
$telcode[$i]=HtmlEncode($row['telcode']);
$username[$i]=HtmlEncode($row['username']);
$telmoney[$i]=HtmlEncode($row['telmoney']);
$smmoney[$i]=HtmlEncode($row['smmoney']);
}
echo "<br/>";
echo "<TABLE width=800 border=0 align=center cellPadding=5 cellSpacing=1 bgcolor='#CCCCCC'>";
echo "<TR bgcolor='#ffffff'><TD width='25%' align='center'>电话号码</TD><TD width='25%' align='center'>帐号名称 </TD><TD width='25%' align='center'>电话费用</TD><TD width='25%' align='center'>短信费用</TD></TR>";
for ($i=0;$i<$cur_num;$i++)
{
echo "<TR bgcolor='#ffffff'><TD width='25%'> $telcode[$i]</TD><TD width='25%'> $username[$i]</TD><TD width='25%'> $telmoney[$i]</TD><TD width='25%'> $smmoney[$i]</TD></TR>";
}
echo "</TABLE>";
$SQL="select useraccount,sum(ollength) ollength,sum(loginlength) loginlength,sum(callintimes) callintimes,sum(callinlength) callinlength,sum(calltotimes) calltotimes,sum(calltolength) calltolength,sum(smouttimes) smouttimes,sum(smoutlength) smoutlength,sum(smintimes) smintimes,sum(sminlength) sminlength from hrb_report where reporttime between '$Starttime' and '$Endtime' group by useraccount union select '总计',sum(ollength) ollength,sum(loginlength) loginlength,sum(callintimes) callintimes,sum(callinlength) callinlength,sum(calltotimes) calltotimes,sum(calltolength) calltolength,sum(smouttimes) smouttimes,sum(smoutlength) smoutlength,sum(smintimes) smintimes,sum(sminlength) sminlength from hrb_report where reporttime between '$Starttime' and '$Endtime'";
$result=$db->query($SQL);
$cur_num=$db->num_rows($result);
for ($i=0;$i<$cur_num;$i++)
{
$row=$db->fetch_array($result);
$useraccount[$i]=HtmlEncode($row['useraccount']);
$ollength[$i]=HtmlEncode($row['ollength']);
$loginlength[$i]=HtmlEncode($row['loginlength']);
$callintimes[$i]=HtmlEncode($row['callintimes']);
$callinlength[$i]=HtmlEncode($row['callinlength']);
$calltotimes[$i]=HtmlEncode($row['calltotimes']);
$calltolength[$i]=HtmlEncode($row['calltolength']);
$smouttimes[$i]=HtmlEncode($row['smouttimes']);
$smoutlength[$i]=HtmlEncode($row['smoutlength']);
$smintimes[$i]=HtmlEncode($row['smintimes']);
$sminlength[$i]=HtmlEncode($row['sminlength']);
}
echo "<br/>";
echo "<TABLE width=800 border=0 align=center cellPadding=5 cellSpacing=1 bgcolor='#CCCCCC'>";
echo "<TR bgcolor='#ffffff'><TD width='10%' align='center'> 帐号<br/>名称</TD><TD width='9%' align='center'> 在线<br/>时长</TD><TD width='9%' align='center'> 登录<br/>时长</TD><TD width='9%' align='center'> 来电<br/>次数</TD><TD width='9%' align='center'> 来电<br/>时长</TD><TD width='9%' align='center'> 去电<br/>次数</TD><TD width='9%' align='center'> 去电<br/>时长</TD><TD width='9%' align='center'> 发短信<br/>次数</TD><TD width='9%' align='center'> 发短信<br/>时长</TD><TD width='9%' align='center'> 收短信<br/>次数</TD><TD width='9%' align='center'> 收短信<br/>时长</TD></TR>";
for ($i=0;$i<$cur_num;$i++)
{
echo "<TR bgcolor='#ffffff'><TD width='10%' align='center'>$useraccount[$i]</TD><TD width='9%' align='center'>$ollength[$i]</TD><TD width='9%' align='center'>$loginlength[$i]</TD><TD width='9%' align='center'>$callintimes[$i]</TD><TD width='9%' align='center'>$callinlength[$i]</TD><TD width='9%' align='center'>$calltotimes[$i]</TD><TD width='9%' align='center'>$calltolength[$i]</TD><TD width='9%' align='center'>$smouttimes[$i]</TD><TD width='9%' align='center'>$smoutlength[$i]</TD><TD width='9%' align='center'>$smintimes[$i]</TD><TD width='9%' align='center'>$sminlength[$i]</TD></TR>";
}
echo "</TABLE>";
/*
switch($qry)
{
case "1":
{
$SQL="select count(*) as cnt from tb_user where registtime between '$Starttime' and '$Endtime'";
$result=$db->query($SQL);
$row=$db->fetch_array($result);
$totalput=$row['cnt'];
//echo $Starttime;
echo "<TABLE width=800 border=0 align=center cellPadding=5 cellSpacing=1 bgcolor='#CCCCCC'>";
echo "<TR bgcolor='#ffffff'><TD width=141>发展帐号 ".$totalput." 个</TD></TR>";
echo "</TABLE>";
break;
}
case "2":
{
$SQL="select concat(telareacode,'-',telcode) as telcode,username,sum(case serviceid when '01' then fee else 0 end) as telmoney,sum(case serviceid when '02' then fee else 0 end) as smmoney from v_tel_sm_cdruser where starttime > '$Starttime' and endtime < '$Endtime' group by telcode,username UNION select '费用合计:','-',sum(case serviceid when '01' then fee else 0 end) as telmoney,sum(case serviceid when '02' then fee else 0 end) as smmoney from v_tel_sm_cdruser where starttime > '$Starttime' and endtime < '$Endtime'";
$result=$db->query($SQL);
$cur_num=$db->num_rows($result);
for ($i=0;$i<$cur_num;$i++)
{
$row=$db->fetch_array($result);
$telcode[$i]=HtmlEncode($row['telcode']);
$username[$i]=HtmlEncode($row['username']);
$telmoney[$i]=HtmlEncode($row['telmoney']);
$smmoney[$i]=HtmlEncode($row['smmoney']);
}
echo "<TABLE width=800 border=0 align=center cellPadding=5 cellSpacing=1 bgcolor='#CCCCCC'>";
echo "<TR bgcolor='#ffffff'><TD width='25%' align='center'>电话号码</TD><TD width='25%' align='center'>帐号名称 </TD><TD width='25%' align='center'>电话费用</TD><TD width='25%' align='center'>短信费用</TD></TR>";
for ($i=0;$i<$cur_num;$i++)
{
echo "<TR bgcolor='#ffffff'><TD width='25%'> $telcode[$i]</TD><TD width='25%'> $username[$i]</TD><TD width='25%'> $telmoney[$i]</TD><TD width='25%'> $smmoney[$i]</TD></TR>";
}
echo "</TABLE>";
break;
}
case "3":
{
$SQL="select useraccount,sum(ollength) ollength,sum(loginlength) loginlength,sum(callintimes) callintimes,sum(callinlength) callinlength,sum(calltotimes) calltotimes,sum(calltolength) calltolength,sum(smouttimes) smouttimes,sum(smoutlength) smoutlength,sum(smintimes) smintimes,sum(sminlength) sminlength from hrb_report where reporttime between '$Starttime' and '$Endtime' group by useraccount union select '总计',sum(ollength) ollength,sum(loginlength) loginlength,sum(callintimes) callintimes,sum(callinlength) callinlength,sum(calltotimes) calltotimes,sum(calltolength) calltolength,sum(smouttimes) smouttimes,sum(smoutlength) smoutlength,sum(smintimes) smintimes,sum(sminlength) sminlength from hrb_report where reporttime between '$Starttime' and '$Endtime'";
$result=$db->query($SQL);
$cur_num=$db->num_rows($result);
for ($i=0;$i<$cur_num;$i++)
{
$row=$db->fetch_array($result);
$useraccount[$i]=HtmlEncode($row['useraccount']);
$ollength[$i]=HtmlEncode($row['ollength']);
$loginlength[$i]=HtmlEncode($row['loginlength']);
$callintimes[$i]=HtmlEncode($row['callintimes']);
$callinlength[$i]=HtmlEncode($row['callinlength']);
$calltotimes[$i]=HtmlEncode($row['calltotimes']);
$calltolength[$i]=HtmlEncode($row['calltolength']);
$smouttimes[$i]=HtmlEncode($row['smouttimes']);
$smoutlength[$i]=HtmlEncode($row['smoutlength']);
$smintimes[$i]=HtmlEncode($row['smintimes']);
$sminlength[$i]=HtmlEncode($row['sminlength']);
}
echo "<TABLE width=800 border=0 align=center cellPadding=5 cellSpacing=1 bgcolor='#CCCCCC'>";
echo "<TR bgcolor='#ffffff'><TD width='10%' align='center'> 帐号名称</TD><TD width='9%' align='center'> 在线时长</TD><TD width='9%' align='center'> 登录时长</TD><TD width='9%' align='center'> 来电次数</TD><TD width='9%' align='center'> 来电时长</TD><TD width='9%' align='center'> 去电次数</TD><TD width='9%' align='center'> 去电时长</TD><TD width='9%' align='center'> 发短信次数</TD><TD width='9%' align='center'> 发短信时长</TD><TD width='9%' align='center'> 收短信次数</TD><TD width='9%' align='center'> 收短信时长</TD></TR>";
for ($i=0;$i<$cur_num;$i++)
{
echo "<TR bgcolor='#ffffff'><TD width='10%' align='center'>$useraccount[$i]</TD><TD width='9%' align='center'>$ollength[$i]</TD><TD width='9%' align='center'>$loginlength[$i]</TD><TD width='9%' align='center'>$callintimes[$i]</TD><TD width='9%' align='center'>$callinlength[$i]</TD><TD width='9%' align='center'>$calltotimes[$i]</TD><TD width='9%' align='center'>$calltolength[$i]</TD><TD width='9%' align='center'>$smouttimes[$i]</TD><TD width='9%' align='center'>$smoutlength[$i]</TD><TD width='9%' align='center'>$smintimes[$i]</TD><TD width='9%' align='center'>$sminlength[$i]</TD></TR>";
}
echo "</TABLE>";
break;
}
}
*/
?>
代理页面名称:AJAXProxy.php 源码:





















javascript代码页:









































































































