Пример #1
0
function login($email, $password)
{
    // check username and password with db
    // if yes, return true
    // else throw exception
    // connect to db
    $dbInfo = initialize_db_info();
    $dbLink = db_connect($dbInfo);
    db_select($dbLink, $dbInfo);
    $sql = generateUserVerificationSql($email, $password);
    // check if username is unique
    $result = mysql_query($sql, $dbLink);
    if (!$result || mysql_num_rows($result) == 0) {
        // The username and password did not match.
        // Check to see if the user exists.
        if (findUsername($email)) {
        } else {
        }
    }
    if (mysql_num_rows($result) > 0) {
        $row = mysql_fetch_assoc($result);
        $currentUser = new user_info();
        $currentUser->setId($row['id']);
        $currentUser->setFirstName($row['first_name']);
        $currentUser->setLastName($row['last_name']);
        $currentUser->setEmail($row['email']);
        $currentUser->setHunterId($row['hunter_id']);
        $currentUser->setLoggedIn(true);
        $_SESSION['current_user'] = $currentUser;
        $_SESSION['roles'] = getRoles($currentUser);
        return $currentUser;
    } else {
        throw new Exception('no user found 2');
    }
}
Пример #2
0
function getInfo()
{
    $info = user_info::getUserInfo($_SESSION['userId']);
    if ($info != false) {
        return $info;
    } else {
        return false;
    }
}
Пример #3
0
function createUserFromRow($dbRow)
{
    $rowUser = new user_info();
    $rowUser->setId($dbRow['id']);
    $rowUser->setFirstName($dbRow['first_name']);
    $rowUser->setLastName($dbRow['last_name']);
    $rowUser->setEmail($dbRow['email']);
    $rowUser->setHunterId($dbRow['hunter_id']);
    return $rowUser;
}
Пример #4
0
<?php

define('ROOT', dirname($_SERVER['SCRIPT_FILENAME']));
require ROOT . "/include/admin-init.php";
if (!is_login()) {
    die(html_jump('login.php'));
}
set_page_type('library', 'library_return');
set_page_power(array(1));
set_title("图书归还");
$all_user = new user_info();
$all_user->get_id_list();
get_admin_header();
?>
<div id="library-lent">
<h2 class="center">图书归还</h2>
<?php 
if (isset($_GET['status'])) {
    if ($_GET['status'] == 'OK') {
        echo '<p class="status blue center">成功归还图书</p>';
    } else {
        echo '<p class="status red center">', $_GET['status'], '</p>';
    }
}
?>
<form action="library-action.php" method="get">
图书ID:<input name="id" value="<?php 
if (isset($_GET['id'])) {
    echo $_GET['id'];
}
?>
Пример #5
0
 * 负责处理新发表文章的逻辑
 * Createed By C860 at 2014-1-19
 */
if (!class_exists('sys')) {
    include_once '../conf/config.php';
}
//需要登录
sys::needLog('../login.php');
//检测数据合法性
if (isset($_POST['title']) && !empty($_POST['title']) && isset($_POST['content']) && !empty($_POST['content']) && isset($_POST['tags']) && !empty($_POST['tags'])) {
    //引入相关模型类
    include_once '../Models/article.php';
    include_once '../Models/tag_relate_article.php';
    include_once '../Models/user_info.php';
    $currentTime = date('Y-m-d H:i:s');
    //新增文章
    if (article::add($_POST['title'], $_POST['content'], $currentTime, $_SESSION['userId'])) {
        $ID = article::getId($_POST['title'], $_SESSION['userId'], $currentTime);
        $tags = explode('|', $_POST['tags']);
        foreach ($tags as $tag) {
            tag_relate_article::add($tag, $ID);
        }
        user_info::increaseArticleCount($_SESSION['userId']);
        sys::alert('发表成功!');
        sys::redirect('../index.php');
    }
} else {
    //引入相关模型类
    include_once 'Models/tag.php';
    $taglist = tag::getAllTags();
}
Пример #6
0
<?php

if (!isset($_POST['do'])) {
    exit;
}
require_once '../class/include.php';
$facebook = new Facebook(array('appId' => FACEBOOK_APP_ID, 'secret' => FACEBOOK_SECRET));
$user = $facebook->getUser();
if ($_POST['do'] == 'insertUserInfo') {
    $user_info = new user_info();
    //$user_info->GetById(1);
    $useragent = $_SERVER['HTTP_USER_AGENT'];
    if (preg_match('/android.+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|meego.+mobile|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $useragent) || preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-/i', substr($useragent, 0, 4))) {
        $came_from_platform_url = '1';
        $came_from_app_url = '0';
    } else {
        $came_from_platform_url = '0';
        $came_from_app_url = '1';
    }
    if ($user) {
        try {
            $user_profile = $facebook->api('/me');
        } catch (Exception $e) {
            echo 'Caught exception: ', $e->getMessage(), "\n";
        }
        // echo $user;exit;
        if (isset($_POST['radio1'])) {
            $st = "SELECT `ques1`,`ques2`,`ques3` FROM `trivia` ";
            $query = mysql_query($st) or die(mysql_error() . ' ' . $st);
            $row = mysql_fetch_assoc($query);
            $sum_answer = 0;
Пример #7
0
<?php

define('ROOT', dirname($_SERVER['SCRIPT_FILENAME']));
require ROOT . "/include/admin-init.php";
if (!is_login()) {
    die(html_jump('login.php'));
}
set_page_type('user', 'user_manage');
set_page_power(array(1));
set_title("用户管理");
$all_user = new user_info();
$all_user->get_all_user();
$all_group = new group();
$all_group->get_id_list();
if (isset($_GET['status']) && $_GET['status'] != 'OK') {
    add_footer_str('<script language="javascript">error_notic("' . $_GET['status'] . '","");</script>');
}
get_admin_header();
?>
<div id="user-manage">
<h2 class="center">用户管理中心</h2>
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr class="title"><th>ID</th><th>用户名</th><th>姓名</th><th>专业</th><th>班级</th><th>年级</th><th>分组</th><th>电话</th><th>QQ</th><th>邮箱</th><th>权限</th><th>状态</th><th>操作</th></tr>
<?php 
$i = 0;
foreach ($all_user->all as $id => $v) {
    echo "<tr class=\"list-", $i++ % 2, "\">", "<td>", $v['id'], "</td>", "<td>", $v['user'], "</td>", "<td>", $v['name'], "</td>", "<td>", $v['major'], "</td>", "<td>", $v['class'], "</td>", "<td>", $v['grade'], "</td>", "<td>", $all_group->id_list[$v['group']], '-', $v['group'], "</td>", "<td>", $v['tel'], "</td>", "<td>", $v['qq'], "</td>", "<td>", $v['email'], "</td>", '<td><a href="user-manage.php?act=chang-power&id=', $v['id'], '" title="修改权限">', get_power_name($v['power']), "</a></td>", "<td>", $v['active'] == 1 ? '<a href="user-action.php?act=unactive&id=' . $v['id'] . '" title="取消激活">激活</a>' : '<a href="user-action.php?act=active&id=' . $v['id'] . '" title="激活">未激活</a>', "</td>", '<td><a href="user-edit-info.php?id=', $v['id'], '">编辑</a>&nbsp;<a href="user-action.php?act=del&id=', $v['id'], '">删除</a></td>', "</tr>\n";
}
?>
</table>
</div>
Пример #8
0
<?php

/*
 * checkLog.php
 * 用户登录检测程序
 * Created By C860 at 2014-1-18
 */
include_once '../conf/config.php';
//引入相关模型类
include_once '../Models/user_basic.php';
include_once '../Models/user_info.php';
//检测数据合法性
if (isset($_POST['user']) && !empty($_POST['user']) && isset($_POST['password']) && !empty($_POST['password'])) {
    if (user_basic::check($_POST['user'], $_POST['password'], 0)) {
        $uid = user_basic::getUserId($_POST['user']);
        $nickname = user_info::getNickname($uid);
        //设置SESSION
        $_SESSION['userId'] = $uid;
        $_SESSION['user'] = $_POST['user'];
        $_SESSION['nickname'] = $nickname;
        sys::redirect('../index.php');
    } else {
        sys::alert('用户名或密码错误!');
        sys::redirect('../login.php');
    }
}
Пример #9
0
<?php

define('ROOT', dirname($_SERVER['SCRIPT_FILENAME']));
require ROOT . "/include/admin-init.php";
if (!is_login()) {
    die(html_jump('login.php'));
}
set_page_type('user', 'user_group');
set_page_power(array(1));
set_title("用户组管理");
$group = new group();
$user_info = new user_info();
$group->get_group();
$user_info->get_all_user();
$user_info->get_id_list();
$group->get_user_group();
if (isset($_GET['status']) && $_GET['status'] != 'OK') {
    add_footer_str('<script language="javascript">error_notic("' . $_GET['status'] . '","");</script>');
}
get_admin_header();
?>
<div id="user-group">
<h2 class="center">用户组管理</h2>
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr class="title"><th>ID</th><th>分组名</th><th>组长</th><th>组员</th><th>操作</th></tr>
<?php 
$i = 0;
foreach ($group->group as $v) {
    echo '<tr class="list-', $i++ % 2, '"><td>', $v['id'], '</td>', '<td>', $v['name'], '</td>', '<td>';
    if (isset($user_info->id_list[$v['lader']])) {
        echo '<a href="user.php?id=', $v['lader'], '">', $group->lader_id[$v['lader']], '(', $v['lader'], ')</a>';
Пример #10
0
 function edit_group($id, $name, $lader)
 {
     if (empty($name) || empty($lader) || empty($id)) {
         return '数据有误';
     }
     global $mysql;
     $old = $mysql->get_mysql_arr("group", "*", '`id`=' . $id);
     if (!(isset($old[0]['id']) && $old[0]['id'] == $id)) {
         return 'ID不存在或ID错误';
     }
     if ($old[0]['name'] == $name && $old[0]['lader'] == $lader) {
         return '信息未改变';
     }
     $user_info = new user_info();
     $user_info->get_id_list();
     if (!isset($user_info->id_list[$lader])) {
         return '该组长不存在';
     }
     if ($mysql->up_sql_arr("group", array('name' => $name, 'lader' => $lader), '`id`=' . $id)) {
         return 'OK';
     } else {
         return '更新数据失败';
     }
 }
Пример #11
0
<?php

/*
 * article.php
 * 负责文章显示页面的逻辑
 * Created By C860 at 2014-2-7
 */
include_once 'conf/config.php';
//引入相关模型类
include_once 'Models/article.php';
include_once 'Models/user_info.php';
//检验数据合法性
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = $_GET['id'];
    $article = article::getArticle($id);
    $author = user_info::getNickname($article['user_id']);
    if (!$article || !$author) {
        sys::alert('未知错误!');
        sys::redirect('index.php');
    }
}
Пример #12
0
<?php

include_once "conf/config.php";
//引入相关模型类
include_once "Models/user_info.php";
include_once "Models/article.php";
if (!$_GET['id']) {
    die("出错");
}
$ID = $_GET['id'];
list($ID, $nickname, $popularity, $registerTime, $signature, $article_count) = user_info::getUserInfo($ID);
$allrows = article::getArticleInfo($ID);
if (!$allrows) {
    $allrows = array();
}
?>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>hci-user</title>
	<link rel="stylesheet" type="text/css" href="public/stylesheets/global.css">
	<link rel="stylesheet" type="text/css" href="public/stylesheets/user.css">
	<script type="text/javascript" src="public/javascripts/navSlide.js"></script>
	<script type="text/javascript">
	window.onload = function(){
		//本页面对应栏,下标由0起始,首页为0
        initSlide(0);
	};
	</script>
</head>
Пример #13
0
        //	  // email address not valid
        //	  if (!valid_email($email)) {
        //	    throw new Exception('That is not a valid email address.  Please go back and try again.');
        //	  }
        //
        //	  // passwords not the same
        //	  if ($password1 != $password2) {
        //	    throw new Exception('The passwords you entered do not match - please go back and try again.');
        //	  }
        //
        //	  // Check password length is ok
        //	  // Ok if username truncates, but passwords will get
        //	  // Munged if they are too long.
        //	  if ((strlen($password1) < 6) || (strlen($password1) > 16)) {
        //	    throw new Exception('Your password must be between 6 and 16 characters Please go back and try again.');
        //	  }
        // Attempt to register
        // This function can also throw an exception
        register($email, $password1, $firstName, $lastName);
        $currentUser = new user_info();
        $currentUser->setFirstName($firstName);
        $currentUser->setLastName($lastName);
        $currentUser->setEmail($email);
        sendNewUserNotification($currentUser);
        // Register session variable
        $_SESSION['current_user'] = $currentUser;
        header("Location: /index.php");
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
Пример #14
0
include_once '../conf/config.php';
//引入相关模型类
include_once '../Models/user_basic.php';
include_once '../Models/user_info.php';
//检测数据合法性
if (isset($_POST['user']) && !empty($_POST['user']) && isset($_POST['password']) && !empty($_POST['password']) && isset($_POST['nickname']) && !empty($_POST['nickname'])) {
    //检测用户个性签名是否存在
    if (isset($_POST['signature'])) {
        $signature = $_POST['signature'];
    } else {
        $signature = '';
    }
    //检测用户名是否存在
    if (user_basic::userExist($_POST['user'])) {
        sys::alert('用户名已存在!');
        sys::redirect('../register.php');
    }
    //检测昵称是否存在
    if (user_info::nicknameExist($_POST['nickname'])) {
        sys::alert('用户昵称已存在!');
        sys::redirect('../register.php');
    }
    //数据全部合法,进行注册程序
    if (user_basic::add($_POST['user'], $_POST['password']) && user_info::add(user_basic::getUserId($_POST['user']), $_POST['nickname'], date('Y-m-d H:i:s'), $signature)) {
        sys::alert('注册成功!');
        sys::redirect('../index.php');
    } else {
        sys::alert('出现未知错误!');
        sys::redirect('../register.php');
    }
}