Web/PHP
config 파일 리스트 방식으로 생성
aucd29
2013. 9. 26. 21:44
<?php
include_once $_SERVER[DOCUMENT_ROOT].'/global.php';
include_once $_SERVER[DOCUMENT_ROOT].'/include/dbconn.php';
include_once $clsRoot.'/class.Common.php';
include_once $clsRoot."/class.FormControl.php";
?>
<html>
<head>
<title>지역 정보</title>
<meta name='author' content='interkorea'>
<meta name='keywords' content=''>
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='pragma' content='no-cache'>
<meta http-equiv='content-type' content='text/html; charset=euc-kr'>
<link rel='stylesheet' href='/include/css.css' type='text/css'>
<script language='javascript' src='/include/main.js'></script>
</head>
<body>
<?php
// ------------------------------------------------------------------------
// address data
// ------------------------------------------------------------------------
include "../../JsCode/CityCache.php";
?>
<table cellspacing='0' cellpadding='0' border='0' align='center'>
<!-- 지역검색 -->
<form method='post' name='frm_write' action='./area_process.php?psMode=WRITE' enctype='multipart/form-data' style='border:0;margin:0' onSubmit='return SoftCheck(this)'>
<tr>
<td>지역 선택하기 </td>
<td>
<select name='sCity' onchange='JavaScript:ChangeCat0(this.selectedIndex)' style='font-size:9pt;width:100' msg='시/도를 선택해주세요' required >
<option value=''> -시/도선택-
<?php
// 특정지역을 없애려면 디비를 지우면된다 -0-;;;
$sql = "SELECT nCategoryID, sName FROM category_city WHERE nParent=0";
$res = mysql_query($sql);
if(!$res)
{
echo '<font color=red style=font-size:9pt>'.mysql_error().'<br>'.$sql.'</font>';
exit;
}
while($rs = mysql_fetch_array($res))
{
$sCityChk=($rs[sName]==$sCity)?'SELECTED':'';
echo "
<option value='$rs[sName]' $sCityChk> $rs[sName]";
}
?>
</select>
</td>
<td>
<select name='sCity2' class=box style='width:100'>
<option value='' selected> 지역선택
</select>
</td>
<td>
<?php
$aAreaType = array(
'선택 한것만 검색',
'선택한것을 제외하고 검색',
);
$objFrmCtl->radio('nAreaType', $aAreaType, 't', $rs[nAreaType]);
?>
</td>
<td>
<input type='image' src='../../img/btn_search.gif' align='absbottom' />
</td>
</tr>
</form>
</table>
<br />
<table cellspacing='0' align='center' cellpadding='3' border='1' width='95%' bordercolordark='white' bordercolorlight='#D6D6D6'>
<tr class='tableTR'>
<td>지역</td>
<td>옵션</td>
<td>삭제</td>
</tr>
<?php
if(is_file("./data/area.cgi"))
{
$aFile = file('./data/area.cgi');
foreach($aFile as $index => $value)
{
$aData = explode('|', $value);
$data = trim($aData[2]);
echo "
<tr>
<td>$aData[0]$aData[1]</td>
<td align='center'>$aAreaType[$data]</td>
<td align='center'><a href=\"javascript:delChker2('./area_process.php?psMode=REMOVE&no=$index')\">삭제</a></td>
</tr>";
}
}
?>
</table>
</body>
</html>
===========================================================================
<?php
include_once $DOCUMENT_ROOT.'/global.php';
// ------------------------------------------------------------------------
// class
// ------------------------------------------------------------------------
include_once $clsRoot.'/class.Common.php';
include_once $clsRoot."/class.Filecontrol.php";
// ------------------------------------------------------------------------
// 페이지명
// ------------------------------------------------------------------------
$sPage = 'area';
$uploadRoot = "$upRoot/$sPage";
switch( $psMode )
{
case ( 'WRITE' ):
if($sCity) $sAreaCity = ">>$sCity";
if($sCity2) $sAreaCity2 = ">>$sCity2";
if(!is_dir('./data'))
{
$objCommon->msg('create data directory', null); // close, none
}
$aPost = "$sAreaCity|$sAreaCity2|$nAreaType\n";
$aArea = @file('./data/area.cgi');
$fp = fopen("./data/area.cgi", w);
fwrite($fp, $aPost);
if(is_file("./data/area.cgi"))
{
foreach($aArea as $value) fwrite($fp, $value);
}
fclose($fp);
$objCommon->go("./{$sPage}_list.php");
break;
// MODIFY ----------------------------------------------------------------------------------
case ( 'MODIFY' ):
if($sCity) $sAreaCity = ">>$sCity";
if($sCity2) $sAreaCity2 = ">>$sCity2";
$aPost = "$sAreaCity|$sAreaCity2|$nAreaType\n";
$fp = fopen("./data/area.cgi", w);
$aArea = file('./data/area.cgi');
foreach($aArea as $index => $value)
{
if($_POST[no]==$index)
{
fwrite($fp, $aPost);
}
else
{
fwrite($fp, $value);
}
}
fclose($fp);
$objCommon->go("./{$sPage}_list.php");
break;
// REMOVE ----------------------------------------------------------------------------------
case ( 'REMOVE' ):
$aArea = file('./data/area.cgi');
$fp = fopen("./data/area.cgi", w);
foreach($aArea as $index => $value)
{
if($_GET[no]!=$index) fwrite($fp, $value);
}
fclose($fp);
$objCommon->go("./{$sPage}_list.php");
break;
// -----------------------------------------------------------------------------------------
default:
$objCommon->go('/');
break;
}
?>
include_once $_SERVER[DOCUMENT_ROOT].'/global.php';
include_once $_SERVER[DOCUMENT_ROOT].'/include/dbconn.php';
include_once $clsRoot.'/class.Common.php';
include_once $clsRoot."/class.FormControl.php";
?>
<html>
<head>
<title>지역 정보</title>
<meta name='author' content='interkorea'>
<meta name='keywords' content=''>
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='pragma' content='no-cache'>
<meta http-equiv='content-type' content='text/html; charset=euc-kr'>
<link rel='stylesheet' href='/include/css.css' type='text/css'>
<script language='javascript' src='/include/main.js'></script>
</head>
<body>
<?php
// ------------------------------------------------------------------------
// address data
// ------------------------------------------------------------------------
include "../../JsCode/CityCache.php";
?>
<table cellspacing='0' cellpadding='0' border='0' align='center'>
<!-- 지역검색 -->
<form method='post' name='frm_write' action='./area_process.php?psMode=WRITE' enctype='multipart/form-data' style='border:0;margin:0' onSubmit='return SoftCheck(this)'>
<tr>
<td>지역 선택하기 </td>
<td>
<select name='sCity' onchange='JavaScript:ChangeCat0(this.selectedIndex)' style='font-size:9pt;width:100' msg='시/도를 선택해주세요' required >
<option value=''> -시/도선택-
<?php
// 특정지역을 없애려면 디비를 지우면된다 -0-;;;
$sql = "SELECT nCategoryID, sName FROM category_city WHERE nParent=0";
$res = mysql_query($sql);
if(!$res)
{
echo '<font color=red style=font-size:9pt>'.mysql_error().'<br>'.$sql.'</font>';
exit;
}
while($rs = mysql_fetch_array($res))
{
$sCityChk=($rs[sName]==$sCity)?'SELECTED':'';
echo "
<option value='$rs[sName]' $sCityChk> $rs[sName]";
}
?>
</select>
</td>
<td>
<select name='sCity2' class=box style='width:100'>
<option value='' selected> 지역선택
</select>
</td>
<td>
<?php
$aAreaType = array(
'선택 한것만 검색',
'선택한것을 제외하고 검색',
);
$objFrmCtl->radio('nAreaType', $aAreaType, 't', $rs[nAreaType]);
?>
</td>
<td>
<input type='image' src='../../img/btn_search.gif' align='absbottom' />
</td>
</tr>
</form>
</table>
<br />
<table cellspacing='0' align='center' cellpadding='3' border='1' width='95%' bordercolordark='white' bordercolorlight='#D6D6D6'>
<tr class='tableTR'>
<td>지역</td>
<td>옵션</td>
<td>삭제</td>
</tr>
<?php
if(is_file("./data/area.cgi"))
{
$aFile = file('./data/area.cgi');
foreach($aFile as $index => $value)
{
$aData = explode('|', $value);
$data = trim($aData[2]);
echo "
<tr>
<td>$aData[0]$aData[1]</td>
<td align='center'>$aAreaType[$data]</td>
<td align='center'><a href=\"javascript:delChker2('./area_process.php?psMode=REMOVE&no=$index')\">삭제</a></td>
</tr>";
}
}
?>
</table>
</body>
</html>
===========================================================================
<?php
include_once $DOCUMENT_ROOT.'/global.php';
// ------------------------------------------------------------------------
// class
// ------------------------------------------------------------------------
include_once $clsRoot.'/class.Common.php';
include_once $clsRoot."/class.Filecontrol.php";
// ------------------------------------------------------------------------
// 페이지명
// ------------------------------------------------------------------------
$sPage = 'area';
$uploadRoot = "$upRoot/$sPage";
switch( $psMode )
{
case ( 'WRITE' ):
if($sCity) $sAreaCity = ">>$sCity";
if($sCity2) $sAreaCity2 = ">>$sCity2";
if(!is_dir('./data'))
{
$objCommon->msg('create data directory', null); // close, none
}
$aPost = "$sAreaCity|$sAreaCity2|$nAreaType\n";
$aArea = @file('./data/area.cgi');
$fp = fopen("./data/area.cgi", w);
fwrite($fp, $aPost);
if(is_file("./data/area.cgi"))
{
foreach($aArea as $value) fwrite($fp, $value);
}
fclose($fp);
$objCommon->go("./{$sPage}_list.php");
break;
// MODIFY ----------------------------------------------------------------------------------
case ( 'MODIFY' ):
if($sCity) $sAreaCity = ">>$sCity";
if($sCity2) $sAreaCity2 = ">>$sCity2";
$aPost = "$sAreaCity|$sAreaCity2|$nAreaType\n";
$fp = fopen("./data/area.cgi", w);
$aArea = file('./data/area.cgi');
foreach($aArea as $index => $value)
{
if($_POST[no]==$index)
{
fwrite($fp, $aPost);
}
else
{
fwrite($fp, $value);
}
}
fclose($fp);
$objCommon->go("./{$sPage}_list.php");
break;
// REMOVE ----------------------------------------------------------------------------------
case ( 'REMOVE' ):
$aArea = file('./data/area.cgi');
$fp = fopen("./data/area.cgi", w);
foreach($aArea as $index => $value)
{
if($_GET[no]!=$index) fwrite($fp, $value);
}
fclose($fp);
$objCommon->go("./{$sPage}_list.php");
break;
// -----------------------------------------------------------------------------------------
default:
$objCommon->go('/');
break;
}
?>