public static function createMainSearchFiltersCache() { // $mainSearchFilters['media']['formats'] = $this->getDistinctFieldAndCount('format', ['unit']); // $mainSearchFilters['media']['domains'] = $this->getDistinctFieldAndCount('domain', ['unit']); $mainSearchFilters['media']['categories'] = static::getCategories(); $mainSearchFilters['media']['all'] = ["count" => Entity::whereIn('tags', ['unit'])->count(), "label" => "All Media"]; //unset($mainSearchFilters['media']['documentTypes']['twrex']); $mainSearchFilters['job']['count'] = Entity::where('type', 'job')->count(); $mainSearchFilters['workers']['count'] = CrowdAgent::all()->count(); ksort($mainSearchFilters['media']['categories']); $entity = new Temp(); $entity->_id = "mainSearchFilters"; $entity->filters = $mainSearchFilters; $entity->save(); return $entity->toArray(); }
public function actionAjaxGetCode() { $uid = Yii::app()->request->getPost('sms_uid'); $psw = Yii::app()->request->getPost('sms_psw'); $cid = Yii::app()->request->getPost('sms_cid'); $phone = Yii::app()->request->getPost('sms_phone'); $arr = explode(',', '0,1,2,3,4,5,6,7,8,9'); $code = ''; for ($i = 0; $i < 6; $i++) { $tag = mt_rand(0, 9); $code .= $arr[$tag]; } $temp_model = new Temp(); $temp_model->phone = trim($phone); $temp_model->code = trim($code); $temp_model->time = time(); if ($temp_model->save()) { $sms = new SMSComponent($uid, $psw, $cid); $res = $sms->sendMsg($code, $phone); $res = CJSON::decode($res); if ($res['code'] == 0) { echo CJSON::encode(array('success' => true, 'msg' => '短信已发送,请注意查收')); } else { echo CJSON::encode(array('success' => false, 'msg' => '短信发送失败,请稍后重试')); } } else { echo CJSON::encode(array('success' => false, 'msg' => '验证码获取失败,请稍后重试')); } }