function del_tree($dossier, $not_racine = "") { if (($dir = opendir($dossier)) === false) { return; } while ($name = readdir($dir)) { if ($name === '.' or $name === '..') { continue; } $full_name = $dossier . '/' . $name; if (is_dir($full_name)) { del_tree($full_name); } else { unlink($full_name); } } closedir($dir); if ($not_racine == "") { @rmdir($dossier); } }
function del_tree($chemin) { // supprime le dossier ou le fichier $chemin $erreurs=""; if ($chemin[strlen($chemin)-1] != "/") $chemin.= "/"; if (is_dir($chemin)) { $dossier = opendir($chemin); while ($fichier = readdir($dossier)) { if ($fichier != "." && $fichier != "..") { $chemin_fichier = $chemin . $fichier; if (is_dir($chemin_fichier)) del_tree($chemin_fichier); else if (!@unlink($chemin_fichier)) $erreurs.="Impossible de supprimer le fichier ".$chemin_fichier.".<br/>"; } } closedir($dossier); if (!@rmdir($chemin)) $erreurs.="Impossible de supprimer le dossier ".$chemin.".<br/>"; } else if (!@unlink($chemin)) $erreurs.="Impossible de supprimer le fichier".$chemin.".<br/>"; return $erreurs; }
function delete_links($ids) { global $UPLOADS_DIR; if ($ids) { $this->app->orm->transaction = 'BEGIN'; $this->app->orm->study()->where($this->pk, $ids)->delete(); $this->app->orm->comment()->where($this->pk, $ids)->delete(); $this->app->orm->evaluate_form()->where($this->pk, $ids)->delete(); $this->app->orm->score()->where($this->pk, $ids)->delete(); $this->app->orm->transaction = 'COMMIT'; //delete folder if ($UPLOADS_DIR) { $fds = $ids; if (!is_array($ids)) { $fds = array(); $fds[] = $ids; } foreach ($fds as $fd) { @unlink($UPLOADS_DIR . 'photos/' . $fd . '.jpg'); del_tree($UPLOADS_DIR . $fd); } } } }
/** * Remove a tree and all it's containing files from disk */ function del_tree($dir) { $files = glob($dir . '*', GLOB_MARK); foreach ($files as $file) { if (substr($file, -1) == '/') { del_tree($file); } else { unlink($file); } } if (is_dir($dir)) { rmdir($dir); } }