/**
     * Print out a custom error page for an exception with the HTTP status code
     * specified
     * 
     * @param object Exception $e
     * @param int $code
     * @return void
     * @access private
     * @since 2/21/08
     */
    function printMessage($message, $code)
    {
        $codeString = SegueErrorPrinter::getCodeString($code);
        $errorString = _('Error');
        $logMessage = '';
        print <<<END
<html>\t
<head>
\t<title>{$code} {$codeString}</title>
\t<style>
\t\tbody {
\t\t\tbackground-color: #FFF8C6;
\t\t\tfont-family: Verdana, sans-serif;
\t\t}
\t\t
\t\t.header {
\t\t\theight: 65px;
\t\t\tborder-bottom: 1px dotted #333;
\t\t}
\t\t.segue_name {
\t\t\tfont-family: Tahoma, sans-serif; 
\t\t\tfont-variant: small-caps; 
\t\t\tfont-weight: bold;
\t\t\tfont-size: 60px;
\t\t\tcolor: #333333;
\t\t\t
\t\t\tfloat: left;
\t\t}
\t\t
\t\t.error {
\t\t\tfont-size: 20px;
\t\t\tfont-weight: bold;
\t\t\tfloat: left;
\t\t\tmargin-top: 40px;
\t\t\tmargin-left: 20px;
\t\t}
\t\t
\t\tblockquote {
\t\t\tmargin-bottom: 50px;
\t\t\tclear: both;
\t\t}
\t</style>
</head>
<body>
\t<div class='header'>
\t\t<div class='segue_name'>Segue</div> 
\t\t<div class='error'>{$errorString}</div>
\t</div>
\t<blockquote>
\t\t<h1>{$codeString}</h1>
\t\t<p>{$message}</p>
\t</blockquote>
\t<p>{$logMessage}</p>
</body>
</html>

END;
    }
Esempio n. 2
0
    print "\n\t\t<owner>" . $info['slot_owner'] . "</owner>";
    if ($info['site_exists']) {
        print "\n\t\t<site>";
        print "\n\t\t\t<title><![CDATA[" . $info['site_title'] . "]]></title>";
        print "\n\t\t\t<history>";
        print "\n\t\t\t\t<creator>" . $info['site_addedby'] . "</creator>";
        print "\n\t\t\t\t<created_time>" . $info['site_added_timestamp'] . "</created_time>";
        print "\n\t\t\t\t<last_editor>" . $info['site_editedby'] . "</last_editor>";
        print "\n\t\t\t\t<last_edited_time>" . $info['site_edited_timestamp'] . "</last_edited_time>";
        print "\n\t\t\t</history>";
        print "\n\t\t</site>";
    }
    print "\n\t</slot>";
}
db_connect($dbhost, $dbuser, $dbpass, $dbdb);
$errorPrinter = new SegueErrorPrinter();
if (!defined('DATAPORT_SEGUE1_SECRET_KEY')) {
    $errorPrinter->doError(500, 'Invalid configuration: DATAPORT_SEGUE1_SECRET_KEY is not defined.');
}
if (!defined('DATAPORT_SEGUE1_SECRET_VALUE')) {
    $errorPrinter->doError(500, 'Invalid configuration: DATAPORT_SEGUE1_SECRET_VALUE is not defined.');
}
if (!isset($_GET[DATAPORT_SEGUE1_SECRET_KEY])) {
    $errorPrinter->doError(403, 'Invalid Key/Password combination.');
}
if ($_GET[DATAPORT_SEGUE1_SECRET_KEY] != DATAPORT_SEGUE1_SECRET_VALUE) {
    $errorPrinter->doError(403, 'Invalid Key/Password combination.');
}
if (!isset($_GET['user']) || !strlen($_GET['user'])) {
    $errorPrinter->doError(400, 'No user specified.');
}
Esempio n. 3
0
{
    if (is_dir($path)) {
        $handle = opendir($path);
        while (false !== ($entry = readdir($handle))) {
            if ($entry != '.' && $entry != '..') {
                deleteRecursive($path . DIRECTORY_SEPARATOR . $entry);
            }
        }
        closedir($handle);
        rmdir($path);
    } else {
        unlink($path);
    }
}
db_connect($dbhost, $dbuser, $dbpass, $dbdb);
$errorPrinter = new SegueErrorPrinter();
if (!defined('DATAPORT_SEGUE1_SECRET_KEY')) {
    $errorPrinter->doError(500, 'Invalid configuration: DATAPORT_SEGUE1_SECRET_KEY is not defined.');
}
if (!defined('DATAPORT_SEGUE1_SECRET_VALUE')) {
    $errorPrinter->doError(500, 'Invalid configuration: DATAPORT_SEGUE1_SECRET_VALUE is not defined.');
}
if (!defined('DATAPORT_TMP_DIR')) {
    $errorPrinter->doError(500, 'Invalid configuration: DATAPORT_TMP_DIR is not defined.');
}
if (!is_writable(DATAPORT_TMP_DIR)) {
    $errorPrinter->doError(500, 'Invalid configuration: DATAPORT_TMP_DIR (' . DATAPORT_TMP_DIR . ') is writable.');
}
if (!isset($_GET[DATAPORT_SEGUE1_SECRET_KEY])) {
    $errorPrinter->doError(403, 'Invalid Key/Password combination.');
}
Esempio n. 4
0
        // If we were not forwarded, re-throw
        throw $e;
    }
    // Handle certain types of uncaught exceptions specially. In particular,
    // Send back HTTP Headers indicating that an error has ocurred to help prevent
    // crawlers from continuing to pound invalid urls.
} catch (UnknownActionException $e) {
    SegueErrorPrinter::handleException($e, 404);
} catch (NullArgumentException $e) {
    SegueErrorPrinter::handleException($e, 400);
} catch (PermissionDeniedException $e) {
    SegueErrorPrinter::handleException($e, 403);
} catch (UnknownIdException $e) {
    SegueErrorPrinter::handleException($e, 404);
} catch (Exception $e) {
    SegueErrorPrinter::handleException($e, 500);
}
if (defined('ENABLE_TIMERS') && ENABLE_TIMERS) {
    $execTimer->end();
    $output = ob_get_clean();
    ob_start();
    print "\n<table>\n<tr><th align='right'>Execution Time:</th>\n<td align='right'><pre>";
    printf("%1.6f", $execTimer->printTime());
    print "</pre></td></tr>\n</table>";
    $dbhandler = Services::getService("DBHandler");
    printpre("NumQueries: " . $dbhandler->getTotalNumberOfQueries());
    if (isset($dbhandler->recordQueryCallers) && $dbhandler->recordQueryCallers) {
        print $dbhandler->getQueryCallerStats();
    }
    try {
        $db = Harmoni_Db::getDatabase('segue_db');
Esempio n. 5
0
 * Answer a text file with 'true' or 'false' if a site exists for the parameters sent.
 *
 *
 * @since 3/13/08
 * 
 * @copyright Copyright &copy; 2007, Middlebury College
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
 *
 * @version $Id$
 */
require_once dirname(__FILE__) . '/../config.inc.php';
require_once dirname(__FILE__) . "/../includes.inc.php";
require_once dirname(__FILE__) . '/../objects/slot.inc.php';
require_once dirname(__FILE__) . '/../objects/segue.inc.php';
require_once dirname(__FILE__) . '/../objects/site.inc.php';
require_once dirname(__FILE__) . '/../objects/section.inc.php';
require_once dirname(__FILE__) . '/../objects/page.inc.php';
require_once dirname(__FILE__) . '/../objects/story.inc.php';
require_once dirname(__FILE__) . '/../objects/group.inc.php';
require_once dirname(__FILE__) . '/SegueErrorPrinter.class.php';
$errorPrinter = new SegueErrorPrinter();
if (!isset($_GET['site']) || !strlen($_GET['site'])) {
    $errorPrinter->doError(400, 'No site specified.');
}
$site = new Site($_GET['site']);
header("Content-Type: text/plain");
if (isset($site->site_does_not_exist) && $site->site_does_not_exist) {
    print "false";
} else {
    print "true";
}
Esempio n. 6
0
 /**
  * Execute the Action
  * 
  * @param object Harmoni $harmoni
  * @return mixed
  * @access public
  * @since 4/3/06
  */
 function execute()
 {
     $harmoni = Harmoni::instance();
     /*********************************************************
      * Split sites based on their location-category
      *********************************************************/
     try {
         $rootSiteComponent = SiteDispatcher::getCurrentRootNode();
     } catch (UnknownIdException $e) {
         // For non-existant node exceptions, redirect to the site root.
         if ($e->getCode() == 289743 && RequestContext::value('node') && RequestContext::value('site')) {
             $url = SiteDispatcher::quickURL($harmoni->request->getRequestedModule(), $harmoni->request->getRequestedAction(), array('site' => RequestContext::value('site')));
             $errorPrinter = SegueErrorPrinter::instance();
             $message = "<strong>" . _("The node you requested does not exist or has been deleted. Click %1 to go to the %2.") . "</strong>";
             $message = str_replace('%1', "<a href='" . $url . "'>" . _("here") . "</a>", $message);
             $message = str_replace('%2', "<a href='" . $url . "'>" . _("main page of the site") . "</a>", $message);
             $errorPrinter->handExceptionWithRedirect($e, 404, $message);
             exit;
         } else {
             if (RequestContext::value('site')) {
                 $slotMgr = SlotManager::instance();
                 $slot = $slotMgr->getSlotByShortname(RequestContext::value('site'));
                 // Redirect to the new URL if this site has been migrated
                 if ($redirectUrl = $slot->getMigratedRedirectUrl()) {
                     header("HTTP/1.1 301 Moved Permanently");
                     header('Location: ' . $redirectUrl);
                     exit;
                 }
                 throw $e;
             } else {
                 throw $e;
             }
         }
     }
     try {
         $slot = $rootSiteComponent->getSlot();
         // Redirect to the new URL if this site has been migrated
         if ($redirectUrl = $slot->getMigratedRedirectUrl()) {
             header("HTTP/1.1 301 Moved Permanently");
             header('Location: ' . $redirectUrl);
             exit;
         }
         if (SiteDispatcher::getBaseUrlForSlot($slot) != MYURL) {
             RequestContext::sendTo(SiteDispatcher::quickUrl());
         } else {
             /*********************************************************
              * Ensure that the requested node is a member of the site
              * listed in the URL.
              *********************************************************/
             if (!RequestContext::value('site') || RequestContext::value('site') != $slot->getShortname()) {
                 /*********************************************************
                  * This is added in Segue 2.1.0 for testing that all 
                  * Segue-generated links are producing the correct URLs.
                  * This should be removed here and in
                  *		segue/config/debug_default.conf.php
                  * after testing is complete.
                  *********************************************************/
                 if (defined('DEBUG_LOG_WRONG_SITE') && DEBUG_LOG_WRONG_SITE == true && isset($_SERVER['HTTP_REFERER']) && preg_match('#^' . str_replace('.', '\\.', MYURL) . '#', $_SERVER['HTTP_REFERER'])) {
                     HarmoniErrorHandler::logException(new WrongSiteException("Expecting site '" . $slot->getShortname() . "', saw '" . RequestContext::value('site') . "' in the url. Links to wrong sites should not be generated by Segue. If the link on the referrer page was written by Segue (and not a user), submit a bug report. Sending to " . SiteDispatcher::quickUrl()));
                 }
                 RequestContext::sendTo(SiteDispatcher::quickUrl());
             }
         }
         // Mark the site as viewed
         Segue_AccessLog::instance()->touch($slot->getShortname());
     } catch (UnknownIdException $e) {
         // No slot for the site....
     }
     $authZ = Services::getService("AuthZ");
     $recordManager = Services::getService("RecordManager");
     //
     // Begin Optimizations
     //
     // The code below queues up authorizations for all visible nodes,
     // as well as pre-fetches all of the RecordSets that have data
     // specific to the visible nodes.
     $visibleComponents = SiteDispatcher::getSiteDirector()->getVisibleComponents(SiteDispatcher::getCurrentNodeId());
     $preCacheIds = array();
     foreach ($visibleComponents as $component) {
         $id = $component->getQualifierId();
         $authZ->getIsAuthorizedCache()->queueId($id);
         $preCacheIds[] = $id->getIdString();
     }
     $recordManager->preCacheRecordsFromRecordSetIDs($preCacheIds);
     //
     // End Optimizations
     //
     $mainScreen = new Container(new YLayout(), BLOCK, BACKGROUND_BLOCK);
     $allWrapper = $this->addHeaderControls($mainScreen);
     $this->addSiteContent($mainScreen);
     $this->addFooterControls($allWrapper);
     if (defined('SEGUE_SITE_FOOTER')) {
         $allWrapper->add(new UnstyledBlock(SEGUE_SITE_FOOTER), "100%", null, CENTER, BOTTOM);
     }
     $this->mainScreen = $mainScreen;
     return $allWrapper;
 }