update lib/hook
This commit is contained in:
parent
42663073c5
commit
82f776b035
3 changed files with 2575 additions and 2061 deletions
326
AvocadoEdition_Light/lib/Hook/hook.class.php
Normal file
326
AvocadoEdition_Light/lib/Hook/hook.class.php
Normal file
|
|
@ -0,0 +1,326 @@
|
|||
<?php
|
||||
if (!defined('_GNUBOARD_'))
|
||||
exit;
|
||||
|
||||
/**
|
||||
* Library for handling hooks.
|
||||
*
|
||||
* @author Josantonius <hello@josantonius.com>
|
||||
* @copyright 2017 (c) Josantonius - PHP-Hook
|
||||
* @license https://opensource.org/licenses/MIT - The MIT License (MIT)
|
||||
* @link https://github.com/Josantonius/PHP-Hook
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hook handler.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Hook
|
||||
{
|
||||
/**
|
||||
* Instance id.
|
||||
*
|
||||
* @since 1.0.5
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected static $id = '0';
|
||||
|
||||
/**
|
||||
* Callbacks.
|
||||
*
|
||||
* @since 1.0.3
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $callbacks = array();
|
||||
|
||||
/**
|
||||
* Number of actions executed.
|
||||
*
|
||||
* @since 1.0.3
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $actions = array('count' => 0);
|
||||
|
||||
/**
|
||||
* Current action hook.
|
||||
*
|
||||
* @since 1.0.3
|
||||
*
|
||||
* @var string|false
|
||||
*/
|
||||
protected static $current = false;
|
||||
|
||||
/**
|
||||
* Method to use the singleton pattern and just create an instance.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $singleton = 'getInstance';
|
||||
|
||||
/**
|
||||
* Instances.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $instances = array();
|
||||
|
||||
/**
|
||||
* Get instance.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return object → instance
|
||||
*/
|
||||
// 이부분 수정
|
||||
/*
|
||||
public static function getInstance($id = '0')
|
||||
{
|
||||
self::$id = $id;
|
||||
if (isset(self::$instances[self::$id])) {
|
||||
return self::$instances[self::$id];
|
||||
}
|
||||
|
||||
return self::$instances[self::$id] = new self;
|
||||
}
|
||||
*/
|
||||
|
||||
public static function getInstance($id = '0')
|
||||
{
|
||||
self::$id = $id;
|
||||
if (isset(self::$instances[self::$id])) {
|
||||
return self::$instances[self::$id];
|
||||
}
|
||||
|
||||
$calledClass = get_called_class();
|
||||
|
||||
return self::$instances[self::$id] = new $calledClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach custom function to action hook.
|
||||
*
|
||||
* @since 1.0.3
|
||||
*
|
||||
* @param string $tag → action hook name
|
||||
* @param callable $func → function to attach to action hook
|
||||
* @param int $priority → order in which the action is executed
|
||||
* @param int $args → number of arguments accepted
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function addAction($tag, $func, $priority = 8, $args = 0)
|
||||
{
|
||||
$that = self::getInstance(self::$id);
|
||||
|
||||
$that->callbacks[$tag][$priority][] = array(
|
||||
'function' => $func,
|
||||
'arguments' => $args,
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add actions hooks from array.
|
||||
*
|
||||
* @since 1.0.3
|
||||
*
|
||||
* @param array $actions
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function addActions($actions)
|
||||
{
|
||||
foreach ($actions as $arguments) {
|
||||
call_user_func_array(array(__CLASS__, 'addAction'), $arguments);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run all hooks attached to the hook.
|
||||
*
|
||||
* By default it will look for getInstance method to use singleton
|
||||
* pattern and create a single instance of the class. If it does not
|
||||
* exist it will create a new object.
|
||||
*
|
||||
* @see setSingletonName() for change the method name.
|
||||
*
|
||||
* @since 1.0.3
|
||||
*
|
||||
* @param string $tag → action hook name
|
||||
* @param mixed $args → optional arguments
|
||||
* @param bool $remove → delete hook after executing actions
|
||||
*
|
||||
* @return returns the output of the last action or false
|
||||
*/
|
||||
public static function doAction($tag, $args = array(), $remove = true)
|
||||
{
|
||||
$that = self::getInstance(self::$id);
|
||||
|
||||
self::$current = $tag;
|
||||
|
||||
$that->actions['count']++;
|
||||
|
||||
if (!array_key_exists($tag, $that->actions)) {
|
||||
$that->actions[$tag] = 0;
|
||||
}
|
||||
|
||||
$that->actions[$tag]++;
|
||||
$actions = $that->getActions($tag, $remove);
|
||||
//asort($actions);
|
||||
// 이 부분 수정 priority 로 정렬 하려면 ksort를 써야함
|
||||
ksort($actions);
|
||||
|
||||
foreach ($actions as $priority) {
|
||||
foreach ($priority as $action) {
|
||||
$action = $that->runAction($action, $args);
|
||||
}
|
||||
}
|
||||
|
||||
self::$current = false;
|
||||
|
||||
return (isset($action)) ? $action : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set method name for use singleton pattern.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param string $method → singleton method name
|
||||
*/
|
||||
public static function setSingletonName($method)
|
||||
{
|
||||
$that = self::getInstance(self::$id);
|
||||
|
||||
$that->singleton = $method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current action hook.
|
||||
*
|
||||
* @since 1.0.3
|
||||
*
|
||||
* @return string|false → current action hook
|
||||
*/
|
||||
public static function current()
|
||||
{
|
||||
return self::$current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there is a certain action hook.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*
|
||||
* @param string $tag → action hook name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isAction($tag)
|
||||
{
|
||||
$that = self::getInstance(self::$id);
|
||||
|
||||
return isset($that->callbacks[$tag]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run action hook.
|
||||
*
|
||||
* @since 1.0.3
|
||||
*
|
||||
* @param string $action → action hook
|
||||
* @param int $args → arguments
|
||||
*
|
||||
* @return callable|false → returns the calling function
|
||||
*/
|
||||
protected function runAction($action, $args)
|
||||
{
|
||||
$function = $action['function'];
|
||||
$argsNumber = $action['arguments'];
|
||||
|
||||
$class = (isset($function[0])) ? $function[0] : false;
|
||||
$method = (isset($function[1])) ? $function[1] : false;
|
||||
|
||||
$args = $this->getArguments($argsNumber, $args);
|
||||
|
||||
if (!($class && $method) && function_exists($function)) {
|
||||
return call_user_func($function, $args);
|
||||
} elseif ($obj = call_user_func(array($class, $this->singleton))) {
|
||||
if ($obj !== false) {
|
||||
return call_user_func_array(array($obj, $method), $args);
|
||||
}
|
||||
} elseif (class_exists($class)) {
|
||||
$instance = new $class;
|
||||
|
||||
return call_user_func_array(array($instance, $method), $args);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get actions for hook
|
||||
*
|
||||
* @since 1.0.3
|
||||
*
|
||||
* @param string $tag → action hook name
|
||||
* @param bool $remove → delete hook after executing actions
|
||||
*
|
||||
* @return object|false → returns the calling function
|
||||
*/
|
||||
protected function getActions($tag, $remove)
|
||||
{
|
||||
if (isset($this->callbacks[$tag])) {
|
||||
$actions = $this->callbacks[$tag];
|
||||
if ($remove) {
|
||||
unset($this->callbacks[$tag]);
|
||||
}
|
||||
}
|
||||
|
||||
return (isset($actions)) ? $actions : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arguments for action.
|
||||
*
|
||||
* @since 1.0.3
|
||||
*
|
||||
* @param int $argsNumber → arguments number
|
||||
* @param mixed $arguments → arguments
|
||||
*
|
||||
* @return array → arguments
|
||||
*/
|
||||
protected function getArguments($argsNumber, $arguments)
|
||||
{
|
||||
if ($argsNumber == 1 && is_string($arguments)) {
|
||||
return array($arguments);
|
||||
} elseif ($argsNumber === count($arguments)) {
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $argsNumber; $i++) {
|
||||
if (array_key_exists($i, $arguments)) {
|
||||
$args[] = $arguments[$i];
|
||||
continue;
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
}
|
||||
167
AvocadoEdition_Light/lib/Hook/hook.extends.class.php
Normal file
167
AvocadoEdition_Light/lib/Hook/hook.extends.class.php
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
if (!defined('_GNUBOARD_'))
|
||||
exit;
|
||||
|
||||
class GML_Hook extends Hook
|
||||
{
|
||||
|
||||
protected $filters = array('count' => 0);
|
||||
|
||||
protected $callback_filters = array();
|
||||
|
||||
protected static $current_filter = false;
|
||||
|
||||
protected function runAction($action, $args)
|
||||
{
|
||||
$function = $action['function'];
|
||||
$argsNumber = $action['arguments'];
|
||||
|
||||
$class = (is_array($function) && isset($function[0])) ? $function[0] : false;
|
||||
$method = (is_array($function) && isset($function[1])) ? $function[1] : false;
|
||||
|
||||
$args = $this->getArguments($argsNumber, $args);
|
||||
|
||||
if (!($class && $method) && is_callable($function)) {
|
||||
return call_user_func_array($function, $args);
|
||||
} elseif ($obj = call_user_func(array($class, $this->singleton))) {
|
||||
if ($obj !== false) {
|
||||
return call_user_func_array(array($obj, $method), $args);
|
||||
}
|
||||
} elseif (class_exists($class)) {
|
||||
$instance = new $class;
|
||||
|
||||
return call_user_func_array(array($instance, $method), $args);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getFilters($tag, $remove)
|
||||
{
|
||||
if (isset($this->callback_filters[$tag])) {
|
||||
$filters = $this->callback_filters[$tag];
|
||||
if ($remove) {
|
||||
unset($this->callback_filters[$tag]);
|
||||
}
|
||||
}
|
||||
|
||||
return (isset($filters)) ? $filters : array();
|
||||
}
|
||||
|
||||
public static function get_properties($type, $is_callback = false)
|
||||
{
|
||||
|
||||
$that = self::getInstance(self::$id);
|
||||
|
||||
if ($type === 'event') {
|
||||
return $is_callback ? $that->callbacks : $that->actions;
|
||||
}
|
||||
|
||||
return $is_callback ? $that->callback_filters : $that->filters;
|
||||
}
|
||||
|
||||
public static function addFilter($tag, $func, $priority = 8, $args = 0)
|
||||
{
|
||||
$that = self::getInstance(self::$id);
|
||||
|
||||
$that->callback_filters[$tag][$priority][] = array(
|
||||
'function' => $func,
|
||||
'arguments' => $args,
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function apply_filters($tag, $args = array(), $remove = true)
|
||||
{
|
||||
$that = self::getInstance(self::$id);
|
||||
|
||||
self::$current_filter = $tag;
|
||||
|
||||
$that->filters['count']++;
|
||||
|
||||
if (!array_key_exists($tag, $that->filters)) {
|
||||
$that->filters[$tag] = 0;
|
||||
}
|
||||
|
||||
$that->filters[$tag]++;
|
||||
$filters = $that->getFilters($tag, $remove);
|
||||
ksort($filters);
|
||||
|
||||
$value = $args[0];
|
||||
|
||||
foreach ($filters as $priority) {
|
||||
foreach ($priority as $filter) {
|
||||
if (isset($args[0])) {
|
||||
$args[0] = $value;
|
||||
}
|
||||
$replace = $that->runAction($filter, $args);
|
||||
|
||||
if (!is_null($replace)) {
|
||||
$value = $replace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self::$current_filter = false;
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
protected function getArguments($argsNumber, $arguments)
|
||||
{
|
||||
if ($argsNumber == 1 && is_string($arguments)) {
|
||||
return array($arguments);
|
||||
} elseif ($argsNumber === count($arguments)) {
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
$args = array();
|
||||
|
||||
for ($i = 0; $i < $argsNumber; $i++) {
|
||||
if (is_array($arguments) && array_key_exists($i, $arguments)) {
|
||||
$args[] = $arguments[$i];
|
||||
}
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
public static function remove_filter($tag, $func, $priority)
|
||||
{
|
||||
$that = self::getInstance(self::$id);
|
||||
|
||||
$is_remove = false;
|
||||
|
||||
if (isset($that->callback_filters[$tag]) && isset($that->callback_filters[$tag][$priority])) {
|
||||
|
||||
foreach ((array) $that->callback_filters[$tag][$priority] as $key => $value) {
|
||||
if (isset($value['function']) && $value['function'] === $func) {
|
||||
unset($that->callback_filters[$tag][$priority][$key]);
|
||||
$is_remove = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $is_remove;
|
||||
}
|
||||
|
||||
public static function remove_action($tag, $func, $priority)
|
||||
{
|
||||
$that = self::getInstance(self::$id);
|
||||
|
||||
$is_remove = false;
|
||||
|
||||
if (isset($that->callbacks[$tag]) && isset($that->callbacks[$tag][$priority])) {
|
||||
|
||||
foreach ((array) $that->callbacks[$tag][$priority] as $key => $value) {
|
||||
if (isset($value['function']) && $value['function'] === $func) {
|
||||
unset($that->callbacks[$tag][$priority][$key]);
|
||||
$is_remove = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $is_remove;
|
||||
}
|
||||
}
|
||||
|
||||
// end Hook Class;
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
if (!defined('_GNUBOARD_'))
|
||||
exit;
|
||||
include_once(dirname(__FILE__) . '/pbkdf2.compat.php');
|
||||
|
||||
/*************************************************************************
|
||||
|
|
@ -19,7 +20,8 @@ function get_microtime()
|
|||
// 한페이지에 보여줄 행, 현재페이지, 총페이지수, URL
|
||||
function get_paging($write_pages, $cur_page, $total_page, $url, $add = "")
|
||||
{
|
||||
if(!$write_pages) $write_pages = 5;
|
||||
if (!$write_pages)
|
||||
$write_pages = 5;
|
||||
|
||||
//$url = preg_replace('#&page=[0-9]*(&page=)$#', '$1', $url);
|
||||
$url = preg_replace('#&page=[0-9]*#', '', $url) . '&page=';
|
||||
|
|
@ -33,8 +35,10 @@ function get_paging($write_pages, $cur_page, $total_page, $url, $add="")
|
|||
$start_page = (((int) (($cur_page - 1) / $write_pages)) * $write_pages) + 1;
|
||||
$end_page = $start_page + $write_pages - 1;
|
||||
|
||||
if ($end_page >= $total_page) $end_page = $total_page;
|
||||
if ($start_page > 1) $str .= '<a href="'.$url.($start_page-1).$add.'" class="pg_control pg_prev" title="이전"><i class="material-icons">navigate_before</i></a>'.PHP_EOL;
|
||||
if ($end_page >= $total_page)
|
||||
$end_page = $total_page;
|
||||
if ($start_page > 1)
|
||||
$str .= '<a href="' . $url . ($start_page - 1) . $add . '" class="pg_control pg_prev" title="이전"><i class="material-icons">navigate_before</i></a>' . PHP_EOL;
|
||||
|
||||
if ($total_page > 1) {
|
||||
$str .= "<span class='pg-number-group'>";
|
||||
|
|
@ -47,7 +51,8 @@ function get_paging($write_pages, $cur_page, $total_page, $url, $add="")
|
|||
$str .= "</span>";
|
||||
}
|
||||
|
||||
if ($total_page > $end_page) $str .= '<a href="'.$url.($end_page+1).$add.'" class="pg_control pg_next" title="다음"><i class="material-icons">navigate_next</i></a>'.PHP_EOL;
|
||||
if ($total_page > $end_page)
|
||||
$str .= '<a href="' . $url . ($end_page + 1) . $add . '" class="pg_control pg_next" title="다음"><i class="material-icons">navigate_next</i></a>' . PHP_EOL;
|
||||
if ($cur_page < $total_page) {
|
||||
$str .= '<a href="' . $url . $total_page . $add . '" class="pg_control pg_end" title="마지막으로"><i class="material-icons">keyboard_double_arrow_right</i></a>' . PHP_EOL;
|
||||
}
|
||||
|
|
@ -157,7 +162,8 @@ function alert($msg='', $url='', $error=true, $post=false)
|
|||
global $g5, $config, $member;
|
||||
global $is_admin;
|
||||
|
||||
if (!$msg) $msg = '올바른 방법으로 이용해 주십시오.';
|
||||
if (!$msg)
|
||||
$msg = '올바른 방법으로 이용해 주십시오.';
|
||||
|
||||
$header = '';
|
||||
if (isset($g5['title'])) {
|
||||
|
|
@ -196,7 +202,8 @@ function confirm($msg, $url1='', $url2='', $url3='')
|
|||
alert($msg);
|
||||
}
|
||||
|
||||
if (!$url3) $url3 = clean_xss_tags($_SERVER['HTTP_REFERER']);
|
||||
if (!$url3)
|
||||
$url3 = clean_xss_tags($_SERVER['HTTP_REFERER']);
|
||||
|
||||
$msg = str_replace("\\n", "<br>", $msg);
|
||||
|
||||
|
|
@ -253,7 +260,8 @@ function url_auto_link($str)
|
|||
// url에 http:// 를 붙인다
|
||||
function set_http($url)
|
||||
{
|
||||
if (!trim($url)) return;
|
||||
if (!trim($url))
|
||||
return;
|
||||
|
||||
if (!preg_match("/^(http|https|ftp|telnet|news|mms)\:\/\//i", $url))
|
||||
$url = "http://" . $url;
|
||||
|
|
@ -286,8 +294,7 @@ function get_file($bo_table, $wr_id)
|
|||
$file['count'] = 0;
|
||||
$sql = " select * from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no ";
|
||||
$result = sql_query($sql);
|
||||
while ($row = sql_fetch_array($result))
|
||||
{
|
||||
while ($row = sql_fetch_array($result)) {
|
||||
$no = $row['bf_no'];
|
||||
$file[$no]['href'] = G5_BBS_URL . "/download.php?bo_table=$bo_table&wr_id=$wr_id&no=$no" . $qstr;
|
||||
$file[$no]['download'] = $row['bf_download'];
|
||||
|
|
@ -354,8 +361,7 @@ function get_list($write_row, $board, $skin_url, $subject_len=40)
|
|||
$list['subject'] = conv_subject($list['wr_subject'], $board['bo_subject_len'], '…');
|
||||
|
||||
// 목록에서 내용 미리보기 사용한 게시판만 내용을 변환함 (속도 향상) : kkal3(커피)님께서 알려주셨습니다.
|
||||
if ($board['bo_use_list_content'] || $board['bo_type'] == 'mmb')
|
||||
{
|
||||
if ($board['bo_use_list_content'] || $board['bo_type'] == 'mmb') {
|
||||
$html = 0;
|
||||
if (strstr($list['wr_option'], 'html1'))
|
||||
$html = 1;
|
||||
|
|
@ -459,7 +465,8 @@ function search_font($stx, $str)
|
|||
$src = array('/', '|');
|
||||
$dst = array('\/', '\|');
|
||||
|
||||
if (!trim($stx)) return $str;
|
||||
if (!trim($stx))
|
||||
return $str;
|
||||
|
||||
// 검색어 전체를 공란으로 나눈다
|
||||
$s = explode(' ', $stx);
|
||||
|
|
@ -468,7 +475,8 @@ function search_font($stx, $str)
|
|||
$pattern = '';
|
||||
$bar = '';
|
||||
for ($m = 0; $m < count($s); $m++) {
|
||||
if (trim($s[$m]) == '') continue;
|
||||
if (trim($s[$m]) == '')
|
||||
continue;
|
||||
// 태그는 포함하지 않아야 하는데 잘 안되는군. ㅡㅡa
|
||||
//$pattern .= $bar . '([^<])(' . quotemeta($s[$m]) . ')';
|
||||
//$pattern .= $bar . quotemeta($s[$m]);
|
||||
|
|
@ -497,8 +505,7 @@ function conv_content($content, $html, $filter=true)
|
|||
{
|
||||
global $config, $board;
|
||||
|
||||
if ($html)
|
||||
{
|
||||
if ($html) {
|
||||
$source = array();
|
||||
$target = array();
|
||||
|
||||
|
|
@ -513,8 +520,7 @@ function conv_content($content, $html, $filter=true)
|
|||
// 테이블 태그의 개수를 세어 테이블이 깨지지 않도록 한다.
|
||||
$table_begin_count = substr_count(strtolower($content), "<table");
|
||||
$table_end_count = substr_count(strtolower($content), "</table");
|
||||
for ($i=$table_end_count; $i<$table_begin_count; $i++)
|
||||
{
|
||||
for ($i = $table_end_count; $i < $table_begin_count; $i++) {
|
||||
$content .= "</table>";
|
||||
}
|
||||
|
||||
|
|
@ -522,8 +528,7 @@ function conv_content($content, $html, $filter=true)
|
|||
|
||||
if ($filter)
|
||||
$content = html_purifier($content);
|
||||
}
|
||||
else // text 이면
|
||||
} else // text 이면
|
||||
{
|
||||
// & 처리 : & 등의 코드를 정상 출력함
|
||||
$content = html_symbol($content);
|
||||
|
|
@ -619,7 +624,8 @@ function get_sql_search($search_ca_name, $search_field, $search_text, $search_op
|
|||
for ($i = 0; $i < count($s); $i++) {
|
||||
// 검색어
|
||||
$search_str = trim($s[$i]);
|
||||
if ($search_str == "") continue;
|
||||
if ($search_str == "")
|
||||
continue;
|
||||
|
||||
// 인기검색어
|
||||
insert_popular($field, $search_str);
|
||||
|
|
@ -719,24 +725,17 @@ function subject_sort_link($col, $query_string='', $flag='asc')
|
|||
global $sst, $sod, $sfl, $stx, $page, $sca;
|
||||
|
||||
$q1 = "sst=$col";
|
||||
if ($flag == 'asc')
|
||||
{
|
||||
if ($flag == 'asc') {
|
||||
$q2 = 'sod=asc';
|
||||
if ($sst == $col)
|
||||
{
|
||||
if ($sod == 'asc')
|
||||
{
|
||||
if ($sst == $col) {
|
||||
if ($sod == 'asc') {
|
||||
$q2 = 'sod=desc';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$q2 = 'sod=desc';
|
||||
if ($sst == $col)
|
||||
{
|
||||
if ($sod == 'desc')
|
||||
{
|
||||
if ($sst == $col) {
|
||||
if ($sod == 'desc') {
|
||||
$q2 = 'sod=asc';
|
||||
}
|
||||
}
|
||||
|
|
@ -786,13 +785,17 @@ function is_admin($mb_id)
|
|||
{
|
||||
global $config, $group, $board;
|
||||
|
||||
if (!$mb_id) return;
|
||||
if (!$mb_id)
|
||||
return;
|
||||
|
||||
$mb = get_member($mb_id);
|
||||
|
||||
if ($config['cf_admin'] == $mb_id || $mb['mb_level'] == 10) return 'super';
|
||||
if (isset($group['gr_admin']) && ($group['gr_admin'] == $mb_id)) return 'group';
|
||||
if (isset($board['bo_admin']) && ($board['bo_admin'] == $mb_id)) return 'board';
|
||||
if ($config['cf_admin'] == $mb_id || $mb['mb_level'] == 10)
|
||||
return 'super';
|
||||
if (isset($group['gr_admin']) && ($group['gr_admin'] == $mb_id))
|
||||
return 'group';
|
||||
if (isset($board['bo_admin']) && ($board['bo_admin'] == $mb_id))
|
||||
return 'board';
|
||||
return '';
|
||||
}
|
||||
|
||||
|
|
@ -807,7 +810,8 @@ function get_category_option($bo_table='', $ca_name='')
|
|||
$str = "";
|
||||
for ($i = 0; $i < count($categories); $i++) {
|
||||
$category = trim($categories[$i]);
|
||||
if (!$category) continue;
|
||||
if (!$category)
|
||||
continue;
|
||||
|
||||
$str .= "<option value=\"$categories[$i]\"";
|
||||
if ($category == $ca_name) {
|
||||
|
|
@ -835,7 +839,8 @@ function get_group_select($name, $selected='', $event='')
|
|||
$result = sql_query($sql);
|
||||
$str = "<select id=\"$name\" name=\"$name\" $event>\n";
|
||||
for ($i = 0; $row = sql_fetch_array($result); $i++) {
|
||||
if ($i == 0) $str .= "<option value=\"\">선택</option>";
|
||||
if ($i == 0)
|
||||
$str .= "<option value=\"\">선택</option>";
|
||||
$str .= option_selected($row['gr_id'], $selected, $row['gr_subject']);
|
||||
}
|
||||
$str .= "</select>";
|
||||
|
|
@ -845,7 +850,8 @@ function get_group_select($name, $selected='', $event='')
|
|||
|
||||
function option_selected($value, $selected, $text = '')
|
||||
{
|
||||
if (!$text) $text = $value;
|
||||
if (!$text)
|
||||
$text = $value;
|
||||
if ($value == $selected)
|
||||
return "<option value=\"$value\" selected=\"selected\">$text</option>\n";
|
||||
else
|
||||
|
|
@ -877,22 +883,29 @@ function insert_point($mb_id, $point, $content='', $rel_table='', $rel_id='', $r
|
|||
global $is_admin;
|
||||
|
||||
// 포인트 사용을 하지 않는다면 return
|
||||
if (!$config['cf_use_point']) { return 0; }
|
||||
if (!$config['cf_use_point']) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 포인트가 없다면 업데이트 할 필요 없음
|
||||
if ($point == 0) { return 0; }
|
||||
if ($point == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 회원아이디가 없다면 업데이트 할 필요 없음
|
||||
if ($mb_id == '') { return 0; }
|
||||
if ($mb_id == '') {
|
||||
return 0;
|
||||
}
|
||||
$mb = sql_fetch(" select mb_id from {$g5['member_table']} where mb_id = '$mb_id' ");
|
||||
if (!$mb['mb_id']) { return 0; }
|
||||
if (!$mb['mb_id']) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 회원포인트
|
||||
$mb_point = get_point_sum($mb_id);
|
||||
|
||||
// 이미 등록된 내역이라면 건너뜀
|
||||
if ($rel_table || $rel_id || $rel_action)
|
||||
{
|
||||
if ($rel_table || $rel_id || $rel_action) {
|
||||
$sql = " select count(*) as cnt from {$g5['point_table']}
|
||||
where mb_id = '$mb_id'
|
||||
and po_rel_table = '$rel_table'
|
||||
|
|
@ -1155,8 +1168,7 @@ function delete_point($mb_id, $rel_table, $rel_id, $rel_action)
|
|||
global $g5;
|
||||
|
||||
$result = false;
|
||||
if ($rel_table || $rel_id || $rel_action)
|
||||
{
|
||||
if ($rel_table || $rel_id || $rel_action) {
|
||||
// 포인트 내역정보
|
||||
$sql = " select * from {$g5['point_table']}
|
||||
where mb_id = '$mb_id'
|
||||
|
|
@ -1290,13 +1302,13 @@ function view_file_link($file, $width, $height, $content='')
|
|||
global $g5;
|
||||
static $ids;
|
||||
|
||||
if (!$file) return;
|
||||
if (!$file)
|
||||
return;
|
||||
|
||||
$ids++;
|
||||
|
||||
// 파일의 폭이 게시판설정의 이미지폭 보다 크다면 게시판설정 폭으로 맞추고 비율에 따라 높이를 계산
|
||||
if ($width > $board['bo_image_width'] && $board['bo_image_width'])
|
||||
{
|
||||
if ($width > $board['bo_image_width'] && $board['bo_image_width']) {
|
||||
$rate = $board['bo_image_width'] / $width;
|
||||
$width = $board['bo_image_width'];
|
||||
$height = (int) ($height * $rate);
|
||||
|
|
@ -1628,19 +1640,15 @@ function get_table_define($table, $crlf="\n")
|
|||
|
||||
$sql = 'SHOW FIELDS FROM ' . $table;
|
||||
$result = sql_query($sql);
|
||||
while ($row = sql_fetch_array($result))
|
||||
{
|
||||
while ($row = sql_fetch_array($result)) {
|
||||
$schema_create .= ' ' . $row['Field'] . ' ' . $row['Type'];
|
||||
if (isset($row['Default']) && $row['Default'] != '')
|
||||
{
|
||||
if (isset($row['Default']) && $row['Default'] != '') {
|
||||
$schema_create .= ' DEFAULT \'' . $row['Default'] . '\'';
|
||||
}
|
||||
if ($row['Null'] != 'YES')
|
||||
{
|
||||
if ($row['Null'] != 'YES') {
|
||||
$schema_create .= ' NOT NULL';
|
||||
}
|
||||
if ($row['Extra'] != '')
|
||||
{
|
||||
if ($row['Extra'] != '') {
|
||||
$schema_create .= ' ' . $row['Extra'];
|
||||
}
|
||||
$schema_create .= ',' . $crlf;
|
||||
|
|
@ -1651,8 +1659,7 @@ function get_table_define($table, $crlf="\n")
|
|||
|
||||
$sql = 'SHOW KEYS FROM ' . $table;
|
||||
$result = sql_query($sql);
|
||||
while ($row = sql_fetch_array($result))
|
||||
{
|
||||
while ($row = sql_fetch_array($result)) {
|
||||
$kname = $row['Key_name'];
|
||||
$comment = (isset($row['Comment'])) ? $row['Comment'] : '';
|
||||
$sub_part = (isset($row['Sub_part'])) ? $row['Sub_part'] : '';
|
||||
|
|
@ -1865,8 +1872,7 @@ function check_string($str, $options)
|
|||
if ($options & G5_SPACE) {
|
||||
$s .= $c;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if ($options & G5_SPECIAL) {
|
||||
$s .= $c;
|
||||
}
|
||||
|
|
@ -1904,7 +1910,8 @@ function explain($sql)
|
|||
$q = "explain $sql";
|
||||
echo $q;
|
||||
$row = sql_fetch($q);
|
||||
if (!$row['key']) $row['key'] = "NULL";
|
||||
if (!$row['key'])
|
||||
$row['key'] = "NULL";
|
||||
echo " <font color=blue>(type={$row['type']} , key={$row['key']})</font>";
|
||||
}
|
||||
}
|
||||
|
|
@ -1918,9 +1925,11 @@ function bad_tag_convert($code)
|
|||
if ($is_admin && $member['mb_id'] != $view['mb_id']) {
|
||||
//$code = preg_replace_callback("#(\<(embed|object)[^\>]*)\>(\<\/(embed|object)\>)?#i",
|
||||
// embed 또는 object 태그를 막지 않는 경우 필터링이 되도록 수정
|
||||
$code = preg_replace_callback("#(\<(embed|object)[^\>]*)\>?(\<\/(embed|object)\>)?#i",
|
||||
$code = preg_replace_callback(
|
||||
"#(\<(embed|object)[^\>]*)\>?(\<\/(embed|object)\>)?#i",
|
||||
create_function('$matches', 'return "<div class=\"embedx\">보안문제로 인하여 관리자 아이디로는 embed 또는 object 태그를 볼 수 없습니다. 확인하시려면 관리권한이 없는 다른 아이디로 접속하세요.</div>";'),
|
||||
$code);
|
||||
$code
|
||||
);
|
||||
}
|
||||
|
||||
return preg_replace("/\<([\/]?)(script|iframe|form)([^\>]*)\>?/i", "<$1$2$3>", $code);
|
||||
|
|
@ -1960,16 +1969,23 @@ function is_utf8($str)
|
|||
for ($i = 0; $i < $len; $i++) {
|
||||
$c = ord($str[$i]);
|
||||
if ($c > 128) {
|
||||
if (($c > 247)) return false;
|
||||
elseif ($c > 239) $bytes = 4;
|
||||
elseif ($c > 223) $bytes = 3;
|
||||
elseif ($c > 191) $bytes = 2;
|
||||
else return false;
|
||||
if (($i + $bytes) > $len) return false;
|
||||
if (($c > 247))
|
||||
return false;
|
||||
elseif ($c > 239)
|
||||
$bytes = 4;
|
||||
elseif ($c > 223)
|
||||
$bytes = 3;
|
||||
elseif ($c > 191)
|
||||
$bytes = 2;
|
||||
else
|
||||
return false;
|
||||
if (($i + $bytes) > $len)
|
||||
return false;
|
||||
while ($bytes > 1) {
|
||||
$i++;
|
||||
$b = ord($str[$i]);
|
||||
if ($b < 128 || $b > 191) return false;
|
||||
if ($b < 128 || $b > 191)
|
||||
return false;
|
||||
$bytes--;
|
||||
}
|
||||
}
|
||||
|
|
@ -2094,7 +2110,8 @@ function get_uniqid()
|
|||
$key = date('ymdHis', time()) . str_pad((int) (microtime() * 100), 2, "0", STR_PAD_LEFT);
|
||||
|
||||
$result = sql_query(" insert into {$g5['uniqid_table']} set uq_id = '$key', uq_ip = '{$_SERVER['REMOTE_ADDR']}' ", false);
|
||||
if ($result) break; // 쿼리가 정상이면 빠진다.
|
||||
if ($result)
|
||||
break; // 쿼리가 정상이면 빠진다.
|
||||
|
||||
// insert 하지 못했으면 일정시간 쉰다음 다시 유일키를 만든다.
|
||||
usleep(10000); // 100분의 1초를 쉰다
|
||||
|
|
@ -2124,7 +2141,8 @@ function check_device($device)
|
|||
{
|
||||
global $is_admin;
|
||||
|
||||
if ($is_admin) return;
|
||||
if ($is_admin)
|
||||
return;
|
||||
|
||||
if ($device == 'pc' && G5_IS_MOBILE) {
|
||||
alert('PC 전용 게시판입니다.', G5_URL);
|
||||
|
|
@ -2315,7 +2333,8 @@ function get_skin_javascript($skin_path, $dir='')
|
|||
// file_put_contents 는 PHP5 전용 함수이므로 PHP4 하위버전에서 사용하기 위함
|
||||
// http://www.phpied.com/file_get_contents-for-php4/
|
||||
if (!function_exists('file_put_contents')) {
|
||||
function file_put_contents($filename, $data) {
|
||||
function file_put_contents($filename, $data)
|
||||
{
|
||||
$f = @fopen($filename, 'w');
|
||||
if (!$f) {
|
||||
return false;
|
||||
|
|
@ -2352,7 +2371,8 @@ function add_javascript($javascript, $order=0)
|
|||
$html_process->merge_javascript($javascript, $order);
|
||||
}
|
||||
|
||||
class html_process {
|
||||
class html_process
|
||||
{
|
||||
protected $css = array();
|
||||
protected $js = array();
|
||||
|
||||
|
|
@ -2496,7 +2516,8 @@ function hyphen_hp_number($hp)
|
|||
// 로그인 후 이동할 URL
|
||||
function login_url($url = '')
|
||||
{
|
||||
if (!$url) $url = G5_URL;
|
||||
if (!$url)
|
||||
$url = G5_URL;
|
||||
|
||||
return urlencode(clean_xss_tags(urldecode($url)));
|
||||
}
|
||||
|
|
@ -2663,31 +2684,25 @@ if (!function_exists("get_sock")) {
|
|||
{
|
||||
// host 와 uri 를 분리
|
||||
//if (ereg("http://([a-zA-Z0-9_\-\.]+)([^<]*)", $url, $res))
|
||||
if (preg_match("/http:\/\/([a-zA-Z0-9_\-\.]+)([^<]*)/", $url, $res))
|
||||
{
|
||||
if (preg_match("/http:\/\/([a-zA-Z0-9_\-\.]+)([^<]*)/", $url, $res)) {
|
||||
$host = $res[1];
|
||||
$get = $res[2];
|
||||
}
|
||||
|
||||
// 80번 포트로 소캣접속 시도
|
||||
$fp = fsockopen($host, 80, $errno, $errstr, 30);
|
||||
if (!$fp)
|
||||
{
|
||||
if (!$fp) {
|
||||
die("$errstr ($errno)\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
fputs($fp, "GET $get HTTP/1.0\r\n");
|
||||
fputs($fp, "Host: $host\r\n");
|
||||
fputs($fp, "\r\n");
|
||||
|
||||
// header 와 content 를 분리한다.
|
||||
while (trim($buffer = fgets($fp,1024)) != "")
|
||||
{
|
||||
while (trim($buffer = fgets($fp, 1024)) != "") {
|
||||
$header .= $buffer;
|
||||
}
|
||||
while (!feof($fp))
|
||||
{
|
||||
while (!feof($fp)) {
|
||||
$buffer .= fgets($fp, 1024);
|
||||
}
|
||||
}
|
||||
|
|
@ -3186,7 +3201,8 @@ function get_skin_url($dir, $skin)
|
|||
}
|
||||
|
||||
// 발신번호 유효성 체크
|
||||
function check_vaild_callback($callback){
|
||||
function check_vaild_callback($callback)
|
||||
{
|
||||
$_callback = preg_replace('/[^0-9]/', '', $callback);
|
||||
|
||||
/**
|
||||
|
|
@ -3196,12 +3212,17 @@ function check_vaild_callback($callback){
|
|||
* 030으로 시작하면 총10자리 또는 11자리인데 9자리라차단
|
||||
*/
|
||||
|
||||
if( substr($_callback,0,4) == '1588') if( strlen($_callback) != 8) return false;
|
||||
if( substr($_callback,0,2) == '02') if( strlen($_callback) != 9 && strlen($_callback) != 10 ) return false;
|
||||
if( substr($_callback,0,3) == '030') if( strlen($_callback) != 10 && strlen($_callback) != 11 ) return false;
|
||||
if (substr($_callback, 0, 4) == '1588') if (strlen($_callback) != 8)
|
||||
return false;
|
||||
if (substr($_callback, 0, 2) == '02') if (strlen($_callback) != 9 && strlen($_callback) != 10)
|
||||
return false;
|
||||
if (substr($_callback, 0, 3) == '030') if (strlen($_callback) != 10 && strlen($_callback) != 11)
|
||||
return false;
|
||||
|
||||
if( !preg_match("/^(02|0[3-6]\d|01(0|1|3|5|6|7|8|9)|070|080|007)\-?\d{3,4}\-?\d{4,5}$/",$_callback) &&
|
||||
!preg_match("/^(15|16|18)\d{2}\-?\d{4,5}$/",$_callback) ){
|
||||
if (
|
||||
!preg_match("/^(02|0[3-6]\d|01(0|1|3|5|6|7|8|9)|070|080|007)\-?\d{3,4}\-?\d{4,5}$/", $_callback) &&
|
||||
!preg_match("/^(15|16|18)\d{2}\-?\d{4,5}$/", $_callback)
|
||||
) {
|
||||
return false;
|
||||
} else if (preg_match("/^(02|0[3-6]\d|01(0|1|3|5|6|7|8|9)|070|080)\-?0{3,4}\-?\d{4}$/", $_callback)) {
|
||||
return false;
|
||||
|
|
@ -3241,7 +3262,8 @@ class str_encrypt
|
|||
return base64_encode($result);
|
||||
}
|
||||
|
||||
function decrypt($str) {
|
||||
function decrypt($str)
|
||||
{
|
||||
$result = '';
|
||||
$str = base64_decode($str);
|
||||
$length = strlen($str);
|
||||
|
|
@ -3291,4 +3313,3 @@ function is_include_path_check($path='')
|
|||
}
|
||||
return true;
|
||||
}
|
||||
?>
|
||||
Loading…
Reference in a new issue