Exemple #1
0
function addLocation($location)
{
    //global the variables
    global $deviceKey, $deviceForm, $tool, $headings, $titles, $status;
    //create an empty temporary array to store all the new values given from the form
    $tempDeviceInfo = array();
    $deviceKey = array("name", "city", "address", "postal", "phone", "email", "room" . "notes", "addLocation");
    //add the values from the array
    foreach ($deviceKey as $index => $key) {
        $tempDeviceInfo[$key] = addslashes(htmlspecialchars(trim($_POST[$key]), ENT_QUOTES));
    }
    //set the values for location
    if ($location->set_name($tempDeviceInfo[name])) {
        $location->set_city($tempDeviceInfo[city]);
        $location->set_address($tempDeviceInfo[address]);
        $location->set_postal_code($tempDeviceInfo[postal]);
        $location->set_email($tempDeviceInfo[email]);
        $location->set_phone($tempDeviceInfo[phone]);
        $location->set_room($tempDeviceInfo[room]);
        $location->set_notes($tempDeviceInfo[notes]);
        //if the insert is sucessful reload the page with the new values
        if ($this_ID = $location->insert()) {
            $status = "success";
            $allLocation = Location::get_locations();
            $_SESSION['action'] = "Added new device location: " . $tempDeviceInfo[name];
            $update = new Updates();
            $update->set_action($_SESSION['action']);
            $update->set_username($_SESSION['fullname']);
            if ($update->insert_update()) {
                $_SESSION['action'] = "";
            }
            foreach ($allLocation as $id => $type) {
                echo "<option id={$id} name={$id}>{$type}</option>";
            }
        } else {
            $deviceForm->error("Warning: Failed to add location. Reason: " . $location->get_error(), $_GET['ID']);
        }
    } else {
        $deviceForm->error("Warning: Failed to add location. Reason: " . $location->get_error(), $_GET['ID']);
    }
}
Exemple #2
0
}
$access = $_SESSION['access'];
if (preg_match("/configurations.php/", $_SERVER['PHP_SELF'])) {
    if ($access != 100) {
        header("Location: index.php");
        echo "<h1>You have no permission</h1>";
    }
}
if ($_SESSION['action'] != "") {
    $allUpdates = Updates::get_updates();
    $index = 0;
    foreach ($allUpdates as $id => $value) {
        $index++;
        if ($index > 10) {
            $curUpdate = new Updates($id);
            if ($curUpdate->get_archived() == 0) {
                $curUpdate->set_archived(1);
                if (!$curUpdate->update()) {
                    echo 'update widget failed. Reason: ' . $curUpdate->get_error();
                }
            }
        }
    }
    $update = new Updates();
    $update->set_action($_SESSION['action']);
    $update->set_username($_SESSION['fullname']);
    $update->set_archived(0);
    if ($update->insert_update()) {
        $_SESSION['action'] = "";
    }
}