본문 바로가기

Web/PHP

리스트 디비(area)

data
area_list.php
area_process.php

===================================================================================================================

<?php
include_once $_SERVER[DOCUMENT_ROOT].'/global.php';
include_once $clsRoot.'/class.Common.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>

<table cellspacing='0' align='center' cellpadding='3' border='1' width='95%' bordercolordark='white' bordercolorlight='#D6D6D6'>
<!-- 지역검색 -->
<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 class='tableTR' width='20%'>입 력</td>
    <td><input type='text' name='data' class='input' style='width:60%' /> <input type='submit' value=' 전 송 ' class='inputbtn' /></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>
</tr>
<?php
if(is_file("./data/area.cgi"))
{
    $aFile = file('./data/area.cgi');
    foreach($aFile as $index => $value)
    {
     // $aData = explode('|', $value);
        $data = trim($value);

        echo "
        <tr>
            <td>$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(!is_dir('./data'))
        {
            $objCommon->msg('create data directory', null); // close, none
        }

        $aPost = "$data\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' ):

        $aPost = "$data\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;
}
?>

'Web > PHP' 카테고리의 다른 글

컨텐츠 xml로 변환  (0) 2013.09.26
kimsplus 파일버전 게시판 합치기  (0) 2013.09.26
md5를이용한 암호/복호화  (0) 2013.09.26
프로텍트 패턴  (0) 2013.09.26
history.back()시 내용삭제 문제 해결책  (0) 2013.09.26