Beispiel #1
0
 function main()
 {
     // Quickform2インスタンス作成
     $form = new HTML_Quickform2('qform_smarty', 'POST', array('action' => 'index.php'));
     // Form要素の構築
     $uname = $form->addElement('text', 'uname', array('style' => 'width: 100px;'), array('label' => "ユーザID:"));
     $upass = $form->addElement('password', 'upass', array('style' => 'width: 100px;'), array('label' => "パスワード:"));
     $button = $form->addElement('submit', 'send', array('value' => "ログイン"));
     // パラメータのルールを設定
     $uname->addRule('required', USERIDEMPTY);
     $upass->addRule('required', PASSEMPTY);
     $uname->addRule('regex', USERIDERR, '/^[ -~]+$/');
     // フィルタの設定
     // name に htmlspecialchars関数を適用する
     $uname->addFilter('htmlspecialchars');
     // 全要素にtrim関数を適用する
     $form->addRecursiveFilter('trim');
     // フォームの出力or入力後処理
     if ($form->validate()) {
         // ユーザIDとパスワードが両方入力されたとき
         if (isset($_POST[P_USERID]) && isset($_POST[P_USERPASS])) {
             // user.phpの読み込み
             require_once LIBPATH . 'user.php';
             // UserOperationインスタンスの作成
             $usr_ins = new UserOperation();
             // ログイン判定・ユーザ情報の取得
             $res = $usr_ins->userlogin($_POST[P_USERID], $_POST[P_USERPASS]);
             // データの取得に成功した場合
             if ($res[RESFLAG] == TRUE) {
                 // データベース切断
                 $usr_ins->dbend();
                 // セッションに値がない場合
                 if (empty($_SESSION[USER_ID])) {
                     // セッション作成
                     $_SESSION[USER_ID] = $res[RESDATA]['user_c'];
                 }
                 // SESSIONにユーザIDがあれば、アドレス帳一覧ページに移動
                 if (!empty($_SESSION[USER_ID])) {
                     // アドレス帳一覧ページに移動
                     $this->_redirect(DEFAULT_MODULE);
                 }
                 // データの取得に失敗したとき
             } else {
                 echo "<span style=\"color:#FF0000\">" . LOGINERR . "</span>";
                 // データベース切断
                 $usr_ins->dbend();
             }
             $this->createForm($form);
         }
     } else {
         $this->createForm($form);
     }
 }
Beispiel #2
0
 function main()
 {
     // QuickForm2インスタンス作成
     $form = new HTML_Quickform2('qform_smarty', 'POST', array('action' => 'index.php?module=search'));
     // Form要素の構築
     // text 要素を追加
     $search = $form->addElement('text', 'search', array('style' => 'width: 100px;'), array('label' => "検索:"));
     if ($_GET[ADDSEARCH] != "") {
         $search->setValue($_GET[ADDSEARCH]);
     }
     // ボタンのグループを作成・追加
     $buttonGroup = $form->addElement('group', 'buttons');
     $buttonGroup->addElement('submit', 'send', array('value' => "検索"));
     // フィルタの設定
     // name に htmlspecialchars関数を適用する
     $search->addFilter('htmlspecialchars');
     // 全要素にtrim関数を適用する
     $form->addRecursiveFilter('trim');
     // フォームの出力or入力後処理
     if ($form->validate()) {
         // AddressOperationインスタンスの作成
         $obj = new AddressOperation();
         // 検索
         $data = $obj->searchAddress($search->getValue());
         // データを取得できたか
         if ($data[RESFLAG] == TRUE) {
             if (count($data[RESDATA]) != 0) {
                 foreach ($data[1] as $num => $value) {
                     $add_data[$num] = array('id' => $value[id], 'name_c' => $value[name_c]);
                 }
                 // フォームと取得したデータを作成
                 $this->createForm($form, $add_data);
             } else {
                 $this->createForm($form);
             }
         } else {
             $this->createForm($form);
         }
         // データベース接続を解除
         $obj->dbend();
     } else {
         $this->createForm($form);
     }
 }
 function main()
 {
     // idの取得
     $id = $_GET[ID];
     // インスタンスの作成
     $form = new HTML_Quickform2('qform_smarty', 'POST', array('action' => 'index.php?module=address_setting'));
     // Form要素の構築
     // hidden 要素を追加
     $id_form = $form->addElement('hidden', 'action');
     // text 要素を追加
     $name_c = $form->addElement('text', 'name_c', array('style' => 'width: 200px;'), array('label' => "名前:"));
     $readname_c = $form->addElement('text', 'readname_c', array('style' => 'width: 200px;'), array('label' => "ふりがな:"));
     $tel_c = $form->addElement('text', 'tel_c', array('style' => 'width: 200px;'), array('label' => "電話番号:"));
     $tel_sub_c = $form->addElement('text', 'tel_sub_c', array('style' => 'width: 200px;'), array('label' => "電話番号(サブ):"));
     $mail_c = $form->addElement('text', 'mail_c', array('style' => 'width: 200px;'), array('label' => "メールアドレス:"));
     $mail_sub_c = $form->addElement('text', 'mail_sub_c', array('style' => 'width: 200px;'), array('label' => "メールアドレス(サブ):"));
     $postcode_c = $form->addElement('text', 'postcode_c', array('style' => 'width: 100px;'), array('label' => "郵便番号:"));
     $add_c = $form->addElement('text', 'add_c', array('style' => 'width: 300px;'), array('label' => "住所:"));
     $building_c = $form->addElement('text', 'building_c', array('style' => 'width: 300px;'), array('label' => "建物名:"));
     $fb_c = $form->addElement('text', 'fb_c', array('style' => 'width: 200px;'), array('label' => "facebookアカウント:"));
     // ボタンのグループを作成・追加
     $buttonGroup = $form->addElement('group', 'buttons');
     $buttonGroup->addElement('submit', 'send', array('value' => "登録"));
     $buttonGroup->addElement('reset', 'reset', array('value' => "キャンセル"));
     // AddressOperationインスタンスの作成
     $obj = new AddressOperation();
     // idがある場合、初期値を取得
     if (!empty($id)) {
         $res = $obj->getAdddetail($id);
         if ($res[RESFLAG] == TRUE) {
             // アドレス詳細情報
             $add_data = array('name_c' => $res[RESDATA]['name_c'], 'readname_c' => $res[RESDATA]['readname_c'], 'tel_c' => $res[RESDATA]['tel_c'], 'tel_sub_c' => $res[RESDATA]['tel_sub_c'], 'mail_c' => $res[RESDATA]['mail_c'], 'mail_sub_c' => $res[RESDATA]['mail_sub_c'], 'postcode_c' => $res[RESDATA]['postcode_c'], 'add_c' => $res[RESDATA]['add_c'], 'building_c' => $res[RESDATA]['building_c'], 'fb_c' => $res[RESDATA]['fb_c']);
             // 初期値を代入
             $id_form->setValue($id);
             if (!empty($add_data['name_c'])) {
                 $name_c->setValue($add_data['name_c']);
             }
             if (!empty($add_data['readname_c'])) {
                 $readname_c->setValue($add_data['readname_c']);
             }
             if (!empty($add_data['tel_c'])) {
                 $tel_c->setValue($add_data['tel_c']);
             }
             if (!empty($add_data['tel_sub_c'])) {
                 $tel_sub_c->setValue($add_data['tel_sub_c']);
             }
             if (!empty($add_data['mail_c'])) {
                 $mail_c->setValue($add_data['mail_c']);
             }
             if (!empty($add_data['mail_sub_c'])) {
                 $mail_sub_c->setValue($add_data['mail_sub_c']);
             }
             if (!empty($add_data['postcode_c'])) {
                 $postcode_c->setValue($add_data['postcode_c']);
             }
             if (!empty($add_data['add_c'])) {
                 $add_c->setValue($add_data['add_c']);
             }
             if (!empty($add_data['building_c'])) {
                 $building_c->setValue($add_data['building_c']);
             }
             if ($add_data['fb_c'] != "") {
                 $fb_c->setValue($add_data['fb_c']);
             }
         }
         // テンプレートにタイトルを割り当て
         $this->smarty->assign('title', "アドレス帳 ~アドレス編集画面~");
         $this->smarty->assign('h1', "アドレス編集");
         $this->smarty->assign('id', $id);
         // データベース接続を解除
         $obj->dbend();
     } else {
         // テンプレートにタイトルを割り当て
         $this->smarty->assign('title', "アドレス帳 ~アドレス登録画面~");
         $this->smarty->assign('h1', "アドレス登録");
     }
     // パラメータのルールを設定
     // 値が空かチェック
     $name_c->addRule('required', NAMEEMPTY);
     $readname_c->addRule('required', READNAMEEMPTY);
     // 値が正しいかチェック
     $tel_c->addRule('regex', TELREGEX, '/^[0-9]+$/');
     $tel_sub_c->addRule('regex', TELSUBREGEX, '/^[0-9]+$/');
     $postcode_c->addRule('regex', POSTREGEX, '/^[0-9]+$/');
     $mail_c->addRule('regex', MAILREGEX, '/^[ -~]+$/');
     $mail_sub_c->addRule('regex', MAILSUBREGEX, '/^[ -~]+$/');
     $fb_c->addRule('regex', FBAREGEX, '/^[ -~]+$/');
     // 長さチェック
     $name_c->addRule('maxlength', NAMEMAX, 125);
     $readname_c->addRule('maxlength', READNAMEMAX, 255);
     $tel_c->addRule('maxlength', TELMAX, 11);
     $tel_sub_c->addRule('maxlength', TELSUBMAX, 11);
     $mail_c->addRule('maxlength', MAILMAX, 255);
     $mail_sub_c->addRule('maxlength', MAILSUBMAX, 255);
     $postcode_c->addRule('maxlength', POSTMAX, 7);
     $name_c->addRule('maxlength', FBAMAX, 100);
     // フィルタの設定
     $name_c->addFilter('htmlspecialchars');
     $readname_c->addFilter('htmlspecialchars');
     $mail_c->addFilter('htmlspecialchars');
     $mail_sub_c->addFilter('htmlspecialchars');
     $add_c->addFilter('htmlspecialchars');
     $building_c->addFilter('htmlspecialchars');
     $fb_c->addFilter('htmlspecialchars');
     // 全要素にtrim関数を適用する
     $form->addRecursiveFilter('trim');
     // フォームの出力or入力後処理
     if ($form->validate()) {
         if ($id_form->getValue() == "") {
             $ares = $obj->addressInsert($name_c->getValue(), $readname_c->getValue(), $tel_c->getValue(), $tel_sub_c->getValue(), $mail_c->getValue(), $mail_sub_c->getValue(), $postcode_c->getValue(), $add_c->getValue(), $building_c->getValue(), $fb_c->getValue());
             // Insertできたか
             if ($ares[RESFLAG] == TRUE) {
                 echo ADDINSERTOK;
                 // 連続投稿禁止用フラグ
                 $this->smarty->assign('insertflag', TRUE);
             } else {
                 echo "<span style=\"color:#FF0000\">" . ADDINSERTNG . "</span>";
             }
         } else {
             $ares = $obj->addressUpdate($id_form->getValue(), $name_c->getValue(), $readname_c->getValue(), $tel_c->getValue(), $tel_sub_c->getValue(), $mail_c->getValue(), $mail_sub_c->getValue(), $postcode_c->getValue(), $add_c->getValue(), $building_c->getValue(), $fb_c->getValue());
             // Updateできたか
             if ($ares[RESFLAG] == TRUE) {
                 $this->smarty->assign('id', $id_form->getValue());
                 echo ADDUPDATEOK;
             } else {
                 $this->smarty->assign('id', $id_form->getValue());
                 echo "<span style=\"color:#FF0000\">" . ADDUPDATENG . "</span>";
             }
         }
         $this->createForm($form);
     } else {
         $this->createForm($form);
     }
     // データベース接続を解除
     $obj->dbend();
 }
 function main()
 {
     // Quickform2インスタンス作成
     $form = new HTML_Quickform2('qform_smarty', 'POST', array('action' => 'index.php?module=user_setting'));
     // ユーザDBインスタンス作成
     $obj = new UserOperation();
     // 登録済みユーザ名取得;
     // DBにユーザ名があるかチェック
     $uchk = $obj->userCheck($_SESSION[USER_ID]);
     if ($uchk[RESFLAG] == FALSE) {
         echo USERCOMPARE;
         // データベース接続を解除
         $obj->dbend();
         $userflag = FALSE;
         $this->smarty->assign('userflag', $userflag);
         $this->smarty->display('user_setting.html');
         exit;
     } else {
         $userflag = TRUE;
     }
     // Form要素の構築
     // text 要素を追加
     $name = $form->addElement('text', 'name', array('style' => 'width: 150px;'), array('label' => "名前:"));
     // 入力値がない場合、初期値を設定
     if ($name->getValue() == "") {
         $name->setValue($_SESSION[USER_ID]);
     }
     // password 要素を追加
     $pass_sim = $form->addElement('password', 'pass_sim', array('style' => 'width: 150px;'), array('label' => "現在のパスワード:"));
     $pass = $form->addElement('password', 'pass', array('style' => 'width: 150px;'), array('label' => "新規パスワード:"));
     $pass_conf = $form->addElement('password', 'pass_conf', array('style' => 'width: 150px;'), array('label' => "パスワードの確認:"));
     // ボタンのグループを作成・追加
     $buttonGroup = $form->addElement('group', 'buttons');
     $buttonGroup->addElement('submit', 'send', array('value' => "登録"));
     $buttonGroup->addElement('reset', 'reset', array('value' => "リセット"));
     // パラメータのルールを設定
     // 値が空かチェック
     $name->addRule('required', NAMEEMPTY);
     $pass_sim->addRule('required', PASSSIMEMPTY);
     $pass->addRule('required', PASSNEWEMPTY);
     $pass_conf->addRule('required', PASSCONFEMPTY);
     // パスワードが不正でないか(半角英数かどうか)チェック
     $pass->addRule('regex', PASSREGEX, '/^[ -~]+$/');
     // 長さチェック
     $name->addRule('length', NAMELENGTH, array(4, 16));
     $pass->addRule('length', PASSLENGTH, array(4, 16));
     // 2つの値が同じかどうかチェック
     $pass->addRule('compare', PASSNEWCOMPARE, array('operator' => '==', 'operand' => $pass_conf));
     // フィルタの設定
     // name に htmlspecialchars関数を適用する
     $name->addFilter('htmlspecialchars');
     // 全要素にtrim関数を適用する
     $form->addRecursiveFilter('trim');
     // フォームの出力or入力後処理
     if ($form->validate()) {
         // 既存のパスワード確認処理
         $passc = $obj->passCheck($pass_sim->getValue());
         if ($passc[RESFLAG] == TRUE) {
             // ユーザ情報更新
             $update = $obj->userUpdate($name->getValue(), $pass->getValue(), $_SESSION[USER_ID]);
             if ($update[RESFLAG] == TRUE) {
                 // sessionに新規ユーザIDを代入
                 $_SESSION[USER_ID] = $name->getValue();
                 echo USERUPDATEOK;
             } else {
                 echo "<span style=\"color:#FF0000\">" . USERUPDATENG . "</span>";
             }
         } else {
             echo "<span style=\"color:#FF0000\">" . PASSSIMCOMPARE . "</span>";
         }
         $this->createForm($form, $userflag);
     } else {
         $this->createForm($form, $userflag);
     }
     // データベース接続を解除
     $obj->dbend();
 }