/**
  * 
  * @static
  * @return void
  */
 public static function Logout()
 {
     Session::StartUser(User::GetById(0));
 }
Example #2
0
if (!empty($user_name) && !empty($user_email) && !empty($_POST["user_password"]) && !empty($_POST["user_password2"])) {
    if ($_POST["user_password"] != $_POST["user_password2"]) {
        $error_message = I18n::L("Passwords mismatch.");
    } else {
        if (!Support::IsEMail($user_email)) {
            $error_message = I18n::L("Wrong E-mail address.");
        } else {
            if (User::FindUser($user_name)) {
                $error_message = I18n::L("Username «%s» is already taken, please find another username.", array($user_name));
            } else {
                if (User::FindUserByEmail($user_email)) {
                    $error_message = I18n::L("This email «%s» is already regesitered, please use another email.", array($user_email));
                } else {
                    $obj = User::Add(User::Create($user_name, $user_email, $_POST["user_password"]));
                    if ($obj->user_id) {
                        Session::StartUser($obj);
                        header("Location:" . PREFIX . "/dashboard/");
                        exit;
                    } else {
                        $error_message = I18n::L("Error while registring user.");
                    }
                    //todo: add some error log
                }
            }
        }
    }
} else {
    if (!empty($_POST["register"])) {
        $error_message = I18n::L("Please fill all required fields.");
    }
}
Example #3
0
/**
 * @package    zoneideas
 * @subpackage idea
 * @author     Serg Podtynnyi <*****@*****.**>
 */
/**
 *
 *
 */
ob_start();
include_once "../core.php";
$action = "login";
if (!empty($_POST["login"])) {
    if (!empty($_POST["user_name"]) && !empty($_POST["user_password"])) {
        $obj = User::CheckUser($_POST["user_name"], $_POST["user_password"]);
        User::$current = Session::StartUser($obj);
    } else {
        $error_message = I18n::L("Please fill all required fields.");
    }
}
if (User::Logged()) {
    header("Location:" . PREFIX . "/dashboard/");
    exit;
}
if (!empty($_POST["login"]) && !User::Logged()) {
    if (empty($error_message)) {
        $error_message = I18n::L("Wrong password.");
    }
    Viewer::AddData("error_message", $error_message);
    Viewer::AddData("user_name", $_POST["user_name"]);
}