📄 indexcontroller.php
字号:
<?php
/*
秀影EasyFramework框架
qq:24498936
msn:jdzcn_net@hotmail.com
website:http://www.vodcms.com
*/
class IndexController extends Easy_Controller_Action {
public $_AdminModel;
public function Init(){
$this->_AdminModel = new AdminModel();
$this->_ModuleModel = new ModuleModel();
$this->_Deny = new DenyModel();
$this->_Deny->CheckDeny();
//$acl = new AclModel();
//$acl->set('guest');
if ($this->_Request->getParam('action') != 'index' && $this->_Request->getParam('action') != 'login' ){
if ($this->_AdminModel->CheckLogin() != true){
exit($this->_View->render('index/index_login'));
}
}
}
public function IndexAction(){
// $this->_AdminModel = new AdminModel();
$this->_Request->setSession('failed', NULL);
if ($this->_Request->getSession('id') > 0){
$this->_View->topModule = $this->_ModuleModel->getTopMenu();
}
$this->_View->title = '秀影系统管理后台';
if ($this->_AdminModel->CheckLogin() != true){
exit($this->_View->render('index/index_login'));
}
}
public function LoginAction(){
$maxTimeout = 5;
$username = $this->_Request->getPost('username');
$password = $this->_Request->getPost('password');
$array['username'] = strtolower($username);
$array['password'] = MD5(strtolower($password));
$code = (int)$this->_Request->getSession('code');
if ($code !== (int)$this->_Request->getPost('code')){
$this->_View->error ='<script>alert("'._('验证码输入不正确!').'");</script>';
}elseif ($result = $this->_AdminModel->Login($array)){
$this->_View->Redirect('?mod=index');
exit;
}else{
$this->_View->error =_('用户名或者密码不正确!');
$this->failed = $this->_Request->getSession('failed');
$this->_Request->setSession('failed', ($this->failed + 1));
if ($this->failed >= $maxTimeout){
if ($this->failed == $maxTimeout){
$this->_Deny->deny($array['username'].'后台登陆密码错误次数太多!',
$this->_Request->StrUserIp(), $this->_Request->StrUserIp(), 5); //写入封锁IP
$this->_Request->sendHeader(403);
echo _('您的密码错误次数太多!请15分钟后访问此页!');
exit;
}
}
}
}
public function AuthAction(){
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Content-type: image/png");
$height = 19;
$width = 47;
$im = ImageCreateTrueColor($width, $height);
$blue = ImageColorAllocate ($im, 255,255,255);
$f1 = ImageColorAllocate ($im, 79,14,95);
$f2 = ImagecolorAllocate($im,201,16,63);
$f3 = ImagecolorAllocate($im,22,104,11);
ImageFill($im, 0, 0, $blue);
$str = substr(rand(), 0, 4);
$this->_Request->setSession('code', $str);
$yan=ImageString($im, 5, 6, 1, substr($str,0,1), $f2);
$yan=ImageString($im, 5, 15,1, substr($str,1,1), $fl);
$yan=ImageString($im, 5, 25, 1, substr($str,2,1), $f2);
$yan=ImageString($im, 5, 34,1, substr($str,3,1), $f3);
ImagePng ($im);
ImageDestroy($im);
exit;
}
public function TopAction(){
}
public function LeftAction(){
$id = (int)$this->_Request->getParam('menu') ? (int)$this->_Request->getParam('menu') : 1;
$this->_View->row = $this->_ModuleModel->getModule(array('id'=> $id));
$this->_View->leftModule = $this->_ModuleModel->getAll(array('parentid'=>$id));
$this->_View->flag = (int)$this->_Request->getSession('flag');
}
public function MainAction(){
$DB = $GLOBALS['DB'];
$this->_View->mysqlversion = $DB->version();
$this->_View->information = $this->_AdminModel->information();
$this->_View->license = $GLOBALS['license'];
$this->_View->ver = base64_encode(http_build_query($GLOBALS['license']));
}
public function notieAction(){
}
public function CopyrightAction(){
}
public function logoutAction(){
$this->_Request->setSession('id', null);
$this->_Request->setSession('flag', null);
$this->_Request->setSession('failed', null);
$this->_Request->setCookie('admin', null);
$this->_Request->setSession('group', null);
$this->_Request->setSession('hash', null);
$this->_View->redirect('?mod=index&action=login');
exit;
}
public function reportAction(){
if ($this->_Request->isPost()){
$email = $this->_Request->getPost('email');
$subject = $this->_Request->getPost('subject');
$contents = $this->_Request->getPost('contents');
if ($email && $subject && $contents){
$Mail = new Mail();
if ($Mail->sendMail(array('24498936@qq.com', 'jdzcn_net@hotmail.com'), $subject, $contents)===true){
$this->_View->message = _('报告提交成功!我们将在48小时内给您回复');
}else{
$this->_View->message = _('报告发送失败!错误原因:'.$Mail->ErrorInfo);
}
exit($this->_View->render('message'));
}else{
$this->_View->message = _('提交失败!您的信息填写不完整');
exit($this->_View->render('message'));
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -