function GalleryMain($embedded = false) { global $gallery; /* Process the request */ list($ret, $g2Data) = _GalleryMain($embedded); if (!$ret) { $gallery->performShutdownActions(); /* Write out our session data */ $session =& $gallery->getSession(); $ret = $session->save(); } /* Complete our transaction */ if (!$ret && $gallery->isStorageInitialized()) { $storage =& $gallery->getStorage(); $ret = $storage->commitTransaction(); } /* Error handling (or redirect info in debug mode) */ if ($ret) { _GalleryMain_errorHandler($ret->wrap(__FILE__, __LINE__), $g2Data); $g2Data['isDone'] = true; if ($ret && $gallery->isStorageInitialized()) { /* Nuke our transaction, too */ $storage =& $gallery->getStorage(); $storage->rollbackTransaction(); } } else { if (isset($g2Data['redirectUrl'])) { /* If we're in debug mode, show a redirect page */ print '<h1> Debug Redirect </h1> ' . 'Not automatically redirecting you to the next page because we\'re in debug mode<br/>'; printf('<a href="%s">Continue to the next page</a>', $g2Data['redirectUrl']); print '<hr/>'; print "<pre>"; print $gallery->getDebugBuffer(); print "</pre>"; } } return $g2Data; }
/** * 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(); } /* Complete our transaction */ if (!$ret && $gallery->isStorageInitialized()) { $storage =& $gallery->getStorage(); $ret = $storage->commitTransaction(); } if ($ret) { $g2Data['isDone'] = true; } else { if (isset($g2Data['redirectUrl'])) { /* If we're in debug mode, show a redirect page */ print '<h1> Debug Redirect </h1> ' . 'Not automatically redirecting you to the next page because we\'re in debug mode<br/>'; printf('<a href="%s">Continue to the next page</a>', $g2Data['redirectUrl']); print '<hr/>'; print '<pre>'; print $gallery->getDebugBuffer(); print '</pre>'; } } return $g2Data; }