Example #1
0
try {
    if (!$application == NULL) {
        if ($application->IsConfigured()) {
            redirect("login.php", 301);
            exit;
        } else {
            if (isset($_POST['USERNAME']) && isset($_POST['PWD']) && isset($_POST['PWDR'])) {
                //TODO Clear Input
                if ($_POST['USERNAME'] == "" || $_POST['PWD'] == "" || $_POST['PWDR'] == "") {
                    throw new Exception("Fields cannot be empty");
                }
                if ($_POST['PWD'] != $_POST['PWDR']) {
                    throw new Exception("Two passwords are different");
                }
                $new = new User();
                $new->SetID($_POST['USERNAME']);
                $new->SetPassword($_POST['PWD']);
                $new->SetAdmin(TRUE);
                $new->SetValid(TRUE);
                $new->Save();
                $msg = "User added successfully";
            }
        }
    }
} catch (Exception $e) {
    $error = $e->getMessage();
}
?>

<html>
<head>
Example #2
0
<?php

include 'models/user.php';
// try setting User
$adminuser = new User();
// this should be fetched from the DB.
$adminuser->SetID(5);
$adminuser->setusername("admin");
$adminuser->setpassword("admin");
$adminuser->setstatus(1);
$adminuser->settypeid(1);
echo 'User ID: ' . $adminuser->GetID() . "<br/>";
echo 'Username: '******'Password: '******'Status: ' . $adminuser->GetStatus() . "<br/>";
echo 'Type ID: ' . $adminuser->GetTypeID() . "<br/>";
Example #3
0
        } else {
            if (isset($_POST['USERNAME']) && isset($_POST['PWD']) && isset($_POST['PWDR'])) {
                if ($_POST['USERNAME'] == "" || $_POST['PWD'] == "" || $_POST['PWDR'] == "") {
                    throw new Exception("Fields cannot be empty");
                }
                if ($_POST['PWD'] != $_POST['PWDR']) {
                    throw new Exception("Two passwords are different");
                }
                $username = clearInput($_POST['USERNAME']);
                $usernameN = strip_tags($username);
                if ($usernameN != $username) {
                    throw new Exception("Inserted Username is not valid");
                }
                $username = strtolower($username);
                $new = new User();
                $new->SetID($username);
                $new->SetPassword($_POST['PWD']);
                $new->SetAdmin(isset($_POST['ADMIN']));
                $new->SetValid(TRUE);
                $new->Save();
                $msg = "User added successfully";
            }
        }
    } catch (Exception $e) {
        $error = $e->getMessage();
    }
}
?>

<html>
<head>