Exemplo n.º 1
0
function forgotPwd()
{
    global $req;
    global $connection;
    global $module;
    $req->hasParams("email");
    $email = $req->getParam("email");
    $POST = array('email' => $email);
    $val = new validation();
    $val->addSource($POST);
    $val->addRule('email', 'email', true, 2, 100, true);
    $val->run();
    if (sizeof($val->errors) > 0) {
        $connection->close();
        $errors = implode(" <br/> ", $val->errors);
        Res::sendInvalid("Error: " . $errors);
    } else {
        $POST = $val->sanitized;
        $email = $module->escape($POST['email']);
        $output = $module->forgotPwd($email);
        if (is_bool($output)) {
            Res::sendInvalid($module->message);
        } else {
            $res = new Res();
            $res->send();
        }
    }
}
Exemplo n.º 2
0
function addUsers()
{
    global $req;
    global $connection;
    $req->hasParams("adminUName", "adminFName", "adminGender", "adminEMail", "adminPassword", "adminPhone");
    $adminUName = $req->getParam("adminUName");
    $adminFName = $req->getParam("adminFName");
    $adminGender = $req->getParam("adminGender");
    $adminEMail = $req->getParam("adminEMail");
    $adminPassword = $req->getParam("adminPassword");
    $adminPhone = $req->getParam("adminPhone");
    $POST = array('adminUName' => $adminUName, 'adminFName' => $adminFName, 'adminGender' => $adminGender, 'adminEMail' => $adminEMail, 'adminPassword' => $adminPassword, 'adminPhone' => $adminPhone);
    $genderValues = array('m', 'f', 'u');
    $val = new validation();
    $val->addSource($POST);
    $val->addRule('adminUName', 'string', true, 2, 50, true)->addRule('adminFName', 'string', true, 2, 50, true)->addRule('adminGender', 'string', true, 1, 1, true)->addRule('adminEMail', 'email', true, 5, 100, true)->addRule('adminPassword', 'string', true, 4, 35, true)->addRule('adminPhone', 'string', true, 4, 20, true);
    $val->run();
    if (sizeof($val->errors) > 0) {
        $errors = implode(" <br/> ", $val->errors);
        Res::sendInvalid("Errors:" . $errors);
    } else {
        $POST = $val->sanitized;
        $adminTable = new adminTable($connection);
        $adminUName = $adminTable->escape($POST['adminUName']);
        $adminFName = $adminTable->escape($POST['adminFName']);
        $adminGender = $adminTable->escape($POST['adminGender']);
        $adminEMail = $adminTable->escape($POST['adminEMail']);
        $adminPassword = $adminTable->escape($POST['adminPassword']);
        $adminPhone = $adminTable->escape($POST['adminPhone']);
        $adminId = $adminTable->insertUsers($adminUName, $adminFName, $adminGender, $adminEMail, $adminPassword, $adminPhone);
        if (is_bool($adminId)) {
            Res::sendInvalid("Errors:" . $adminTable->message);
        } else {
            $res = new Res();
            $res->addData("adminId", $adminId);
            $res->send();
        }
    }
}