부트스트랩 기반으로 회원관리 테이블을 작성중이다.
PDO 기반으로 Class 함수를 만드느라고 시행착오를 겪어가면서 수정 보완하면서 만들고 있다.
=== admin.php ===
<?php include_once '_common.php';?> <!DOCTYPE html> <html lang="en"> <head> <?php require_once $g['path_layout'] . 'default/includes/_import.head.php'; ?> </head> <body> <?php require_once $g['path_layout'] . 'default/includes/header.php'; ?>
<!-- 메인 화면 --> <main class="container-fluid"> <div class="container main-container"> <!-- body 화면 --> <div class="row"> <div class="col-md-12"> <div class="panel panel-default"> <div class="panel-body" id="panel_content"> <?php require_once $g['path_module'] . 'admin/adminMenu.php';?> </div> </div> </div> </div> </div> </main> <div id="ajaxPath" data-path="<?php echo $g['path_page'] . 'process/'; ?>" ></div> <div id="dialog"></div> <div id="actionPath" data-path="<?php echo $g['path_module'] . 'admin/'; ?>" ></div> </body> </html> |
=== _import.head.php ===
<meta charset="UTF-8"> <meta name="robots" content="noindex,nofollow"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta http-equiv="cache-control" content="no-cache" /> <meta http-equiv="expires" content="0" /> <meta http-equiv="pragma" content="no-cache" /> <meta name="apple-mobile-web-app-capable" content="no" /> <meta name="apple-mobile-web-app-status-bar-style" content="black" /> <title><?=$_site['site_name'];?></title> <link rel="stylesheet" href="<?php echo $g['path_bootstrap']?>css/bootstrap.min.css" /> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" /> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <link rel="stylesheet" href="<?php echo $g['path_core']?>css/topmenu.css" /> <link rel="stylesheet" href="<?php echo $g['path_core']?>css/vertical-menu.css" /> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="<?php echo $g['path_bootstrap']?>js/bootstrap.min.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script src="<?php echo $g['path_core']?>js/jquery.tablednd.js"></script> <script src="<?php echo $g['path_core']?>js/user.js"></script> <script src="<?php echo $g['path_core']?>js/table_display.js"></script> <!--[if lt IE 9]> <!-- 5. 인터넷익스플로러 9버전 이하일 경우 html5가 인식될 수 있게 해주는 스크립트 --> <script src="<?php echo $g['path_bootstrap']?>js/respond.min.js"></script> |
=== header.php ===
<nav class="navbar navbar-default"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">메뉴</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="<?php echo $g['path_page'];?>index.php"> <?=isset($_bbs_info['bbs_name'])?$_bbs_info['bbs_name']:$_site['site_name']?> </a> </div> <div class="navbar-collapse collapse" id="navbar" > <ul class="nav navbar-nav"> <?php require_once $g['path_layout'].'menu/item_topmenu.php';?> </ul>
<ul class="nav navbar-nav navbar-right"> <?php if(isset($_SESSION['userID']) && !empty($_SESSION['userID'])):?> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><? echo $_SESSION['userNM'] ?> <b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="#" onclick="document.getElementById('logout-form').submit();">로그아웃</a></li> <li><a href="<?php echo $g['path_page'];?>member.php?m=info">정보수정</a></li> <?php if(isset($_SESSION['admin']) && $_SESSION['admin']==1):?> <li class="divider"></li> <li><a href="<?php echo $g['path_page']; ?>admin.php">관리자</a></li> <?php endif;?> </ul> </li> <?php else:?> <li><a href="#modal-login" data-toggle="modal" >로그인</a></li> <li><a href="<?php echo $g['path_page'];?>member.php?m=join">회원가입</a></li> <?php endif;?> </ul>
</div><!--/.nav-collapse --> <div> <?php include_once $g['path_layout'].'default/includes/login_modal.php'; ?> </div>
</div> </nav> |
=== memberList.php ===
<?php if (!isset($_SESSION)) { session_start(); } if(!isset($_SESSION['userID']) || empty($_SESSION['userID'])){ echo 0; exit; }
require_once $_SERVER['DOCUMENT_ROOT'].'/pdoclass/dbconfig.php'; $c = new LoginClass; $b = new boardClass; $link_url = $_SERVER['PHP_SELF']; // 현재 실행중인 파일명 가져오기 $page = isset($_GET['page'])? trim($_GET['page']):1;//페이지 변수 설정 $rowsPage = 10; // 한 화면에 표시되는 게시글 수 $curPage = isset($_GET['p']) ? $_GET['p'] : 1; $table = "members m join member_data d on m.idx=d.relatedidx"; $cat1 = isset($cat1) ? $cat1: ''; $cat2 = isset($cat2) ? $cat2: ''; $where = isset($_GET['where']) ? $_GET['where']: ''; $keyword = isset($_GET['keyword']) ? $_GET['keyword']: ''; $xorderby= isset($xorderby) ? $xorderby : 'idx DESC'; if($where && $keyword) { if($where == 'userNM') $sql = "userNM LIKE '%".$keyword."%' "; if($where == 'userID') $sql = "userID LIKE '%".$keyword."%' "; if($where == 'mobileNO') $sql = "mobileNO LIKE '%".$keyword."%' "; if($where == 'unify') { $sql = "(userID LIKE '%".$keyword."%' OR userNM LIKE '%".$keyword."%' OR mobileNO LIKE '%".$keyword."%') "; } } else { $sql =''; } $g['url_link']=($where?'where='.$where.'&':'').($keyword?'keyword='.urlencode(stripslashes($keyword)).'&':'').($cat1?'cat1='.$cat1.'&':'').($cat2?'cat2='.$cat2.'&':''); $g['bbs_reset'] = $link_url;
$rows= $c->getDbArray($table,$sql,'*',$xorderby,$rowsPage,$curPage); $NUM = $c->getDbRows($table,$sql); // 전체 게시글 수 또는 검색된 게시글 수 $TPG = $b->getTotalPage($NUM,$rowsPage); // 전체페이지수 및 현재 페이지수 ?>
<div class="pull-left info"> <?php if( $keyword ):?><strong>"<?php echo $keyword?>"</strong> 검색결과 : <?php endif?> <?php echo number_format($NUM)?>개 (<?php echo $curPage;?>/<?php echo $TPG;?>페이지) </div> <table id="membertable" class="table table-bordred table-striped table-hover"> <thead> <th align="center" width="50"><strong>idx</strong></th> <th align="center"><strong>아이디</strong></th> <th align="center"><strong>성명</strong></th> <th align="center"><strong>휴대폰</strong></th> <th align="center"><strong>일반전화</strong></th> <th align="center"><strong>가입일</strong></th> <th align="center"><strong>접속일</strong></th> <th align="center"><strong>권한</strong></th> <th align="center"><strong>개인정보</strong></th> </thead> <tbody>
<?php foreach($rows as $R): $A = $c->getDbDataFromIdx('member_data','relatedidx',$R['idx'] ); ?> <tr id="<?php echo $R['idx']; ?>"> <td><?php echo $R['idx']; ?></td> <td><?php echo $R['userID']; ?></td> <td><?php echo $R['userNM']; ?></td> <td><?php echo $c->hyphen_telNo($R['mobileNO']); ?></td> <td><?php echo $c->hyphen_telNo($A['officeNO']); ?></td> <td><?php echo substr($R['regdate'], 0, 8); ?></td> <td><?php echo $R['curdate']; ?></td> <td><?php echo $R['admin'] == 1 ? '관리자' : ''; ?></td> <td><?php echo $A['smart'] == 1 ? '공개동의' : '비공개'; ?></td> </tr> <?php endforeach; ?> </tbody> </table> <div class='searchbox'> <form name="membersearchf" class="form-inline" action="<?php echo $link_url;?>"> <input type="hidden" name="orderby" value="<?php echo $xorderby;?>" /> <select name="where" class="form-control input-sm"> <option value="unify">통합</option> <option value="userNM">이름</option> <option value="userID">아이디</option> <option value="mobileNO">휴대폰</option> </select> <div class="input-group input-group-sm"> <input type="text" name="keyword" value="" class="form-control input-search" placeholder="검색어"> <span class="input-group-btn"> <button type="button" class="btn btn-default" onclick="this.form.where.value='userNM';this.form.keyword.value='',this.form.submit();" title="리셋"><i class="glyphicon glyphicon-repeat"></i></button> <button type="submit" class="btn btn-info" title="검색"><i class="glyphicon glyphicon-search"></i></button> </span> </div> </form> </div> <div class="pull-right info"> <a href="<?php echo $g['bbs_reset']?>" class="btn btn-default btn-sm pull-right">처음목록</a> </div> <?php $b->PageLinkView($link_url, $NUM, $rowsPage, $curPage, $g['url_link']); ?> |
관련 작성 함수
※ PDO 조건에 맞게 구현되지 못한 함수도 있고 구현한 함수도 있다. (SQL 인젝션 관점)
계속 시도를 하면서 방법을 찾을 생각이다.
// table 결과 조회 용도
public function getDbArray($table, $where, $flddata, $orderby, $rowsPage, $curPage) {
$sql = 'select ' . $flddata . ' from ' . $table . ($where ? ' where ' . $this -> getSqlFilter($where) : '') . ($orderby ? ' order by ' . $orderby : '') . ($rowsPage ? ' limit ' . (($curPage - 1) * $rowsPage) . ', ' . $rowsPage : '');
$stmt = $this -> db -> prepare($sql);
$stmt -> execute();
return $stmt;
}
// WhereArgs 조건에 일치하는 선택 DbData 가져오기
public function getDbDataFromIdx($table, $whereArgs, $idx) {
$sql = 'select * from ' . $table . ' where ' . $whereArgs . '=?';
$stmt = $this -> db -> prepare($sql);
$stmt -> execute(array($idx));
return $stmt -> fetch();
}
vertical-menu.css
/* Bootstrap 테이블 수정 */ .table > thead { background-color: #b3c6ff; } .table > thead > tr > th { text-align: center; } .table-hover > tbody > tr:hover { background-color: #e6ecff; } .table > tbody > tr > td { text-align: center; } .table > tbody > tr > #title { text-align: left; } div > #paging { text-align: center; }
/* make sidebar nav vertical */ @media (min-width: 768px) { .sidebar .sidebar-nav .navbar .navbar-collapse { padding: 0; max-height: none; } .sidebar .sidebar-nav .navbar ul { float: none; } .sidebar .sidebar-nav .navbar ul:not { display: block; } .sidebar .sidebar-nav .navbar li { float: none; display: block; } .sidebar .sidebar-nav .navbar li a { padding-top: 12px; padding-bottom: 12px; } } |
topmenu.css /* 로그인 폼 */ .modal-header { color:black !important; text-align: center; font-size: 30px; } .modal-footer { background-color: #f9f9f9; padding: 5px 5px 5px 5px; border-top: 0px; } /* 로그인 폼 End */
/* 서브메뉴 */ .dropdown-submenu{position:relative;} .dropdown-submenu>.dropdown-menu{ top:0; left:100%; margin-top:-6px; margin-left:-1px; -webkit-border-radius:0 6px 6px 6px; -moz-border-radius:0 6px 6px 6px; border-radius:0 6px 6px 6px; }
.dropdown-submenu>a:after{ display:block; content:" "; float:right; width:0; height:0; border-color:transparent; border-style:solid; border-width:5px 0 5px 5px; border-left-color:#cccccc; margin-top:5px; margin-right:-10px; } .dropdown-submenu:hover>a:after{ border-left-color:#555; } .dropdown-submenu.pull-left{float:none;} .dropdown-submenu.pull-left>.dropdown-menu{ left:-100%; margin-left:10px; -webkit-border-radius:6px 0 6px 6px; -moz-border-radius:6px 0 6px 6px; border-radius:6px 0 6px 6px; }
@media only screen and (max-width: 768px) { }
@media only screen and (min-width: 768px) { .dropdown-submenu:hover>.dropdown-menu { display: block; } }
|