<?php
    $conf_basedir	= "../../";	//相对主目录的位置
    $conf_where		= "admin";	//选择调用相应模块
    //$directory		= basename(dirname(__FILE__));	//定义当前所在的目录，引入模块公用函数
    include_once($conf_basedir."base.inc.php");
    checkAuth('99');	//判断登录和权限
	
	$title = "友情链接统计";

	if ($actiontype) doaction($actiontype,$actionid);
    $css="<link href='http://esfadmin.house365.com/script/css/autocomplete.css' rel='stylesheet' type='text/css' />";
    $js = "<script type='text/javascript' src='http://esfadmin.house365.com/script/js/showpic.js'></script>
    <script type='text/javascript' src='http://esfadmin.house365.com/script/js/public.js'></script>
   <script type='text/javascript' src='http://esfadmin.house365.com/script/js/jquery_ui_autocomplete/ui/jquery.ui.core.js'></script>
   <script type='text/javascript' src='http://esfadmin.house365.com/script/js/jquery_ui_autocomplete/ui/jquery.ui.position.js'></script>
   <script type='text/javascript' src='http://esfadmin.house365.com/script/js/jquery_ui_autocomplete/ui/jquery.ui.widget.js'></script>
   <script type='text/javascript' src='http://esfadmin.house365.com/script/js/jquery_ui_autocomplete/ui/jquery.ui.autocomplete.js'></script>";
    $tbl='friend_link';

	$cond_arr_1=array();
	$cond_arr_1["0"]		="全部";
    $cond_arr_1["1"]	    ="小区";
    $cond_arr_1["2"]	    ="区属";
    $cond_arr_1["3"]	    ="板块";

	$cond_arr_2=array();
	$cond_arr_2[""]	="全部";
	$cond_arr_2["youlian_user_a"]	="youlian_user_a";
	$cond_arr_2["youlian_user_b"]	="youlian_user_b";
    $cond_arr_2["youlian_user_c"]	="youlian_user_c";
    $cond_arr_2["youlian_user_d"]	="youlian_user_d";
	if(in_array($_SESSION[$web_auth]["username"],array("youlian_user_a","youlian_user_b","youlian_user_c","youlian_user_d")))
	{
		$addname = $_SESSION[$web_auth]["username"];
		$cond_arr_2 = '';
		$cond_arr_2[$addname] = $addname;
	}
	$cond_search_2	= tonyForm("select","addname",$cond_arr_2,$addname);

    //顶部查询部分开始
    $wherecond = "1=1";

	if($type > 0){
		$wherecond.= " and type = '".$type."'";
	}
	if(!empty($addname)){
		$wherecond.= " and addname = '".$addname."'";
	}

	if(!empty($start_time) || !empty($end_time))
	{
		if(empty($start_time)){
			$stime = strtotime("2014-7-1 00:00:01");
		}else{
			$stime = strtotime($start_time." 00:00:01");
		}
		if(empty($end_time)){
			$etime = time();
		}else{
			$etime = strtotime($end_time." 23:59:59");
		}
		$wherecond.= " and ctime BETWEEN ".$stime." AND ".$etime." ";
	}

    //获得数据当前页面数据
    $sql = "select status,addname from $tbl where  $wherecond";
    $data = $dbback->GetAll($sql);
	$list_arr = array();
	foreach($data as $k => $v){
		if(in_array($_SESSION[$web_auth]["username"],array("youlian_user_a","youlian_user_b","youlian_user_c","youlian_user_d")))
		{
			if($_SESSION[$web_auth]["username"] != $v['addname']){
				continue;
			}
		}
		if($v['status'] == 1){
			if($list_arr[$v['addname']]['yes'] > 0){
				$list_arr[$v['addname']]['yes'] = $list_arr[$v['addname']]['yes']+1;
			}else{
				$list_arr[$v['addname']]['yes'] = 1;
			}
		}else{
			if($list_arr[$v['addname']]['no'] > 0){
				$list_arr[$v['addname']]['no'] = $list_arr[$v['addname']]['no']+1;
			}else{
				$list_arr[$v['addname']]['no'] = 1;
			}
		}
		if($list_arr[$v['addname']]['all'] > 0){
			$list_arr[$v['addname']]['all'] = $list_arr[$v['addname']]['all']+1;
		}else{
			$list_arr[$v['addname']]['all'] = 1;
		}
	}
	
    //引用模版文件
    include_once(Template("header"));
    include_once(Template("friend_link/friend_statistic"));
    include_once(Template("footer"));
?>