Skip to content

Instantly share code, notes, and snippets.

@marvin
Created March 13, 2012 21:44
Show Gist options
  • Save marvin/2031929 to your computer and use it in GitHub Desktop.
Save marvin/2031929 to your computer and use it in GitHub Desktop.
gowfreak sein bildupload path validator
<?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