<?php if(!isset($_SESSION)){ session_start(); } //echo '<pre>';print_r($_POST);echo '</pre>'; //exit; if(isset($_POST) && $_SERVER['REQUEST_METHOD'] == "POST"){ @extract($_POST); require_once 'path.php';// root 폴더를 기준으로 상대경로 자동 구하기 require_once $g['path_config'].'dbconnect.php'; require_once $g['path_class'].'dbDataClass.php'; require_once $g['path_class'].'bbsClass.php'; $d = new DBDataClass(); $c = new bbsClass();
if($mode == 'write'){ $subject = trim($subject); $content = trim($content); $html = 0; $depth = 1; $notice = 0; date_default_timezone_set('Asia/Seoul');
if($uid == 0){ $d_regis = date('YmdHis'); $access_ip=$_SERVER['REMOTE_ADDR']; $QKEY = "bbsid,subject,content,html,depth,notice,d_regis,userID,userNM,ip"; $QVAL = "'$bid','$subject','$content',$html,$depth,$notice,'$d_regis','$userID','$userNM','$access_ip'"; $d->getDbInsert('bbs_data',$QKEY,$QVAL); Mail2Admin($subject,$content); echo 1; } else { // 등록자 여부 체크 $R = $d->getDbData('bbs_data','uid='.$uid,'*'); if($R['userID'] === $_SESSION['userID']){ // 관리자도 수정은 불가 $QSET="subject='".$subject."',"; $QSET.="content='".$content."',"; $QSET.="html='".$html."'"; $QVAL="uid='".$uid."'";
$d->getDbUpdate('bbs_data',$QSET,$QVAL); echo 2; } else { echo -2; } } } else if($mode == 'delete'){ $d->getDbDelete('bbs_data',"uid='".$uid."'"); echo 3; // 삭제 } } else { echo -1; }
function Mail2Admin($subject,$message){ global $c; $to = "jsk005@naver.com"; $from = "webmaster@abc.com"; $nameFrom = "AppMaster"; $message = $c->getContents($message,'TEXT');
$mailheaders = "Return-Path: $from\r\n"; $mailheaders.= "From: $nameFrom <$from>\r\n"; $mailheaders.= "Content-Type: text/html;charset=utf-8\r\n"; $mailheaders.= "MIME-Version: 1.0\r\n";
mail($to, $subject, $message, $mailheaders, $from); } ?>
|
function getContents($str,$html){ if ($html == 'HTML'){ $str = htmlspecialchars_decode(stripslashes($str)); $str = str_replace('<A href=','<a target="_blank" href=',$str); $str = str_replace('<a href=','<a target="_blank" href=',$str); $str = str_replace('<a target="_blank" href="#','<a href="#',$str); $str = str_replace(' target="_blank">','>',$str); $str = str_replace('< param','<param',$str); $str = str_replace("\t",' ',$str); $str = str_replace('@IFRAME@','iframe',$str);
$str = str_replace('imgOrignWin(this.src)=""','onclick="imgOrignWin(this.src);"',$str); $str = str_replace('imgorignwin(this.src)=""','onclick="imgOrignWin(this.src);"',$str); $_atkParam = array(';a=','&a=','?a=','m=admin','system='); foreach($_atkParam as $_prm){ $str = str_replace($_prm,'',$str); } } else { $str = str_replace('<','<',$str); $str = str_replace('>','>',$str); $str = str_replace(' ','&nbsp;',$str); $str = str_replace("\t",' ',$str); $str = nl2br($str); } return $str; }
|