예제 #1
0
파일: login.php 프로젝트: ynarwal/scavhunt
function userLogin()
{
    global $user, $dataDir;
    session_start();
    if (isset($_REQUEST['schoolId'])) {
        $schoolId = $_REQUEST['schoolId'];
        $password = $_REQUEST['password'];
        $_SESSION['schoolId'] = $schoolId;
        $_SESSION['password'] = $password;
    } else {
        $schoolId = $_SESSION['schoolId'];
        $password = $_SESSION['password'];
    }
    if (!isUser($schoolId)) {
        $user = false;
        return false;
    }
    $userFile = $dataDir . '/users/' . $schoolId . '.dat';
    $account = unserialize(file_get_contents($userFile));
    if ($account['password'] == md5($password)) {
        $studentInfo = array_merge($account, getStudentInfo($schoolId));
        $user = $studentInfo;
    } else {
        $user = false;
    }
    return $user;
}
예제 #2
0
 public function testGetStudentInfo()
 {
     $ar = array();
     $ar['id'] = '120273G';
     $ar['name'] = 'Pasindu Jayaweera';
     $ar['intake'] = '2012';
     $ar['image'] = 'resources/img/profilePics/120273G.png';
     $this->assertEquals($ar, getStudentInfo('120273G'));
 }
예제 #3
0
        // Last names differ, so use those for sorting.
        return strcmp($a['last'], $b['last']);
    }
    // Scores are different, so we can sort by that.
    return $aC > $bC ? -1 : 1;
}
for ($challengeNumber = 1; $challengeNumber <= $challengeTotal; $challengeNumber++) {
    $challengeBits = explode('-', $challenges[$challengeNumber - 1]);
    if ($challengeId == trim($challengeBits[0])) {
        // We reached the current challenge, stop here.
        break;
    }
    $challengeOn = trim($challengeBits[0]);
    if (isset($scores[$challengeOn])) {
        foreach ($scores[$challengeOn] as $userId => $score) {
            $userInfo = getStudentInfo($userId);
            if ($userInfo['grade'] != 0) {
                $scoreboard['individual'][$userId]['name'] = $userInfo['first'] . ' ' . $userInfo['last'];
                $scoreboard['individual'][$userId]['first'] = $userInfo['first'];
                $scoreboard['individual'][$userId]['last'] = $userInfo['last'];
                $scoreboard['individual'][$userId]['score'] += $score;
                if (isset($scoreboard['class'][$userInfo['grade']])) {
                    $scoreboard['class'][$userInfo['grade']]['score'] += $score;
                }
            }
        }
    }
    $scoreboard['individual'] = assignRanks($scoreboard['individual']);
    $scoreboard['class'] = assignRanks($scoreboard['class']);
}
if (!$challengeId) {
예제 #4
0
<?php

include 'session.php';
include 'controller/dbController.php';
$semester = $_GET['q'];
$record = getStudentInfo($login_session);
$name = $record["name"];
$image = $record["image"];
$intake = $record["intake"];
//get the year of the Student's certain semester
$year = getYearOfStudentSemester($semester, $login_session);
//get all enrolled courses for a certain students certain semseter
$codeList = getAllCourseEnrolledForSemester($semester, $login_session);
//get all data about that codes in that very semester
$courseStats = getBatchStatsForSemester($semester, $login_session, $year);
//get the semesterGPA for a certain user
$semGpa = getSemGpa($semester, $login_session);
?>
<html>
<head>
</head>
<body>
    <!--Redesin the user's box with including RANK and GPA -->
    <div class ="mybox">
        <div class="propic">
            <?php 
echo '<center><img src="data:image/jpeg;base64,' . base64_encode(file_get_contents($image)) . '"/></center>';
?>
        </div> 
        <h1><span class="data"><center><?php 
echo "" . $name;
예제 #5
0
                                                <label>About Me</label>
                                                <textarea rows="5" class="form-control" placeholder="Here can be your description" value="Mike">Lamborghini Mercy, Your chick she so thirsty, I'm in that two seat Lambo.</textarea>
                                            </div>
                                        </div>
                                    </div>

                                    <button type="submit" class="btn btn-info btn-fill pull-right">Update Profile</button>
                                    <div class="clearfix"></div>
                                </form>
                            </div>
                        </div>
                    </div>-->
                    <div class="col-md-12 col-lg-12">
                        <div class="card card-user">
                           <?php 
echo getStudentInfo($student_id);
?>
                           <p style="text-align:center;color:black;">Road to Straight A's!</p>
                           <div class="progress">
                             <div class="progress-bar progress-bar-warning progress-bar-striped" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%">
                               <span class="sr-only">50% Complete (warning)</span>
                             </div>
                           </div>
                           <p style="text-align:center;color:black;">You're close to perfect attendance!</p>
                           <div class="progress">
                             <div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 40%">
                               <span class="sr-only">80% Complete (success)</span>
                             </div>
                            </div>
                            <hr>
                            <div class="text-center">
예제 #6
0
 public function testGetStudentInfoWithNonExistingStudent()
 {
     $this->assertFalse(getStudentInfo('AAA'));
 }
<?php

include 'session.php';
include 'controller/dbController.php';
//get the passed student ID
$studentId = $_GET['q'];
//get the details of the user
$record = getStudentInfo($studentId);
$image = $record["image"];
$name = $record["name"];
?>
<html>
<head>
</head>
<body>
    <!-- Div of the comparing student-->
    <div class="someonebox">
        <!-- To Crop the image to the needed size-->
        <div class = crop>    
        <?php 
echo '<center><img src="data:image/jpeg;base64,' . base64_encode(file_get_contents($image)) . '"/></center>';
?>
         <h1><span class="data"><?php 
echo "<center>" . $name;
?>
</span></center><br>   </h1>
        </div>
    </div>
    <!-- Div to display the comparison table-->
    <div class ="comparebox">        
        <!-- Div to the table seperately-->
예제 #8
0
<?php

include 'session.php';
include 'controller/dbController.php';
$studentOne = $_GET["q"];
$year = $_GET["y"];
//details of the first student
$record = getStudentInfo($studentOne);
$studentOneName = $record["name"];
$studentOneImage = $record["image"];
$secondOptionStudents = getStudentInfoCommonCourseFollowed($studentOne);
?>

<html>
<body>
    <div class= "studentOnebox">
        <div class="propic">
            <?php 
echo '<center><img src="data:image/jpeg;base64,' . base64_encode(file_get_contents($studentOneImage)) . '"/></center>';
?>
        </div> 
        <h1><span class="data"><center><?php 
echo "" . $studentOneName;
?>
</center></span><br>   </h1>
    </div>

    <div  class="selectStudent2" id="val">    
        <form>
        <select id=selectCourse2 name="users" onchange="compare(this.value)">
        <option value="">Select Student</option>
예제 #9
0
파일: login.php 프로젝트: ynarwal/scavhunt
unset($errorText);
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST' && (isset($_POST['create_age']) || isset($_POST['create_lastname']) || isset($_POST['create_password']))) {
    if ($_POST['create_lastname'] == '' && $_POST['create_password'] == '') {
        $errorText = 'Sorry, we couldn\'t log you in using that information.';
    } elseif ($_POST['create_age'] != 'over_13') {
        $errorText = 'Sorry, you must be at least 13 to play in the scavenger hunt.';
    } else {
        // They want to create an account, and are at least 13.
        if (isUser($_POST['schoolId'])) {
            // The user already exists
            $errorText = 'It looks like you already have an account. Try logging in with just your ID and password.';
        } elseif (($_POST['create_password'] = '') || $_POST['create_lastname'] == '') {
            // They didn't enter a last name or password
            $errorText = 'Sorry, you must fill out the new user form completely.';
        } else {
            $user = getStudentInfo($_POST['schoolId']);
            if (count($user) == 0 || levenshtein(strtolower($user['last']), strtolower($_POST['create_lastname'])) > 2) {
                // The student ID wasn't found, or their last name didn't match closely enough
                $errorText = 'Sorry, we can\'t find a record of you at the school.';
            } else {
                // Create their record
                $userFileData = serialize(array('password' => md5($_REQUEST['create_password'])));
                file_put_contents($user['file'], $userFileData);
                // Log them in
                session_start();
                $_SESSION['schoolId'] = $_POST['schoolId'];
                $_SESSION['password'] = $_REQUEST['create_password'];
                $_SESSION['flash'] = 'Your account was created successfully, and you\'ve been logged in.';
                // Bounce them so they'll get redirected to the right place
                header('Location: /login.php');
                die;
예제 #10
0
파일: play.php 프로젝트: ynarwal/scavhunt
function pickUnusedSurvey($fromChallenge, $minPoints)
{
    global $user, $challengeId, $dataDir, $answerFile, $answers, $seeking;
    $userToFind = false;
    // See if we already have a user to find.
    if (count($answers[$challengeId]) != count($answers[$challengeId . '_assigned'])) {
        // We do, just use that.
        $userToFind = $answers[$challengeId . '_assigned'][count($answers[$challengeId . '_assigned']) - 1];
    } else {
        // We need to find a random user that:
        //  1. Is not us
        //  2. Has not already been chosen by us
        //  3. Has enough points on the relevant question
        $scores = unserialize(file_get_contents($dataDir . '/scores.dat'));
        $possibleUsers = $scores[$fromChallenge];
        // Do we even have scores yet?
        if (!is_array($possibleUsers)) {
            return false;
        }
        // Remove us
        if (isset($possibleUsers[$user['id']])) {
            unset($possibleUsers[$user['id']]);
        }
        // Remove people we've already chosen
        if (is_array($answers[$challengeId . '_assigned'])) {
            foreach ($answers[$challengeId . '_assigned'] as $assignedUser) {
                if (isset($possibleUsers[$assignedUser])) {
                    unset($possibleUsers[$assignedUser]);
                }
            }
        }
        // Remove people with scores that are too low
        foreach ($possibleUsers as $scoreUserId => $score) {
            if ($score < $minPoints) {
                unset($possibleUsers[$scoreUserId]);
            }
        }
        // Anything left?
        if (count($possibleUsers > 0)) {
            // Pick a random one.
            $userToFind = array_rand($possibleUsers);
        } else {
            // Nope. Oh well.
            $userToFind = false;
        }
        // Save the newly found [non-?]user
        $answers[$challengeId . '_assigned'][] = $userToFind;
        file_put_contents($answerFile, serialize($answers));
    }
    if ($userToFind == false) {
        return false;
    }
    // Load their data
    $seeking = getStudentInfo($userToFind);
    // Look up their answer(s) to that challenge
    $otherAnswers = unserialize(file_get_contents($dataDir . '/users/' . $userToFind . '_answers.dat'));
    return $otherAnswers[$fromChallenge];
}
예제 #11
0
<?php

include 'db_helper.php';
if ($_GET['f'] == 'add' && $_GET['name'] && $_GET['gender'] && $_GET['email'] && $_GET['phone']) {
    addStudent($_GET['name'], $_GET['gender'], $_GET['email'], $_GET['phone']);
} elseif ($_GET['f'] == 'get' && $_GET['email']) {
    getStudent($_GET['email']);
} elseif ($_GET['f'] == 'update' && $_GET['name'] && $_GET['gender'] && $_GET['phone'] && $_GET['sid']) {
    updateStudent($_GET['name'], $_GET['gender'], $_GET['phone'], $_GET['sid']);
} elseif ($_GET['f'] == 'get' && $_GET['sid']) {
    getStudentInfo($_GET['sid']);
}
function getStudent($email)
{
    $dbQuery = sprintf("SELECT ID FROM Student WHERE email = '%s'", mysql_real_escape_string($email));
    //
    $result = getDBResultRecord($dbQuery);
    //header("Content-type: application/json");
    echo json_encode($result);
}
function addStudent($name, $gender, $email, $phone)
{
    $dbQuery = sprintf("INSERT INTO Student (name,gender,email,phone) VALUES ('%s','%d','%s','%d')", mysql_real_escape_string($name), $gender, mysql_real_escape_string($email), $phone);
    $result = getDBResultInserted($dbQuery, 'ID');
    //header("Content-type: application/json");
    echo json_encode($result);
}
function updateStudent($name, $gender, $phone, $sid)
{
    $dbQuery = sprintf("UPDATE Student SET name = '%s',gender='%d',phone='%d' WHERE ID = '%d'", mysql_real_escape_string($name), $gender, $phone, $sid);
    $result = getDBResultAffected($dbQuery);