Delete multiple static pages generated by an article under PHP

  • 2020-03-31 20:59:44
  • OfStack

 
//The pool deletes multiple static pages generated by an article
//The resulting article is called 5.html 5_2.html 5_3.html
 
function delStaticHtml ($article_id) 
{ 
global $db; 
$sql =  " SELECT `post_time` FROM `@__article` WHERE `article_id` =  ' {$article_id}' " ; 
$art = $db->getOne ($sql); 
if ($art) 
{ 
$n = 1; 
$html_dir =  ' ../html/'.date( ' Ym',$art['post_time']).'/'; 
$filename = $html_dir.$article_id.'.html'; 
while (file_exists($filename)) 
{ 
@unlink($filename); 
$n++; 
$filename = $html_dir.$article_id.'_'.$n.'.html'; 
} 
} 
return false; 
} 

Related articles: