public function setUserLogin($userInfo = array(), $remember = 0, $saveLogin = true)
 {
     if ($saveLogin) {
         $this->update("logincount=logincount+1,loginip='" . ip2long(getUserIp()) . "',logintime='" . TIME . "'", array('id' => $userInfo['id']));
     }
     $saltkey = getRandStr(8);
     $auth = setEnocde($userInfo['id'] . "\t" . $userInfo['psw'], admin::getAuthKey($saltkey));
     myCookie('s_saltkey', $saltkey, $remember);
     myCookie('s_auth', $auth, $remember);
     return true;
 }
Beispiel #2
0
function updateToken($hash)
{
    db_connect();
    $date = date('Y-m-d H:i:s');
    $sql = 'UPDATE blog_token SET';
    $sql .= ' latest_ip = "' . getUserIp() . '"';
    $sql .= ', latest_time = "' . $date . '"';
    $sql .= ', current_access = current_access+1';
    $sql .= ' WHERE hash = "' . $hash . '"';
    return mysql_query($sql);
}
/**
 * @helper::alertShutdown()
 * @Author: Idea Tweaker
 */
function alertShutdown()
{
    $ci = getInstance();
    $session = $ci->auth_model->getSession();
    $data = array();
    $data['logout_time'] = getTime();
    $data['logout_type'] = 'Auto';
    $data['ip_address'] = getUserIp();
    $data['userid'] = $session['token'];
    if (connection_aborted()) {
        storeLogHistory($data);
    }
}
Beispiel #4
0
$companyselect = array();
$result = mysql_query("SELECT company_ref_id, name from sys_companies");
while ($row = mysql_fetch_assoc($result)) {
    $companyselect[] = $row;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $username = $_POST['username'];
    $password = md5($_POST['password']);
    $company = $_POST['company'];
    $query = mysql_query("SELECT * FROM sys_users WHERE is_active = 'Yes' AND user_name = '{$username}' AND user_password = '******' AND company_ref_id = '{$company}'");
    $numrows = mysql_num_rows($query);
    if ($numrows != 0) {
        $users = mysql_fetch_assoc($query);
        $valid = true;
        if ($users['ip_restrict'] == 'Yes') {
            $raw_ip = getUserIp();
            $result = mysql_query("SELECT ip FROM user_ips WHERE user_id = {$users['user_id']} AND ip = {$raw_ip}");
            $restrict = mysql_fetch_assoc($query);
            if ($restrict) {
                $valid = false;
                echo "<div id='wc' title='IP Restrict'>\n";
                echo "<p>You are not authorized to view this page<br/>You are logging in from restricted IP address ({$raw_ip})</p>\n";
                echo "</div>\n";
            }
        }
        if ($users['fail_login'] >= 5) {
            $valid = false;
            echo "<div id='wc' title='Login Restrict'>\n";
            echo "<p>Enough! You are not authorized to view this page</p>\n";
            echo "</div>\n";
        }
Beispiel #5
0
 function query()
 {
     $query = sprintf("INSERT into `users` (`username`, `password`, `first_name`, `last_name`, `email`, `date`, `image`, `cover`, `online`, `ip`, `notificationl`, `notificationc`, `notificationd`, `notificationf`, `email_comment`, `email_like`, `email_new_friend`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', 'default.png', 'default.png', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');", $this->db->real_escape_string(strtolower($this->username)), md5($this->db->real_escape_string($this->password)), $this->db->real_escape_string($this->first_name), $this->db->real_escape_string($this->last_name), $this->db->real_escape_string($this->email), date("Y-m-d H:i:s"), time(), $this->db->real_escape_string(getUserIp()), $this->like_notification, $this->comment_notification, $this->chat_notification, $this->friend_notification, $this->email_comment, $this->email_like, $this->email_new_friend);
     $this->db->query($query);
 }
 } else {
 }
 if ($_POST['submit']) {
     $verify = $_SESSION['testimonial'];
     $text = mysql_real_escape_string($_POST['testimonial']);
     $person = mysql_real_escape_string($_POST['name']);
     $email = mysql_real_escape_string($_POST['email']);
     if (isset($_POST['guide'])) {
         $guide = 1;
     } else {
         $guide = 0;
     }
     $service = mysql_real_escape_string($_POST['service']);
     $website = mysql_real_escape_string($_POST['website']);
     $location = mysql_real_escape_string($_POST['location']);
     $ipaddress = getUserIp();
     $date = date("Y-m-d");
     $check_test = mysql_query("SELECT * FROM testimonials WHERE verify = '{$verify}'");
     if (mysql_num_rows($check_test) == 0) {
         echo "<span class='return-success'>Success: Your testimonial has been submitted and is awaiting review!</span>";
         mysql_query("INSERT INTO testimonials (verify, text, person, email, guide, service, website, location, ipaddress, date) VALUES (\"{$verify}\", \"{$text}\", \"{$person}\", \"{$email}\", \"{$guide}\", \"{$service}\", \"{$website}\", \"{$location}\", \"{$ipaddress}\", \"{$date}\")") or die(mysql_error());
         emailTestimonial($verify, $email, $person, $service, $website, $location, $ipaddress, $date, $text);
     } else {
     }
 } else {
 }
 echo "<h3>what our customers have to say</h3>";
 $getTestimonials = mysql_query("SELECT * FROM testimonials WHERE approved = 1 ORDER BY id DESC");
 while ($testimonial = mysql_fetch_assoc($getTestimonials)) {
     $id = $testimonial['id'];
     $ver = $testimonial['verify'];
Beispiel #7
0
 function edit()
 {
     $this->load->library('form_validation');
     $this->load->model('user_model');
     $this->load->model('table_model');
     try {
         $this->form_validation->set_rules('style', 'style', 'trim|required');
         $this->form_validation->set_rules('ver', 'ver', 'trim|required|integer');
         $this->form_validation->set_rules('username', '用户名', 'trim|required|min_length[3]|max_length[15]');
         $this->form_validation->set_rules('password', '密码', 'trim|required|min_length[32]|max_length[32]');
         $this->form_validation->set_rules('creator', '创建者', 'trim|required|min_length[3]|max_length[15]');
         $this->form_validation->set_rules('nickname', '昵称', 'trim|max_length[15]');
         $this->form_validation->set_rules('name', '棋局名', 'trim|required|min_length[1]|max_length[15]');
         $this->form_validation->set_rules('type', '棋局类型', 'trim|required|integer');
         $this->form_validation->set_rules('timer', '棋局计时器', 'trim|required|integer');
         $this->form_validation->set_rules('level', '晋级', 'trim|required|integer');
         $this->form_validation->set_rules('lanip', 'IP', 'trim|max_length[15]');
         $this->form_validation->set_rules('port', '端口', 'trim|required|integer');
         if ($this->form_validation->run() == FALSE) {
             throw new Exception();
         }
         $get = $this->form_validation->get_all_gets();
         if (!$this->user_model->checkServerPassword($get['username'], $get['style'])) {
             $this->form_validation->set_error_string('非法访问!');
             throw new Exception();
         }
         if (!$this->checkVersion($get['ver'])) {
             $this->form_validation->set_error_string('对不起!您的软件版本过低,请登陆幸福家园BBS,下载最新版本!网址:http://bbs.ourhf.com');
             throw new Exception();
         }
         if (!$this->user_model->checkUser($get['creator'], $get['password'])) {
             $this->form_validation->set_error_string('您无权修改棋局!');
             throw new Exception();
         }
         $result = $this->table_model->edit($get);
         if (!$result) {
             $this->form_validation->set_error_string('您无权修改棋局!');
             throw new Exception();
         }
         $result = $this->table_model->detail($get['name']);
         if ($result) {
             $this->OutputStatus = STATUS_OK;
             $data = array($result['TableName'], $result['Creator'], $result['CreatorName'], $result['Visitor'], $result['VisitorName'], $result['Type'], $result['GameTimer'], $result['Level'], $result['LastTime'], $result['IP'], $result['LANIP'], $result['Port'], getUserIp());
             $this->OutputArray = $data;
         } else {
             $this->OutputStatus = STATUS_NONE;
             $this->OutputArray = '没有棋局!';
         }
     } catch (Exception $e) {
         $this->setErrorOutput(validation_errors());
     }
     $this->loadView('output');
 }
Beispiel #8
0
function updateLogin($uid)
{
    $userIp = getUserIp();
    $curDate = date("Y-m-d H:i:s", strtotime("now"));
    $updateStr = "update user_data set status=1, loginIp=\"";
    $updateStr .= $userIp . "\", operateDate=\"" . $curDate;
    $updateStr .= "\" where uid=" . $uid;
    if (!mysql_query($updateStr)) {
        return mysql_error();
    } else {
        return 0;
    }
}
 public function setUserLogin($userInfo = array(), $remember = 0, $saveLogin = true, $loginFrom = 'wx')
 {
     $saltkey = getRandInt(8);
     $auth = setEnocde($userInfo['uid'] . "\t" . $userInfo['aid'] . "\t" . $loginFrom, user::getAuthKey($saltkey));
     myCookie('saltkey', $saltkey, $remember);
     myCookie('auth', $auth, $remember);
     //修改登录数据
     if ($saveLogin) {
         $this->update(array('last_login_ip' => ip2long(getUserIp()), 'last_login_time' => TIME), array('uid' => $userInfo['uid']));
     }
     return true;
 }
Beispiel #10
0
 function edit($param)
 {
     $this->removeInactive();
     $CI = get_instance();
     $CI->load->model('online_model');
     $CI->online_model->removeInactive();
     $this->db->select('id')->from('table')->where('TableName', $param['name'])->where('Creator <>', $param['creator']);
     if ($this->db->count_all_results() > 0) {
         return false;
     } else {
         $data = array('Creator' => $param['creator'], 'CreatorName' => $param['nickname'], 'Type' => $param['type'], 'GameTimer' => $param['timer'], 'Level' => $param['level'], 'IP' => getUserIp(), 'LANIP' => ($param['lanip'] == '' or $param['lanip'] == getUserIp()) ? '' : $param['lanip'], 'Port' => $param['port'], 'LastTime' => date('Y-m-d H:i:s'));
         $this->db->select('id')->from('table')->where('Creator', $param['creator']);
         if ($this->db->count_all_results() > 0) {
             $this->db->where('Creator', $param['creator']);
             $this->db->update('table', $data);
         } else {
             $data['TableName'] = $param['name'];
             $data['Visitor'] = '';
             $data['VisitorName'] = '';
             $this->db->insert('table', $data);
         }
         return $data;
     }
 }
Beispiel #11
0
 function login($username, $password, $lanip, $port)
 {
     // 产生安全码,用于登陆以后的操作
     if ($this->makeSecurity($username)) {
         $this->db->select('*')->from('user')->where('UserName', $username)->where('Password', $password);
         $query = $this->db->get();
         if ($query->num_rows() > 0) {
             $row = $query->row_array();
             $playTimes = $row['Win'] + $row['Lose'] + $row['Draw'];
             $disconnect = $row['GameTimes'] - $playTimes;
             if ($disconnect > $row['DisconnectTimes'] and $disconnect % 2 == 0) {
                 $reduce = true;
                 $row['DisconnectTimes'] = $row['GameTimes'] - $playTimes;
                 $row['Score']--;
                 $data = array('Score' => $row['Score'], 'DisconnectTimes' => $row['DisconnectTimes']);
                 $this->db->where('UserName', $username);
                 $this->db->update('user', $data);
             } else {
                 $reduce = false;
             }
             $this->db->select('UserName')->from('online')->where('UserName', $username);
             $query_online = $this->db->get();
             $data = array('UserName' => $username, 'Name' => $row['Name'], 'IP' => getUserIp(), 'LANIP' => $lanip, 'Port' => $port, 'LastTime' => date('Y-m-d H:i:s'));
             if ($query_online->num_rows() > 0) {
                 $this->db->where('UserName', $username);
                 $this->db->update('online', $data);
             } else {
                 $this->db->insert('online', $data);
             }
             $data = array('LastLogin' => date('Y-m-d H:i:s'));
             $this->db->where('UserName', $username);
             $this->db->update('user', $data);
             // 100 天未登陆者,用户数据将被删除!
             //$this->db->delete('user', array('DATE_ADD(LastLogin,INTERVAL 100 DAY)<' => date('Y-m-d H:i:s')));
             $ret = array($row['Email'], $row['UserClass'], $row['Face'], $row['Name'], $row['Sex'], $row['Age'], $row['Country'], $row['State'], $row['City'], $row['Win'], $row['Lose'], $row['Draw'], $row['GameTimes'], $row['Score'], getUserIp(), AzDG_crypt($row['Security1']), AzDG_crypt($row['Security2']));
             if ($reduce) {
                 $ret[] = '请注意:由于您又断线了 2 次,所以扣除 1 分! 当前分数: ' . $row['Score'];
             }
         } else {
             $ret = false;
         }
     } else {
         $ret = false;
     }
     $CI = get_instance();
     $CI->load->model('online_model');
     $CI->online_model->removeInactive();
     return $ret;
 }