<?php
header("Content-Type:text/html;charset=utf-8");
require_once("../global/connect.php");
//判断时间长度
$labelStep=3;
if($_POST["n"]==1){
$date=date("Y-m-d",strtotime("-30 day"));
$fromto="(".$date."至".date("Y-m-d").")";
}
if($_POST["n"]==2){
$labelStep=6;
$date=date("Y-m-d",strtotime("-60 day"));
$fromto="(".$date."至".date("Y-m-d").")";
}
if($_POST["n"]==3){
$labelStep=9;
$date=date("Y-m-d",strtotime("-90 day"));
$fromto="(".$date."至".date("Y-m-d").")";
}
if($_POST["n"]==12){
$labelStep=36;
$date=date("Y-m-d",strtotime("-365 day"));
$fromto="(".$date."至".date("Y-m-d").")";
}
//判断数据来源
if($_POST["m"]=="IPPV"){
$sql="select * from flow where adddate > '$date'";
$sql=mysql_query($sql);
$xml="<chart unescapeLinks=\"0\" caption=\"IP/PV统计$fromto\" lineThickness=\"1\" showValues=\"0\" formatNumberScale=\"0\" anchorRadius=\"2\" divLineAlpha=\"20\" divLineColor=\"CC3300\" divLineIsDashed=\"1\" showAlternateHGridColor=\"1\" alternateHGridAlpha=\"5\" alternateHGridColor=\"CC3300\" shadowAlpha=\"40\" labelStep=\"$labelStep\" numvdivlines=\"5\" chartRightMargin=\"35\" bgColor=\"FFFFFF,CC3300\" bgAngle=\"270\" bgAlpha=\"10,10\">";
$xmlx="<categories>";
$datas1="<dataset seriesName=\"IP\" color=\"1D8BD1\" anchorBorderColor=\"1D8BD1\" anchorBgColor=\"1D8BD1\">";
$datas2="<dataset seriesName=\"PV\" color=\"F1683C\" anchorBorderColor=\"F1683C\" anchorBgColor=\"F1683C\">";
while($row=mysql_fetch_array($sql)){
$xmlx .= "<category label='$row[adddate]'/>";
$datas1 .="<set value='$row[ip]'/>";
$datas2 .="<set value='$row[pv]'/>";
}
$xmlx .="</categories>";
$datas1 .="</dataset>";
$datas2 .="</dataset>";
$xml .=$xmlx;
$xml .=$datas1;
$xml .=$datas2;
}
if($_POST["m"]=="outlink"){
$sql="select * from flow where adddate > '$date'";
$sql=mysql_query($sql);
$xml="<chart unescapeLinks=\"0\" caption=\"反链统计$fromto\" lineThickness=\"1\" showValues=\"0\" formatNumberScale=\"0\" anchorRadius=\"2\" divLineAlpha=\"20\" divLineColor=\"CC3300\" divLineIsDashed=\"1\" showAlternateHGridColor=\"1\" alternateHGridAlpha=\"5\" alternateHGridColor=\"CC3300\" shadowAlpha=\"40\" labelStep=\"$labelStep\" numvdivlines=\"5\" chartRightMargin=\"35\" bgColor=\"FFFFFF,CC3300\" bgAngle=\"270\" bgAlpha=\"10,10\">";
$xmlx="<categories>";
$datas1="<dataset seriesName=\"谷歌反链\" color=\"1D8BD1\" anchorBorderColor=\"1D8BD1\" anchorBgColor=\"1D8BD1\">";
$datas2="<dataset seriesName=\"百度反链\" color=\"F1683C\" anchorBorderColor=\"F1683C\" anchorBgColor=\"F1683C\">";
while($row=mysql_fetch_array($sql)){
$xmlx .= "<category label='$row[adddate]'/>";
$datas1 .="<set value='$row[goutlink]'/>";
$datas2 .="<set value='$row[boutlink]'/>";
}
$xmlx .="</categories>";
$datas1 .="</dataset>";
$datas2 .="</dataset>";
$xml .=$xmlx;
$xml .=$datas1;
$xml .=$datas2;
}
if($_POST["m"]=="shoulu"){
$sql="select * from flow where adddate > '$date'";
$sql=mysql_query($sql);
$xml="<chart unescapeLinks=\"0\" caption=\"收录统计$fromto\" lineThickness=\"1\" showValues=\"0\" formatNumberScale=\"0\" anchorRadius=\"2\" divLineAlpha=\"20\" divLineColor=\"CC3300\" divLineIsDashed=\"1\" showAlternateHGridColor=\"1\" alternateHGridAlpha=\"5\" alternateHGridColor=\"CC3300\" shadowAlpha=\"40\" labelStep=\"$labelStep\" numvdivlines=\"5\" chartRightMargin=\"35\" bgColor=\"FFFFFF,CC3300\" bgAngle=\"270\" bgAlpha=\"10,10\">";
$xmlx="<categories>";
$datas1="<dataset seriesName=\"谷歌收录\" color=\"1D8BD1\" anchorBorderColor=\"1D8BD1\" anchorBgColor=\"1D8BD1\">";
$datas2="<dataset seriesName=\"百度收录\" color=\"F1683C\" anchorBorderColor=\"F1683C\" anchorBgColor=\"F1683C\">";

while($row=mysql_fetch_array($sql)){
$xmlx .= "<category label='$row[adddate]'/>";
$datas1 .="<set value='$row[google]'/>";
$datas2 .="<set value='$row[baidu]'/>";

}
$xmlx .="</categories>";
$datas1 .="</dataset>";
$datas2 .="</dataset>";

$xml .=$xmlx;
$xml .=$datas1;
$xml .=$datas2;

}
if($_POST["m"]=="dianji"){
$sql="select * from consulting where date > '$date'";
$sql=mysql_query($sql);
$xml="<chart unescapeLinks=\"0\" caption=\"点击/费用统计$fromto\" lineThickness=\"1\" showValues=\"0\" formatNumberScale=\"0\" anchorRadius=\"2\" divLineAlpha=\"20\" divLineColor=\"CC3300\" divLineIsDashed=\"1\" showAlternateHGridColor=\"1\" alternateHGridAlpha=\"5\" alternateHGridColor=\"CC3300\" shadowAlpha=\"40\" labelStep=\"$labelStep\" numvdivlines=\"5\" chartRightMargin=\"35\" bgColor=\"FFFFFF,CC3300\" bgAngle=\"270\" bgAlpha=\"10,10\">";
$xmlx="<categories>";
$datas1="<dataset seriesName=\"点击量\" color=\"1D8BD1\" anchorBorderColor=\"1D8BD1\" anchorBgColor=\"1D8BD1\">";
$datas2="<dataset seriesName=\"竞价费用\" color=\"F1683C\" anchorBorderColor=\"F1683C\" anchorBgColor=\"F1683C\">";

while($row=mysql_fetch_array($sql)){
$xmlx .= "<category label='$row[date]'/>";
$datas1 .="<set value='$row[dianji]'/>";
$datas2 .="<set value='$row[money]'/>";

}
$xmlx .="</categories>";
$datas1 .="</dataset>";
$datas2 .="</dataset>";

$xml .=$xmlx;
$xml .=$datas1;
$xml .=$datas2;

}
if($_POST["m"]=="chengjiao"){
$sql="select * from consulting where date > '$date'";
$sql=mysql_query($sql);
$xml="<chart unescapeLinks=\"0\" caption=\"成交/上门/有效/咨询量统计$fromto\" lineThickness=\"1\" showValues=\"0\" formatNumberScale=\"0\" anchorRadius=\"2\" divLineAlpha=\"20\" divLineColor=\"CC3300\" divLineIsDashed=\"1\" showAlternateHGridColor=\"1\" alternateHGridAlpha=\"5\" alternateHGridColor=\"CC3300\" shadowAlpha=\"40\" labelStep=\"$labelStep\" numvdivlines=\"5\" chartRightMargin=\"35\" bgColor=\"FFFFFF,CC3300\" bgAngle=\"270\" bgAlpha=\"10,10\">";
$xmlx="<categories>";
$datas1="<dataset seriesName=\"成交量\" color=\"1D8BD1\" anchorBorderColor=\"1D8BD1\" anchorBgColor=\"1D8BD1\">";
$datas2="<dataset seriesName=\"上门量\" color=\"F1683C\" anchorBorderColor=\"F1683C\" anchorBgColor=\"F1683C\">";
$datas3="<dataset seriesName=\"有效量\" color=\"19a00f\" anchorBorderColor=\"19a00f\" anchorBgColor=\"19a00f\">";
$datas4="<dataset seriesName=\"咨询量\" color=\"031e01\" anchorBorderColor=\"031e01\" anchorBgColor=\"031e01\">";

while($row=mysql_fetch_array($sql)){
$xmlx .= "<category label='$row[date]'/>";
$datas1 .="<set value='$row[chengjiao]'/>";
$datas2 .="<set value='$row[shangmen]'/>";
$datas3 .="<set value='$row[youxiao]'/>";
$datas4 .="<set value='$row[zixun]'/>";
}
$xmlx .="</categories>";
$datas1 .="</dataset>";
$datas2 .="</dataset>";
$datas3 .="</dataset>";
$datas4 .="</dataset>";
$xml .=$xmlx;
$xml .=$datas1;
$xml .=$datas2;
$xml .=$datas3;
$xml .=$datas4;
}
$xml .= "</chart>";					
echo $xml;
?>