+
location.replace('$url'); ";
@@ -176,8 +178,9 @@ function get_cookie($cookie_name)
// 경고메세지를 경고창으로
function alert($msg = '', $url = '', $error = true, $post = false)
{
- global $g5, $config, $member;
- global $is_admin;
+ global $g5, $config, $member, $is_admin;
+
+ EventHandler::triggerEvent("gnuboard.alert", $msg, $url, $error, $post);
if (!$msg)
$msg = '올바른 방법으로 이용해 주십시오.';
@@ -196,11 +199,14 @@ function alert_close($msg, $error = true)
{
global $g5;
+ EventHandler::triggerEvent("gnuboard.alert_close", $msg, $error);
+
$header = '';
if (isset($g5['title'])) {
$header = $g5['title'];
}
- include_once(G5_BBS_PATH . '/alert_close.php');
+
+ include_once G5_BBS_PATH . '/alert_close.php';
exit;
}
@@ -570,21 +576,29 @@ function conv_content($content, $html, $filter = true)
// Open : HTML Purifier is open-source and highly customizable
function html_purifier($html)
{
+ global $is_admin, $write;
+
$f = file(G5_PLUGIN_PATH . '/htmlpurifier/safeiframe.txt');
$domains = [];
foreach ($f as $domain) {
// 첫행이 # 이면 주석 처리
if (!preg_match("/^#/", $domain)) {
$domain = trim($domain);
- if ($domain)
+ if ($domain) {
array_push($domains, $domain);
+ }
}
}
- // 내 도메인도 추가
- array_push($domains, $_SERVER['HTTP_HOST'] . '/');
- $safeiframe = implode('|', $domains);
+
+ // 글쓴이가 관리자인 경우에만 현재 사이트 도메인을 허용
+ if (isset($write) && isset($write['mb_id']) && $write['mb_id'] && is_admin($write['mb_id'])) {
+ array_push($domains, $_SERVER['HTTP_HOST'] . '/');
+ }
+ $safeiframe = implode('|', run_replace('html_purifier_safeiframes', $domains, $html));
include_once(G5_PLUGIN_PATH . '/htmlpurifier/HTMLPurifier.standalone.php');
+ include_once(G5_PLUGIN_PATH . '/htmlpurifier/extend.video.php');
+
$config = HTMLPurifier_Config::createDefault();
// data/cache 디렉토리에 CSS, HTML, URI 디렉토리 등을 만든다.
$config->set('Cache.SerializerPath', G5_DATA_PATH . '/cache');
@@ -592,10 +606,27 @@ function html_purifier($html)
$config->set('HTML.SafeObject', false);
$config->set('Output.FlashCompat', false);
$config->set('HTML.SafeIframe', true);
- $config->set('URI.SafeIframeRegexp', '%^(https?:)?//(' . $safeiframe . ')%');
+ if ((function_exists('check_html_link_nofollow') && check_html_link_nofollow('html_purifier'))) {
+ $config->set('HTML.Nofollow', true); // rel=nofollow 으로 스팸유입을 줄임
+ }
+ $config->set('URI.SafeIframeRegexp', '%^(https?:)?//(' . preg_replace('/\\\?\./', '\.', $safeiframe) . ')%');
$config->set('Attr.AllowedFrameTargets', array('_blank'));
+ //유튜브, 비메오 전체화면 가능하게 하기
+ $config->set('Filter.Custom', array(new HTMLPurifier_Filter_Iframevideo()));
+
+ /*
+ * HTMLPurifier 설정을 변경할 수 있는 Event hook
+ * 리스너에서는 첫번째 인자($config)로 `HTMLPurifier_Config` 객체를 받을 수 있다
+ */
+ EventHandler::triggerEvent("gnuboard.html_purifier_config", $config, [
+ 'html' => $html,
+ 'write' => $write,
+ 'is_admin' => $is_admin
+ ]);
+
$purifier = new HTMLPurifier($config);
- return $purifier->purify($html);
+
+ return run_replace('html_purifier_result', $purifier->purify($html), $purifier, $html);
}
@@ -1568,6 +1599,9 @@ function sql_query($sql, $error = G5_DISPLAY_SQL_ERROR, $link = null)
$result = @mysql_query($sql, $link);
}
}
+
+ EventHandler::triggerEvent("gnuboard.sql_query_after", $result, $sql, $error);
+
return $result;
}
@@ -2283,6 +2317,8 @@ function delete_cache_latest($bo_table)
foreach ($files as $filename)
unlink($filename);
}
+
+ EventHandler::triggerEvent("gnuboard.delete_cache_latest", $bo_table);
}
// 게시판 첨부파일 썸네일 삭제
@@ -2321,6 +2357,8 @@ function delete_editor_thumbnail($contents)
if (!$contents)
return;
+ EventHandler::triggerEvent("gnuboard.delete_editor_thumbnail_before", $contents);
+
// $contents 중 img 태그 추출
$matchs = get_editor_image($contents);
@@ -2340,6 +2378,8 @@ function delete_editor_thumbnail($contents)
unlink($filename);
}
}
+
+ EventHandler::triggerEvent("gnuboard.delete_editor_thumbnail_after", $contents, $matchs);
}
// 1:1문의 첨부파일 썸네일 삭제
@@ -3060,6 +3100,24 @@ function clean_xss_attributes($str)
return $str;
}
+function clean_relative_paths($path)
+{
+ $path_len = strlen($path);
+
+ $i = 0;
+ while ($i <= $path_len) {
+ $result = str_replace('../', '', str_replace('\\', '/', $path));
+
+ if ((string) $result === (string) $path)
+ break;
+
+ $path = $result;
+ $i++;
+ }
+
+ return $path;
+}
+
// unescape nl 얻기
function conv_unescape_nl($str)
{
@@ -3115,6 +3173,8 @@ function member_delete($mb_id)
// 아이콘 삭제
@unlink(G5_DATA_PATH . '/member/' . substr($mb_id, 0, 2) . '/' . $mb_id . '.gif');
+
+ EventHandler::triggerEvent("gnuboard.member_delete_after", $mb_id);
}
// 이메일 주소 추출
diff --git a/AvocadoEdition_Light/lib/mailer.lib.php b/AvocadoEdition_Light/lib/mailer.lib.php
index 497b0dc..83d39f8 100644
--- a/AvocadoEdition_Light/lib/mailer.lib.php
+++ b/AvocadoEdition_Light/lib/mailer.lib.php
@@ -2,7 +2,7 @@
if (!defined('_GNUBOARD_'))
exit;
-include_once(G5_PHPMAILER_PATH . '/PHPMailerAutoload.php');
+include_once G5_PHPMAILER_PATH . '/PHPMailerAutoload.php';
// 메일 보내기 (파일 여러개 첨부 가능)
// type : text=0, html=1, text+html=2
@@ -18,30 +18,49 @@ function mailer($fname, $fmail, $to, $subject, $content, $type = 0, $file = "",
if ($type != 1)
$content = nl2br($content);
- $mail = new PHPMailer(); // defaults to using php "mail()"
- if (defined('G5_SMTP') && G5_SMTP) {
- $mail->IsSMTP(); // telling the class to use SMTP
- $mail->Host = G5_SMTP; // SMTP server
- if (defined('G5_SMTP_PORT') && G5_SMTP_PORT)
- $mail->Port = G5_SMTP_PORT;
+ $result = run_replace('mailer', $fname, $fmail, $to, $subject, $content, $type, $file, $cc, $bcc);
+
+ if (is_array($result) && isset($result['return'])) {
+ return $result['return'];
}
- $mail->CharSet = 'UTF-8';
- $mail->From = $fmail;
- $mail->FromName = $fname;
- $mail->Subject = $subject;
- $mail->AltBody = ""; // optional, comment out and test
- $mail->msgHTML($content);
- $mail->addAddress($to);
- if ($cc)
- $mail->addCC($cc);
- if ($bcc)
- $mail->addBCC($bcc);
- //print_r2($file); exit;
- if ($file != "") {
- foreach ($file as $f) {
- $mail->addAttachment($f['path'], $f['name']);
+
+ $mail_send_result = false;
+
+ try {
+ $mail = new PHPMailer(); // defaults to using php "mail()"
+ if (defined('G5_SMTP') && G5_SMTP) {
+ $mail->IsSMTP(); // telling the class to use SMTP
+ $mail->Host = G5_SMTP; // SMTP server
+ if (defined('G5_SMTP_PORT') && G5_SMTP_PORT)
+ $mail->Port = G5_SMTP_PORT;
}
+ $mail->CharSet = 'UTF-8';
+ $mail->From = $fmail;
+ $mail->FromName = $fname;
+ $mail->Subject = $subject;
+ $mail->AltBody = ""; // optional, comment out and test
+ $mail->msgHTML($content);
+ $mail->addAddress($to);
+ if ($cc)
+ $mail->addCC($cc);
+ if ($bcc)
+ $mail->addBCC($bcc);
+ //print_r2($file); exit;
+ if ($file != "") {
+ foreach ($file as $f) {
+ $mail->addAttachment($f['path'], $f['name']);
+ }
+ }
+
+ $mail = run_replace('mail_options', $mail, $fname, $fmail, $to, $subject, $content, $type, $file, $cc, $bcc);
+ $mail_send_result = $mail->send();
+
+ } catch (Exception $e) {
+
}
+
+ EventHandler::triggerEvent("gnuboard.mail_send_result", $mail_send_result, $mail, $to, $cc, $bcc);
+
return $mail->send();
}
diff --git a/AvocadoEdition_Light/lib/thumbnail.lib.php b/AvocadoEdition_Light/lib/thumbnail.lib.php
index 2455dad..b1245b4 100644
--- a/AvocadoEdition_Light/lib/thumbnail.lib.php
+++ b/AvocadoEdition_Light/lib/thumbnail.lib.php
@@ -793,7 +793,7 @@ function is_animated_gif($filename)
$cache[$key] = ($count > 1) ? true : false;
- run_event('is_animated_gif_after', $filename, $cache[$key]);
+ EventHandler::triggerEvent("gnuboard.is_animated_gif_after", $filename, $cache[$key]);
return $cache[$key];
}
diff --git a/AvocadoEdition_Light/plugin/editor/cheditor5/imageUpload/config.php b/AvocadoEdition_Light/plugin/editor/cheditor5/imageUpload/config.php
index 7766785..914041e 100644
--- a/AvocadoEdition_Light/plugin/editor/cheditor5/imageUpload/config.php
+++ b/AvocadoEdition_Light/plugin/editor/cheditor5/imageUpload/config.php
@@ -11,13 +11,13 @@ define("CHE_UPLOAD_IMG_CHECK", 1); // 이미지 파일을 썸네일 할수 있
# data/editor 디렉토리가 없는 경우가 있을수 있으므로 디렉토리를 생성하는 코드를 추가함. kagla 140305
-@mkdir(G5_DATA_PATH.'/'.G5_EDITOR_DIR, G5_DIR_PERMISSION);
-@chmod(G5_DATA_PATH.'/'.G5_EDITOR_DIR, G5_DIR_PERMISSION);
+@mkdir(G5_DATA_PATH . '/' . G5_EDITOR_DIR, G5_DIR_PERMISSION);
+@chmod(G5_DATA_PATH . '/' . G5_EDITOR_DIR, G5_DIR_PERMISSION);
$ym = date('ym', G5_SERVER_TIME);
-$data_dir = G5_DATA_PATH.'/'.G5_EDITOR_DIR.'/'.$ym;
-$data_url = G5_DATA_URL.'/'.G5_EDITOR_DIR.'/'.$ym;
+$data_dir = G5_DATA_PATH . '/' . G5_EDITOR_DIR . '/' . $ym;
+$data_url = G5_DATA_URL . '/' . G5_EDITOR_DIR . '/' . $ym;
define("SAVE_DIR", $data_dir);
@@ -29,42 +29,46 @@ define("SAVE_DIR", $data_dir);
define("SAVE_URL", $data_url);
-function che_get_user_id() {
- global $member;
+function che_get_user_id()
+{
+ global $member;
- if(session_id() == '') {
- @session_start();
- }
+ if (session_id() == '') {
+ @session_start();
+ }
- $add_str = (isset($member['mb_id']) && $member['mb_id']) ? $member['mb_id'] : '';
- return session_id().$add_str;
+ $add_str = (isset($member['mb_id']) && $member['mb_id']) ? $member['mb_id'] : '';
+ return session_id() . $add_str;
}
-function che_get_file_passname(){
- $tmp_name = che_get_user_id().$_SERVER['REMOTE_ADDR'];
- $tmp_name = md5(sha1($tmp_name));
- return $tmp_name;
+function che_get_file_passname()
+{
+ $tmp_name = che_get_user_id() . $_SERVER['REMOTE_ADDR'];
+ $tmp_name = md5(sha1($tmp_name));
+ return $tmp_name;
}
-function che_generateRandomString($length = 4) {
- $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
- $charactersLength = strlen($characters);
- $randomString = '';
- for ($i = 0; $i < $length; $i++) {
- $randomString .= $characters[rand(0, $charactersLength - 1)];
- }
- return $randomString;
+function che_generateRandomString($length = 4)
+{
+ $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
+ $charactersLength = strlen($characters);
+ $randomString = '';
+ for ($i = 0; $i < $length; $i++) {
+ $randomString .= $characters[rand(0, $charactersLength - 1)];
+ }
+ return $randomString;
}
-function che_replace_filename($filename){
+function che_replace_filename($filename)
+{
- $ext = pathinfo($filename, PATHINFO_EXTENSION);
+ $ext = pathinfo($filename, PATHINFO_EXTENSION);
- $random_str = che_generateRandomString(4);
+ $random_str = che_generateRandomString(4);
- $passname = che_get_file_passname();
-
- $file_arr = explode('_', $filename);
+ $passname = che_get_file_passname();
- return $file_arr[0].'_'.$passname.'_'.$random_str.'.'.$ext;
+ $file_arr = explode('_', $filename);
+
+ return $file_arr[0] . '_' . $passname . '_' . $random_str . '.' . $ext;
}
diff --git a/AvocadoEdition_Light/plugin/editor/cheditor5/imageUpload/delete.php b/AvocadoEdition_Light/plugin/editor/cheditor5/imageUpload/delete.php
index 8ff619c..aa0fd87 100644
--- a/AvocadoEdition_Light/plugin/editor/cheditor5/imageUpload/delete.php
+++ b/AvocadoEdition_Light/plugin/editor/cheditor5/imageUpload/delete.php
@@ -1,51 +1,51 @@
()\[\]\{\}]/", "", $_POST["filesrc"]) : '';
-if( !$filesrc || ! preg_match('=^[^/?*;:{}\\\\]+\.[^/?*;:{}\\\\]+$=', $filesrc) || ! preg_match('/\.(gif|jpe?g|bmp|png)$/i', $filesrc) ){
- die( false );
+if (!$filesrc || !preg_match('=^[^/?*;:{}\\\\]+\.[^/?*;:{}\\\\]+$=', $filesrc) || !preg_match('/\.(gif|jpe?g|bmp|png)$/i', $filesrc)) {
+ die(false);
}
$is_editor_upload = false;
-$get_nonce = get_session('nonce_'.FT_NONCE_SESSION_KEY);
+$get_nonce = get_session('nonce_' . FT_NONCE_SESSION_KEY);
-if( $get_nonce && ft_nonce_is_valid( $get_nonce, 'cheditor' ) ){
- $is_editor_upload = true;
+if ($get_nonce && ft_nonce_is_valid($get_nonce, 'cheditor')) {
+ $is_editor_upload = true;
}
-if( !$is_editor_upload ){
- die( false );
+if (!$is_editor_upload) {
+ die(false);
}
// ---------------------------------------------------------------------------
-$file_arr = explode('_', $filesrc );
+$file_arr = explode('_', $filesrc);
-if( $file_arr[1] !== che_get_file_passname() ){
- die( false );
+if ($file_arr[1] !== che_get_file_passname()) {
+ die(false);
}
$filepath = SAVE_DIR . '/' . $filesrc;
$r = false;
-if( function_exists('run_event') ){
- run_event('delete_editor_file', $filepath, $r);
+if (class_exists('EventHandler') && method_exists('EventHandler', 'triggerEvent')) {
+ EventHandler::triggerEvent("gnuboard.delete_editor_file", $filepath, $r);
}
if (file_exists($filepath)) {
- $r = unlink($filepath);
- if ($r) {
- $thumbPath = dirname($filepath) . DIRECTORY_SEPARATOR . "thumb_" . basename($filepath);
- if (file_exists($thumbPath)) {
- unlink($thumbPath);
- }
- }
+ $r = unlink($filepath);
+ if ($r) {
+ $thumbPath = dirname($filepath) . DIRECTORY_SEPARATOR . "thumb_" . basename($filepath);
+ if (file_exists($thumbPath)) {
+ unlink($thumbPath);
+ }
+ }
}
echo $r ? true : false;
diff --git a/AvocadoEdition_Light/plugin/editor/cheditor5/imageUpload/upload.php b/AvocadoEdition_Light/plugin/editor/cheditor5/imageUpload/upload.php
index c4ceda7..fc38564 100644
--- a/AvocadoEdition_Light/plugin/editor/cheditor5/imageUpload/upload.php
+++ b/AvocadoEdition_Light/plugin/editor/cheditor5/imageUpload/upload.php
@@ -1,8 +1,8 @@
get_upload_path($file_name);
$success = is_file($file_path) && $file_name[0] !== '.' && unlink($file_path);
- if (function_exists('run_event')) {
- run_event('delete_editor_file', $file_path, $success);
+ if (class_exists('EventHandler') && method_exists('EventHandler', 'triggerEvent')) {
+ EventHandler::triggerEvent("gnuboard.delete_editor_file", $file_path, $success);
}
if ($success) {
diff --git a/AvocadoEdition_Light/plugin/editor/smarteditor2/photo_uploader/popup/php/index.php b/AvocadoEdition_Light/plugin/editor/smarteditor2/photo_uploader/popup/php/index.php
index 35bfa0f..48f355d 100644
--- a/AvocadoEdition_Light/plugin/editor/smarteditor2/photo_uploader/popup/php/index.php
+++ b/AvocadoEdition_Light/plugin/editor/smarteditor2/photo_uploader/popup/php/index.php
@@ -42,20 +42,19 @@ if (isset($_GET['_nonce']) && ft_nonce_is_valid($_GET['_nonce'], 'smarteditor'))
if ($is_editor_upload) {
- run_event('smarteditor_photo_upload', $data_dir, $data_url);
+ EventHandler::triggerEvent("gnuboard.smarteditor_photo_upload", $data_dir, $data_url);
- require('UploadHandler.php');
- $options = array(
+ require 'UploadHandler.php';
+ $options = [
'upload_dir' => $data_dir,
'upload_url' => $data_url,
// This option will disable creating thumbnail images and will not create that extra folder.
// However, due to this, the images preview will not be displayed after upload
'image_versions' => []
- );
+ ];
$upload_handler = new UploadHandler($options);
-
} else {
- echo json_encode(array('files' => array('0' => array('error' => $_GET['_nonce']))));
+ echo json_encode(['files' => ['0' => ['error' => $_GET['_nonce']]]]);
exit;
}
diff --git a/AvocadoEdition_Light/tail.php b/AvocadoEdition_Light/tail.php
index 1105572..f193765 100644
--- a/AvocadoEdition_Light/tail.php
+++ b/AvocadoEdition_Light/tail.php
@@ -2,8 +2,12 @@
if (!defined('_GNUBOARD_'))
exit;
+EventHandler::triggerEvent("gnuboard.tail.before");
+
if (defined('G5_THEME_PATH') && file_exists(G5_THEME_PATH . "/tail.php")) {
include_once G5_THEME_PATH . '/tail.php';
+
+ EventHandler::triggerEvent("gnuboard.tail.after");
return;
}
@@ -19,4 +23,6 @@ if (defined('G5_THEME_PATH') && file_exists(G5_THEME_PATH . "/tail.php")) {