function cleanAlbum($obj) { global $albumcount; $subalbum = $obj->name; $file = basename($subalbum); $seoname = seoFriendly($file); $album_cleaned = false; if ($seoname != $file) { $newname = dirname($subalbum); if (empty($newname) || $newname == '.') { $newname = $seoname; } else { $newname .= '/' . $seoname; } if ($e = $obj->rename($newname)) { $error = getE($e, $subalbum, $newname); printf(gettext('<em>%1$s</em> rename to <em>%2$s</em> failed: %3$s'), $subalbum, $newname, $error); echo "<br />\n"; } else { $obj->save(); clearstatcache(); printf(gettext('<em>%1$s</em> renamed to <em>%2$s</em>'), $subalbum, $newname); echo "<br />\n"; $albumcount++; $obj = newAlbum($newname); zpFunctions::removeDir(SERVERCACHE . '/' . $subalbum); if (extensionEnabled('static_html_cache')) { Gallery::clearCache(SERVERPATH . '/' . STATIC_CACHE_FOLDER); } $album_cleaned = true; } } if (!$obj->isDynamic()) { checkFolder($obj, $album_cleaned); } }
/** * Cleans out the cache folder * * @param string $cachefolder the sub-folder to clean */ function clearCache($cachefolder = NULL) { zpFunctions::removeDir(SERVERPATH . '/' . STATIC_CACHE_FOLDER . '/' . strtolower($this->feed) . '/' . $cachefolder, true); }
/** * * Recursively clears and removes a folder * @param string $path * @return boolean */ static function removeDir($path, $within = false) { if (($dir = @opendir($path)) !== false) { while (($file = readdir($dir)) !== false) { if ($file != '.' && $file != '..') { if (is_dir($path . '/' . $file)) { if (!zpFunctions::removeDir($path . '/' . $file)) { return false; } } else { @chmod($path . $file, 0777); if (!@unlink($path . '/' . $file)) { return false; } } } } closedir($dir); if (!$within) { @chmod($path, 0777); if (!@rmdir($path)) { return false; } } return true; } return false; }
} } if (!is_dir($folder . DATA_FOLDER)) { @mkdir($folder . DATA_FOLDER); } if (!is_dir($folder . THEMEFOLDER)) { @mkdir($folder . THEMEFOLDER); } foreach ($targets as $target => $type) { if (file_exists($folder . $target)) { $link = str_replace('\\', '/', @readlink($folder . $target)); switch ($type) { case 'dir': if (empty($link) || $link == $folder . $target) { // an actual folder if (zpFunctions::removeDir($folder . $target)) { if (SYMLINK && @symlink(SERVERPATH . '/' . $target, $folder . $target)) { $msg[] = sprintf(gettext('The existing folder <code>%s</code> was replaced.'), $folder . filesystemToInternal($target)) . "<br />\n"; } else { $msg[] = sprintf(gettext('The existing folder <code>%1$s</code> was removed but Link creation failed.'), $target) . "<br />\n"; $success = false; } } else { $msg[] = sprintf(gettext('The existing folder <code>%s</code> could not be removed.'), $folder . filesystemToInternal($target)) . "<br />\n"; $success = false; } } else { // is a symlink @chmod($folder . $target, 0777); $success = @rmdir($folder . $target); if (!$success) {
/** * Cleans out the cache folder. (Adpated from the zenphoto image cache) * * @param string $cachefolder the sub-folder to clean */ static function clearHTMLCache($folder = NULL) { if (is_null($folder)) { $cachesubfolders = array("index", "albums", "images", "pages"); foreach ($cachesubfolders as $cachesubfolder) { zpFunctions::removeDir(SERVERPATH . '/' . STATIC_CACHE_FOLDER . "/" . $cachesubfolder, true); } } else { zpFunctions::removeDir(SERVERPATH . '/' . STATIC_CACHE_FOLDER . "/" . $folder); } }
setOptionDefault('RSS_pages', 1); setOptionDefault('RSS_article_comments', 1); setOptionDefault('AlbumThumbSelect', 1); setOptionDefault('site_email', "zenphoto@" . $_SERVER['SERVER_NAME']); setOptionDefault('site_email_name', 'ZenPhoto20'); //effervescence_plus migration if (file_exists(SERVERPATH . '/' . THEMEFOLDER . '/effervescence_plus')) { if ($_zp_gallery->getCurrentTheme() == 'effervescence_plus') { $_zp_gallery->setCurrentTheme('effervescence+'); $_zp_gallery->save(); } $options = query_full_array('SELECT LCASE(`name`) as name, `value` FROM ' . prefix('options') . ' WHERE `theme`="effervescence_plus"'); foreach ($options as $option) { setThemeOption($option['name'], $option['value'], NULL, 'effervescence+', true); } zpFunctions::removeDir(SERVERPATH . '/' . THEMEFOLDER . '/effervescence_plus'); } ?> <p> <?php $deprecate = false; $themes = array_keys($_zp_gallery->getThemes()); natcasesort($themes); echo gettext('Theme setup:') . '<br />'; foreach ($themes as $key => $theme) { if (protectedTheme($theme)) { unset($themes[$key]); } else { $deprecate = true; } ?>
/** * Cleans out the cache folder * * @param string $cachefolder the sub-folder to clean */ static function clearCache($cachefolder = NULL) { zpFunctions::removeDir(SERVERCACHE . '/' . $cachefolder, true); }
/** * Cleans out the cache folder * * @param string $cachefolder the sub-folder to clean */ static function clearCache($cachefolder = NULL) { if (is_null($cachefolder)) { $cachefolder = SERVERCACHE; } zpFunctions::removeDir($cachefolder, true); }
?> <div class="tabbox"> <?php zp_apply_filter('admin_note', 'seo_cleanup', ''); ?> <h1><?php echo gettext('Cleanup album and image names to be SEO friendly'); ?> </h1> <?php foreach ($albums as $album) { $obj = newAlbum($album); $count = $count + cleanAlbum($obj); } if ($albumcount || $count) { zpFunctions::removeDir(SERVERPATH . '/' . STATIC_CACHE_FOLDER, true); ?> <div class="notebox"> <p> <?php if ($albumcount) { printf(ngettext('%d album cleaned.', '%d albums cleaned', $albumcount), $albumcount); } else { echo gettext('No albums cleaned.'); } ?> </p> <p> <?php if ($count) { printf(ngettext('%d image cleaned.', '%d images cleaned', $count), $count);