<?php $gallerySetErrorHandler = false; include(dirname(__FILE__) . '/bootstrap.inc'); if (!@$gallery->getConfig('setup.password')) { /* May be invalid if a multisite install lost its config.php; galleryBaseUrl unknown */ header('Location: install/'); return; } if ($gallery->isEmbedded()) { require_once(dirname(__FILE__) . '/init.inc'); } else { /* If this is a request for a public data file, give it to the user immediately */ $unsanitizedView = isset($_GET[GALLERY_FORM_VARIABLE_PREFIX . 'view']) ? $_GET[GALLERY_FORM_VARIABLE_PREFIX . 'view'] : null; $itemId = (int)(isset($_GET[GALLERY_FORM_VARIABLE_PREFIX . 'itemId']) ? $_GET[GALLERY_FORM_VARIABLE_PREFIX . 'itemId'] : null); if ($unsanitizedView == 'core.DownloadItem' && !empty($itemId)) { /* * Our URLs are immutable because they have the serial numbers embedded. If the browser * presents us with an If-Modified-Since then it has the latest version of the file already. */ if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || (function_exists('getallheaders') && ($headers = getallheaders()) && (isset($headers['If-Modified-Since']) || isset($headers['If-modified-since'])))) { header('HTTP/1.0 304 Not Modified'); return; } /* * Fast download depends on having data.gallery.cache set, so set it now. If for some * reason we fail, we'll reset it in init.inc (but that's OK). */ $gallery->setConfig( 'data.gallery.cache', $gallery->getConfig('data.gallery.base') . 'cache/'); $path = GalleryDataCache::getCachePath( array('type' => 'fast-download', 'itemId' => $itemId)); /* We don't have a platform yet so we have to use the raw file_exists */ /* Disable fast-download in maintenance mode, admins still get via core.DownloadItem */ if (file_exists($path) && !$gallery->getConfig('mode.maintenance')) { include($path); if (GalleryFastDownload()) { return; } } } /* Otherwise, proceed with our regular process */ require_once(dirname(__FILE__) . '/init.inc'); $ret = GalleryInitFirstPass(); if ($ret) { _GalleryMain_errorHandler($ret, null); return; } /* Process the request */ GalleryMain(); } if (!empty($gallerySetErrorHandler)) { restore_error_handler(); $gallerySetErrorHandler = false; } /** * Main handler for all Gallery pages/requests. * @return array */ function GalleryMain($embedded=false) { global $gallery; /* Process the request */ list ($ret, $g2Data) = _GalleryMain($embedded); if ($ret) { _GalleryMain_errorHandler($ret, $g2Data); /** * @todo security question: should we be resetting the auth code (below) even if the * storage is not initialized here? */ if ($gallery->isStorageInitialized()) { /* Nuke our transaction, too */ $storage =& $gallery->getStorage(); $storage->rollbackTransaction(); if ($ret->getErrorCode() & ERROR_REQUEST_FORGED) { /* * The auth token was automatically reset as a side-effect when we determined that * this request was forged, so save the session now. */ $session =& $gallery->getSession(); $ret2 = $session->save(true); if ($ret2) { GalleryCoreApi::addEventLogEntry( 'Gallery Error', 'Unable to reset the auth token', $ret2->getAsText()); } } } } else { $gallery->performShutdownActions(); /* Write out our session data */ $session =& $gallery->getSession(); $ret = $session->save(); } } usw. ?>
58.4k Fragen
249k Antworten
7k Nutzer