/** * 修改个人信息 */ function actionChangeInfo() { $this->_pathway->addStep('个人信息'); $currentUser = $this->_app->currentUser(); $user = Users::find()->getById($currentUser['id']); $form = new Form_User(url('admin::usercenter/changeInfo')); $form->element('username')->set('readonly', 'true'); $form->remove('password'); $form->element('group_id')->items = Groups::find('id=?', $user->group_id)->order('weight desc')->getAll()->toHashMap('id', 'name'); $form->element('level_id')->items = Levels::find('weight=?', $user->level_id)->order('weight desc')->getAll()->toHashMap('weight', 'name'); $form->remove('enabled'); $form->add(QForm::ELEMENT, 'id', array('_ui' => 'hidden', 'value' => $currentUser['id'])); if ($this->_context->isPOST() && $form->validate($_POST)) { try { $user->changeProps($form->values()); $user->save(); return "{msg:'编辑成功'}"; } catch (QDB_ActiveRecord_ValidateFailedException $ex) { $form->invalidate($ex); } } else { $form->import($user); } $form->add(QForm::ELEMENT, 'reg_at', array('_ui' => 'textbox', '_label' => '注册时间', 'value' => date('Y-m-d', $user->register_at), 'class' => 'txt w200', 'readonly' => 'true')); $form->add(QForm::ELEMENT, 'reg_ip', array('_ui' => 'textbox', '_label' => '注册IP', 'value' => $user->register_ip, 'class' => 'txt w200', 'readonly' => 'true')); $form->add(QForm::ELEMENT, 'log_at', array('_ui' => 'textbox', '_label' => '最后登录时间', 'value' => $user->login_at == 0 ? '0000-00-00' : date('Y-m-d', $user->login_at), 'class' => 'txt w200', 'readonly' => 'true')); $form->add(QForm::ELEMENT, 'log_ip', array('_ui' => 'textbox', '_label' => '最后登录IP', 'value' => $user->login_ip, 'class' => 'txt w200', 'readonly' => 'true')); $form->add(QForm::ELEMENT, 'log_count', array('_ui' => 'textbox', '_label' => '登录次数', 'value' => $user->login_count, 'class' => 'txt w200', 'readonly' => 'true')); $this->_view['form'] = $form; }
public function loadModel($id) { $model = Levels::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Cette méthode permet de logger une information avec le niveau de notre choix (une constante de Levels). * Par ailleurs, cette méthode prend en charge les templates type {clef} qu'il map avec les données de $context * @param string $level : Une constante de Levels, défini le niveau de logg * @param string $message : Le message à logger * @param array $context : Optionnel, le tableau des données à mapper au message (une donnée est fourni au format 'clef' => 'valeur' * @return int : 0 = erreur, 1 = Log, 2 = Log et email */ public function log($level, $message, array $context = array()) { //On map d'éventuels flags du message avec les données du context foreach ($context as $key => $value) { $message = str_replace('{' . $key . '}', $value, $message); } //On ajoute l'en-tête au log et le saut de ligne $logHeader = '[' . date('Y-m-d H:i:s') . '] [PID : ' . getmypid() . ' USER UID : ' . posix_geteuid() . '] (IP : ' . (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'UNKNOWN') . ') [' . $level . '] : '; $message = $logHeader . $message . "\n"; //Si le niveau d'erreur n'existe pas if (!array_key_exists($level, Levels::getLevels())) { return 0; } //On va essayer d'utiliser des constantes pour les différentes infos du logger. //Si on ne trouve pas on va définir une valeur par défaut $activ = DESCARTESLOGGER_ACTIV; $minLevel = DESCARTESLOGGER_MIN_LEVEL; $email = DESCARTESLOGGER_EMAIL; $minLevelEmail = DESCARTESLOGGER_MIN_LEVEL_EMAIL; $file = DESCARTESLOGGER_FILE; if (!$activ) { return 0; } //Ne pas oublier que les levels sont etiquetés selon une forme étrange (plus important = 0 moins important = 7) if ($minLevel > Levels::getLevels()[$level]) { return 0; } //On commence à essayer d'ecrire if (!($handle = fopen($file, 'ab'))) { return 0; } if (!fwrite($handle, $message)) { return 0; } fclose($handle); //Si on ne doit pas mail if (!$email || !($minLevelEmail > Levels::getLevels()[$level])) { return 1; } //On essaye de mail if (!mail($email, 'DescartesLogger - ' . $level, $message)) { return 1; } return 2; }
if ($model->isNewRecord) { ?> <hr class="row-divider"> <button class="btn btn-info" type="button" onclick="$('#webrights').slideToggle('slow');">Добавить WEB админа</button> <div id="webrights" style="display: none"><br> <?php echo $form->textFieldRow($webadmins, 'username', array('class' => 'span6', 'size' => 32, 'maxlength' => 32, 'value' => 'Будет использован ник Amx админа', 'disabled' => 'disabled')); ?> <?php echo $form->passwordFieldRow($webadmins, 'password', array('class' => 'span6', 'size' => 32, 'maxlength' => 32, 'value' => '')); ?> <?php echo $form->textFieldRow($webadmins, 'email', array('class' => 'span6', 'size' => 60, 'maxlength' => 64)); ?> <?php echo $form->dropdownListRow($webadmins, 'level', Levels::getList(), array('class' => 'span6')); ?> </div> <?php } ?> <div class="form-actions"> <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Добавить' : 'Сохранить')); ?> </div> <?php $this->endWidget();
function __construct() { Debug::log("Iniciando libraries/router/RouterBase.", __LINE__, __FUNCTION__, __CLASS__, __FILE__); parent::__construct(); }
public function applyLanguageByUrl() { Run::$benchmark->mark("Router/Levels/LanguageByUrl/Inicio"); Debug::log("Iniciando applyLanguageByUrl.", __LINE__, __FUNCTION__, __CLASS__, __FILE__); //verifica se possui referencia de idioma //Debug::print_r(Language::$AVALIABLE); if (isset(self::$levels[0])) { if (in_array(Levels::$levels[0], Language::$AVALIABLE)) { Language::$ENABLED = self::$levels[0]; Language::$USING = true; self::$levelRef = 1; } else { //seta idioma default Language::$ENABLED = Run::LANGUAGE_DEFAULT; Language::$USING = false; } } else { Language::$ENABLED = Run::LANGUAGE_DEFAULT; Language::$USING == false; } if (Run::ROUTER_FIXED_LANGUAGE && !in_array(Levels::$levels[0], Language::$AVALIABLE) || Run::ROUTER_FIXED_START && self::$levels[self::$levelRef] == "") { Debug::log("Redirecionando para idioma default.", __LINE__, __FUNCTION__, __CLASS__, __FILE__); //self::$levelRef = 1; $start = Run::ROUTER_FIXED_START && self::$levels[self::$levelRef] == "" ? Run::ROUTER_START : $this->getPath(); $redirect = $this->path_url; //Debug::p("REDIRECT: ".$redirect); if (self::$levels[0] != Language::$ENABLED && Run::ROUTER_FIXED_LANGUAGE) { $redirect .= $this->path['base'] . Language::$ENABLED . "/"; } //Debug::p("REDIRECT: ".$redirect); $redirect .= $start; //Debug::p("REDIRECT: ".$redirect); //exit; header("Location: " . $redirect); exit; } else { //Language::$ENABLED = Run::LANGUAGE_DEFAULT; //Language::$USING = false; } Run::$benchmark->writeMark("Router/Levels/LanguageByUrl/Inicio", "Router/Levels/LanguageByUrl/ChecklanguageRouter"); if (Run::LANGUAGE_AUTO_LOAD_PHRASES) { Language::loadPhrasesFromProperties(Language::$ENABLED); } Run::$benchmark->writeMark("Router/Levels/LanguageByUrl/ChecklanguageRouter", "Router/Levels/LanguageByUrl/loadPhrasesFromProperties"); //Debug::print_r(self::$levels); Run::$benchmark->writeMark("Router/Levels/LanguageByUrl/Inicio", "Router/Levels/LanguageByUrl/Final"); }
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('type' => 'vertical', 'id' => 'webadmins-form', 'enableAjaxValidation' => true)); ?> <p class="note">Поля, отмеченные <span class="required">*</span> обязательны к заполнению.</p> <fieldset> <?php echo $form->errorSummary($model); ?> <?php echo $form->textFieldRow($model, 'username', array('size' => 32, 'maxlength' => 32)); ?> <?php echo $form->passwordFieldRow($model, 'password', array('size' => 32, 'maxlength' => 32, 'value' => '')); ?> <?php echo $form->dropdownListRow($model, 'level', Levels::getList()); ?> <?php echo $form->textFieldRow($model, 'email', array('size' => 60, 'maxlength' => 64)); ?> <?php if (!$model->isNewRecord) { echo $form->textFieldRow($model, 'try'); } ?> </fieldset> <div class="form-actions"> <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Создать' : 'Обновить')); ?> <?php
<?php /** * Форма добавления/редактирования уровней админов */ /** * @author Craft-Soft Team * @package CS:Bans * @version 1.0 beta * @copyright (C)2013 Craft-Soft.ru. Все права защищены. * @link http://craft-soft.ru/ * @license http://creativecommons.org/licenses/by-nc-sa/4.0/deed.ru «Attribution-NonCommercial-ShareAlike» */ $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('type' => 'horisontal', 'id' => 'levels-form', 'enableAjaxValidation' => false)); $array = Levels::getValues(); $array2 = Levels::getValues(TRUE); ?> <?php echo $form->errorSummary($model); ?> <?php echo $form->dropDownListRow($model, 'bans_add', $array, array('class' => 'span5', 'maxlength' => 3)); ?> <?php echo $form->dropDownListRow($model, 'bans_edit', $array2, array('class' => 'span5', 'maxlength' => 3)); ?> <?php
<?php /** * Вьюшка управления веб админами */ /** * @author Craft-Soft Team * @package CS:Bans * @version 1.4.0 * @copyright (C)2016 Craft-Soft.ru. Все права защищены. * @link http://craft-soft.ru/ * @license http://creativecommons.org/licenses/by-nc-sa/4.0/deed.ru «Attribution-NonCommercial-ShareAlike» */ $this->pageTitle = Yii::app()->name . ' :: Админцентр - WEB админы'; $this->breadcrumbs = array('Админцентр' => array('/admin/index'), 'Управление WEB админами'); $this->menu = array(array('label' => 'Админцентр', 'url' => array('/admin/index')), array('label' => 'Добавить админа', 'url' => array('create'))); $this->renderPartial('/admin/mainmenu', array('active' => 'site', 'activebtn' => 'webadmins')); ?> <h2>Управление ВЕБ админаи</h2> <?php $this->widget('bootstrap3.widgets.BsGridView', array('id' => 'webadmins-grid', 'type' => 'striped bordered condensed', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', 'username', 'email', array('name' => 'level', 'filter' => Levels::getList()), array('class' => 'bootstrap3.widgets.BsButtonColumn'))));
public function hasChildren() { reset($this->toConsume); list($key, $value) = each($this->toConsume); $this->childCachePrefix = $key; $this->childCache = $this->levels->getChildrenOfAtLevel($key, $this->level + 1); return (bool) $this->childCache; }
/** * 详情 等级 */ function actionLevelView() { $this->_pathway->addStep('浏览等级详情'); $id = $this->_context->id; $level = Levels::find()->getById($id); $this->_view['level'] = $level; }
$form = $this->beginWidget('bootstrap3.widgets.BsActiveForm', array('layout' => 'horizontal', 'id' => 'webadmins-form', 'enableAjaxValidation' => true)); ?> <p class="note">Поля, отмеченные <span class="required">*</span> обязательны к заполнению.</p> <fieldset> <?php echo $form->errorSummary($model); ?> <?php echo $form->textFieldControlGroup($model, 'username', array('size' => 32, 'maxlength' => 32)); ?> <?php echo $form->passwordFieldControlGroup($model, 'password', array('size' => 32, 'maxlength' => 32, 'value' => '')); ?> <?php echo $form->dropdownListControlGroup($model, 'level', Levels::getList()); ?> <?php echo $form->textFieldControlGroup($model, 'email', array('size' => 60, 'maxlength' => 64)); ?> <?php if (!$model->isNewRecord) { echo $form->textFieldControlGroup($model, 'try'); } ?> </fieldset> <div class="form-group"> <button type="submit" class="btn btn-primary">Сохранить</button> </div> <?php
function actionPutout() { $this->_pathway->addStep('媒资编目'); $id = $this->_context->id; $file = Files::find()->getById($id); if ($file->isNewRecord()) { return '记录不存在或已删除'; } if (!file_exists($file->path . $file->name . '.' . $file->ext)) { return '文件不存在或已删除'; } //保存编目信息 if ($this->_context->isPOST()) { $file->level = $this->_context->level; if (!isset($this->_context->groups) || in_array('all', $this->_context->groups)) { $file->groups = 'all'; } else { $file->groups = ','; foreach ($this->_context->groups as $v) { $file->groups .= $v . ','; } } $file->is_download = $this->_context->is_download; $file->status = $this->_context->status; $file->putout_username = $this->_view['currentUser']['username']; $file->putout_at = time(); try { $file->save(); } catch (QDB_ActiveRecord_ValidateFailedException $ex) { return '提交失败!'; } //更新索引 $filesCounter = FilesCounter::find()->getById(1); if ($filesCounter->isNewRecord()) { $filesCounter = new FilesCounter(); $filesCounter->id = 1; } $filesCounter->file_id = $file->id(); try { $filesCounter->save(); @exec(Q::ini('appini/search/sphinxDelta')); } catch (QDB_ActiveRecord_ValidateFailedException $ex) { return '更新索引失败!'; } return '提交成功!'; } $this->_view['file'] = $file; $this->_view['levels'] = Levels::find('enabled=1')->getAll(); $this->_view['groups'] = Groups::find('enabled=1')->getAll(); }