public static function access() { if (REQUEST::$POST && FORM::passed()) { if (isset(FORM::$ACCOUNT[self::$FORMNAME]) && isset(FORM::$ACCOUNT[self::$FORMNAME]["access_type"]) && isset(FORM::$COLUMN[self::$FORMNAME]) && !empty(FORM::$COLUMN[self::$FORMNAME])) { $db = CONFIG::primary_database(); if (isset(ACCOUNT::$roles[$db])) { $username_value = null; $password_value = null; $dbconfig = ACCOUNT::get_database_config(); extract($dbconfig); $accountname = self::$FORMNAME; foreach (FORM::$COLUMN[self::$FORMNAME] as $field => $schema) { if ($table == $schema["table"]) { if ($schema["column"] == ACCOUNT::$roles[$db]["username"]) { $username_value = FORM::$accountname("username"); } if ($schema["column"] == ACCOUNT::$roles[$db]["password"]) { $password_value = self::bool_val(ACCOUNT::$roles[$db]["encrypt_password"]) == true ? ACCOUNT::encrypt_password(FORM::$accountname("password")) : FORM::$accountname("password"); } } } if ($username_value != null) { $useraccount = ACCOUNT::get($username, $username_value); if ($useraccount != null) { if (FORM::$ACCOUNT[self::$FORMNAME]["access_type"] == "recover") { ACCOUNT::recover($useraccount); } if (FORM::$ACCOUNT[self::$FORMNAME]["access_type"] == "register") { ACCOUNT::$error_already_exists = true; } if (FORM::$ACCOUNT[self::$FORMNAME]["access_type"] == "login") { if ($useraccount->{$password} == $password_value) { SESSION::setaccount($useraccount->{$id}); } else { ACCOUNT::$error_log_in_failed = true; } } } else { if (FORM::$ACCOUNT[self::$FORMNAME]["access_type"] == "register") { ACCOUNT::create(FORM::fields()); } elseif (FORM::$ACCOUNT[self::$FORMNAME]["access_type"] == "recover") { ACCOUNT::$error_not_found = true; } else { ACCOUNT::$error_not_found = true; } } } else { ACCOUNT::$error_log_in_failed = true; } } } } }