public function conectar()
 {
     $username = isset($_POST['user']) ? $_POST['user'] : '';
     $password = isset($_POST['pass']) ? $_POST['pass'] : '';
     $permanent = isset($_POST['remember']);
     if (!($id = User::isValidUser($username, $password))) {
         echo -1;
     } else {
         User::saveUserSession($id, $permanent);
     }
 }
Example #2
0
require "src/scripts/conecta.php";
include_once "src/classes/Users.class.php";
//require "src/scripts/restrito.php";
$tpl = new Template('html_libs/template_livre.html');
$tpl->addFile("CONTEUDO", "html_libs/sys_login.html");
/* 
 * Recebendo dados por S_POST
 * para fazer login
 */
if (getenv("REQUEST_METHOD") == "POST") {
    if (isset($_POST['user'], $_POST['pass'])) {
        $user = $_POST['user'];
        $pass = $_POST['pass'];
        if (strlen($user) >= 6 && strlen($pass) >= 4) {
            $user = new User($user, $pass);
            if ($user->isValidUser()) {
                $user->startSession();
                $user->gotoRightPage();
                //$tpl->ALERTA = "Você está logado como ".$_SESSION['usuario'];
            } else {
                $tpl->ALERTA = "Os dados fornecidos estão incorretos!";
            }
        } else {
            $tpl->ALERTA = "O usuario deve ter no mínimo 6 caracteres e a senha 4.";
        }
    }
}
/*
 * Mostrar Página Restrita
 *
 */
Example #3
0
*/
include '../includes/Authenticate.php';
include '../classes/User.php';
include '../include/Database.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['submit'])) {
    $status = '';
    $name = htmlspecialchars(trim($_POST['name']));
    $department = htmlspecialchars(trim($_POST['department']));
    $emailid = htmlspecialchars(trim($_POST['emailid']));
    $password = htmlspecialchars(trim($_POST['password']));
    $secureid = htmlspecialchars(trim($_POST['secureid']));
    $contactnumber = htmlspecialchars(trim($_POST['contactnumber']));
    $fields = array($name, $department, $emailid, $password, $secureid, $contactnumber);
    // check if the secure id entered is "14300" if yes then set the user type to student else admin
    if (Authenticate::areFieldsFilled($fields)) {
        if (User::isValidUser($secureid)) {
            $type = User::getUserType($secureid);
            //register the user
            $isRegistrationSuccessful = User::register($name, $emailid, $department, $contactnumber, $type, $password);
            if ($isRegistrationSuccessful === DatabaseManager::PRIMARY_KEY_VIOLATED) {
                $status = "Email Id already Exists!";
            } elseif ($isRegistrationSuccessful === DatabaseManager::INSERT_SUCCESS) {
                if (Authenticate::login($emailid, $password)) {
                    Authenticate::redirect();
                }
            } else {
                $status = $isRegistrationSuccessful;
            }
        } else {
            $status = 'Invalid secure Id';
        }
Example #4
0
 public static function removeinvite($username, $password, $guildname, $username2)
 {
     if (User::isValidUser($username, $password)) {
         if (User::isGuildMaster($username, $guildname)) {
             $rows = Queries::getRowsWithValue(Database::$table_invites, "guildname", $guildname);
             for ($i = 0; $i < sizeof($rows); $i++) {
                 if ($rows[$i]['username'] == $username2) {
                     if (Queries::deleteWithTwoVals(Database::$table_invites, "username", $username2, "guildname", $guildname)) {
                         return "success";
                     }
                     return "failed to access database";
                 }
             }
             return "request not found";
         }
         return "only guildmaster can do this";
     }
     return "invalid user";
 }