Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
284 views
in Technique[技术] by (71.8m points)

php - Website Self Destruct from Browser Bar

IS there a file that I can upload onto my website (my website is a website that contains very very very sensitive information) that when navigated to in the browser (www.example.com/script.php) can be executed to delete all files from the folder it is uplaoded into/ I want to be able to delete this information easy as that. Kind of like a Self Destruct Button. MY website is used for testing sensitive equiptment commands for diamond blade cutters. We got almost the perfect cut for a diamond which makes ours very valuable. Our site was hacked and there was nothn gi could do in the backend because the password was changed on us so i want to put a secret file in there that does this.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

i would not recommend that as a solution,
why don't you secure the script instead ?

anyway just for the fun of it here is a function that will delete a folder

function deleteAll($directory, $empty = false) {
    $t= time(); // you can also use it to delete old files by subtracting from this

    if(substr($directory,-1) == "/") {
        $directory = substr($directory,0,-1);
    }

    if(!file_exists($directory) || !is_dir($directory)) {
        return false;
    } elseif(!is_readable($directory)) {
        return false;
    } else {
        $directoryHandle = opendir($directory);

        while ($contents = readdir($directoryHandle)) {
            if($contents != '.' && $contents != '..') {
                if(filemtime($directory . "/" . $contents) < $t) {
                    $path = $directory . "/" . $contents;

                    if(is_dir($path)) {
                        @deleteAll($path);
                    } else {
                        @unlink($path);
                    }
                }
            }
        }

        closedir($directoryHandle);
        if($empty == false) {
            if(!@rmdir($directory)) {
                return false;
            }
        }

        return true;
    }
}

(!) be careful when you use it it will DELETE everything you can call it like this deleteAll(".", true);

but this is not a solution look into securing your script


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...