| Server IP : 67.43.7.42 / Your IP : 216.73.216.61 Web Server : Apache System : Linux host.isabellascookies.com 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : isabella ( 503) PHP Version : 5.5.38 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/isabella/public_html/lib/Mage/System/ |
Upload File : |
<?php
class Mage_System_Dirs
{
public static function rm($dirname)
{
if(is_array($dirname)) {
$dirname = $dirname[1];
}
// Sanity check
if (!@file_exists($dirname)) {
return false;
}
// Simple delete for a file
if (@is_file($dirname) || @is_link($dirname)) {
return unlink($dirname);
}
// Create and iterate stack
$stack = array($dirname);
while ($entry = array_pop($stack)) {
// Watch for symlinks
if (@is_link($entry)) {
@unlink($entry);
continue;
}
// Attempt to remove the directory
if (@rmdir($entry)) {
continue;
}
// Otherwise add it to the stack
$stack[] = $entry;
$dh = opendir($entry);
while (false !== $child = readdir($dh)) {
// Ignore pointers
if ($child === '.' || $child === '..') {
continue;
}
// Unlink files and add directories to stack
$child = $entry . DIRECTORY_SEPARATOR . $child;
if (is_dir($child) && !is_link($child)) {
$stack[] = $child;
} else {
@unlink($child);
}
}
@closedir($dh);
}
return true;
}
public static function mkdirStrict($path, $recursive = true, $mode = 0777)
{
$exists = file_exists($path);
if($exists && is_dir($path)) {
return true;
}
if($exists && !is_dir($path)) {
throw new Exception("'{$path}' already exists, should be a dir, not a file!");
}
$out = @mkdir($path, $mode, $recursive);
if(false === $out) {
throw new Exception("Can't create dir: '{$path}'");
}
return true;
}
public static function copyFileStrict($source, $dest)
{
$exists = file_exists($source);
if(!$exists) {
throw new Exception('No file exists: '.$exists);
}
}
}