if (empty($notify)) { $notify = '&saved'; } } header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin-edit.php?page=edit' . $qs_albumsuffix . $notify . $pg . $returntab); exit; break; /** DELETION ******************************************************************/ /*****************************************************************************/ /** DELETION ******************************************************************/ /*****************************************************************************/ case "deletealbum": XSRFdefender('delete'); if ($folder) { $album = new Album($gallery, $folder); if ($album->remove()) { $nd = 3; } else { $nd = 4; } if (isset($_GET['return'])) { $albumdir = pathurlencode(sanitize($_GET['return'], 3)); } else { $albumdir = dirname($folder); if ($albumdir != '/' && $albumdir != '.') { $albumdir = "&album=" . pathurlencode($albumdir); } else { $albumdir = ''; } } }
/** * 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; }
/** * Processes the check box bulk actions for albums * */ function processAlbumBulkActions() { global $gallery; $action = sanitize($_POST['checkallaction']); $ids = $_POST['ids']; $total = count($ids); $message = NULL; if ($action != 'noaction') { if ($total > 0) { if ($action == 'addtags' || $action == 'alltags') { foreach ($_POST as $key => $value) { $key = postIndexDecode($key); if (substr($key, 0, 10) == 'mass_tags_') { if ($value) { $tags[] = substr($key, 10); } } } $tags = sanitize($tags, 3); } $n = 0; foreach ($ids as $albumname) { $n++; $albumobj = new Album($gallery, $albumname); switch ($action) { case 'deleteall': $albumobj->remove(); break; case 'showall': $albumobj->setShow(1); break; case 'hideall': $albumobj->setShow(0); break; case 'commentson': $albumobj->setCommentsAllowed(1); break; case 'commentsoff': $albumobj->setCommentsAllowed(0); break; case 'resethitcounter': $albumobj->set('hitcounter', 0); break; case 'addtags': $mytags = array_unique(array_merge($tags, $albumobj->getTags())); $albumobj->setTags($mytags); break; case 'cleartags': $albumobj->setTags(array()); break; case 'alltags': $images = $albumobj->getImages(); foreach ($images as $imagename) { $imageobj = newImage($albumobj, $imagename); $mytags = array_unique(array_merge($tags, $imageobj->getTags())); $imageobj->setTags($mytags); $imageobj->save(); } break; case 'clearalltags': $images = $albumobj->getImages(); foreach ($images as $imagename) { $imageobj = newImage($albumobj, $imagename); $imageobj->setTags(array()); $imageobj->save(); } break; } $albumobj->save(); } } return $action; } }