public function actionLogout() { $this->_sessionRemove('accountID'); $this->_sessionRemove('accountName'); $this->_session->destroy(); unset($_COOKIE['auth']); \app\common\XUtils::message('success', '成功退出', \Yii::$app->urlManager->createUrl(['iadmin/access/login'])); }
public function beforeSave($insert) { parent::beforeSave($insert); $this->url_code = \app\common\XUtils::shorturl($this->url); $this->description = \app\common\XUtils::ihtmlspecialchars($this->description); !$this->id && ($this->createtime = time()); $this->updatetime = time(); return true; }
public function actionUploadDict() { $sougouDir = Yii::$app->params['sougouDictDir']; $dictFiles = array(); if (file_exists($sougouDir)) { if (is_writable($sougouDir)) { $oDir = dir($sougouDir); while (($file = $oDir->read()) !== false) { if (strcasecmp($file, '.') != 0 && strcasecmp($file, '..') != 0) { $filename = $sougouDir . '/' . $file; if (is_dir($filename)) { $subDir = dir($filename); while (($subFile = $subDir->read()) !== false) { if (strcasecmp($subFile, '.') != 0 && strcasecmp($subFile, '..') != 0) { $dictFiles[$file][] = $subFile; } } } } } } else { exit('目录不可写'); } } $count = count($dictFiles); $page = isset($_REQUEST['page']) ? $_REQUEST['page'] ? $_REQUEST['page'] : 1 : 1; $pageSize = 10; $start = ($page - 1) * $pageSize; $pager = new \yii\data\Pagination(array('defaultPageSize' => $pageSize, 'totalCount' => $count)); if ($page > $pager->getPageCount() && $page != 1) { exit('超过最大页数'); } $data = array(); if ($count) { $sArr = array_slice($dictFiles, $start, $pageSize, true); foreach ($sArr as $time => $value) { if (!empty($value)) { foreach ($value as $key => $val) { if (preg_match('/\\.scel/', $val)) { $file = $sougouDir . '/' . $time . '/' . $val; $data[$time][$key] = array('filename' => mb_convert_encoding($val, 'UTF-8', 'GBK,GB2312'), 'filesize' => \app\common\XUtils::file_size_format(filesize($file)), 'filetype' => filetype($file), 'filetime' => date('Y-m-d H:i:s', filemtime($file))); } } } } } if (Yii::$app->request->isPost) { exit(json_encode(array('data' => $data, 'pager' => \yii\widgets\LinkPager::widget(['pagination' => $pager, 'prevPageLabel' => '上一页', 'nextPageLabel' => '下一页'])))); } return $this->render('uploaddict', array('data' => $data, 'pager' => $pager)); }
public function actionFilterKw() { $filterkwPath = ROOT_PATH . '/data/filter_keywords.tmp'; $kwRecord = \app\models\WSetting::find()->select('values')->where(array("keys" => "filter_keywords"))->one(); if ($kwRecord) { $settingModel = \app\models\WSetting::findOne("filter_keywords"); } else { $settingModel = new \app\models\WSetting(); } if (Yii::$app->request->isPost) { if ($_POST['WSetting']) { $_POST['WSetting']['values'] = strip_tags($_POST['WSetting']['values']); $_POST['WSetting']['values'] = preg_replace('/[\'",“ \\|]*/', '', $_POST['WSetting']['values']); $settingModel->attributes = $_POST['WSetting']; if ($settingModel->save()) { file_put_contents($filterkwPath, $_POST['WSetting']['values']); XUtils::message('success', '更新成功'); } } } return $this->render('filterkw', array('model' => $settingModel)); }
public function verifyAccess() { $adminGroupModel = new \app\models\WAdminGroup(); $menuModel = new \app\models\WMenu(); $urlRule = $this->setUrlFlag(); $groupIds = $adminGroupModel->getUserPower($this->_sessionGet('accountID')); if ($groupIds->group_options != 'administrator' && $groupIds->group_options != '') { $rulesArray = $menuModel->getMeunByIf('id in (' . $groupIds->group_options . ')', 'menu_acl'); $rules = array(); foreach ($rulesArray as $val) { $rules[] = $val->menu_acl; } $rules = implode(',', $rules) . ',iadmin_default,iadmin_default_index'; if (strpos($rules, $urlRule) == false) { \app\common\XUtils::message('error', '您没有操作权限', \Yii::$app->urlManager->createUrl(['iadmin/admin/index'])); } } }
/** * 有问题 待解决 * @return [type] [description] */ public function actionDelete() { $adminModel = new \app\models\WAdmin(); $backUrl = \Yii::$app->urlManager->createUrl('iadmin/admin/index'); if (\Yii::$app->request->isGet) { $ids = $this->_getParam('id'); if (!$adminModel->isExist(['id' => $ids], 'id')) { $this->redirect($backUrl); } } elseif (\Yii::$app->request->isPost) { $ids = $this->_getPost('ids'); $ids = implode(',', $ids); } if (in_array(1, (array) $ids)) { \app\common\XUtils::message('error', '超级管理员不能被删除', $backUrl); } if ($adminModel->deleteRecord('id in (' . $ids . ')')) { \app\common\XUtils::message('success', '用户信息删除成功!', $backUrl); } \app\common\XUtils::message('success', '用户信息删除失败,请重试!', $backUrl); }
public function __construct() { $keywords = XUtils::loadcache(ROOT_PATH . '/data/filter_keywords.tmp'); $this->censor_words = $keywords ? explode(',', $keywords) : array(); }
/** * 有问题 待解决 * @return [type] [description] */ public function actionDeletePowerOptions() { $menuModel = new \app\models\WMenu(); $backUrl = \Yii::$app->urlManager->createUrl('iadmin/auth/index-power-options'); if (\Yii::$app->request->isGet) { $ids = $this->_getParam('id'); if (!$menuModel->isExist(['id' => $ids], 'id')) { $this->redirect($backUrl); } } elseif (\Yii::$app->request->isPost) { $ids = $this->_getPost('ids'); $ids = implode(',', $ids); } foreach ((array) $ids as $key => $val) { $subCatalogArray = $menuModel->getMenuListOptions($menuModel->getAllMenus('type <> 1'), $val); if (!empty($subCatalogArray)) { \app\common\XUtils::message('error', 'ID为' . $val . '有下级菜单,不能删除', $backUrl); } } if ($menuModel->deleteRecord('id in (' . $ids . ')')) { \app\common\XUtils::message('success', '菜单信息删除成功!', $backUrl); } \app\common\XUtils::message('error', '用户信息删除失败,请重试!', $backUrl); }