コード例 #1
0
function manageSubjects($config, $parameters)
{
    if (!isset($_SESSION['uname']) || isset($_SESSION['urole']) && 3 != $_SESSION['urole']) {
        header('Location: /');
        exit;
    }
    $userName = $_SESSION['uname'];
    loadModel('models/Students');
    $profile = getStudentByStudentUserName($config, $userName);
    if (!$profile['status']) {
        return ['status' => false, 'message' => 'Invalid student profile found.'];
    }
    $student = $profile['student'];
    loadModel('models/Subjects');
    $remainingSubjects = getSubjectsNotTakenByStudent($config, $student['ID']);
    if (!$remainingSubjects['status']) {
        return ['status' => false, 'message' => 'An error occured while trying to get remaining subjects.'];
    }
    if ('POST' == getRequestMethod()) {
        if (!isset($_SESSION['uname'])) {
            header('Location: /students');
        }
        $studentName = $_SESSION['uname'];
        $result = addSubjectsToStudent($config, array_merge(['UserName' => $studentName], $_POST));
        $_SESSION['addStatus'] = $result['status'];
        $_SESSION['addStatusMessage'] = $result['message'];
        header('Location: /students');
    }
    return $remainingSubjects;
}
コード例 #2
0
function add($config, $parameters)
{
    loadModel('models/Subjects');
    loadModel('models/Students');
    $subjects = getAllSubjects($config);
    if (!$subjects['status']) {
        $subjects['subjects'] = [];
    }
    if ('POST' == getRequestMethod()) {
        $result = addStudent($config, $_POST);
        $_SESSION['addStatus'] = $result['status'];
        $_SESSION['addStatusMessage'] = $result['message'];
        header('Location: /students');
    }
    return ['status' => true, 'message' => 'An error occured while trying to retrieve Student records.', 'subjects' => $subjects['subjects']];
}
コード例 #3
0
function index($config, $parameters)
{
    if ('POST' == getRequestMethod()) {
        $username = isset($_POST['username']) ? $_POST['username'] : null;
        $password = isset($_POST['password']) ? sha1($_POST['password']) : null;
        loadModel('models/Users');
        $result = checkLogin($config, $username, $password);
        if ($result['status']) {
            if (isset($result['user'])) {
                $_SESSION['uname'] = $result['user']['UserName'];
                $_SESSION['urole'] = $result['user']['UserRole']['ID'];
                header('Location: /');
                exit;
            }
        } else {
            return ['status' => true, 'message' => $result['message'], 'invalid' => true];
        }
    }
    return ['status' => true, 'message' => 'Index action completed for controller Home.', 'data' => []];
}
コード例 #4
0
ファイル: KDGGeneral.php プロジェクト: typ6a/newhtf
function isGet()
{
    return strtolower(getRequestMethod()) == 'get' ? true : false;
}
コード例 #5
0
$clientPrivateKey = $_SERVER['AWS_SECRET_KEY'];
// These two keys are only needed if the delete file feature is enabled
// or if you are, for example, confirming the file size in a successEndpoint
// handler via S3's SDK, as we are doing in this example.
$serverPublicKey = $_SERVER['PARAM1'];
$serverPrivateKey = $_SERVER['PARAM2'];
// The following variables are used when validating the policy document
// sent by the uploader:
$expectedBucketName = "upload.fineuploader.com";
// $expectedMaxSize is the value you set the sizeLimit property of the
// validation option. We assume it is `null` here. If you are performing
// validation, then change this to match the integer value you specified
// otherwise your policy document will be invalid.
// http://docs.fineuploader.com/branch/develop/api/options.html#validation-option
$expectedMaxSize = 15000000;
$method = getRequestMethod();
// This first conditional will only ever evaluate to true in a
// CORS environment
if ($method == 'OPTIONS') {
    handlePreflight();
} else {
    if ($method == "DELETE") {
        handlePreflightedRequest();
        // only needed in a CORS environment
        deleteObject();
    } else {
        if ($method == 'POST') {
            handlePreflightedRequest();
            // Assumes the successEndpoint has a parameter of "success" associated with it,
            // to allow the server to differentiate between a successEndpoint request
            // and other POST requests (all requests are sent to the same endpoint in this example).
コード例 #6
0
function handleRequest($handlerArray)
{
    $method = getRequestMethod();
    debug("Request method: {$method}");
    $handler = $handlerArray[$method];
    if ($handler != null) {
        $handler();
    } else {
        badRequest("Method not supported: " . $method);
    }
}