function WikiGalleryThumbnail($pagename, $auth = "read") { global $WikiGallery_UseAuthorization, $WikiGalleryThumbProviders, $WikiGallery_DefaultGroup; // get filename if (!isset($_GET["image"])) { Abort('no image given'); } if (!isset($_GET["group"])) { $group = $WikiGallery_DefaultGroup; } else { $group = $_GET["group"]; } $path = WikiGallerySecurePath(urldecode($_GET["image"])); // group exists? if (!isset($WikiGalleryThumbProviders[$group])) { Abort("Invalid gallery group \"{$group}\" given"); } $provider =& $WikiGalleryThumbProviders[$group]; // get size $width = intval(@$_GET["width"]); $height = intval(@$_GET["height"]); if ($width < 0 || $width > 1600) { $width = 0; } if ($height < 0 || $height > 1200) { $height = 0; } $resizeMode = urldecode(@$_GET["mode"]); // check authorization $pagename = fileNameToPageName($path); if ($WikiGallery_UseAuthorization) { $page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT); if (!$page) { Abort('?cannot read $pagename'); } PCache($pagename, $page); } // get image $provider->thumb($path, $width, $height, $resizeMode); exit; }
function picture($width, $height, $resizeMode, $path, $random = false) { $path = WikiGallerySecurePath($path); // random picture? if ($random) { // get pictures $pictures = $this->provider->getFilenames("/" . $path); if (!$pictures) { // no pictures found. Try albums instead $albums = $this->provider->getFilenames("/" . $path, true); if (!albums) { return false; } $path .= "/" . $albums[rand(0, count($albums) - 1)]; return $this->picture($width, $height, $resizeMode, $path, true); } // choose random picture $num = rand(0, count($pictures) - 1); $path .= "/" . $pictures[$num]; } // return thumb url return $this->provider->thumb($path, $width, $height, $resizeMode); }