Inheritance: extends AdminVIEWS
 /**
  * 记录日志
  * @param type $result
  */
 public function log($result, $modelId = 0)
 {
     $log = new AdminLogs();
     $log->admin_id = Yii::app()->user->user_id;
     $log->admin_name = Yii::app()->user->user_name;
     $log->ip = Yii::app()->request->userHostAddress;
     $log->model_id = $modelId == 0 ? $this->attributes[$this->primaryKey] : $modelId;
     $log->result = $result;
     $log->model = strtolower(get_class($this));
     $log->save();
 }
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = AdminLogs::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #3
0
 public function actionDelete($id, $page = null)
 {
     $data = AdPosition::get_one_by_id($id, false);
     if ($data['ad_position_system']) {
         if (!isset($_GET['ajax'])) {
             $this->redirect[] = array('text' => '', 'href' => url($this->module->id . '/Ad/Position/Index'));
             $this->message('系统广告位,不允许删除!', self::MSG_SUCCESS, true);
         }
     }
     Yii::app()->db->createCommand()->update('{{ad_position}}', array('ad_position_status' => AdPosition::STAT_DELETED), 'ad_position_id=:ad_position_id', array(':ad_position_id' => $id));
     //更新缓存
     AdPosition::update_cache();
     //记录操作日志
     $user = Yii::app()->user;
     $message = '{user_name}删除了广告位{ad_position_name}';
     $data = array('user_id' => $user->id, 'user_name' => $user->name, 'ad_position_name' => $data['ad_position_name'], 'addons_data' => array('ad_position_id' => $id));
     AdminLogs::add($user->id, 'Ad/Position', $id, 'Delete', 'success', $message, $data);
     if (!isset($_GET['ajax'])) {
         $this->redirect(array('Ad/Position/Index'));
     }
 }
Example #4
0
     $log = new Logs($db);
     $comments = new Comments($db, $user);
     $reports = new Reports($db, $user, $torrent, $subtitles, $requests, $forum, $mailbox, $comments, $log);
     list($result, $totalCount) = $reports->query(array("limit" => $_GET["limit"], "index" => $_GET["index"]));
     httpResponse($result, $totalCount);
     break;
 case validateRoute('PATCH', 'reports/\\d+'):
     $reports = new Reports($db, $user);
     httpResponse($reports->update((int) $params[1], $postdata));
     break;
 case validateRoute('DELETE', 'reports/\\d+'):
     $reports = new Reports($db, $user);
     httpResponse($reports->delete((int) $params[1]));
     break;
 case validateRoute('GET', 'adminlogs'):
     $adminlogs = new AdminLogs($db, $user);
     list($result, $totalCount) = $adminlogs->query(array("limit" => $_GET["limit"], "index" => $_GET["index"], "search" => $_GET["searchText"]));
     httpResponse($result, $totalCount);
     break;
 case validateRoute('GET', 'recovery-logs'):
     $recoveryLog = new RecoveryLog($db, $user);
     list($result, $totalCount) = $recoveryLog->query(array("limit" => $_GET["limit"], "index" => $_GET["index"]));
     httpResponse($result, $totalCount);
     break;
 case validateRoute('GET', 'sqlerrors'):
     $sqlerrors = new SqlErrors($db, $user);
     list($result, $totalCount) = $sqlerrors->query(array("limit" => $_GET["limit"], "index" => $_GET["index"]));
     httpResponse($result, $totalCount);
     break;
 case validateRoute('GET', 'cheatlogs'):
     $cheatlogs = new CheatLogs($db, $user);
Example #5
0
 public function delete($id)
 {
     if ($this->getClass() < self::CLASS_ADMIN) {
         throw new Exception('Du saknar rättigheter.', 401);
     }
     $user = $this->get($id);
     foreach (explode(", ", "iplog, bonuslog, bookmarks, snatch, reqvotes, blocks, bevaka, cheatlog, invites, readposts, peers") as $x) {
         $this->db->query("DELETE FROM " . $x . " WHERE userid = " . $id);
     }
     $this->db->query("DELETE FROM users WHERE id = " . $id);
     $this->db->query("DELETE FROM messages WHERE receiver = " . $id);
     $this->db->query("DELETE FROM friends WHERE friendid = " . $id . " OR userid = " . $id);
     $adminlogs = new AdminLogs($this->db, $this);
     $adminlogs->create("{{username}} raderade kontot [b]" . $user["username"] . "[/b] ifrån databasen");
 }
Example #6
0
 /**
  * 档案栏目管理
  */
 public function indexAction()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         //保存修改
         if (!is_array($_POST['class_name'])) {
             $_POST['class_name'] = array();
         }
         foreach ($_POST['class_name'] as $_k => $_v) {
             $flag = $this->db->update('{{content_archives_classes}}', array('class_name' => $_v, 'class_identify' => $_POST['class_identify'][$_k], 'content_model_id' => $_POST['content_model_id'][$_k], 'class_is_show' => $_POST['class_is_show'][$_k], 'class_rank' => $_POST['class_rank'][$_k], 'class_lasttime' => $_SERVER['REQUEST_TIME']), 'class_id=:class_id', array(':class_id' => $_k));
             if ($flag) {
                 //记录操作日志
                 $message = '{user_name}修改了档案栏目{classes_name}';
                 $data = array('classes_name' => $_v, 'data' => $_POST);
                 AdminLogs::add('Content/Class', $_k, 'Modify', 'success', $message, $data);
             }
         }
         //添加新记录
         if (!is_array($_POST['class_name_new'])) {
             $_POST['class_name_new'] = array();
         }
         foreach ($_POST['class_name_new'] as $_k => $_v) {
             if (is_array($_v)) {
                 foreach ($_v as $__k => $__v) {
                     $flag = $this->db->insert('{{content_archives_classes}}', array('class_id' => 0, 'class_parent_id' => $_k, 'class_name' => $__v, 'content_model_id' => $_POST['content_model_id_new'][$_k][$__k], 'class_identify' => $_POST['class_identify_new'][$_k][$__k], 'class_is_default' => 0, 'class_default' => 'index.html', 'class_is_part' => ContentArchivesClass::STAT_PART_COVER_CLASS, 'class_tempindex' => '', 'class_templist' => '', 'class_temparticle' => '', 'class_seo_keywords' => '', 'class_seo_description' => '', 'class_status' => ContentArchivesClass::STAT_STATUS_NORMAL, 'class_is_show' => isset($_POST['class_is_show_new'][$_k][$__k]) ? $_POST['class_is_show_new'][$_k][$__k] : 0, 'class_rank' => $_POST['class_rank_new'][$_k][$__k], 'class_lasttime' => $_SERVER['REQUEST_TIME'], 'class_dateline' => $_SERVER['REQUEST_TIME']));
                     if ($flag) {
                         //记录操作日志
                         $message = '{user_name}添加了游戏子栏目{classes_name}';
                         $data = array('classes_name' => $__v, 'data' => $_POST);
                         AdminLogs::add('Content/Class', $this->db->getLastInsertID(), 'Insert', 'success', $message, $data);
                     }
                 }
             } else {
                 $flag = $this->db->insert('{{content_archives_classes}}', array('class_id' => 0, 'class_parent_id' => 0, 'class_name' => $_v, 'content_model_id' => $_POST['content_model_id_new'][$_k], 'class_identify' => $_POST['class_identify_new'][$_k], 'class_is_default' => 0, 'class_default' => 'index.html', 'class_is_part' => ContentArchivesClass::STAT_PART_COVER_CLASS, 'class_tempindex' => '', 'class_templist' => '', 'class_temparticle' => '', 'class_seo_keywords' => '', 'class_seo_description' => '', 'class_status' => ContentArchivesClass::STAT_STATUS_NORMAL, 'class_is_show' => isset($_POST['class_is_show_new'][$_k]) ? $_POST['class_is_show_new'][$_k] : 0, 'class_rank' => $_POST['class_rank_new'][$_k], 'class_lasttime' => $_SERVER['REQUEST_TIME'], 'class_dateline' => $_SERVER['REQUEST_TIME']));
                 if ($flag) {
                     //记录操作日志
                     $message = '{user_name}添加了档案栏目{classes_name}';
                     $data = array('classes_name' => $_v, 'data' => $_POST);
                     AdminLogs::add('Content/Class', $this->db->getLastInsertID(), 'Insert', 'success', $message, $data);
                 }
             }
         }
         ContentArchivesClassModel::updateCache();
         $this->refresh();
     }
     //
     $classes = ContentArchivesClassModel::inst()->getClassesByCache();
     //
     $models = ContentModelModel::inst()->getModelsByCache();
     $this->getView()->assign(array('classes' => $classes, 'models' => $models));
 }
Example #7
0
 /**
  * 内容模型管理
  */
 public function indexAction($page = null)
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         //保存修改
         if (!is_array($_POST['Model']['content_model_rank'])) {
             $_POST['Model']['content_model_rank'] = array();
         }
         foreach ($_POST['Model']['content_model_rank'] as $_k => $_v) {
             $flag = Yii::app()->db->createCommand()->update('{{content_model}}', array('content_model_rank' => $_POST['Model']['content_model_rank'][$_k] ? intval($_POST['Model']['content_model_rank'][$_k]) : 255, 'content_model_lasttime' => $_SERVER['REQUEST_TIME']), 'content_model_id=:content_model_id', array(':content_model_id' => $_k));
             if ($flag) {
                 //记录操作日志
                 $message = '{user_name}修改了内容模型({model_name})排序';
                 $data = array('user_id' => Yii::app()->user->id, 'user_name' => Yii::app()->user->name, 'model_name' => ContentModel::get_model_name_by_id($_k), 'addons_data' => $_POST);
                 AdminLogs::add(Yii::app()->user->id, 'Content/Model', $_k, 'Modify', 'success', $message, $data);
             }
         }
         ContentModel::update_cache();
         //$this->refresh();
         $this->redirect[] = array('text' => '', 'href' => '/content/model/index');
         $this->message('修改内容模型完成', self::MSG_SUCCESS, true);
     }
     $this->getView()->assign(array('models' => ContentModelModel::inst()->getModelsByCache()));
 }
Example #8
0
 public function actionDelete($collect_model_id, $id)
 {
     $collect_fields_name = CollectModelField::get_fields_name_by_id($id);
     $collect_model_identify = CollectModel::get_model_identify_by_id($collect_model_id);
     $collect_fields = CollectModelField::get_fields_identify_by_id($collect_model_id, $id);
     $sql = "ALTER TABLE `collect_model_addons{$collect_model_identify}` DROP  `" . $collect_fields['collect_fields_identify'] . "`";
     Yii::app()->db->createCommand($sql)->execute();
     Yii::app()->db->createCommand()->update('{{collect_model_fields}}', array('collect_fields_status' => CollectModelField::STAT_DELETED), 'collect_fields_id=:collect_fields_id', array(':collect_fields_id' => $id));
     CollectModelField::update_cache();
     //记录操作日志
     $user = Yii::app()->user;
     $message = '{user_name}删除了采集字段{collect_fields_name}';
     $data = array('user_id' => $user->id, 'user_name' => $user->name, 'collect_fields_name' => $collect_fields_name, 'data' => array('collect_fields_id' => $id));
     AdminLogs::add($user->id, 'Collect/Fields', $id, 'Delete', 'success', $message, $data);
     if (!isset($_GET['ajax'])) {
         $this->redirect(array("Collect/Model/{$collect_model_id}/Fields/Index"));
     }
 }
Example #9
0
 public function delete($id)
 {
     if ($this->getClass() < self::CLASS_ADMIN) {
         throw new Exception(L::get("PERMISSION_DENIED"), 401);
     }
     $user = $this->get($id);
     foreach (explode(", ", "iplog, bonuslog, bookmarks, snatch, reqvotes, blocks, bevaka, cheatlog, invites, readposts, peers") as $x) {
         $this->db->query("DELETE FROM " . $x . " WHERE userid = " . $id);
     }
     $this->db->query("DELETE FROM users WHERE id = " . $id);
     $this->db->query("DELETE FROM messages WHERE receiver = " . $id);
     $this->db->query("DELETE FROM friends WHERE friendid = " . $id . " OR userid = " . $id);
     $adminlogs = new AdminLogs($this->db, $this);
     $adminlogs->create(L::get("ACCOUNT_REMOVED_LOG", [$user["username"]], Config::DEFAULT_LANGUAGE));
 }
Example #10
0
File: Rule.php Project: nbaiwan/yav
 public function deleteAction($id, $page = null)
 {
     $collect_rule_name = CollectRuleModel::inst()->getRuleNameById($id);
     $this->db->update('{{collect_rule}}', array('collect_rule_status' => CollectRuleModel::STAT_DELETED), 'collect_rule_id=:collect_rule_id', array(':collect_rule_id' => $id));
     CollectRuleModel::inst()->updateCache();
     //记录操作日志
     $message = '{user_name}删除了采集模板{collect_rule_name}';
     $data = array('collect_rule_name' => $collect_rule_name, 'addons_data' => array('collect_rule_id' => $id));
     AdminLogs::add('Collect/Rule', $id, 'Delete', 'success', $message, $data);
     if (!isset($_GET['ajax'])) {
         $this->redirect('/collect/rule/index');
     }
 }
Example #11
0
 /**
  * 文档管理
  */
 public function actionIndex($content_model_id = null, $class_id = null, $search_key = null, $page = null)
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         //保存修改
         if (!is_array($_POST['Archive']['content_archives_rank'])) {
             $_POST['Archive']['content_archives_rank'] = array();
         }
         foreach ($_POST['Archive']['content_archives_rank'] as $_k => $_v) {
             $flag = Yii::app()->db->createCommand()->update('{{content_model}}', array('content_archives_rank' => $_POST['Archive']['content_archives_rank'][$_k] ? intval($_POST['Archive']['content_archives_rank'][$_k]) : 255, 'content_archives_lasttime' => $_SERVER['REQUEST_TIME']), 'content_archives_id=:content_archives_id', array(':content_archives_id' => $_k));
             if ($flag) {
                 //记录操作日志
                 $message = '{user_name}修改了文档({archive_subject})信息';
                 $data = array('user_id' => Yii::app()->user->id, 'user_name' => Yii::app()->user->name, 'archive_subject' => $_v, 'data' => $_POST);
                 AdminLogs::add(Yii::app()->user->id, 'Content/Archive', $_k, 'Modify', 'success', $message, $data);
             }
         }
         //$this->refresh();
         $this->redirect[] = array('text' => '', 'href' => $this->forward ? $this->forward : url($this->module->id . '/Content/Archives/Index'));
         $this->message('修改文档完成', self::MSG_SUCCESS, true);
     }
     $params = array('allow_cache' => false, 'content_model_id' => $content_model_id, 'class_id' => $class_id ? $class_id : 2, 'search_key' => $search_key);
     $_model = ContentModel::get_model_by_id($content_model_id);
     $_list_template = $_model['content_model_list_template'] ? $_model['content_model_list_template'] : 'default';
     $this->render("_{$_list_template}_list", array('content_model_id' => $content_model_id, 'class_id' => $class_id, 'archives' => ContentArchives::Pages($params), 'models' => ContentModel::get_models_by_cache(), 'classes' => ContentArchivesClass::get_classes_by_cache()));
 }
Example #12
0
 public function actionDelete($id, $page = null)
 {
     $data = AdData::get_one_by_id($id);
     Yii::app()->db->createCommand()->update('{{ad_data}}', array('ad_data_status' => AdData::STAT_DELETED), 'ad_data_id=:ad_data_id', array(':ad_data_id' => $id));
     //更新缓存
     AdData::update_cache();
     //记录操作日志
     $user = Yii::app()->user;
     $message = '{user_name}删除了广告素材{ad_data_subject}';
     $data = array('user_id' => $user->id, 'user_name' => $user->name, 'ad_data_subject' => $data['ad_data_subject'], 'addons_data' => array('ad_data_id' => $id));
     AdminLogs::add($user->id, 'Ad/Data', $id, 'Delete', 'success', $message, $data);
     if (!isset($_GET['ajax'])) {
         $this->redirect(array('Ad/Data/Index'));
     }
 }
Example #13
0
 /**
  * 
  * @param unknown_type $content_model_id
  */
 public function actionIndex($content_model_id)
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         //保存修改
         if (!is_array($_POST['Field']['content_model_field_rank'])) {
             $_POST['Field']['content_model_field_rank'] = array();
         }
         foreach ($_POST['Field']['content_model_field_rank'] as $_k => $_v) {
             $flag = Yii::app()->db->createCommand()->update('{{content_model_fields}}', array('content_model_field_rank' => $_POST['Field']['content_model_field_rank'][$_k] ? intval($_POST['Field']['content_model_field_rank'][$_k]) : 255), 'content_model_field_id=:content_model_field_id', array(':content_model_field_id' => $_k));
             if ($flag) {
                 //记录操作日志
                 $message = '{user_name}修改了内容模型({model_name})字段({field_name})排序';
                 $data = array('user_id' => Yii::app()->user->id, 'user_name' => Yii::app()->user->name, 'model_name' => ContentModel::get_model_name_by_id($content_model_id), 'field_name' => ContentModelField::get_field_name_by_id($_v), 'addons_data' => $_POST);
                 AdminLogs::add(Yii::app()->user->id, 'Content/Model/Field', $_k, 'Modify', 'success', $message, $data);
             }
         }
         ContentModelField::update_cache();
         //$this->refresh();
         $this->redirect[] = array('text' => '', 'href' => url($this->module->id . "/Content/Model/{$content_model_id}/Field/Index"));
         $this->message('修改字段排序完成', self::MSG_SUCCESS, true);
     }
     $fields = ContentModelField::get_fields_by_cache($content_model_id);
     $this->render('index', array('fields' => $fields, "content_model_id" => $content_model_id));
 }