Warning: Cannot modify header information - headers already sent by...오류 해결 좀 부탁드립니다.

Warning: Cannot modify header information - headers already sent by...오류 해결 좀 부탁드립니다.

QA

Warning: Cannot modify header information - headers already sent by...오류 해결 좀 부탁드립니다.

본문

최근게시물 다는중에 아래와 같은 오류가 나옵니다.
부디 오류 해결 좀 부탁드립니다.
 
오류메세지
Warning: Cannot modify header information - headers already sent by (output started at /home/jcsilver.or.kr/www/index.htm:5) in /home/jcsilver.or.kr/www/jcsilver/common.php on line 7
<index 파일>
<HTML>
<HEAD>
<TITLE></TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=euc-kr">
<style type="text/css">
table {
font-size: 13px;
line-height: 23px;
color: #666666;
}
body {
font-size: 13px;
line-height: 23px;
}
a:link {
text-decoration: none;
color: #333333;
}
a:visited {
text-decoration: none;
color: #333333;
}
a:hover {
text-decoration: none text-decoration: underline;
color: #ff3333;
}
a:active {
text-decoration: none;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
function getCookie( name ){
var nameOfCookie = name + "=";
var x = 0;
while ( x <= document.cookie.length )
{
var y = (x+nameOfCookie.length);
if ( document.cookie.substring( x, y ) == nameOfCookie ) {
if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
endOfCookie = document.cookie.length;
return unescape( document.cookie.substring( y, endOfCookie ) );
}
x = document.cookie.indexOf( " ", x ) + 1;
if ( x == 0 )
break;
}
return "";
}
//if ( getCookie( "Notice" ) != "done" ) {
//두번째 새창으로 열릴 페이지의 경로 및 크기와 위치를 지정해 주세요.
//noticeWindow = noticeWindow = window.open('popup/14-02-10.htm','notice','scrollbars=no,left=0,top=0,width=550,height=550');
//noticeWindow.opener = self;
//}
//if ( getCookie( "Notice2" ) != "done" ) {
//두번째 새창으로 열릴 페이지의 경로 및 크기와 위치를 지정해 주세요.
//noticeWindow = noticeWindow = window.open('popup/13-08-29.htm','notice2','scrollbars=no,left=0,top=0,width=600,height=858');
//noticeWindow.opener = self;
//}
//if ( getCookie( "Notice3" ) != "done" ) {
//두번째 새창으로 열릴 페이지의 경로 및 크기와 위치를 지정해 주세요.
//noticeWindow = noticeWindow = window.open('popup/11-01-20.htm','notice3','scrollbars=no,left=620,top=0,width=600,height=788');
//noticeWindow.opener = self;
//}
// -->
</SCRIPT>
<script LANGUAGE="javascript" SRC="http://jcsilver.or.kr/gjcityns.js"></script>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<SCRIPT language="javaSCRIPT" src="http://jcsilver.or.kr/common.js"></SCRIPT>
</HEAD>
<!--<div id="Layer1" style="position:absolute; left:950px; top:347px; width:53px; height:97px; z-index:1">
<table width="81" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> <img src="images/2008-quick_01.gif" width="81" height="29" alt=""></td>
</tr>
<tr>
<td> <a href="http://www.mohw.go.kr" target="_blank"><img src="images/2008-quick_02.gif" alt="" width="81" height="32" border="0"></a></td>
</tr>
<tr>
<td> <a href="http://www.kaswcs.or.kr" target="_blank"><img src="images/2008-quick_03.gif" alt="" width="81" height="59" border="0"></a></td>
</tr>
<tr>
<td> <a href="http://caritas.wonju.or.kr" target="_blank"><img src="images/2008-quick_04.gif" alt="" width="81" height="63" border="0"></a></td>
</tr>
<tr>
<td> <a href="http://chungbuk.chest.or.kr" target="_blank"><img src="images/2008-quick_05.gif" alt="" width="81" height="60" border="0"></a></td>
</tr>
<tr>
<td> <a href="http://www.okjc.net" target="_blank"><img src="images/2008-quick_06.gif" alt="" width="81" height="29" border="0"></a></td>
</tr>
<tr>
<td> <img src="images/2008-quick_07.gif" width="81" height="11" alt=""></td>
</tr>
</table>
</div>
-->
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="images/bggg.gif"><table id="Table_01" width="950" height="87" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"> <img src="images/top_01.gif" width="950" height="11" alt=""></td>
</tr>
<tr>
<td> <img src="images/top_02.gif" width="298" height="76" alt=""></td>
<td> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="650" height="70">
<param name="movie" value="images/menu.swf">
<param name="quality" value="high">
<embed src="images/menu.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="650" height="70"></embed></object></td>
</tr>
</table></td>
</tr>
</table>
<table width="950" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="950" height="335">
<param name="movie" value="images/img.swf">
<param name="quality" value="high">
<embed src="images/img.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="950" height="335"></embed></object></td>
</tr>
</table>
<table width="940" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="190" rowspan="2" valign="top"><table width="194" border="0" cellpadding="2" cellspacing="0">
<tr>
<td valign="top">
<?
$asmLoginBoxStyle = 'mvKey';
$asmWidth = '164px';
include "$DOCUMENT_ROOT/asapro/member/index.htm";
?>
</td>
</tr>
<tr>
<td width="190" valign="top"> <a href="http://www.jcsilver.or.kr/asapro/board/main-1_4.htm"><img src="images/08_in_left_01.gif" alt="" width="190" height="45" border="0"></a></td>
</tr>
<tr>
<td valign="top"> <a href="http://www.jcsilver.or.kr/asapro/board/main-3-1.htm"><img src="images/08_in_left_02.gif" alt="" width="190" height="29" border="0"></a></td>
</tr>
<tr>
<td valign="top"> <a href="http://www.jcsilver.or.kr/asapro/board/main-3-3.htm"><img src="images/08_in_left_03.gif" alt="" width="190" height="33" border="0"></a></td>
</tr>
<tr>
<td align="center" valign="top">
<!--<iframe src="http://weather.superboard.com/wxbn.cgi?db=10_jcsilver" width="160" height="120" frameborder="0" scrolling="no" leftmargin='0' topmargin='0' marginwidth='0'></iframe> -->
</td>
</tr>
<tr>
<td align="center" valign="top"><a href="http://www.longtermcare.or.kr" target="_blank"><img src="images/noin.gif" border="0"></a></td>
</tr>

<tr>
<td align="center" valign="top"><table width="95" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<? $sn = "home"; include ("$DOCUMENT_ROOT/asapro/stat/count.php"); ?>
</td>
</tr>
</table></td>
</tr>
</table></td>
<td width="752" valign="top"><table width="752" border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td rowspan="2"> <a href="http://www.jcsilver.or.kr/asapro/board/07-food.html" target="_blank"><img src="images/08_in_cen1_01.gif" alt="" width="93" height="156" border="0"></a></td>
<td rowspan="2"> <a href="http://www.jcsilver.or.kr/asapro/board/main-2.html#tu"><img src="images/08_in_cen1_02.gif" alt="" width="104" height="156" border="0"></a></td>
<td rowspan="2"> <a href="http://www.jcsilver.or.kr/asapro/board/main-1_2.htm"><img src="images/08_in_cen1_03.gif" alt="" width="73" height="156" border="0"></a></td>
<td rowspan="2"> <a href="http://www.jcsilver.or.kr/bbs/board.php?bo_table=news"><img src="images/08_in_cen1_04.gif" alt="" width="106" height="156" border="0"></a></td>
</tr>
<tr>
<td>
<!---------------새소식------------------------------------------------------------------------------------->
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="tb_mm01" style="display;">
<tr>
<td width="1"><IMG SRC="images/ind-ce_08.gif" WIDTH=1 HEIGHT=31 ALT=""></td>
<td width="238"><a href="http://www.jcsilver.or.kr/asapro/board/list.htm?bn=notice"><img src="images/08_in_cen1_05.gif" alt="" width="238" height="45" border="0"></a></td>
<td width="138"> <a href="javascript:con_ShowHidden('mm02');" onMouseOut="MM_swapImgRestore()" onBlur="MM_swapImgRestore()" onMouseOver="con_ShowHidden('mm02');MM_swapImage('chapter2','','http://www.gwangju.go.kr/gjcity/images/main/nsmain_05_02o.gif',0)" onFocus="con_ShowHidden('mm02');MM_swapImage('chapter2','','http://www.gwangju.go.kr/gjcity/images/main/nsmain_05_02o.gif',0)"><img src="images/08_in_cen1_06.gif" alt="" width="138" height="45" border="0"></a></td>
</tr>
<tr>
<td height="93" colspan="4" valign="top"> <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="29">
<? $bn = "notice";
$whereIsSign = 'images/in.gif';
$nLine = 6;
$frontPageWidth = '376';
$showDate = '1';
$subject_textIndent = '22';
$showMore = '0';
include("$DOCUMENT_ROOT/asapro/board/auto.htm"); ?>
</td>
</tr>
</table></td>
</tr>
</table>
<!---------------공지사항----------------->
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="tb_mm02" style="display:none;">
<tr>
<td width="1"><IMG SRC="images/ind-ce_08.gif" WIDTH=1 HEIGHT=31 ALT=""></td>
<td width="238"><a href="javascript:con_ShowHidden('mm01');" onMouseOut="MM_swapImgRestore()" onBlur="MM_swapImgRestore()" onMouseOver="con_ShowHidden('mm01');MM_swapImage('chapter1','','http://www.gwangju.go.kr/gjcity/images/main/nsmain_05_01o.gif',0)" onFocus="con_ShowHidden('mm01');MM_swapImage('chapter1','','http://www.gwangju.go.kr/gjcity/images/main/nsmain_05_01o.gif',0)"><img src="images/08_in_cen1_05.gif" width="238" height="45" border="0"></a></td>
<td width="138"><a href="http://www.jcsilver.or.kr/asapro/board/list.htm?bn=board"><img src="images/08_in_cen1_06.gif" width="138" height="45" border="0"></a></td>
</tr>
<tr>
<td height="93" colspan="4" valign="top"> <table width="98%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="29">
<? $bn = "board";
$whereIsSign = 'images/in.gif';
$nLine = 6;
$frontPageWidth = '376';
$showDate = '1';
$subject_textIndent = '22';
$showMore = '0';
include("$DOCUMENT_ROOT/asapro/board/auto.htm"); ?>
</td>
</tr>
</table></td>
</tr>
</table>
<!---------------입찰공고----------------->
</td>
</tr>
</table></td>
</tr>
<tr>
<td valign="top"><table width="752" border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td colspan="3"> <a href="http://www.jcsilver.or.kr/asapro/board/list.htm?bn=gallery"><img src="images/08_in_cen2_01.gif" alt="" width="205" height="44" border="0"></a></td>
<td width="274"> <a href="http://www.jcsilver.or.kr/asapro/photo/list.htm?code=AS1131498628"><img src="images/08_in_cen2_02.gif" alt="" width="274" height="44" border="0"></a></td>
<td width="273"> <a href="http://www.jcsilver.or.kr/jcsilver/bbs/board.php?bo_table=jcsilver"><img src="images/08_in_cen2_03.gif" alt="" width="273" height="44" border="0"></a></td>
</tr>
<tr valign="top">
<td width="19"> <img src="images/08_in_cen2_04.gif" width="19" height="103" alt=""></td>
<td width="159">
<!-----------동영상-------------->
<object width="159" height="102"><param name="movie" value="//www.youtube.com/v/3kppWRoM2PY?version=3&hl=ko_KR"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="//www.youtube.com/v/3kppWRoM2PY?version=3&hl=ko_KR" type="application/x-shockwave-flash" width="159" height="102" allowscriptaccess="always" allowfullscreen="true"></embed></object> <!---------------동영상끝------------>
</td>
<td width="27"> <img src="images/08_in_cen2_06.gif" width="27" height="103" alt=""></td>
<td rowspan="2"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<? $code="AS1131498628"; include("$DOCUMENT_ROOT/asapro/photo/auto.htm"); ?>
</td>
</tr>
</table></td>
<td rowspan="2" align="right"> <table width="96%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<!--그누보드 최근글 시작-->
<?
$g4_path="./jcsilver";
include_once("$g4_path/common.php");
include_once("$g4[path]/lib/latest.lib.php");
?>
<?=latest("hoya_scroll", "jcsilver", 6, 6);
?>
<!--그누보드 최근글 끝-->
</td>
</tr>
</table></td>
</tr>
<tr valign="top">
<td colspan="3"> <img src="images/08_in_cen2_09.gif" width="205" height="51" alt=""></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2" valign="top">
<?
include "$DOCUMENT_ROOT/asapro/board/copyright.html"
?>
</td>
</tr>
</table>
</body>
</html>
<common.php 파일>
<?
/*******************************************************************************
** 공통 변수, 상수, 코드
*******************************************************************************/
error_reporting(E_ALL ^ E_NOTICE);
// 보안설정이나 프레임이 달라도 쿠키가 통하도록 설정
header('P3P: CP="ALL CURa ADMa DEVa TAIa OUR BUS IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC OTC"');
if (!isset($set_time_limit)) $set_time_limit = 0;
@set_time_limit($set_time_limit);
// 짧은 환경변수를 지원하지 않는다면
if (isset($HTTP_POST_VARS) && !isset($_POST)) {
$_POST = &$HTTP_POST_VARS;
$_GET = &$HTTP_GET_VARS;
$_SERVER = &$HTTP_SERVER_VARS;
$_COOKIE = &$HTTP_COOKIE_VARS;
$_ENV = &$HTTP_ENV_VARS;
$_FILES = &$HTTP_POST_FILES;
if (!isset($_SESSION))
$_SESSION = &$HTTP_SESSION_VARS;
}
//
// phpBB2 참고
// php.ini 의 magic_quotes_gpc 값이 FALSE 인 경우 addslashes() 적용
// SQL Injection 등으로 부터 보호
//
if( !get_magic_quotes_gpc() )
{
if( is_array($_GET) )
{
while( list($k, $v) = each($_GET) )
{
if( is_array($_GET[$k]) )
{
while( list($k2, $v2) = each($_GET[$k]) )
{
$_GET[$k][$k2] = addslashes($v2);
}
@reset($_GET[$k]);
}
else
{
$_GET[$k] = addslashes($v);
}
}
@reset($_GET);
}
if( is_array($_POST) )
{
while( list($k, $v) = each($_POST) )
{
if( is_array($_POST[$k]) )
{
while( list($k2, $v2) = each($_POST[$k]) )
{
$_POST[$k][$k2] = addslashes($v2);
}
@reset($_POST[$k]);
}
else
{
$_POST[$k] = addslashes($v);
}
}
@reset($_POST);
}
if( is_array($_COOKIE) )
{
while( list($k, $v) = each($_COOKIE) )
{
if( is_array($_COOKIE[$k]) )
{
while( list($k2, $v2) = each($_COOKIE[$k]) )
{
$_COOKIE[$k][$k2] = addslashes($v2);
}
@reset($_COOKIE[$k]);
}
else
{
$_COOKIE[$k] = addslashes($v);
}
}
@reset($_COOKIE);
}
}
if ($_GET['g4_path'] || $_POST['g4_path'] || $_COOKIE['g4_path']) {
unset($_GET['g4_path']);
unset($_POST['g4_path']);
unset($_COOKIE['g4_path']);
unset($g4_path);
}

//==========================================================================================================================
// XSS(Cross Site Scripting) 공격에 의한 데이터 검증 및 차단
//--------------------------------------------------------------------------------------------------------------------------
function xss_clean($data)
{
// If its empty there is no point cleaning it :\
if(empty($data))
return $data;

// Recursive loop for arrays
if(is_array($data))
{
foreach($data as $key => $value)
{
$data[$key] = xss_clean($value);
}

return $data;
}

// http://svn.bitflux.ch/repos/public/popoon/trunk/classes/externalinput.php
// +----------------------------------------------------------------------+
// | Copyright (c) 2001-2006 Bitflux GmbH |
// +----------------------------------------------------------------------+
// | Licensed under the Apache License, Version 2.0 (the "License"); |
// | you may not use this file except in compliance with the License. |
// | You may obtain a copy of the License at |
// | http://www.apache.org/licenses/LICENSE-2.0 |
// | Unless required by applicable law or agreed to in writing, software |
// | distributed under the License is distributed on an "AS IS" BASIS, |
// | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
// | implied. See the License for the specific language governing |
// | permissions and limitations under the License. |
// +----------------------------------------------------------------------+
// | Author: Christian Stocker <*** 개인정보보호를 위한 이메일주소 노출방지 ***> |
// +----------------------------------------------------------------------+

// Fix &entity\n;
$data = str_replace(array('&','<','>'), array('&','<','>'), $data);
$data = preg_replace('/(*\w+)[\x00-\x20]+;/', '$1;', $data);
$data = preg_replace('/(*[0-9A-F]+);*/i', '$1;', $data);
if (function_exists("html_entity_decode"))
{
$data = html_entity_decode($data);
}
else
{
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
$data = strtr($data, $trans_tbl);
}
// Remove any attribute starting with "on" or xmlns
$data = preg_replace('#(<[^>]+?[\x00-\x20"\'])(?:on|xmlns)[^>]*+>#i', '$1>', $data);
// Remove javascript: and vbscript: protocols
$data = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([`\'"]*)[\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#i', '$1=$2nojavascript...', $data);
$data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#i', '$1=$2novbscript...', $data);
$data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#', '$1=$2nomozbinding...', $data);
// Only works in IE: <span style="width: expression(alert('Ping!'));"></span>
$data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?expression[\x00-\x20]*\([^>]*+>#i', '$1>', $data);
$data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?behaviour[\x00-\x20]*\([^>]*+>#i', '$1>', $data);
$data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*+>#i', '$1>', $data);
// Remove namespaced elements (we do not need them)
$data = preg_replace('#</*\w+:\w[^>]*+>#i', '', $data);
do
{
// Remove really unwanted tags
$old_data = $data;
$data = preg_replace('#</*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|i(?:frame|layer)|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|title|xml)[^>]*+>#i', '', $data);
}
while ($old_data !== $data);

return $data;
}
$_GET = xss_clean($_GET);
//==========================================================================================================================

//==========================================================================================================================
// extract($_GET); 명령으로 인해 page.php?_POST[var1]=data1&_POST[var2]=data2 와 같은 코드가 _POST 변수로 사용되는 것을 막음
// 081029 : letsgolee 님께서 도움 주셨습니다.
//--------------------------------------------------------------------------------------------------------------------------
$ext_arr = array ('PHP_SELF', '_ENV', '_GET', '_POST', '_FILES', '_SERVER', '_COOKIE', '_SESSION', '_REQUEST',
'HTTP_ENV_VARS', 'HTTP_GET_VARS', 'HTTP_POST_VARS', 'HTTP_POST_FILES', 'HTTP_SERVER_VARS',
'HTTP_COOKIE_VARS', 'HTTP_SESSION_VARS', 'GLOBALS');
$ext_cnt = count($ext_arr);
for ($i=0; $i<$ext_cnt; $i++) {
// GET 으로 선언된 전역변수가 있다면 unset() 시킴
if (isset($_GET[$ext_arr[$i]])) unset($_GET[$ext_arr[$i]]);
}
//==========================================================================================================================
// PHP 4.1.0 부터 지원됨
// php.ini 의 register_globals=off 일 경우
@extract($_GET);
@extract($_POST);
@extract($_SERVER);
// 완두콩님이 알려주신 보안관련 오류 수정
// $member 에 값을 직접 넘길 수 있음
$config = array();
$member = array();
$board = array();
$group = array();
$g4 = array();
// index.php 가 있는곳의 상대경로
// php 인젝션 ( 임의로 변수조작으로 인한 리모트공격) 취약점에 대비한 코드
// prosper 님께서 알려주셨습니다.
if (!$g4_path || preg_match("/:\/\//", $g4_path))
die("<meta http-equiv='content-type' content='text/html; charset=$g4[charset]'><script type='text/javascript'> alert('잘못된 방법으로 변수가 정의되었습니다.'); </script>");
//if (!$g4_path) $g4_path = ".";
$g4['path'] = $g4_path;
// 경로의 오류를 없애기 위해 $g4_path 변수는 해제
unset($g4_path);
include_once("$g4[path]/lib/constant.php"); // 상수 정의
include_once("$g4[path]/config.php"); // 설정 파일
include_once("$g4[path]/lib/common.lib.php"); // 공통 라이브러리
// config.php 가 있는곳의 웹경로
if (!$g4['url'])
{
$g4['url'] = 'http://' . $_SERVER['HTTP_HOST'];
$dir = dirname($_SERVER["PHP_SELF"]);
if (!file_exists("config.php"))
$dir = dirname($dir);
$cnt = substr_count($g4['path'], "..");
for ($i=2; $i<=$cnt; $i++)
$dir = dirname($dir);
$g4['url'] .= $dir;
}
// \ 를 / 롤 변경
$g4['url'] = strtr($g4['url'], "\\", "/");
// url 의 끝에 있는 / 를 삭제한다.
$g4['url'] = preg_replace("/\/$/", "", $g4['url']);
//==============================================================================
// 공통
//==============================================================================
$dirname = dirname(__FILE__).'/';
$dbconfig_file = "dbconfig.php";
if (file_exists("$g4[path]/$dbconfig_file"))
{
if (is_dir("$g4[path]/install")) die("<meta http-equiv='content-type' content='text/html; charset=$g4[charset]'><script type='text/javascript'> alert('install 디렉토리를 삭제하여야 정상 실행됩니다.'); </script>");
include_once("$g4[path]/$dbconfig_file");
$connect_db = sql_connect($mysql_host, $mysql_user, $mysql_password);
$select_db = sql_select_db($mysql_db, $connect_db);
if (!$select_db)
die("<meta http-equiv='content-type' content='text/html; charset=$g4[charset]'><script type='text/javascript'> alert('DB 접속 오류'); </script>");
}
else
{
echo "<meta http-equiv='content-type' content='text/html; charset=$g4[charset]'>";
echo <<<HEREDOC
<script type="text/javascript">
alert("DB 설정 파일이 존재하지 않습니다.\\n\\n프로그램 설치 후 실행하시기 바랍니다.");
location.href = "./install/";
</script>
HEREDOC;
exit;
}
unset($my); // DB 설정값을 클리어 해줍니다.
//print_r2($GLOBALS);
//-------------------------------------------
// SESSION 설정
//-------------------------------------------
ini_set("session.use_trans_sid", 0); // PHPSESSID를 자동으로 넘기지 않음
ini_set("url_rewriter.tags",""); // 링크에 PHPSESSID가 따라다니는것을 무력화함 (해뜰녘님께서 알려주셨습니다.)
session_save_path("{$g4['path']}/data/session");
if (isset($SESSION_CACHE_LIMITER))
@session_cache_limiter($SESSION_CACHE_LIMITER);
else
@session_cache_limiter("no-cache, must-revalidate");
//==============================================================================
// 공용 변수
//==============================================================================
// 기본환경설정
// 기본적으로 사용하는 필드만 얻은 후 상황에 따라 필드를 추가로 얻음
$config = sql_fetch(" select * from $g4[config_table] ");
ini_set("session.cache_expire", 180); // 세션 캐쉬 보관시간 (분)
ini_set("session.gc_maxlifetime", 10800); // session data의 garbage collection 존재 기간을 지정 (초)
ini_set("session.gc_probability", 1); // session.gc_probability는 session.gc_divisor와 연계하여 gc(쓰레기 수거) 루틴의 시작 확률을 관리합니다. 기본값은 1입니다. 자세한 내용은 session.gc_divisor를 참고하십시오.
ini_set("session.gc_divisor", 100); // session.gc_divisor는 session.gc_probability와 결합하여 각 세션 초기화 시에 gc(쓰레기 수거) 프로세스를 시작할 확률을 정의합니다. 확률은 gc_probability/gc_divisor를 사용하여 계산합니다. 즉, 1/100은 각 요청시에 GC 프로세스를 시작할 확률이 1%입니다. session.gc_divisor의 기본값은 100입니다.
session_set_cookie_params(0, "/");
ini_set("session.cookie_domain", $g4['cookie_domain']);
@session_start();
/*
// 081022 : CSRF 방지를 위해 코드를 작성했으나 효과가 없어 주석처리 함
if (strpos($_SERVER[PHP_SELF], $g4['admin']) === false)
set_session("ss_admin", false);
*/
// 4.00.03 : [보안관련] PHPSESSID 가 틀리면 로그아웃한다.
if ($_REQUEST['PHPSESSID'] && $_REQUEST['PHPSESSID'] != session_id())
goto_url("{$g4['bbs_path']}/logout.php");
// QUERY_STRING
$qstr = "";
/*
if (isset($bo_table)) $qstr .= 'bo_table=' . urlencode($bo_table);
if (isset($wr_id)) $qstr .= '&wr_id=' . urlencode($wr_id);
*/
if (isset($sca)) {
$sca = mysql_real_escape_string($sca);
$qstr .= '&sca=' . urlencode($sca);
}
if (isset($sfl)) {
$sfl = mysql_real_escape_string($sfl);
//$sfl = preg_replace("/[^\w\,\|]+/", "", $sfl);
$qstr .= '&sfl=' . urlencode($sfl); // search field (검색 필드)
}
if (isset($stx)) { // search text (검색어)
$stx = mysql_real_escape_string($stx);
$qstr .= '&stx=' . urlencode($stx);
}
if (isset($sst)) {
$sst = mysql_real_escape_string($sst);
$qstr .= '&sst=' . urlencode($sst); // search sort (검색 정렬 필드)
}
if (isset($sod)) { // search order (검색 오름, 내림차순)
$sod = preg_match("/^(asc|desc)$/i", $sod) ? $sod : "";
$qstr .= '&sod=' . urlencode($sod);
}
if (isset($sop)) { // search operator (검색 or, and 오퍼레이터)
$sop = preg_match("/^(or|and)$/i", $sop) ? $sop : "";
$qstr .= '&sop=' . urlencode($sop);
}
if (isset($spt)) { // search part (검색 파트[구간])
$spt = (int)$spt;
$qstr .= '&spt=' . urlencode($spt);
}
if (isset($page)) { // 리스트 페이지
$page = (int)$page;
$qstr .= '&page=' . urlencode($page);
}
if ($wr_id) {
$wr_id = (int)$wr_id;
}
if ($bo_table) {
$bo_table = preg_match("/^[a-zA-Z0-9_]+$/", $bo_table) ? $bo_table : "";
}
// URL ENCODING
if (isset($url)) {
$urlencode = urlencode($url);
}
else {
// 2008.01.25 Cross Site Scripting 때문에 수정
//$urlencode = $_SERVER['REQUEST_URI'];
$urlencode = urlencode($_SERVER[REQUEST_URI]);
}
//===================================

// 자동로그인 부분에서 첫로그인에 포인트 부여하던것을 로그인중일때로 변경하면서 코드도 대폭 수정하였습니다.
if ($_SESSION['ss_mb_id']) // 로그인중이라면
{
$member = get_member($_SESSION['ss_mb_id']);
// 오늘 처음 로그인 이라면
if (substr($member['mb_today_login'], 0, 10) != $g4['time_ymd'])
{
// 첫 로그인 포인트 지급
insert_point($member['mb_id'], $config['cf_login_point'], "{$g4['time_ymd']} 첫로그인", "@login", $member['mb_id'], $g4['time_ymd']);
// 오늘의 로그인이 될 수도 있으며 마지막 로그인일 수도 있음
// 해당 회원의 접근일시와 IP 를 저장
$sql = " update {$g4['member_table']} set mb_today_login = '{$g4['time_ymdhis']}', mb_login_ip = '{$_SERVER['REMOTE_ADDR']}' where mb_id = '{$member['mb_id']}' ";
sql_query($sql);
}
}
else
{
// 자동로그인 ---------------------------------------
// 회원아이디가 쿠키에 저장되어 있다면 (3.27)
if ($tmp_mb_id = get_cookie("ck_mb_id"))
{
$tmp_mb_id = substr(preg_replace("/[^a-zA-Z0-9_]*/", "", $tmp_mb_id), 0, 20);
// 최고관리자는 자동로그인 금지
if ($tmp_mb_id != $config['cf_admin'])
{
$sql = " select mb_password, mb_intercept_date, mb_leave_date, mb_email_certify from {$g4['member_table']} where mb_id = '{$tmp_mb_id}' ";
$row = sql_fetch($sql);
$key = md5($_SERVER['SERVER_ADDR'] . $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT'] . $row['mb_password']);
// 쿠키에 저장된 키와 같다면
$tmp_key = get_cookie("ck_auto");
if ($tmp_key == $key && $tmp_key)
{
// 차단, 탈퇴가 아니고 메일인증이 사용이면서 인증을 받았다면
if ($row['mb_intercept_date'] == "" &&
$row['mb_leave_date'] == "" &&
(!$config['cf_use_email_certify'] || preg_match('/[1-9]/', $row['mb_email_certify'])) )
{
// 세션에 회원아이디를 저장하여 로그인으로 간주
set_session("ss_mb_id", $tmp_mb_id);
// 페이지를 재실행
echo "<script type='text/javascript'> window.location.reload(); </script>";
exit;
}
}
// $row 배열변수 해제
unset($row);
}
}
// 자동로그인 end ---------------------------------------
}
// 첫방문 쿠키
// 1년간 저장
if (!get_cookie("ck_first_call")) set_cookie("ck_first_call", $g4[server_time], 86400 * 365);
if (!get_cookie("ck_first_referer")) set_cookie("ck_first_referer", $_SERVER[HTTP_REFERER], 86400 * 365);
// 회원이 아니라면 권한을 방문객 권한으로 함
if (!($member['mb_id']))
$member['mb_level'] = 1;
else
$member['mb_dir'] = substr($member['mb_id'],0,2);
//$member['mb_level_title'] = $g4['member_level'][$member['mb_level']]; // 권한명
$write_table = "";
if (isset($bo_table)) {
$board = sql_fetch(" select * from {$g4['board_table']} where bo_table = '$bo_table' ");
if ($board['bo_table']) {
$gr_id = $board['gr_id'];
$write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
//$comment_table = $g4['write_prefix'] . $bo_table . $g4['comment_suffix']; // 코멘트 테이블 전체이름
if ($wr_id)
$write = sql_fetch(" select * from $write_table where wr_id = '$wr_id' ");
}
}
if (isset($gr_id))
$group = sql_fetch(" select * from {$g4['group_table']} where gr_id = '$gr_id' ");

// 회원, 비회원 구분
$is_member = $is_guest = false;
if ($member['mb_id'])
$is_member = true;
else
$is_guest = true;

$is_admin = is_admin($member['mb_id']);
if ($is_admin != "super") {
// 접근가능 IP
$cf_possible_ip = trim($config['cf_possible_ip']);
if ($cf_possible_ip) {
$is_possible_ip = false;
$pattern = explode("\n", $cf_possible_ip);
for ($i=0; $i<count($pattern); $i++) {
$pattern[$i] = trim($pattern[$i]);
if (empty($pattern[$i]))
continue;
//$pat = "/({$pattern[$i]})/";
$pattern[$i] = str_replace(".", "\.", $pattern[$i]);
$pat = "/^{$pattern[$i]}/";
$is_possible_ip = preg_match($pat, $_SERVER['REMOTE_ADDR']);
if ($is_possible_ip)
break;
}
if (!$is_possible_ip)
die ("접근이 가능하지 않습니다.");
}
// 접근차단 IP
$is_intercept_ip = false;
$pattern = explode("\n", trim($config['cf_intercept_ip']));
for ($i=0; $i<count($pattern); $i++) {
$pattern[$i] = trim($pattern[$i]);
if (empty($pattern[$i]))
continue;
$pattern[$i] = str_replace(".", "\.", $pattern[$i]);
$pat = "/^{$pattern[$i]}/";
$is_intercept_ip = preg_match($pat, $_SERVER['REMOTE_ADDR']);
if ($is_intercept_ip)
die ("접근 불가합니다.");
}
}
// 스킨경로
$board_skin_path = '';
if (isset($board['bo_skin']))
$board_skin_path = "{$g4['path']}/skin/board/{$board['bo_skin']}"; // 게시판 스킨 경로
// 방문자수의 접속을 남김
include_once("{$g4['bbs_path']}/visit_insert.inc.php");

// common.php 파일을 수정할 필요가 없도록 확장합니다.
$tmp = dir("$g4[path]/extend");
while ($entry = $tmp->read()) {
// php 파일만 include 함
if (preg_match("/(\.php)$/i", $entry))
include_once("$g4[path]/extend/$entry");
}
?>

이 질문에 댓글 쓰기 :

답변 2

답변을 작성하시기 전에 로그인 해주세요.
전체 37
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT