= '02:00' && date('H:i') <= '04:00'){ include('update.php'); exit; }*/ # Load library require_once((IS_HOSTING ? '' : '../').'libs/lib.php'); # Load configure file require_once((IS_HOSTING ? '' : '../').'pages/'.$SUB_DOMAIN.'/config/config.php'); define(SITE_HEADER.'URL_PUBLIC', constant(SITE_HEADER.'URL').(IS_HOSTING ? 'public/' : '')); # Set VIEW_NAME, SUB_NAME $uri = explode('/', $_SERVER['REQUEST_URI']); $params = explode('?', end($uri)); if(count($uri) > 2 && strlen($uri[1]) > 0){ $VIEW_NAME = $uri[1]; for($i=2; $i 1 && empty(end($params))) ? 'index' : end($uri); } else $SUB_NAME = empty($params[0]) ? 'index' : $uri[1]; # Seperate VIEW_NAME parameters $params = explode('?', $VIEW_NAME); if(count($params) > 1 && strlen($params[1]) > 0) $VIEW_NAME = $params[0]; # Seperate SUB_NAME parameters $params = explode('?', $SUB_NAME); if(count($params) > 1 && strlen($params[1]) > 0) $SUB_NAME = $params[0]; # Set session if(!isset($_SESSION['a_sid'])){ $_SESSION['a_lang'] = 'ko'; $_SESSION['a_no'] = 0; $_SESSION['a_sid'] = createRID(); $_SESSION['a_type'] = 'guest'; $_SESSION['a_level'] = 0; $_SESSION['a_ip'] = $_SERVER['REMOTE_ADDR']; $ip_e = explode('.', $_SESSION['a_ip']); $_SESSION['a_ip_e'] = $ip_e[0].'.'.$ip_e[1].'.x.'.$ip_e[3]; preg_match_all('@[0-9]@', sha1($_SESSION['a_ip']), $nip); $_SESSION['a_nickname'] = lang('Guest').$nip[0][0].$nip[0][1].$nip[0][2].$nip[0][3].$nip[0][4]; $agent = '/(iPod|iPhone|Android|BlackBerry|SymbianOS|SCH-M\d+|Opera Mini|Windows CE|Nokia|SonyEricsson|webOS|PalmOS)/'; if(preg_match($agent, $_SERVER['HTTP_USER_AGENT'])) $_SESSION['a_device'] = 'mobile'; else $_SESSION['a_device'] = 'pc'; $_SESSION['a_img'] = 'user/anonymous.gif'; } # Auto signin if(isset($_COOKIE['h']) && isset($_COOKIE['s']) && isset($_COOKIE['c']) && $_SESSION['a_type'] == 'guest'){ # Check checksum value if(md5($_COOKIE['s'].sha1($_COOKIE['h'])) == $_COOKIE['c']){ $DB_HEADER = $_COOKIE['h']; $db = new Database($DB_HEADER, 'account'); $db_a = $db->select('all', array('sid' => $_COOKIE['s']), true); # Check auto signin settings if($db_a['auto_signin'] == 1 && !empty($db_a)){ $_SESSION['a_no'] = $db_a['no']; $_SESSION['a_sid'] = $_COOKIE['s']; $_SESSION['a_uid'] = $db_a['uid']; $_SESSION['a_type'] = $db_a['type']; $_SESSION['a_level'] = $db_a['level']; $_SESSION['a_nickname'] = $db_a['nickname']; $_SESSION['a_img'] = $db_a['img']; } else{ unset($_SESSION['a_sid']); setcookie('h', '', time()-3600); setcookie('s', '', time()-3600); setcookie('c', '', time()-3600); } } else{ unset($_SESSION['a_sid']); setcookie('h', '', time()-3600); setcookie('s', '', time()-3600); setcookie('c', '', time()-3600); } } # Get Settings $db = new Database(constant(SITE_HEADER.'DB_HEADER')); $db_s = $db->getSettings(); if($db_s['site_status'] == 'deactive' && ($_SERVER['REMOTE_ADDR'] != '121.66.79.58' && $_SERVER['REMOTE_ADDR'] != '203.255.220.2')){ include_once((IS_HOSTING ? '' : '../').'error/'.(file_exists((IS_HOSTING ? '' : '../').'error/'.$SUB_DOMAIN.'_deactive.php') ? $SUB_DOMAIN.'_deactive.php' : '404.php')); exit; } # Get page $view_e = explode('/', $VIEW_NAME); $db->setTable('page'); if($view_e[0] == 'script') $DB_PAGE = $db->select('all', array('sub' => $SUB_DOMAIN, 'url' => substr($VIEW_NAME, 6).'/'.substr($SUB_NAME, 0, strlen($SUB_NAME)-3)), true); else $DB_PAGE = $db->select('all', array('sub' => $SUB_DOMAIN, 'url' => (empty($VIEW_NAME) ? '' : '/'.$VIEW_NAME).'/'.$SUB_NAME), true); if((empty($DB_PAGE) || $DB_PAGE['status'] == 'hide') && $view_e[0] != 'ajax' && $view_e[0] != 'script' && $view_e[0] != 'u'){ $ERROR_PAGE = 404; //echo 'sub: '.$SUB_DOMAIN.', url: '.substr($VIEW_NAME, 6).'/'.substr($SUB_NAME, 0, strlen($SUB_NAME)-3); include_once((IS_HOSTING ? '' : '../').'error/'.(file_exists((IS_HOSTING ? '' : '../').'error/'.$SUB_DOMAIN.'_'.$ERROR_PAGE.'.php') ? $SUB_DOMAIN.'_'.$ERROR_PAGE.'.php' : '404.php')); exit; } # Check permission if(($DB_PAGE['auth'] == 'user' && $_SESSION['a_type'] == 'guest') || ($DB_PAGE['auth'] == 'admin' && $_SESSION['a_type'] != 'admin') ){ if($_SESSION['a_type'] == 'guest') alertRedirect(lang('NeedSignin'), C_URL.'a/signin?u='.rawurlencode($_SERVER['REQUEST_URI'])); else alertRedirect(lang('WrongPermission'), $_SERVER['HTTP_REFERER']); exit; } if($DB_PAGE['level'] > $_SESSION['a_level']){ alertRedirect(lang('WrongPermission'), $_SERVER['HTTP_REFERER']); exit; } # Render page if($view_e[0] == 'ajax'){ $DONT_RENDER = true; header('Content-Type: application/json'); } else if($view_e[0] == 'script'){ header('Content-Type: application/javascript'); } else if($view_e[0] == 'u'){ } else{ $HEADER_NAME = 'header_default.php'; $FOOTER_NAME = 'footer_default.php'; } if($DB_PAGE['status'] == 'file' || $view_e[0] == 'ajax' || $view_e[0] == 'u'){ if($view_e[0] == 'script'){ if(file_exists((IS_HOSTING ? '' : '../').'pages/'.$SUB_DOMAIN.'/controllers/script_controller.php')) include_once((IS_HOSTING ? '' : '../').'pages/'.$SUB_DOMAIN.'/controllers/script_controller.php'); } else{ if(file_exists((IS_HOSTING ? '' : '../').'pages/'.$SUB_DOMAIN.'/controllers/'.$VIEW_NAME.'_controller.php')) include_once((IS_HOSTING ? '' : '../').'pages/'.$SUB_DOMAIN.'/controllers/'.$VIEW_NAME.'_controller.php'); } } if(!$DONT_RENDER){ $p = new Page($SUB_DOMAIN, $VIEW_NAME, $SUB_NAME, $HEADER_NAME, $FOOTER_NAME, $DB_PAGE); $p->renderPage(); } # Show error page if($ERROR_PAGE > 0){ if($view_e[0] == 'script' || $view_e[0] == 'ajax') echo json('WrongAccess'); else include_once((IS_HOSTING ? '' : '../').'error/'.(file_exists((IS_HOSTING ? '' : '../').'error/'.$SUB_DOMAIN.'_'.$ERROR_PAGE.'.php') ? $SUB_DOMAIN.'_'.$ERROR_PAGE.'.php' : '404.php')); } ?>