dongzeao5047 2013-10-08 12:57
浏览 14
已采纳

too long

i am new in php

i have upload all files and folders in public_html to live my website, i don't know what was problem there in server but PaxHeader named folder was automatically created in all my public_html like in css,js,admin, admin's js in every folder there is a folder named PaxHeader so i want to make a script for delete that folder from all public_html but basically i am a designer. so i know only few php code. any bodody help me for that

my folder structure is like :

           -public_html
              -PaxHeader
              -js
                -PaxHeader 
              -css
                 -PaxHeader
              -admin
                 -PaxHeader
                 -js
                   -PaxHeader
                 -css
                   -PaxHeader

this structure is just example, PaxHeader folder is in every folder of public_html and evry PaxHeader folder has some files, how i can delete by script of php ?

  • 写回答

2条回答 默认 最新

  • doujiku1028 2013-10-08 15:56
    关注

    I wrote a simple php code for you.

    $basepath = "/home/mohsen/Desktop/public_html/";
    $dirNameToRemove = "PaxHeader";
    
    function findAndRemove($path)
    {
        global $dirNameToRemove;
    
        $items = scandir($path);
    
        foreach($items as $item)
        {
            if(!is_dir($path . $item) || $item == '.' || $item == '..')
                continue;
    
            if($item == $dirNameToRemove)
            {
                #remove directory
                rmdir($path . $item);
            }
            else
            {
                findAndRemove($path . $item . "/");
            }
        }
    }
    
    findAndRemove($basepath);
    

    $basepath variable is a base path to your public_html directory $dirNameToRemove variable is the name of directory you want to delete recursive.

    Enjoy it!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据