PHP写的CVS文件夹清理工具

前些日子有朋友用C#写的这种工具~~我是用TortoiseCVS, 如果不连接服务器无法生成发布文件~~今天CVS服务器没启动,无法继续随即用PHP写一个耍耍~~没什么复杂,递归删除文件夹~~呵呵~

None.gif <?
ExpandedBlockStart.gifContractedBlock.gif
/**/ /**
InBlock.gif * CVS_Clean.php - Clean CVS folder from the target path.
InBlock.gif *
InBlock.gif * Copyright (c) 2002-2005 mikespook & swill
InBlock.gif *
ExpandedBlockEnd.gif 
*/

None.gifrequire_once(
' File/Find.php ' );
None.gif
None.gif
class  CVS_Clean
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif  var $br;
InBlock.gif  var $slash;
InBlock.gif  var $path;
InBlock.gif  var $r;
InBlock.gif
InBlock.gif  function CVS_Clean()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif    
if (strtoupper(substr(PHP_OS, 0,3== 'WIN'))
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif      $
this->slash = "\\";
ExpandedSubBlockEnd.gif    }

InBlock.gif    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif      $
this->slash = "/";
ExpandedSubBlockEnd.gif    }

InBlock.gif    
if (isset($_SERVER['argc']))
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif      $
this->br = "\n";
ExpandedSubBlockEnd.gif    }

InBlock.gif    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif      $
this->br = "<br/>";
ExpandedSubBlockEnd.gif    }

InBlock.gif    
if (isset($_GET['path']))
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif      $
this->path = $_GET['path'];      
ExpandedSubBlockEnd.gif    }

InBlock.gif    elseif (isset($_SERVER[
'argv'][1]))
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif      $
this->path = $_SERVER['argv'][1];      
ExpandedSubBlockEnd.gif    }

InBlock.gif    
if (isset($_GET['r']))
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif      $r 
= $_GET['r'];
ExpandedSubBlockEnd.gif    }

InBlock.gif    elseif (isset($_SERVER[
'argv'][2]))
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif      $r 
= $_SERVER['argv'][2];
ExpandedSubBlockEnd.gif    }

InBlock.gif    $
this->= strtolower($r) !== '-nr';
ExpandedSubBlockEnd.gif  }

InBlock.gif
InBlock.gif  function help()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif    echo 
"I will show you this message that you didn`t input the paramater <dir> or the paramater <dir> is not a valid directory.".$this->br.$this->br;
InBlock.gif    echo 
"mikespook <mikespook@gmail.com>".$this->br;
InBlock.gif    echo 
"http://www.xxiyy.com".$this->br.$this->br;
InBlock.gif    echo 
"Useage: CVS_Clean <dir> [Options]".$this->br;
InBlock.gif    echo 
"Clean CVS folder from the directory".$this->br.$this->br;  
InBlock.gif    echo 
"<dir>\tThe directory you want to clean without slash (".$this->slash.") at the end.".$this->br;
InBlock.gif    echo 
"-nr\tDon`t remove the CVS folder recursively.";
ExpandedSubBlockEnd.gif  }

InBlock.gif
InBlock.gif  function run()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif    
if (!is_dir($this->path))
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif      $
this->help();
ExpandedSubBlockEnd.gif    }

InBlock.gif    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif      $
this->clean($this->path);
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif  }

InBlock.gif
InBlock.gif  function clean($path)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif    $finder 
= File_Find::mapTreemultiple($path, 2);    
InBlock.gif    
foreach($finder as $name => $item)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif      
if (is_array($item))
ExpandedSubBlockStart.gifContractedSubBlock.gif      
dot.gif{
InBlock.gif        
if ($this->r)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif          $
this->clean($path.$this->slash.$name);
ExpandedSubBlockEnd.gif        }

InBlock.gif        
if ($name === 'CVS')
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{          
InBlock.gif          $
this->rm($path.$this->slash.$name);          
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif      }

ExpandedSubBlockEnd.gif   }

ExpandedSubBlockEnd.gif  }

InBlock.gif
InBlock.gif  function rm($path)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif    $finder 
= File_Find::mapTreemultiple($path, 1);
InBlock.gif    
foreach($finder as $item)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif      unlink($path.$
this->slash.$item);
ExpandedSubBlockEnd.gif    }

InBlock.gif    rmdir($path);
ExpandedSubBlockEnd.gif  }

ExpandedBlockEnd.gif}

None.gif
None.gif$main 
=   new  CVS_Clean();
None.gif$main
-> run();
None.gif
?>

转载于:https://www.cnblogs.com/mikespook/archive/2005/08/23/220930.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值