\n"); if(!defined('XMLEDITOR_LOG')) define('XMLEDITOR_LOG','log/error.log'); if(!defined('BASE_URL')) define('BASE_URL','http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/'); //************************************************************************** // setup environment require_once('PEAR.php'); // error handling error_reporting(E_ALL); PEAR::setErrorHandling(PEAR_ERROR_TRIGGER, E_USER_WARNING); //************************************************************************** // process URI - follow cleanURLs // load some general libraries for dealing with urls require_once(RELATIVE_ROOT.'lib/URLFunctions.php'); // **************************************************************************** // This is used to catch bad url requests. they need to end with a / or a filename // do it here before all the libraries, so it does load too much before refreshing if(isset($_GET['path']) && substr($_GET['path'],-4) != '.php' && substr($_GET['path'],-1) != '/') { Header('Location: ' . cleanURL($_GET['path'].'/')); exit; } setIncludePath(); if(isset($_REQUEST)) stripGPCSlashes($_REQUEST); if(isset($_POST)) stripGPCSlashes($_POST); if(isset($_GET)) stripGPCSlashes($_GET); if(isset($_COOKIE)) stripGPCSlashes($_COOKIE); session_start(); // set up control variables if(isset($_REQUEST['path'])) { $GLOBALS['galleryPath'] = $_REQUEST['path']; } else { $GLOBALS['galleryPath'] = ""; } setCleanUrlBase($GLOBALS['galleryPath']); // create php4 file_put_contents if(!function_exists('file_put_contents')) { function file_put_contents($filename, $data, $file_append = false) { $fp = fopen($filename, (!$file_append ? 'w+' : 'a+')); if(!$fp) { trigger_error('file_put_contents cannot write in file.', E_USER_ERROR); return; } fputs($fp, $data); fclose($fp); } } //************************************************************************** // parse url $GLOBALS['url_parts'] = split('/',$GLOBALS['galleryPath']); if(empty($GLOBALS['url_parts'][(count($GLOBALS['url_parts'])-1)])) { array_pop($GLOBALS['url_parts']); } //************************************************************************** // Main //************************************************************************** // determine which object we are working with // choices: collection, media and tag if(isset($GLOBALS['url_parts'][0])) { // set properties if they are available $objectId = (!isset($GLOBALS['url_parts'][1])) ? '' : $GLOBALS['url_parts'][1]; $view = (!isset($GLOBALS['url_parts'][2])) ? '' : $GLOBALS['url_parts'][2]; if($GLOBALS['url_parts'][0] == 'collection') { include(CLASS_ROOT.'Collection.php'); $thisCollection =& new Collection($objectId); $content = $thisCollection->getContent($view); } else if($GLOBALS['url_parts'][0] == 'media') { include(CLASS_ROOT.'Media.php'); $thisMedia =& new Media($objectId); $content = $thisMedia->getContent($view); } else if($GLOBALS['url_parts'][0] == 'tag') { include(CLASS_ROOT.'Tag.php'); $thisTag =& new Tag($objectId); $content = $thisTag->getContent($view); } else { // show all collections $content = 'requesting unavailable service: '.$GLOBALS['url_parts'][0].''; $GLOBALS['xslFile'] = "style/system.xsl"; } } else { $content = showServices(); } //************************************************************************** // Transformation (XSLT) header('Content-type: application/xml'); echo $content; //************************************************************************** // Functions /** * Shows available services * * @access public * @return STRING xml */ function showServices() { $xmlString = '' .'' .'' .'' .''; return $xmlString; } /** * perform xsl transformation * * @access public * @return STRING xml */ function transform($xmlString,$xslFile,$xslParams = '') { if(empty($xslParams)) $xslParams = array(); $xmldoc = domxml_open_mem($xmlString); $xsldoc = domxml_xslt_stylesheet_file($xslFile); $result = $xsldoc->process($xmldoc,$xslParams); $transformedContent =& $xsldoc->result_dump_mem($result); return $transformedContent; } //************************************************************************** ?>