경로 수정 작업 중

This commit is contained in:
chicpro
2013-03-14 17:56:20 +09:00
parent 8ba59fe9b0
commit 1a60978568
1212 changed files with 39023 additions and 33180 deletions

View File

@ -2,185 +2,40 @@
/*******************************************************************************
** 공통 변수, 상수, 코드
*******************************************************************************/
error_reporting(E_ALL ^ E_NOTICE);
//error_reporting(E_ALL ^ E_NOTICE);
//error_reporting(E_ALL & ~E_NOTICE);
//error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
// 보안설정이나 프레임이 달라도 쿠키가 통하도록 설정
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 (!defined('G4_SET_TIME_LIMIT')) define('G4_SET_TIME_LIMIT', 0);
@set_time_limit(G4_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() 적용
//==============================================================================
// php.ini 의 magic_quotes_gpc 값이 Off 인 경우 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);
// http://kr.php.net/manual/en/function.get-magic-quotes-gpc.php#97783
//------------------------------------------------------------------------------
if (!get_magic_quotes_gpc()) {
$escape_function = 'addslashes($value)';
$addslashes_deep = create_function('&$value, $fn', '
if (is_string($value)) {
$value = ' . $escape_function . ';
} else if (is_array($value)) {
foreach ($value as &$v) $fn($v, $fn);
}
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 <chregu@bitflux.ch> |
// +----------------------------------------------------------------------+
// Fix &entity\n;
$data = str_replace(array('&amp;','&lt;','&gt;'), array('&amp;amp;','&amp;lt;','&amp;gt;'), $data);
$data = preg_replace('/(&#*\w+)[\x00-\x20]+;/', '$1;', $data);
$data = preg_replace('/(&#x*[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;
');
// Escape data
$addslashes_deep($_POST, $addslashes_deep);
$addslashes_deep($_GET, $addslashes_deep);
$addslashes_deep($_COOKIE, $addslashes_deep);
$addslashes_deep($_REQUEST, $addslashes_deep);
}
$_GET = xss_clean($_GET);
//==========================================================================================================================
//==============================================================================
//==========================================================================================================================
@ -211,223 +66,286 @@ $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 변수는 해제
function g4_path()
{
$path = dirname(__FILE__); // 예) /home/sir/www/g4s
$linux_dir = str_replace("\\", "/", $path); // 예) /home/sir/www/g4s
$document_root = str_replace("\\", "/", $_SERVER['DOCUMENT_ROOT']); // 예) /home/sir/www
$base_dir = preg_replace('#^'.$document_root.'#i', '', $linux_dir); // 예) /g4s
$port = $_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : '';
$http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') ? 's' : '') . '://';
$result = array();
$result['path'] = $path;
$result['url'] = $http.$_SERVER['SERVER_NAME'].$port.$base_dir;
$result['curr_url'] = $http.$_SERVER['SERVER_NAME'].$port.$_SERVER['PHP_SELF'];
$result['curr_uri'] = $result['curr_url'] . ($_SERVER['QUERY_STRING'] ? '?'.$_SERVER['QUERY_STRING'] : '');
return $result;
}
$g4_path = g4_path();
include_once($g4_path['path'].'/config.php'); // 설정 파일
unset($g4_path);
include_once("$g4[path]/lib/constant.php"); // 상수 정의
include_once("$g4[path]/config.php"); // 설정 파일
include_once("$g4[path]/lib/common.lib.php"); // 공통 라이브러리
//header("Content-Type: text/html; charset={$g4['charset']}");
// 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>");
//------------------------------------------------------------------------------
$dbconfig_file = G4_DATA_PATH.'/'.G4_DBCONFIG_FILE;
if (file_exists($dbconfig_file)) {
include_once($dbconfig_file);
include_once(G4_LIB_PATH.'/common.lib.php'); // 공통 라이브러리
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;
$connect_db = sql_connect(G4_MYSQL_HOST, G4_MYSQL_USER, G4_MYSQL_PASSWORD) or die('MySQL Connect Error!!!');
$select_db = sql_select_db(G4_MYSQL_DB, $connect_db) or die('MySQL DB Error!!!');
@mysql_query(" set names utf8 ");
} else {
?>
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>오류! 그누보드4S 설치하기</title>
<style>
body {background:#f7f7f2}
h1 {margin:50px auto 30px;width:540px;color:#ff3061;font-size:1.4em}
div {margin:0 auto;padding:20px;width:500px;border:1px solid #eee;background:#fff}
div p {line-height:1.5em}
div a {display:block;margin:50px auto 10px;width:170px;text-align:center}
</style>
</head>
<body>
<h1>오류가 있습니다.</h1>
<div>
<p>다음 파일을 찾을 수 없습니다.</p>
<ul>
<li><strong><?=$dbconfig_file?></strong></li>
</ul>
<p>프로그램 설치 후 실행하시기 바랍니다.</p>
<a href="<?=G4_URL?>/install/">그누보드4S 설치하기</a>
</div>
</body>
</html>
<?
exit;
}
unset($my); // DB 설정값을 클리어 해줍니다.
//==============================================================================
//print_r2($GLOBALS);
$_SERVER['PHP_SELF'] = htmlentities($_SERVER['PHP_SELF']);
//-------------------------------------------
//==============================================================================
// SESSION 설정
//-------------------------------------------
//------------------------------------------------------------------------------
ini_set("session.use_trans_sid", 0); // PHPSESSID를 자동으로 넘기지 않음
ini_set("url_rewriter.tags",""); // 링크에 PHPSESSID가 따라다니는것을 무력화함 (해뜰녘님께서 알려주셨습니다.)
session_save_path("{$g4['path']}/data/session");
session_save_path(G4_DATA_PATH.'/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] ");
$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_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);
*/
// 보안서버주소 설정
if (G4_HTTPS_DOMAIN) {
define('G4_HTTPS_URL', G4_HTTPS_DOMAIN);
define('G4_HTTPS_BBS_URL', G4_HTTPS_DOMAIN.'/'.G4_BBS_DIR);
} else {
define('G4_HTTPS_URL', G4_URL);
define('G4_HTTPS_BBS_URL', G4_BBS_URL);
}
//==============================================================================
// Mobile 모바일 설정
// 쿠키에 저장된 값이 모바일이라면 브라우저 상관없이 모바일로 실행
// 그렇지 않다면 브라우저의 HTTP_USER_AGENT 에 따라 모바일 결정
// G4_MOBILE_AGENT : config.php 에서 선언
//------------------------------------------------------------------------------
$is_mobile = false;
if ($_REQUEST['device']=='pc')
$is_mobile = false;
else if ($_REQUEST['device']=='mobile')
$is_mobile = true;
else if (isset($_SESSION['ss_is_mobile']))
$is_mobile = $_SESSION['ss_is_mobile'];
else if (is_mobile())
$is_mobile = true;
$_SESSION['ss_is_mobile'] = $is_mobile;
define('G4_IS_MOBILE', $is_mobile);
if (G4_IS_MOBILE) {
include_once(G4_LIB_PATH.'/mobile.lib.php'); // 모바일 전용 라이브러리
$g4['mobile_path'] = G4_PATH.'/'.$g4['mobile_dir'];
}
//==============================================================================
// 4.00.03 : [보안관련] PHPSESSID 가 틀리면 로그아웃한다.
if ($_REQUEST['PHPSESSID'] && $_REQUEST['PHPSESSID'] != session_id())
goto_url("{$g4['bbs_path']}/logout.php");
if (isset($_REQUEST['PHPSESSID']) && $_REQUEST['PHPSESSID'] != session_id())
goto_url(G4_BBS_URL.'/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);
$qstr = '';
if (isset($_REQUEST['sca'])) {
$sca = escape_trim($_REQUEST['sca']);
if ($sca)
$qstr .= '&amp;sca=' . urlencode($sca);
} else {
$sca = '';
}
if (isset($sfl)) {
$sfl = mysql_real_escape_string($sfl);
// 크롬에서만 실행되는 XSS 취약점 보완
// 코드 $sfl 변수값에서 < > ' " % = ( ) 공백 문자를 없앤다.
$sfl = preg_replace("/[\<\>\'\"\%\=\(\)\s]/", "", $sfl);
//$sfl = preg_replace("/[^\w\,\|]+/", "", $sfl);
$qstr .= '&sfl=' . urlencode($sfl); // search field (검색 필드)
if (isset($_REQUEST['sfl'])) {
$sfl = escape_trim($_REQUEST['sfl']);
if ($sfl)
$qstr .= '&amp;sfl=' . urlencode($sfl); // search field (검색 필드)
} else {
$sfl = '';
}
if (isset($stx)) { // search text (검색어)
$stx = mysql_real_escape_string($stx);
$qstr .= '&stx=' . urlencode($stx);
if (isset($_REQUEST['stx'])) { // search text (검색어)
$stx = escape_trim($_REQUEST['stx']);
if ($stx)
$qstr .= '&amp;stx=' . urlencode($stx);
} else {
$stx = '';
}
if (isset($sst)) {
$sst = mysql_real_escape_string($sst);
$qstr .= '&sst=' . urlencode($sst); // search sort (검색 정렬 필드)
if (isset($_REQUEST['sst'])) {
$sst = escape_trim($_REQUEST['sst']);
if ($sst)
$qstr .= '&amp;sst=' . urlencode($sst); // search sort (검색 정렬 필드)
} else {
$sst = '';
}
if (isset($sod)) { // search order (검색 오름, 내림차순)
$sod = preg_match("/^(asc|desc)$/i", $sod) ? $sod : "";
$qstr .= '&sod=' . urlencode($sod);
if (isset($_REQUEST['sod'])) { // search order (검색 오름, 내림차순)
$sod = preg_match("/^(asc|desc)$/i", $sod) ? $sod : '';
if ($sod)
$qstr .= '&amp;sod=' . urlencode($sod);
} else {
$sod = '';
}
if (isset($sop)) { // search operator (검색 or, and 오퍼레이터)
$sop = preg_match("/^(or|and)$/i", $sop) ? $sop : "";
$qstr .= '&sop=' . urlencode($sop);
if (isset($_REQUEST['sop'])) { // search operator (검색 or, and 오퍼레이터)
$sop = preg_match("/^(or|and)$/i", $sop) ? $sop : '';
if ($sop)
$qstr .= '&amp;sop=' . urlencode($sop);
} else {
$sop = '';
}
if (isset($spt)) { // search part (검색 파트[구간])
if (isset($_REQUEST['spt'])) { // search part (검색 파트[구간])
$spt = (int)$spt;
$qstr .= '&spt=' . urlencode($spt);
if ($spt)
$qstr .= '&amp;spt=' . urlencode($spt);
} else {
$spt = '';
}
if (isset($page)) { // 리스트 페이지
$page = (int)$page;
$qstr .= '&page=' . urlencode($page);
if (isset($_REQUEST['page'])) { // 리스트 페이지
$page = (int)$_REQUEST['page'];
if ($page)
$qstr .= '&amp;page=' . urlencode($page);
} else {
$page = '';
}
if ($wr_id) {
$wr_id = (int)$wr_id;
if (isset($_REQUEST['w'])) {
$w = substr($w, 0, 2);
} else {
$w = '';
}
if ($bo_table) {
$bo_table = preg_match("/^[a-zA-Z0-9_]+$/", $bo_table) ? $bo_table : "";
if (isset($_REQUEST['wr_id'])) {
$wr_id = (int)$_REQUEST['wr_id'];
} else {
$wr_id = 0;
}
if (isset($_REQUEST['bo_table'])) {
$bo_table = escape_trim($_REQUEST['bo_table']);
$bo_table = substr($bo_table, 0, 20);
} else {
$bo_table = '';
}
// URL ENCODING
if (isset($url)) {
if (isset($_REQUEST['url'])) {
$url = escape_trim($_REQUEST['url']);
$urlencode = urlencode($url);
} else {
$url = '';
$urlencode = urlencode(escape_trim($_SERVER['REQUEST_URI']));
}
else {
// 2008.01.25 Cross Site Scripting 때문에 수정
//$urlencode = $_SERVER['REQUEST_URI'];
$urlencode = urlencode($_SERVER[REQUEST_URI]);
if (isset($_REQUEST['gr_id'])) {
$gr_id = escape_trim($_REQUEST['gr_id']);
} else {
$gr_id = '';
}
//===================================
// 자동로그인 부분에서 첫로그인에 포인트 부여하던것을 로그인중일때로 변경하면서 코드도 대폭 수정하였습니다.
if ($_SESSION['ss_mb_id']) // 로그인중이라면
{
if ($_SESSION['ss_mb_id']) { // 로그인중이라면
$member = get_member($_SESSION['ss_mb_id']);
// 오늘 처음 로그인 이라면
if (substr($member['mb_today_login'], 0, 10) != $g4['time_ymd'])
{
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']);
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 = " 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
{
} else {
// 자동로그인 ---------------------------------------
// 회원아이디가 쿠키에 저장되어 있다면 (3.27)
if ($tmp_mb_id = get_cookie("ck_mb_id"))
{
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'])
{
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)
{
$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'])) )
{
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);
set_session('ss_mb_id', $tmp_mb_id);
// 페이지를 재실행
echo "<script type='text/javascript'> window.location.reload(); </script>";
@ -441,45 +359,41 @@ else
// 자동로그인 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 = array();
$write_table = "";
if (isset($bo_table)) {
if ($bo_table) {
$board = sql_fetch(" select * from {$g4['board_table']} where bo_table = '$bo_table' ");
if ($board['bo_table']) {
set_cookie("ck_bo_table", $board['bo_table'], 86400 * 1);
$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)
if (isset($wr_id) && $wr_id)
$write = sql_fetch(" select * from $write_table where wr_id = '$wr_id' ");
}
}
if (isset($gr_id))
if ($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_admin = '';
if ($member['mb_id']) {
$is_member = true;
else
$is_admin = is_admin($member['mb_id']);
$member['mb_dir'] = substr($member['mb_id'],0,2);
} else {
$is_guest = true;
$member['mb_id'] = '';
$member['mb_level'] = 1; // 비회원의 경우 회원레벨을 가장 낮게 설정
}
$is_admin = is_admin($member['mb_id']);
if ($is_admin != "super") {
if ($is_admin != 'super') {
// 접근가능 IP
$cf_possible_ip = trim($config['cf_possible_ip']);
if ($cf_possible_ip) {
@ -517,20 +431,55 @@ if ($is_admin != "super") {
}
}
//==============================================================================
// 스킨경로
$board_skin_path = '';
if (isset($board['bo_skin']))
$board_skin_path = "{$g4['path']}/skin/board/{$board['bo_skin']}"; // 게시판 스킨 경로
//------------------------------------------------------------------------------
if (G4_IS_MOBILE) {
$board_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/board/'.$board['bo_mobile_skin'];
$board_skin_url = G4_MOBILE_URL .'/'.G4_SKIN_DIR.'/board/'.$board['bo_mobile_skin'];
$member_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/member/'.$config['cf_mobile_member_skin'];
$member_skin_url = G4_MOBILE_URL .'/'.G4_SKIN_DIR.'/member/'.$config['cf_mobile_member_skin'];
$new_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/new/'.$config['cf_mobile_new_skin'];
$search_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/search/'.$config['cf_mobile_search_skin'];
$connect_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/connect/'.$config['cf_mobile_connect_skin'];
$poll_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/poll/basic';
if (isset($_GET['skin_dir']))
$poll_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/poll/'.$_GET['skin_dir'];
} else {
$board_skin_path = G4_SKIN_PATH.'/board/'.$board['bo_skin'];
$board_skin_url = G4_SKIN_URL .'/board/'.$board['bo_skin'];
$member_skin_path = G4_SKIN_PATH.'/member/'.$config['cf_member_skin'];
$member_skin_url = G4_SKIN_URL .'/member/'.$config['cf_member_skin'];
$new_skin_path = G4_SKIN_PATH.'/new/'.$config['cf_new_skin'];
$search_skin_path = G4_SKIN_PATH.'/search/'.$config['cf_search_skin'];
$connect_skin_path = G4_SKIN_PATH.'/connect/'.$config['cf_connect_skin'];
$poll_skin_path = G4_SKIN_PATH.'/poll/basic';
if (isset($_GET['skin_dir']))
$poll_skin_path = G4_SKIN_PATH.'/poll/'.$_GET['skin_dir'];
}
//==============================================================================
// 방문자수의 접속을 남김
include_once("{$g4['bbs_path']}/visit_insert.inc.php");
include_once(G4_BBS_PATH.'/visit_insert.inc.php');
// common.php 파일을 수정할 필요가 없도록 확장합니다.
$tmp = dir("$g4[path]/extend");
$tmp = dir(G4_EXTEND_PATH);
while ($entry = $tmp->read()) {
// php 파일만 include 함
if (preg_match("/(\.php)$/i", $entry))
include_once("$g4[path]/extend/$entry");
include_once(G4_EXTEND_PATH.'/'.$entry);
}
// 자바스크립트에서 go(-1) 함수를 쓰면 폼값이 사라질때 해당 폼의 상단에 사용하면
// 캐쉬의 내용을 가져옴. 완전한지는 검증되지 않음
header('Content-Type: text/html; charset=utf-8');
$gmnow = gmdate('D, d M Y H:i:s') . ' GMT';
header('Expires: 0'); // rfc2616 - Section 14.21
header('Last-Modified: ' . $gmnow);
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header('Pragma: no-cache'); // HTTP/1.0
?>