Пример #1
0
 function __construct($entry_id, $attach_id)
 {
     $this->attach_id = $attach_id;
     $this->entry_id = $entry_id;
     $this->board_id = parent::getMeta($this->entry_id, 'board_id');
     $this->title = get_the_title($this->attach_id);
     $this->filePath = wp_get_attachment_url($this->attach_id);
     $this->filetype = get_post_meta($this->attach_id, 'file_type', true);
     if (!$this->filetype || empty($this->filetype)) {
         $filetype = wp_check_filetype(basename($this->filePath));
         $this->filetype = $filetype['ext'];
     }
     $this->filename = trim($this->title . '.' . $this->filetype);
     $this->fullpath = get_attached_file($this->attach_id);
 }
Пример #2
0
function admin_kingkong_board_manage_entry_column($entries, $entry_id)
{
    $return_content = '';
    $controller = new kkbController();
    foreach ($entries as $entry) {
        switch ($entry['value']) {
            case 'thumbnail':
                if (has_post_thumbnail($entry_id)) {
                    $thumbnail_id = get_post_thumbnail_id($entry_id);
                    $url = wp_get_attachment_image_src($thumbnail_id, 'thumbnail');
                    $image = '<img src="' . $url[0] . '" style="width:20px; height:auto">';
                } else {
                    $image = __('없음', 'kingkongboard');
                }
                $return_content .= '<td style="text-align:center">' . $image . '</td>';
                break;
            case "title":
                $entry_type = '';
                $entry_type = get_kingkong_board_meta_value($entry_id, 'type');
                $entry_attachment = get_post_meta($entry_id, 'kingkongboard_attached', true);
                $entry_secret = get_post_meta($entry_id, 'kingkongboard_secret', true);
                if ($entry_attachment) {
                    $entry_attach_text = "<i class='kkb-icon kkb-icon-attachment'></i>";
                } else {
                    $entry_attach_text = "";
                }
                if ($entry_secret) {
                    $entry_secret_icon = '<img src="' . KINGKONGBOARD_PLUGINS_URL . '/assets/images/icon-locked.png" style="width:12px; height:auto; position:relative; top:0px; margin-left:5px">';
                } else {
                    $entry_secret_icon = '';
                }
                $parent = get_kingkong_board_meta_value($entry_id, 'parent');
                $entry_depth = get_kingkong_board_meta_value($entry_id, 'depth');
                $writer = get_kingkong_board_meta_value($entry_id, 'writer');
                if ($entry_depth > 1) {
                    $padding = 10 * $entry_depth;
                    $reply_padding = 'style="padding-left:' . $padding . 'px;"';
                    $reply_icon = '<img src="' . KINGKONGBOARD_PLUGINS_URL . '/assets/images/icon-reply.gif" style="width:25px; height:auto; position:relative; top:3px; margin-right:5px">';
                    $parent_id = '&prnt=' . $parent;
                } else {
                    $reply_padding = '';
                    $reply_icon = '';
                    $parent_id = '';
                }
                $return_content .= "<td " . $reply_padding . ">" . $reply_icon . "<a href='?page=KingkongBoard&view=entry-view&id=" . $entry_id . $parent_id . "'>" . get_the_title($entry_id) . "</a>" . $entry_attach_text . $entry_secret_icon . "</td>";
                break;
            case "date":
                $return_content .= "<td>" . get_the_date('Y-m-d H:i:s', $entry_id) . "</td>";
                break;
            case "writer":
                $user_id = $controller->getMeta($entry_id, 'login_id');
                $post = get_post($entry_id);
                $writer = kingkongboard_text_cut($writer, 8, "...");
                $user_id > 1 ? $writer_path = '<a href="' . get_edit_user_link($user_id) . '">' . $writer . '</a>' : ($writer_path = $writer);
                $return_content .= "<td>" . $writer_path . "</td>";
                break;
            case "options":
                $guid = $controller->getMeta($entry_id, 'guid');
                $preview_path = add_query_arg(array('view' => 'read', 'id' => $entry_id), get_the_permalink($guid));
                $return_content .= "<td style='text-align:left'><a href='admin.php?page=KingkongBoard&view=entry-modify&id=" . $entry_id . "' class='button-kkb kkbgreen button-modify-each-entry' data='" . $entry_id . "'><i class='kkb-icon kkb-icon-modify'></i></a> <a class='button-kkb kkbred button-remove-each-entry' data='" . $entry_id . "'><i class='kkb-icon kkb-icon-trash'></i></a> <a href='" . $preview_path . "' target='_blank' class='button-kkb kkbyellow' data='" . $entry_id . "'><i class='kkb-icon kkb-icon-preview'></i></a></td>";
                break;
        }
    }
    return $return_content;
}
Пример #3
0
 public function comment_notification($entry_id, $comment_id, $content)
 {
     $controller = new kkbController();
     $board_id = $controller->getMeta($entry_id, 'board_id');
     $comment = get_comment($comment_id);
     $notice_comment = get_post_meta($board_id, 'kingkongboard_notice_comment', true);
     $emails = get_post_meta($board_id, 'kingkongboard_notice_emails', true);
     $board_title = get_the_title($board_id);
     $entry_title = get_the_title($entry_id);
     $entry_title = str_replace('Private:', '', $entry_title);
     $entry_title = str_replace('비공개: ', '', $entry_title);
     $headers[] = 'From: ' . __('관리자', 'kingkongboard') . ' <' . get_bloginfo('admin_email') . '>';
     $body = __('작성자', 'kingkongboard') . ': ' . $controller->getMeta($entry_id, 'writer') . "\r\n\r\n";
     $body .= __('댓글내용', 'kingkongboard') . ': ' . $content;
     $body .= "\r\n\r\n바로가기 : " . get_the_permalink($entry_id);
     if ($emails) {
         $emails = explode(",", $emails);
         if ($notice_comment == 'checked') {
             wp_mail($emails, '[' . get_bloginfo('name') . '] ' . sprintf(__('%s 글 신규댓글 알림 : %s', 'kingkongboard'), $entry_title, $comment->comment_content), $body, $headers);
         }
     }
 }
<?php

$entry_id = $board_id;
$Board = new kkbController();
$board_id = $Board->getMeta($entry_id, 'board_id');
if (isset($_POST['entry_title'])) {
    $entry_title = sanitize_text_field($_POST['entry_title']);
} else {
    $entry_title = null;
}
if ($entry_title) {
    $Board->writeModify($_POST, 'admin');
}
$current_user = wp_get_current_user();
$hour_options = null;
$minute_options = null;
$second_options = null;
for ($i = 0; $i < 24; $i++) {
    if ($i == date('H', $Board->getMeta($entry_id, 'date'))) {
        $hour_options .= '<option selected>' . $i . '</option>';
    } else {
        $hour_options .= '<option>' . $i . '</option>';
    }
}
for ($i = 0; $i < 60; $i++) {
    if ($i == date('i', $Board->getMeta($entry_id, 'date'))) {
        $minute_options .= '<option selected>' . $i . '</option>';
    } else {
        $minute_options .= '<option>' . $i . '</option>';
    }
}
<?php

list($path) = explode(DIRECTORY_SEPARATOR . 'wp-content', dirname(__FILE__) . DIRECTORY_SEPARATOR);
include $path . DIRECTORY_SEPARATOR . 'wp-load.php';
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
if (!stristr($referer, $host)) {
    wp_die('KINGKONG BOARD : ' . __('지금 페이지는 외부 접근이 차단되어 있습니다.', 'kingkongboard'));
}
if (!isset($_POST)) {
    wp_die('KINGKONG BOARD : ' . __('잘못된 접근 입니다.', 'kingkongboard'));
}
include_once ABSPATH . 'wp-includes/pluggable.php';
$kkb_comment = new kkbComment();
$kkb_comment->kkb_comment_save($_POST);
$controller = new kkbController();
$post_id = $controller->getMeta($_POST['entry_id'], 'guid');
$board_id = $controller->getMeta($_POST['entry_id'], 'board_id');
$iframe_use = get_post_meta($board_id, 'kkb_iframe_use', true);
$return_args = array('view' => 'read', 'id' => $_POST['entry_id']);
if ($iframe_use == 'T') {
    $return_args['kkb_mod'] = 'iframe';
}
$return_path = add_query_arg($return_args, get_the_permalink($post_id));
header("Location: " . $return_path);
Пример #6
0
 /**
  * 게시글의 태그를 불러온다.
  **/
 public function getTags($bid)
 {
     global $wpdb;
     $result_tags = null;
     $controller = new kkbController();
     $tax_table = $wpdb->prefix . 'term_taxonomy';
     $relation_table = $wpdb->prefix . 'term_relationships';
     $kkb_tags = $wpdb->get_results("SELECT term_taxonomy_id FROM {$tax_table} WHERE taxonomy = 'kkb_tag' ORDER BY count ASC");
     if ($kkb_tags) {
         foreach ($kkb_tags as $tag) {
             $term_ids[] = $tag->term_taxonomy_id;
         }
         if ($term_ids) {
             $term_ids = join(',', $term_ids);
             $relations = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM {$relation_table} WHERE term_taxonomy_id IN ({$term_ids})");
             if ($relations) {
                 foreach ($relations as $relation) {
                     $entry_id = $relation->object_id;
                     $get_board_id = $controller->getMeta($entry_id, 'board_id');
                     if ($bid == $get_board_id) {
                         $result_tags[] = $relation->term_taxonomy_id;
                     }
                 }
             }
         }
     }
     if ($result_tags) {
         $result_tags = join(',', $result_tags);
         $results = $wpdb->get_results("SELECT term_taxonomy_id FROM {$tax_table} WHERE term_taxonomy_id IN ({$result_tags}) ORDER BY count DESC LIMIT 8");
         foreach ($results as $result) {
             $terms[] = $result->term_taxonomy_id;
         }
         $result_tags = $terms;
     }
     return $result_tags;
 }
Пример #7
0
 public function kkb_comment_save($data)
 {
     $entry_id = kingkongboard_xssfilter(kingkongboard_htmlclear($data['entry_id']));
     $controller = new kkbController();
     $board_id = $controller->getMeta($entry_id, 'board_id');
     $comment_html_use = get_post_meta($board_id, 'kkb_comment_html_use', true);
     if ($comment_html_use == 'T') {
         $content = kingkongboard_xssfilter($data['kkb_comment_content']);
     } else {
         $content = kingkongboard_xssfilter(kingkongboard_htmlclear($data['kkb_comment_content']));
     }
     $content = apply_filters('kkb_comment_write_content_xssfilter_after', $content, $data['kkb_comment_content'], $board_id);
     isset($data['comment_parent']) ? $comment_parent = kingkongboard_xssfilter(kingkongboard_htmlclear($data['comment_parent'])) : ($comment_parent = null);
     if ($controller->actionCommentPermission($board_id, null, 'write') == true) {
         if ($comment_parent) {
             $parent = $comment_parent;
         } else {
             $parent = 0;
         }
         if (is_user_logged_in()) {
             global $current_user;
             get_currentuserinfo();
             $writer = $current_user->display_name;
             $email = $current_user->user_email;
             $user_id = $current_user->ID;
         } else {
             $writer = kingkongboard_xssfilter(kingkongboard_htmlclear($data['writer']));
             $email = kingkongboard_xssfilter(kingkongboard_htmlclear($data['email']));
             $user_id = 0;
         }
         if (!empty($data['comment_origin'])) {
             $origin = sanitize_text_field($data['comment_origin']);
         } else {
             $origin = 0;
         }
         if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
             $ip = $_SERVER['HTTP_CLIENT_IP'];
         } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
             $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
         } else {
             $ip = $_SERVER['REMOTE_ADDR'];
         }
         $time = current_time('mysql');
         $comment = array('comment_post_ID' => $entry_id, 'comment_author' => $writer, 'comment_author_email' => $email, 'comment_author_url' => '', 'comment_content' => $content, 'comment_type' => '', 'comment_parent' => $parent, 'user_id' => $user_id, 'comment_author_IP' => $ip, 'comment_agent' => $_SERVER['HTTP_USER_AGENT'], 'comment_date' => $time, 'comment_approved' => 1);
         $comment_id = wp_insert_comment($comment);
         if (!is_wp_error($comment_id)) {
             $parent_depth = $this->kkb_get_comment_meta($comment_parent, 'depth');
             $parent_origin = $this->kkb_get_comment_meta($comment_parent, 'origin');
             if (!$parent_depth) {
                 $parent_depth = 0;
             }
             if ($parent_origin) {
                 if ($parent_origin == $comment_parent) {
                     $origin = $comment_parent;
                 } else {
                     $origin = $parent_origin;
                 }
             } else {
                 $origin = $comment_id;
             }
             $input_meta = array('lnumber' => 1, 'eid' => $entry_id, 'cid' => $comment_id, 'origin' => $origin, 'parent' => $comment_parent, 'depth' => $parent_depth + 1);
             $this->kkb_update_comment_meta($input_meta);
             if (!is_user_logged_in()) {
                 update_comment_meta($comment_id, 'kkb_comment_password', md5($data['password']));
             }
             do_action('kingkongboard_save_comment_after', $entry_id, $comment_id, $content);
             return $comment_id;
         }
     }
 }
Пример #8
0
 public function view($view)
 {
     global $post;
     switch ($view) {
         case 'list':
             ob_start();
             require_once KINGKONGBOARD_ABSPATH . "includes/view.list.php";
             $content = ob_get_contents();
             ob_end_clean();
             break;
         case 'read':
             $entry_type = parent::getMeta($this->entry_id, 'type');
             if ($this->entry_id && parent::actionPermission($this->board_id, $this->entry_id, 'read') == true && $entry_type <= 1) {
                 switch (parent::checkSecret($this->board_id, $this->entry_id)) {
                     case 0:
                         // 열람가능
                         ob_start();
                         require_once kkb_template_path("view.read.php");
                         $content = ob_get_contents();
                         ob_end_clean();
                         break;
                     case 1:
                         ob_start();
                         require_once kkb_template_path("view.read.check.php");
                         $content = ob_get_contents();
                         ob_end_clean();
                         break;
                     case 2:
                         // 회원, 본인글이 아니므로 열람 불가하다.
                         return apply_filters('kkb_read_secret_denied', __('비밀글 입니다. 작성자 본인과 관리자만 열람할 수 있습니다.', 'kingkongboard'), $this->board_id);
                         break;
                 }
             } else {
                 $content = apply_filters('kkb_loop_read_denied_message', __('권한이 없거나 게시글이 존재하지 않습니다.', 'kingkongboard'), $this->board_id);
             }
             break;
         case 'write':
             if (parent::actionPermission($this->board_id, null, 'write') == true) {
                 ob_start();
                 require_once kkb_template_path("view.write.php");
                 $content = ob_get_contents();
                 ob_end_clean();
             } else {
                 $content = apply_filters('kkb_loop_write_denied_message', __('글 쓰기 권한이 없습니다.', 'kingkongboard'), $this->board_id);
             }
             break;
         case 'modify':
             if (parent::actionPermission($this->board_id, $this->entry_id, 'modify') == true) {
                 ob_start();
                 require_once kkb_template_path("view.modify.php");
                 $content = ob_get_contents();
                 ob_end_clean();
             } else {
                 $content = apply_filters('kkb_loop_modify_denied_message', __('글수정 권한이 없습니다.', 'kingkongboard'), $this->board_id);
             }
             break;
         case 'reply':
             $parent_type = parent::getMeta($this->entry_id, 'type');
             if (parent::actionPermission($this->board_id, $this->entry_id, 'reply') == true && $parent_type != 1) {
                 ob_start();
                 require_once kkb_template_path("view.reply.php");
                 $content = ob_get_contents();
                 ob_end_clean();
             } else {
                 $content = apply_filters('kkb_loop_reply_denied_message', __('답글쓰기가 허용되지 않습니다.', 'kingkongboard'), $this->board_id);
             }
             break;
         case 'delete':
             if (parent::actionPermission($this->board_id, $this->entry_id, 'delete') == true) {
                 ob_start();
                 require_once kkb_template_path("view.delete.php");
                 $content = ob_get_contents();
                 ob_end_clean();
             } else {
                 $content = apply_filters('kkb_loop_delete_denied_message', __('글 삭제 권한이 없습니다.', 'kingkongboard'), $this->board_id);
             }
             break;
         case 'cmtcheck':
             if (isset($_GET['mod']) && isset($_GET['cid'])) {
                 $cid = sanitize_text_field($_GET['cid']);
                 $mod = sanitize_text_field($_GET['mod']);
                 $exists = get_comment($cid);
                 if (isset($exists->comment_ID)) {
                     if (parent::actionCommentPermission($this->board_id, $cid, $mod) == true) {
                         ob_start();
                         require_once KINGKONGBOARD_ABSPATH . "includes/view.read.comment.check.php";
                         $content = ob_get_contents();
                         ob_end_clean();
                     } else {
                         $content = apply_filters('kkb_comment_permission_denied_message', __('권한이 없습니다.', 'kingkongboard'), $this->board_id);
                     }
                 } else {
                     $content = apply_filters('kkb_comment_noexists_message', __('존재하지 않는 댓글 입니다.', 'kingkongboard'), $this->board_id);
                 }
             } else {
                 $content = apply_filters('kkb_comment_action_denied_message', __('잘못된 접근 입니다.', 'kingkongboard'), $this->board_id);
             }
             break;
     }
     return $content;
 }
<?php

$parent_id = '';
if (isset($_POST['entry_title'])) {
    $entry_title = sanitize_text_field($_POST['entry_title']);
} else {
    $entry_title = false;
}
if ($entry_title) {
    $Board = new kkbController();
    $board_id = $Board->getMeta($_GET['id'], 'board_id');
    $Board->writeEntry($board_id, $_POST, 'admin');
}
if (isset($_GET['parent'])) {
    $parent = sanitize_text_field($_GET['parent']);
} else {
    $parent = false;
}
if ($parent) {
    if ($parent != '') {
        $parent_id = $parent;
    }
} else {
    $parent_id = sanitize_text_field($_GET['id']);
}
$current_user = wp_get_current_user();
$hour_options = null;
$minute_options = null;
$second_options = null;
for ($i = 0; $i < 24; $i++) {
    if ($i == date('H', current_time('timestamp', 0))) {
Пример #10
0
 public function kkb_comment_modify($data)
 {
     global $wpdb;
     $table = $wpdb->prefix . 'comments';
     $controller = new kkbController();
     $content = kingkongboard_xssfilter(kingkongboard_htmlclear($data['kkb_comment_modify_textarea']));
     $entry_id = kingkongboard_xssfilter(kingkongboard_htmlclear($data['entry_id']));
     $board_id = $controller->getMeta($entry_id, 'board_id');
     $cid = $data['cid'];
     if ($controller->actionCommentPermission($board_id, $cid, 'modify') == true) {
         $wpdb->update($table, array('comment_content' => $content), array('comment_ID' => $cid), array('%s'), array('%d'));
     }
 }