贡献偶写的两个目录操作类。。。 (原创)
由于我站点会员提出,所以写了,顺便给村民共享。
代码如下:
----------------------------
无限级目录复制代码
代码:--------------------------------------------------------------------------------
<?
//目录复制
//本程序由wm_chief原创,如要转载,请注明作者与来源(http://www.phome.net)
$o_path="admin";//源目录
$n_path="n_admin";//新目录
class copy_path
{
function wm_chief_copypath($o_path,$n_path)
{$hand=opendir($o_path);
if(!file_exists($n_path))//目标目录不存在则建立
{$this->wm_chief_createpath($n_path);}
$i=0;
while($file=readdir($hand))
{$i++;
if($i==1||$i==2)
{continue;}
if(!(strchr($file,".")))
{
$o_s_path=$o_path."/".$file;
$n_s_path=$n_path."/".$file;
$this->wm_chief_copypath($o_s_path,$n_s_path);
}
else
{
$o_file=$o_path."/".$file;
$n_file=$n_path."/".$file;
$this->wm_chief_copyfile($o_file,$n_file);
}
}
closedir($hand);
return true;
}
function wm_chief_copyfile($o_file,$n_file)
{
copy($o_file,$n_file);
}
function wm_chief_createpath($n_path)
{
mkdir($n_path,0777);
}
}
$wm_chief=new copy_path();
$wm_chief_ok=$wm_chief->wm_chief_copypath($o_path,$n_path);
if($wm_chief_ok)
{
echo"复制完毕";
}
//本程序由wm_chief原创,如要转载,请注明作者与来源(http://www.phome.net)
?>
--------------------------------------------------------------------------------
原文地址:http://phomenet.u9.a-gf.com/ebb/ShowThread/?threadid=1363&forumid=2
----------------------------
无限级目录与文件删除代码
代码:--------------------------------------------------------------------------------
<?
//删除目录
//本程序由wm_chief原创,如要转载,请注明作者与来源(http://www.phome.net)
class del_path
{
function wm_chief_delpath($del_path)
{
if(!file_exists($del_path))//目标目录不存在则建立
{echo"目录不存在";return false;}
$hand=opendir($del_path);
$i=0;
while($file=readdir($hand))
{$i++;
if($i==1||$i==2)
{continue;}
if(!(strchr($file,".")))
{
$del_s_path=$del_path."/".$file;
$this->wm_chief_delpath($del_s_path);
}
else
{
$del_file=$del_path."/".$file;
$this->wm_chief_file($del_file);
}
}
closedir($hand);
$this->wm_chief_path($del_path);
return true;
}
//删除文件
function wm_chief_file($del_file)
{
unlink($del_file);
}
//删除目录
function wm_chief_path($del_path)
{
rmdir($del_path);
}
}
$DelPath="DelPath";//要删除的目录
$wm_chief=new del_path();
$wm_chief_ok=$wm_chief->wm_chief_delpath($DelPath);
if($wm_chief_ok)
{
echo"删除完毕";
}
//本程序由wm_chief原创,如要转载,请注明作者与来源(http://www.phome.net)
?>
--------------------------------------------------------------------------------
原文地址:http://phomenet.u9.a-gf.com/ebb/ShowThread/?threadid=1545&forumid=2
---------------------------
广告:谁有新版的Zend encode呀。。。。给偶下载地址
我的联系方式:
email:wm_chief@163.com
msn:wmchief@163.com
oicq:155053794
谢谢了(加密的代码前面是zend 200011以后就行了)