public static function setaccount($id) { $_SESSION["__nise__"]["account"] = $id; ACCOUNT::set($id); $loggedin = ACCOUNT::set(); $loggedout = !$loggedin; NISE::put(compact('loggedin', 'loggedout')); }
public static function apply() { Output\OUTPUT::set_static_file(); if (self::has_attribute(self::get("primary_database")[0], "alias", true)) { CONFIG::$primarydatabase = self::get("primary_database")[0]["@attributes"]["alias"]; } foreach (self::get("rewrite_rules") as $value) { REQUEST::translate($value); } foreach (self::get("links") as $value) { self::set_table_links($value); } if (REQUEST::$is_static == true && !empty(Output\OUTPUT::$static_file)) { Output\OUTPUT::static_file(); } if (REQUEST::redirect()) { header("Location: " . REQUEST::root() . "/" . REQUEST::redirect_uri()); } foreach (self::get("accounttypes") as $value) { ACCOUNT::translate($value); } foreach (self::get("database") as $value) { if (self::has_attribute($value, "alias", true)) { $alias = $value["@attributes"]["alias"]; unset($value["@attributes"]["alias"]); $config = $value["@attributes"]; unset($value["@attributes"]); if (!isset($config["tablelinks"]) && isset(self::$table_links[$alias])) { $config["tablelinks"] = self::$table_links[$alias]; } Database\DATABASE::register_database($alias, $config); foreach (self::get("table") as $subvalue) { if (!self::find_previous_config("table:", $subvalue) && !empty($subvalue)) { if (isset($value["@attributes"]["database_alias"]) && $value["@attributes"]["database_alias"] == $alias) { self::configure_database($subvalue); } } } } } foreach (self::get("form") as $value) { if (self::has_attribute($value, "name", true)) { FORM::translate($value["@attributes"]["name"], $value); } } foreach (self::get("project") as $value) { foreach ($value as $subkey => $subvalue) { if (self::startswith(strtolower($subkey), "include:") && self::has_attribute($subvalue, "file", true)) { $file = $subvalue["@attributes"]["file"]; if (file_exists(self::$projectdir . "/" . $file . ".php")) { include self::$projectdir . "/" . $file . ".php"; } } } } ACCOUNT::set_database_config(); REQUEST::init(); ACCOUNT::access(); if (ACCOUNT::redirect()) { header("Location: " . REQUEST::root() . "/" . REQUEST::redirect_uri()); } REQUEST::access(); }
<?php include_once 'config.php'; include_once 'lib/function.php'; include_once 'lib/mailaddrlib.php'; include_once 'lib/accountlib.php'; session_start(); $errormode = 0; isset($_SESSION['name']) ? $name = $_SESSION['name'] : ($name = ''); isset($_GET['sid']) ? $sid = h($_GET['sid']) : ($sid = ''); if ($name !== '' || $sid === '') { // header('Location:' . $CFG['HOMEPATH'] . '/index.php'); } $mail = new MailAddr(); $ac = new ACCOUNT(); $errormode = $ac->chkMailSid($sid); // 1: SID がDBにない // 2: 通常ユーザとして登録済 // 3: SIDの登録日が $CFG['LIMITDATE'] より古い // 4: メールアドレス認証未認証 if ($errormode === 1 || $errormode === 2) { header('Location:' . $CFG['HOMEPATH'] . '/index.php'); } else { if ($errormode === 3) { $ac->delAccountSid($sid); } } // チェックして問題なかったので、SID を有効化 if ($errormode === 4) { $ac->AuthMailAddr($sid); }
} else { $pass_er = 0; } } } // 名前入力チェック isset($_POST['sei']) ? $sei = h($_POST['sei']) : ($sei = ''); isset($_POST['mei']) ? $mei = h($_POST['mei']) : ($mei = ''); if ($sei === '' || $mei === '') { $errormode = 1; $name_er = 1; } // アカウト登録処理 if ($mode === 'submit' && $errormode === 0) { // アカウント登録 $ac = new ACCOUNT(); $ac->addAccount($accountname, $pwd1, $sei, $mei, $email, $sid); $name = $sei . ' ' . $mei; // 確認メールの送信 $mailsend = new MailAddr(); $mailsend->chkAddrMailSend($email, $name, $sid); $mode = 'addaccount'; $_SESSION['account'] = $email; $_SESSION['name'] = $sei . " " . $mei . "(仮)"; $_SESSION['level'] = '0'; } } ?> <!DOCTYPE html> <html lang="ja"> <head>
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; } } } } }
include_once 'config.php'; include_once 'lib/function.php'; include_once 'lib/accountlib.php'; session_start(); $errormode = 0; // ログイン処理 if (isset($_POST['mode']) && $_POST['mode'] === 'login') { if (!isset($_POST['accountname']) || !isset($_POST['password'])) { $errormode = 1; } // エラーなしなのでログインチャレンジ if ($errormode == 0) { $accountname = h($_POST['accountname']); $password = h($_POST['password']); $ac = new ACCOUNT(); $userdata = $ac->Login($accountname, $password); } // ログインの確認 if ($userdata !== FALSE) { $_SESSION['accountname'] = $accountname; $_SESSION['name'] = h($userdata['sei'] . " " . $userdata['mei']); $_SESSION['level'] = h($userdata['level']); } else { $_SESSION['accountname'] = ''; $_SESSION['name'] = ''; $_SESSION['level'] = ''; $errormode = 2; } } // ログインに成功すれば最初のページへ