TOOL更新_ユーザ側ログインチェックを作った。
TOOL更新_ユーザ側ログインチェックを作った。プログラム(赤色)を載せておくことにする。
│
├─.kazphp
│ │
│ ├─application
│ │ ├─admin
│ │ ├─com
│ │ ├─default
│ │ ErrorController.php
│ │ Index1Controller.php
│ │ IndexController.php
│ ├─common
│ ├─log
│ ├─templates
│ │ └─view
│ │ │ analytics.lbi
│ │ │ err.html
│ │ │ footer.lbi
│ │ │ header.lbi
│ │ │ index.html
│ │ │ index1.html
│ │ │ menu.lbi
│ │ │ pagetop.lbi
│ │ │
│ │ ├─admin
│ │ │
│ └─upload
├─.php
│ ├─Pager
│ ├─smarty
│ └─ZendFramework-1.10.7
└─kaz
│ .htaccess
│ userIndex.php
│
├─admin
├─css
├─img
│ ├─btn
│ └─lightbox
├─js
└─upload
■IndexController.php ログイン画面
・クラス図
これは管理者側と同じです。(http://d.hatena.ne.jp/kazpgm/20100819/1282234084)
・PGMソース
<?php // ============================================================= // 2010 kaz PHP自動作成お助けTOOL.(http://kazpgm.ddo.jp/) Start // 修正BSDライセンス。 // ============================================================= // DBマネージャを使用するプログラム用Controller基底クラス。 require_once 'ControllerDbBase.php'; // DBマネージャを使用するプログラムController実装クラス class IndexController extends ControllerDbBase { protected function _commActSub() { // 親クラスでabstractメソッドにしてある。親クラスの_commAct()から呼ばれる。 $this->_mode = strtolower($this->_o['mode']); $this->_modeBk = $this->_mode; if ($this->_mode != 'login_do') { // 権限セッションを全て解除する Zend_Session::destroy(); } switch($this->_mode) { case 'login': // 一覧 break; case 'login_do': // ログインの実行 $conditions = $this->_editWhere(); $condstm = $conditions[AppConst::STM]; // ステートメント $valary = $conditions[AppConst::VAL_ARY]; // 値の配列 if ('' != $condstm) { $condstm = "WHERE ". $condstm; } $sql = <<<__SQL__ SELECT u.* FROM m_user u $condstm __SQL__; $result = $this->_db->getAll($sql, $valary); //入力されたログイン情報が正しいかチェック。 if(empty($result)){ $this->_err = array( 'login' => 'ログインIDまたはパスワードが正しくありません。' ); } if($this->_err) { // エラーあり // 入力フォームを表示するmodeにする $this->_mode = 'login'; } break; default: $this->_mode = 'login'; } switch($this->_mode) { case 'login':// 登録 break; case 'login_do': // ログイン実行 $this->_sess['u_login_id_login'] = $result[0]['u_login_id']; $this->_sessObj->array = $this->_sess; $this->_redirect('index1'); break; default: echo 'Unknown mode. (mode=' . $this->_mode . ')'; exit; } // DB commit $this->_dbCommit(); // HTML出力 $this->_outHtml(); } // 検索条件設定 protected function _editWhere() { // 親クラスでabstractメソッドにしてある $condstm = ''; // ステートメント $condvalary = array(); // 値の配列 $conditions = array(); // SQL条件文設定 $condstm .= " u.u_login_id = ? "; // 会員番号 $condvalary[] = $this->_o['loginid']; $condstm .= " AND u.u_pwd1 = ? "; // パスワード $condvalary[] = $this->_o['loginpwd']; $condstm .= " AND u.u_yuko_flg = '2' "; // 有効 $conditions[AppConst::STM] = $condstm; // ステートメント $conditions[AppConst::VAL_ARY] = $condvalary; // 値の配列 return $conditions; } // HTML出力 protected function _outHtml() { // 親クラスでabstractメソッドにしてある $this->_o['c_elements_idx'] = '0'; // viewログ出力 $this->_outViewLog($this->_o, $this->_err, $this->_result); $smarty = Zend_Registry::get('smarty'); $smarty->assign('o', $this->_o); $smarty->assign('err', $this->_err ); $smarty->assign('sess', $this->_sess ); $smarty->display('view/' . $this->_getFolderName() . 'index.html'); } // viewに使用するフォルダ名 // 例 return 'logininfo'; protected function _getFolderName() { return ''; } } // ============================================================= // 2010 kaz PHP自動作成お助けTOOL.(http://kazpgm.ddo.jp/) End // 修正BSDライセンス。 // =============================================================
■Index1Controller.php メニュー画面
・クラス図
これは管理者側と同じです。(http://d.hatena.ne.jp/kazpgm/20100819/1282234084)
・PGMソース
<?php // ============================================================= // 2010 kaz PHP自動作成お助けTOOL.(http://kazpgm.ddo.jp/) Start // 修正BSDライセンス。 // ============================================================= // DBマネージャを使わないもの用Controller基底クラス。 require_once 'ControllerBase.php'; // DBマネージャを使わないものController実装クラス class Index1Controller extends ControllerBase { // 各アクション共通の前処理 public function preDispatch() { // 親クラスの各アクション共通の前処理 parent::preDispatch(); } protected function _commActSub() { // 親クラスでabstractメソッドにしてある。親クラスの_commAct()から呼ばれる。 // HTML出力 $this->_outHtml(); } // HTML出力 protected function _outHtml() { // 親クラスでabstractメソッドにしてある $this->_o['c_elements_idx'] = '0'; // viewログ出力 $this->_outViewLog($this->_o, $this->_err, $this->_result); $smarty = Zend_Registry::get('smarty'); $smarty->assign('o', $this->_o); $smarty->assign('err', $this->_err ); $smarty->assign('sess', $this->_sess ); $smarty->display('view/' . $this->_getFolderName() . 'index1.html'); } // viewに使用するフォルダ名 // 例 return 'logininfo'; protected function _getFolderName() { return ''; } } // ============================================================= // 2010 kaz PHP自動作成お助けTOOL.(http://kazpgm.ddo.jp/) End // 修正BSDライセンス。 // =============================================================
■analytics.lbi ここにGogle Analyticsを載せる。ディフォルトは空白。
■footer.lbi コピーライト。
<div id="footer"> <p>Copyright (c) 2010 kaz PHP自動作成お助けTOOL. All rights reserved.</p> </div>
■header.lbi カレンダーのjavascript
<script type="text/javascript" src="/kaz01u/js/jkl-calendar_20090707u.js" charset="SHIFT-JIS"></script>
■index.html ユーザ側ログイン画面のSmartyTemplate
{{* // ============================================================================ // Copyright (c) 2010 kaz PHP自動作成お助けTOOL. All rights reserved. // ============================================================================ // index 画面 *}} <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="UTF-8"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>kaz PHP自動作成お助けTOOL サイト管理システム</title> <link rel="stylesheet" href="/samples/kazBase/kaz/css/screen.css" type="text/css" media="screen,print" /> <style type="text/css"> .input{ width: 120px; } </style> </head> <body onload="document.frm.loginid.focus()"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="64" valign="top"> <!-- #BeginLibraryItem "/Library/header.lbi" --> {{include file='view/header.lbi'}} <!-- #EndLibraryItem --> </td> </tr> <tr> <td><form name="frm" method="POST" action="index"> <input type="text" name="dummy" style="display:none;" /> <input type="hidden" name="mode" value="login_do"> <table width="379" border="0" cellspacing="0" cellpadding="0"> <tr> <table width="348" border="0" cellspacing="0" cellpadding="5"> <tr> <td colspan="2" class="fs10">※ID、パスワードを入力後、「ログイン」ボタンを押してください。</td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td>ID</td> <td><input name="loginid" type="text" id="loginid" maxlength="50" class="input"></td> </tr> <tr> <td>パスワード</td> <td><input name="loginpwd" type="password" id="loginpwd" maxlength="10" class="input"></td> </tr> <tr> <td colspan="2">{{$err.login}}</td> </tr> </table> <br> </td> <td><table border="0" cellspacing="0" cellpadding="5"> <tr> <td><a href="javascript:document.frm.submit();">ログイン</a></td> </tr> <tr> <td><a href="javascript:document.frm.reset();">キャンセル</a></td> </tr> </table></td> </tr> </table> </tr> </table> </form></td> </tr> <tr> <td height="64" valign="bottom"> <!-- #BeginLibraryItem "/Library/pagetop.lbi" --> {{include file='view/pagetop.lbi'}} <!-- #EndLibraryItem --> </td> </tr> </table> {{include file='view/analytics.lbi'}} </body> </html>
■index1.html ログイン画面のSmartyTemplate
{{* // ============================================================================ // Copyright (c) 2010 kaz PHP自動作成お助けTOOL. All rights reserved. // ============================================================================ *}} <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <title>kaz PHP自動作成お助けTOOL サイト管理システム</title> <link rel="stylesheet" href="/samples/kazBase/kaz/css/screen.css" type="text/css" media="screen,print" /> </head> <body> <!-- wrapper start --> <div id="wrapper"> <!-- #BeginLibraryItem "/Library/header.lbi" --> {{include file='view/header.lbi'}} <!-- #EndLibraryItem --> <!-- contents start --> <div id="contents"> <!-- #BeginLibraryItem "/Library/menu.lbi" --> {{include file='view/menu.lbi'}} <!-- #EndLibraryItem --><br> <p class="clear"></p> </div> <!-- contents end --> <!-- #BeginLibraryItem "/Library/footer.lbi" --> {{include file='view/footer.lbi'}} <!-- #EndLibraryItem --> </div> <!-- wrapper end --> {{include file='view/analytics.lbi'}} </body> </html>
■menu.lbi メニューのSmartyTemplate
<!-- menu start --> <div id="side"> {{if '' != $sess.u_login_id_login}} <!-- menu-top start --> <div id="menu-top" style="background-color:#E6E6E6; border:solid 1px #E6E6E6;"><a href="/samples/kazBase/kaz/index"><img src="/samples/kazBase/kaz/img/botton_logout.gif" alt="LOG OUT" width="59" height="14" border="0" /></a></div> <!-- menu-top end --> {{else}} <!-- menu-top start --> <div id="menu-top" style="background-color:#E6E6E6; border:solid 1px #E6E6E6;"><a href="/samples/kazBase/kaz/index"><img src="/samples/kazBase/kaz/img/botton_login.gif" alt="LOG IN" width="78" height="45" border="0" /></a></div> <!-- menu-top end --> {{/if}} <!-- menu buhin user --> <div class="menu-news"> <p>企業情報管理</p> </div> <ul class="menu"> <li><a href="/samples/kazBase/kaz/corp/corpudd/ins">企業情報登録</a></li> {{if (( '' == $sess.u_login_id_login) && ( $sess.login_type != '1' && $sess.login_type != '2' && $sess.login_type != '3')) }} <li><a href="/samples/kazBase/kaz/corp/corpu/list" disabled >企業情報一覧</a></li> {{else}} <li><a href="/samples/kazBase/kaz/corp/corpu/list">企業情報一覧</a></li> {{/if}} <li><a href="/samples/kazBase/kaz/corp/corpu/list_new">企業情報登録日時降順</a></li> </ul><!-- menu buhin user --> <div class="menu-news"> <p>使用できる項目管理</p> </div> <ul class="menu"> <li><a href="/samples/kazBase/kaz/item/itemuadd/ins">使用できる項目登録</a></li> {{if (( '' == $sess.u_login_id_login) && ( $sess.login_type != '1' && $sess.login_type != '2' && $sess.login_type != '3')) }} <li><a href="/samples/kazBase/kaz/item/itemu/list" disabled >使用できる項目一覧</a></li> {{else}} <li><a href="/samples/kazBase/kaz/item/itemu/list">使用できる項目一覧</a></li> {{/if}} <li><a href="/samples/kazBase/kaz/item/itemu/list_new">使用できる項目登録日時降順</a></li> </ul><!-- menu buhin user1 --> <div class="menu-news"> <p>お問い合わせ管理</p> </div> <ul class="menu"> <li><a href="/samples/kazBase/kaz/contact/inquadd/ins">お問い合わせ登録</a></li> </ul> </div>
■pagetop.lbi 予備で入れてあるSmartyTemplate ディフォルトは空白。
補足:css、js、image画像はVectorに登録したものを参考にしてください。
■サイト:http://kazpgm.ddo.jp/の『5.次期バージョン開発中』にのせた。
10/6 21:00-4:30
2011/01/22 TOOL更新_Ver0.1Zd(次バージョン)のZendFramework-1.10.7のinclude_pathを『.php』フォルダに移動する。(http://d.hatena.ne.jp/kazpgm/20110122/1295697206)の内容を反映した。
<<修正前>> ├─.php │ └─smarty <<修正後>> ├─.php │ ├─Pager │ ├─smarty │ └─ZendFramework-1.10.7
2011/02/01 0:30-0:40 corpUaddをcorpuadd、corpUをcorpu、itemUaddをitemuadd、itemUをitemu、inqUaddをinquaddに修正した。これはhttp://d.hatena.ne.jp/kazpgm/20110131/1296487044による修正を反映したもの。