<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
        /**
         * 临时测试文件
         * @author cxf
        */
class Test extends MY_Controller {

        function __construct()
        {
          parent::__construct();
          $this->load->model("user_model");
          $this->load->model("house_model");
          $this->load->model("ask_model");
          $this->load->library("user_class");
          $this->load->helper("template_helper");
          $this->user_id = checklogin();

        }


        
        /**
         * 把bbs用户刷入二手房
         * @author cxf
        */
        public function insert_user(){

        $offset = $page * 10000;
        $state = false;

        $bbs_user = $this->user_model->get_data(array('form_name' => 'user','where'=>array('userid >'=>10000*($page-1),'userid <='=>$offset,'lastactivity >'=>'1325347200'),'select'=>array('userid','username','password','email','lastactivity','joindate','ipaddress','mobile','birthday'),'order_by'=>'userid'),'bbs');
               
        $count = count($bbs_user); 

        if($count==0)
          {
           $state = true;
          }
        $str = '';
         
        for ($i = 1; $i <= $count; $i++) {
            

            if(isset($bbs_user[$i]) && !empty($bbs_user[$i])){
            $str .= "('".$bbs_user[$i]['userid']."','".$bbs_user[$i]['username']."', '".mysql_real_escape_string($bbs_user[$i]['email'])."',  '".$bbs_user[$i]['password']."', '".$bbs_user[$i]['lastactivity']."', '".$bbs_user[$i]['mobile']."', '".strtotime($bbs_user[$i]['birthday'])."', '".$bbs_user[$i]['ipaddress']."', 'nj', '".$bbs_user[$i]['joindate']."', '3'),";
            }
            //echo ($i%1000)."<br/>";
            if(($i%1000)==0 || $i == $count)
            {
                if($str)
                {
                $str = rtrim($str,',');
                $sql = "
                REPLACE INTO `personal_user` (`id` ,`username` ,`email` ,`password` ,`lastlogintime` ,`telno` ,`birthdate` ,`ipaddress` ,`cityname` ,`registertime` ,`infofrom`)
                VALUES $str";
               //echo $sql."<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>";
                $this->user_model->db_esf->query($sql);
                $str='';
                }
            }
        }
       

        if ($state == false) {
            sleep(2);
            $page++;
            echo '<script type="text/javascript">location.href="'.USER_CENTER.'test/insert_user?page=' . $page . '";</script>';
        }
        echo 'over';
      }

      public function test1(){
         $arr=array('blockshowname'=>$blockshowname,'buildarea'=>$buildarea,'price'=>$price,'floor'=>$floor,'subfloor'=>$subfloor,'totalfloor'=>$totalfloor,'priceunit'=>$priceunit);
         $telno = '15955549555';
         $num = $this->house_model->yzsamehouse($telno,$arr,'sell');
         echo $num;
         
         
      }

      public function new_usernum(){
	  
          $begin_time=$this->input->get("begin_time");
          $end_time=$this->input->get("end_time");
		  $city=$this->input->get("city");
          if(!empty($begin_time) && !empty($end_time))
          {

		  $user1 =  $this->house_model->get_data(array('form_name' => 'personal_user','where'=>array('registertime >'=>strtotime($begin_time),'registertime <'=>strtotime($end_time),'infofrom'=>1,'is_use'=>1,'cityname'=>$city),'select'=>array('id')),'esfbak');
          echo '主动注册用户:'.count($user1).'<br/>';
          $user2 =  $this->house_model->get_data(array('form_name' => 'personal_user','where'=>array('registertime >'=>strtotime($begin_time),'registertime <'=>strtotime($end_time),'infofrom'=>2,'is_use'=>1,'cityname'=>$city),'select'=>array('id')),'esfbak');
          echo '被动注册用户:'.count($user2).'<br/>';
          $user4 =  $this->house_model->get_data(array('form_name' => 'personal_user','where'=>array('registertime >'=>strtotime($begin_time),'registertime <'=>strtotime($end_time),'infofrom'=>4,'is_use'=>1,'cityname'=>$city),'select'=>array('id')),'esfbak');
          echo '手机注册用户:'.count($user4).'<br/>';
          echo '总数：'.(count($user4)+count($user2)+count($user1));
          }else{
          echo '参数不对';
          }
         
         
      }
	  
	  public function new_wantnum(){
          $begin_time=$this->input->get("begin_time");
          $end_time=$this->input->get("end_time");
          if(!empty($begin_time) && !empty($end_time))
          {

		  $num1 =  $this->house_model->get_data(array('form_name' => 'buy','where'=>array('creattime >'=>strtotime($begin_time),'creattime <'=>strtotime($end_time)),'select'=>array('id')),'esfhousebak');
          echo '求购数量:'.count($num1).'<br/>';
          $num2 =  $this->house_model->get_data(array('form_name' => 'rentwanted','where'=>array('creattime >'=>strtotime($begin_time),'creattime <'=>strtotime($end_time)),'select'=>array('id')),'esfhousebak');
          echo '求租数量:'.count($num2).'<br/>';

          }else{
          echo '参数不对';
          }
		  }
		  
		  public function new_matchnum(){
          $begin_time=$this->input->get("begin_time");
          $end_time=$this->input->get("end_time");
          if(!empty($begin_time) && !empty($end_time))
          {
		  $num1 =  $this->house_model->get_data(array('form_name' => 'buy_match','where'=>array('creattime >'=>strtotime($begin_time),'creattime <'=>strtotime($end_time)),'select'=>array('id')),'esfhousebak');
          echo '求购匹配数量:'.count($num1).'<br/>';
          $broker1 =  $this->house_model->get_data(array('form_name' => 'buy_match','where'=>array('creattime >'=>strtotime($begin_time),'creattime <'=>strtotime($end_time)),'select'=>array('distinct(match_uid)')),'esfhousebak');
          echo '求购匹配经纪人数量:'.count($broker1).'<br/>';
          $num2 =  $this->house_model->get_data(array('form_name' => 'rentwanted_match','where'=>array('creattime >'=>strtotime($begin_time),'creattime <'=>strtotime($end_time)),'select'=>array('id')),'esfhousebak');
          echo '求租匹配数量:'.count($num2).'<br/>';
          $broker2 =  $this->house_model->get_data(array('form_name' => 'rentwanted_match','where'=>array('creattime >'=>strtotime($begin_time),'creattime <'=>strtotime($end_time)),'select'=>array('distinct(match_uid)')),'esfhousebak');
          echo '求租匹配经纪人数量:'.count($broker2).'<br/>';
          }else{
          echo '参数不对';
          }
		  }


	 public function new_refreshnum(){
          $begin_time=$this->input->get("begin_time");
          $end_time=$this->input->get("end_time");
          if(!empty($begin_time) && !empty($end_time))
          {

		  $num1 =  $this->house_model->get_data(array('form_name' => 'log_house_operate','where'=>array('datetime >'=>date('Y-m-d H:i:s', strtotime($begin_time)),'datetime <'=>date('Y-m-d H:i:s', strtotime($end_time)),'type'=>2,'city'=>'nj','tbl'=>'sell'),'select'=>array('id')),'esfbak');
          echo '二手房刷新:'.count($num1).'<br/>';
          $num2 =  $this->house_model->get_data(array('form_name' => 'log_house_operate','where'=>array('datetime >'=>date('Y-m-d H:i:s', strtotime($begin_time)),'datetime <'=>date('Y-m-d H:i:s', strtotime($end_time)),'type'=>2,'city'=>'nj','tbl'=>'rent'),'select'=>array('id')),'esfbak');
          echo '租房刷新:'.count($num2).'<br/>';
          }else{
          echo '参数不对';
          }
         
         
      }

      public function new_housenum(){
          $begin_time=$this->input->get("begin_time");
          $end_time=$this->input->get("end_time");
          if(!empty($begin_time) && !empty($end_time))
          {
          $num=$this->house_model->get_house_num(strtotime($begin_time),strtotime($end_time),1);
          echo '有图房源数量:'.$num.'<br/>';
          $num1=$this->house_model->get_house_num(strtotime($begin_time),strtotime($end_time),0);
          echo '总房源数量:'.$num1.'<br/>';
          }else{
          echo '参数不对';
          }
         
         
      }

       public function new_behaviornum(){
          $begin_time=$this->input->get("begin_time");
          if(!empty($begin_time))
          {
		  $num1 =  $this->house_model->get_data(array('form_name' => 'log_user_behavior'.date("Ymd",strtotime($begin_time)),'select'=>array('count(id) as num')),'esfbak');
          echo '总行为数:'.$num1[0]['num'].'<br/>';
		  $num1 =  $this->house_model->get_data(array('form_name' => 'log_user_behavior'.date("Ymd",strtotime($begin_time)),'where'=>array('device'=>'1'),'select'=>array('count(id) as num')),'esfbak');
          echo 'pc总行为数:'.$num1[0]['num'].'<br/>';
		  $num6 =  $this->house_model->get_data(array('form_name' => 'log_user_behavior'.date("Ymd",strtotime($begin_time)),'where'=>array('device'=>'2'),'select'=>array('count(id) as num')),'esfbak');
          echo 'andriod总行为数:'.$num1[0]['num'].'<br/>';
		  $num7 =  $this->house_model->get_data(array('form_name' => 'log_user_behavior'.date("Ymd",strtotime($begin_time)),'where'=>array('device'=>'3'),'select'=>array('count(id) as num')),'esfbak');
          echo 'iphone总行为数:'.$num1[0]['num'].'<br/>';
          $num8 =  $this->house_model->get_data(array('form_name' => 'log_user_behavior'.date("Ymd",strtotime($begin_time)),'where'=>array('device'=>'1'),'select'=>array('distinct(telno)')),'esfbak');
          echo 'pc总号码数:'.count($num3).'<br/>';
          $num4 =  $this->house_model->get_data(array('form_name' => 'log_user_behavior'.date("Ymd",strtotime($begin_time)),'where'=>array('device'=>'2'),'select'=>array('distinct(telno)')),'esfbak');
          echo 'andriod总号码数:'.count($num4).'<br/>';
          $num5 =  $this->house_model->get_data(array('form_name' => 'log_user_behavior'.date("Ymd",strtotime($begin_time)),'where'=>array('device'=>'3'),'select'=>array('distinct(telno)')),'esfbak');
          echo 'iphone总号码数:'.count($num5).'<br/>';
          $num2 =  $this->house_model->get_data(array('form_name' => 'log_user_behavior'.date("Ymd",strtotime($begin_time)),'select'=>array('distinct(telno)')),'esfbak');
          echo '总号码数:'.count($num2).'<br/>';
          }else{
          echo '参数不对';
          }
         
         
      }

        public function new_behavior(){
          $begin_time=$this->input->get("begin_time");
          $begin_time = strtotime($begin_time);
          $end_time=$this->input->get("end_time");
          
          $end_time = strtotime($end_time);

          if(!empty($begin_time) && !empty($end_time))
          {
                  
            for($i=$begin_time;$i<=$end_time;$i=$i+(24*60*60))
            {

            $user1 =  $this->house_model->get_data(array('form_name' => 'log_user_behavior'.date("Ymd",$i),'where'=>array('operate_type '=>8),'select'=>array('id')),'esfbak');
            echo date("Ymd",$i).'关注房源:'.count($user1).'<br/>';
            $user2 =  $this->house_model->get_data(array('form_name' => 'log_user_behavior'.date("Ymd",$i),'where'=>array('operate_type '=>11),'select'=>array('id')),'esfbak');
            echo date("Ymd",$i).'关注小区:'.count($user2).'<br/>';           
            $user3 =  $this->house_model->get_data(array('form_name' => 'log_user_behavior'.date("Ymd",$i),'where'=>array('operate_type '=>7),'select'=>array('id')),'esfbak');
            echo date("Ymd",$i).'发送到手机:'.count($user3).'<br/>';  
            $user4 =  $this->house_model->get_data(array('form_name' => 'log_user_behavior'.date("Ymd",$i),'where'=>array('operate_type '=>9),'select'=>array('id')),'esfbak');
            echo date("Ymd",$i).'求租求购发布:'.count($user4).'<br/>';  
            $user5 =  $this->house_model->get_data(array('form_name' => 'log_user_behavior'.date("Ymd",$i),'where'=>array('operate_type '=>6),'select'=>array('id')),'esfbak');
            echo date("Ymd",$i).'预约看房:'.count($user5).'<br/>';  

            $user6 =  $this->house_model->get_data(array('form_name' => 'log_user_behavior'.date("Ymd",$i),'where'=>array('operate_type '=>3),'select'=>array('id')),'esfbak');
            echo date("Ymd",$i).'加入收藏夹:'.count($user6).'<br/>'; 

            $num1+= count($user1);
            $num2+= count($user2);
            $num3+= count($user3);
            $num4+= count($user4);
            $num5+= count($user5);
            $num6+= count($user6);
            }
          echo '合计：'.$num1.'<br/>'.$num2.'<br/>'.$num3.'<br/>'.$num4.'<br/>'.$num5.'<br/>'.$num6;
          echo 'over';exit;

          }else{
          echo '参数不对';
          }
         
         
      }
	  
	  	function delpush(){
			$str = '';
	       $push =  $this->house_model->get_data(array('form_name' => 'push_user','where'=>array('sendkind'=>1,'tbl'=>'rent'),'select'=>array('sendid','id')),'esfbak');
		   $n=0;
		   foreach($push as $value){
		     $is_buy = $this->house_model->get_data(array('form_name' => 'rentwanted','where'=>array('id'=>$value['sendid'],'infofrom'=>'1'),'select'=>array('id')),'esfhousebak');
			 if(!empty($is_buy[0]['id'])){
			   $str.=$value['id'].',';
			   $n++;
			 }
		   }
		   echo $n;
		   var_dump($str);exit;
	   }
}
?>