public function actionIndex() { $criteria = new CDbCriteria(); $criteria->order = 't.order'; $criteria->with = array('config'); $model = ConfigGroup::model()->opened()->findAll($criteria); // Save if (isset($_POST['Config'])) { if (isset($_POST['Config'][request()->csrfTokenName])) { unset($_POST['Config'][request()->csrfTokenName]); } foreach ($_POST['Config'] as $k => $v) { db()->createCommand()->update('{{config}}', array('value' => $v, 'updated_at' => date('Y-m-d H:i:s')), 'param = :param', array(':param' => $k)); } if (request()->isAjaxRequest) { echo 'ok'; app()->end(); } } if (isset($_POST['Reset'])) { $configModel = Config::model()->find('param = :param', array(':param' => $_POST['Reset']['field'])); if ($configModel !== NULL) { $configModel->setAttribute('value', $configModel->default); $configModel->save(FALSE); echo $configModel->default; } else { echo 'fail'; } app()->end(); } $this->render('//settings/index', array('model' => $model)); }
private function loadModel($id) { $model=Config::model()->findByPk($id); if($model===null) throw new CHttpException(404,'The requested page does not exist.'); return $model; }
/** * Updates a particular model. * @param integer $id the ID of the model to be updated */ public function actionUbah($id) { $this->penjualanId = $id; $model = $this->loadModel($id); // Penjualan tidak bisa diubah kecuali statusnya draft if ($model->status != Penjualan::STATUS_DRAFT) { $this->redirect(array('index')); } $this->namaProfil = $model->profil->nama; $this->profil = Profil::model()->findByPk($model->profil_id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $penjualanDetail = new PenjualanDetail('search'); $penjualanDetail->unsetAttributes(); $penjualanDetail->setAttribute('penjualan_id', '=' . $id); $barang = new Barang('search'); $barang->unsetAttributes(); if (isset($_GET['cariBarang'])) { $barang->setAttribute('nama', $_GET['namaBarang']); $criteria = new CDbCriteria(); $criteria->order = 'nama ASC'; $barang->setDbCriteria($criteria); } $configCariBarang = Config::model()->find("nama='pos.caribarangmode'"); $this->render('ubah', array('model' => $model, 'penjualanDetail' => $penjualanDetail, 'barang' => $barang, 'tipeCari' => $configCariBarang->nilai)); }
public function init() { /* if($error=Yii::app()->errorHandler->error) { $this->render('//site/error', array('error' => $error));exit(); } */ // put config into params $Configs = Config::model()->findAll(array('index' => 'key')); if (!isset($Configs['host']) || $_SERVER['HTTP_HOST'] !== $Configs['host']['value']) { // put the latest host into the database. if (!isset($Configs['host'])) { $Configs['host'] = new Config(); $Configs['host']->key = 'host'; } $Configs['host']->value = $_SERVER['HTTP_HOST']; $Configs['host']->save(); if (!isset($Configs['https'])) { $Configs['https'] = new Config(); $Configs['https']->key = 'https'; } $Configs['https']->value = (int) isset($_SERVER['HTTPS']); $Configs['https']->save(); } foreach ($Configs as $setting) { Yii::app()->params[$setting['key']] = $setting['value']; } //check for encyption key passphrase being set EncryptFile::checkPassphrase(); }
protected function beforeRender($view) { parent::beforeRender($view); $titles = $this->pageTitles; $titles[] = Config::model()->get('title'); $this->setPageTitle(implode(' - ', $titles)); return true; }
/** * 实时获取系统配置 * @return [type] [description] */ private function _config() { $model = Config::model()->findAll(); foreach ($model as $key => $row) { $config[$row['variable']] = $row['value']; } return $config; }
public function get($param) { Yii::import('application.models.Config'); $criteria = new CDbCriteria(); $criteria->compare('name', $param, false); $model = Config::model()->find($criteria); return $model->value; }
public function getConfigData() { $contactData = new ConfigForm(); foreach ($contactData->attributes as $k => $v) { $contacts[$k] = Config::model()->findByPk($k)->config_value; } return $contacts; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Config the loaded model * @throws CHttpException */ public function loadModel($id) { $Config = Config::model()->findByPk($id); if ($Config === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $Config; }
public function getConfigData() { $contactData = Config::model()->findAll(); foreach ($contactData as $k => $v) { $contacts[$v->config_name] = $v->config_value; } return $contacts; }
/** * * @return <type> */ public function get_settings() { $rows = Config::model()->findAll(); // create ассоц массив с именем опции как ключ foreach ($rows as $row) { $res[$row['key']] = $row; } return $res; }
public function getConfig($param = null) { $config = Config::model()->getConfigData(); if ($param) { return $config[$param]; } else { return $config; } }
/** * 实时获取系统配置 * @return [type] [description] */ public static function _config() { $model = Config::model()->findAll(); if ($model) { foreach ($model as $key => $row) { $config[$row['variable']] = $row['value']; } return $config; } }
public function actionIndex() { //seo $title[] = Config::model()->get('title'); $this->setPageTitle(implode('-', $title)); $keywords = array('成都网站设计', '成都网站建设', '成都网站优化', '成都网站维护', '成都网站制作', '成都网站建设公司', '成都网站制作公司', '成都网站设计公司', '成都网络营销公司'); $this->setPageState('keywords', implode(',', $keywords)); $description[] = Config::model()->get('name') . '主要提供包括网站建设、域名注册、网站设计制作、网站优化托管、网络综合营销在内的一站式网络应用及解决方案,' . Config::model()->get('name') . '是一家四川地区知名的专业互联网运营商之一。'; $this->setPageState('description', implode(',', $description)); $this->render('index'); }
public function actionContent_about() { $model = Config::model()->findByPk(1); if (isset($_POST['Config'])) { $model->attributes = $_POST['Config']; if ($model->save()) { Yii::app()->user->setFlash('config', true); $this->redirect(array('content_about')); } } $this->render('content_about', array('model' => $model)); }
public function actionEditconfig($cid) { $configModel = Config::model(); $configInfo = $configModel->findByPk($cid); $configInfotmp = $configInfo; Yii::import('application.vendors.*'); require_once 'Qiniu/rs.php'; require_once 'Qiniu/io.php'; $bucket = Yii::app()->params['bucket']; $accessKey = Yii::app()->params['accessKey']; $secretKey = Yii::app()->params['secretKey']; if (isset($_POST['Config'])) { $post = $_POST['Config']; $configInfo->attributes = $post; if ($configInfo->validate()) { $images = ""; if (!empty($_FILES['icon']['tmp_name'])) { $file = $_FILES['icon']; $type = ".jpg"; if (ImageTypeCheck($file['name'], $file['size'])) { $newname = time() . rand(10000, 99999) . $type; Qiniu_SetKeys($accessKey, $secretKey); $putPolicy = new Qiniu_RS_PutPolicy($bucket); $upToken = $putPolicy->Token(null); list($ret, $err) = Qiniu_Put($upToken, $newname, file_get_contents($file['tmp_name']), null); if ($err === null) { //ok $images = Yii::app()->params['resurl'] . $newname; } else { //no } } //Get original Pic and Del $icon = GetImageFileName($configInfotmp->icon); if (!empty($icon)) { Qiniu_SetKeys($accessKey, $secretKey); $client = new Qiniu_MacHttpClient(null); $err = Qiniu_RS_Delete($client, $bucket, $icon[0]); } } else { $images = $configInfo->icon; } $configInfo->icon = $images; if (!$configInfo->save()) { Yii::app()->user->setFlash('state', "Sorry,系统错误,修改配置失败 :("); } else { $this->redirect(array('webconfig')); } } } $data = array('editModel' => $configInfo); $this->render('editconfig', $data); }
/** * Default action of controller, edits site configuration * * @throws CHttpException */ public function actionIndex() { if (($model = Config::model()->find()) === null) { throw new CHttpException(404, 'The requested page does not exist.'); } if (isset($_POST['Config'])) { $model->attributes = $_POST['Config']; if ($model->save()) { Yii::app()->user->setFlash('success', "Изменения успешно сохранены!"); } } $this->render('update', array('model' => $model)); }
public static function queueList() { $task = Config::model()->get('task'); if (!empty($task)) { $task = json_decode($task); $task = array_unique($task); echo '<pre>'; foreach ($task as $k => $v) { echo 'task: ' . $v; echo "\r\n"; } } }
private function loadConfigModel() { $conf = Yii::app()->cache->get('siteconfig'); if($conf===false){ $model = Config::model()->find(array('condition'=>'id=1')); if($model==null){ return $model; } $conf = $model; Yii::app()->cache->set('siteconfig',$model,3600*24*30); } return $conf; }
public function save() { foreach ($this->attributes as $k => $v) { $model = Config::model()->findByPk($k); if (!$model) { $model = new Config(); } $model->config_name = $k; $model->config_value = $v; $model->save(); } return true; }
/** * 获取配置信息 * @param string $var [description] * @param string $scope [description] * @return [type] [description] */ public static function get($var = '') { $model = Config::model()->findAll(); $config = null; foreach ($model as $key => $row) { if ($var && $var == $row['variable']) { return $row['value']; } else { $config[$row['variable']] = $row['value']; } } return $config; }
/** * 获取配置信息 * @param string $var [description] * @param string $scope [description] * @return [type] [description] */ public static function get($var = '', $scope = 'base') { $condition = array('condition' => 'scope=:scope', 'params' => array('scope' => $scope)); $model = Config::model()->findAll($condition); foreach ($model as $key => $row) { if ($var && $var == $row['variable']) { return $row['value']; } else { $config[$row['variable']] = $row['value']; } } return $config; }
public function actionDefault() { $model = new ConfigForm(); if (isset($_POST['ConfigForm'])) { $model->attributes = $_POST['ConfigForm']; $model->save(); $this->redirect('/admin/config'); } foreach ($model->attributes as $k => $v) { $model->{$k} = Config::model()->findByPk($k)->config_value; } $data = array('model' => $model); $this->render('default', $data); }
public static function config($type) { if ($type == 'authcode') { return 'b93154b988e33fdf0d144fde73028b77'; } elseif ($type == 'authorCode') { return '2013@zhangMaofei'; } if (empty(Yii::app()->params['c'])) { $_c = Config::model()->findAll(); $configs = CHtml::listData($_c, 'name', 'value'); tools::writeSet($configs); return stripcslashes($configs[$type]); } else { return stripcslashes(Yii::app()->params['c'][$type]); } }
public function getUInfo($uid) { $data = array(); //Config $userConfig = Config::model(); $sql = "select title,icon,seo,titlecolor,contentcolor from {{webconfig}} where userid = {$uid} "; $data['webconfig'] = $userConfig->findBySql($sql); //About $userModel = new User(); $data['userInfo'] = $userModel->findByPk($uid); //Photo $photoModel = new Photo(); $sql = "select * from {{photo}} where userid = {$uid} order by rand() limit 0,6"; $data['photoInfo'] = $photoModel->findAllBySql($sql); //Lable $data['labelInfo'] = $this->getTags($uid); return $data; }
public function actionUpdate() { $startTime = Yii::app()->request->getParam('start_time'); $endTime = Yii::app()->request->getParam('end_time'); $isOpen = Yii::app()->request->getParam('is_open'); if (!$startTime || !$endTime) { throw new CHttpException(404, Yii::t('yii', '时间设置错误')); } $timeConfig = Config::model()->find('name=:name', array(':name' => 'dinner_time')); $timeConfig->start_time = $startTime; $timeConfig->end_time = $endTime; $timeConfig->is_open = intval($isOpen); if ($timeConfig->save()) { $this->redirect(array('index')); } else { throw new CHttpException(404, Yii::t('yii', '更新失败')); } }
public function actionAdd() { $this->checkPower('setConfig'); $type = zmf::filterInput($_POST['type'], 't', 1); if ($type == '' or !in_array($type, array('baseinfo', 'upload', 'base', 'email'))) { $type = 'baseinfo'; } unset($_POST['type']); unset($_POST['YII_CSRF_TOKEN']); $configs = $_POST; if (!empty($configs)) { foreach ($configs as $k => $v) { if (is_array($v)) { $v = join(',', $v); } //组织出hash,根据变量、变量的值及分类的md5 $_hash = md5($k . $v . $type); //如果能找到hash则说明该设置未变化 $_configInfo = Config::model()->find('`hash`=:hash', array(':hash' => $_hash)); if (!$_configInfo) { //没找到说明已更改或者不存在该设置 //根据name和classify判断是否有该设置,没有则新增,有则更新 $_detailInfo = Config::model()->find('`name`=:name AND classify=:type', array(':name' => $k, ':type' => $type)); if (!$_detailInfo) { //新增 $data = array('name' => zmf::filterInput($k, 't'), 'value' => zmf::filterInput($v, 't'), 'classify' => zmf::filterInput($type, 't'), 'hash' => $_hash); $model = new Config(); $model->attributes = $data; $model->save(); } else { //更新 Config::model()->updateByPk($_detailInfo['id'], array('value' => zmf::filterInput($v, 't'), 'hash' => $_hash)); } } else { //未做变化,不操作 } } } //更新本地配置缓存 $_c = Config::model()->findAll(); $configs = CHtml::listData($_c, 'name', 'value'); zmf::writeSet($configs); $this->redirect(array('config/index', 'type' => $type)); }
public function action_ajax() { $r = Yii::app()->request; //$c = $this->config; switch ($r->getParam('action')) { case 'reviews-enable': Config::model()->updateByPk(1, array('reviews' => $r->getParam('value') == 1 ? 1 : 0)); echo json_encode(1); break; case 'calendar-enable': Config::model()->updateByPk(1, array('eventCalendar' => $r->getParam('value') == 1 ? 1 : 0)); echo json_encode(1); break; case 'pay-points-enable': Config::model()->updateByPk(1, array('paymentPoints' => $r->getParam('value') == 1 ? 1 : 0)); echo json_encode(1); break; case 'similar-news-enable': Config::model()->updateByPk(1, array('relatedNews' => $r->getParam('value') == 1 ? 1 : 0)); echo json_encode(1); break; case 'check-product-enable': Config::model()->updateByPk(1, array('checkStockStatus' => $r->getParam('value') == 1 ? 1 : 0)); echo json_encode(1); break; case 'recoveryPassPhone': Config::model()->updateByPk(1, array('recoveryPassPhone' => $r->getParam('value') == 1 ? 1 : 0)); echo json_encode(1); break; case 'recoveryPassEmail': Config::model()->updateByPk(1, array('recoveryPassEmail' => $r->getParam('value') == 1 ? 1 : 0)); echo json_encode(1); break; case 'ref-enable': Config::model()->updateByPk(1, array('referralSystem' => $r->getParam('value') == 1 ? 1 : 0)); echo json_encode(1); break; default: echo json_encode(null); break; } }
public function isOnTime() { $timeConfig = Config::model()->find('name=:name', array(':name' => 'dinner_time')); $timeConfig = CJSON::decode(CJSON::encode($timeConfig)); if ($timeConfig) { $dataStr = date('Y-m-d', time()); if ($timeConfig['is_open']) { $startTime = strtotime($dataStr . ' ' . $timeConfig['start_time']); $endTime = strtotime($dataStr . ' ' . $timeConfig['end_time']); if ($startTime <= time() && $endTime >= time()) { return true; } else { return false; } } else { return true; } } return true; }
/** * Метод наполнения БД тестовыми данными * $param $alias псевдоним настройки * ничего не возвращает */ private function insertFake($alias) { for ($i = 0; $i < 100; $i++) { //заполняем таблицу users $users = new Users(); $users->username = test . $i; $users->email = 'test' . $i . '@test.com'; $users->password = rand(1000, 99999); $users->first_name = 'firstname' . $i; $users->last_name = 'lastname' . $i; if ($users->validate()) { $users->save(); } //заполняем таблицу trip $trip = new Trip(); $trip->users__id = rand(1, 100); $trip->departure = 'city' . $i; $trip->destination = 'city' . $i; $trip->date_start = date('Y-m-d', strtotime(rand(2012, 2015) . '-' . rand(1, 12) . '-' . rand(1, 28))); $trip->date_end = date('Y-m-d', strtotime(rand(2012, 2015) . '-' . rand(1, 12) . '-' . rand(1, 28))); if ($trip->validate()) { $trip->save(); } //заполняем таблицу purchases $purchase = new Purchases(); $purchase->users__id = rand(1, 100); $purchase->trip__id = rand(1, 100); $purchase->name = 'purchase' . $i; $purchase->price = rand(1, 10000); if ($purchase->validate()) { $purchase->save(); } } $config = Config::model()->findByAlias($alias); if ($config instanceof Config && !(bool) $config->is_done) { $config->is_done = (int) TRUE; $config->save(); } }