码迷,mamicode.com
首页 > Web开发 > 详细

cakephp的 \cake24\Cake\Controller\BaseController.php

时间:2017-05-26 11:54:29      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:1.5   insert   xpl   jsonp   数据库   oda   commit   code   anywhere   

<?php
/**
 * 该方法公共依赖层控制器
 * 在此控制器下新增的方法建议统一加上前缀 cake24_ 避免和之前的方法冲突
 * @author dutongzhen
 */
class BaseController extends Controller {

	/**
     *  报名入口,检查当前号码是否存在于系统,如存在以下板块,则将被重置到报名管理中
     *  2015-12-30
     *  Sherwin
     **/
    public function cake24_ck_baoming_reset($mobile) {
        $this->autoRender = false;
        $quest = false;
        // $mobile = $_GET[‘mobile‘];
/*        $this->loadModel("Baomings");
        $this->loadModel("RejectLogs");
        $this->loadModel("ResetLogs");*/
        $info = $this->Baomings->find("first", array(‘conditions‘ => array(‘Baomings.mobile‘ => $mobile), ‘order‘ => array(‘Baomings.id DESC‘)));
        $content = "";

        if (empty($info)) {
            return json_encode(array(‘status‘ => $quest, ‘baoming_id‘ => 0));
        }
/*
        echo "<pre>";
        print_r($info);*/

        $update  = array();

        if ($info[‘Baomings‘][‘is_conect‘] == 1 && $info[‘Baomings‘][‘yixiang‘] != 1 && $info[‘Baomings‘][‘is_fp‘] == 1 && $info[‘Baomings‘][‘mes_bak‘] == 1 && $info[‘Baomings‘][‘delay‘] == 0 && ($info[‘Baomings‘][‘status‘] == 0 || $info[‘Baomings‘][‘status‘] == 1) && ($info[‘Baomings‘][‘status_trace‘] == 0 || $info[‘Baomings‘][‘status_trace‘] == 1) && $info[‘Baomings‘][‘invalid‘] == 0 && $info[‘Baomings‘][‘decoration‘] != 1 && $info[‘Baomings‘][‘is_qy‘] == 0) {
            # 意向管理
            $quest = true;
            $content = "由业主主动报名,从意向管理重置到报名管理中";
            $update[‘is_fp‘] = 1;
        } else if ($info[‘Baomings‘][‘is_fp‘] == 1 && $info[‘Baomings‘][‘mes_bak‘] == 1 && ($info[‘Baomings‘][‘delay‘] == 1 || $info[‘Baomings‘][‘delay‘] == 2) && ($info[‘Baomings‘][‘status‘] == 0 || $info[‘Baomings‘][‘status‘] == 1) && ($info[‘Baomings‘][‘status_trace‘] == 0 || $info[‘Baomings‘][‘status_trace‘] == 1) && $info[‘Baomings‘][‘invalid‘] == 0 && $info[‘Baomings‘][‘decoration‘] == 0 && $info[‘Baomings‘][‘is_qy‘] == 0) {
            # 潜在管理
            $quest = true;
            $content = "由业主主动报名,从潜在管理重置到报名管理中";
            $update[‘is_fp‘] = 0;
            $update[‘ownercs‘] = 0;
        } else if ($info[‘Baomings‘][‘decoration‘] == 1 && $info[‘Baomings‘][‘is_qy‘] == 0) { 
            # 无装修需求
            $quest = true;
            $content = "由业主主动报名,从无装修需求重置到报名管理中";
            $update[‘is_fp‘] = 0;
            $update[‘ownercs‘] = 0;
        } else if ($info[‘Baomings‘][‘is_fp‘] == 1 && $info[‘Baomings‘][‘yixiang‘] != 1 && ($info[‘Baomings‘][‘status_trace‘] == 2 || $info[‘Baomings‘][‘status_trace‘] == 3) && $info[‘Baomings‘][‘is_qy‘] == 0) { 
            # 结束
            $quest = true;
            $content = "由业主主动报名,从结束管理重置到报名管理中";
            $update[‘is_fp‘] = 0;
            $update[‘ownercs‘] = 0;
        } else if ($info[‘Baomings‘][‘is_fp‘] == 1 && $info[‘Baomings‘][‘yixiang‘] != 1 && ($info[‘Baomings‘][‘status‘] == 2 || $info[‘Baomings‘][‘invalid‘] == 1) && $info[‘Baomings‘][‘is_qy‘] == 0) { 
            # 无效
            $quest = true;
            $content = "由业主主动报名,从无效管理重置到报名管理中";
            $update[‘is_fp‘] = 0;
            $update[‘ownercs‘] = 0;
        } else if ($info[‘Baomings‘][‘is_qy‘] == 1) {
            $quest = false;
        } else {
            return json_encode(array(‘status‘ => true, ‘baoming_id‘ => $info[‘Baomings‘][‘id‘]));
        }

        if ($quest == true) {
            $update[‘is_conect‘] = 0;
            $update[‘mes_bak‘] = 1;
            $update[‘delay‘] = 0;
            $update[‘status‘] = 0;
            $update[‘status_trace‘] = 1;
            $update[‘invalid‘] = 0;
            $update[‘yixiang‘] = 0;
            $update[‘allow‘] = 0;
            $update[‘is_qy‘] = 0;
            $update[‘decoration‘] = 0;
            $update[‘reset_time‘] = "‘" . date("Y-m-d H:i:s") . "‘";
            $update[‘reject_allot_status‘] = 0;
            $update[‘reject_over_status‘] = 0;
            $update[‘reject_invalid_status‘] = 0;
            $update[‘can_not_go‘] = 0;
            $update[‘can_not_cause‘] = null;

            $this->Baomings->updateAll($update, array(‘Baomings.id‘ => $info[‘Baomings‘][‘id‘]));

            $this->RejectLogs->updateAll(array(‘reset_tiger‘ => 1, ‘reset_time‘ => "‘" . date("Y-m-d H:i:s") . "‘"), array(‘baoming_id‘ => $info[‘Baomings‘][‘id‘], ‘type‘ => array(1,4,5), ‘ex_status‘ => 1));

            $this->ResetLogs->save(array(‘baoming_id‘ => $info[‘Baomings‘][‘id‘], ‘content‘ => $content, ‘create_time‘ => date("Y-m-d H:i:s"), ‘cs_id‘ => 0));
        }

        // echo $content . "<br />";
        return json_encode(array(‘status‘ => $quest, ‘baoming_id‘ => !empty($info[‘Baomings‘][‘id‘]) ? $info[‘Baomings‘][‘id‘] : 0));
    }

    /*
     *@数据返回类型
     *@par $arr 需要返回的数据(以数组的形式)
     *@par $return_type true /  false
     *@更新于 2017-04-24
     */
    private function bm_returns($arr, $return_type)
    {
        $return = json_encode($arr);
        if($return_type){

            return $return;
        }
        die($return);
    }

    /*
    * 记录是否是广告推广过来的用户
    * $putin 渠道来源
    */
    protected function cake24_set_unionOrigin($putin,$is_app=false){
        if(!$_POST || !empty($is_app)){
            if(!strpos($_SERVER[‘QUERY_STRING‘], ‘.png‘)&&!strpos($_SERVER[‘QUERY_STRING‘], ‘.jpg‘)&&!strpos($_SERVER[‘QUERY_STRING‘], ‘.gif‘)&&!strpos($_SERVER[‘QUERY_STRING‘], ‘.css‘)){
                $is_origin=1;//广告
                if( empty($putin) ){
                    $is_origin=2;//非广告
                    if( strpos($_SERVER[‘HTTP_REFERER‘],‘youjuke‘) && (strpos($_SERVER[‘HTTP_REFERER‘],‘putin‘) || strpos($_SERVER[‘HTTP_REFERER‘],‘bdjj‘)) ){
                        $is_origin=1;//广告
                    }
                }
                //$this->Cookie->write(‘unionOrigin‘, $is_origin, false, 86400);
                setcookie(‘unionOrigin‘,$is_origin,time()+86400,‘/‘);
            }
            
        }
    }

    /*
     *@更新服务咨询数据信息
     *@par $baoming_id 报名id
     *@author dtz 2017-03-28
     *注:如果已报名,未报名服务,这里不作处理;如果已报名和服务,对SERVICE表处理;如果仅新报名,按原有逻辑处理
     *处理逻辑为将baoming_service表中out_time改为当前一次的报名时间,out_type改为3,out_csid=0
     *@author dtz 2017-03-21
     *@更新于 2017-03-28
     */
    private function _cake24_check_service($baoming_id){

        if(!empty($baoming_id)){

            $conditions = [‘baoming_id‘ => $baoming_id];
            
            $serviceData = $this->BaomingService->find(‘first‘, [

                ‘conditions‘ => $conditions
            ]);

            if($serviceData[‘BaomingService‘][‘out_type‘] == 0){

                $up_service_data = [

                    ‘out_csid‘ => 0,
                    ‘out_type‘ => 3,
                    ‘out_time‘ => time()
                ];

                $this->BaomingService->updateAll($up_service_data, $conditions);
            }

        }
    }

    /** 
      * @服务咨询报名入口
      * @par $return true 返回插入数据的id false 不返回插入的id
      * @return  $baoming_id (报名id) 
      * @author dtz 2017-03-21
      * @更新于 2017-03-28
      * @注:曾经在服务咨询(zx_fuwu = 1)报过名的,并且out_type = 0的,除了zx_tuijian改为1以外,将baoming_service表中out_time改为当前一次的报名时间,out_type改为3,out_csid=0
      **/
    public function cake24_commit($return = false){

        unset($service_data);
        $baoming_id = $this->cake24_commit2(true, false, false, true);//服务咨询
        if(!empty($baoming_id)){

            //判断服务咨询报名是否存在
            $service_exist = $this->BaomingService->find(‘first‘, [

                ‘conditions‘ => [‘baoming_id‘ => $baoming_id]
            ]);

            if(!$service_exist){
                $service_data = [‘baoming_id‘ => $baoming_id, ‘last_plate‘ => 0, ‘create_time‘ => time()];

                //判断当前报名是否分配过客服(如果分配过需要baoming_service.is_fp_genzong 为1)
                $genzong_con = [‘baoming_id‘ => $baoming_id, ‘type‘ => 1, ‘f_cs !=‘ => NULL];
                $genzong_exist = $this->GenzongCsfp->find(‘count‘, [ ‘conditions‘ => $genzong_con ]);
                if($genzong_exist){

                    $service_data[‘is_fp_genzong‘] = 1;
                }


                if($this->BaomingService->save($service_data)){

                    //更新服务咨询数据信息
                    $this->_cake24_check_service($baoming_id);

                    //报名成功
                    if($return){

                        return $baoming_id;
                    }else{

                        $this->bm_returns( array(‘code‘ => 10200, ‘str‘ => ‘报名成功!‘), false );
                    }
                    
                }else{

                    //报名错误
                    $this->bm_returns( array(‘code‘ => 10400, ‘str‘ => ‘报名失败,请重试!‘), false );
                }
            }else{

                
                $this->bm_returns( array(‘code‘ => 10200, ‘str‘ => ‘您已报名!‘), false );
            }
        }else{

            //报名错误
            $this->bm_returns( array(‘code‘ => 10400, ‘str‘ => ‘报名失败,请重试!‘), false );
        }
    }

    /*
     * 将JSONP形式的报名数据提交统一改为内部调用
     * 并在cake24项目下新增报名数据录入接口
     * create date 2015-11-16
     * 更新于 2017-03-24
     * $is_zhuangxiu  true 其他装修报名 false  建材馆报名  
     * $return_type 返回类型
     * $service false(不是服务咨询报名),  true (是服务咨询报名)
     * app 过来的报名 统一添加参数 $REQUEST[‘find_cookies‘] = 1
     */
    public function cake24_commit2($return = false, $is_zhuangxiu = true, $return_type = false, $service = false) {
        $this->layout = false;
        $this->autoRender = false;

        $REQUEST = array_merge($_GET, $_POST);

        if (!empty($REQUEST[‘callback‘]) && preg_match(‘/^\w+$/‘, $REQUEST[‘callback‘])) {
            $callback = $REQUEST[‘callback‘];
        }

        $data = array();

        $require = array(‘name‘, ‘mobile‘);
        foreach ($require as $value) {
            
            if(empty($REQUEST[$value])){//判断关键数据是否为空,为空则返回错误

                $str = $value == ‘name‘ ? ‘姓名‘:‘手机号‘;

                $this->bm_returns( array(‘code‘ => 10402, ‘str‘ => $str.‘不能为空!‘, ‘data‘ => array()), $return_type );
            }

            $func = ‘cake24_ck‘ . $value;
            if($value == ‘mobile‘) {
                
                //U_ENCRYPT 作用是对手机进行加密处理
                $foo = !$data[$value] = $this->U_ENCRYPT($this->$func($REQUEST[$value]));
            }else{
                
                //对姓名进行过滤,去除掉特殊字符和如果姓名为空则标注为NONAME
                $foo = !$data[$value] = $this->$func($REQUEST[$value]);
            }
            if (empty($REQUEST[$value]) || !method_exists($this, $func) || $foo) {
                
                $this->bm_returns( array(‘code‘ => 10403, ‘str‘ => ‘提交错误,请不要填写特殊字符!‘, ‘data‘ => array()),$return_type );
            }
        }

        //对字段数据进行判断
        $fields = array(‘area‘, ‘budget‘, ‘loupan‘, ‘roomtype‘, ‘zxstyle‘, ‘zx_fangshi‘, ‘address‘, ‘bm_bak‘, ‘zxtype‘, ‘utm_page‘, ‘sex‘, ‘decoration_type‘, ‘district_id‘, ‘c_preferences‘,‘zhuangixu_status‘,‘c_experience‘);

        foreach ($REQUEST as $key => $value) {
            if (!in_array($key, $fields) || strlen($value) == 0) {
                continue;
            }

            $func = ‘cake24_ck‘ . $key;
            if (!method_exists($this, $func) || !$data[$key] = $this->$func($value)) {
                continue;
                
                $this->bm_returns( array(‘code‘ => 10403, ‘str‘ => ‘字段数据错误!‘, ‘data‘ => array(‘field‘ => $key)),$return_type );
            }
        }

        
        //判断是否有多个ip
        $ips = $this->cake24_getIP();
        if(strpos($ips, ‘,‘)){
            
            $explode = explode(‘,‘, $ips);
            $ips = trim($explode[0]);
        }

        //屏蔽掉局域网、外测和系统配置ip
        //true 当前ip需要屏蔽 , false 当前ip不需要屏蔽
        $ignore = $this->cake24_ignore_ip($ips);

        if( !$ignore ){//不需要屏蔽的ip,但不能重复报名超过10次
            
            $client_ip_count = $this->Baomings->find(‘count‘,array(
                    ‘conditions‘=>array(
                        ‘client_ip‘=>$ips,
                        ‘DATE_FORMAT(addtime,\‘%Y-%m-%d\‘)‘=>date(‘Y-m-d‘)
                    )
                )
            );
            
            //同一个ip下报名次数不能超过10次
            if( $client_ip_count >= 10 ){
                
                $this->bm_returns( array(‘code‘ => 10400, ‘str‘ => ‘报名次数过多,请稍后再试!‘, ‘data‘ => array(‘id‘ => 0)),$return_type );
            }
        }
        

        $city_id = (int)$REQUEST[‘city_id‘] ? (int)$REQUEST[‘city_id‘] : 0;
        $getcity = $this->cake24_getProvinces($city_id);
        $getcityid = $getcity[‘Cities‘][‘id‘] ? $getcity[‘Cities‘][‘id‘] : 72;
        $getprovinceid = $getcity[‘Cities‘][‘provinces_id‘] ? $getcity[‘Cities‘][‘provinces_id‘] : 9;

        $data[‘bm_laiyuan‘] = ‘baoming‘;
        $data[‘zx_jiaju‘] = !empty($REQUEST[‘zx_jiaju‘]) ? (int)$REQUEST[‘zx_jiaju‘] : 0;
        $data[‘addtime‘] = date(‘Y-m-d H:i:s‘);
        $data[‘mes_bak‘] = 1;
        $data[‘province_id‘] = $getprovinceid;
        $data[‘city_id‘] = $getcityid;
        $data[‘client_ip‘] = $ips;

        $union = array_key_exists(‘unionKey‘, $REQUEST) ? $REQUEST[‘unionKey‘] : $this->Cookie->read(‘unionKey‘);
        $name = ‘BM‘;
        if (!empty($union)) {
            
            list($name, $child) = explode(‘_‘, $union, 2);
            $name = strtoupper($name);

            //对推广渠道过滤特殊字符
            $name = $this->cake24_replace_text( $name );
            $child = $this->cake24_replace_text( $child );

            $data[‘from_union‘] = $name;
            $data[‘from_child‘] = $child;
            $data[‘newest_child‘] = $child;
            $this->loadModel("SemSources");
            $bm_laiyuan = $this->SemSources->field( ‘j_name‘ ,array(‘l_name‘=>$name,‘state‘=>0) );
            if( $bm_laiyuan ){
                
                if( $name == ‘LT‘ ){
                    
                    $data[‘from_child‘] = str_replace(‘+‘, ‘|‘, $child);
                }
                $data[‘bm_laiyuan‘] = $bm_laiyuan;
            }else{
                
                $data[‘bm_laiyuan‘] = ‘sem1‘;
            }             
        }

        if( in_array($name, [‘BDXK2‘,‘BDXK‘]) ){
            $data[‘is_origin‘] = 0;
        }else{
            //记录是否是广告推广过来的用户
            //app 过来的报名 统一添加参数 $REQUEST[‘find_cookies‘] = 1
            $data[‘is_origin‘] = $REQUEST[‘find_cookies‘] == 1 ? 0 : ($_COOKIE[‘unionOrigin‘] == 1 ? 0 : 1 );
            
            //自然流量(seo)报名来源记录
            if($data[‘is_origin‘]==1){
                $data[‘bm_laiyuan‘] = ‘baoming‘;
                $data[‘from_union‘] = NULL;
                $data[‘from_child‘] = ‘1‘;
            }
        }

        //按断客户端是否都是手机
        $form = $this->cake24_is_mobile();
        if ($form) {
            $data[‘detail_ly‘] = ‘mobile‘;
        } else {
            $data[‘detail_ly‘] = ‘pc‘;
        }
        

        $baomingModel = $this->Baomings->find(‘first‘, array(
                ‘conditions‘ => array(‘Baomings.mobile‘=>$data[‘mobile‘]), 
                ‘fields‘ => array(‘Baomings.id‘, ‘Baomings.zx_tuijian‘,‘Baomings.zx_jiaju‘,‘BaomingsPlus.periods‘, ‘zx_fuwu‘),
                ‘order‘ => array(‘Baomings.id desc‘)
            )
        );
        
        if(!$is_zhuangxiu && !$service){//建材馆报名非服务咨询
            
            $data[‘zx_tuijian‘] = 0;
            $data[‘zx_jiaju‘] = 1;

        }elseif($is_zhuangxiu && !$service){//装修非服务咨询
            $data[‘zx_tuijian‘] = 1;
            $data[‘zx_jiaju‘] = 0;

        }elseif ($service) {//服务咨询
            $data[‘zx_tuijian‘] = 0;
            $data[‘zx_jiaju‘] = 0;
            $data[‘zx_fuwu‘] = 1;
        }

        //$cake24_sjtest = ‘201603‘;//$this->cake24_sjtest();//期数
        $cake24_sjtest = $this->JcSetPeriod->field(‘periods‘,array(‘is_set‘=>1),‘JcSetPeriod.id desc‘);

        //没有数据添加  否则重置或修改
        if( !$baomingModel ){
            
            if (!$this->Baomings->save($data)) {        
                
                $this->bm_returns( array(‘code‘ => 10500, ‘str‘ => ‘错误提交!‘, ‘data‘ => array()),$return_type );
            }
            $this->U_SAVE_BM($this->Baomings->id, $REQUEST[‘mobile‘]);
            $this->BaomingsPlus->updateAll(array(‘periods‘=>"‘".$cake24_sjtest."‘",‘material_addtime‘=>time()),array(‘BaomingsPlus.baoming_id‘=>$this->Baomings->id));
        }else{
            
            $Baomings_id = $baomingModel[‘Baomings‘][‘id‘];
            
            //是建材特卖馆报名并且非服务咨询报名
            if(!$is_zhuangxiu && !$service){
                
                //不是同期的添加数据  否则修改参数   (取消期数报名)
                if($baomingModel[‘BaomingsPlus‘][‘periods‘] != $cake24_sjtest){
                    
                    $bm_updata = array(
                        ‘zx_jiaju‘ => 1,
                        ‘utm_page‘=>"‘".$data[‘utm_page‘]."‘",
                        ‘newest_child‘=>"‘".$data[‘newest_child‘]."‘",
                        ‘is_origin‘ => $data[‘is_origin‘]
                    );
                    $this->Baomings->updateAll( $bm_updata ,array(‘Baomings.id‘=>$Baomings_id));
                    //20170406 是建材报名 重置无建材活动需求字段BaomingPlus.unjchd 改为 0  连
                    $this->BaomingsPlus->updateAll(array(‘periods‘=>"‘".$cake24_sjtest."‘",‘material_addtime‘=>time(),‘unjchd‘=>0),array(‘BaomingsPlus.baoming_id‘=>$Baomings_id)); 
                    $this->Baomings->id = $Baomings_id;
                }else{
                    
                    //报名数据之前 zx_jiaju不等于1的
                    if($baomingModel[‘Baomings‘][‘zx_jiaju‘] != 1){
                        
                        $arrs[‘zx_jiaju‘] = 1;
                        //$arrs[‘from_child‘] = "‘".$data[‘from_child‘]."‘";
                        //$arrs[‘bm_laiyuan‘] = "‘".$data[‘bm_laiyuan‘]."‘";
                        $arrs[‘utm_page‘] = "‘".$data[‘utm_page‘]."‘";
                        $arrs[‘newest_child‘] = "‘".$data[‘newest_child‘]."‘";
                        $arrs[‘is_origin‘] = $data[‘is_origin‘];
                        $this->Baomings->updateAll($arrs,array(‘Baomings.id‘=>$Baomings_id));
                        $this->BaomingsPlus->updateAll(array(‘material_addtime‘=>time()),array(‘baoming_id‘=>$Baomings_id));
                        $this->Baomings->id = $Baomings_id;    
                    }else{
                        
                        //$arrs[‘from_child‘] = "‘".$data[‘from_child‘]."‘";
                        $arrs[‘utm_page‘] = "‘".$data[‘utm_page‘]."‘";
                        $arrs[‘newest_child‘] = "‘".$data[‘newest_child‘]."‘";
                        $arrs[‘is_origin‘] = $data[‘is_origin‘];
                        $this->Baomings->updateAll($arrs,array(‘Baomings.id‘=>$Baomings_id));
                        $this->Baomings->id = $Baomings_id;
                        $this->bm_returns( array(‘code‘ => 10400, ‘str‘ => ‘您已报名!‘, ‘data‘ => array()),$return_type );
                    }    
                }    
                
            //属于装修业务重置逻辑
            }elseif($is_zhuangxiu && !$service){  
                
                //更新服务咨询数据信息
                $this->_cake24_check_service($Baomings_id);

                //判断是否是有装修报名数据 调重置方法 否则更新
                if($baomingModel[‘Baomings‘][‘zx_tuijian‘] == 1){
                    
                    $json_decode = json_decode($this->cake24_ck_baoming_reset($data[‘mobile‘]),true);
                    $this->Baomings->id = $json_decode[‘baoming_id‘];
                }else{
                    
                    $arrs[‘zx_tuijian‘] = 1;
                    //$arrs[‘from_child‘] = "‘".$data[‘from_child‘]."‘";
                    //$arrs[‘bm_laiyuan‘] = "‘".$data[‘bm_laiyuan‘]."‘";
                    $this->Baomings->id = $Baomings_id;   
                }
                $arrs[‘utm_page‘] = "‘".$data[‘utm_page‘]."‘";
                $arrs[‘newest_child‘] = "‘".$data[‘newest_child‘]."‘";
                $arrs[‘is_origin‘] = $data[‘is_origin‘];
                $this->Baomings->updateAll($arrs,array(‘Baomings.id‘=>$this->Baomings->id));
            }elseif($service) {//服务咨询报名重置
                
                $arrs[‘zx_fuwu‘] = 1;
                $arrs[‘utm_page‘] = "‘".$data[‘utm_page‘]."‘";
                $arrs[‘newest_child‘] = "‘".$data[‘newest_child‘]."‘";
                $arrs[‘is_origin‘] = $data[‘is_origin‘];
                $this->Baomings->id = $Baomings_id;
                $this->Baomings->updateAll($arrs,array(‘Baomings.id‘=>$this->Baomings->id));
            }
                      
        }
        

        //报名页面来源过滤掉特殊字符
        if (preg_match(‘/([\w\x{4e00}-\x{9fa5}]+)-([\w\x{4e00}-\x{9fa5}]+)-([\w\x{4e00}-\x{9fa5}]+)-([\w\x{4e00}-\x{9fa5}]+)/u‘, $data[‘utm_page‘], $matches)) {
            list($channel, $page, $type, $name) = $this->Sources->setSources($matches[1], $matches[2], $matches[3], $matches[4]);
            $sources = array(‘channel_id‘ => $channel, ‘page_id‘ => $page, ‘type_id‘ => $type, ‘name_id‘ => $name, ‘baoming_id‘ => $this->Baomings->id, ‘addtime‘ => date(‘Y-m-d H:i:s‘));
            $this->BaomingSources->save($sources);
        }

        # 全站弹窗
        setcookie(‘pop_youjuke‘, 1, time() + 30 * 24 * 60 * 60, ‘/‘, ‘.‘.PRIMARY_DOMAIN);


        if($return){return $this->Baomings->id;}
        if (!empty($callback)) {
            
            die($callback . ‘(‘ . json_encode(array(‘code‘ => 10200, ‘str‘ => ‘提交成功!‘, ‘data‘ => array(‘id‘ => $this->Baomings->id, ‘cnzz‘ => ‘http://fuwu.‘ . PRIMARY_DOMAIN . ‘/index/bmResult?utm=‘ . $name))) . ‘)‘);
        } else {
            
            $this->bm_returns( array(‘code‘ => 10200, ‘str‘ => ‘提交成功!‘, ‘data‘ => array(‘id‘ => $this->Baomings->id)),$return_type );
            
        }
    }

    private function cake24_is_Baomings_chongzhi($data,$repeat)
    {
        $json_decode = json_decode($this->cake24_ck_baoming_reset($data[‘mobile‘]),true);
        //返回false 作为装修报名插入数据库 否则获取返回的报名id
        if(!$json_decode[‘status‘])
        {
            if (!$this->Baomings->save($data)) 
            {                     
                die(json_encode(array(‘code‘ => 10500, ‘str‘ => ‘错误提交!‘, ‘data‘ => array())));
            }
        }
        else
        {
            //建材报名
            if(!$repeat)
            {
                $arrs = array(‘zx_jiaju‘=>1);    
            }
            else
            {
                $arrs = array(‘zx_tuijian‘=>1);
            }
            $arrs[‘from_child‘] = "‘".$data[‘from_child‘]."‘";
            $arrs[‘bm_laiyuan‘] = "‘".$data[‘bm_laiyuan‘]."‘";
            $arrs[‘utm_page‘] = "‘".$data[‘utm_page‘]."‘";
            $this->Baomings->updateAll($arrs,array(‘Baomings.id‘=>$json_decode[‘baoming_id‘]));
            $this->Baomings->id = $json_decode[‘baoming_id‘];
        }
        return $this->Baomings->id;
    }


    //姓名(名称)格式判断
    private function cake24_ckname($value) {
        $value = trim($value);
        $value = $this->cake24_replace_specialChar($value);//过滤掉特殊字符
        if (!empty($value)) {
            return $value;
        }else{

            return ‘NONAME‘;//过滤掉特殊字符后,如果为空则赋值默认的值
        }
    }

    //手机号格式判断
    private function cake24_ckmobile($value) {
        if (preg_match(‘/^[1][3,4,5,7,8][0-9]{9}$/‘, $value)) {
            return $value;
        }
        return false;
    }

    //报名面积格式判断
    private function cake24_ckarea($value) {
        if (preg_match(‘/^\d{1,4}$/‘, $value)) {
            return $value;
        }
        return false;
    }

    //报名预算格式判断
    private function cake24_ckbudget($value) {
        if (preg_match(‘/^\d{1,4}(\.\d{1,4})?$/‘, $value)) {
            return $value;
        }
        return false;
    }

    //报名地址格式判断(去除掉特殊字符)
    private function cake24_ckaddress($value) {
        return strip_tags($value);
    }

    //报名楼盘格式判断(去除掉特殊字符)
    private function cake24_ckloupan($value) {
        return strip_tags($value);
    }

    //报名户型格式判断
    private function cake24_ckroomtype($value) {
        return is_numeric($value) ? $value : false;
    }

    private function cake24_ckzxstyle($value) {
        return is_numeric($value) ? $value : false;
    }

    private function cake24_ckzx_fangshi($value) {
        return $value;
        return is_numeric($value) ? $value : false;
    }

    private function cake24_ckbm_bak($value) {
        return strip_tags($value);
    }

    private function cake24_ckzxtype($value) {
        return is_numeric($value) ? $value : false;
    }

    //报名页面来源格式判断
    private function cake24_ckutm_page($value) {
        
        return $this->cake24_replace_text( $value );
    }

    //报名姓名判断
    private function cake24_cksex($value) {
        return in_array($value, array(1, 2)) ? $value : 2;
    }

    private function cake24_ckdecoration_type($value) {
        return is_numeric($value) ? $value : false;
    }

    //报名区域判断
    private function cake24_ckdistrict_id($value) {
        return is_numeric($value) ? $value : 717;
    }

    //报名偏好判断
    private function cake24_ckc_preferences($value) {
        return is_numeric($value) ? $value : false;
    }

    //报名装修状态判断
    private function cake24_ckzhuangixu_status($value) {
        return is_numeric($value) ? $value : false;
    }

    private function cake24_ckc_experience($value) {
        return is_numeric($value) ? $value : false;
    }

    //替换敏感字符
    protected function cake24_replace_text($text)
    {
        $text = str_replace(‘\\‘, ‘‘, $text);
        $text = preg_replace(‘/\/|\"|\‘|[><()=;#!@#$%^&*?.+|]|(and)|(or)/i‘, ‘‘, $text);
        return $text;
    }

    /*
    *去除掉特殊字符(新)
    *date 2017-01-05
    */
    protected function cake24_replace_specialChar($strParam){
        
        return preg_replace("/[^\x{4e00}-\x{9fa5}a-zA-Z0-9]/iu",‘‘,$strParam);
    }

    //判断是否是电脑登录,还是手机登录
    public function cake24_is_mobile() {
        $user_agent = $_SERVER[‘HTTP_USER_AGENT‘];
        $mobile_agents = array("240x320", "acer", "acoon", "acs-", "abacho", "ahong", "airness", "alcatel", "amoi",
            "android", "anywhereyougo.com", "applewebkit/525", "applewebkit/532", "asus", "audio",
            "au-mic", "avantogo", "becker", "benq", "bilbo", "bird", "blackberry", "blazer", "bleu",
            "cdm-", "compal", "coolpad", "danger", "dbtel", "dopod", "elaine", "eric", "etouch", "fly ",
            "fly_", "fly-", "go.web", "goodaccess", "gradiente", "grundig", "haier", "hedy", "hitachi",
            "htc", "huawei", "hutchison", "inno", "ipad", "ipaq", "iphone", "ipod", "jbrowser", "kddi",
            "kgt", "kwc", "lenovo", "lg ", "lg2", "lg3", "lg4", "lg5", "lg7", "lg8", "lg9", "lg-", "lge-", "lge9", "longcos", "maemo",
            "mercator", "meridian", "micromax", "midp", "mini", "mitsu", "mmm", "mmp", "mobi", "mot-",
            "moto", "nec-", "netfront", "newgen", "nexian", "nf-browser", "nintendo", "nitro", "nokia",
            "nook", "novarra", "obigo", "palm", "panasonic", "pantech", "philips", "phone", "pg-",
            "playstation", "pocket", "pt-", "qc-", "qtek", "rover", "sagem", "sama", "samu", "sanyo",
            "samsung", "sch-", "scooter", "sec-", "sendo", "sgh-", "sharp", "siemens", "sie-", "softbank",
            "sony", "spice", "sprint", "spv", "symbian", "tablet", "talkabout", "tcl-", "teleca", "telit",
            "tianyu", "tim-", "toshiba", "tsm", "up.browser", "utec", "utstar", "verykool", "virgin",
            "vk-", "voda", "voxtel", "vx", "wap", "wellco", "wig browser", "wii", "windows ce",
            "wireless", "xda", "xde", "zte", "MicroMessenger");
        $is_mobile = false;
        foreach ($mobile_agents as $device) {
            if (stristr($user_agent, $device)) {
                $is_mobile = true;
                break;
            }
        }
        return $is_mobile;
    }

    //获取省信息
    public function cake24_getProvinces($cityid){
      
    if(!$cityid)
      {
        $getCity = $this->cake24_getCity( $this->cake24_getIP() );
        $city = in_array($getCity[‘city‘], array(‘上海‘,‘无锡‘)) ? $getCity[‘city‘]  : ‘上海‘;
        $conditions = array(‘Cities.name‘=>$city);
      }
      else
      {
        $conditions = array(‘Cities.id‘=>$cityid);
      }
      $Cities = $this->Cities->find(‘all‘,array(‘conditions‘=>$conditions));
      return $Cities[0];
    }

    public function cake24_getCity($ip){
        
        $this->layout = false;
        $this->autoRender = false;
        //$url="http://ip.taobao.com/service/getIpInfo.php?ip=".$ip;
        $url="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=".$ip;
        $ip = $this->cake24_curl_get($url);
        $ip = json_decode($ip,true);
        if($ip[‘ret‘] == -1)
        {
            return false;
        }
        return $ip;
        
    }

    //跨域获取信息
    public function cake24_curl_get($url){
        
        $to=2;

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_TIMEOUT, $to);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_HEADER, 0);
        $data = curl_exec($curl);
        curl_close($curl);
        return $data;
    }

    //获取用户真实IP
    public function cake24_getIP() {
        if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
            $ip = getenv("HTTP_CLIENT_IP");
        else
            if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
                $ip = getenv("HTTP_X_FORWARDED_FOR");
            else
                if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
                    $ip = getenv("REMOTE_ADDR");
                else
                    if (isset ($_SERVER[‘REMOTE_ADDR‘]) && $_SERVER[‘REMOTE_ADDR‘] && strcasecmp($_SERVER[‘REMOTE_ADDR‘], "unknown"))
                        $ip = $_SERVER[‘REMOTE_ADDR‘];
                    else
                        $ip = "unknown";
        return ($ip);
    }


    

    #发送账户短信
    public function cake24_send_message($data){
        
        $mobile = $data[‘mobile‘];
        $content = $data[‘content‘];
        $source = $data[‘source‘];

        $times = $data[‘times‘] ? $data[‘times‘] : null;
        if (empty($mobile) || empty($content)) {
            return false;
        }

        if (empty($times)) {
            $times = 1;
        }

        $post[‘mobile‘] = is_array($mobile) ? join(‘,‘, $mobile) : $mobile;
        $post[‘content‘] = $content;
        $post[‘source‘] = $source;

        $sms_api = ‘http://sms.youjuke.com/sms/send_sms_api‘;


        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $sms_api);
        curl_setopt ( $ch, CURLOPT_POST, 1 );
        curl_setopt ( $ch, CURLOPT_HEADER, 0 );
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post );

        $output = curl_exec($ch);
        curl_close($ch);

        if (trim($output) == "失败" && $times <= 2) {
            $data[‘times‘] = !empty($data[‘times‘]) ? $data[‘times‘] + 1 : 1;
            $this->cake24_send_message($data);
        } else {
            //return true;
            return ‘成功‘;
        }

        //return false;
        return ‘失败‘;
    }

    //通过手机号查询手机号码的归属地信息 (已失效)
    public function cake24_phonesearch2($mobile){

        $ch = curl_init();
        $url = ‘http://apis.baidu.com/chazhao/mobilesearch/phonesearch?phone=‘.$mobile;
        $header = array(
            ‘apikey: c3aadd615ae4b6bfcbf8e4afc503fab7‘,
        );
        // 添加apikey到header
        curl_setopt($ch, CURLOPT_HTTPHEADER  , $header);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // 执行HTTP请求
        curl_setopt($ch , CURLOPT_URL , $url);
        $res = curl_exec($ch);

        return json_decode($res, TRUE);
    }

    //通过手机号查询手机号码的归属地信息
    public function cake24_phonesearch($mobile){

        $url = ‘http://sj.apidata.cn/?mobile=‘.$mobile;
        $ch = curl_init();
        // 执行HTTP请求
        curl_setopt($ch, CURLOPT_HTTPHEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // 执行HTTP请求
        curl_setopt($ch , CURLOPT_URL , $url);
        $res = curl_exec($ch); 

        curl_close($ch);
        $res = json_decode($res, TRUE);
        $data[‘error‘] = $res[‘status‘] == 1 ? 0 : 1;
        $data[‘message‘] = $res[‘message‘];
        $data[‘data‘] = $res[‘data‘];
        return $data;
    }

    //通过ip查询ip的归属地信息
    public function cake24_ipsearch($ip){

        //判断是否是合法的ip
        if(!filter_var($ip, FILTER_VALIDATE_IP)){return NULL;}
        
        $ch = curl_init();
        $url = ‘http://apis.baidu.com/apistore/iplookupservice/iplookup?ip=‘.$ip;
        $header = array(
            ‘apikey: c3aadd615ae4b6bfcbf8e4afc503fab7‘,
        );
        // 添加apikey到header
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // 执行HTTP请求
        curl_setopt($ch , CURLOPT_URL , $url);
        $res = curl_exec($ch);

        return json_decode($res, TRUE);
    }

    /*
     * 判断业主报名的地址,目前公司自支持上海和江苏地区
     * 如果报名的来源地址为非上海和江苏的 则录入报名里 zx_tuijian =0 反之则为 1
     */

    public function cake24_getbaoming_area($mobile, $ip=‘‘){

        //获取报名信息的ip地址
        if(empty($ip)){$ip = $this->cake24_getIP();}

        $ipAddress = $this->cake24_ipsearch($ip);
        $phoneAddress = $this->cake24_phonesearch($mobile);

        $ipresult = in_array($ipAddress[‘province‘], array(‘上海‘, ‘江苏‘));
        $mobileresult = in_array($phoneAddress[‘data‘][‘province‘], array(‘上海‘, ‘江苏‘));

        if($ipresult || $mobileresult){


            return 1;
        }else{

            return 0;
        }

    }

    //通过经纬度获取具体的地理位置
    public function cake24_getLocation($x, $y){

        $ch = curl_init();
        $url = ‘http://apis.baidu.com/3023/geo/address?l=‘.$x.‘,‘.$y;
        
        $header = array(
            ‘apikey: c3aadd615ae4b6bfcbf8e4afc503fab7‘,
        );
        // 添加apikey到header
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // 执行HTTP请求
        curl_setopt($ch , CURLOPT_URL , $url);
        $res = curl_exec($ch);

        $addressData = json_decode($res, true);
        $admName = $addressData[‘addrList‘][0][‘admName‘];
        $locationArr = explode(‘,‘, $admName);
        return $locationArr;

    }

    /*
    * 通过经纬度获取具体的地理位置(新)
    * $x,$y 经纬度
    * date 2016-10-24
    */
    public function cake24_getAddress($x, $y){

        $ch = curl_init();
        $url = ‘http://api.haoservice.com/api/getLocationinfor?latlng=‘.$x.‘,‘.$y.‘&type=2&key=9fba1a9b3c804d8680125836b560ea64‘;
        
        
        // 执行HTTP请求
        curl_setopt($ch, CURLOPT_HTTPHEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // 执行HTTP请求
        curl_setopt($ch , CURLOPT_URL , $url);
        $res = curl_exec($ch);

        $res_arr = json_decode($res, true);
        $addressData = $res_arr[‘result‘];

        return $addressData;

    }

    /*
    * 获取广告信息
    * $c_id 广告所属分类id
    * $fields 要获取的字段信息
    */
    public function cake24_GetAdve($c_id,$fields=array(),$intro=‘‘,$model=‘‘,$limit=‘‘)
    {
        if( !$c_id )
        {
            return false;
        }
        $this->loadModel("ItvAttribute");
        $this->loadModel("FirmItvDetails");
        $this->loadModel("Firms");
        if( $model )
        {
            $this->ItvAttribute->useDbConfig = $this->FirmItvDetails->useDbConfig = $this->Firms->useDbConfig = ‘youjk‘;
        }
        $image_url = ‘http://index.img.youjuke.com‘;
        $times = date(‘Y-m-d‘);
        $fields = array_merge($fields,array(‘itv_balance‘,‘total_cost‘,‘firm_id‘,‘is_itv‘,‘end_time‘));
        $ItvAttribute = $this->ItvAttribute->findAsFirms(‘all‘,array(
                ‘conditions‘=>array(
                    ‘status‘=>1,
                    ‘delete‘=>0,
                    ‘c_id‘ => $c_id,
                    ‘OR‘ => array(
                        array(‘is_itv‘=>1,‘start_time <=‘=>$times,‘end_time >=‘=>$times),
                        array(‘is_itv‘=>2)
                    )
                ),
                ‘fields‘ => $fields,
                ‘order‘ => array(‘is_itv asc‘),
                ‘limit‘ => $limit
            )
        );
        $data = array();
        foreach ($ItvAttribute as $key => $val) 
        {
            $val_key = $val[‘ItvAttribute‘];
            //广告扣费
            if( $val_key[‘is_itv‘] == 1 )
            {
                $this->FirmItvDetails->clear();
                //广告费未支付的扣除费用
                $is_exists = $this->FirmItvDetails->find(‘count‘,array(
                        ‘conditions‘=>array(‘firm_id‘=>$val_key[‘firm_id‘],‘itv_id‘=>$val_key[‘id‘],‘renew_time‘=>$val_key[‘end_time‘])
                    )
                );
                if( !$is_exists )
                {
                    //余额充足扣除广告费并且显示 否则跳出不显示
                    if( $val_key[‘itv_balance‘] >= $val_key[‘total_cost‘] )
                    {
                        $dataSource = $this->FirmItvDetails->getDataSource();
                        $dataSource->begin();
                        $fee_time = date(‘Y-m-d H:i:s‘);
                        $det_data[‘firm_id‘] = $val_key[‘firm_id‘];
                        $det_data[‘itv_id‘] = $val_key[‘id‘];
                        $det_data[‘note‘] = $intro.‘-广告扣费‘;
                        $det_data[‘type‘] = 2;
                        $det_data[‘amount‘] = ‘-‘.$val_key[‘total_cost‘];
                        $det_data[‘add_time‘] = $fee_time;
                        $det_data[‘renew_time‘] = $val_key[‘end_time‘];
                        if( !$this->FirmItvDetails->save( $det_data ) )
                        {
                            $dataSource->rollback();
                        }
                        else
                        {
                            $this->Firms->updateAll( array(‘itv_balance‘=>‘`itv_balance`-‘.$val_key[‘total_cost‘]) , array(‘Firms.id‘=>$val_key[‘firm_id‘]) );
                            $dataSource->commit();
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                
            }
            $c_id = $val_key[‘c_id‘];
            $img = $image_url.‘/‘.$val_key[‘c_id‘].‘/‘;
            $val_key[‘image‘] = $img.$val_key[‘image‘];
            $val_key[‘firm_logo‘] = $img.$val_key[‘firm_logo‘];
            $data[ $c_id ][] = $val_key;
        }
        return $data;
    }


    /*
    * 根据面积 计算几室几厅
    */
    protected function cake24_baojia_budget($total_area,$info=false)
    {
        $woshi = array();
        $keting = array();
        $chufang = array();
        $weishengjian = array();
        $yangtai = array();
        /*
          建筑面积*0.8=实际总面积
          60平米以下:1室1厅(厨房卫生间阳台固定4平米。卧室/厅=1/1)
          61-90:2室1厅(厨房卫生间阳台固定6平米。卧室1/卧室2/厅=3/2/3)
          91-110:3室1厅(厨房卫生间阳台固定8平米。卧室1/卧室2/卧室3/厅=3/2/2/3)
          111-130:3室2厅(厨房卫生间阳台固定8平米。卧室1/卧室2/卧室3/厅1/厅2=3/2/2/3/2)
          131-150:3室2厅2卫(厨房阳台固定面积8平米,卫生间6平米。卧室1/卧室2/卧室3/厅1/厅2=3/2/2/3/2)
          151-180:4室2厅1厨2卫1阳(厨房10平米,卫生间6平米,阳台8平米。卧室1/卧室2/卧室3/卧室4/厅1/厅2=3/2/2/2/3/2)
         */
        $real_area = $total_area * 0.8;
        if ($total_area > 0 && $total_area < 60) {
            $woshi["woshi_61"] = round(($real_area - 4 * 3) / 2, 1);
            $keting[‘keting_21‘] = round(($real_area - 4 * 3) / 2, 1);
            $chufang[‘chufang_11‘] = 4;
            $weishengjian[‘weishengjian_31‘] = 4;
            $yangtai[‘yangtai_31‘] = 4;
        } else if ($total_area >= 60 && $total_area < 90) {
            $woshi["woshi_61"] = round(($real_area - 6 * 3) * 3 / 8, 1);
            $woshi["woshi_62"] = round(($real_area - 6 * 3) * 2 / 8, 1);
            $keting[‘keting_21‘] = round(($real_area - 6 * 3) * 3 / 8, 1);
            $chufang[‘chufang_11‘] = 6;
            $weishengjian[‘weishengjian_31‘] = 6;
            $yangtai[‘yangtai_31‘] = 6;
        } else if ($total_area >= 90 && $total_area < 110) {
            $woshi["woshi_61"] = round(($real_area - 6 * 3) * 3 / 10, 1);
            $woshi["woshi_62"] = round(($real_area - 6 * 3) * 2 / 10, 1);
            $woshi["woshi_63"] = round(($real_area - 6 * 3) * 2 / 10, 1);
            $keting[‘keting_21‘] = round(($real_area - 6 * 3) * 3 / 10, 1);
            $chufang[‘chufang_11‘] = 8;
            $weishengjian[‘weishengjian_31‘] = 8;
            $yangtai[‘yangtai_31‘] = 8;
        } else if ($total_area >= 110 && $total_area < 130) {
            $woshi["woshi_61"] = round(($real_area - 6 * 3) * 3 / 12, 1);
            $woshi["woshi_62"] = round(($real_area - 6 * 3) * 2 / 12, 1);
            $woshi["woshi_63"] = round(($real_area - 6 * 3) * 2 / 12, 1);
            $keting[‘keting_21‘] = round(($real_area - 6 * 3) * 3 / 12, 1);
            $keting[‘keting_22‘] = round(($real_area - 6 * 3) * 2 / 12, 1);
            $chufang[‘chufang_11‘] = 8;
            $weishengjian[‘weishengjian_31‘] = 8;
            $yangtai[‘yangtai_31‘] = 8;
        } else if ($total_area >= 130 && $total_area < 150) {
            $woshi["woshi_61"] = round(($real_area - 22) * 3 / 12, 1);
            $woshi["woshi_62"] = round(($real_area - 22) * 2 / 12, 1);
            $woshi["woshi_63"] = round(($real_area - 22) * 2 / 12, 1);
            $keting[‘keting_21‘] = round(($real_area - 22) * 3 / 12, 1);
            $keting[‘keting_22‘] = round(($real_area - 22) * 2 / 12, 1);
            $chufang[‘chufang_11‘] = 8;
            $weishengjian[‘weishengjian_31‘] = 6;
            $yangtai[‘yangtai_31‘] = 8;
        } else if ($total_area >= 150) {
            $woshi["woshi_61"] = round(($real_area - 24) * 3 / 14, 1);
            $woshi["woshi_62"] = round(($real_area - 24) * 2 / 14, 1);
            $woshi["woshi_63"] = round(($real_area - 24) * 2 / 14, 1);
            $woshi["woshi_64"] = round(($real_area - 24) * 2 / 14, 1);
            $keting[‘keting_21‘] = round(($real_area - 24) * 3 / 14, 1);
            $keting[‘keting_22‘] = round(($real_area - 24) * 2 / 14, 1);
            $chufang[‘chufang_11‘] = 10;
            $weishengjian[‘weishengjian_31‘] = 6;
            $yangtai[‘yangtai_31‘] = 8;
        }

        $budget = $woshi;
        $budget = array_merge($budget,$keting,$chufang,$weishengjian,$yangtai);
        $jine = $this->cake24_show_zxbj( $budget );
        if( $info )
        {
            return $jine;
        }
        return round($jine[‘total_price‘], 2);
    }

    protected function cake24_show_zxbj( $budget=array() ) 
    {

        $this->layout = false;
        //房屋基础信息
        $i_p = 1; //总倍数
        //客厅  2
        $arr_keting = array();
        if (!empty($budget[‘keting_21‘])) {
            $arr_keting[] = $budget[‘keting_21‘];
        }
        if (!empty($budget[‘keting_22‘])) {
            $arr_keting[] = $budget[‘keting_22‘];
        }
        $c_kt = count($arr_keting);
        //$keting[‘keting_21‘] = $budget[‘keting_21‘];
        //$keting[‘keting_22‘] = $budget[‘keting_22‘];

        //卧室  6
        $arr_woshi = array();
        if (!empty($budget[‘woshi_61‘])) {
            $arr_woshi[] = $budget[‘woshi_61‘];
        }
        if (!empty($budget[‘woshi_62‘])) {
            $arr_woshi[] = $budget[‘woshi_62‘];
        }
        if (!empty($budget[‘woshi_63‘])) {
            $arr_woshi[] = $budget[‘woshi_63‘];
        }
        if (!empty($budget[‘woshi_64‘])) {
            $arr_woshi[] = $budget[‘woshi_64‘];
        }
        if (!empty($budget[‘woshi_65‘])) {
            $arr_woshi[] = $budget[‘woshi_65‘];
        }
        if (!empty($budget[‘woshi_66‘])) {
            $arr_woshi[] = $budget[‘woshi_66‘];
        }
        $c_ws = count($arr_woshi);

        //公用卫生间   3
        $arr_weishengjian = array();
        if (!empty($budget[‘weishengjian_31‘])) {
            $arr_weishengjian[] = $budget[‘weishengjian_31‘];
        }
        if (!empty($budget[‘weishengjian_32‘])) {
            $arr_weishengjian[] = $budget[‘weishengjian_32‘];
        }
        if (!empty($budget[‘weishengjian_33‘])) {
            $arr_weishengjian[] = $budget[‘weishengjian_33‘];
        }
        $c_wsj = count($arr_weishengjian);


        //厨房   1
        $arr_chufang = array();
        if (!empty($budget[‘chufang_11‘])) {
            $arr_chufang[] = $budget[‘chufang_11‘];
        }
        $c_cf = count($arr_chufang);

        //厅阳台   3
        $arr_yangtai = array();
        if (!empty($budget[‘yangtai_31‘])) {
            $arr_yangtai[] = $budget[‘yangtai_31‘];
        }
        if (!empty($budget[‘yangtai_32‘])) {
            $arr_yangtai[] = $budget[‘yangtai_32‘];
        }
        if (!empty($budget[‘yangtai_33‘])) {
            $arr_yangtai[] = $budget[‘yangtai_33‘];
        }
        $c_yt = count($arr_yangtai);

        //总面积
        $arr_areas = array_merge($arr_keting, $arr_woshi, $arr_weishengjian, $arr_chufang, $arr_yangtai);
        $areas = array_sum($arr_areas);
        //总价
        $total_price = 0;

        //家装基础施工报价清单
        //客厅工程
        $kt_sy = 0; //js索引初始值
        //$kt_total = 0;//客厅总价
        foreach ($arr_keting as $k => $val) {
            $arr_kt[$k][‘sy‘] = $kt_sy + $k; //js索引
            //墙面铲除墙面腻子层 qm_nzh
            $arr_kt[$k][‘gcl‘][‘qm_nzh‘] = $val * 2.67;
            $arr_kt[$k][‘gcj‘][‘qm_nzh‘] = $arr_kt[$k][‘gcl‘][‘qm_nzh‘] * 7 * $i_p;
            $arr_kt[$k][‘price‘] += $arr_kt[$k][‘gcj‘][‘qm_nzh‘];
            //墙面滚胶 qm_gj
            $arr_kt[$k][‘gcl‘][‘qm_gj‘] = $val * 2.67;
            $arr_kt[$k][‘gcj‘][‘qm_gj‘] = $arr_kt[$k][‘gcl‘][‘qm_gj‘] * 6 * $i_p;
            $arr_kt[$k][‘price‘] += $arr_kt[$k][‘gcj‘][‘qm_gj‘];
            //墙面批腻子 qm_pnz
            $arr_kt[$k][‘gcl‘][‘qm_pnz‘] = $val * 2.67;
            $arr_kt[$k][‘gcj‘][‘qm_pnz‘] = $arr_kt[$k][‘gcl‘][‘qm_pnz‘] * 19 * $i_p;
            $arr_kt[$k][‘price‘] += $arr_kt[$k][‘gcj‘][‘qm_pnz‘];
            //墙面手刷乳胶漆 qm_rjq(多乐士金装五合一,一底两面)
            $arr_kt[$k][‘gcl‘][‘qm_rjq‘] = $val * 2.67;
            $arr_kt[$k][‘gcj‘][‘qm_rjq‘] = $arr_kt[$k][‘gcl‘][‘qm_rjq‘] * 17 * $i_p;
            $arr_kt[$k][‘price‘] += $arr_kt[$k][‘gcj‘][‘qm_rjq‘];
            //顶面普通木龙骨石膏板吊顶 dm_sgb
            $arr_kt[$k][‘gcl‘][‘dm_sgb‘] = $val * 0.4;
            $arr_kt[$k][‘gcj‘][‘dm_sgb‘] = $arr_kt[$k][‘gcl‘][‘dm_sgb‘] * 130 * $i_p;
            $arr_kt[$k][‘price‘] += $arr_kt[$k][‘gcj‘][‘dm_sgb‘];
            //顶面铲除顶面腻子层 dm_nzh
            $arr_kt[$k][‘gcl‘][‘dm_nzh‘] = $val * 1.33;
            $arr_kt[$k][‘gcj‘][‘dm_nzh‘] = $arr_kt[$k][‘gcl‘][‘dm_nzh‘] * 7 * $i_p;
            $arr_kt[$k][‘price‘] += $arr_kt[$k][‘gcj‘][‘dm_nzh‘];
            //顶面滚胶 dm_gj
            $arr_kt[$k][‘gcl‘][‘dm_gj‘] = $val * 1.33;
            $arr_kt[$k][‘gcj‘][‘dm_gj‘] = $arr_kt[$k][‘gcl‘][‘dm_gj‘] * 6 * $i_p;
            $arr_kt[$k][‘price‘] += $arr_kt[$k][‘gcj‘][‘dm_gj‘];
            //顶面批腻子 dm_pnz
            $arr_kt[$k][‘gcl‘][‘dm_pnz‘] = $val * 1.33;
            $arr_kt[$k][‘gcj‘][‘dm_pnz‘] = $arr_kt[$k][‘gcl‘][‘dm_pnz‘] * 19 * $i_p;
            $arr_kt[$k][‘price‘] += $arr_kt[$k][‘gcj‘][‘dm_pnz‘];
            //顶面手刷乳胶漆 dm_rjq(金装五合一,一底两面)
            $arr_kt[$k][‘gcl‘][‘dm_rjq‘] = $val * 1.33;
            $arr_kt[$k][‘gcj‘][‘dm_rjq‘] = $arr_kt[$k][‘gcl‘][‘dm_rjq‘] * 17 * $i_p;
            $arr_kt[$k][‘price‘] += $arr_kt[$k][‘gcj‘][‘dm_rjq‘];

            $total_price += $arr_kt[$k][‘price‘];
        }
        

//卧室工程
        $ws_sy = $c_kt;
//$ws_total = 0;//卧室总价
        foreach ($arr_woshi as $k => $val) {
            $arr_ws[$k][‘sy‘] = $ws_sy + $k; //js索引
//墙面铲除墙面腻子层 qm_nzh
            $arr_ws[$k][‘gcl‘][‘qm_nzh‘] = $val * 2.5;
            $arr_ws[$k][‘gcj‘][‘qm_nzh‘] = $arr_ws[$k][‘gcl‘][‘qm_nzh‘] * 7 * $i_p;
            $arr_ws[$k][‘price‘] += $arr_ws[$k][‘gcj‘][‘qm_nzh‘];
//墙面滚胶 qm_gj
            $arr_ws[$k][‘gcl‘][‘qm_gj‘] = $val * 2.5;
            $arr_ws[$k][‘gcj‘][‘qm_gj‘] = $arr_ws[$k][‘gcl‘][‘qm_gj‘] * 6 * $i_p;
            $arr_ws[$k][‘price‘] += $arr_ws[$k][‘gcj‘][‘qm_gj‘];
//墙面批腻子 qm_pnz
            $arr_ws[$k][‘gcl‘][‘qm_pnz‘] = $val * 2.5;
            $arr_ws[$k][‘gcj‘][‘qm_pnz‘] = $arr_ws[$k][‘gcl‘][‘qm_pnz‘] * 19 * $i_p;
            $arr_ws[$k][‘price‘] += $arr_ws[$k][‘gcj‘][‘qm_pnz‘];
//墙面手刷乳胶漆 qm_nzc
            $arr_ws[$k][‘gcl‘][‘qm_nzc‘] = $val * 2.5;
            $arr_ws[$k][‘gcj‘][‘qm_nzc‘] = $arr_ws[$k][‘gcl‘][‘qm_nzc‘] * 17 * $i_p;
            $arr_ws[$k][‘price‘] += $arr_ws[$k][‘gcj‘][‘qm_nzc‘];
//顶面铲除顶面腻子层 dm_nzc
            $arr_ws[$k][‘gcl‘][‘dm_nzc‘] = $val * 1;
            $arr_ws[$k][‘gcj‘][‘dm_nzc‘] = $arr_ws[$k][‘gcl‘][‘dm_nzc‘] * 7 * $i_p;
            $arr_ws[$k][‘price‘] += $arr_ws[$k][‘gcj‘][‘dm_nzc‘];
//顶面滚胶 dm_gj
            $arr_ws[$k][‘gcl‘][‘dm_gj‘] = $val * 1;
            $arr_ws[$k][‘gcj‘][‘dm_gj‘] = $arr_ws[$k][‘gcl‘][‘dm_gj‘] * 6 * $i_p;
            $arr_ws[$k][‘price‘] += $arr_ws[$k][‘gcj‘][‘dm_gj‘];
//顶面批腻子 dm_pnz
            $arr_ws[$k][‘gcl‘][‘dm_pnz‘] = $val * 1;
            $arr_ws[$k][‘gcj‘][‘dm_pnz‘] = $arr_ws[$k][‘gcl‘][‘dm_pnz‘] * 19 * $i_p;
            $arr_ws[$k][‘price‘] += $arr_ws[$k][‘gcj‘][‘dm_pnz‘];
//顶面手刷乳胶漆 dm_rjq
            $arr_ws[$k][‘gcl‘][‘dm_rjq‘] = $val * 1;
            $arr_ws[$k][‘gcj‘][‘dm_rjq‘] = $arr_ws[$k][‘gcl‘][‘dm_rjq‘] * 17 * $i_p;
            $arr_ws[$k][‘price‘] += $arr_ws[$k][‘gcj‘][‘dm_rjq‘];
//门套打底(宽度≤200mm) mt_dd
            $arr_ws[$k][‘gcl‘][‘mt_dd‘] = $val * 0.5;
            $arr_ws[$k][‘gcj‘][‘mt_dd‘] = $arr_ws[$k][‘gcl‘][‘mt_dd‘] * 43 * $i_p;
            $arr_ws[$k][‘price‘] += $arr_ws[$k][‘gcj‘][‘mt_dd‘];
//大理石窗台板(宽度≤600-900MM) dls_ctb
            $arr_ws[$k][‘gcl‘][‘dls_ctb‘] = $val * 0.2;
            $arr_ws[$k][‘gcj‘][‘dls_ctb‘] = $arr_ws[$k][‘gcl‘][‘dls_ctb‘] * 230 * $i_p;
            $arr_ws[$k][‘price‘] += $arr_ws[$k][‘gcj‘][‘dls_ctb‘];

            $total_price += $arr_ws[$k][‘price‘];
        }
//---卧室1
        
//公用卫生间工程
        $wsj_sy = $c_kt + $c_ws;
//$wsj_total = 0;//卫生间总价
        foreach ($arr_weishengjian as $k => $val) {
            $arr_wsj[$k][‘sy‘] = $wsj_sy + $k; //js索引
//地面做二遍防水处理 dm_fscl
            $arr_wsj[$k][‘gcl‘][‘dm_fscl‘] = $val * 4;
            $arr_wsj[$k][‘gcj‘][‘dm_fscl‘] = $arr_wsj[$k][‘gcl‘][‘dm_fscl‘] * 55 * $i_p;
            $arr_wsj[$k][‘price‘] += $arr_wsj[$k][‘gcj‘][‘dm_fscl‘];
//铺贴地砖不拼花(含填缝) pt_dzb
            $arr_wsj[$k][‘gcl‘][‘pt_dzb‘] = $val * 1;
            $arr_wsj[$k][‘gcj‘][‘pt_dzb‘] = $arr_wsj[$k][‘gcl‘][‘pt_dzb‘] * 77 * $i_p;
            $arr_wsj[$k][‘price‘] += $arr_wsj[$k][‘gcj‘][‘pt_dzb‘];
//地面找平(30mm内) dm_zp
            $arr_wsj[$k][‘gcl‘][‘dm_zp‘] = $val * 1;
            $arr_wsj[$k][‘gcj‘][‘dm_zp‘] = $arr_wsj[$k][‘gcl‘][‘dm_zp‘] * 60 * $i_p;
            $arr_wsj[$k][‘price‘] += $arr_wsj[$k][‘gcj‘][‘dm_zp‘];
//淋浴房挡水槛(浅色,含磨边) lyf_dsk
            $arr_wsj[$k][‘gcl‘][‘lyf_dsk‘] = $val * 0.38;
            $arr_wsj[$k][‘gcj‘][‘lyf_dsk‘] = $arr_wsj[$k][‘gcl‘][‘lyf_dsk‘] * 150 * $i_p;
            $arr_wsj[$k][‘price‘] += $arr_wsj[$k][‘gcj‘][‘lyf_dsk‘];
//大理石门槛石宽度≤240MM dls_mks
            $arr_wsj[$k][‘gcl‘][‘dls_mks‘] = $val * 0.25;
            $arr_wsj[$k][‘gcj‘][‘dls_mks‘] = $arr_wsj[$k][‘gcl‘][‘dls_mks‘] * 115 * $i_p;
            $arr_wsj[$k][‘price‘] += $arr_wsj[$k][‘gcj‘][‘dls_mks‘];
//铺贴墙砖不拼花(含填缝) pt_qzb
            $arr_wsj[$k][‘gcl‘][‘pt_qzb‘] = $val * 3.8;
            $arr_wsj[$k][‘gcj‘][‘pt_qzb‘] = $arr_wsj[$k][‘gcl‘][‘pt_qzb‘] * 73 * $i_p;
            $arr_wsj[$k][‘price‘] += $arr_wsj[$k][‘gcj‘][‘pt_qzb‘];
//墙面磁砖倒角加工费 qm_czdj
            $arr_wsj[$k][‘gcl‘][‘qm_czdj‘] = $val * 3;
            $arr_wsj[$k][‘gcj‘][‘qm_czdj‘] = $arr_wsj[$k][‘gcl‘][‘qm_czdj‘] * 20 * $i_p;
            $arr_wsj[$k][‘price‘] += $arr_wsj[$k][‘gcj‘][‘qm_czdj‘];
//门套打底(宽度≤200mm) mt_dd
            $arr_wsj[$k][‘gcl‘][‘mt_dd‘] = $val * 1.25;
            $arr_wsj[$k][‘gcj‘][‘mt_dd‘] = $arr_wsj[$k][‘gcl‘][‘mt_dd‘] * 43 * $i_p;
            $arr_wsj[$k][‘price‘] += $arr_wsj[$k][‘gcj‘][‘mt_dd‘];
//地漏及安装 dl_az
            $arr_wsj[$k][‘gcl‘][‘dl_az‘] = $val * 0.5;
            $arr_wsj[$k][‘gcj‘][‘dl_az‘] = $arr_wsj[$k][‘gcl‘][‘dl_az‘] * 88 * $i_p;
            $arr_wsj[$k][‘price‘] += $arr_wsj[$k][‘gcj‘][‘dl_az‘];
//安装成品台盆柜(含面盆、面盆龙头) az_tpg
            $arr_wsj[$k][‘gcl‘][‘az_tpg‘] = $val * 0.25;
            $arr_wsj[$k][‘gcj‘][‘az_tpg‘] = $arr_wsj[$k][‘gcl‘][‘az_tpg‘] * 80 * $i_p;
            $arr_wsj[$k][‘price‘] += $arr_wsj[$k][‘gcj‘][‘az_tpg‘];
//冷热水龙头安装(面盆/浴缸/淋浴/洗衣机) lr_slt
            $arr_wsj[$k][‘gcl‘][‘lr_slt‘] = $val * 0.25;
            $arr_wsj[$k][‘gcj‘][‘lr_slt‘] = $arr_wsj[$k][‘gcl‘][‘lr_slt‘] * 80 * $i_p;
            $arr_wsj[$k][‘price‘] += $arr_wsj[$k][‘gcj‘][‘lr_slt‘];
//浴室浴配件安装(毛巾杆、浴巾架等) ys_ypj
            $arr_wsj[$k][‘gcl‘][‘ys_ypj‘] = $val * 0.25;
            $arr_wsj[$k][‘gcj‘][‘ys_ypj‘] = $arr_wsj[$k][‘gcl‘][‘ys_ypj‘] * 100 * $i_p;
            $arr_wsj[$k][‘price‘] += $arr_wsj[$k][‘gcj‘][‘ys_ypj‘];
//三角阀+软管(套) sjf_rg
            $arr_wsj[$k][‘gcl‘][‘sjf_rg‘] = $val * 0.75;
            $arr_wsj[$k][‘gcj‘][‘sjf_rg‘] = $arr_wsj[$k][‘gcl‘][‘sjf_rg‘] * 60 * $i_p;
            $arr_wsj[$k][‘price‘] += $arr_wsj[$k][‘gcj‘][‘sjf_rg‘];
//安装马桶 az_mt
            $arr_wsj[$k][‘gcl‘][‘az_mt‘] = $val * 0.25;
            $arr_wsj[$k][‘gcj‘][‘az_mt‘] = $arr_wsj[$k][‘gcl‘][‘az_mt‘] * 75 * $i_p;
            $arr_wsj[$k][‘price‘] += $arr_wsj[$k][‘gcj‘][‘az_mt‘];

            $total_price += $arr_wsj[$k][‘price‘];
        }
        
//厨房工程 总:1
        $cf_sy = $c_kt + $c_ws + $c_wsj;
//$cf_total = 0;//卧室总价
        foreach ($arr_chufang as $k => $val) {
            $arr_cf[$k][‘sy‘] = $cf_sy + $k; //js索引
//铺贴地砖不拼花(含填缝) pt_dz
            $arr_cf[$k][‘gcl‘][‘pt_dz‘] = $val * 1;
            $arr_cf[$k][‘gcj‘][‘pt_dz‘] = $arr_cf[$k][‘gcl‘][‘pt_dz‘] * 77 * $i_p;
            $arr_cf[$k][‘price‘] += $arr_cf[$k][‘gcj‘][‘pt_dz‘];
//地面找平(30mm内) dm_zp
            $arr_cf[$k][‘gcl‘][‘dm_zp‘] = $val * 1;
            $arr_cf[$k][‘gcj‘][‘dm_zp‘] = $arr_cf[$k][‘gcl‘][‘dm_zp‘] * 60 * $i_p;
            $arr_cf[$k][‘price‘] += $arr_cf[$k][‘gcj‘][‘dm_zp‘];
//大理石门槛石宽度≤240MM dls_mk
            $arr_cf[$k][‘gcl‘][‘dls_mk‘] = $val * 0.2;
            $arr_cf[$k][‘gcj‘][‘dls_mk‘] = $arr_cf[$k][‘gcl‘][‘dls_mk‘] * 115 * $i_p;
            $arr_cf[$k][‘price‘] += $arr_cf[$k][‘gcj‘][‘dls_mk‘];
//铺贴墙砖不拼花(含填缝) pt_qz
            $arr_cf[$k][‘gcl‘][‘pt_qz‘] = $val * 3.8;
            $arr_cf[$k][‘gcj‘][‘pt_qz‘] = $arr_cf[$k][‘gcl‘][‘pt_qz‘] * 73 * $i_p;
            $arr_cf[$k][‘price‘] += $arr_cf[$k][‘gcj‘][‘pt_qz‘];
//磁砖倒角加工费 cz_djjgf
            $arr_cf[$k][‘gcl‘][‘cz_djjgf‘] = $val * 2.4;
            $arr_cf[$k][‘gcj‘][‘cz_djjgf‘] = $arr_cf[$k][‘gcl‘][‘cz_djjgf‘] * 20 * $i_p;
            $arr_cf[$k][‘price‘] += $arr_cf[$k][‘gcj‘][‘cz_djjgf‘];
//门套打底(宽度≤200mm) mt_dd
            $arr_cf[$k][‘gcl‘][‘mt_dd‘] = $val * 1;
            $arr_cf[$k][‘gcj‘][‘mt_dd‘] = $arr_cf[$k][‘gcl‘][‘mt_dd‘] * 43 * $i_p;
            $arr_cf[$k][‘price‘] += $arr_cf[$k][‘gcj‘][‘mt_dd‘];
//厨房水槽安装(含冷热水龙头安装) cf_scaz
            $arr_cf[$k][‘gcl‘][‘cf_scaz‘] = $val * 0.2;
            $arr_cf[$k][‘gcj‘][‘cf_scaz‘] = $arr_cf[$k][‘gcl‘][‘cf_scaz‘] * 45 * $i_p;
            $arr_cf[$k][‘price‘] += $arr_cf[$k][‘gcj‘][‘cf_scaz‘];
//三角阀+软管(套) sjf_rg
            $arr_cf[$k][‘gcl‘][‘sjf_rg‘] = $val * 0.8;
            $arr_cf[$k][‘gcj‘][‘sjf_rg‘] = $arr_cf[$k][‘gcl‘][‘sjf_rg‘] * 60 * $i_p;
            $arr_cf[$k][‘price‘] += $arr_cf[$k][‘gcj‘][‘sjf_rg‘];

            $total_price += $arr_cf[$k][‘price‘];
        }
        
//厅阳台工程
        $yt_sy = $c_kt + $c_ws + $c_wsj + $c_cf;
        $yt_total = 0; //厅阳台总价
        foreach ($arr_yangtai as $k => $val) {
            $arr_yt[$k][‘sy‘] = $yt_sy + $k; //js索引
//铺贴地砖不拼花(含填缝,单边≥200mm) pt_dz
            $arr_yt[$k][‘gcl‘][‘pt_dz‘] = $val * 1;
            $arr_yt[$k][‘gcj‘][‘pt_dz‘] = $arr_yt[$k][‘gcl‘][‘pt_dz‘] * 77 * $i_p;
            $arr_yt[$k][‘price‘] += $arr_yt[$k][‘gcj‘][‘pt_dz‘];
//地面找平(30mm内) dm_zp
            $arr_yt[$k][‘gcl‘][‘dm_zp‘] = $val * 1;
            $arr_yt[$k][‘gcj‘][‘dm_zp‘] = $arr_yt[$k][‘gcl‘][‘dm_zp‘] * 60 * $i_p;
            $arr_yt[$k][‘price‘] += $arr_yt[$k][‘gcj‘][‘dm_zp‘];
//大理石门槛石宽度≤240MM dls_mk
            $arr_yt[$k][‘gcl‘][‘dls_mk‘] = $val * 0.63;
            $arr_yt[$k][‘gcj‘][‘dls_mk‘] = $arr_yt[$k][‘gcl‘][‘dls_mk‘] * 115 * $i_p;
            $arr_yt[$k][‘price‘] += $arr_yt[$k][‘gcj‘][‘dls_mk‘];
//铺贴墙砖不拼花(含填缝,单边≥200mm) pt_qz
            $arr_yt[$k][‘gcl‘][‘pt_qz‘] = $val * 2;
            $arr_yt[$k][‘gcj‘][‘pt_qz‘] = $arr_yt[$k][‘gcl‘][‘pt_qz‘] * 73 * $i_p;
            $arr_yt[$k][‘price‘] += $arr_yt[$k][‘gcj‘][‘pt_qz‘];
//顶面批腻子 dm_pnz
            $arr_yt[$k][‘gcl‘][‘dm_pnz‘] = $val * 1;
            $arr_yt[$k][‘gcj‘][‘dm_pnz‘] = $arr_yt[$k][‘gcl‘][‘dm_pnz‘] * 19 * $i_p;
            $arr_yt[$k][‘price‘] += $arr_yt[$k][‘gcj‘][‘dm_pnz‘];
//顶面手刷乳胶漆(金装五合一,一底两面) dm_rjq
            $arr_yt[$k][‘gcl‘][‘dm_rjq‘] = $val * 1;
            $arr_yt[$k][‘gcj‘][‘dm_rjq‘] = $arr_yt[$k][‘gcl‘][‘dm_rjq‘] * 17 * $i_p;
            $arr_yt[$k][‘price‘] += $arr_yt[$k][‘gcj‘][‘dm_rjq‘];

            $total_price += $arr_yt[$k][‘price‘];
        }
        
//水电及其安装
        $sd_sy = $c_kt + $c_ws + $c_wsj + $c_cf + $c_yt;
        $total_area = $areas;
        $shuidian_price = 0;
        $shuidian_gcl = array();
        $shuidian_gcj = array();

//电话线 sd_dhx
        $shuidian_gcl[‘sd_dhx‘] = $total_area * 0.25;
        $shuidian_gcj[‘sd_dhx‘] = $shuidian_gcl[‘sd_dhx‘] * 4 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_dhx‘];
//网络线 sd_wlx
        $shuidian_gcl[‘sd_wlx‘] = $total_area * 0.75;
        $shuidian_gcj[‘sd_wlx‘] = $shuidian_gcl[‘sd_wlx‘] * 5.3 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_wlx‘];
//弱电全套开关/插座(地插价格另计) sd_rdkg
        $shuidian_gcl[‘sd_rdkg‘] = $total_area * 0.11;
        $shuidian_gcj[‘sd_rdkg‘] = $shuidian_gcl[‘sd_rdkg‘] * 45 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_rdkg‘];
//视频线 sd_spx
        $shuidian_gcl[‘sd_spx‘] = $total_area * 0.63;
        $shuidian_gcj[‘sd_spx‘] = $shuidian_gcl[‘sd_spx‘] * 7.3 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_spx‘];
//安装弱电箱 sd_rdx
        $shuidian_gcl[‘sd_rdx‘] = $total_area * 0.01;
        $shuidian_gcj[‘sd_rdx‘] = $shuidian_gcl[‘sd_rdx‘] * 330 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_rdx‘];
//6分PVC线管(含管件) sd_pvc
        $shuidian_gcl[‘sd_pvc‘] = $total_area * 3.13;
        $shuidian_gcj[‘sd_pvc‘] = $shuidian_gcl[‘sd_pvc‘] * 5.3 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_pvc‘];
//1.5㎡电线 sd_15dx
        $shuidian_gcl[‘sd_15dx‘] = $total_area * 5.75;
        $shuidian_gcj[‘sd_15dx‘] = $shuidian_gcl[‘sd_15dx‘] * 4 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_15dx‘];
//2.5㎡电线 sd_25dx
        $shuidian_gcl[‘sd_25dx‘] = $total_area * 6.25;
        $shuidian_gcj[‘sd_25dx‘] = $shuidian_gcl[‘sd_25dx‘] * 4.9 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_25dx‘];
//4㎡电线 sd_4dx
        $shuidian_gcl[‘sd_4dx‘] = $total_area * 0.5;
        $shuidian_gcj[‘sd_4dx‘] = $shuidian_gcl[‘sd_4dx‘] * 7.3 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_4dx‘];
//安装强电箱箱体12路 sd_qdx
        $shuidian_gcl[‘sd_qdx‘] = $total_area * 0.01;
        $shuidian_gcj[‘sd_qdx‘] = $shuidian_gcl[‘sd_qdx‘] * 400 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_qdx‘];
//强电开关/插座(地插价格另计) sd_qdkg
        $shuidian_gcl[‘sd_qdkg‘] = $total_area * 0.56;
        $shuidian_gcj[‘sd_qdkg‘] = $shuidian_gcl[‘sd_qdkg‘] * 25 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_qdkg‘];
//开关插座暗盒 sd_kgah
        $shuidian_gcl[‘sd_kgah‘] = $total_area * 0.68;
        $shuidian_gcj[‘sd_kgah‘] = $shuidian_gcl[‘sd_kgah‘] * 8 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_kgah‘];
//安装灯头盒 sd_azdth
        $shuidian_gcl[‘sd_azdth‘] = $total_area * 0.38;
        $shuidian_gcj[‘sd_azdth‘] = $shuidian_gcl[‘sd_azdth‘] * 5.5 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_azdth‘];
//冷热水管 sd_lrsg
        $shuidian_gcl[‘sd_lrsg‘] = $total_area * 0.63;
        $shuidian_gcj[‘sd_lrsg‘] = $shuidian_gcl[‘sd_lrsg‘] * 45 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_lrsg‘];
//灯具安装 sd_djaz
        $shuidian_gcl[‘sd_djaz‘] = $total_area * 0.01;
        $shuidian_gcj[‘sd_djaz‘] = $shuidian_gcl[‘sd_djaz‘] * 400 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_djaz‘];
//砖墙管线开槽(含修粉) sd_qzgx
        $shuidian_gcl[‘sd_qzgx‘] = $total_area * 1;
        $shuidian_gcj[‘sd_qzgx‘] = $shuidian_gcl[‘sd_qzgx‘] * 10.5 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_qzgx‘];
//钢筋混凝土墙面凿槽(含修粉) sd_gjhyt
        $shuidian_gcl[‘sd_gjhyt‘] = $total_area * 0.38;
        $shuidian_gcj[‘sd_gjhyt‘] = $shuidian_gcl[‘sd_gjhyt‘] * 23 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_gjhyt‘];
//机器开孔(空调/脱排/浴霸) sd_jqkk
        $shuidian_gcl[‘sd_jqkk‘] = $total_area * 0.06;
        $shuidian_gcj[‘sd_jqkk‘] = $shuidian_gcl[‘sd_jqkk‘] * 40 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_jqkk‘];
//杂物费(按建筑面积计算) sd_zwf
        $shuidian_gcl[‘sd_zwf‘] = $total_area * 0.01;
        $shuidian_gcj[‘sd_zwf‘] = $shuidian_gcl[‘sd_zwf‘] * 250 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_zwf‘];
//垃圾清运费(新房,按建筑面积计算) sd_ljqyf
        $shuidian_gcl[‘sd_ljqyf‘] = $total_area * 0.73;
        $shuidian_gcj[‘sd_ljqyf‘] = $shuidian_gcl[‘sd_ljqyf‘] * 6 * $i_p;
        $shuidian_price += $shuidian_gcj[‘sd_ljqyf‘];

        $total_price += $shuidian_price;

        return array(‘total_price‘=>$total_price,‘arr_kt‘=>$arr_kt,‘arr_ws‘=>$arr_ws,‘arr_wsj‘=>$arr_wsj,‘arr_cf‘=>$arr_cf,‘arr_yt‘=>$arr_yt,‘arr_sd‘=>$shuidian_price);

    }




    ############################ U_DECRYPT ############################

    # 加密
    public function U_ENCRYPT($mobile) {
        return U_ENCRYPT($mobile);
        
        // $wMobile = array(
        //     ‘18601693057‘, # l
        //     ‘13918817036‘, # m
        //     ‘15001793098‘, # z
        //     ‘13611849697‘, # h
        //     ‘18605623290‘, # c
        //     ‘17051210248‘  # f
        // );
        // if (in_array($mobile, $wMobile)) {
        //     return U_ENCRYPT($mobile);
        // }
        // return $mobile;
    }

    # 解密
    public function U_DECRYPT($mobile) {
        if (strlen($mobile) == 16)
            return U_DECRYPT($mobile); # 新存入字段 解密后返回
        else
            return $mobile; # 旧存入字段 直接返回
    }

    # 保存明文
    public function U_SAVE_BM($bmid, $mobile) {
        $this->loadModel(‘BmLog‘);
        $data[‘baoming_id‘] = $bmid;
        $data[‘mobile‘] = $mobile;
        return $this->BmLog->save($data);
    }

    /**
      *获取当前页面报名人数(数据会有75秒的延迟)
      *该方法已被 function cake24_get_baomingNum() 替代
      *暂时废止
      *2017-03-13
      **/
    public function cake24_get_baoming_num($utm_page, $overTime = 75){
        
        if(empty($utm_page)){return 0;}

        $conditions = array(‘GlobalConfig.category_id‘ => 1); //1-报名页面来源
        $utmPageArr = $this->GlobalConfig->find(‘list‘, array(
            ‘conditions‘ => $conditions, 
            ‘fields‘ => array(‘GlobalConfig.short‘, ‘GlobalConfig.name‘))
        );

        //获取报名户型设计数量
        if ($this->Redis->get(‘UTMPAGE_‘.$utm_page)) {
            $baoming_num = $this->Redis->get(‘UTMPAGE_‘.$utm_page);
        } else {  
            
            $conditions = array(‘Baoming.utm_page LIKE‘=>$utmPageArr[$utm_page].‘%‘);
            $baoming_num = $this->Baoming->find(‘count‘,array(‘conditions‘=>$conditions));
            $this->Redis->setex(‘UTMPAGE_‘.$utm_page, $overTime, $baoming_num);
        }

        $this->set(‘baoming_num‘, $baoming_num);
    }

    /** 
      * @获取报名数量
      * @par $type    utm_page(获取指定页面报名数量),all(获取当前所有的报名数量),date(获取具体日期的报名数量),month(获取具体月份的报名数量)
      * @par $param   具体的数据
      * @par $fix_num 需要填充的数量
      * @par $return 是否返回数据  false (不返回数据,直接定义变量) , true (返回数据)
      * @par $overTime redis信息更新时间 默认为75 S
      * 注: 当参数错误、输入的日期格式不正确和找不到$type类型时,统一返回 0
      * @return  $baoming_num (报名数量) 直接定义变量
      * @author dtz 2017-03-13
      **/
    public function cake24_get_baomingNum($param, $type = ‘utm_page‘, $fix_num = 0, $return = false, $overTime = 75){

        unset($baoming_num);
        if(empty($param)){ return $baoming_num = 0; }

        $conditions = array(‘GlobalConfig.category_id‘ => 1); //1-报名页面来源
        $utmPageArr = $this->GlobalConfig->find(‘list‘, array(
            ‘conditions‘ => $conditions, 
            ‘fields‘ => array(‘GlobalConfig.short‘, ‘GlobalConfig.name‘))
        );

        //分析数据类型
        switch ($type) {
            case ‘utm_page‘://获取指定页面来源的报名数量
                $key = ‘GET_UTMPAGE_‘.$param;
                $conditions = array(‘`Baoming`.`utm_page`‘=>$utmPageArr[$param]);
                break;

            case ‘all‘://获取所有数据的报名数量
                $fix_num = 200000;//所有数据的基数同意是200000
                $key = ‘GET_‘.strtoupper($param);
                $conditions = [];
                break;

            case ‘date‘://获取指定日期的报名数量
                $is_date = $this->cake24_check_date($param);//判断是否是日期格式
                if($is_date){

                    $key = ‘GET_DATE_‘.$param;
                    $conditions = array(‘DATE_FORMAT(`addtime`,\‘%Y-%m-%d\‘)‘ => $param);

                }else{//如果日期格式不对则返回0

                    return 0;
                }
                break;
            case ‘month‘://获取指定月份的报名数量 (暫時不用)
                $is_month = $this->cake24_check_date($param);//判断是否是日期格式
                if($is_month){

                    $key = ‘GET_MONTH_‘.$param;
                    $conditions = array(‘DATE_FORMAT(`addtime`,\‘%Y-%m\‘)‘ => $param);
                }else{//如果月份格式不对则返回0

                    return 0;
                }
                break;

            
            default:
                return 0;//默认返回0
                break;
        }

        //获取各类型的报名数量
        if ($this->Redis->get($key)) {
            $baoming_num = $this->Redis->get($key);
        } else {
            
            $baoming_num = $this->Baoming->find(‘count‘,array(‘conditions‘ => $conditions));
            $this->Redis->setex($key, $overTime, $baoming_num);
        }

        //如果需要填充的数量部位0 则在原基础的数据上加上需要填充的数据
        if($fix_num != 0 && is_int($fix_num)){ $baoming_num += $fix_num; }

        if($return){

            return $baoming_num;
        }else{

            $this->set(‘baoming_num‘, $baoming_num);
        }

        
    }

    /** 
      * @判断日期格式时候正确
      * 功能 判断日期格式是否正确
      * 参数 $str 日期字符串, $format 日期格式
      * $format 支持 Y-m-d 和 Y/m/d 两种格式 Ymd暂时不兼容
      * 注意 : 在判斷月份的時候$format 格式必須也只是 Y-m-d 和 Y/m/d 不能寫成  Y-m 和 Y/m
      * @return  true 格式正确 , false 格式错误
      * @author dtz 2017-03-13
      **/
    protected function cake24_check_date($str, $format=‘Y-m-d‘){
        
        
        $date_type = preg_replace(‘/[\.a-zA-Z]/s‘, ‘‘, $format);//去除大小寫字母

        //$date_type[0] 的值为 - 或者 /
        //计算 $date_type[0] 在字符串中的次数 (如果是日期格式的话 $date_type[0] 符号不会超过2个,如果超过2个则直接返回 false)
        $substr_count = substr_count($str, $date_type[0]);
        if(in_array($substr_count, array(1, 2))){

            if($substr_count == 1){ $str .= $date_type[0].‘01‘; }
        }else{

            return false;
        }

        $unixTime  = strtotime($str);
        if(!is_numeric($unixTime)) return false; //如果不是数字格式,则直接返回 

        $checkDate = date($format, $unixTime);
        $checktime = strtotime($checkDate);
        if($unixTime == $checktime){
            return true;
        }else{ 
            return false; 
        } 
    } 

    /** 
      * @屏蔽掉局域网、外测和系统配置ip
      * @par $ip  当前ip地址
      * @return  true 当前ip需要屏蔽 , false 当前ip不需要屏蔽
      * @author dtz 2017-03-06
      **/
    protected function cake24_ignore_ip($ip){

        //判断是否是合法的公共IPv4地址  
        if(!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE)){

            return true;//局域网的ip需要屏蔽
        }

        if(strpos($ip, ‘,‘)){
            
            $explode = explode(‘,‘, $ip);
            $ip = trim($explode[0]);
        }

        $this->loadModel("ApplicationConfig");
        $ipData = $this->ApplicationConfig->find(‘list‘,array(
                ‘conditions‘=>array(
                    ‘project‘=>array(‘now_ipaddress‘,‘budding_ipaddress‘)
                ),
                ‘fields‘ => array(‘text‘,‘text‘)
            )
        );
        
        $check_ip_arr = explode(‘.‘, $ip);//要检测的ip拆分成数组
        $ipArr  = [‘116.62.40.158‘, ‘180.173.90.62‘];//公司外测的ip也可以添加局域网ip段,但如果要加局域网ip段的话就和代码功能重复,在此加局域网ip段需要注释掉
        $ignoreIpArr  = array_merge(array_values($ipData), $ipArr);
        
        if(!in_array($ip, $ignoreIpArr)){

            foreach ($ignoreIpArr as $key => $value) {
                
                if(strpos($value, ‘*‘) !== false ){//发现有*号替代符

                    $arr = explode(‘.‘, $value);
                    $bl = true;//用于记录循环检测中是否有匹配成功的

                    foreach ($arr as $k => $val) {
                        if($val != ‘*‘){//不等于* 就要进来检测,如果为*符号替代符就不检查

                            if($val != $check_ip_arr[$k]){
                                $bl = false;
                                break;//终止检查本个ip 继续检查下一个ip
                            }
                        }
                    }
                }
            }

        }else{

            $bl = true;
        }

        return $bl;
    }

    /** 
      * 格式化网址 
      * par $url 待格式化的网址
      * return  处理后的网址
      * Recoded By dtz
      * date 2017-02-06
      **/ 
    protected function cake24_filterUrl($url = ‘‘){
     
        $url = trim(strtolower($url));
        $url = trim(preg_replace(‘/^http:\/\//‘, ‘‘, $url));
        if ($url == ‘‘){

            return false;
        }else{
            return urlencode(‘http://‘ . $url);
        }
        
    }

    //拼接请求地址,此地址你可以在官方的文档中查看到
    protected function cake24_sinaShortenUrl($long_url){
        
        //新浪
        /*$url = ‘http://api.t.sina.com.cn/short_url/shorten.json?source=31641035&url_long=‘ . $long_url;
        //获取请求结果
        $result = $this->curlQuery($url);*/
        //下面这行注释用于调试,你可以把注释去掉看看从sina返回的信息是什么东西
        //print_r($result);exit();
        //百度
        $ch = curl_init();
        $url = ‘http://apis.baidu.com/3023/shorturl/shorten?url_long=‘.$long_url;
        $header = array(
            ‘apikey: c3aadd615ae4b6bfcbf8e4afc503fab7‘,
        );
        // 添加apikey到header
        curl_setopt($ch, CURLOPT_HTTPHEADER  , $header);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // 执行HTTP请求
        curl_setopt($ch , CURLOPT_URL , $url);
        $result = curl_exec($ch);

        //解析json
        $json = json_decode($result,true);
        $url_short = $json[‘urls‘][0][‘url_short‘];
        //异常情况返回false
        if (isset($json[‘error‘]) || $url_short == ‘‘)
        {
            return false;
        }
        else
        {
            return $url_short;
        }

    }

  /** 
  * @去除XSS(跨站脚本攻击)的函数 
  * @par $val 字符串参数,可能包含恶意的脚本代码如<script language="javascript">alert("hello world");</script> 
  * @return  处理后的字符串 
  * @Recoded By Androidyue 
  **/  
  public function cake24_remove_xss($val) 
  {    
     // remove all non-printable characters. CR(0a) and LF(0b) and TAB(9) are allowed    
     // this prevents some character re-spacing such as <java\0script>    
     // note that you have to handle splits with \n, \r, and \t later since they *are* allowed in some inputs  
     $val = preg_replace(‘/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/‘, ‘‘, $val);    
     
     // straight replacements, the user should never need these since they‘re normal characters    
     // this prevents like <IMG SRC=@avascript:alert(‘XSS‘)>    
     $search = ‘abcdefghijklmnopqrstuvwxyz‘;   
     $search .= ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ‘;    
     $search .= ‘1234567890!@#$%^&*()‘;   
     $search .= ‘~`";:?+/={}[]-_|\‘\\‘;   
     for ($i = 0; $i < strlen($search); $i++) {   
        // ;? matches the ;, which is optional   
        // 0{0,7} matches any padded zeros, which are optional and go up to 8 chars   
     
        // @ @ search for the hex values   
        $val = preg_replace(‘/(&#[xX]0{0,8}‘.dechex(ord($search[$i])).‘;?)/i‘, $search[$i], $val); // with a ;   
        // @ @ 0{0,7} matches ‘0‘ zero to seven times    
        $val = preg_replace(‘/(&#0{0,8}‘.ord($search[$i]).‘;?)/‘, $search[$i], $val); // with a ;   
     }   
     
     // now the only remaining whitespace attacks are \t, \n, and \r   
     $ra1 = Array(‘javascript‘, ‘vbscript‘, ‘expression‘, ‘applet‘, ‘meta‘, ‘xml‘, ‘blink‘, ‘link‘, ‘style‘, ‘script‘, ‘embed‘, ‘object‘, ‘iframe‘, ‘frame‘, ‘frameset‘, ‘ilayer‘, ‘layer‘, ‘bgsound‘, ‘title‘, ‘base‘);   
     $ra2 = Array(‘onabort‘, ‘onactivate‘, ‘onafterprint‘, ‘onafterupdate‘, ‘onbeforeactivate‘, ‘onbeforecopy‘, ‘onbeforecut‘, ‘onbeforedeactivate‘, ‘onbeforeeditfocus‘, ‘onbeforepaste‘, ‘onbeforeprint‘, ‘onbeforeunload‘, ‘onbeforeupdate‘, ‘onblur‘, ‘onbounce‘, ‘oncellchange‘, ‘onchange‘, ‘onclick‘, ‘oncontextmenu‘, ‘oncontrolselect‘, ‘oncopy‘, ‘oncut‘, ‘ondataavailable‘, ‘ondatasetchanged‘, ‘ondatasetcomplete‘, ‘ondblclick‘, ‘ondeactivate‘, ‘ondrag‘, ‘ondragend‘, ‘ondragenter‘, ‘ondragleave‘, ‘ondragover‘, ‘ondragstart‘, ‘ondrop‘, ‘onerror‘, ‘onerrorupdate‘, ‘onfilterchange‘, ‘onfinish‘, ‘onfocus‘, ‘onfocusin‘, ‘onfocusout‘, ‘onhelp‘, ‘onkeydown‘, ‘onkeypress‘, ‘onkeyup‘, ‘onlayoutcomplete‘, ‘onload‘, ‘onlosecapture‘, ‘onmousedown‘, ‘onmouseenter‘, ‘onmouseleave‘, ‘onmousemove‘, ‘onmouseout‘, ‘onmouseover‘, ‘onmouseup‘, ‘onmousewheel‘, ‘onmove‘, ‘onmoveend‘, ‘onmovestart‘, ‘onpaste‘, ‘onpropertychange‘, ‘onreadystatechange‘, ‘onreset‘, ‘onresize‘, ‘onresizeend‘, ‘onresizestart‘, ‘onrowenter‘, ‘onrowexit‘, ‘onrowsdelete‘, ‘onrowsinserted‘, ‘onscroll‘, ‘onselect‘, ‘onselectionchange‘, ‘onselectstart‘, ‘onstart‘, ‘onstop‘, ‘onsubmit‘, ‘onunload‘,‘onxload‘);   
     $ra = array_merge($ra1, $ra2);   
     
     $found = true; // keep replacing as long as the previous round replaced something   
     while ($found == true) {   
        $val_before = $val;   
        for ($i = 0; $i < sizeof($ra); $i++) {   
           $pattern = ‘/‘;   
           for ($j = 0; $j < strlen($ra[$i]); $j++) {   
              if ($j > 0) {   
                 $pattern .= ‘(‘;    
                 $pattern .= ‘(&#[xX]0{0,8}([9ab]);)‘;   
                 $pattern .= ‘|‘;    
                 $pattern .= ‘|(&#0{0,8}([9|10|13]);)‘;   
                 $pattern .= ‘)*‘;   
              }   
              $pattern .= $ra[$i][$j];   
           }   
           $pattern .= ‘/i‘;    
           $replacement = substr($ra[$i], 0, 2).‘<x>‘.substr($ra[$i], 2); // add in <> to nerf the tag    
           $val = preg_replace($pattern, $replacement, $val); // filter out the hex tags    
           if ($val_before == $val) {    
              // no replacements were made, so exit the loop    
              $found = false;    
           }    
        }    
     }    
     $val = preg_replace(‘/\>|\<|\"|\‘|[()=]|(alert)|(if)/i‘, ‘‘, $val);  
     $val = preg_replace(‘/(xrame)|(onxload)|(body)|(prompt)/i‘,‘‘,$val);
     return $val;    
  }    

}

 

cakephp的 \cake24\Cake\Controller\BaseController.php

标签:1.5   insert   xpl   jsonp   数据库   oda   commit   code   anywhere   

原文地址:http://www.cnblogs.com/polax/p/6907599.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!