declare function move to top
This commit is contained in:
parent
e63d31aa2d
commit
86a086139c
3 changed files with 97 additions and 77 deletions
3
AvocadoEdition_Light/addons/sample/sample.addon.php
Normal file
3
AvocadoEdition_Light/addons/sample/sample.addon.php
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
if (!defined("__ADVDIR__"))
|
||||||
|
exit();
|
||||||
3
AvocadoEdition_Light/addons/sample/sample.config.php
Normal file
3
AvocadoEdition_Light/addons/sample/sample.config.php
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
if (!defined("_GNUBOARD_"))
|
||||||
|
exit();
|
||||||
|
|
@ -12,7 +12,6 @@ if (!defined('G5_SET_TIME_LIMIT')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@set_time_limit(G5_SET_TIME_LIMIT);
|
@set_time_limit(G5_SET_TIME_LIMIT);
|
||||||
define("__ADVDIR__", __DIR__);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* func(...$args) 지원을 위해 최소 버전이 gnuboard5 최소인 5.2.17 보다 높게 설정되었습니다.
|
* func(...$args) 지원을 위해 최소 버전이 gnuboard5 최소인 5.2.17 보다 높게 설정되었습니다.
|
||||||
|
|
@ -26,45 +25,6 @@ if (version_compare(PHP_VERSION, '5.6.0', '<')) {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
include_once __DIR__ . "/classes/event_handler.php";
|
|
||||||
|
|
||||||
$extra_headers = [
|
|
||||||
'HTTP_X_REAL_IP',
|
|
||||||
'HTTP_X_FORWARDED_HOST',
|
|
||||||
'HTTP_X_FORWARDED_PROTO',
|
|
||||||
'HTTP_X_FORWARDED_SSL',
|
|
||||||
];
|
|
||||||
|
|
||||||
// filter for dynamic variables
|
|
||||||
$var_filter = [
|
|
||||||
'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'
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($var_filter as $val) {
|
|
||||||
if (array_key_exists($val, $_GET) && isset($_GET[$val])) {
|
|
||||||
unset($_GET[$val]);
|
|
||||||
}
|
|
||||||
if (array_key_exists($val, $_POST) && isset($_POST[$val])) {
|
|
||||||
unset($_POST[$val]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load require class and others
|
* Load require class and others
|
||||||
* @param mixed $base_dir
|
* @param mixed $base_dir
|
||||||
|
|
@ -152,44 +112,37 @@ function get_embed_file($type, $path, ...$args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
$_system = new stdClass;
|
* get gnuboard path
|
||||||
$_system->classes = load_libs(__DIR__ . "/classes", "class");
|
* @return string[]
|
||||||
$_system->addons = load_libs(__DIR__ . "/addons", "addon");
|
*/
|
||||||
// $_system->modules = load_libs(__DIR__ . "/modules", "model");
|
|
||||||
// $_system->modules = load_libs(__DIR__ . "/modules");
|
|
||||||
|
|
||||||
function g5_path()
|
function g5_path()
|
||||||
{
|
{
|
||||||
$result['path'] = str_replace('\\', '/', dirname(__FILE__));
|
$result = [];
|
||||||
$tilde_remove = preg_replace('/^\/\~[^\/]+(.*)$/', '$1', $_SERVER['SCRIPT_NAME']);
|
$result['path'] = str_replace('\\', '/', __DIR__);
|
||||||
$document_root = str_replace($tilde_remove, '', $_SERVER['SCRIPT_FILENAME']);
|
|
||||||
$root = str_replace($document_root, '', $result['path']);
|
$script_name = $_SERVER['SCRIPT_NAME'];
|
||||||
$port = $_SERVER['SERVER_PORT'] != 80 ? ':' . $_SERVER['SERVER_PORT'] : '';
|
$script_filename = $_SERVER['SCRIPT_FILENAME'];
|
||||||
$http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://';
|
$document_root = substr($script_filename, 0, -strlen($script_name));
|
||||||
$user = str_replace(str_replace($document_root, '', $_SERVER['SCRIPT_FILENAME']), '', $_SERVER['SCRIPT_NAME']);
|
|
||||||
|
$root = substr($result['path'], strlen($document_root));
|
||||||
|
|
||||||
|
$port = ($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443)
|
||||||
|
? ':' . $_SERVER['SERVER_PORT']
|
||||||
|
: '';
|
||||||
|
|
||||||
|
$is_https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
|
||||||
|
$http = $is_https ? 'https://' : 'http://';
|
||||||
|
|
||||||
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
|
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
|
||||||
if (isset($_SERVER['HTTP_HOST']) && preg_match('/:[0-9]+$/', $host))
|
$host = preg_replace('/:\d+$/', '', $host);
|
||||||
$host = preg_replace('/:[0-9]+$/', '', $host);
|
|
||||||
$host = preg_replace("/[\<\>\'\"\\\'\\\"\%\=\(\)\/\^\*]/", '', $host);
|
$host = preg_replace("/[\<\>\'\"\\\'\\\"\%\=\(\)\/\^\*]/", '', $host);
|
||||||
$result['url'] = $http . $host . $port . $user . $root;
|
|
||||||
|
$result['url'] = $http . $host . $port . $root;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
$g5_path = g5_path();
|
|
||||||
|
|
||||||
include_once $g5_path['path'] . '/config.php'; // 설정 파일
|
|
||||||
|
|
||||||
// arc: 이 이벤트는 before 가 없습니다.
|
|
||||||
EventHandler::triggerEvent("gnuboard.loadlibs.after", $_system);
|
|
||||||
|
|
||||||
unset($g5_path);
|
|
||||||
|
|
||||||
// Cloudflare 환경을 고려한 https 사용여부
|
|
||||||
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === "https") {
|
|
||||||
$_SERVER['HTTPS'] = 'on';
|
|
||||||
}
|
|
||||||
|
|
||||||
// multi-dimensional array에 사용자지정 함수적용
|
// multi-dimensional array에 사용자지정 함수적용
|
||||||
function array_map_deep($fn, $array)
|
function array_map_deep($fn, $array)
|
||||||
{
|
{
|
||||||
|
|
@ -220,14 +173,76 @@ function sql_escape_string($str)
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
// SQL Injection 등으로 부터 보호를 위해 sql_escape_string() 적용
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
function strip_slashes_deep($value)
|
function strip_slashes_deep($value)
|
||||||
{
|
{
|
||||||
return is_array($value) ? array_map('strip_slashes_deep', $value) : stripslashes($value);
|
return is_array($value) ? array_map('strip_slashes_deep', $value) : stripslashes($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
include_once __DIR__ . "/classes/event_handler.php";
|
||||||
|
|
||||||
|
$extra_headers = [
|
||||||
|
'HTTP_X_REAL_IP',
|
||||||
|
'HTTP_X_FORWARDED_HOST',
|
||||||
|
'HTTP_X_FORWARDED_PROTO',
|
||||||
|
'HTTP_X_FORWARDED_SSL',
|
||||||
|
];
|
||||||
|
|
||||||
|
// filter for dynamic variables
|
||||||
|
$var_filter = [
|
||||||
|
'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'
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($var_filter as $val) {
|
||||||
|
if (array_key_exists($val, $_GET) && isset($_GET[$val])) {
|
||||||
|
unset($_GET[$val]);
|
||||||
|
}
|
||||||
|
if (array_key_exists($val, $_POST) && isset($_POST[$val])) {
|
||||||
|
unset($_POST[$val]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$g5_path = g5_path();
|
||||||
|
|
||||||
|
// gnuboard5 configuration file
|
||||||
|
include_once $g5_path['path'] . '/config.php';
|
||||||
|
|
||||||
|
$_system = new stdClass;
|
||||||
|
$_system->g5_path = $g5_path;
|
||||||
|
$_system->classes = load_libs(__DIR__ . "/classes", "class");
|
||||||
|
|
||||||
|
define("__ADVDIR__", __DIR__);
|
||||||
|
|
||||||
|
$_system->addons = load_libs(__DIR__ . "/addons", "addon");
|
||||||
|
// future update... maybe
|
||||||
|
// $_system->modules = load_libs(__DIR__ . "/modules", "model");
|
||||||
|
// $_system->modules = load_libs(__DIR__ . "/modules");
|
||||||
|
|
||||||
|
// arc: 이 이벤트는 before 가 없습니다.
|
||||||
|
EventHandler::triggerEvent("gnuboard.loadlibs.after", $_system);
|
||||||
|
|
||||||
|
unset($g5_path);
|
||||||
|
|
||||||
|
// Cloudflare 환경을 고려한 https 사용여부
|
||||||
|
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === "https") {
|
||||||
|
$_SERVER['HTTPS'] = 'on';
|
||||||
|
}
|
||||||
|
|
||||||
// magic_quotes_gpc 에 의한 backslashes 제거
|
// magic_quotes_gpc 에 의한 backslashes 제거
|
||||||
if (version_compare(PHP_VERSION, '7.0.0', '<')) {
|
if (version_compare(PHP_VERSION, '7.0.0', '<')) {
|
||||||
if (version_compare(PHP_VERSION, '5.6.0', '>=')) {
|
if (version_compare(PHP_VERSION, '5.6.0', '>=')) {
|
||||||
|
|
@ -247,7 +262,6 @@ $_POST = array_map_deep(G5_ESCAPE_FUNCTION, $_POST);
|
||||||
$_GET = array_map_deep(G5_ESCAPE_FUNCTION, $_GET);
|
$_GET = array_map_deep(G5_ESCAPE_FUNCTION, $_GET);
|
||||||
$_COOKIE = array_map_deep(G5_ESCAPE_FUNCTION, $_COOKIE);
|
$_COOKIE = array_map_deep(G5_ESCAPE_FUNCTION, $_COOKIE);
|
||||||
$_REQUEST = array_map_deep(G5_ESCAPE_FUNCTION, $_REQUEST);
|
$_REQUEST = array_map_deep(G5_ESCAPE_FUNCTION, $_REQUEST);
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
// PHP 4.1.0 부터 지원됨
|
// PHP 4.1.0 부터 지원됨
|
||||||
// php.ini 의 register_globals=off 일 경우
|
// php.ini 의 register_globals=off 일 경우
|
||||||
|
|
@ -773,8 +787,8 @@ define('G5_DEVICE_BUTTON_DISPLAY', $set_device);
|
||||||
if (G5_IS_MOBILE) {
|
if (G5_IS_MOBILE) {
|
||||||
$g5['mobile_path'] = G5_PATH . '/' . $g5['mobile_dir'];
|
$g5['mobile_path'] = G5_PATH . '/' . $g5['mobile_dir'];
|
||||||
}
|
}
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
|
//==============================================================================
|
||||||
$board_skin_path = get_skin_path('board', $board['bo_skin']);
|
$board_skin_path = get_skin_path('board', $board['bo_skin']);
|
||||||
$board_skin_url = get_skin_url('board', $board['bo_skin']);
|
$board_skin_url = get_skin_url('board', $board['bo_skin']);
|
||||||
$member_skin_path = get_skin_path('member', $config['cf_member_skin']);
|
$member_skin_path = get_skin_path('member', $config['cf_member_skin']);
|
||||||
|
|
@ -787,7 +801,6 @@ $connect_skin_path = get_skin_path('connect', $config['cf_connect_skin']);
|
||||||
$connect_skin_url = get_skin_url('connect', $config['cf_connect_skin']);
|
$connect_skin_url = get_skin_url('connect', $config['cf_connect_skin']);
|
||||||
$faq_skin_path = get_skin_path('faq', $config['cf_faq_skin']);
|
$faq_skin_path = get_skin_path('faq', $config['cf_faq_skin']);
|
||||||
$faq_skin_url = get_skin_url('faq', $config['cf_faq_skin']);
|
$faq_skin_url = get_skin_url('faq', $config['cf_faq_skin']);
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
// 방문자수의 접속을 남김
|
// 방문자수의 접속을 남김
|
||||||
|
|
@ -812,6 +825,7 @@ if (!empty($extend_file) && is_array($extend_file)) {
|
||||||
include_once G5_EXTEND_PATH . '/' . $file;
|
include_once G5_EXTEND_PATH . '/' . $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($extend_file);
|
unset($extend_file);
|
||||||
|
|
||||||
// ----- 테마 추가기능 불러오기 (확장)
|
// ----- 테마 추가기능 불러오기 (확장)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue