http://ga1234.cafe24.com/main/main.php
main 폴더안에 있는 main.php에다 최신글을 출력할까 합니다.
그런데 상단에 <? include_once('../lib/latest.lib.php'); ?>를 넣어 latest를 호출해도 오류가 납니다.
php를 잘 몰라 함수 및 경로를 어떻게 지정해야 할지 모르겠습니다.
답변 3개 / 댓글 5개
먼저 제안드리고 싶은 점은 그누보드가 루트에 설치되었는데 메인 페이지는 별도의 main이라는 폴더에 구성이 되어 있는데요. 이렇게 구성하시는 것보다는 루트에 같이 구성하시는 것이 더욱 용이하다고 보여집니다.
현재 부분에서는
include_once('../_common.php');include_once(G5_LIB_PATH.'/latest.lib.php');
와 같이 구성해서 넣어보세요.
답변에 대한 댓글 3개
include_once('../common.php'); 치니까 되네요.
_common.php 파일을 만드세요 main 폴더안에 만드시고 내용을 아래와 같이
아래 코드는 config 파일이 존재하는 폴더를 찾아주는 소스입니다.
<?php$tilde_remove = preg_replace('/^\/\~[^\/]+(.*)$/', '$1', $_SERVER['SCRIPT_NAME']);$document_root = str_replace($tilde_remove, '', $_SERVER['SCRIPT_FILENAME']);$port = $_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : '';$http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') ? 's' : '') . '://';$user = str_replace(str_replace($document_root, '', $_SERVER['SCRIPT_FILENAME']), '', $_SERVER['SCRIPT_NAME']);$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];if(isset($_SERVER['HTTP_HOST']) && preg_match('/:[0-9]+$/', $host)) $host = preg_replace('/:[0-9]+$/', '', $host); $index_url = $http.$host.$port.$user; $index_root = index_path($index_url, $_SERVER['PHP_SELF']); include_once($index_root.'/common.php'); function index_path($index, $url){ $path = "."; $index = explode("/", $index); $url = explode("/", $url); //index 페이지의 경로를 찾는다. $index_path = $index[count($index)-1]; // 현재 경로가 상위폴더인지 검사한다. for($i=0; $i<count($url); $i++){ if($index_path == $url[$i]){ $up_polder = true; $index_key = $i; //index 폴더의 위치를 저장 } } if($up_polder){ //상위 폴더일경우 $loop_cnt = count($url) - 2 - $index_key; for($i=0; $i<$loop_cnt; $i++){ if($i == 0 ){ $path = ".."; }else{ $path .= "/.."; } } }else{ // 하위 폴더일경우 현재 폴더를 찾는다 $url_path = $url[count($url)-2];//폴더가 아닌 파일을 제거하기 위해 -2 for($i=0; $i<count($index); $i++){ if($url_path == $index[$i]){ $url_key = $i+1;// 현위치의 다음 부터 폴더경로 추가를 위해 +1을 해줌 } } for($i=$url_key; $i<count($index); $i++){ // 폴더경로 추가 $path .= "/".$index[$i]; } } return $path;} ?>
그리고 나머지는 port 님 이알려주신대로
./_common.php 파일은 같은 폴더에 존재 하니 상위로 나갈 필요는 없습니다.
답변에 대한 댓글 1개
<? include_once('../lib/latest.lib.php'); ?>
.. 부분의 경로가 잘못되었다던가...그러신거같아요...음...
.. <-- 이부분을 경로 맞추시면될거같은데
..을 $g4[path] 로 바꿔보세요
<? include_once('../lib/latest.lib.php'); ?> 이거를
<? include_once('$g4[path]/lib/latest.lib.php'); ?> 이렇게
답변에 대한 댓글 1개
답변을 작성하려면 로그인이 필요합니다.