public function init()
 {
     Yii::log(Yii::app()->getRequest()->getRequestUri(), 'trace', 'API_RAW_REQUEST_URL');
     if (!empty($_GET['code']) && !empty($_GET['state']) && $_GET['state'] == 'wxbutton') {
         $temopenid = WX::getUserWebOpenid($_GET['code']);
         if (!empty($temopenid)) {
             Yii::app()->session['openid'] = $temopenid;
         }
     }
     $this->openid = Yii::app()->session['openid'];
     if (in_array(SERVER_NAME, array('yicheng', 'mac'))) {
         $this->openid = 'opYNAwg9MS6Btoo0cVmvvQLSaoHY';
     }
     $this->user_id = UserIdentity::getuserid($this->openid);
     Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/css/jquery-2.1.4.min.js');
     Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/css/bootstrap/css/bootstrap.css');
     Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/css/bootstrap/js/bootstrap.min.js');
     Yii::app()->clientScript->registerScriptFile("http://res.wx.qq.com/open/js/jweixin-1.0.0.js");
     Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/css/yunba/socket.io-1.3.5.min.js');
     Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/css/yunba/yunba-js-sdk.js');
     $this->signPackage = $this->getSignPackage();
 }
 public static function createOrUpdate($udid)
 {
     $type = 'update';
     $userid = UserIdentity::getuserid($udid);
     $community = Community::model()->findByAttributes(array('user_id' => $userid));
     if (!$community) {
         $community = new Community();
         $type = 'create';
     }
     $userlocate = User::model()->get_locate()->findByPk($userid);
     $community->user_id = $userid;
     $community->begin_time = self::getTime();
     $community->lng = $userlocate->y;
     $community->lat = $userlocate->x;
     $community->type = 1;
     $community->communityid = uniqid("", true);
     $community->des = $userlocate->nickname . "的漂流伞";
     if (!$community->save()) {
         Yii::log(CVarDumper::dumpAsString($community->errors), 'error', 'Community new save error');
     } else {
         BDLbs::createOrUpdate(intval($community->id), $community->des, $community->des, $community->lat, $community->lng, $type);
         return true;
     }
 }