Ejemplo n.º 1
0
function UpdateSettings()
{
    global $api_key;
    echo "Updating Settings\n";
    $user = GetUserData();
    if (is_array($user) && count($user)) {
        // load the current settings
        copy("./settings/settings.ini", "./settings/settings.ini.bak");
        $current = file_get_contents("./settings/settings.ini");
        if ($current && strlen($current)) {
            $settings = "";
            $lines = explode("\n", $current);
            foreach ($lines as $line) {
                $line = trim($line);
                if (!preg_match('/^(?P<key>[^=]+)=(?P<value>.*)$/', $line, $matches) || !array_key_exists($matches['key'], $user)) {
                    $settings .= $line;
                }
                $settings .= "\n";
            }
            $settings .= "\n;\n;Settings from user data\n;\n\n";
            foreach ($user as $key => $value) {
                if ($key == 'api_key') {
                    $api_key = trim($value);
                } else {
                    $settings .= "{$key}={$value}\n";
                }
            }
            $location_key = sha1(uniqid(mt_rand(), true));
            $settings .= "\n";
            $settings .= "location_key={$location_key}\n";
            $settings .= "ec2_initialized=1\n";
            file_put_contents("./settings/settings.ini", $settings);
        }
    }
}
Ejemplo n.º 2
0
function RegUserInfoComplete($con)
{
    GetUserData($con);
    if ($_SESSION['type'] == 'S') {
        $finalize = $con->prepare("SELECT Student_Id AS ID, Major FROM Student WHERE Username=:u");
        $finalize->bindColumn('Major', $_SESSION['major']);
    } elseif ($_SESSION['type'] == 'F') {
        $finalize = $con->prepare("SELECT Instructor_Id AS ID FROM Faculty WHERE Username=:u");
    } else {
        die('RegUserInfoComplete called on something which is not a faculty or student');
    }
    $finalize->bindParam(':u', $_SESSION['user']);
    $finalize->bindColumn('ID', $_SESSION['ID']);
    $finalize->execute();
    if ($res = $finalize->fetch()) {
        $finalize->closeCursor();
        return True;
    } else {
        $finalize->closeCursor();
        return False;
    }
}
Ejemplo n.º 3
0
<?php

require 'head.php';
?>


<?php 
if (!isset($_SESSION['user'])) {
    echo "<meta http-equiv=\"REFRESH\" content=\"0;url=index.php\"/>";
} else {
    $finalize = $con->prepare("UPDATE Faculty SET Position=:p, Dept_Id=:d WHERE Username=:u");
    $finalize->bindParam(':u', $_SESSION['user']);
    $finalize->bindParam(':p', $_POST['Position']);
    $finalize->bindParam(':d', $_POST['Department']);
    if ($finalize->execute()) {
        $finalize->closeCursor();
        $_SESSION['type'] = 'R';
        #force re fetch name
        GetUserData($con);
        echo "<meta http-equiv=\"REFRESH\" content=\"0;url=research-intrest.php\"/>";
    } else {
        die('Execute problem');
    }
}
?>

<?php 
require 'foot.php';
Ejemplo n.º 4
0
function GetDataForUser($userKey, $includeGroups)
{
    $users = GetUserData();
    if (!array_key_exists($userKey, $users)) {
        return NULL;
    }
    $userVal = $users[$userKey];
    if ($includeGroups) {
        $userVal->groups = GetGroupMemberships($userKey);
    }
    return $userVal;
}