Projekt

Obecné

Profil

Stáhnout (613 Bajtů) Statistiky
| Větev: | Revize:
1
<?php
2
require "../model/DB.php";
3

    
4
session_start();
5

    
6
if (array_key_exists("loggedIn", $_SESSION) && $_SESSION['loggedIn'] == "true" && array_key_exists("role", $_SESSION) && $_SESSION['role'] == "admin") {
7
    $DB = new DB();
8
    $results = $DB->select("SELECT id, username, role from USERS WHERE role = 'admin'", array());
9
    if (sizeof($results) == 1) { //at least one admin must still exist
10
        if ($results[0]["id"] != $_POST['userId']) {
11
            $result = $DB->deleteUser($_POST['userId']);
12
        }
13
    } else if (sizeof($results) > 1) {
14
        $result = $DB->deleteUser($_POST['userId']);
15
    }
16
}
(2-2/13)