public function addUser()
 {
     $username = I('post.username', 0);
     $password = I('post.password', 0);
     ($username === 0 || $password === 0) && $this->error("大哥别瞎搞!");
     $username = checkUsername($username);
     if (!$username) {
         $this->ajaxReturn("大哥别瞎注册!");
         exit;
     }
     $user = M('user');
     $queryResult = $user->where("username = '******'", $username)->find();
     if ($queryResult) {
         $this->ajaxReturn("user_exist");
         exit;
     }
     $data = array('id' => "", 'username' => $username, 'password' => pwEncrypt($username, $password), 'lasttime' => time(), 'lastip' => get_client_ip());
     $result = $user->add($data);
     if ($result) {
         $this->ajaxReturn("ok");
         exit;
     } else {
         $this->ajaxReturn("注册失败!");
         exit;
     }
 }
 public function index()
 {
     $sysinfo = M('sys')->order('id asc')->find();
     $this->assign('sys', $sysinfo);
     $appid = $sysinfo['web_appid'];
     $appsecret = $sysinfo['web_appsecret'];
     if (!defined('VIRIFY')) {
         virifylocal();
     }
     $_scene = M('scene');
     $where['scenecode_varchar'] = I('get.id', 0);
     $where['delete_int'] = 0;
     $_scene_list = $_scene->where($where)->select();
     // print_r($_scene_list); exit('dddd');
     $sysinfo = M('sys')->order('id asc')->find();
     if ($sysinfo['is_user_anli_shenghe'] && !isset($_GET['preview'])) {
         if ($_scene_list[0]["shenhe"] != 1) {
             $this->error('抱歉,您的场景还没通过管理员审核', '/#/main');
         }
     }
     $argu2 = array();
     $argu2['title'] = $_scene_list[0]["scenename_varchar"];
     $argu2['url'] = C('IS_OPEN_STATIC') ? 'v-' . $_scene_list[0]["scenecode_varchar"] : 'index.php?c=view&id=' . $_scene_list[0]["scenecode_varchar"];
     $argu2['desc'] = $_scene_list[0]["desc_varchar"];
     $argu2['imgsrc'] = $_scene_list[0]["thumbnail_varchar"];
     $this->assign("confinfo2", $argu2);
     $mydd = get_client_ip();
     if ($mydd !== '127.0.0.1') {
         $confinfo = $this->get_js_sdk($appid, $appsecret);
     }
     $this->assign("confinfo", $confinfo);
     $this->display(HTML_VESION);
 }
Exemplo n.º 3
0
 public function login()
 {
     #是否显示验证码
     $msg = '';
     if (IS_POST) {
         $name = I('name');
         $password = I('password');
         if (!empty($name) && !empty($password)) {
             #验证用户信息
             $user_info = D('Common/Admin')->loginCheck($name, $password);
             #记录登录日志
             $log_data = array('admin_id' => isset($user_info['id']) ? $user_info['id'] : 0, 'login_time' => date('Y-m-d H:i:s'), 'login_ip' => get_client_ip());
             $log_result = D('Common/Adminlog')->log_add($log_data);
             #跳转
             if (isset($user_info['id'])) {
                 session('user', $user_info['id']);
                 redirect(U('admin/Index/index'));
             } else {
                 $this->error('登录失败,用户名或密码错误。');
             }
         } else {
             $this->error('登录失败,用户名或密码错误。');
         }
     }
     $this->display();
 }
Exemplo n.º 4
0
 /**
  * 后台登陆控制器
  */
 public function login()
 {
     $arr = array('user_login' => I('user_login'), 'user_pass' => encrypt(I('user_pass'), C('ENCRYPTION_KEY')), 'remember-me' => I('remember-me'));
     //处理下次自动登录
     if ($arr['remember-me'] == 1) {
         $account = $arr['user_login'];
         $ip = get_client_ip(0, true);
         $value = $account . '|' . $ip;
         $value = encrypt($value, C('ENCRYPTION_KEY'));
         @setcookie('remember-me', $value, time() + 7 * 24 * 3600, "/");
     }
     $user = M('user')->where(array('user_login' => $arr['user_login']))->find();
     $userinfo = D('user')->getInfo($user['id']);
     if ($user['user_status'] == 0) {
         $this->error('账号被禁用,请联系管理员...');
     }
     if ($user['user_type'] != '管理员') {
         $this->error('无权限登录...');
     }
     if (!$user || $user['user_pass'] != $arr['user_pass']) {
         $this->error('账号密码错误,请重试...');
     }
     $data = array('id' => $user['id'], 'last_login_ip' => get_client_ip(0, true), 'last_login_time' => date("Y-m-d H:i:s"));
     $result = M('user')->save($data);
     if (!$result) {
         $this->error('登录失败,请重试...');
     }
     session('uid', $user['id']);
     session('username', $userinfo['username']);
     session('last_login_time', $data['last_login_time']);
     session('last_login_ip', $data['last_login_ip']);
     $this->success('登陆成功', U('Index/index'));
 }
Exemplo n.º 5
0
 public function index()
 {
     if (IS_POST) {
         $User = M("User");
         $username = I('post.username');
         $password = I('post.password');
         $where['username'] = $username;
         $result = $User->where($where)->find();
         if ($result != NULL && $result != false) {
             if (md5($result['salt'] . $password) == $result['password']) {
                 $data['lastlogin'] = date('Y-m-d H:i:s');
                 $data['ip'] = get_client_ip();
                 $User->where($result)->data($data)->save();
                 $result['msg'] = 'succeed';
                 $this->ajaxReturn($result);
             } else {
                 $error['msg'] = 'password error';
                 $this->ajaxReturn($error);
             }
         } else {
             $error['msg'] = 'username error';
             $this->ajaxReturn($error);
         }
     }
 }
Exemplo n.º 6
0
 public function publish($content, $uid, $reid = 0)
 {
     if (mb_strlen($content) > 255) {
         $data = array('content' => mb_substr($content, 0, 255, 'utf8'), 'content_over' => mb_substr($content, 255, 25, 'utf8'));
     } else {
         $data = array('content' => $content);
     }
     $data['ip'] = get_client_ip(1);
     $data['uid'] = $uid;
     if ($reid > 0) {
         $data['reid'] = $reid;
     }
     if ($this->create($data)) {
         $tid = $this->add();
         if ($tid) {
             if ($reid > 0) {
                 $this->setRecount($reid);
             }
             return $tid;
         } else {
             return 0;
         }
     } else {
         return $this->getError();
     }
 }
Exemplo n.º 7
0
 public function login()
 {
     if (!IS_POST) {
         E('无效的页面');
     }
     $Verify = new \Think\Verify();
     //if(!$Verify->check($code)) $this->error('验证码错误');
     $db = M('login');
     $user = $db->where(array('username' => I('username')))->find();
     if (!$user || $user['password'] != I('password', '', md5)) {
         $this->error('账号或密码错误');
     }
     //更新最后一次登录时间及IP
     $data = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
     $db->save($data);
     session('uid', $user['id']);
     session('username', $user['username']);
     session('name', $user['name']);
     session('logintime', date('Y-m-d H:i:s', $user['logintime']));
     session('loginip', $user['loginip']);
     if ($user['jd'] == '1') {
         session('admin', '1');
     } else {
         session('admin', '0');
     }
     if (I('username') == 'admin') {
         session('iadmin', 1);
     } else {
         session('iadmin', 0);
     }
     $this->redirect('/Home/Index/index');
 }
 public function login()
 {
     if (!IS_POST) {
         halt('页面不存在3');
     }
     // 		if(I('code','','md5')!=session('verify')){
     // 			$this->error('验证码错误');
     // 		}
     $username = I('username');
     $pwd = I('password', '', 'md5');
     $user = M('user')->where(array('username' => $username))->find();
     if (!$user || $user['password'] != $pwd) {
         $this->error('账号或密码错误!');
     }
     if ($user['lock']) {
         $this->error('用户被锁了');
     }
     $data = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
     M('user')->save($data);
     session('uid', $user['id']);
     session('username', $user['username']);
     session('logintime', date('Y-m-d H:i:s', $user['logintime']));
     session('loginip', $user['loginip']);
     $this->redirect('Admin/Index/index');
 }
Exemplo n.º 9
0
 public function grade_login()
 {
     if (!check_verify(I('code', ''))) {
         $this->error('验证码错误');
     }
     $username = I('username');
     $user = M('user')->where(array('username' => $username))->find();
     $pwd = I('password', '', 'md5');
     if (!$user | $user['password'] != $pwd) {
         $this->error('用户名或密码错误');
     }
     if ($user['lock']) {
         $this->error('用户被锁定,请联系管理员解锁');
     }
     $data = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
     M('user')->save($data);
     session(C('USER_AUTH_KEY'), $user['id']);
     session('username', $user['username']);
     session('lastlogintime', date('Y-m-d H:i', $user['logintime']));
     session('lastloginip', $user['loginip']);
     if ($user['username'] == C('RBAC_SUPERADMIN')) {
         session(C('ADMIN_AUTH_KEY'), true);
     }
     import('Org.Util.Rbac');
     Rbac::saveAccessList();
     //        dump($_SESSION);die;
     $this->redirect('Grade/Grade/grade_index');
 }
 public function login()
 {
     if (!IS_POST) {
         $this->error('页面不存在');
     }
     //p($_POST);
     if (!isset($_POST['submit'])) {
         return false;
     }
     //安全一点再判断一下
     //验证码对比
     $code = I('verify');
     //if(!check_verify($code))$this->error('验证码错误');//测试系统,忽略认证
     $name = I('uname');
     $pwd = md5(I('pwd'));
     $db = M('admin');
     $user = $db->where(array('username' => $name))->find();
     if (!$user || $user['password'] != $pwd) {
         $this->error('账号或密码错误');
     }
     if ($user['lock']) {
         $this->error('账号被锁定');
     }
     $data = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
     $db->save($data);
     session('uid', $user['id']);
     session('username', $user['username']);
     session('logintime', date('Y-m-d H:i', $user['logintime']));
     session('now', date('Y-m-d H:i', time()));
     session('loginip', $user['loginip']);
     session('admin', $user['admin']);
     $this->success('正在登陆...', __APP__);
 }
Exemplo n.º 11
0
 public function index()
 {
     if (IS_POST) {
         $ip = get_client_ip();
         $time = time();
         $map['ip'] = array('eq', $ip);
         //留言间隔
         $Set = D('Set')->find();
         $model = D('Message');
         $Message = $model->where($map)->order('id desc')->find();
         if ($time - $Message['create_time'] < $Set['messageinterval']) {
             $this->error('每条留言需间隔' . $Set['messageinterval'] / 60 . '分钟!');
         }
         if ($vo = $model->create()) {
             //保存当前数据对象
             //  $list = $model->add();
             // if ($list !== false){
             if ($model->add()) {
                 //	 $this->ajaxReturn(0,"留言成功!",1);
                 $this->success('留言成功!');
             } else {
                 //失败提示
                 //  $this->ajaxReturn('添加失败',0);
                 $this->error('提交失败!');
             }
         } else {
             $this->error($model->getError());
         }
     } else {
         $this->display();
     }
 }
Exemplo n.º 12
0
 /**
  * 后台控制器初始化
  */
 protected function _initialize()
 {
     // 获取当前用户ID
     if (defined('UID')) {
         return;
     }
     define('UID', is_login());
     if (!UID) {
         // 还没登录 跳转到登录页面
         $this->redirect('Public/login');
     }
     /* 读取数据库中的配置 */
     $config = S('DB_CONFIG_DATA');
     if (!$config) {
         $config = D('Config')->lists();
         S('DB_CONFIG_DATA', $config);
     }
     C($config);
     //添加配置
     // 是否是超级管理员
     define('IS_ROOT', is_administrator());
     if (!IS_ROOT && C('ADMIN_ALLOW_IP')) {
         // 检查IP地址访问
         if (!in_array(get_client_ip(), explode(',', C('ADMIN_ALLOW_IP')))) {
             $this->error('403:禁止访问');
         }
     }
 }
Exemplo n.º 13
0
 function init_follow($openid, $token = '', $has_subscribe = false)
 {
     empty($token) && ($token = get_token());
     addWeixinLog($openid . '::_' . $token, 'init_follow_in');
     if (empty($openid) || $openid == -1 || empty($token) || $token == -1) {
         return false;
     }
     $data['token'] = $token;
     $data['openid'] = $openid;
     $datas = $data;
     $uid = M('public_follow')->where($data)->getField('uid');
     addWeixinLog($uid, 'init_follow_check_uid');
     if ($uid) {
         return $uid;
     }
     // 自动注册
     $config = getAddonConfig('UserCenter', $token);
     $user = array('experience' => intval($config['experience']), 'score' => intval($config['score']), 'reg_ip' => get_client_ip(1), 'reg_time' => NOW_TIME, 'last_login_ip' => get_client_ip(1), 'last_login_time' => NOW_TIME, 'status' => 1, 'is_init' => 1, 'is_audit' => 1, 'come_from' => 1);
     $user2 = getWeixinUserInfo($openid);
     $user = array_merge($user, $user2);
     $data['uid'] = $uid = D('Common/User')->add($user);
     if ($has_subscribe !== false) {
         $data['has_subscribe'] = $has_subscribe;
     }
     M('public_follow')->add($data);
     return $uid;
 }
Exemplo n.º 14
0
 static function save($type = '', $destination = '', $extra = '')
 {
     if (empty(self::$log)) {
         return;
     }
     $type = $type ? $type : C('LOG_TYPE');
     if (self::FILE == $type) {
         // 文件方式记录日志信息
         if (empty($destination)) {
             $destination = C('LOG_PATH') . date('y_m_d') . '.log';
         }
         //检测日志文件大小,超过配置大小则备份日志文件重新生成
         if (is_file($destination) && floor(C('LOG_FILE_SIZE')) <= filesize($destination)) {
             rename($destination, dirname($destination) . '/' . time() . '-' . basename($destination));
         }
     } else {
         $destination = $destination ? $destination : C('LOG_DEST');
         $extra = $extra ? $extra : C('LOG_EXTRA');
     }
     $now = date(self::$format);
     error_log($now . ' ' . get_client_ip() . ' ' . $_SERVER['REQUEST_URI'] . "\r\n" . implode('', self::$log) . "\r\n", $type, $destination, $extra);
     // 保存后清空日志缓存
     self::$log = array();
     //clearstatcache();
 }
Exemplo n.º 15
0
 /**
  * 帐号注册
  */
 function signin()
 {
     if (IS_POST) {
         $post = I('post.');
         if ($post['email'] == '') {
             $this->error('邮件地址不能为空!');
         }
         if ($post['verification_code'] != $_SESSION['verification_code']) {
             $this->error('你输入的验证码不正确!');
         }
         $this->_check_email($post['email']);
         $data['email'] = $post['email'];
         $data['register_time'] = NOW_TIME;
         $data['register_ip'] = get_client_ip(1);
         if ($this->user->add($data) !== false) {
             $link = PDM_URL . '?c=account&a=authentication&sign=' . pdm_code($post['email']);
             $tpl = file_get_contents(PDM_INC_PATH . 'ThirdParty/PHPMailer/templates/register_success.htm');
             $tpl = str_replace('#EMAIL#', $data['email'], $tpl);
             $tpl = str_replace('#SYSTEM_NAME#', PDM_NAME, $tpl);
             $tpl = str_replace('#DATE#', date('Y年m月d日'), $tpl);
             $tpl = str_replace('#LINK#', $link, $tpl);
             pdm_sendmail($data['email'], '密码管理系统注册确认', $tpl);
             $this->success('帐号注册成功,请到你的邮件中确认激活!', '', 5);
         } else {
             $this->error('帐号注册失败!');
         }
     } else {
         $this->display();
     }
 }
Exemplo n.º 16
0
 public function praise()
 {
     $arr = array('s' => 0, 'error' => '');
     $ip = get_client_ip();
     $praise_model = M('praise');
     $goods_model = M('goods');
     //if(IS_AJAX){
     $gid = I('gid');
     $type = I('type');
     $data = array('uid' => is_login(), 'gid' => $gid, 'type' => $type, 'ip' => $ip);
     if ($praise_model->add($data)) {
         if ($type == 1) {
             $goods_model->where('gid=' . $gid)->setInc('praise', 1);
             cookie('like' . $gid, $gid, 24 * 60 * 60 * 5);
         } else {
             $goods_model->where('gid=' . $gid)->setInc('dislike', 1);
             cookie('dislike' . $gid, $gid, 24 * 60 * 60 * 5);
         }
         $this->ajaxReturn($arr);
     } else {
         $arr['s'] = 1;
         $arr['error'] = 'Sorry 数据错误';
         $this->ajaxReturn($arr);
     }
     //}else{
     //$this->error('非法访问!');
     //}
 }
Exemplo n.º 17
0
 public function verify($login_info)
 {
     $password = $login_info['password'];
     $AdminUser = M('admin_user');
     $field = "id,account,password,name,login_count,lock_time,error_count,role_id";
     $account_info = $AdminUser->field($field)->where("status=1 and (account='{$login_info['account']}')")->find();
     if (empty($account_info)) {
         return false;
     }
     $account = $account_info['account'];
     if (empty($account_info['role_id'])) {
         return array('status' => 0, 'info' => '账户未分配角色,请联系管理员');
     } elseif ($account_info['lock_time'] - time() > 0) {
         return array('status' => 0, 'info' => '账户被锁');
     } elseif (isset($password) && md5($password) !== $account_info['password']) {
         if (($error_count = 5 - $account_info['error_count'] % 6) > 0) {
             $AdminUser->where("id={$account_info['id']}")->setInc('error_count');
             return array('status' => 0, 'info' => '密码错误,剩余次数' . $error_count);
         } else {
             $AdminUser->where("id={$account_info['id']}")->save(array('lock_time' => time() + 1800));
             return array('status' => 0, 'info' => '账户锁定');
         }
     }
     //登陆成功
     $data_update = array('login_count' => $account_info['login_count'] + 1, 'last_login_time' => time(), 'last_login_ip' => get_client_ip(), 'error_count' => 0);
     $AdminUser->where("id={$account_info['id']}")->save($data_update);
     return $account_info;
 }
 public function index()
 {
     $email = strim($GLOBALS['request']['email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['pwd']);
     //密码
     if (app_conf("SMS_ON") == 0) {
         $root['response_code'] = 0;
         $root['show_err'] = $GLOBALS['lang']['SMS_OFF'];
         //短信未开启
         output($root);
     }
     //检查用户,用户密码
     $user = user_check($email, $pwd);
     $user_id = intval($user['id']);
     $root['user_id'] = $user_id;
     if ($user_id > 0) {
         $mobile = $user['mobile'];
         $code = intval($user['bind_verify']);
         if ($mobile == '') {
             $root['response_code'] = 0;
             $root['show_err'] = $GLOBALS['lang']['MOBILE_EMPTY_TIP'];
             output($root);
         }
         if (!check_mobile($mobile)) {
             $root['response_code'] = 0;
             $root['show_err'] = $GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE'];
             output($root);
         }
         if (!check_ipop_limit(get_client_ip(), "mobile_verify", 60, 0)) {
             $root['response_code'] = 0;
             $root['show_err'] = $GLOBALS['lang']['MOBILE_SMS_SEND_FAST'];
             //短信发送太快
             output($root);
         }
         //开始生成手机验证
         if ($code == 0) {
             //已经生成过了,则使用旧的验证码;反之生成一个新的
             $code = rand(1111, 9999);
             $GLOBALS['db']->query("update " . DB_PREFIX . "user set bind_verify = '" . $code . "',verify_create_time = '" . TIME_UTC . "' where id = " . $user_id);
         }
         //使用立即发送方式
         $result = send_verify_sms($mobile, $code, $user, true);
         //
         $root['response_code'] = $result['status'];
         if ($root['response_code'] == 1) {
             $root['show_err'] = $GLOBALS['lang']['MOBILE_VERIFY_SEND_OK'];
         } else {
             $root['show_err'] = $result['msg'];
             if ($root['show_err'] == null || $root['show_err'] == '') {
                 $root['show_err'] = "验证码发送失败";
             }
         }
     } else {
         $root['response_code'] = 0;
         $root['show_err'] = "未登录";
         $root['user_login_status'] = 0;
     }
     output($root);
 }
Exemplo n.º 19
0
 /**
  * ------------------------------
  * what to do
  * ------------------------------
  * @param  unkonw_type
  * @return unknow_type
  */
 function login($userName, $userPass, $authCode)
 {
     if (!isset($userName)) {
         $userName = $_POST['userName'];
     }
     if (!isset($userPass)) {
         $userPass = $_POST['userPass'];
     }
     if (!isset($authCode)) {
         $authCode = $_POST['authCode'];
     }
     $userInfo = self::chk_user($userName, $userPass, $authCode);
     $_SESSION['userID'] = $userInfo['user_id'];
     $_SESSION['nickName'] = $userInfo['nick_name'];
     $_SESSION['userType'] = $userInfo['user_type'];
     $loginTime = time();
     if (!function_exists('get_client_ip')) {
         include_once '../common/function.php';
     }
     $loginIP = get_client_ip();
     global $db;
     $arr = array('login_time' => $loginTime, 'login_ip' => $loginIP);
     $db->row_insert('users', $arr, "user_id={$userInfo['user_id']}");
     return $userInfo;
 }
Exemplo n.º 20
0
 public function login()
 {
     if (IS_POST) {
         $username = $this->_post('username', 'trim');
         $password = $this->_post('password', 'trim');
         if (!$username || !$password) {
             $this->error(L('input_empty'));
         }
         $verify_code = $this->_post('verify_code', 'trim');
         if (session('verify') != md5($verify_code)) {
             $this->error(L('verify_code_error'));
         }
         $admin = M('admin')->where(array('username' => $username, 'status' => 1))->find();
         if (!$admin) {
             $this->error(L('admin_not_exist'));
         }
         if ($admin['password'] != md5($password)) {
             $this->error(L('password_error'));
         }
         $admin_role = M('admin_role')->where(array('id' => $admin['role_id']))->find();
         session('admin', array('id' => $admin['id'], 'role_id' => $admin['role_id'], 'role_name' => $admin_role['name'], 'username' => $admin['username']));
         M('admin')->where(array('id' => $admin['id']))->save(array('last_time' => time(), 'last_ip' => get_client_ip()));
         $this->success(L('login_success'), U('index/index'));
     } else {
         $this->display();
     }
 }
Exemplo n.º 21
0
 public function addUserHandle()
 {
     //用户信息
     if (!I('username') || !I('password', '', 'md5')) {
         $this->error('用户名密码不能为空');
     }
     foreach (I('info') as $v) {
         if ($v == null) {
             $this->error('所属部门不能为空');
         }
     }
     $user = array('user_name' => I('username'), 'user_stu_num' => I('userNum'), 'user_password' => I('password', '', 'md5'), 'user_log_time' => time(), 'user_log_ip' => get_client_ip(), 'user_status' => 1);
     //所属部门
     $info = array();
     if ($uid = M('user')->add($user)) {
         //添加部门和职务信息
         foreach (I('info') as $v) {
             $info[] = array('dept_id' => $v['dept'], 'role_id' => $v['role'], 'user_id' => $uid);
         }
         M('user_dept_role')->addAll($info);
         $this->success('添加用户成功', U('Admin/Rbac/index'));
     } else {
         $this->error('添加用户失败');
     }
 }
Exemplo n.º 22
0
 function checkOne($item)
 {
     $item['action_ip'] = $item['action_ip'] ? get_client_ip(1) : null;
     foreach ($item as $k => $v) {
         if (empty($v)) {
             unset($item[$k]);
         }
     }
     unset($k, $v);
     $time = time();
     $map['action_list'] = array(array('like', '%[' . $item['action'] . ']%'), '', 'or');
     $map['status'] = 1;
     $limitList = D('ActionLimit')->getList($map);
     !empty($item['action']) && ($item['action_id'] = M('action')->where(array('name' => $item['action']))->getField('id'));
     foreach ($limitList as &$val) {
         $ago = get_time_ago($val['time_unit'], $val['time_number'], $time);
         $item['create_time'] = array('egt', $ago);
         $log = M('action_log')->where($item)->order('create_time desc')->select();
         if (count($log) >= $val['frequency']) {
             $punishes = explode(',', $val['punish']);
             foreach ($punishes as $punish) {
                 //执行惩罚
                 if (method_exists($this, $punish)) {
                     $this->{$punish}($item, $val);
                 }
             }
             unset($punish);
             if ($val['if_message']) {
                 D('Message')->sendMessageWithoutCheckSelf($item['user_id'], L('_SYSTEM_MESSAGE_'), $val['message_content'], $_SERVER['HTTP_REFERER']);
             }
         }
     }
     unset($val);
 }
 /**
  * 后台控制器初始化
  */
 protected function _initialize()
 {
     // 获取当前用户ID
     define('UID', is_login());
     if (!UID) {
         // 还没登录 跳转到登录页面
         $this->redirect('Public/login');
     }
     // 是否是超级管理员
     define('IS_ROOT', is_administrator());
     if (!IS_ROOT && C('ADMIN_ALLOW_IP')) {
         // 检查IP地址访问
         if (!in_array(get_client_ip(), explode(',', C('ADMIN_ALLOW_IP')))) {
             $this->error('403:禁止访问');
         }
     }
     // 检测访问权限
     $access = $this->accessControl();
     if ($access === false) {
         $this->error('403:禁止访问');
     } elseif ($access === null) {
         $dynamic = $this->checkDynamic();
         //检测分类栏目有关的各项动态权限
         if ($dynamic === null) {
             //检测非动态权限
             $rule = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME);
             if (!$this->checkRule($rule, array('in', '1,2'))) {
                 $this->error('未授权访问!');
             }
         } elseif ($dynamic === false) {
             $this->error('未授权访问!');
         }
     }
     $this->assign('__MENU__', $this->getMenus());
 }
Exemplo n.º 24
0
 public function face()
 {
     if (!$this->uid) {
         ajaxmsg("请先登陆", 0);
     }
     $vs = M('members_status')->getFieldByUid($this->uid, 'face_status');
     if ($vs == 1) {
         ajaxmsg("您已通过现场认证,无需再次认证", 0);
     }
     $vxs = M('face_apply')->where("uid={$this->uid} AND apply_status=0")->count('id');
     if ($vxs >= 1) {
         ajaxmsg("您已经提交申请,请等待客服人员处理", 0);
     }
     $newid = memberMoneyLog($this->uid, 26, -$this->glo['fee_face'], $info = "申请现场认证");
     if ($newid) {
         $save['uid'] = $this->uid;
         $save['add_time'] = time();
         $save['add_ip'] = get_client_ip();
         $save['apply_status'] = 0;
         $newidx = M('face_apply')->add($save);
         if ($newidx) {
             ajaxmsg("申请成功,请等待客服与您联系");
         } else {
             ajaxmsg("申请失败,请重试");
         }
     } else {
         ajaxmsg("申请失败,请重试");
     }
 }
Exemplo n.º 25
0
 protected function isLogin()
 {
     if (empty($_SESSION[APP_NAME . '_USERINFO'])) {
         /* session 不存在,检查cookie */
         if (!empty($_COOKIE['ECTOUCHCP']['ADMIN_ID']) && !empty($_COOKIE['ECTOUCHCP']['ADMIN_PWD'])) {
             // 找到了cookie, 验证cookie信息
             $condition['user_id'] = intval($_COOKIE['ECTOUCHCP']['ADMIN_ID']);
             $userInfo = $this->model->table('admin_user')->field('user_id, user_name, password, email, last_login, ec_salt')->where($condition)->find();
             if (empty($userInfo)) {
                 // 没有找到这个记录
                 setcookie($_COOKIE['ECTOUCHCP']['ADMIN_ID'], '', 1);
                 setcookie($_COOKIE['ECTOUCHCP']['ADMIN_PWD'], '', 1);
                 return false;
             } else {
                 // 检查密码是否正确
                 if (md5(md5($userInfo['user_id'] . $userInfo['user_name']) . C('hash_code')) == $_COOKIE['ECTOUCHCP']['ADMIN_PWD']) {
                     $this->setLogin($userInfo);
                     $data['last_login'] = gmtime();
                     $data['last_ip'] = get_client_ip();
                     $this->model->table('admin_user')->data($data)->where($condition)->update();
                     $this->userInfo = $_SESSION[APP_NAME . '_USERINFO'];
                     return true;
                 } else {
                     setcookie($_COOKIE['ECTOUCHCP']['ADMIN_ID'], '', 1);
                     setcookie($_COOKIE['ECTOUCHCP']['ADMIN_PWD'], '', 1);
                     return false;
                 }
             }
         }
         return false;
     } else {
         $this->userInfo = $_SESSION[APP_NAME . '_USERINFO'];
         return true;
     }
 }
Exemplo n.º 26
0
 public function index()
 {
     $id = I('id', '', 'intval');
     !$id && $this->_404();
     $union_mod = D('union');
     $user_mod = D('user');
     $user = $user_mod->where(array('id' => $id))->find();
     $date['uid'] = $user['id'];
     $date['username'] = $user['username'];
     $date['score'] = C('ftx_score_rule.union_visit');
     if (false === ($data = $union_mod->create($date))) {
         $this->error($union_mod->getError());
     }
     if (!$union_mod->where(array('ip' => get_client_ip()))->count()) {
         $score_data = array('score' => array('exp', 'score+' . C('ftx_score_rule.union_visit')), 'sign_time' => strtotime(date('Ymd')));
         D('user')->where(array('id' => $user['id']))->setField($score_data);
         //改变用户积分
         //添加一条积分记录
         $score_log_data['uid'] = $user['id'];
         $score_log_data['uname'] = $user['username'];
         $score_log_data['action'] = 'union_visit';
         $score_log_data['score'] = C('ftx_score_rule.union_visit');
         D('score_log')->create($score_log_data);
         D('score_log')->add();
         $union_mod->add();
     }
     redirect(C('ftx_site_url'));
 }
Exemplo n.º 27
0
 /**
  * 设置登录状态
  */
 public function autoLogin($mb)
 {
     # 记录登录SESSION和COOKIES
     $auth = array('mb_seq' => $mb['mb_seq'], 'mb_tel' => $mb['mb_tel'], 'mb_login' => $mb['mb_login'], 'mb_login_ip' => get_client_ip(1));
     session('mb_auth', $auth);
     session('mb_auth_sign', $this->dataAuthSign($auth));
 }
Exemplo n.º 28
0
 /**
  * 会员注册
  * @author MaWei (http://www.phpyrb.com)
  * @date 2014-10-6  下午3:28:30
  */
 function register()
 {
     $data = array();
     $data['uname'] = text($_REQUEST['name']);
     $data['passwd'] = text($_REQUEST['passwd']);
     $data['email'] = text($_REQUEST['email']);
     $data['status'] = 1;
     $data['sex'] = 3;
     $data['lasttime'] = $data['registertime'] = time();
     $data['lastip'] = get_client_ip();
     //检测用户名
     if ($this->member->checkname($data['uname'])) {
         echo json_encode(array('status' => null, 'msg' => '用户名已存在'));
         exit;
     }
     //检测邮箱
     if ($this->member->checkemail($data['email'])) {
         echo json_encode(array('status' => null, 'msg' => '邮箱已存在'));
         exit;
     }
     $data['passwd'] = $this->member->encrypt($data['passwd']);
     $reid = add_updata($data, 'Member');
     if ($reid === false) {
         echo json_encode(array('status' => -1, 'msg' => '非常抱歉,由于网络原因!注册失败!'));
     } else {
         echo json_encode(array('status' => 1, 'msg' => '恭喜您!注册成功!'));
     }
 }
Exemplo n.º 29
0
 public function index()
 {
     $data = I('post.');
     if (!empty($data['username']) && !empty($data['password']) && !empty($data['verify'])) {
         if ($this->Verify->check($data['verify'])) {
             $user = M('user');
             $userdata = $user->where("username='******' and state=0", $data['username'])->find();
             if ($userdata && $userdata['password'] === md5(C('SECURE_CODE') . md5($data['password']))) {
                 unset($userdata['password']);
                 $userdata['ip'] = get_client_ip();
                 $user->where('id=' . $userdata['id'])->save(array('logintime' => time()));
                 $user_auth = json_encode($userdata);
                 $user_auth_cookie = authcode($user_auth, ENCODE);
                 cookie('auth', $user_auth_cookie, 3600);
                 $this->success('登陆成功', U('index/index'));
                 exit;
             } else {
                 $this->error("用户名或密码错误");
             }
         } else {
             $this->error("验证码填写错误");
         }
     }
     $this->display();
 }
Exemplo n.º 30
0
 /**
  * 添加邮件发送记录
  * @param $data
  *
  */
 private function addLogSendEmail($data)
 {
     $logModel = M('LogEmail');
     $data['addtime'] = time();
     $data['ip'] = get_client_ip();
     $logModel->data($data)->add();
 }