⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 membercontroller.php

📁 a short sketch about linux syntex lines.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php
/*
用户控制面板控制器
*/
class MemberController extends Easy_Controller_Action {
	public function Init(){
		$this->_View->setViewRoot('templates');
		$this->_View->skin = $this->config['template'];
		$this->_View->Template = new Template();	//
		$this->_User = new UsersModel();
		$this->uid = (int)$this->_Request->getCookie('uid');
		$this->_View->config = $this->config;
		$filter = array('login', 'logoff','register', 'check', 'lostpass', 'help', 'validate','online','exit', 'resetpass');
		if (in_array($this->_Request->getParam('action'), $filter)===false){
			$this->receive_url = $this->config['domain'].INSTALLDIR.'?mod=member&action=receive';
			$this->_View->user = $this->_User->login(array('uid'=>(int)$this->uid));
			if (!$this->_View->user['uid']){
				exit($this->_View->render('public/validate'));
			}
		}
		$contents = file_get_contents(ROOT.'templates/'.$this->config['template'].'/index.tpl.php');
		preg_match_all('/<link(.+?)>/is', $contents, $tmp);
		foreach($tmp[1] as $css){
			$this->_View->style.= preg_replace('/href="(.+?)"/is', 'href="'.$this->config['basedir'].'templates/'.$this->config['template'].'/$1"', '<link'.$css.'>');
		}
		$this->_View->header = $this->_View->render($this->_View->skin.'/header');
	}
	public function registerAction(){
		if (intval($this->config['register']) === 0 ){
			$this->_View->message = _('网站暂时关闭注册!');
			exit($this->_View->render('public/alert'));
		}
		if ($this->_Request->isPost()){//注册成功
			$POST = $this->_Request->getPost();
			$POST['username'] = trim($this->_Request->getPost('username'));
			$POST['password'] = $this->_Request->getPost('password');
			$POST['passwd'] = $this->_Request->getPost('passwd');
			$POST['usergroup'] = $this->config['usergroup'];
			$POST['logins'] = 1;
			$POST['playtime'] = time();
			$POST['lastime'] = time();
			$POST['locked'] = 0;
			$POST['gender'] = $this->_Request->getPost('gender');
			$POST['email'] = $this->_Request->getPost('email');
			$POST['usertype'] = $this->config['usertype'];
			$POST['point'] = $this->config['point'];
			if (strtotime((string)$this->config['days'])===false){
				$POST['lifetime'] = time()+(86400*(int)$this->config['days']);
			}else{
				$POST['lifetime'] = strtotime((string)$this->config['days']);
			}
			$POST['lifetime'] = date('Y-m-d H:i:s', $POST['lifetime']);
			unset($POST['sub'], $POST['sub_x'], $POST['sub_y']);
			$uid = $this->_User->add($POST);
			if ($uid===false){
				echo '<script>alert("'.implode(',', $this->_User->error).'");history.back();</script>';
				exit;
			}
			$this->_Request->setCookie('username', $POST['username']);
			$this->_Request->setCookie('uid', $uid);
			$this->_Request->setCookie('usergroup', $POST['usergroup']);
			$this->_View->body = $this->_View->render('public/register_2');
		}else{
			$this->_View->body = $this->_View->render('public/register_1');
		}
		exit($this->_View->render('public/register'));
	}
	public function indexAction(){
		$this->editmyselfAction();
	}
	public function CheckAction(){
		header('Content-type: application/x-javascript');
		$username = $this->_Request->getParam('username');
		$useremail = $this->_Request->getParam('email');
		if($username){
			if ($this->config['ucenter'] == 1){
				$ucenter = new Ucenter();
				if ($ucenter->checkusername('username', $username)===false){
					exit('false');
				}
			}
			if ($this->_User->exists(array('username'=>
				$this->_Request->getParam('username')))===false){
				exit('false');
			}else{
				exit('true');
			}
		}elseif ($useremail){	//验证email
			if ($this->config['ucenter'] == 1){
				$ucenter = new Ucenter();
				if ($ucenter->checkusername('email', $useremail)===false){
					exit('false');
				}
			}
			if ($this->_User->exists(array('email'=>
			$this->_Request->getParam('email')))===false){
				exit('false');
			}else{
				exit('true');
			}
		}elseif ($this->_Request->getParam('pass')){
			$where['uid'] = $this->uid;
			$where['password'] = md5(strtolower($this->_Request->getParam('pass')));
			if ($this->_User->exists($where)===false){
				exit('true');
			}else{
				exit('false');
			}
		}
		exit;
	}
	/*登陆窗口*/
	public function loginAction(){
		header ("Cache-Control: no-cache, must-revalidate");
		header ("Pragma: no-cache"); 
		$bar = new NetbarModel();
		$uid = intval($this->_Request->getCookie('uid'));
		$userip = $this->_Request->strUserIp();
		//echo $uid;
		if ($this->_Request->isPost()){
			$playlog = new PlaylogModel();
			$array = null;
			$array['username'] = trim($this->_Request->getPost('username'));
			$array['password'] = strtolower($this->_Request->getPost('password'));
			$referer = $this->_Request->getPost('uri');
			$row = $this->_User->login($array);
			//$tmp = $playlog->isOnline($array['username']);
			if ($row['uid'] ){
				//print_r($this->_Request->getCookie());
				//exit;
				/*if ($tmp && ($this->_Request->getCookie('online') != $tmp['sid'])){
					message(_('您的登陆名已经是登陆状态,请不要多人使用同一账户!\n如果是您上次未正常退出,请在'.(int)($this->config['refreshonline']/60).'分钟后在登陆'),'history.back()');
					exit;
				}*/
				$this->_Request->setCookie('username', $row['username']);
				$this->_Request->setCookie('uid', $row['uid']);
				$this->_Request->setCookie('usergroup', $row['usergroup']);
				$this->_Request->setCookie('point', $row['point']);
				/*写入用户到在线用户列表*/
				$array = array();
				$array['username'] = $row['username'];
				$array['sid'] = session_id();
				$array['userip'] = $this->_Request->strUserip();
				$array['firstime'] = time();
				$array['lastime'] = time();
				$this->_User->setLoginTime($row['uid']);////更新用户最后登录时间
				$playlog->setSession($array);	//write online session
				$this->_Request->setCookie('online', $array['sid'], 86400);
				unset($array);
				if ($referer){
					echo '<script>location.href="'.base64_decode($referer).'";</script>';
				}else{
					echo '<script>history.back(-1);</script>';
					exit;
				}
			}else{
				message(_('用户名或者密码不正确!'),'history.back()');
			}
			exit;
		}else {
			$row = $this->_User->login(array('uid'=>$uid), 1);
			if ($row['uid']){
				$row['groupname'] = $row['groupname'] ? $row['groupname'] : _('游客');
				$playlog = new PlaylogModel();
				$log = $playlog->getRow("a.username='".$row['username']."'");	//获取用户上次观看
				if ( strlen($log['title']) > 0){
					$row['movie'] = '<a href="'.INSTALLDIR.'?mod=movie&action=view&movid='.$log['movid'].'" target="_blank">'.truncate($log['title'],10).'</a>';
				}
				if ($row['usergroup'] == $this->config['vip']){
					$vip = '<a href="'.INSTALLDIR.'?mod=movie&action=vip" target="_blank">'._('秘密通道').'</a>';
					//echo 'd';
				}
				$this->_View->user = $row;
				$this->_View->user['vip'] = $vip;
				if ($row['usertype'] == 1){
					if ($row['lifetime']<=time()){	//包月到期时
						if ($row['point']>0){	//到期但是有影币
							$this->_View->user['state'] = _($row['point'].'点');
						}else{
							$this->_View->user['state'] = _('已到期');
						}
					}else{
						$this->_View->user['state'] = ceil(($row['lifetime'] - time())/86400)._('天');
					}
				}else{
					if ($row['point']<1){
						if ($row['lifetime'] > time()){
							$this->_View->user['state'] = ceil(($row['lifetime'] - time())/86400)._('天');
						}else{
							$this->_View->user['state'] = intval($row['point'])._('点').',<a href="'.INSTALLDIR.'?mod=member&action=payment" target="_blank">'._('请充值').'</a>';
						}
					}else{
						$this->_View->user['state'] = _($row['point'].'点');
					}
				}
				exit($this->_View->render($this->_View->skin.'/login_succeed'));
			}else{	//非登录模式
				$this->_View->netbar =$bar->isAllow($userip);
				$this->_View->netbar['groupname'] = $group[$this->_View->netbar['usergroup']]['title'];
				if ($this->_View->netbar['id']){
					if ($this->_View->netbar['lifetime']<= time()){
						$this->_View->netbar['days'] = _('已到期');
					}else{
						$this->_View->netbar['days'] = ceil(($this->_View->netbar['lifetime']-time())/86400)._('天');
					}
					$group = unserialize(Easy_Cache::get('usergroup'));
					$this->_Request->setCookie('username', $this->_View->netbar['name']);
					exit($this->_View->render($this->_View->skin.'/login_netbar'));
				}elseif($this->config['auth'] !=1){
					if ($this->config['auth'] == 2){	//时间段免费
						$freetime = explode('/', $this->config['freetime']);
						if (date('H')>$freetime[0] || date('H')<$freetime[1]){	//在时间段内
							$this->_View->free['freetime'] = $freetime[0]._('点至'.$freetime[1].'点');
							exit($this->_View->render($this->_View->skin.'/login_free'));
						}else{
							exit($this->_View->render($this->_View->skin.'/login'));
						}
					}else{	//免登录模式
						exit($this->_View->render($this->_View->skin.'/login_free'));
					}
				}else{
					exit($this->_View->render($this->_View->skin.'/login'));
				}
			}
		}
	}
	/*注销用户*/
	public function logoffAction(){
		if ($this->config['ucenter'] == 1){
			$ucenter = new Ucenter();
			echo $ucenter->synlogout( intval($this->_Request->getCookie('uid')) );
			@sleep(1);
		}
		$this->_Request->setCookie('username', null);
		$this->_Request->setCookie('uid', null);
		$this->_Request->setCookie('usergroup', null);
		$playlog = new PlaylogModel();
		$playlog->delSession($this->_Request->getCookie('online'));
		$referer = $_SERVER['HTTP_REFERER'];
		if( $referer ) {
			header('location:'.$referer);
		}else{
			echo '<script>history.back(-1);</script>';
		}
		exit;
	}
	/**/
	public function editmyselfAction(){
		$member = new MemberModel();
		if ($this->_Request->isPost()){
			$POST = $this->_Request->getPost();
			$POST['uid'] = $this->uid;
			$member->editmyself($POST);
			message(_('修改资料成功!'), 'history.back()');
			exit;
		}else{
			$row = $this->_View->user;
			$this->_View->group = unserialize(Easy_Cache::get('usergroup'));
			$row['maxdown'] = $this->_view->group[$row['usergroup']]['maxdown'];
			$row['maxip'] = $this->_view->group[$row['usergroup']]['maxip'];
			$row['maxdata'] = $this->_view->group[$row['usergroup']]['maxdata'];
			$this->_View->modify = $row;
			unset($row);
			$this->_View->rightBody = $this->_View->render('member/editmyself');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -