Illegal string offset 뜹니다. 채택완료
php5.6에서 잘 되던 것이
php7.4에서 저렇게 뜹니다.
Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 27
Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 37
Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 48
Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 27
Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 37
Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 48
Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 27
Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 37
Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 48
Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 27
Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 37
Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 48
Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 27
Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 37
Warning: Illegal string offset 'bo_table' in /home1/test/public_html/sitemap/sitemap.php on line 48
소스는 아래와 같습니다.
</p>
<p><?php
# 총 4군데 변경입니다.
# common.php 파일 위치 절대 경로 세팅
include_once ("../common.php"); # 꼭 변경하세요.</p>
<p> # 기본 설정
$wwwPath = "../"; # 꼭 변경하세요.
$wwwURL = "<a href="http://domail.com";" target="_blank" rel="noopener noreferrer">http://domail.com";</a> # 꼭 변경하세요.
# 게시판 리스트
$sql = " SELECT * FROM {$g5['board_table']} WHERE bo_read_level = 1";
$query = sql_query($sql);
while ($row = sql_fetch_array($query)) {
$board[] = $row;
}
# 파일 작성 시작
$sitemap = fopen($wwwPath.'/sitemap/sitemap.xml', 'w') or die('file not found'); # 사이트맵 생성 경로 변경
fwrite($sitemap, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
fwrite($sitemap, '<urlset xmlns="<a href="http://www.sitemaps.org/schemas/sitemap/0.9">');" target="_blank" rel="noopener noreferrer">http://www.sitemaps.org/schemas/sitemap/0.9">');</a>
$boardLink = "";
$contentLink = "";
foreach ($board as $key => $val) :
# 마지막 게시물 시간
$sql = " SELECT * FROM {$g5['write_prefix']}{$val['bo_table']} WHERE wr_id = wr_parent AND wr_is_comment = 0 ORDER BY wr_datetime DESC LIMIT 0, 1";
$query = sql_fetch($sql);
# 마지막 게시물 생성 시간이 없으면 현재 시간으로 설정
$query['wr_datetime'] = (empty($query['wr_datetime'])) ? date('Y-m-d\TH:i:s')."+00:00" : preg_replace("/\s/im", "T", $query['wr_datetime'])."+00:00";
# 게시판 링크 작성
$boardLink = "";
$boardLink = "<url>";
$boardLink .= "<loc>";
$boardLink .= G5_URL."/{$val['bo_table']}";
$boardLink .= "</loc>";
$boardLink .= "<lastmod>{$query['wr_datetime']}</lastmod>";
$boardLink .= "<changefreq>daily</changefreq>";
$boardLink .= "<priority>0.9</priority>";
$boardLink .= "</url>";
# 게시판 링크 작성
fwrite($sitemap, $boardLink);
# 게시판 게시물 작성
$sql = " SELECT * FROM {$g5['write_prefix']}{$val['bo_table']} WHERE wr_id = wr_parent AND wr_is_comment = 0 ORDER BY wr_datetime DESC";
$query = sql_query($sql);
unset($row);
while ($row = sql_fetch_array($query)) {
$row['wr_datetime'] = (empty($row['wr_datetime'])) ? date('Y-m-d\TH:i:sp')."+00:00" : preg_replace("/\s/im", "T", $row['wr_datetime'])."+00:00";
$contentLink = "";
$contentLink = "<url>";
$contentLink .= "<loc>";
$contentLink .= G5_URL."/{$val['bo_table']}/{$row['wr_id']}";
$contentLink .= "</loc>";
$contentLink .= "<lastmod>".preg_replace("/\s/im", "T", $row['wr_datetime'])."</lastmod>";
$contentLink .= "<changefreq>weekly</changefreq>";
$contentLink .= "<priority>0.5</priority>";
$contentLink .= "</url>";
# 게시판 게시물 링크 작성
fwrite($sitemap, $contentLink);
}
endforeach;
fwrite($sitemap, '</urlset>');
fclose($sitemap);
?>
<p>완료</p>
답변 2개
답변에 대한 댓글 2개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
가능하시면 어디를 바꾸어야 알려 주시면 감사 하겠습니다.
너무 오랫만에 봐서 그런지 바보가 된거 같네요. ㅠ.ㅠ