/** * Delete the entire album PERMANENTLY. Be careful! This is unrecoverable. * Returns true if successful * * @return bool */ function remove() { if (parent::remove()) { if (!$this->isDynamic()) { foreach ($this->getAlbums() as $folder) { $subalbum = new Album($this->gallery, $folder); $subalbum->remove(); } foreach ($this->getImages() as $filename) { $image = newImage($this, $filename); $image->remove(); } $curdir = getcwd(); chdir($this->localpath); $filelist = safe_glob('*'); foreach ($filelist as $file) { if ($file != '.' && $file != '..') { unlink($this->localpath . $file); // clean out any other files in the folder } } chdir($curdir); } query("DELETE FROM " . prefix('options') . "WHERE `ownerid`=" . $this->id); query("DELETE FROM " . prefix('comments') . "WHERE `type`='albums' AND `ownerid`=" . $this->id); query("DELETE FROM " . prefix('obj_to_tag') . "WHERE `type`='albums' AND `objectid`=" . $this->id); $success = true; if ($this->isDynamic()) { $filestoremove = safe_glob(substr($this->localpath, 0, strrpos($this->localpath, '.')) . '.*'); } else { $filestoremove = safe_glob(substr($this->localpath, 0, -1) . '.*'); } foreach ($filestoremove as $file) { if (in_array(strtolower(getSuffix($file)), $this->sidecars)) { $success = $success && unlink($file); } } if ($this->isDynamic()) { return @unlink($this->localpath) && $success; } else { return @rmdir($this->localpath) && $success; } } return false; }
/** * Permanently delete this image (permanent: be careful!) * Returns the result of the unlink operation (whether the delete was successful) * @param bool $clean whether to remove the database entry. * @return bool */ function remove() { if (parent::remove()) { $result = true; $filestodelete = safe_glob(substr($this->localpath, 0, strrpos($this->localpath, '.')) . '.*'); foreach ($filestodelete as $file) { $result = $result && @unlink($file); } if ($result) { query("DELETE FROM " . prefix('obj_to_tag') . "WHERE `type`='images' AND `objectid`=" . $this->id); query("DELETE FROM " . prefix('comments') . "WHERE `type` ='images' AND `ownerid`=" . $this->id); } return $result; } return false; }
/** * Permanently delete this image (permanent: be careful!) * Returns the result of the unlink operation (whether the delete was successful) * @param bool $clean whether to remove the database entry. * @return bool */ function remove() { $result = false; if (parent::remove()) { $result = true; $filestodelete = safe_glob(substr($this->localpath, 0, strrpos($this->localpath, '.')) . '.*'); foreach ($filestodelete as $file) { @chmod($file, 0777); $result = $result && @unlink($file); } if ($result) { query("DELETE FROM " . prefix('obj_to_tag') . "WHERE `type`='images' AND `objectid`=" . $this->id); query("DELETE FROM " . prefix('comments') . "WHERE `type` ='images' AND `ownerid`=" . $this->id); $filestodelete = safe_glob(SERVERCACHE . '/' . substr(dirname($this->localpath), strlen(ALBUM_FOLDER_SERVERPATH)) . '/*' . stripSuffix(basename($this->localpath)) . '*'); foreach ($filestodelete as $file) { @chmod($file, 0777); $result = $result && @unlink($file); } } } clearstatcache(); return $result; }
/** * Delete the entire album PERMANENTLY. Be careful! This is unrecoverable. * Returns true if successful * * @return bool */ function remove() { $rslt = false; if (parent::remove()) { query("DELETE FROM " . prefix('options') . "WHERE `ownerid`=" . $this->id); query("DELETE FROM " . prefix('comments') . "WHERE `type`='albums' AND `ownerid`=" . $this->id); query("DELETE FROM " . prefix('obj_to_tag') . "WHERE `type`='albums' AND `objectid`=" . $this->id); $rslt = true; $filestoremove = safe_glob(substr($this->localpath, 0, -1) . '.*'); foreach ($filestoremove as $file) { if (in_array(strtolower(getSuffix($file)), $this->sidecars)) { @chmod($file, 0777); unlink($file); } } } return $rslt; }
/** * Permanently delete this image (permanent: be careful!) * Returns the result of the unlink operation (whether the delete was successful) * @param bool $clean whether to remove the database entry. * @return bool */ function remove() { $result = false; if (parent::remove()) { $result = true; $filestodelete = safe_glob(substr($this->localpath, 0, strrpos($this->localpath, '.')) . '.*'); foreach ($filestodelete as $file) { @chmod($file, 0777); $result = $result && @unlink($file); } if ($result) { query("DELETE FROM " . prefix('obj_to_tag') . "WHERE `type`='images' AND `objectid`=" . $this->id); query("DELETE FROM " . prefix('comments') . "WHERE `type` ='images' AND `ownerid`=" . $this->id); $cachepath = SERVERCACHE . '/' . pathurlencode($this->album->name) . '/' . $this->filename; $cachefilestodelete = safe_glob(substr($cachepath, 0, strrpos($cachepath, '.')) . '_*'); foreach ($cachefilestodelete as $file) { @chmod($file, 0777); @unlink($file); } } } clearstatcache(); return $result; }