<?php
/**
* FarODP version 6.0 - http://www.farfarfar.com/scripts/odp/
*
* Copyright (c) www.farfarfar.com
*
* - You cannot remove or modify this comment.
* - You cannot remove the ODP attribution.
* - You cannot remove the Thumbshots attribution.
* - You cannot remove the "Free Online Games" link or the "Powered by FarODP" link.
*/
error_reporting(E_ALL);
include_once dirname(__FILE__) . '/config.php';
if (URL_REWRITING_ENABLED)
define('BROWSE_URL', DIR_PATH);
else
define('BROWSE_URL', DIR_PATH.'/?c=');
// Common functions
include_once dirname(__FILE__) . '/includes/common/functions.php';
include_once dirname(__FILE__) . '/includes/common/ReadURL.php';
include_once dirname(__FILE__) . '/includes/common/ErrorHandler.php';
include_once dirname(__FILE__) . '/includes/common/WebRequest.php';
include_once dirname(__FILE__) . '/includes/common/WebAction.php';
// FarODP logic
include_once dirname(__FILE__) . '/includes/FarODPController.php';
include_once dirname(__FILE__) . '/includes/FarODPTree.php';
// Open Directory HTML fetcher
include_once dirname(__FILE__) . '/includes/html/OpenDirectoryHTMLController.php';
include_once dirname(__FILE__) . '/includes/html/OpenDirectoryHTMLInterpreter.php';
// XML logic
include_once dirname(__FILE__) . '/includes/xml/FarODPXMLObject.php';
include_once dirname(__FILE__) . '/includes/xml/OpenDirectoryXMLCacheObject.php';
include_once dirname(__FILE__) . '/includes/xml/FarODPRDFObject.php';
include_once dirname(__FILE__) . '/includes/xml/XMLObject.php';
$action = new Action();
// Set error handler.
$errorHandler = new ErrorHandler();
set_error_handler('farodp_error');
// Initialize web-related classes.
$request = new WebRequest();
$node = new FarODPNode();
$webAct = new WebAction();
// Control logic.
FarODPController($request->getCat('c', '', 500), $node, $request, new OpenDirectoryHTMLController());
// Fetch current category.
if ($temp = $node->getElementsByClassName('AstCurCat')) {
$cat = $temp[0]->cat;
$lastCat = '';
if (count($cat) > 0) {
$curCat = $cat[count($cat)-1];
if (count($cat) > 1) {
$lastCat = $cat[count($cat)-2];
}
} else {
$curCat = '';
}
}
else
{
$curCat = '';
$lastCat = '';
}
// Print status codes.
switch ($action->getAction()) {
case 'cannotBrowse':
case 'cannotSearch':
header('HTTP/1.0 500 Internal Server Error');
break;
case 'categoryBlocked':
case 'searchFiltered':
header('HTTP/1.0 404 Not Found');
break;
case 'searchHeavyLoad':
header('HTTP/1.0 503 Service Unavailable');
}
// Display XML versions when requested.
$type = $request->getVal('type');
if ($type == 'xml' || $type == 'rdf') {
function processFarODPXML(&$node, &$format) {
$node->accept($format, 0);
return $format->getXML();
}
if ($type == 'xml')
$output = processFarODPXML($node, new FarODPXMLObject($cat));
else if ($type == 'rdf')
$output = processFarODPXML($node, new FarODPRDFObject($cat));
header('Content-Type: text/xml; charset=utf-8');
echo $output;
exit;
} else {
include_once './templates/Overall.php';
}
?>