public function screen_regist($auth = "")
 {
     $btn = "";
     $btn2 = "";
     $this->file = "memberinfo_form.tpl";
     // デフォルト
     // フォーム要素のデフォルト値を設定
     $date_defaults = ['Y' => date('Y'), 'm' => date('m'), 'd' => date('d')];
     $this->form->setDefaults(['birthday' => $date_defaults]);
     $this->make_form_controle();
     // フォームの妥当性検証
     if (!$this->form->validate()) {
         $this->action = "form";
     }
     if ($this->action == "form") {
         $this->title = '新規登録画面';
         $this->next_type = 'regist';
         $this->next_action = 'confirm';
         $btn = '確認画面へ';
     } else {
         if ($this->action == "confirm") {
             $this->title = '確認画面';
             $this->next_type = 'regist';
             $this->next_action = 'complete';
             $this->form->freeze();
             $btn = '登録する';
             $btn2 = '戻る';
         } else {
             if ($this->action == "complete" && isset($_POST['submit2']) && $_POST['submit2'] == '戻る') {
                 $this->title = '新規登録画面';
                 $this->next_type = 'regist';
                 $this->next_action = 'confirm';
                 $btn = '確認画面へ';
             } else {
                 if ($this->action == "complete" && isset($_POST['submit']) && $_POST['submit'] == '登録する') {
                     // データベースを操作します。
                     $PrememberModel = new PrememberModel();
                     // データベースを操作します。
                     $MemberModel = new MemberModel();
                     $userdata = $this->form->getSubmitValues();
                     if ($MemberModel->check_username($userdata) || $PrememberModel->check_username($userdata)) {
                         $this->title = '新規登録画面';
                         $this->message = "メールアドレスは登録済みです。";
                         $this->next_type = 'regist';
                         $this->next_action = 'confirm';
                         $btn = '確認画面へ';
                     } else {
                         // システム側から利用するときに利用
                         if ($this->is_system && is_object($auth)) {
                             $userdata['password'] = $auth->get_hashed_password($userdata['password']);
                         } else {
                             $userdata['password'] = $this->auth->get_hashed_password($userdata['password']);
                         }
                         $userdata['birthday'] = sprintf("%04d%02d%02d", $userdata['birthday']['Y'], $userdata['birthday']['m'], $userdata['birthday']['d']);
                         if ($this->is_system) {
                             $MemberModel->regist_member($userdata);
                             $this->title = '登録完了画面';
                             $this->message = "登録を完了しました。";
                         } else {
                             $userdata['link_pass'] = hash('sha256', uniqid(rand(), 1));
                             $PrememberModel->regist_premember($userdata);
                             $this->mail_to_premember($userdata);
                             $this->title = 'メール送信完了画面';
                             $this->message = "登録されたメールアドレスへ確認のためのメールを送信しました。<BR>";
                             $this->message .= "メール本文に記載されているURLにアクセスして登録を完了してください。<BR>";
                         }
                         $this->file = "message.tpl";
                     }
                 }
             }
         }
     }
     $this->form->addElement('submit', 'submit', $btn);
     $this->form->addElement('submit', 'submit2', $btn2);
     $this->form->addElement('reset', 'reset', '取り消し');
     $this->view_display();
 }
Esempio n. 2
0
 public function screen_regist($auth = "")
 {
     $btn1 = "";
     $btn2 = "";
     $this->file = 'member_regist.tpl';
     $this->make_member_regist_form();
     $this->form->setDefaults(array('gender' => array('gender' => '1'), 'birthday' => array('Y' => 1980, 'm' => 1, 'd' => 1)));
     if (!(isset($_POST['submit1']) && $_POST['submit1'] == "登録")) {
         if (!$this->form->validate()) {
             $this->action = "form";
         }
     }
     if ($this->action == "form") {
         if ($this->is_system) {
             $this->title = "新規会員登録";
             $this->message = "--会員の情報を入力してください--";
         } else {
             $this->title = "簡単にサイトへの登録ができます!";
             $this->message = "--ご記入ください--";
         }
         $this->next_type = "regist";
         $this->next_action = "confirm";
         $btn1 = "確認";
         $btn2 = "";
     } else {
         if ($this->action == "confirm" && isset($_POST['submit1']) && $_POST['submit1'] == "確認") {
             $this->form->freeze();
             //入力値をセッションへ
             $_SESSION['memberdata'] = $this->form->getSubmitValues();
             $this->title = "<確認>";
             $this->message = "下記でよろしいですか?";
             $this->next_type = "regist";
             $this->next_action = "complete";
             $btn1 = "登録";
             $btn2 = "戻る";
         } else {
             if ($this->action == "complete" && isset($_POST['submit2']) && $_POST['submit2'] == "戻る") {
                 unset($_SESSION['memberdata']);
                 $this->title = "< 登録画面 >";
                 $this->next_type = "regist";
                 $this->next_action = "confirm";
                 $btn1 = "確認";
                 $btn2 = "";
             } else {
                 if ($this->action == "complete" && isset($_POST['submit1']) && $_POST['submit1'] == "登録") {
                     $PrememberModel = new PrememberModel();
                     $MemberModel = new MemberModel();
                     $memberdata = $_SESSION['memberdata'];
                     if ($MemberModel->check_member($memberdata) || $PrememberModel->check_member($memberdata)) {
                         $this->title = "登録画面";
                         $this->message = "!!!すでにこのメールアドレスは登録されています!!!";
                         $this->next_type = "regist";
                         $this->next_action = "confirm";
                         $btn1 = "確認";
                         $btn2 = "";
                     } else {
                         $memberdata['birthday'] = sprintf("%04d%02d%02d", $memberdata['birthday']['Y'], $memberdata['birthday']['m'], $memberdata['birthday']['d']);
                         $memberdata['gender'] = sprintf("%1d", $memberdata['gender']['gender']);
                         if ($this->is_system && is_object($auth)) {
                             $memberdata['password'] = $auth->get_hash_password($memberdata['password']);
                         } else {
                             $memberdata['password'] = $this->auth->get_hash_password($memberdata['password']);
                         }
                         if ($this->is_system) {
                             $this->title = "基本情報の入力完了";
                             $this->message = "次に追加の情報の登録に移行します";
                             $this->next_type = "regist_add";
                             $this->next_action = "form";
                             $btn1 = "OK";
                             $this->file = "message_submit.tpl";
                         } else {
                             $memberdata['link_pass'] = hash('sha256', uniqid(rand(), 1));
                             $PrememberModel->regist_premember($memberdata);
                             $this->mail_to_premember($memberdata);
                             $this->title = "仮登録完了";
                             $this->message = $memberdata['last_name'] . "さん、ご入力ありがとうございます。<br><br>";
                             $this->message .= "登録されたメールアドレスに確認のためメールをお送りました。<br><br>";
                             $this->message .= "メール本文のURL(12時間有効)より<br><br>";
                             $this->message .= "登録を完了させてください。<br><br>";
                             $this->file = "message.tpl";
                         }
                     }
                 }
             }
         }
     }
     $this->form->addElement('submit', 'submit1', $btn1);
     $this->form->addElement('submit', 'submit2', $btn2);
     $this->form->addElement('reset', 'reset', 'リセット');
     $this->view_display();
 }