예제 #1
0
 /**
  * 올바른 글의 순서를 위해 등록글의 번호와 부모글의 리스팅 번호를 비교해 업데이트 해준다.
  * @param string $post_id, $parent
  */
 public function listChanger($board_id, $entry_id, $post_id, $parent)
 {
     global $wpdb;
     $table = $wpdb->prefix . 'kingkongboard_meta';
     $results = $wpdb->get_results("SELECT * FROM {$table} WHERE board_id = {$board_id} AND ID != {$post_id} ORDER BY date ASC");
     $lastRst = $wpdb->get_row("SELECT * FROM {$table} WHERE board_id = {$board_id} AND ID = {$post_id}");
     $kkberror = new kkbError();
     if ($lastRst) {
         if ($lastRst->depth > 1) {
             $pNumber = $this->getListnumber($lastRst->parent);
             $Upresults = $wpdb->get_results("SELECT * FROM {$table} WHERE board_id = {$board_id} AND list_number > {$pNumber}");
             if ($Upresults) {
                 foreach ($Upresults as $Upresult) {
                     $this->updateListnumber($Upresult->ID, $Upresult->list_number + 1);
                 }
             }
             $this->updateListnumber($lastRst->ID, $pNumber + 1);
             return $entry_id;
         } else {
             if ($results) {
                 foreach ($results as $result) {
                     $this->updateListnumber($result->ID, $result->list_number + 1);
                 }
             }
             return $entry_id;
         }
     } else {
         return $kkberror->Error(011);
     }
 }
예제 #2
0
function kingkongboard_entry_password_check()
{
    global $current_user;
    $result = array();
    $entry_id = sanitize_text_field($_POST['entry_id']);
    $entry_pwd = sanitize_text_field($_POST['entry_pwd']);
    $entry_pwd = md5($entry_pwd);
    $board_id = get_kingkong_board_meta_value($entry_id, 'board_id');
    $added_user = get_kingkong_board_meta_value($entry_id, 'login_id');
    $entry_secret = get_post_meta($entry_id, 'kingkongboard_entry_password', true);
    $entry_password = get_post_meta($entry_id, 'kingkongboard_entry_password', true);
    $board_managers = get_post_meta($board_id, 'board_managers', true);
    if ($board_managers) {
        $board_managers = unserialize($board_managers);
    } else {
        $board_managers = array();
    }
    if (is_user_logged_in()) {
        $user_login = $current_user->user_login;
    } else {
        $user_login = null;
    }
    if (in_array($user_login, $board_managers) or current_user_can('manage_options') or $added_user == $current_user->ID and $added_user != 0) {
        $result['status'] = "success";
    } else {
        if ($entry_pwd == $entry_secret) {
            $result['status'] = "success";
        } else {
            $result['status'] = "failed";
            $error = new kkbError();
            if ($added_user != $current_user->ID && $added_user != 0) {
                $result['message'] = $error->getMessage(07);
            } else {
                $result['message'] = $error->getMessage(00);
            }
        }
    }
    header("Content-Type: application/json");
    echo json_encode($result);
    exit;
}
예제 #3
0
 /**
  * data, entry_id 값을 받아 포스트 메타 정보를 업데이트 한다.
  * @param string $data, $entry_id
  */
 public function writeMeta($board_id, $entry_id, $data)
 {
     $kkberror = new kkbError();
     if ($data && $entry_id) {
         if (isset($data['entry_attachment'])) {
             $entry_attachments = serialize($data['entry_attachment']);
             update_post_meta($entry_id, 'kingkongboard_attached', $entry_attachments);
         }
         if (isset($data['entry_password'])) {
             $entry_secret = $data['entry_password'];
             $entry_secret = md5($entry_secret);
             update_post_meta($entry_id, 'kingkongboard_entry_password', $entry_secret);
         }
         if (isset($data['entry_secret'])) {
             //update_post_meta($entry_id, 'kingkongboard_secret', 'on');
             $this->updateSecret($entry_id);
         }
         // 비밀글 답변글일때 기존 글 작성자가 비회원 이라면 기존글 비밀번호를 답변글에 적용한다.
         if (isset($data['write_type'])) {
             if ($data['write_type'] == 'reply') {
                 $parent_id = $this->getMeta($data['parent'], 'parent');
                 $parent_user = $this->getMeta($data['parent'], 'login_id');
                 $parent_secret = get_post_meta($parent_id, 'kingkongboard_secret', true);
                 if ($parent_user == 0 && !empty($parent_secret)) {
                     $entry_secret = get_post_meta($parent_id, 'kingkongboard_entry_password', true);
                     update_post_meta($entry_id, 'kingkongboard_entry_password', $entry_secret);
                 }
             }
         }
         $status = $this->writeTable($board_id, $entry_id, $data);
         if ($status == false) {
             return $kkberror->Error(010);
         } else {
             return $status;
         }
     } else {
         return $kkberror->Error(00);
     }
 }