public function Action()
 {
     switch ($_GET['action']) {
         case 'login':
             if (isset($_POST['send'])) {
                 if (!Validate::Check_Length($_POST['code'], 4, 'equals')) {
                     Tool::alertBack('验证码必须为四位');
                 }
                 if (!Validate::Check_Equals($_POST['code'], strtolower($_SESSION['code']))) {
                     Tool::alertBack('验证码不正确');
                 }
                 $object = $this->model->Manage_Login();
                 if (!Validate::Check_Null($object)) {
                     $_SESSION['admin']['username'] = $object->username;
                     //生成session
                     $_SESSION['admin']['level_position'] = $object->level_position;
                     $this->model->Login_Count();
                     Tool::alertLocation(null, 'admin.php');
                 } else {
                     Tool::alertBack('用户名或者密码错误,请重新输入');
                 }
             }
             break;
         case 'logout':
             if (session_start()) {
                 session_destroy();
             }
             Tool::alertLocation(null, 'admin_login.php');
             break;
     }
 }
Beispiel #2
0
 public static function checkAdmin()
 {
     if (!isset($_SESSION['ticeAdmin'])) {
         Tool::alertLocation('请先登录', Controller::createUrl('default/login'));
         return false;
     }
     return true;
 }
Beispiel #3
0
 public function checkLogin()
 {
     if (!isset($_SESSION['ticeStuId'])) {
         Tool::alertLocation(null, Controller::createUrl('user/login'));
         return false;
     }
     return true;
 }
Beispiel #4
0
 static function Check_Login()
 {
     if (session_start()) {
         if (!isset($_SESSION['admin'])) {
             Tool::alertLocation(null, 'admin_login.php');
         }
     }
 }
 private function delete()
 {
     if (isset($_GET['id'])) {
         $this->_model->id = $_GET['id'];
         $this->_model->deleteComment() ? Tool::alertLocation('Succeed', PREV_URL) : Tool::alertBack('Fail');
     } else {
         Tool::alertBack("illegal operation");
     }
 }
 private function delete()
 {
     if (isset($_GET['id'])) {
         $this->_model->id = $_GET['id'];
         $this->_model->deleteComment() ? Tool::alertLocation('恭喜你,删除评论成功!', PREV_URL) : Tool::alertBack('很遗憾,删除评论失败!');
     } else {
         Tool::alertBack('非法操作!');
     }
 }
 private function Comment_Del()
 {
     if (isset($_GET['id']) && $_GET['action'] == 'del') {
         $this->model->id = $_GET['id'];
         if ($this->model->Del_Comment()) {
             Tool::alertLocation('删除成功', PREV_URL);
         }
     }
 }
 private function add()
 {
     if (@$_POST['send'] == '新增管理员') {
         $this->_model->admin_user = $_POST['admin_user'];
         $this->_model->admin_pass = sha1($_POST['admin_pass']);
         $this->_model->level = $_POST['level'];
         $this->_model->addManage() ? Tool::alertLocation('添加成功', 'manage.php?action=list') : Tool::alertBack('添加失败');
     }
     $this->_tpl->assign('add', true);
     $this->_tpl->assign('title', '新增管理员');
 }
 public function Delete_Level()
 {
     $this->id = $_GET['id'];
     $sql_delete = "delete from manage_level where id='{$this->id}' limit 1";
     $affected_rows = parent::add_up_de($sql_delete);
     if ($affected_rows == 1) {
         Tool::alertLocation('删除成功', 'level.php?action=show');
     } else {
         Tool::alertBack('删除失败');
     }
 }
 private function delete()
 {
     if (isset($_GET['id'])) {
         $this->_model->id = $_GET['id'];
         $_manage = new ManageModel();
         $_manage->level = $this->_model->id;
         if ($_manage->getOneManage()) {
             Tool::alertBack('this level could not be deleted. please delete user first');
         }
         $this->_model->deleteLevel() ? Tool::alertLocation('Succeed', PREV_URL) : Tool::alertBack('Fail');
     } else {
         Tool::alertBack("illegal operation");
     }
 }
 private function delCache()
 {
     $_dir = ROOT_PATH . '/cache/';
     if (!($_dh = @opendir($_dir))) {
         return;
     }
     while (false !== ($_obj = readdir($_dh))) {
         if ($_obj == '.' || $_obj == '..') {
             continue;
         }
         @unlink($_dir . '/' . $_obj);
     }
     closedir($_dh);
     Tool::alertLocation('succeed', 'main.php');
 }
Beispiel #12
0
 private function setCount()
 {
     if (isset($_POST['send'])) {
         if (empty($_POST['vote'])) {
             Tool::alertClose('警告:请选择一个投票项目!');
         }
         if ($_COOKIE['ip'] == $_SERVER["REMOTE_ADDR"]) {
             if (time() - $_COOKIE['time'] < 86400) {
                 Tool::alertLocation('警告:您已经参与了本投票,请不要重复投票!', 'cast.php');
             }
         }
         $this->_model->id = $_POST['vote'];
         $this->_model->setCount();
         setcookie('ip', $_SERVER["REMOTE_ADDR"]);
         setcookie('time', time());
         Tool::alertLocation('恭喜,累计投票成功,感谢您的参与!', 'cast.php');
     }
 }
 public function login()
 {
     if (isset($_POST['send'])) {
         if (Validate::checkLength($_POST['code'], 4, 'equals')) {
             Tool::alertBack('validation code must be 4');
         }
         if (Validate::checkEquals(strtolower($_POST['code']), $_SESSION['code'])) {
             Tool::alertBack('wrong validation code');
         }
         if (Validate::checkNull($_POST['admin_user'])) {
             Tool::alertBack('username empty');
         }
         if (Validate::checkLength($_POST['admin_user'], 2, 'min')) {
             Tool::alertBack('username less than 2');
         }
         if (Validate::checkLength($_POST['admin_user'], 20, 'max')) {
             Tool::alertBack('username more than 20');
         }
         if (Validate::checkNull($_POST['admin_pass'])) {
             Tool::alertBack('password empty');
         }
         if (Validate::checkLength($_POST['admin_pass'], 6, 'min')) {
             Tool::alertBack('password less than 6');
         }
         $this->_model->admin_user = $_POST['admin_user'];
         $this->_model->admin_pass = md5($_POST['admin_pass']);
         $_login = $this->_model->getLoginManage();
         if ($_login) {
             $_SESSION['admin']['admin_user'] = $_login->admin_user;
             $_SESSION['admin']['level_name'] = $_login->level_name;
             Tool::alertLocation(null, 'admin.php');
         } else {
             Tool::alertBack('username or password not right');
         }
     }
 }
 private function delete()
 {
     if (isset($_GET['id'])) {
         $this->_model->id = $_GET['id'];
         $this->_model->deleteNav() ? Tool::alertLocation('succeed', PREV_URL) : Tool::alertBack('fail');
     } else {
         Tool::alertBack('illegal act');
     }
 }
 public function Action()
 {
     global $templates;
     switch ($_GET['action']) {
         case 'show':
             $templates->assgin('title', '文档列表');
             $templates->assgin('show', true);
             $nav = new NavModel();
             $id = $nav->Get_All_Childid();
             foreach ($id as $value) {
                 $arr[] = $value->id;
             }
             $nav_id = implode(',', $arr);
             $content = new ContentModel();
             $content->nav = $nav_id;
             $templates->assgin('Show_Content', $content->Get_Content());
             //显示所有的content
             $this->Nav();
             //显示所有的导航,select标签
             if (isset($_GET['nav']) && $_GET['send'] == '刷选') {
                 //开始刷选
                 if ($_GET['nav'] != 0) {
                     //不为零
                     $content->nav = $_GET['nav'];
                 } else {
                     $content->nav = $nav_id;
                     //为零的话,默认全部
                 }
                 $templates->assgin('Show_Content', $content->Get_Content());
                 //显示所有的content
             }
             break;
         case 'update':
             if ($_POST['send'] == '修改文档') {
                 $this->model->id = $_POST['id'];
                 $this->Get_Post();
                 $this->model->Update_Content() ? Tool::alertLocation('文档修改成功', 'content.php?action=show') : Tool::alertBack('文档修改失败');
             }
             $templates->assgin('title', '修改文档');
             $templates->assgin('update', true);
             if (isset($_GET['id'])) {
                 $content = new ContentModel();
                 $content->id = $_GET['id'];
                 $object = $content->Get_One_Content();
                 if (!$object) {
                     Tool::alertBack('文档不存在');
                 }
                 $templates->assgin('titlec', $object->title);
                 $this->attr($object->attr);
                 $this->Nav($object->nav);
                 $this->readlimit($object->read_limit);
                 $this->color($object->color);
                 $this->sort($object->sort);
                 $this->commend($object->commend);
                 $templates->assgin('id', $object->id);
                 $templates->assgin('tag', $object->tag);
                 $templates->assgin('keyword', $object->keyword);
                 $templates->assgin('thumbnail', $object->thumbnail);
                 $templates->assgin('source', $object->source);
                 $templates->assgin('author', $object->author);
                 $templates->assgin('info', $object->info);
                 $templates->assgin('content', $object->content);
                 $templates->assgin('read_count', $object->read_count);
                 $templates->assgin('gold', $object->gold);
                 $templates->assgin('color', $object->color);
             } else {
                 Tool::alertBack('非法操作');
             }
             break;
         case 'add':
             if (isset($_POST['send'])) {
                 $this->Get_Post();
                 $affect = $this->model->Add_Content();
                 if ($affect == 1) {
                     Tool::alertLocation('添加文档成功', '?action=show');
                 } else {
                     Tool::alertBack('警告:文档添加失败');
                 }
             }
             $templates->assgin('title', '新增文档');
             $templates->assgin('add', true);
             $this->Nav();
             break;
         case 'delete':
             if (isset($_GET['id'])) {
                 $this->model->id = $_GET['id'];
                 $this->model->Delete_Content() ? Tool::alertLocation('文档删除成功', 'content.php?action=show') : Tool::alertBack('文档删除失败');
             }
             break;
         default:
             echo '非法操作';
             break;
     }
 }
 public function login()
 {
     if (isset($_POST['send'])) {
         parent::__construct($this->_tpl, new UserModel());
         if (Validate::checkNull($_POST['user'])) {
             Tool::alertBack('警告:用户名不得为空!');
         }
         if (Validate::checkLength($_POST['user'], 2, 'min')) {
             Tool::alertBack('警告:用户名长度不得小于两位!');
         }
         if (Validate::checkLength($_POST['user'], 20, 'max')) {
             Tool::alertBack('警告:用户名长度不得大于二十位!');
         }
         if (Validate::checkLength($_POST['pass'], 6, 'min')) {
             Tool::alertBack('警告:密码不得小于六位!');
         }
         if (Validate::checkLength($_POST['code'], 4, 'equals')) {
             Tool::alertBack('警告:验证码必须是四位!');
         }
         if (Validate::checkEquals(strtolower($_POST['code']), $_SESSION['code'])) {
             Tool::alertBack('警告:验证码不正确!');
         }
         $this->_model->user = $_POST['user'];
         $this->_model->pass = sha1($_POST['pass']);
         if (!!($_user = $this->_model->checkLogin())) {
             $_cookie = new Cookie('user', $_user->user, $_POST['time']);
             $_cookie->setCookie();
             $_cookie = new Cookie('face', $_user->face, $_POST['time']);
             $_cookie->setCookie();
             $this->_model->id = $_user->id;
             $this->_model->time = time();
             $this->_model->setLaterUser();
             Tool::alertLocation(null, './');
         } else {
             Tool::alertBack('警告:用户名或密码错误!');
         }
     }
     $this->_tpl->assign('login', true);
 }
 private function setCount()
 {
     if (isset($_GET['cid']) && isset($_GET['id']) && isset($_GET['type'])) {
         parent::__construct($this->_tpl, new CommentModel());
         $this->_model->id = $_GET['id'];
         if (!$this->_model->getOneComment()) {
             Tool::alertBack('警告:不存在此评论!');
         }
         if ($_GET['type'] == 'sustain') {
             $this->_model->setSustain() ? Tool::alertLocation('支持成功!', 'feedback.php?cid=' . $_GET['cid']) : Tool::alertLocation('支持失败!', 'feedback.php?cid=' . $_GET['cid']);
         }
         if ($_GET['type'] == 'oppose') {
             $this->_model->setOppose() ? Tool::alertLocation('反对成功!', 'feedback.php?cid=' . $_GET['cid']) : Tool::alertLocation('反对失败!', 'feedback.php?cid=' . $_GET['cid']);
         }
     }
 }
 private function sus_opp()
 {
     $comment = new CommentModel();
     $comment->cid = $_GET['cid'];
     //支持
     if ($_GET['action'] == 'sustain') {
         $comment->sustain() ? Tool::alertLocation('谢谢您的评价', 'feedback.php?cid=' . $comment->cid) : Tool::alertBack('对不起,请重试');
     }
     //反对
     if ($_GET['action'] == 'oppose') {
         $comment->oppose() ? Tool::alertLocation('谢谢您的评价', 'feedback.php?cid=' . $comment->cid) : Tool::alertBack('对不起,请重试');
     }
 }
 private function Logout()
 {
     $cookie = new Cookie('user');
     $cookie->Destory_Cooie();
     Tool::alertLocation(NULL, 'register.php?action=login');
 }
 public function deleteManage()
 {
     $this->id = $_GET['id'];
     $sql_delete = "delete from manage where id='{$this->id}' limit 1";
     $affected_rows = parent::add_up_de($sql_delete);
     if ($affected_rows == 1) {
         Tool::alertLocation('删除管理员成功', 'manage.php?action=show');
     } else {
         Tool::alertBack('删除管理员失败');
     }
 }
 private function Del_Rotatain()
 {
     $rotatain = new RotatainModel();
     $rotatain->id = $_GET['id'];
     if ($rotatain->Del_Rotatain()) {
         Tool::alertLocation('删除成功', PREV_URL);
     }
 }
Beispiel #22
0
 private function show()
 {
     if (isset($_POST['send'])) {
         $this->_model->webname = $_POST['webname'];
         $this->_model->page_size = $_POST['page_size'];
         $this->_model->article_size = $_POST['article_size'];
         $this->_model->nav_size = $_POST['nav_size'];
         $this->_model->updir = $_POST['updir'];
         $this->_model->ro_time = $_POST['ro_time'];
         $this->_model->ro_num = $_POST['ro_num'];
         $this->_model->adver_text_num = $_POST['adver_text_num'];
         $this->_model->adver_pic_num = $_POST['adver_pic_num'];
         if ($this->_model->setSystem()) {
             $_br = "\r\n";
             $_tab = "\t";
             $_profile = '<?php' . $_br;
             $_profile .= $_tab . "//系统配置文件" . $_br;
             $_profile .= $_tab . "define('WEBNAME','{$this->_model->webname}');" . $_br;
             $_profile .= $_tab . "define('PAGE_SIZE',{$this->_model->page_size});" . $_br;
             $_profile .= $_tab . "define('ARTICLE_SIZE',{$this->_model->article_size});" . $_br;
             $_profile .= $_tab . "define('NAV_SIZE',{$this->_model->nav_size});" . $_br;
             $_profile .= $_tab . "define('UPDIR','{$this->_model->updir}');" . $_br;
             $_profile .= $_br;
             $_profile .= $_tab . "//轮播器配置" . $_br;
             $_profile .= $_tab . "define('RO_TIME',{$this->_model->ro_time});" . $_br;
             $_profile .= $_tab . "define('RO_NUM',{$this->_model->ro_num});" . $_br;
             $_profile .= $_br;
             $_profile .= $_tab . "//广告服务" . $_br;
             $_profile .= $_tab . "define('ADVER_TEXT_NUM',{$this->_model->adver_text_num});" . $_br;
             $_profile .= $_tab . "define('ADVER_PIC_NUM',{$this->_model->adver_pic_num});" . $_br;
             $_profile .= $_tab . "//不可修改的项目" . $_br;
             $_profile .= $_br;
             $_profile .= $_tab . "//数据库配置文件" . $_br;
             $_profile .= $_tab . "define('DB_HOST','localhost');" . $_br;
             $_profile .= $_tab . "define('DB_USER','root');" . $_br;
             $_profile .= $_tab . "define('DB_PASS','yangfan');" . $_br;
             $_profile .= $_tab . "define('DB_NAME','cms');" . $_br;
             $_profile .= $_tab . "define('DB_PORT',3306);" . $_br;
             $_profile .= $_br;
             $_profile .= $_tab . "define('GPC',get_magic_quotes_gpc());" . $_br;
             $_profile .= $_tab . "define('PREV_URL',\$_SERVER[\"HTTP_REFERER\"]);" . $_br;
             $_profile .= $_br;
             $_profile .= $_tab . "//模板配置信息" . $_br;
             $_profile .= $_tab . "define('TPL_DIR',ROOT_PATH.'/templates/');" . $_br;
             $_profile .= $_tab . "define('TPL_C_DIR',ROOT_PATH.'/templates_c/');" . $_br;
             $_profile .= $_tab . "define('CACHE',ROOT_PATH.'/cache/');" . $_br;
             $_profile .= $_tab . "define('MARK',ROOT_PATH.'/images/yc.png');" . $_br;
             $_profile .= '?>' . $_br;
             if (!file_put_contents('../config/profile.inc.php', $_profile)) {
                 Tool::alertBack('警告:生成配置文件失败!');
             }
             Tool::alertLocation('恭喜,修改配置文件成功!', 'system.php');
         } else {
             Tool::alertBack('很遗憾,修改配置文件失败!');
         }
     }
     $_object = $this->_model->getSystem();
     $this->_tpl->assign('webname', $_object->webname);
     $this->_tpl->assign('page_size', $_object->page_size);
     $this->_tpl->assign('article_size', $_object->article_size);
     $this->_tpl->assign('nav_size', $_object->nav_size);
     $this->_tpl->assign('updir', $_object->updir);
     $this->_tpl->assign('ro_time', $_object->ro_time);
     $this->_tpl->assign('ro_num', $_object->ro_num);
     $this->_tpl->assign('adver_text_num', $_object->adver_text_num);
     $this->_tpl->assign('adver_pic_num', $_object->adver_pic_num);
 }
 public function Action()
 {
     global $templates;
     switch ($_GET['action']) {
         case 'show':
             $templates->assgin('title', '会员列表');
             $templates->assgin('show', true);
             parent::Page($this->model->Get_User_Num());
             $all_user = $this->model->Get_ALL_User();
             foreach ($all_user as $value) {
                 if ($value->state == 1) {
                     $value->state = '仅可以登入';
                 }
                 if ($value->state == 0) {
                     $value->state = '封杀会员';
                 }
                 if ($value->state == 2) {
                     $value->state = '初级会员';
                 }
                 if ($value->state == 3) {
                     $value->state = '中级会员';
                 }
                 if ($value->state == 4) {
                     $value->state = '高级会员';
                 }
                 if ($value->state == 5) {
                     $value->state = 'VIP会员';
                 }
             }
             $templates->assgin('ALL_user', $all_user);
             break;
         case 'update':
             if ($_POST['send'] == '修改') {
                 $this->model->id = $_POST['id'];
                 $this->model->password = $_POST['password'];
                 $this->model->face = $_POST['face'];
                 $this->model->question = $_POST['question'];
                 $this->model->answer = $_POST['answer'];
                 $this->model->email = $_POST['email'];
                 $this->model->state = $_POST['state'];
                 if ($this->model->Update_User()) {
                     Tool::alertLocation('修改成功', '?action=show');
                 } else {
                     Tool::alertBack('修改失败');
                 }
             }
             if (isset($_GET['id'])) {
                 $templates->assgin('id', $_GET['id']);
                 $templates->assgin('prev_url', PREV_URL);
                 $templates->assgin('title', '修改会员');
                 $templates->assgin('update', true);
                 $this->model->id = $_GET['id'];
                 $object = $this->model->Get_One_User();
                 $face = $this->face($object->face);
                 $question = $this->question($object->question);
                 $state = $this->state($object->state);
                 $templates->assgin('all_state', $state);
                 $templates->assgin('all_question', $question);
                 $templates->assgin('all_face', $face);
                 $templates->assgin('face', $object->face);
                 $templates->assgin('answer', $object->answer);
                 $templates->assgin('username', $object->username);
                 $templates->assgin('email', $object->email);
                 $templates->assgin('id', $object->id);
                 $templates->assgin('level_info', $object->level_info);
             }
             break;
         case 'add':
             $templates->assgin('title', '新增会员');
             break;
         case 'delete':
             if ($_GET['action'] == 'delete') {
                 $this->model->id = $_GET['id'];
                 if ($this->model->Delete_User()) {
                     Tool::alertLocation('会员删除成功', PREV_URL);
                 } else {
                     Tool::alertBack('会员删除失败');
                 }
             }
             break;
         default:
             echo '非法操作';
             break;
     }
 }
 private function delete()
 {
     if (isset($_GET['id'])) {
         $this->_model->id = $_GET['id'];
         $this->_model->deleteContent() ? Tool::alertLocation('文档删除成功!', PREV_URL) : Tool::alertBack('警告:文档删除失败!');
     } else {
         Tool::alertBack('警告:非法操作!');
     }
 }
 public function login()
 {
     if (isset($_POST['send'])) {
         parent::__construct($this->_tpl, new UserModel());
         $this->_model->user = $_POST['user'];
         $this->_model->pass = md5($_POST['pass']);
         if (!!($_user = $this->_model->checkLogin())) {
             $_cookie = new Cookie('user', $_user->user, $_POST['time']);
             $_cookie->setCookie();
             $_cookie = new Cookie('face', $_user->face, $_POST['time']);
             $_cookie->setCookie();
             $this->_model->id = $_user->id;
             $this->_model->time = time();
             $this->_model->setLaterUser();
             Tool::alertLocation(null, './');
         } else {
             Tool::alertBack('wrong username or password');
         }
     }
     $this->_tpl->assign('login', true);
 }
Beispiel #26
0
<?php

define("IN_TG", true);
require dirname(__FILE__) . '/init.inc.php';
isset($_SESSION['admin']) ? Tool::alertLocation(null, 'admin.php') : Tool::alertLocation(null, 'admin_login.php');
 private function setCount()
 {
     if (isset($_GET['cid']) && isset($_GET['id']) && isset($_GET['type'])) {
         parent::__construct($this->_tpl, new CommentModel());
         $this->_model->id = $_GET['id'];
         if (!$this->_model->getOneComment()) {
             Tool::alertBack('this comment not existing');
         }
         if ($_GET['type'] == 'sustain') {
             $this->_model->setSustain() ? Tool::alertLocation('succeed', 'feedback.php?cid=' . $_GET['cid']) : Tool::alertLocation('fail', 'feedback.php?cid=' . $_GET['cid']);
         }
         if ($_GET['type'] == 'oppose') {
             $this->_model->setOppose() ? Tool::alertLocation('succeed', 'feedback.php?cid=' . $_GET['cid']) : Tool::alertLocation('fail', 'feedback.php?cid=' . $_GET['cid']);
         }
     }
 }
Beispiel #28
0
 public static function checkSession()
 {
     if (!isset($_SESSION['admin'])) {
         Tool::alertLocation('非法登录', 'admin_login.php');
     }
 }
Beispiel #29
0
<?php

require substr(dirname(__FILE__), 0, -6) . '/init.inc.php';
global $_tpl;
$_login = new LoginAction($_tpl);
$_login->_action();
if (isset($_SESSION['admin'])) {
    Tool::alertLocation(null, 'admin.php');
}
$_tpl->display('admin_login.tpl');
 private function sus_opp()
 {
     $this->model->cid = $_GET['cid'];
     $this->model->id = $_GET['id'];
     //支持
     if ($_GET['action'] == 'sustain') {
         $this->model->sustain() ? Tool::alertLocation('谢谢您的评价', 'feedback.php?cid=' . $this->model->cid) : Tool::alertBack('对不起,请重试');
     }
     //反对
     if ($_GET['action'] == 'oppose') {
         $this->model->oppose() ? Tool::alertLocation('谢谢您的评价', 'feedback.php?cid=' . $this->model->cid) : Tool::alertBack('对不起,请重试');
     }
 }