Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Account {
- private static $f = "data/.account";
- private static function GetDetails() {
- if(file_exists(self::$f)) {
- $arr = json_decode(file_get_contents(self::$f),true);
- return $arr;
- }
- else {
- die("Error getting login information. Please contact developer.");
- }
- }
- public static function Auth($email,$password) {
- $email = strtolower($email);
- $logged_in = false;
- $match = self::GetDetails();
- if((isset($_POST["email"]) ? $_POST["email"] : "") == $match["email"] && (isset($_POST["pass"]) ? $_POST["pass"] : "") == $match["pass"]) {
- SessionManager::Set((isset($_POST["remember"]) ? $_POST["remember"] : false) == "1" ? true : false);
- $logged_in = true;
- $message = "You have been logged in.";
- } else {
- $message = "Incorrect email or password.";
- }
- return array("status" => $logged_in, "msg" => $message);
- }
- public static function ChangePwd($old,$new,$confirm) {
- if($new != $confirm) {
- return array(false,"Passwords do not match");
- }
- $arr = self::GetDetails();
- if($old != $arr["pass"]) {
- return array(false,"Current password is incorrect");
- }
- $arr["pass"] = $new;
- $fw = fopen(self::$f,"w");
- fwrite($fw,json_encode($arr));
- fclose($fw);
- return array(true,"Passwords have been changed");
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement