function get_car_by_shop_goo($shop_url, $shop_name, $user_id, $tuku_shop_url) { $cat_id = make_category($shop_name); for ($i = 1; $i < 5; $i++) { $html = file_get_html($shop_url . "stock.html"); //車のURL取得 echo $shop_url . PHP_EOL; if ($html) { foreach ($html->find("table.itemDetail") as $car) { $car_single_url = "http://www.goo-net.com" . $car->find("a", 0)->href; $car_title = $car->find(".first .tit2 a", 0)->plaintext; $car_img = $car->find(".img2 img", 0)->src; $car_id = is_car_regitered($car_single_url); regist_car_goo($car_single_url, $cat_id, $car_title, $user_id, $shop_url, $car_id, $car_img, $tuku_shop_url); } $html->clear(); unset($html); } } }
<?php include "./simple_html_dom.php"; include "../../../wp-load.php"; include "../../../wp-admin/includes/taxonomy.php"; query_posts("post_type=post&posts_per_page=-1&post_status=publish"); if (have_posts()) { while (have_posts()) { the_post(); $maker = get_post_meta($post->ID, "maker", true); $model = get_post_meta($post->ID, "model", true); $id = make_category($maker); echo make_category($model, $id); } } else { } function make_category($slug, $parent = null) { //既存カテゴリをすべて取得 $categories = get_categories($args); //print_r($categories); $flag = 0; foreach ($categories as $cat) { if ($slug == $cat->name) { $flag = 1; $cat_id = $cat->cat_ID; break; } } if ($flag != 1) { //重複無ければ
function index() { $board =& $this->board; $member =& $this->member; $write =& $this->write; $seg =& $this->seg; $param =& $this->param; $w = $seg->get('w'); // 모드 $wr_id = $seg->get('wr_id'); // 게시물아이디 $qstr = $seg->output() . $param->output(); $sca = $param->get('sca'); // 분류 $js = array('jquery/validate'); // JavaScript Files // 개인게시판 권한 if ($board['bo_use_private'] && !IS_ADMIN) { alert('작성 권한이 없습니다.'); } // I will be back. $return_url = url_encode('board/' . BO_TABLE . '/write' . $qstr); // 공지사항 $notice_array = explode(',', trim($board['bo_notice'])); if ($w == 'u' || $w == 'r') { if (!isset($write['wr_id'])) { alert("글이 존재하지 않습니다.\\n\\n삭제되었거나 이동된 경우입니다.", 'board/' . BO_TABLE . '/lists'); } $sca = $write['ca_code']; } if ($w == '') { if ($wr_id) { alert('글쓰기에는 wr_id 값을 사용하지 않습니다.', 'board/' . BO_TABLE); } if ($member['mb_level'] < $board['bo_write_level']) { if (IS_MEMBER) { alert('글을 쓸 권한이 없습니다.'); } else { alert("글을 쓸 권한이 없습니다.\\n\\n회원이라면 로그인 후 이용하세요.", "member/login/qry/" . $return_url); } } $title_msg = '글쓰기'; } else { if ($w == 'u') { if (IS_MEMBER && $write['mb_id'] == $member['mb_id']) { // 자신의 글이면 통과 } else { if ($member['mb_level'] < $board['bo_write_level']) { if (IS_MEMBER) { alert('글을 수정할 권한이 없습니다.'); } else { alert("글을 수정할 권한이 없습니다.\\n\\n회원이라면 로그인 후 이용하세요.", "member/login/qry/" . $return_url); } } } // 수정 권한 IF if (IS_ADMIN == 'group' || IS_ADMIN == 'board') { $mb = $this->Basic_model->get_member($write['mb_id'], 'mb_level'); $mb_level = isset($mb['mb_level']) ? $mb['mb_level'] : 1; } if (IS_ADMIN == 'super') { // 통과 } else { if (IS_ADMIN == 'group') { // 그룹관리자 if ($member['mb_id'] == $board['gr_admin']) { // 자신이 관리하는 그룹인가 if ($member['mb_level'] < $mb_level) { // 자신의 레벨이 낮다면 alert('그룹관리자의 권한보다 높은 회원의 글이므로 수정할 수 없습니다.'); } } else { alert('자신이 관리하는 그룹의 게시판이 아니므로 글을 수정할 수 없습니다.'); } } else { if (IS_ADMIN == 'board') { // 게시판관리자 if ($member['mb_id'] == $board['bo_admin']) { // 자신이 관리하는 게시판인가 if ($member['mb_level'] < $mb_level) { // 자신의 레벨이 낮다면 alert('게시판관리자의 권한보다 높은 회원의 글이므로 수정할 수 없습니다.'); } } else { alert('자신이 관리하는 게시판이 아니므로 글을 수정할 수 없습니다.'); } } else { if ($write['mb_id']) { if (!IS_MEMBER || $member['mb_id'] != $write['mb_id']) { alert('자신의 글이 아니므로 수정할 수 없습니다.'); } } else { $CI =& get_instance(); $CI->load->library('encrypt'); if (md5($this->input->post('password')) !== $CI->encrypt->decode($write['wr_password'])) { alert('비밀번호가 맞지 않습니다.'); } } } } } // 원글만 구한다. $cnt = $this->Board_model->is_reply(BO_TABLE, $wr_id, $write['wr_num'], $write['wr_reply']); if ($cnt && !IS_ADMIN) { alert("이 글과 관련된 답변글이 존재하므로 수정할 수 없습니다.\\n\\n답변글이 있는 원글은 수정할 수 없습니다."); } // 댓글 달린 원글의 수정 여부 if ($board['bo_count_modify'] > 0) { $cnt = $this->Board_model->is_comment(BO_TABLE, $wr_id, IS_MEMBER ? $member['mb_id'] : ''); if ($cnt >= $board['bo_count_modify'] && !IS_ADMIN) { alert("이 글과 관련된 댓글가 존재하므로 수정할 수 없습니다.\\n\\n댓글가 " . $board['bo_count_modify'] . "건 이상 달린 원글은 수정할 수 없습니다."); } } $title_msg = '글수정'; } else { if ($w == 'r') { if ($member['mb_level'] < $board['bo_reply_level']) { if (IS_MEMBER) { alert('글을 답변할 권한이 없습니다.'); } else { alert("글을 답변할 권한이 없습니다.\\n\\n회원이라면 로그인 후 이용하세요.", "member/login/qry/" . $return_url); } } if (in_array((int) $wr_id, $notice_array)) { alert('공지에는 답변 할 수 없습니다.'); } // 비밀글인지를 검사 if (strpos($write['wr_option'], 'secret') !== FALSE) { if ($write['mb_id']) { // 회원의 경우는 해당 글쓴 회원 및 관리자 if (!($write['mb_id'] == $member['mb_id'] || IS_ADMIN)) { alert('비밀글에는 자신 또는 관리자만 답변이 가능합니다.'); } } else { // 비회원의 경우는 비밀글에 답변이 불가함 if (!IS_ADMIN) { alert('비회원의 비밀글에는 답변이 불가합니다.'); } } } // 최대 답변은 테이블에 잡아놓은 wr_reply 사이즈만큼만 가능합니다. if (strlen($write['wr_reply']) == 10) { alert("더 이상 답변하실 수 없습니다.\\n\\n답변은 10단계 까지만 가능합니다."); } $reply = $this->Board_model->get_reply_step(BO_TABLE, $write['wr_num'], $board['bo_reply_order'], $write['wr_reply']); $title_msg = '글답변'; } else { alert('잘못된 접근입니다.'); } } } $notice_checked = $secret_checked = 0; // check 필드 $is_notice = $is_nocomt = FALSE; if (IS_ADMIN) { if ($board['bo_use_comment']) { $is_nocomt = TRUE; } if ($w != 'r') { $is_notice = TRUE; if ($w == 'u') { // 답변 수정시 공지 체크 없음 if ($write['wr_reply']) { $is_notice = FALSE; } else { $notice_checked = in_array((int) $wr_id, $notice_array) ? 1 : 0; } } } } $is_secret = $board['bo_use_secret']; $is_editor = $board['bo_use_editor'] ? TRUE : FALSE; $is_email = $this->config->item('cf_use_email') && $board['bo_use_email'] && $this->config->item('cf_email_wr_write') ? TRUE : FALSE; $is_sign = !IS_MEMBER || IS_ADMIN && $w == 'u' && $member['mb_id'] != $write['mb_id'] ? TRUE : FALSE; // 분류 $category = FALSE; if ($board['bo_use_category']) { $this->load->helper('category'); $category = make_category(array('type' => 'bo_' . BO_TABLE, 'id' => 'ca_code', 'code' => $sca)); } $name = $email = ''; if ($w == '' || $w == 'r') { if (IS_MEMBER) { $name = cut_str(get_text($write['wr_name']), 20); $email = $member['mb_email']; } if ($w == 'r' && strpos($write['wr_option'], 'secret') !== FALSE) { $is_secret = TRUE; $secret_checked = 1; } } else { if ($w == 'u') { $name = cut_str(get_text($write['wr_name']), 20); $email = $write['wr_email']; if (strpos($write['wr_option'], 'secret') !== FALSE) { $secret_checked = 1; } } } // 히든 옵션 $option_hidden = ''; if ($is_editor) { $option_hidden .= "<input type='hidden' name='editor' value='editor' />"; } // 옵션 박스 $option = $option_check = array(); if ($is_notice) { $option['notice'] = array('title' => '공지', 'value' => '1'); $option_check['notice'] = $notice_checked; } if ($is_secret) { if (IS_ADMIN || $is_secret == 1) { $option['secret'] = array('title' => '비밀글', 'value' => 'secret'); $option_check['secret'] = $secret_checked; } else { $option_hidden .= "<input type='hidden' name='secret' value='secret' />"; } } if ($is_email) { $option['mail'] = array('title' => '답변메일받기', 'value' => 'mail'); $option_check['mail'] = $w == 'u' && strpos($write['wr_option'], 'mail') !== FALSE ? 1 : 0; } if ($is_nocomt) { $option['nocomt'] = array('title' => '댓글금지', 'value' => 'nocomt'); $option_check['nocomt'] = strpos($write['wr_option'], 'nocomt') !== FALSE ? 1 : 0; } // 제목 $subject = cut_str(get_text($write['wr_subject']), 255); // 내용 if ($w == '') { $content = $board['bo_insert_content']; } else { if ($w == 'r') { $subject = ''; $content = $board['bo_insert_content']; } else { if ($is_editor) { $content = str_replace('&', '&', $write['wr_content']); } else { $content = get_text($write['wr_content']); } } } // 에디터 $editor = $editorConfig = ''; if ($is_editor) { $attach = array(); if ($w == 'u' && ($write['wr_count_file'] || $write['wr_count_image'])) { $CI =& get_instance(); $CI->load->model('Board_file_model'); $result = $CI->Board_file_model->get_files(BO_TABLE, $wr_id, 'bf_no,bf_editor,bf_source,bf_file,bf_filesize', 'all'); $base_url = $this->config->item('base_url'); foreach ($result as $row) { $filename = $row['bf_source']; if ($row['bf_editor']) { $filepath = $base_url . DATA_DIR . '/file/' . BO_TABLE . '/' . $row['bf_file']; $attach['image'][] = array('attacher' => 'image', 'data' => array('imageurl' => $filepath, 'filename' => $filename, 'filesize' => (int) $row['bf_filesize'], 'thumburl' => $filepath)); } else { $attach['file'][] = array('attacher' => 'file', 'data' => array('attachurl' => $base_url . RT_PATH . '/board/' . BO_TABLE . '/download/wr_id/' . $wr_id . '/no/' . $row['bf_no'], 'filemime' => 'application/octet-stream', 'filename' => $filename, 'filesize' => (int) $row['bf_filesize'])); } } } $editorConfig = array('editor' => array('initializedId' => '1', 'wrapper' => 'tx_trex_container', 'form' => 'fwrite', 'field' => 'wr_content', 'content' => $content, 'attachments' => $attach)); $editor = $this->load->view('board/editor', $editorConfig['editor'], TRUE); $content = ''; // 그냥 비우기 } // SyntaxHighlighter $syntax = FALSE; if ($board['bo_use_syntax'] && $is_editor) { $this->load->config('cf_syntax'); $syntax = $this->config->item('brush_name'); } $head = array('title' => $board['gr_subject'] . ' > ' . $board['bo_subject'] . ' > ' . $title_msg, 'sca' => $sca ? str_replace('.', '-', $sca) : ''); $data = array('title_msg' => $title_msg, 'w' => $w, 'wr_id' => $wr_id, 'sca_str' => $sca ? '?sca=' . $sca : '', 'qstr' => $param->replace('w,wr_id'), 'mb_id' => !$w && IS_MEMBER ? $member['mb_id'] : 'guest', 'name' => $name, 'email' => $email, 'subject' => $subject, 'content' => $content, 'editor' => $editor, 'editorConfig' => json_encode($editorConfig), 'option' => $option, 'option_check' => json_encode($option_check), 'option_hidden' => $option_hidden, 'category' => $category, 'is_editor' => $is_editor, 'is_sign' => $is_sign, 'syntax' => $syntax); // Extra if ($board['bo_use_extra']) { if ($w == 'u') { $data = array_merge($data, $this->Board_model->get_extra(BO_TABLE, $wr_id)); } else { $extra = $this->db->list_fields('ki_extra_' . BO_TABLE); foreach ($extra as $fld) { if ($fld == 'wr_id') { continue; } $data[$fld] = FALSE; } } } // JavaScript Load if ($is_editor) { $js[] = '../editor/js/editor_loader'; $js[] = 'editor_config'; } if (!IS_MEMBER) { $js[] = 'md5'; $js[] = 'kcaptcha'; } if ($board['bo_use_category']) { $js[] = 'category'; } widget::run('head', $head); $this->load->view('board/' . $board['bo_skin'] . '/write', $data); widget::run('tail', array('js' => $js)); }
function index($view = FALSE) { $board =& $this->board; $member =& $this->member; $wr_field =& $this->wr_field; $seg =& $this->seg; $param =& $this->param; $wr_id = $seg->get('wr_id'); // 게시물아이디 $page = $seg->get('page', 1); // 페이지 $qstr = $seg->replace('wr_id') . $param->output(); $sst = $param->get('sst'); // 정렬필드 $sod = $param->get('sod'); // 정렬순서 $sfl = $param->get('sfl'); // 검색필드 $stx = $param->get('stx'); // 검색어 $sca = $param->get('sca'); // 분류 $spt = $param->get('spt'); // 검색 파트 $js = array('board'); // JavaScript Files if ($member['mb_level'] < $board['bo_list_level']) { if (IS_MEMBER) { alert('목록을 볼 권한이 없습니다.'); } else { alert("목록을 볼 권한이 없습니다.\\n\\n회원이라면 로그인 후 이용하세요.", 'member/login/qry/' . url_encode('board/' . BO_TABLE . '/lists' . $qstr)); } } // 분류 사용 여부 $sca_str = $sca ? '?sca=' . $sca : ''; $category = FALSE; if ($board['bo_use_category']) { $this->load->helper('category'); $category = make_category(array('type' => 'bo_' . BO_TABLE, 'id' => 'ca_code', 'code' => $sca, 'lst' => TRUE)); } // 검색 파트 row $search_part = $this->config->item('cf_search_part'); $btn_prev_part = $btn_next_part = ''; // 분류 선택, 검색어, 검색 파트 적용 if ($sca || $sfl && $stx || $board['bo_count_write'] > $search_part) { if ($stx) { $stx = get_text($stx); } $min_spt = $board['bo_min_wr_num']; if (!$spt) { $spt = $min_spt; } $total_count = $this->Board_model->list_count(BO_TABLE, $spt, $sca, $sfl, $stx); $prev_spt = $spt - $search_part; if ($min_spt && $prev_spt >= $min_spt) { $btn_prev_part = '<li><a href="' . RT_PATH . '/board/' . BO_TABLE . '/lists' . $param->replace('spt', $prev_spt, $qstr) . '">이전검색</a></li>'; } $next_spt = $spt + $search_part; if ($next_spt < 0) { $btn_next_part = '<li><a href="' . RT_PATH . '/board/' . BO_TABLE . '/lists' . $param->replace('spt', $next_spt, $qstr) . '">다음검색</a></li>'; } } else { $total_count = $board['bo_count_write']; } $config['suffix'] = $qstr; $config['base_url'] = RT_PATH . '/board/' . BO_TABLE . '/lists/page/'; $config['per_page'] = $board['bo_page_rows']; $config['total_rows'] = $total_count; $config['uri_segment'] = $seg->pos('page'); // 검색 파트 ADD $config['full_tag_open'] = '<ul class="pagination">' . $btn_prev_part; $config['full_tag_close'] = $btn_next_part . '</ul>'; $CI =& get_instance(); $CI->load->library('pagination', $config); // 정렬 if (!$sst) { if ($board['bo_sort_field']) { $sst = $board['bo_sort_field']; } else { $sst = 'wr_num, wr_reply'; $sod = 'asc'; } } else { $sst = preg_match("/^(wr_datetime|wr_hit)\$/i", $sst) ? $sst : FALSE; } $offset = ($page - 1) * $config['per_page']; $result = $this->Board_model->list_result(BO_TABLE, $spt, $sca, $sst, $sod, $sfl, $stx, $config['per_page'], $offset, $wr_field); // 사이드 뷰 if ($board['bo_use_sideview']) { $this->load->helper('sideview'); } // 일반 리스트 $list = $wr_ids = array(); foreach ($result as $i => $row) { $row = get_convert($row, $board, $board['bo_subject_len'], $qstr, TRUE); $list[$i] = new stdClass(); $list[$i]->num = $total_count - ($page - 1) * $config['per_page'] - $i; $list[$i]->href = $row['href']; $list[$i]->wr_id = $row['wr_id']; $list[$i]->subject = strpos($sfl, 'subject') ? search_font($row['subject'], $stx) : $row['subject']; $list[$i]->comment_cnt = $row['comment_cnt']; $list[$i]->name = $row['name']; $list[$i]->datetime2 = $row['datetime2']; $list[$i]->wr_hit = $row['wr_hit']; $list[$i]->ico_reply = $row['ico_reply']; $list[$i]->ico_new = $row['ico_new']; $list[$i]->ico_hot = $row['ico_hot']; $list[$i]->ico_secret = $row['ico_secret']; $list[$i]->ico_file = $row['ico_file']; $list[$i]->ico_image = $row['ico_image']; $list[$i]->ico_movie = $row['ico_movie']; $wr_ids[$row['wr_id']] = $i; } // Extra if ($board['bo_use_extra'] && $wr_ids) { $result = $this->Board_model->get_extra(BO_TABLE, array_keys($wr_ids)); foreach ($result as $row) { $i = $wr_ids[$row['wr_id']]; foreach ($row as $fld => $val) { $list[$i]->{$fld} = $val; } } } // 공지사항 리스트 if (!$sca && !$stx) { $notice = explode(',', trim($board['bo_notice'])); if ($notice[0]) { $result = $this->Board_model->list_notice(BO_TABLE, $notice, $wr_field); $list_nt = array(); foreach ($result as $i => $row) { $row = get_convert($row, $board, $board['bo_subject_len'], $qstr, TRUE); $list_nt[$i] = new stdClass(); $list_nt[$i]->href = $row['href']; $list_nt[$i]->wr_id = $row['wr_id']; $list_nt[$i]->subject = $row['subject']; $list_nt[$i]->comment_cnt = $row['comment_cnt']; $list_nt[$i]->name = $row['name']; $list_nt[$i]->datetime2 = $row['datetime2']; $list_nt[$i]->wr_hit = $row['wr_hit']; } } } // 리스트 버튼 $btn_list = ''; if ($sfl && $stx) { $btn_list = '<a href="' . RT_PATH . '/board/' . BO_TABLE . '/lists' . $sca_str . '" class="btn btn-warning">목록</a>'; } // 글쓰기 버튼 $btn_write = ''; if ($board['bo_use_private'] && !IS_ADMIN) { $btn_write = FALSE; } elseif ($member['mb_level'] >= $board['bo_write_level']) { $btn_write = '<a href="' . RT_PATH . '/board/' . BO_TABLE . '/write' . $sca_str . '" class="btn btn-primary"><span class="glyphicon glyphicon-pencil"></span> 글쓰기</a>'; } // RSS 버튼 $btn_rss = ''; if ($board['bo_use_rss']) { $btn_rss = '<a href="' . RT_PATH . '/board/' . BO_TABLE . '/rss" class="btn btn-xs btn-warning" target="_blank">RSS</a>'; } // 관리자 버튼 $btn_admin = ''; if (SU_ADMIN) { $btn_admin = '<a href="' . RT_PATH . '/' . ADM_F . '/board/form/u/' . BO_TABLE . '" class="btn btn-xs btn-primary" target="_blank">관리자</a>'; } else { if (IS_ADMIN) { $btn_admin = '<button type="button" class="btn btn-xs btn-primary" onclick="board_admin();">관리자</button>'; } } // 관리자 체크박스 및 버튼 표시xsxs $btn_chkbox = ''; if (IS_ADMIN) { $btn_chkbox = '<button type="button" class="btn btn-danger" onclick="select_delete();">선택삭제</button>'; if (SU_ADMIN || IS_ADMIN == 'group') { $btn_chkbox .= '<button type="button" class="btn btn-info" onclick="select_copy(\'copy\');">선택복사</button>'; $btn_chkbox .= '<button type="button" class="btn btn-info" onclick="select_copy(\'move\');">선택이동</button>'; } } // 정렬 링크 $head = array('title' => $board['gr_subject'] . ' > ' . $board['bo_subject'], 'sca' => $sca); $data = array('total_count' => $total_count, 'category' => $category, 'btn_list' => $btn_list, 'btn_write' => $btn_write, 'btn_rss' => $btn_rss, 'btn_admin' => $btn_admin, 'btn_chkbox' => $btn_chkbox, 'wr_id' => $wr_id, 'sca' => $sca, 'sfl' => $sfl, 'stx' => $stx, 'list' => $list, 'list_nt' => isset($list_nt) ? $list_nt : array(), 'paging' => $CI->pagination->create_links(), 'sort_datetime' => $param->sort('wr_datetime', 'desc'), 'sort_hit' => $param->sort('wr_hit', 'desc')); if ($view) { $this->load->view('board/' . $board['bo_skin'] . '/list', $data); } else { // JavaScript Load if (IS_ADMIN) { $js[] = 'board_check'; } if ($board['bo_use_sideview']) { $js[] = 'sideview'; } if ($board['bo_use_category']) { $js[] = 'category'; } widget::run('head', $head); $this->load->view('board/' . $board['bo_skin'] . '/list', $data); widget::run('tail', array('js' => $js)); } }