TOOL更新_管理者側ログインチェックを作った。の続き。
TOOL更新_管理者側ログインチェックを作った。の続き。プログラム(赤色)を載せておくことにする。
│
├─.kazphp
│ ├─application
│ │ └─admin
│ │ └─default
│ │ Index1Controller.php
│ │ IndexController.php
│ ├─common
│ ├─log
│ ├─templates
│ │ └─view
│ │ └─admin
│ │ analytics.lbi
│ │ footer.lbi
│ │ header.lbi
│ │ index.html
│ │ index1.html
│ │ menu.lbi
│ └─upload
├─.php
│ ├─Pager
│ ├─smarty
│ └─ZendFramework-1.10.7
└─kaz
├─admin
│ │ .htaccess
│ │ adminIndex.php
│ ├─css
│ ├─img
│ │ ├─btn
│ │ ├─lightbox
│ │ └─picture
│ └─js
■IndexController.php ログイン画面
・画面イメージ
・クラス図
・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 l.* FROM m_logininfo l $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['loginid'] = $result[0]['loginid']; $this->_sess['login_type'] = $result[0]['login_type']; $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 .= " l.login_id = ? "; // ログインID $condvalary[] = $this->_o['loginid']; $condstm .= " AND l.pwd1 = ? "; // パスワード $condvalary[] = $this->_o['loginpwd']; $condstm .= " AND l.login_type IN ('1', '2', '3') "; // Super管理者、管理者 $condstm .= " AND l.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 'admin/'; } } // ============================================================= // 2010 kaz PHP自動作成お助けTOOL.(http://kazpgm.ddo.jp/) End // 修正BSDライセンス。 // =============================================================
■Index1Controller.php メニュー画面
・画面イメージ
・クラス図
・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(); // ログインチェック if( $this->_sess['login_type'] != '1' && $this->_sess['login_type'] != '2' && $this->_sess['login_type'] != '3'){ $this->_sess['req_url'] = $_SERVER["REQUEST_URI"]; $this->_sessObj->array = $this->_sess; $this->_redirect('index'); } } 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 'admin/'; } } // ============================================================= // 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 サイト管理システム名
<script type="text/javascript" src="/samples/kazBase/kaz/admin/js/kazOtasukeToolItemZoku.js"></script> <script type="text/javascript" src="/samples/kazBase/kaz/admin/js/jkl-calendar_20090707u.js" charset="SHIFT-JIS"></script> <div id="header"> <a href="/samples/kazBase/kaz/admin/index1"><div style="font-size: large; color:#FFFFFF; text-align: center;"><strong>kaz PHP自動作成お助けTOOL 管理システム</strong></div></a> <div id="r-navi"> <p><a href="/samples/kazBase/kaz/admin/"><img src="/samples/kazBase/kaz/admin/img/botton_logout.gif" alt="ログアウト" width="59" height="14" hspace="5" vspace="7" border="0"></a></p> </div> <p class="clear"></p> </div>
■index.html ログイン画面のSmartyTemplate
{{* // ============================================================================ // Copyright (c) 2010 kaz PHP自動作成お助けTOOL. All rights reserved. // ============================================================================ // index 画面 *}} <!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/admin/css/screen.css" type="text/css" media="screen,print" /> </head> <body> <!-- wrapper start --> <div id="wrapper"> <!-- #BeginLibraryItem "/Library/header.lbi" --> {{include file='view/admin/header.lbi'}} <!-- #EndLibraryItem --> <!-- contents start --> <div id="contents-top"> <form name="frm" method="POST" action="index"> <input type="text" name="dummy" style="display:none;" /> <input type="hidden" name="mode" value="login_do"> <!-- login start --> <div align="center"> <table width="379" border="1" cellspacing="0" cellpadding="7"> <tr><td> <!-- login-contents start --> <table width="348" border="0" cellspacing="0" cellpadding="5"> <tr> <td colspan="2">※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="10" class="form-eng" value="{{$o.loginid}}" /></td> </tr> <tr> <td>パスワード</td> <td><input name="loginpwd" type="password" id="loginpwd" maxlength="10" class="form-eng" /></td> </tr> <tr> <td colspan="2">{{$err.login}}</td> </tr> </table> <br> </td> <td><table border="0" cellspacing="0" cellpadding="0"> <tr> <td><p class="btn"><input type="image" src="/samples/kazBase/kaz/admin/img/botton_login.gif" alt="LOGIN" width="78" height="45" border="0" /></p></td> </tr> </table></td> </tr> </table> </td></tr> </table> </div> <!-- login end --> </form> </div> <!-- contents end --> <!-- #BeginLibraryItem "/Library/footer.lbi" --> {{include file='view/admin/footer.lbi'}} <!-- #EndLibraryItem --> </div> <!-- wrapper end --> {{include file='view/admin/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/admin/css/screen.css" type="text/css" media="screen,print" /> </head> <body> <!-- wrapper start --> <div id="wrapper"> <!-- #BeginLibraryItem "/Library/header.lbi" --> {{include file='view/admin/header.lbi'}} <!-- #EndLibraryItem --> <!-- contents start --> <div id="contents"> <!-- #BeginLibraryItem "/Library/menu.lbi" --> {{include file='view/admin/menu.lbi'}} <!-- #EndLibraryItem --><br> <p class="clear"></p> </div> <!-- contents end --> <!-- #BeginLibraryItem "/Library/footer.lbi" --> {{include file='view/admin/footer.lbi'}} <!-- #EndLibraryItem --> </div> <!-- wrapper end --> {{include file='view/admin/analytics.lbi'}} </body> </html>
■menu.lbi メニューのSmartyTemplate
<div id="side"> <!-- menu-top start --> <div id="menu-top"><a href="/samples/kazBase/kaz/admin/index1" class="btn-menu-top">管理者機能TOP</a></div> <!-- menu-top end --> {{if $sess.login_type == '1'}} <!-- menu buhin --> <div class="menu-news"> <p>ログイン情報管理</p> </div> <ul class="menu"> <li><a href="/samples/kazBase/kaz/admin/logininfo/logininfoa/ins?mode=ins">ログイン情報登録</a></li> <li><a href="/samples/kazBase/kaz/admin/logininfo/logininfoa/list?mode=list">ログイン情報一覧</a></li> </ul> {{/if}} <!-- menu buhin --> <div class="menu-news"> <p>使用できる項目管理</p> </div> <ul class="menu"> <li><a href="/samples/kazBase/kaz/admin/item/itema/ins?mode=ins">使用できる項目登録</a></li> <li><a href="/samples/kazBase/kaz/admin/item/itema/list?mode=list">使用できる項目一覧</a></li> </ul> <!-- menu buhin --> <div class="menu-news"> <p>初期データアップロード管理</p> </div> <!-- menu buhin --> <ul class="menu"> <li><a href="/samples/kazBase/kaz/admin/initupload/iuplogininfoacsv">ログイン情報アップロード</a></li> <li><a href="/samples/kazBase/kaz/admin/initupload/iupitemacsv">使用できる項目アップロード</a></li> </ul> </div>
補足:css、js、image画像はVectorに登録したものを参考にしてください。
8/19 0:30-1:30
10/6 4:00-4:10 ■index1.htmlとするところが■index.htmlとなっていたので修正した。■Index1Controller.phpとするところが■IIndex1Controller.phpとなっていたので修正した。・・・・ユーザ側ログインチェックのブログ(http://d.hatena.ne.jp/kazpgm/20101006/1286391269)を作っていて気づいた。
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:20-0:30 logininfoAをlogininfoa、itemAをitema、iUplogininfoCsvをiuplogininfoacsv、iUpitemACsvをiupitemacsvに修正した。これはhttp://d.hatena.ne.jp/kazpgm/20110131/1296487044による修正を反映したもの。