/** * kingkongboard_meta 테이블을 작성한다. * @param array $data, int $entry_id * @return boolen */ public function writeTable($board_id, $entry_id, $data) { if ($board_id && $data && $entry_id) { global $wpdb, $current_user; if (is_user_logged_in()) { $user_id = $current_user->ID; $writer = $current_user->display_name; isset($data['entry_writer']) ? $writer = $data['entry_writer'] : ($writer = $writer); isset($data['entry_write_guest']) ? $user_id = 0 : ($user_id = $current_user->ID); } else { $user_id = 0; $writer = $data['entry_writer']; } $date = get_the_date("Y-m-d H:i:s", $entry_id); $mktime = strtotime($date); $writer = kingkongboard_xssfilter(kingkongboard_htmlclear($writer)); $listNumber = 1; if (isset($data['entry_notice'])) { switch ($data['entry_notice']) { case "notice": $entry_type = 1; break; default: $entry_type = 0; break; } } else { $entry_type = 0; } isset($data['post_id']) ? $guid = $data['post_id'] : ($guid = $data['entry_guid']); isset($data['entry_section']) ? $entry_section = $data['entry_section'] : ($entry_section = null); !isset($data['parent']) ? $data['parent'] = $entry_id : ($data['parent'] = $data['parent']); !isset($data['origin']) ? $data['origin'] = $entry_id : ($data['origin'] = $data['origin']); $depth = $this->getEntryDepth($data['origin']); $table = $wpdb->prefix . 'kingkongboard_meta'; $status = $wpdb->insert($table, array('post_id' => $entry_id, 'section' => $entry_section, 'board_id' => $board_id, 'related_id' => $data['parent'], 'list_number' => $listNumber, 'depth' => $depth, 'parent' => $data['origin'], 'type' => $entry_type, 'date' => $mktime, 'guid' => $guid, 'login_id' => $user_id, 'writer' => $writer), array('%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')); if (!is_wp_error($status)) { $status = $this->listChanger($board_id, $entry_id, $wpdb->insert_id, $data['origin']); return $status; } else { return false; } } else { return false; } }
/** * data, entry_id 값을 받아 킹콩보드 메타 테이블에 레코드를 삽입한다. * @param string $entry_id * @return boolen */ public function kkb_entry_write_kkbtable($data, $entry_id) { if ($data && $entry_id) { global $wpdb, $current_user; if (is_user_logged_in()) { $user_id = $current_user->ID; $writer = $current_user->display_name; if (isset($data['entry_writer'])) { $writer = $data['entry_writer']; } } else { $user_id = 0; $writer = $data['entry_writer']; } $config = $this->config; $mktime = $this->kkb_entry_timetoMK($entry_id); $writer = kingkongboard_xssfilter(kingkongboard_htmlclear($writer)); if ($this->mode == "admin") { $guid = $data['entry_guid']; } else { $guid = $data['page_id']; } if (!isset($data['parent'])) { $data['parent'] = $entry_id; } if (!isset($data['origin'])) { $data['origin'] = $entry_id; } if (isset($data['entry_section'])) { $entry_section = $data['entry_section']; } else { $entry_section = null; } $depth = $this->get_kkb_entry_depth($data['origin']); $listNumber = 1; if (isset($data['entry_notice'])) { switch ($data['entry_notice']) { case "notice": $entry_type = 1; break; default: $entry_type = 0; break; } } else { $entry_type = 0; } $status = $wpdb->insert($config->meta_table, array('post_id' => $entry_id, 'section' => $entry_section, 'board_id' => $config->bid, 'related_id' => $data['parent'], 'list_number' => $listNumber, 'depth' => $depth, 'parent' => $data['origin'], 'type' => $entry_type, 'date' => $mktime, 'guid' => $guid, 'login_id' => $user_id, 'writer' => $writer), array('%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')); if (!is_wp_error($status)) { $this->kkb_entry_list_changer($wpdb->insert_id, $data['origin']); } } else { return kingkongboard_error_message("kkb_entry_write_kkbtable"); } }
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; } } }
$board_reply_use = get_post_meta($this->board_id, 'kkb_reply_use', true); if (isset($_GET['prnt'])) { $parent = sanitize_text_field($_GET['prnt']); if ($parent != '') { $parent_id = $parent; $parent_prm = '&prnt=' . $parent_id; } } else { $parent_id = $entry_id; $parent_prm = ''; } $config->editor == 'wp_editor' ? $content = nl2br(get_post_field('post_content', $entry_id)) : ($content = wpautop(get_post_field('post_content', $entry_id), true)); if ($config->auto_link == 'T') { $content = preg_replace('/((http|https):\\/\\/[\\w-]+(\\.[\\w-]+)+([\\w.,@?^=%&:\\/~+#-]*[\\w@?^=%&\\/~+#-])?)/', '<a href="\\1" target="_blank">\\1</a>', $content); } $content = kingkongboard_xssfilter($content); $content = html_entity_decode($content); $content = apply_filters('the_content', $content); $content = do_shortcode($content); if ($board_thumbnail_input == "T") { $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($entry_id), "full"); $thumb_img = get_post_meta(get_post_thumbnail_id($entry_id)); if (isset($thumb_img['_wp_attachment_image_alt']['0'])) { $thumb_alt = $thumb_img['_wp_attachment_image_alt']['0']; } else { $thumb_alt = __('본문에 추가된 대표 썸네일 사진', 'kingkongboard'); } $thumbnail && !empty($thumbnail) ? $thumbnail_image = '<img src="' . $thumbnail[0] . '" style="max-width:70%; height:auto" alt="' . $thumb_alt . '"><br><br>' : ($thumbnail_image = null); } else { $thumbnail = null; $thumbnail_image = null;