Created
March 13, 2012 21:44
-
-
Save marvin/2031929 to your computer and use it in GitHub Desktop.
gowfreak sein bildupload path validator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Validate { | |
// validates if folder exists, is writeable and needs to be created | |
// it takes an array with paths as parameter | |
// usage: | |
// $paths = array("url1","url2","url3"); | |
// val = new Validate(); | |
// val->ecw($paths); | |
// | |
function ecw($paths){ | |
foreach ($paths as $path){ | |
if (!file_exists($path)) { | |
if (!mkdir($path, 0, true)) { | |
die($path . " existiert nicht und konnte nicht erstellt werden!"); | |
} else { | |
if (chmod($path, 0777)) { | |
die($path . " existierte nicht wurde aber erstellt und rechte gesetzt. bitte seite neu laden!"); | |
} else { | |
die($path . " existierte nicht wurde aber erstellt. rechte konnten aber nicht geaendert werden. bitte seite neu laden!"); | |
} | |
} | |
} else { | |
if(!is_writable($path)){ | |
if (chmod($path, 0777)) { | |
die($path . " existierte bereits. rechte wurde neu gesetzt. bitte seite neu laden!"); | |
} else { | |
die($path . " existiert ist aber nicht schreibbar!"); | |
} | |
} | |
} | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment