PHP
·
发表于 5年以前
·
阅读量:8308
ºÜ¶aµÄ¿ªÔ´cmsϵͳ¶¼ÓÐÒ»¼uÇa³ý»º´aeµÄ¹¦ÄÜ£¬»º´aeÊÇΪÁ˼oÇa*þÎñÆ÷µÄѹÁ¦¶ø²uÉuµÄ£¬µ«ÊÇͬʱÓлº´aeµÄ´aeÔÚÒ²¿ÉÄÜʹһÐ(C)Êý¾Ý²»ÄÜʵʱ¸uУ¬¶Ô´Ë£¬ÎÒÃǾÍÀ´ÊµÏÖÒ»¸oThinkPHPµÄÇaÀi»º´aeµÄ¹¦ÄÜ¡£´uÂeÈçÏ£º
ThinkPHPºǫִÐеĴuÂe:
//»ñÈ¡ÒªÇa³þµÄĿ¼ºÍĿ¼ËuÔڵľø¶ÔÂ*¾¶
public function cache(){
////ǰ̨ÓÃajax get*½Ê½½øÐÐÌa½»µÄ£¬ÕaÀiÊÇÏÈÅжÏÒ»ÏÂ
if($_POST['type']){
//µÃµ½´«µÝ¹ýÀ´µÄÖµ
$type=$_POST['type'];
//½«´«µÝ¹ýÀ´µÄÖµ½øÐÐÇиi£¬ÎÒÊÇÓá°-¡±½øÐÐÇиiµÄ
$name=explode('-', $type);
//µÃµ½ÇиiµÄÌoÊý£¬±aÓÚÏÂÃaeÑ»*
$count=count($name);
//Ñ»*µ÷ÓÃÉÏÃaeµÄ*½*¨
for ($i=0;$i<$count;$i++){
//µÃµ½ÎļþµÄ¾ø¶ÔÂ*¾¶
$abs_dir=dirname(dirname(dirname(dirname(__FILE__))));
//×eºÏÂ*¾¶
$pa=$abs_dir.'indexRuntime';
$runtime=$abs_dir.'indexRuntime~runtime.php';
if(file_exists($runtime))//ÅÐ¶Ï ÎļþÊÇ*ñ´aeÔÚ
{
unlink($runtime);//½øÐÐÎļþɾ³ý
}
//µ÷ÓÃɾ³ýÎļþ¼ÐÏÂËuÓÐÎļþµÄ*½*¨
$this->rmFile($pa,$name[$i]);
}
//¸ø³oÌaʾÐÅÏ¢
$this->ajaxReturn(1,'Ça³ý³É¹¦',1);
}else{
$this->display();
}
}
public function rmFile($path,$fileName){//ɾ³ýÖ´ÐеÄ*½*¨
//È¥³ý¿Õ¸ñ
$path = preg_replace('/(/){2,}|{}{1,}/','/',$path);
//µÃµ½ÍeÕuĿ¼
$path.= $fileName;
//ÅжϴËÎļþÊÇ*ñΪһ¸oÎļþĿ¼
if(is_dir($path)){
//´o¿ªÎļþ
if ($dh = opendir($path)){
//±eÀuÎļþĿ¼Ãu³Æ
while (($file = readdir($dh)) != false){
//ÖðÒ»½øÐÐɾ³ý
unlink($path.''.$file);
}
//¹Ø±ÕÎļþ
closedir($dh);
}
}
}
ǰ̨ҳÃae²¿*Ö´uÂeÈçÏ£º
<script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
<script type="test/javascript">
$(function(){
$('#button').click(function(){
if(confirm("È*ÈÏÒªÇa³ý»º´ae£¿")){
var $type=$('#type').val();
var $mess=$('#mess');
$.post('__URL__/clear',{type:$type},function(data){
alert("»º´aeÇaÀi³É¹¦");
});
}else{
return false;
}
});
});
</script>