Beispiel #1
0
function apms_popular_rows($arr)
{
    global $g5;
    $list = array();
    $rows = isset($arr['rows']) && $arr['rows'] > 0 ? $arr['rows'] : 10;
    $dayterm = isset($arr['dayterm']) && $arr['dayterm'] > 0 ? $arr['dayterm'] : 0;
    $term = isset($arr['term']) && $arr['term'] ? $arr['term'] : '';
    $term = $term == 'day' && $dayterm > 0 ? $dayterm : $term;
    $sql_term = apms_sql_term($term, 'pp_date');
    // 기간(일수,today,yesterday,month,prev)
    $sql = " select pp_word, count(pp_word) as cnt from {$g5['popular_table']} where 1 {$sql_term} group by pp_word order by cnt desc limit 0, {$rows} ";
    $result = sql_query($sql, false);
    for ($i = 0; $row = sql_fetch_array($result); $i++) {
        $list[$i] = $row;
        $list[$i]['cnt'] = $row['cnt'];
        $list[$i]['word'] = get_text($row['pp_word']);
        $list[$i]['href'] = G5_BBS_URL . '/search.php?stx=' . urlencode($list[$i]['word']);
    }
    return $list;
}
Beispiel #2
0
function apms_item_post_rows($arr)
{
    global $g5;
    $list = array();
    //정리
    $type = isset($arr['type']) && $arr['type'] ? apms_escape_string($arr['type']) : '';
    $pt_list = isset($arr['pt_list']) && $arr['pt_list'] ? apms_escape_string($arr['pt_list']) : '';
    $ex_pt = isset($arr['ex_pt']) && $arr['ex_pt'] ? apms_escape_string($arr['ex_pt']) : '';
    $ca_id = isset($arr['ca_id']) && $arr['ca_id'] ? apms_escape_string($arr['ca_id']) : '';
    $ex_ca = isset($arr['ex_ca']) && $arr['ex_ca'] ? apms_escape_string($arr['ex_ca']) : '';
    $mode = isset($arr['mode']) && $arr['mode'] ? $arr['mode'] : 'comment';
    $rows = isset($arr['rows']) && $arr['rows'] > 0 ? $arr['rows'] : 5;
    $page = isset($arr['page']) && $arr['page'] > 1 ? $arr['page'] : 1;
    $sort = isset($arr['sort']) && $arr['sort'] ? $arr['sort'] : '';
    $newtime = isset($arr['newtime']) && $arr['newtime'] > 0 ? $arr['newtime'] : 24;
    $thumb_w = isset($arr['thumb_w']) && $arr['thumb_w'] > 0 ? $arr['thumb_w'] : 0;
    $thumb_h = isset($arr['thumb_h']) && $arr['thumb_h'] > 0 ? $arr['thumb_h'] : 0;
    $thumb_no = isset($arr['thumb_no']) && $arr['thumb_no'] ? true : false;
    $no_img = isset($arr['no_img']) && $arr['no_img'] ? $arr['no_img'] : '';
    $start_rows = 0;
    // 타입
    $sql_type = $type ? "and b.it_type{$type} = '1'" : "";
    // 분류
    $sql_ca = $ca_id ? "and (b.ca_id like '{$ca_id}%' or b.ca_id2 like '{$ca_id}%' or b.ca_id3 like '{$ca_id}%')" : "";
    $sql_ca_ex = $ex_ca ? "and (b.ca_id not like '{$ex_ca}%' and b.ca_id2 not like '{$ex_ca}%' and b.ca_id3 not like '{$ex_ca}%')" : "";
    // 파트너
    $sql_pt = $pt_list ? "and find_in_set(b.pt_id, '{$pt_list}')" : "";
    $sql_pt_ex = $ex_pt ? "and find_in_set(b.pt_id, '{$ex_pt}')=0" : "";
    // 정렬
    $orderby = '';
    switch ($sort) {
        case 'hp':
            $orderby = 'b.it_price desc';
            break;
        case 'lp':
            $orderby = 'b.it_price asc';
            break;
        case 'qty':
            $orderby = 'b.it_sum_qty desc, ';
            break;
        case 'use':
            $orderby = 'b.it_use_cnt desc, ';
            break;
        case 'hit':
            $orderby = 'b.it_hit desc, ';
            break;
        case 'star':
            $orderby = 'b.it_use_avg desc';
            break;
        case 'comment':
            $orderby = 'b.pt_comment desc, ';
            break;
        case 'good':
            $orderby = 'b.pt_good desc, ';
            break;
        case 'nogood':
            $orderby = 'b.pt_nogood desc, ';
            break;
        case 'like':
            $orderby = '(b.pt_good - b.pt_nogood) desc, ';
            break;
    }
    $dayterm = isset($arr['dayterm']) && $arr['dayterm'] > 0 ? $arr['dayterm'] : 0;
    $term = isset($arr['term']) && $arr['term'] ? $arr['term'] : '';
    $term = $term == 'day' && $dayterm > 0 ? $dayterm : $term;
    $sql_term = apms_sql_term($term, 'b.it_datetime');
    // 기간(일수,today,yesterday,month,prev)
    if ($mode == 'comment') {
        $orderby .= "a.wr_id desc";
        $sql_common = "from `{$g5['apms_comment']}` a join `{$g5['g5_shop_item_table']}` b on (a.it_id=b.it_id)\n\t\t\t\t\t\twhere b.it_use = '1' and b.it_soldout <> '1' {$sql_type} {$sql_ca} {$sql_ca_ex} {$sql_pt} {$sql_pt_ex} {$sql_term} ";
    } else {
        if ($mode == 'use') {
            $orderby .= "a.is_id desc";
            $sql_common = "from `{$g5['g5_shop_item_use_table']}` a join `{$g5['g5_shop_item_table']}` b on (a.it_id=b.it_id)\n\t\t\t\t\t\twhere a.is_confirm = '1' and b.it_use = '1' and b.it_soldout <> '1' {$sql_type} {$sql_ca} {$sql_ca_ex} {$sql_pt} {$sql_pt_ex} {$sql_term} ";
        } else {
            if ($mode == 'qa') {
                $orderby .= "a.iq_id desc";
                $sql_common = "from `{$g5['g5_shop_item_qa_table']}` a join `{$g5['g5_shop_item_table']}` b on (a.it_id=b.it_id)\n\t\t\t\t\t\twhere b.it_use = '1' and b.it_soldout <> '1' {$sql_type} {$sql_ca} {$sql_ca_ex} {$sql_pt} {$sql_pt_ex} {$sql_term} ";
            } else {
                return;
            }
        }
    }
    if ($page > 1) {
        $total = sql_fetch("select count(*) as cnt {$sql_common} ", false);
        $total_count = $total['cnt'];
        $total_page = ceil($total_count / $rows);
        // 전체 페이지 계산
        $start_rows = ($page - 1) * $rows;
        // 시작 열을 구함
    }
    $result = sql_query(" select a.*, b.it_name {$sql_common} order by {$orderby} limit {$start_rows}, {$rows} ", false);
    for ($i = 0; $row = sql_fetch_array($result); $i++) {
        $list[$i] = thema_widget_item_list('item' . $mode, $ca_id, $row, $newtime, $thumb_w, $thumb_h, false, true);
        if (!$list[$i]['img']['src'] && $no_img) {
            $list[$i]['img'] = $thumb_no ? apms_thumbnail($no_img, 0, 0, false, true) : apms_thumbnail($no_img, $thumb_w, $thumb_h, false, true);
            // no-image
            $list[$i]['img']['org'] = $no_img;
            $list[$i]['img']['alt'] = '';
        }
    }
    return $list;
}