최신글 랜덤 채택완료
latest.lib에 아래처럼 추가해서 =latest_random('latest_ph1', 'job', 5, 25)?>이렇게 불어고있는데요.
해당 게시판의 모든글을 랜덤으로 가져오지않고,
해당 게시판에서 최근 3일이내 등록된 글중에서 랜덤으로 최신글을 보여주려면 어딜 수정해야하나요?
</p><p>* 최신글랜덤노출 추가 **/</p><p>// 최신글 랜덤 추출</p><p>function latest_random($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="") {</p><p> global $g5;</p><p> //static $css = array();</p><p> </p><p> if (!$skin_dir) $skin_dir = 'basic';</p><p> </p><p> if(G5_IS_MOBILE) {</p><p> $latest_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;</p><p> $latest_skin_url = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;</p><p> } else {</p><p> $latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir;</p><p> $latest_skin_url = G5_SKIN_URL.'/latest/'.$skin_dir;</p><p> }</p><p> </p><p> $cache_fwrite = false;</p><p> if(G5_USE_CACHE) {</p><p> $cache_file = G5_DATA_PATH."/cache/latest-{$bo_table}-rand-{$skin_dir}-{$rows}-{$subject_len}.php";</p><p> </p><p> if(!file_exists($cache_file)) {</p><p> $cache_fwrite = true;</p><p> } else {</p><p> if($cache_time > 0) {</p><p> $filetime = filemtime($cache_file);</p><p> if($filetime && $filetime < (G5_SERVER_TIME - 3600 * $cache_time)) {</p><p> @unlink($cache_file);</p><p> $cache_fwrite = true;</p><p> }</p><p> }</p><p> </p><p> if(!$cache_fwrite)</p><p> include_once($cache_file);</p><p> }</p><p> }</p><p> </p><p> if(!G5_USE_CACHE || $cache_fwrite) {</p><p> $list = array();</p><p> </p><p> $sql = " select * from {$g5['board_table']} where bo_table = '{$bo_table}' ";</p><p> $board = sql_fetch($sql);</p><p> $bo_subject = get_text($board['bo_subject']);</p><p> </p><p> $tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름</p><p> $sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by rand() desc limit 0, {$rows} ";</p><p> $result = sql_query($sql);</p><p> for ($i=0; $row = sql_fetch_array($result); $i++) {</p><p> $list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);</p><p> }</p><p> </p><p> if($cache_fwrite) {</p><p> $handle = fopen($cache_file, 'w');</p><p> $cache_content = "<?php\nif (!defined('_GNUBOARD_')) exit;\n\$bo_subject=\"".$bo_subject."\";\n\$list=".var_export($list, true)."?>";</p><p> fwrite($handle, $cache_content);</p><p> fclose($handle);</p><p> }</p><p> }</p><p> </p><p> /*</p><p> // 같은 스킨은 .css 를 한번만 호출한다.</p><p> if (!in_array($skin_dir, $css) && is_file($latest_skin_path.'/style.css')) {</p><p> echo '<link rel="stylesheet" href="'.$latest_skin_url.'/style.css">';</p><p> $css[] = $skin_dir;</p><p> }</p><p> */</p><p> </p><p> ob_start();</p><p> include $latest_skin_path.'/latest.skin.php';</p><p> $content = ob_get_contents();</p><p> ob_end_clean();</p><p> </p><p> return $content;</p><p>} </p><p>/* 최신글랜덤노출 추가 **/</p><div>
</div><p>
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
8년 전
40 | $sql = " select * from {$g5['board_table']} where bo_table = '{$bo_table}' "; |
45 | $sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by rand() desc limit 0, {$rows} "; |
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인전체 질문 목록
채택
채택
채택
답변대기
채택
채택
채택
답변대기
답변대기
답변대기
채택
채택
채택
채택
채택
채택
채택
답변대기