Esempio n. 1
0
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * [REST_META]
 *
 * username (string)
 *
 */
header('Content-type: application/json');
require_once ROOT_PATH . 'includes/load_admin_usernames.php';
$expectations = ['username'];
if (!\Utilities\Requests::HasRequest($expectations)) {
    die(ModelResponse::InvalidRequest());
}
$is_admin = is_admin($_REQUEST['username']);
$user = null;
if ($is_admin) {
    $user = \Models\User::FindUsername($_REQUEST['username']);
    die(new ModelResponse(true, 'Yes, an admin', $user));
} else {
    die(new ModelResponse(false, sprintf('User \\"%s\\" is not an admin', $_REQUEST['username'])));
}
Esempio n. 2
0
<?php

/*
 * Copyright (C) 2015 alinatoc
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
if (!\Utilities\Requests::HasRequest(['id'])) {
    header('location: ' . BASE_URL);
    exit;
}
if (!\Utilities\Session::IsLoggedIn()) {
    header(sprintf('location: %s?after=%s&note=%s', BASE_URL, urlencode(rtrim(BASE_URL, '/') . $_SERVER['REQUEST_URI']), 'Please log in first using your account'));
}
Esempio n. 3
0
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * [REST_META]
 *
 * category [optional] = { overall | individual | department }
 *
 */
header('Content-type: application/json');
$category = 'overall';
if (\Utilities\Requests::HasRequest(['category'])) {
    if (!in_array(strtolower($_REQUEST['category']), ['overall', 'individual', 'department'])) {
        die(ModelResponse::InvalidRequest());
    }
    $category = strtolower($_REQUEST['category']);
}
switch ($category) {
    case 'individual':
        die(new ModelResponse(true, 'Success', new \Models\Reports\MonthlyIndividualList()));
        break;
    case 'department':
        die(new ModelResponse(true, 'Success', new \Models\Reports\MonthlyDepartmentList()));
        break;
    default:
        // Overall
        die(new ModelResponse(true, 'Success', new \Models\Reports\MonthlyOverallList()));
Esempio n. 4
0
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 * [REST_META]
 *
 * username (string)
 * password (string)
 *
 */
header('Content-type: application/json');
require_once ROOT_PATH . 'includes/load_ad_usernames.php';
// Check requests
if (!\Utilities\Requests::HasRequest(['username', 'password'])) {
    die(ModelResponse::InvalidRequest());
}
extract($_REQUEST, EXTR_SKIP);
$matches = array();
// Username sanitation
preg_match('/[A-Za-z0-9_\\.]+/', $username, $matches);
if (sizeof($matches) > 0) {
    $username = $matches[0];
}
// end of username sanitation
if (!has_account($username)) {
    die(new ModelResponse(false, 'User is not registered'));
}
// Otherwise, proceed with LDAP authentication
$ldapresource = ldap_connect("ldap://svg.openit.local", 389) or die("Unable to connect to ldap://svg.openit.local:389");