잉여 첨부파일 검색 팁을 봤는데요.
본문
아래 같은 소스를 보고 적용 시키니까 잘 되는거 같은데요
문제가 빌더를 쓰고 있는데 data/file 아래에 자동으로 생성 되는 폴더들 까지 디비에 없다고 떠버리네요.
폴더 까지 카운팅이 되버립니다 ㅠㅠ
아래 소스에서 폴더는 안나오게 할수 없을까요? 파일만 검사 하는게 아니라 폴더 까지 나와버리네요.ㅠㅠ
<?php
$sub_menu = '100920';
include_once('./_common.php');
if ($is_admin != 'super')
alert('최고관리자만 접근 가능합니다.', G5_URL);
$g5['title'] = '첨부파일 디비확인';
include_once('./admin.head.php');
?>
<div class="local_desc02 local_desc">
<p>
완료 메세지가 나오기 전에 프로그램의 실행을 중지하지 마십시오.
</p>
</div>
<?php
$directory = array();
$dl = array('file');
$cnt = 0; $cnt2 = 0;
echo '<ul>'.PHP_EOL;
foreach($dl as $val) {
if($handle = opendir(G5_DATA_PATH.'/'.$val)) {
while(false !== ($entry = readdir($handle))) {
if($entry == '.' || $entry == '..' || $entry == 'index.php')
continue;
$path = G5_DATA_PATH.'/'.$val.'/'.$entry;
if(is_dir($path)) {
$directory[] = array( $val, $entry, $path );
}
if($handle2 = opendir($path)) {
while(false !== ($entry2 = readdir($handle2))) {
if($entry2 == '.' || $entry2 == '..' || $entry2 == 'index.php' || $entry2 == 'thumb')
continue;
$cnt++;
$row = sql_fetch(" select bf_source from {$g5['board_file_table']} where bo_table = '{$entry}' and bf_file = '{$entry2}' ");
if (!$row['bf_source']) {
$cnt2++;
echo "<li>파일이 디비에 없습니다. - " . $path . "/" . $entry2 . "</li>\n";
}
flush();
}
}
}
}
}
if (empty($directory)) {
echo '<p>file 디렉토리를 열지못했습니다.</p>';
}
echo '<li>완료됨</li></ul>'.PHP_EOL;
echo '<div class="local_desc01 local_desc"><p><strong>첨부파일 '.$cnt.' 건 중 '.$cnt2.' 개가 검색되었습니다.</strong><br>프로그램의 실행을 끝마치셔도 좋습니다.</p></div>'.PHP_EOL;
?>
<?php
include_once('./admin.tail.php');
?>
답변 1
if($entry2 == '.' || $entry2 == '..' || $entry2 == 'index.php' || $entry2 == 'thumb') continue;
여기를
if(!is_file($entry2) || $entry2 == '.' || $entry2 == '..' || $entry2 == 'index.php' || $entry2 == 'thumb') continue;
이렇게 해보세요.