<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Register_xiao extends MY_Controller {

        function __construct()
        {
			parent::__construct();

			$this->load->model("user_model");
			$this->load->library("user_class");
			$this->load->helper("template_helper");			
			
			
        }

        /**
         * 用户注册
         * @author cxf
        */
        public function index()
        {
			
			
			if(!$_POST) 
			{
				$user_id = checklogin();

				if($user_id>0)
				{
					echo '<script type="text/javascript">window.location.href="'.USER_CENTER.'user";</script>';
					exit();
				}
			}

			$data['title'] = '用户注册';

           if ($_POST) 
		   {
              $validcode = $this->input->post('validcode');
              $telno = $this->input->post('telno');
              $kind = $this->input->post('kind');
              $password = $this->input->post('password'); 

				
              //验证手机号(二手房验证是否有此号码)
              $result=$this->user_model->yztelno($telno);

			  if($result>0){
				  echo 3;
				  exit;
			  }else{
				  //查找全站个人用户中心有无此号码 xue add
			      $ucenterTel = $this->user_model->ucenterCheckTelno($telno);				 
				  if($ucenterTel){
					  //做日志
                      $msg = date('Y-m-d H:i:s').":".$telno." \n";
					  @file_put_contents('./register_err',$msg,FILE_APPEND);
				      echo 3;
					  exit();
				  }

			  }

              //验证验证码
             /* $result=$this->user_model->yzusersms($validcode,$telno,$kind);

              if($result == 0)
              {
				echo 2;
				exit;
              }*/
              
              //先注册全站个人用户中心，成功后注册二手房个人会员中心
			  $uCenterReister = $this->user_model->ucenterReister($telno,md5($password),GB_CITY,$validcode);

			  //记录日志
			  /*
			  $msg = "************************************************ \n";
			  $msg .= date('Y-m-d H:i:s').var_export($uCenterReister['data'],true)." \n";
			  $log = dirname(__FILE__)."/register_record.log";
			  file_put_contents($log,$msg,FILE_APPEND );
				*/
			  if($uCenterReister['result']==1){
				   //全站注册
				  $this->user_model->ucenterLogin($telno,md5($password),GB_CITY);
				  
                  $passport_uid = $uCenterReister['data']['passport_uid'];

                  


				  $url = "api.house365.com/esf/web/api_400.php?stc=".urlencode($telno);
					//ECHO $url;
					curl_get_contents($url);
				  
				  //注册二手房
				  $ip =  get_ip();
				  $user = array(
				  'passport_uid'=>$passport_uid,
				  'telno' => $telno,
				  'password' => md5($password),
				  'registertime' => time(),
				  'lastlogintime' => time(),
				  'infofrom' => 1,
				  'ipaddress' => $ip,
				  'cityname' => GB_CITY
				  );

				   $result=$this->user_model->yztelno($telno);

				  if($result==0){
					  $this->user_model->set_table('personal_user');
					  //过滤表结构
					  $user = $this->user_model->create($user,'db_esf');
					  $result = $this->user_model->add($user,'db_esf');
				  }
				   //设置表
				 
				  if($result>0)
				   {
					 $this->user_class->user_login($result,md5($password),$telno);
					 //2016-1-28 zhou 添加crm记录 ----------- start ------------->
					$crm_uri	= '?city='.GB_CITY;
					
					$crm_uri	.= '&activefrom=210';//降价通知
					$fmailaction	= '注册-用户中心' ;
					
					
					$crm_uri .= '&activename='.urlencode($fmailaction);
					//CRM联系人信息-username
					
					//CRM联系人方式信息-mobile
					$mobile		= strip_tags($telno);
					$crm_uri .= '&mobile='.$mobile;

					$crm_uri .= '&username='.$mobile;
					
					$remark = '注册-用户中心';
					
					$crm_uri .= '&joinremark='.urlencode($remark);
					
				
					get_api("http://crm.house365.com/index.php/Simulate/sea".$crm_uri);

	
					//2016-1-28 zhou 添加crm记录 ----------- start ------------->

					 echo 1;exit;
				   }

			  }  
			  //此处优化验证码

             
           }
		   //bibibibi
		   $data['isa_website'] = '2,19,70';
		   $data['isa_city'] = GB_CITY;
		   $data['isa_addones'] = '';
		   $data['isa_url'] = 'isa.house365.com/js/analyze.js?v=2.1';
			//bibibibi
		   //$data['ga_channel'] = 'center';
           $this->load->view('register',$data);
        }


		//入CRM数据
		public function get_api($t_url)
		{
		
			$ch = curl_init();
			$t_url = $t_url ? $t_url : "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
			echo $t_url;die;
			curl_setopt($ch, CURLOPT_URL, $str);
			curl_setopt($ch, CURLOPT_REFERER, $t_url);
			curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_TIMEOUT, 3);
			$str = curl_exec($ch);
			curl_close($ch);
			return $str;
		
		
		
		}

		public function iframe_register_ajax()
        {

          
		 

		  $validcode = $this->input->get('validcode');
		  $telno = $this->input->get('telno');
		  $kind = $this->input->get('kind');
		  $password = $this->input->get('password');
		  $city = $this->input->get('city');
		  $ip = $this->input->get('ip');

		  //验证手机号
		  $result=$this->user_model->yztelno($telno);
		  if($result > 0 )
		  {
			$ajax_return['error'] = "1"; 
			$ajax_return['message'] = "该手机号码已经注册，请选择登录";
			echo serialize($ajax_return);
			exit;
		  }

		  //验证验证码
		  $result=$this->user_model->yzusersms($validcode,$telno,$kind);
		  if($result == 0)
		  {
			$ajax_return['error'] = "2"; 
			$ajax_return['message'] = "手机验证码不正确！";
			echo serialize($ajax_return);
			exit;
		  }
 
		  $user = array(
		  'telno' => $telno,
		  'password' => md5($password),
		  'registertime' => time(),
		  'lastlogintime' => time(),
		  'infofrom' => 1,
		  'ipaddress' => $ip,
		  'cityname' => $city
		  );

		   //记录日志
		  $msg = "************************************************ \n";
		  $msg .= date('Y-m-d H:i:s').var_export($user,true)." \n";
		  $log = dirname(__FILE__)."/register_iframe_register_ajax.log";
		  file_put_contents($log,$msg,FILE_APPEND );
		  $uCenterReister = $this->user_model->ucenterReister($telno,md5($password),GB_CITY,$validcode);
		  //设置表
		  $this->user_model->set_table('personal_user');
		  //过滤表结构
		  $user = $this->user_model->create($user,'db_esf');
		  $result = $this->user_model->add($user,'db_esf');
		  if($result>0)
		   {
			 $this->user_class->user_login($result,md5($password),$telno);

			//隐藏手机号部分数字
			$pattern = "/(1\d{1,2})\d\d(\d{0,3})/";
			$replacement = "\$1*****\$3";
			$telno2 = preg_replace($pattern, $replacement, trim($telno));
			$showname = $telno2 ? $telno2 : "" ;
			$esfmesnum =  $this->user_model->getmessagenumbyuidwd($result);
			$password_encrypt = passport_encrypt(md5($password));

			$ajax_return['error'] = "0";
			$ajax_return['result'] = $result;
			$ajax_return['showname'] = $showname;
			$ajax_return['esfmesnum'] = $esfmesnum;
			$ajax_return['password_encrypt'] = $password_encrypt;

			 echo serialize($ajax_return);
			 exit;
		   }else{
			 $ajax_return['error'] = "2"; 
			 $ajax_return['message'] = "注册失败！";
			 echo serialize($ajax_return);
			 exit;
		   }
        }

         /**
        * 验证手机号是否存在
        * @author cxf
        */
        public function yztelno_register(){
			$telno = $this->input->post('telno');
			$result=$this->user_model->yztelno($telno);

			if( $result>0 ) {
				echo '5';exit;
			} else {
				//查找全站个人用户中心有无此号码
				$ucenterTel = $this->user_model->ucenterCheckTelno($telno);	
				if( $ucenterTel ) {
					echo '5';exit;
				} else {
					echo '1';exit;
				}
			}
		}
		
		/**
        * 验证手机号是否存在
        * @author cxf
        */
		function iframe_yztelno_register(){
                
			$telno = $this->input->get('telno');
			$result=$this->user_model->yztelno($telno);
			if($result>0)
			{
				$ajax_return['error'] = "1";
				$ajax_return['message'] = "该手机号码已被使用";
			}else{
				$ajax_return['error'] = "0";
			}
			echo serialize($ajax_return);
		}
		

        /**
        * 获取验证码
        * @author cxf
        */
        public function getyzm_register()
        {
		
		    $validate_code = $this->input->post('validate_code');
			if($validate_code!=$_SESSION["authnum"])
			{
			  echo '7';exit;
			}
            //验证是否已经通过验证
            $validcode = random(6);
            $tt = array();

            $tt['validcode'] = $validcode;
            $tt['telno'] = $this->input->post('telno');
            $tt['kind'] = $this->input->post('kind');
            $tt['dateline'] = time();
            $tt['yztelno'] = $this->input->post('yztelno');
            //验证绑定手机，被动注册可以绑定
            if($tt['kind']==5)
            {
			  //是否已经注册过
              $result=$this->user_model->yztelnolt($tt['telno']);
			  //已经注册过了
		      if($result[0]['id']>0 && $result[0]['infofrom'] !=2)
			  {
				  echo '5';exit;
			  }
            }elseif($tt['kind']==4){
              $result=$this->user_model->yztelno($tt['telno']);
              if($result==0)
                {
                 echo '6';exit;
                }

            }else{
            //验证手机号
            if($tt['yztelno']==1)
            {
              $result=$this->user_model->yztelno($tt['telno']);
              if($result>0)
                {
                 echo '5';exit;
                }
            }

            }

            //设置表
            $this->user_model->set_table('personal_sms');

            //过滤表结构
            $tt = $this->user_model->create($tt,'db_esf');
            $result = $this->user_model->add($tt,'db_esf');

            if($result)
            {
				/*
                $msg   = '尊敬的365网友，您操作的验证码为'.$validcode.'，请在收到后两分钟内提交。';
                sendsms($tt['telno'],$msg,'sx');*/

				//修改短信接口	edit by kingj
				
				if(!is_numeric($tt['telno']))
				{
					die('9');
				}
				
				/*2015-8-17 zhou 获取验证码的次数 -------       start --------------- */
				$minute_num =$this->user_model->getMinuteNumPersonalUserStatistic($tt['telno']);

				if($minute_num)
				{
					die('8');
				}

				$day_num =$this->user_model->getNumPersonalUserStatistic($tt['telno']);
				
				if($day_num>=3)
				{
					die('4');
				}
				else
				{
					$this->user_model->addRecordPersonalUserStatistic($tt['telno']);
				}
				/*2015-8-17 zhou 获取验证码的次数 -------       end --------------- */
				
				$return = $this->user_model->ucenterAuthCode($tt['telno']);
				//var_dump($return);exit();
			    $return = $return ? 1 : 2 ;
			    echo $return;exit();
				
              // echo '1';
            }
            else
            {
                echo '2';//发送失败
            }

        }

		/**
        * 获取验证码
        * @author cxf
        */
        public function iframe_getyzm_register()
        {
		
            //验证是否已经通过验证
            $validcode = random(6);
            $tt = array();

            $tt['validcode'] = $validcode;
            $tt['telno'] = $this->input->get('telno');
            $tt['kind'] = $this->input->get('kind');
            $tt['dateline'] = time();
            $tt['yztelno'] = $this->input->get('yztelno');

			$security_key = $this->input->get('security_key');
			$security_num = $this->input->get('security_num');
			if( $security_num != ''){
				if($security_key != md5('HOUSE365_Reg_KEY_'.$security_num ))
				{
					echo '2'; exit;
				}
			}

            //验证绑定手机，被动注册可以绑定
            if($tt['kind']==5)
            {
				$result=$this->user_model->yztelnolt($tt['telno']);
				if($result[0]['id']>0 && $result[0]['infofrom'] !=2)
				{
				 echo '5';exit;
				}
            }elseif($tt['kind']==4){
              $result=$this->user_model->yztelno($tt['telno']);
              if($result==0)
                {
                 echo '6';exit;
                }

            }else{
				//验证手机号
				if($tt['yztelno']==1)
				{
				  $result=$this->user_model->yztelno($tt['telno']);
				  if($result>0)
					{
					 echo '5';exit;
					}
				}

            }

            //设置表
            $this->user_model->set_table('personal_sms');

            //过滤表结构
            $tt = $this->user_model->create($tt,'db_esf');
            $result = $this->user_model->add($tt,'db_esf');

            if($result)
            {
                //$msg   = '尊敬的365网友，您操作的验证码为'.$validcode.'，请在收到后两分钟内提交.';
				$msg   = $validcode;
                sendsms($tt['telno'],$msg,'sx',$validcode);
                echo '1';
            }
            else
            {
                echo '2';//发送失败
            }

        }

        /**
        * 获取验证码
        * @author cxf
        */
        public function getyzm2()
        {
            //验证是否已经通过验证
            $validcode = random(6);
            $tt = array();

            $tt['validcode'] = $validcode;
            $tt['telno'] = $this->input->post('telno');
            $tt['kind'] = $this->input->post('kind');
            $tt['dateline'] = time();
            $tt['yztelno'] = $this->input->post('yztelno');

            //验证绑定手机，被动注册可以绑定
            if( $tt['kind'] == 5)
            {
				$result = $this->user_model->yztelnolt($tt['telno']);

				if( $result[0]['id'] > 0 && $result[0]['infofrom'] != 2)
				{
					echo '5';
					exit;
				}
            }
			else if($tt['kind']==4)
			{
              $result = $this->user_model->yztelno($tt['telno']);

              if($result == 0)
              {
                 
				 echo '6';
				 exit;
              }

            }else{
				//验证手机号
				if($tt['yztelno']==1)
				{
					$result = $this->user_model->yztelno($tt['telno']);
					if($result>0)
					{
						echo '5';
						exit;
					}
				}
            }

            //验证此号码55秒内是否已经发送过验证码,防止刷短信
            $result = $this->user_model->yzusersmstime( 55 , $tt['telno'] , $tt['kind'] );
			if( $result > 0 )
			{
				echo '7';
				exit;
			}

            //设置表
            $this->user_model->set_table('personal_sms');

            //过滤表结构
            $tt = $this->user_model->create($tt,'db_esf');
            $result = $this->user_model->add($tt,'db_esf');

            if($result)
            {
                $msg   = '尊敬的365网友，您操作的验证码为'.$validcode.'，请在收到后两分钟内提交。';
                sendsms($tt['telno'],$msg,'sx',$validcode);
                echo '1';
            }
            else
            {
                echo '2';//发送失败
            }
        }


		/**
        * 获取验证码
        * @author xue add 2015-02-12
        */
        public function forget_getyzm()
        {
			
            //验证是否已经通过验证
            $validcode = random(6);
            $tt = array();

            $tt['validcode'] = $validcode;
            $tt['telno'] = $this->input->post('telno',TRUE);
            $tt['kind'] = $this->input->post('kind',TRUE);
            $tt['dateline'] = time();
            //$tt['yztelno'] = $this->input->post('yztelno',TRUE);
			//$tt['ip'] =  get_ip();
			$security_key = $this->input->post('security_key',TRUE);
           // echo GB_CITY;
			$security_key_yz = $_SESSION[GB_CITY.'_register_num_2'];
          //  echo $security_key;echo "||";
			//echo $security_key_yz;
			if($security_key=="" || $security_key!=$security_key_yz){
				echo '400';
				exit();
			}

			if( $tt['telno'] === false || $tt['kind'] === false )
			{
				echo '400';
				exit;
			}else if($tt['kind'] == 4)
			{
			  //改成验证全站电话

              $result2 = $this->user_model->yztelno($tt['telno']);
              $ucenterTel = $this->user_model->ucenterCheckTelno($tt['telno']);
              if(!$ucenterTel&&$result2==0)
              {
                 
				 echo '6';
				 exit;
              }

            }else if($tt['kind'] == 5){
				//不验证全站（专为修改号码服务）
				//$result2 = $this->user_model->yztelno($tt['telno']);
				//var_dump($result2);exit();
				//if(!$ucenterTel&&$result2==0)
              //  {
                 
					// echo '6';
					// exit;
               // }
				
            }

            //验证此号码55秒内是否已经发送过验证码,防止刷短信
            $result = $this->user_model->yzusersmstime( 55 , $tt['telno'] , $tt['kind'] );

			if( $result > 0 )
			{
				echo '7';
				exit;
			}

            //设置表
            $this->user_model->set_table('personal_sms');

            //过滤表结构
            $tt = $this->user_model->create($tt,'db_esf');
            $result = $this->user_model->add($tt,'db_esf');

            if($result)
            {

               $msg   = '尊敬的365网友，您操作的验证码为'.$validcode.'，请在收到后两分钟内提交。';
			   if($ucenterTel){

				    $return = $this->user_model->ucenterAuthCode($tt['telno']);	
					$return = $return ? 1 : 2 ;
					$return = $return ? 1 : 2 ;
			   }elseif(!$ucenterTel&&$result2>0){
			      sendsms($tt['telno'],$msg,'sx',$validcode);
				  echo '1';
			   }elseif($tt['kind'] == 5){
				   //修改号码专用
			      sendsms($tt['telno'],$msg,'sx',$validcode);
				  echo '1';			   
			   }
              
			  
			   echo $return;exit();
                //sendsms($tt['telno'],$msg,'sx');
                //echo '1';
            }
            else
            {
                echo '2';//发送失败
            }
        }



			/**
        * 获取验证码
        * @author cxf
        */
        public function getyzm()
        {
            //验证是否已经通过验证
            $validcode = random(6);
            $tt = array();

            $tt['validcode'] = $validcode;
            $tt['telno'] = $this->input->post('telno',TRUE);
            $tt['kind'] = $this->input->post('kind',TRUE);
            $tt['dateline'] = time();
            $tt['yztelno'] = $this->input->post('yztelno',TRUE);
			$tt['ip'] =  get_ip();
			$security_key = $this->input->post('security_key',TRUE);

			//if($tt['kind'] == 3 || $tt['kind'] == 1)
			//{	
			$security_num = $_SESSION[GB_CITY.'_register_num'];
			if( $security_key == '' || $security_key != md5('HOUSE365_Reg_KEY_'.$security_num ) )
			{
				echo '400';
				exit;
			}
			//}

			if( $tt['telno'] === false || $tt['kind'] === false )
			{
				echo '400';
				exit;
			}

            //验证绑定手机，被动注册可以绑定
            if( $tt['kind'] == 5)
            {
				$result = $this->user_model->yztelnolt($tt['telno']);

				if( $result[0]['id'] > 0 && $result[0]['infofrom'] != 2)
				{
					echo '5';
					exit;
				}
            }
			else if($tt['kind'] == 4)
			{
              $result = $this->user_model->yztelno($tt['telno']);

              if($result == 0)
              {
                 
				 echo '6';
				 exit;
              }

            }else{

				//验证手机号
				if( $tt['yztelno'] == 1)
				{
					$result = $this->user_model->yztelno($tt['telno']);
					if( $result > 0 )
					{
						echo '5';
						exit;
					}
				}
				
            }

            //验证此号码55秒内是否已经发送过验证码,防止刷短信
            $result = $this->user_model->yzusersmstime( 55 , $tt['telno'] , $tt['kind'] );

			if( $result > 0 )
			{
				echo '7';
				exit;
			}

           /** 2015-9-6  zhou 验证码今天如果有未验证通过的,再次发送还是发送上次的验证码   start  --->**/
			$today_result =$this->user_model->check_yzm_today_orderby_id($tt['telno']);
			if($today_result)
			{
				$this->user_model->update_yzm_today($tt['telno'],$today_result);

				$tt['validcode'] = $today_result;
				$validcode       = $today_result;
				$msg   = '尊敬的365网友，您操作的验证码为'.$validcode.'，请在收到后两分钟内提交。';
				sendsms($tt['telno'],$msg,'sx',$validcode);

				 //设置表
				/*$this->user_model->set_table('personal_sms');

				//过滤表结构
				$tt = $this->user_model->create($tt,'db_esf');
				$result = $this->user_model->add($tt,'db_esf');

				if($result)
				{
					echo '1';
				}
				else
				{
					echo '2';//发送失败
				}*/

				echo '1';
			}
			
			/** 2015-9-6  zhou 验证码今天如果有未验证通过的,再次发送还是发送上次的验证码   end  --->**/
			
			else
			{
				 //设置表
				$this->user_model->set_table('personal_sms');

				//过滤表结构
				$tt = $this->user_model->create($tt,'db_esf');
				$result = $this->user_model->add($tt,'db_esf');

				if($result)
				{
					$msg   = '尊敬的365网友，您操作的验证码为'.$validcode.'，请在收到后两分钟内提交。';
					sendsms($tt['telno'],$msg,'sx',$validcode);
					echo '1';
				}
				else
				{
					echo '2';//发送失败
				}
			}
        }


        



		/**
        * 发布页面获取验证码
        * @author cxf
        */
        public function getyzm_fabu()
        {
            //验证是否已经通过验证
            $validcode = random(6);
            $tt = array();

            $tt['validcode'] = $validcode;
            $tt['telno'] = $this->input->get('telno',TRUE);
            $tt['kind'] = $this->input->get('kind',TRUE);
            $tt['dateline'] = time();
            $tt['yztelno'] = $this->input->get('yztelno',TRUE);
			$tt['ip'] =  get_ip();
			$security_key = $this->input->get('security_key',TRUE);
			$security_num = $this->input->get('security_num',TRUE);

			if($tt['kind'] == 3 || $tt['kind'] == 1)
			{	
				if( $security_key == '' || $security_key != md5('HOUSE365_Reg_KEY_'.$security_num ) )
				{
					echo '400';
					exit;
				}
			}

			if( $tt['telno'] === false || $tt['kind'] === false )
			{
				echo '400';
				exit;
			}

            //验证绑定手机，被动注册可以绑定
            if( $tt['kind'] == 5)
            {
				$result = $this->user_model->yztelnolt($tt['telno']);

				if( $result[0]['id'] > 0 && $result[0]['infofrom'] != 2)
				{
					echo '5';
					exit;
				}
            }
			else if($tt['kind'] == 4)
			{
              $result = $this->user_model->yztelno($tt['telno']);

              if($result == 0)
              {
                 
				 echo '6';
				 exit;
              }

            }else{

				//验证手机号
				if( $tt['yztelno'] == 1)
				{
					$result = $this->user_model->yztelno($tt['telno']);
					if( $result > 0 )
					{
						echo '5';
						exit;
					}
				}
				
            }

            //验证此号码55秒内是否已经发送过验证码,防止刷短信
            $result = $this->user_model->yzusersmstime( 55 , $tt['telno'] , $tt['kind'] );

			if( $result > 0 )
			{
				echo '7';
				exit;
			}

            //设置表
            $this->user_model->set_table('personal_sms');

            //过滤表结构
            $tt = $this->user_model->create($tt,'db_esf');
            $result = $this->user_model->add($tt,'db_esf');

            if($result)
            {
                $msg   = '尊敬的365网友，您操作的验证码为'.$validcode.'，请在收到后两分钟内提交。';
                sendsms($tt['telno'],$msg,'sx',$validcode);
                echo '1';
            }
            else
            {
                echo '2';//发送失败
            }
        }



        /**
         * 验证验证码
         * @author cxf
        */
        public function yzcode(){
		$validcode = intval($this->input->post('vnum'));
        $telno = intval($this->input->post('telno'));
        //验证验证码
        $valid_isuse = $this->user_model->yzusersms($validcode,$telno);
		if($valid_isuse){
            $this->user_model->updatesms($validcode,$telno);
			echo "1";//发送成功
         }else{
			echo '2';
		}

        }


        /**
         * 关注操作
         * @author cxf
        */
        public function savesearch()
        {

         $kind = $this->input->get('kind');
         $uid = $this->input->get('uid');
		 $city = $this->input->get('city');
		 $city=!empty($city)?$city:'nj';
        $backurl = $kind == 1 ? USER_CENTER.'user/sell_condition' : USER_CENTER.'user/rent_condition';
        $num = $this->user_model->getusercollect($uid,$kind);

        if($num < 30)
        {
            $search['type'] = $this->input->get('type');
            $search['bl'] = $this->input->get('bl');
            $search['line'] = $this->input->get('line');
            $search['st'] = $this->input->get('st');
            $search['floor'] = $this->input->get('floor');
            $search['keyword'] = $this->input->get('keyword');
            $search['infofrom'] = $this->input->get('infofrom');
            $search['infotype'] = $this->input->get('infotype');
            $search['roomtype'] = $this->input->get('roomtype');
            $search['renttype'] = $this->input->get('renttype');
            $search['room'] = $this->input->get('room');
            $search['hall'] = $this->input->get('hall');
            $search['toilet'] = $this->input->get('toilet');
            $search['kitchen'] = $this->input->get('kitchen');
            $search['price_sell'] = $this->input->get('price_sell');
            $search['price_rent'] = $this->input->get('price_rent');
            $search['buildarea'] = $this->input->get('buildarea');
            $search['district'] = $this->input->get('district');
            $search['streetid'] = $this->input->get('streetid');
            $search['price_price1'] = $this->input->get('price_price1');
            $search['price_price2'] = $this->input->get('price_price2');
            $search['price1'] = $this->input->get('price1');
            $search['price2'] = $this->input->get('price2');
            $search['buildarea1'] = $this->input->get('buildarea1');
            $search['buildarea2'] = $this->input->get('buildarea2');
            $search['floor1'] = $this->input->get('floor1');
            $search['floor2'] = $this->input->get('floor2');
            $search['fitment'] = $this->input->get('fitment');
            $search['totalf'] = $this->input->get('totalf');
            $search['totalf'] = $this->input->get('totalf');
            $search['buildyear'] = $this->input->get('buildyear');
            $search['forward'] = $this->input->get('forward');
			$search['mright'] = $this->input->get('mright');
            //增加有无个税与增值税
            $search['pricetype'] = $this->input->get('pricetype');
            $search['taxonlytype'] = $this->input->get('taxonlytype');
            if($search['infotype'] == 3){
                $search['officetype'] = $this->input->get('officetype');
                $search['price_office'] = $this->input->get('price_office');
                $search['buildarea_office'] = $this->input->get('buildarea_office');
            }

            if($search['infotype'] == 4 ){
                $search['hangye']		= $this->input->get('hangye');
                $search['shoptype']		= $this->input->get('shoptype');
                $search['shop_staus']	= $this->input->get('shop_staus');
                $search['price_stores'] = $this->input->get('price_stores');
                $search['buildarea_stores']	= $this->input->get('buildarea_stores');
            }
            
            $searchcond = serialize($search);
            //print_r($searchcond);die;
            //验证是否已关注此条件
            $result = $this->user_model->yzcollect($searchcond,$kind,$uid,$city);
            //print_r($searchcond);die;
            if($result)
            {
            echo "4";exit;
            }
            $this->user_model->addcollect($uid,0,$kind,$searchcond,$city);
            echo "1";exit;
        }
        else
        {
            $type = $kind == 1 ? '二手房' : '租房';
            //收藏量超过30条
            echo "2";exit;
        }

        //echo "3";
        exit();
        }



		/**
        * API接口获取验证码
        * @author cxf
        */
		
		public function api_send_sms()
		{
		
			$validcode = random(6);
            $tt = array();

            $tt['validcode'] = $validcode;
			$tt['telno'] = $this->input->get('telno',TRUE);
           
          
			$tt['ip'] =  $_SERVER['REMOTE_ADDR'];
			$tt['ctime'] = time();
            $tt['status'] =0;
			
			$result =$this->user_model->addSendSms($tt);
			
            if($result)
            {
                $msg   = $validcode;
                sendsms($tt['telno'],$msg,'sx',$validcode);
                echo '1';
            }
            else
            {
                echo '2';//发送失败
            }
		
		}


		/**
        * API接口获取app验证码
        */
		
		public function api_send_sms_app()
		{
		
			$validcode = random(6);
            $tt = array();

            $tt['validcode'] = $validcode;
			$tt['telno'] = $this->input->get('telno',TRUE);
           
          
			$tt['ip'] =  $_SERVER['REMOTE_ADDR'];
			$tt['ctime'] = time();
            $tt['status'] =0;
			
			$result =$this->user_model->addSendSmsApp($tt);
			
            if($result)
            {
                //$msg   = $validcode;
				//$msg   = '尊敬的365网友，您操作的验证码为'.$validcode.'，请在收到后两分钟内提交。';
				$msg ='您的验证码是：'.$validcode.'，请在5分钟内完成验证。';
                sendsms($tt['telno'],$msg,'sx',$validcode);
                echo '1';
            }
            else
            {
                echo '2';//发送失败
            }
		
		}



		/**
        * 2015-11-9详情页面金融获取验证码
        * @author zhou
        */
		public function jrgetyzm()
		{
			
			$validcode = random(6);
            $tt = array();

            $tt['validcode'] = $validcode;
            $tt['telno'] = $this->input->get('telno');
            $tt['type'] = $this->input->get('type');
            $tt['ctime'] = time();

			//验证此号码55秒内是否已经发送过验证码,防止刷短信
            $result = $this->user_model->yzjrsmstime( 120 , $tt['telno'] , $tt['type'] );
			
			if( $result > 0 )
			{
				echo '1';
				exit;
			}
			/** 2015-11-10  zhou 验证码今天如果有未验证通过的,再次发送还是发送上次的验证码   start  --->**/
		
			$today_result =$this->user_model->check_jr_yzm_today_orderby_id($tt['telno'],$tt['type']);
			
			if($today_result)
			{
				$validcode       = $today_result;
				$msg   = '尊敬的365网友，您操作的验证码为'.$validcode.'，请在收到后两分钟内提交。';
				sendsms($tt['telno'],$msg,'sx',$validcode,$validcode);
				echo '1';exit;
			}
			
			/** 2015-11-10  zhou 验证码今天如果有未验证通过的,再次发送还是发送上次的验证码   end  --->**/
			else
			{
				//设置表
				$this->user_model->set_table('jr_sms');
				//过滤表结构
				$tt = $this->user_model->create($tt,'db_esf');
				$result = $this->user_model->add($tt,'db_esf');
				if($result)
				{
					$msg   = '尊敬的365网友，您操作的验证码为'.$validcode.'，请在收到后两分钟内提交。';
					sendsms($tt['telno'],$msg,'sx',$validcode);
					echo '1';exit;
				}
				else
				{
					echo '2';exit;//发送失败
				}
			}
		}
		
		/**
        * 2015-11-9详情页面金融验证验证码
        * @author zhou
        */
		public function jrcheckyzm()
		{
			
            $tt['telno'] = $this->input->get('telno');
            $tt['validcode'] = $this->input->get('validcode');
			$today_result =$this->user_model->check_jr_yzm_today_by_validcode($tt['telno'], $tt['validcode']);
			
			if($today_result)
			{
				
				$this->user_model->jrupdatesms($tt['telno'], $tt['validcode']);
				echo 1;exit;
			}
			else
			{
				
				echo 2;exit;
			}
			
		}





}
?>