[Nextcms-commits] CVS: nextcms .htaccess,NONE,1.1 class.Mapper.php,NONE,1.1 class.Cache.php,1.2,1.3
Status: Alpha
Brought to you by:
andrejb
|
From: Andrej B. <an...@us...> - 2002-04-30 23:58:21
|
Update of /cvsroot/nextcms/nextcms
In directory usw-pr-cvs1:/tmp/cvs-serv24337
Modified Files:
class.Cache.php class.Content.php class.Page.php
class.Site.php class.Template.php processor.conf.php-dist
processor.php utils.php xml.php
Added Files:
.htaccess class.Mapper.php
Log Message:
* add a mapper class
* some bugs fixed
* some minor code changes
* warning: previous extension may not compatible with this version
--- NEW FILE: .htaccess ---
Deny from all
<Files ~ "^\processor.php">
Allow from all
</Files>
--- NEW FILE: class.Mapper.php ---
<?php
define('MAPPER_VERSION', 1);
include_once('xml.php');
include_once('class.Site.php');
class Mapper {
var $site;
var $virtual_url;
var $version = MAPPER_VERSION;
function Mapper($disable_cache = false) {
disableLoadedFiles();
$site_file = $GLOBALS['SITE_FILES'];
if (!$disable_cache)
$cached = $this->readCache();
else
$cached = false;
if ($this->version != MAPPER_VERSION) {
$this = new Mapper(true);
return;
}
if (!$cached) {
$this->site = array();
$this->virtual_url = array();
} else foreach ($this->site as $siteid => $site) {
if (!isset($site_file[$siteid])) {
unset($this->site[$siteid]);
$this->mapping_is_modified = true;
}
}
if (!isset($this->mapping_is_modified))
$this->mapping_is_modified = false;
foreach ($site_file as $key => $file) {
if (isset($this->site[$key]))
if (!(filemtime($GLOBALS['document_root'] . '/' . $this->site[$key]['file']) > $this->site[$key]['modtime']))
continue;
else
foreach ($this->virtual_url as $vurl => $pageid) {
list($siteid) = explode(':', $pageid);
if ($siteid === $key)
unset($this->virtual_url[$vurl]);
}
$this->mapping_is_modified = true;
$site = new Site($file);
$csite['root'] = $site->root;
$csite['file'] = $file;
$csite['modtime'] = filemtime($GLOBALS['document_root'] . '/' . $file);
$csite['pageid'] = array();
$csite['pageid'] = $site->getIDUrlList();
$virtual_url = $site->getVirtualUrlIDList();
foreach ($virtual_url as $vurl => $id) {
$this->virtual_url[$vurl] = $key . ':' . $id;
}
unset($site);
$this->site[$key] = $csite;
}
if ($this->mapping_is_modified)
$this->writeCache();
enableLoadedFiles();
}
function getUrlByID($id) {
list($siteid, $pageid) = explode(":", $id);
if (isset($this->site[$siteid]))
return $this->site[$siteid]['pageid'][$pageid];
}
function getUrlByVirtualUrl($virtual_url) {
if (isset($this->virtual_url[$virtual_url])) {
list($siteid, $pageid) = explode(":", $this->virtual_url[$virtual_url]);
return $this->site[$siteid]['pageid'][$pageid];
}
}
function getIDByVirtualUrl($virtual_url) {
if (isset($this->virtual_url[$virtual_url]))
return $this->virtual_url[$virtual_url];
}
function getVirtualUrlByID($id) {
$virtual_url = array_search($id, $this->virtual_url);
if ($virtual_url !== false)
return $virtual_url;
}
function writeCache() {
if (isset($GLOBALS['CACHE_DIR'])) {
unset($this->mapping_is_modified);
$cache_dir = $GLOBALS['document_root'] . $GLOBALS['CACHE_DIR'];
$cache_filename = $GLOBALS['CACHE_DIR'] . "/" . 'mappercache';
$check_mod_files = $GLOBALS['SITE_FILES'];
if (!file_exists($cache_dir))
if (!mkdir($cache_dir, 0777))
printError("Das Cacheverzeichnis $cache_dir existiert nicht und es konnte auch nicht angelegt werden.");
$cachefile = fopen($GLOBALS['document_root'] . $cache_filename, "w");
if (!$cachefile) return;
if (!flock($cachefile, LOCK_EX)) return;
fwrite($cachefile,serialize($this));
fclose($cachefile);
}
}
function readCache() {
if (isset($GLOBALS['CACHE_DIR'])) {
$cache_dir = $GLOBALS['document_root'] . $GLOBALS['CACHE_DIR'];
$cache_filename = $cache_dir . "/" . 'mappercache';
if (!file_exists($cache_filename))
return false;
$cachefile = fopen($cache_filename, "r");
if (!$cachefile) return false;
$contents = fread ($cachefile, filesize ($cache_filename));
fclose($cachefile);
$this = unserialize($contents);
} else return false;
return true;
}
}
?>
Index: class.Cache.php
===================================================================
RCS file: /cvsroot/nextcms/nextcms/class.Cache.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** class.Cache.php 5 Apr 2002 14:45:09 -0000 1.2
--- class.Cache.php 30 Apr 2002 23:58:18 -0000 1.3
***************
*** 44,48 ****
function show() {
! //header ("Last-Modified: " . gmdate ("D, d M Y H:i:s", $this->filemtime) . " GMT");
print $this->cache_data;
}
--- 44,51 ----
function show() {
! global $SEND_LAST_MODIFIED_HEADER;
! if ($SEND_LAST_MODIFIED_HEADER)
! header ("Last-Modified: " . gmdate ("D, d M Y H:i:s", $this->filemtime) . " GMT");
!
print $this->cache_data;
}
Index: class.Content.php
===================================================================
RCS file: /cvsroot/nextcms/nextcms/class.Content.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** class.Content.php 19 Mar 2002 17:51:04 -0000 1.1.1.1
--- class.Content.php 30 Apr 2002 23:58:18 -0000 1.2
***************
*** 30,34 ****
function Content($file) {
! $this->document_root = getDocRoot();
$this->filename = $file;
--- 30,34 ----
function Content($file) {
! $this->document_root = $GLOBALS['document_root'];
$this->filename = $file;
***************
*** 40,56 ****
$this->content = loadFile($this->filename);
$this->xmltree->parseXML($this->content, true);
-
- // get the site filename from parsed content file
- $this->site_name = $this->xmltree->getAttribute("/contentpage[1]", "site");
- $this->site_filename = relToAbs($this->xmltree->getAttribute("/contentpage[1]", "sitefile"), dirname($this->filename));
-
- // if we know the site name we can get the site filename
- if (!empty($this->site_name)) {
- $this->site_filename = $GLOBALS["SITE_FILES"][$this->site_name];
- if (!isset($this->site_filename))
- printError("Fehler in '$this->filename'. Es gibt keine Site-Datei, die dem Name '$this->site_name' zugeordnet ist.");
- } else if (empty($this->site_filename)) {
- printError("Die Content-Datei '$this->filename' wurde keiner Site zugeordnet.");
- }
// get the title
--- 40,43 ----
Index: class.Page.php
===================================================================
RCS file: /cvsroot/nextcms/nextcms/class.Page.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** class.Page.php 25 Mar 2002 15:57:42 -0000 1.3
--- class.Page.php 30 Apr 2002 23:58:18 -0000 1.4
***************
*** 1,4 ****
--- 1,5 ----
<?php
include_once('xml.php');
+ include_once('class.Mapper.php');
include_once('class.Site.php');
include_once('class.Content.php');
***************
*** 7,10 ****
--- 8,13 ----
class Page {
var $document_root;
+ var $url;
+ var $virtual_url;
var $pagetitle;
***************
*** 18,21 ****
--- 21,25 ----
var $nextpage_path;
+ var $mapper;
var $site;
var $content;
***************
*** 29,51 ****
! function Page($url) {
$this->stack = array();
! $this->document_root = getDocRoot();
// check if we can handle the requested url
! if (!file_exists($this->document_root . $url)) {
//header('HTTP/1.0 404 Not Found'); exit;
! printError("404 '$url' not found");
}
// create a new content object
$this->content = new Content($url);
- if (!file_exists($this->document_root . '/' . $this->content->site_filename))
- printError("Die in '" . $this->content->filename . "' angegebene Site-Datei '" .
- $this->content->site_filename . "' wurde nicht gefunden.");
// create a new site object
! $this->site = new Site($this->content->site_filename);
// get the pagenode of the page we want to create
--- 33,65 ----
! function Page($virtual_url) {
$this->stack = array();
! $this->document_root = $GLOBALS['document_root'];
+ $this->mapper = new Mapper();
+
+ $this->virtual_url = $virtual_url;
+ $url = $this->mapper->getUrlByVirtualUrl($virtual_url);
+
// check if we can handle the requested url
! if (!isset($url)) {
//header('HTTP/1.0 404 Not Found'); exit;
! printError("404 URL '$virtual_url' is not attached to any site on this server.");
! }
!
! list($this->siteid, $this->pageid) = explode(':', $this->mapper->getIDByVirtualUrl($virtual_url));
!
! $this->url = $url;
!
! if (!file_exists($this->document_root . $url)) {
! printError("Die Datei '$url' existiert nicht.");
}
// create a new content object
$this->content = new Content($url);
// create a new site object
! $this->site = new Site($GLOBALS['SITE_FILES'][$this->siteid]);
// get the pagenode of the page we want to create
***************
*** 61,65 ****
$this->nextpage_path = $ret['next'];
! // ident is disabled
$this->identchars = '';
$this->noident = true;
--- 75,79 ----
$this->nextpage_path = $ret['next'];
! // ident support is broken, so it is disabled
$this->identchars = '';
$this->noident = true;
***************
*** 88,92 ****
$keywords = array();
! $keywordlists = array_reverse($this->site->xmltree->getParent($pagenode_path, "/site[1]/pages[1]", "", "keywords"));
foreach($keywordlists as $keywordlist)
--- 102,106 ----
$keywords = array();
! $keywordlists = array_reverse($this->site->xmltree->getParent($pagenode_path, "/site[1]/pages[1]", "page", "keywords"));
foreach($keywordlists as $keywordlist)
***************
*** 100,104 ****
$this->keywords = implode(", ", $keywords);
! $site_pagetree = array_reverse($this->site->xmltree->getParent($pagenode_path, "/site[1]/pages[1]", ""));
$docache = false;
--- 114,118 ----
$this->keywords = implode(", ", $keywords);
! $site_pagetree = array_reverse($this->site->xmltree->getParent($pagenode_path, "/site[1]/pages[1]", "page"));
$docache = false;
***************
*** 106,114 ****
switch ($input_vars['show']) {
case 'printerversion':
! $this->template = $this->site->getTemplate($pagenode_path, "printerversion");
break;
default:
! $this->template = $this->site->getTemplate($pagenode_path);
$docache = true;
break;
--- 120,128 ----
switch ($input_vars['show']) {
case 'printerversion':
! $this->template = $this->getTemplate($pagenode_path, "printerversion");
break;
default:
! $this->template = $this->getTemplate($pagenode_path);
$docache = true;
break;
***************
*** 130,133 ****
--- 144,153 ----
}
+ function &getTemplate($pagenode_path, $template_att = '') {
+ if (empty($template_att))
+ return new Template($this->site->getTemplate($pagenode_path));
+ else
+ return new Template($this->site->getTemplate($pagenode_path, $template_att));
+ }
function getContentCode() {
***************
*** 146,155 ****
function getPageLocationCode() {
// get pagepath code
! $site_pagetree = array_reverse($this->site->xmltree->getParent($this->pagenode_path, "/site[1]/pages[1]", ""));
$prechars = "";
$location = "";
foreach ($site_pagetree as $entry) {
$nodeatt = &$this->site->xmltree->getAttributes($entry);
! $docfile = relToAbs($nodeatt["file"], dirname($this->site->filename));
$docname = $nodeatt["name"];
$location .= $prechars . "<a href=\"$docfile\" class=\"location\">$docname</a>";
--- 166,176 ----
function getPageLocationCode() {
// get pagepath code
! $site_pagetree = array_reverse($this->site->xmltree->getParent($this->pagenode_path, "/site[1]/pages[1]", "page"));
$prechars = "";
$location = "";
foreach ($site_pagetree as $entry) {
$nodeatt = &$this->site->xmltree->getAttributes($entry);
! $docfile = $this->site->getVirtualUrlByPath($entry);
!
$docname = $nodeatt["name"];
$location .= $prechars . "<a href=\"$docfile\" class=\"location\">$docname</a>";
***************
*** 216,220 ****
case "this_url":
! return $this->content->filename;
break;
--- 237,241 ----
case "this_url":
! return $this->site->getVirtualUrlByID($this->pageid);
break;
***************
*** 236,239 ****
--- 257,263 ----
}
+ if (isset($GLOBALS['input_vars'][$field_name]))
+ return $GLOBALS['input_vars'][$field_name];
+
return '{' . "$field_name" . '}';
}
***************
*** 309,314 ****
if ($id == 'self')
! $refurl = $this->content->filename;
else
$refurl = $this->site->getUrlByID($id);
if (empty($refurl))
--- 333,340 ----
if ($id == 'self')
! $refurl = $this->site->getVirtualUrlByID($this->pageid);
else
+ $refurl = $this->site->getVirtualUrlByID($id);
+ if (empty($refurl))
$refurl = $this->site->getUrlByID($id);
if (empty($refurl))
***************
*** 339,348 ****
foreach ($node['attributes'] as $key => $value) $startcode .= " " . $key . '="' . $value . '"';
$startcode .= ">";
! if (!empty($id))
$name = $this->site->getNameByID($id);
! if (empty($name))
! $startcode .= 'link';
! else
! $startcode .= $this->site->getNameByID($id);
$startcode .= "</" . $nodename . ">";
--- 365,375 ----
foreach ($node['attributes'] as $key => $value) $startcode .= " " . $key . '="' . $value . '"';
$startcode .= ">";
! if (!empty($id)) {
$name = $this->site->getNameByID($id);
! if (empty($name))
! $startcode .= 'link';
! else
! $startcode .= $this->site->getNameByID($id);
! }
$startcode .= "</" . $nodename . ">";
***************
*** 356,360 ****
$node['attributes']['border'] = 0;
! $node['attributes']['src'] = $this->site->getUrlByID($node['attributes']['ref']);
unset($node['attributes']['ref']);
}
--- 383,391 ----
$node['attributes']['border'] = 0;
! $refurl = $this->site->getVirtualUrlByID($node['attributes']['ref']);
! if (empty($refurl))
! $refurl = $this->site->getUrlByID($node['attributes']['ref']);
!
! $node['attributes']['src'] = $refurl;
unset($node['attributes']['ref']);
}
***************
*** 577,581 ****
$cache = new Cache();
! $cache->writeFile($this->content->filename, $this->htmlpage, array_unique($GLOBALS['loaded_files']));
}
}
--- 608,612 ----
$cache = new Cache();
! $cache->writeFile($this->virtual_url, $this->htmlpage, array_unique($GLOBALS['loaded_files']));
}
}
***************
*** 589,593 ****
function show() {
! print($this->htmlpage);
}
}
--- 620,629 ----
function show() {
! if (!isset($this->send_as_mail))
! print($this->htmlpage);
! else {
! mail($this->send_as_mail['email'], $this->send_as_mail['subject'], $this->htmlpage);
! print("E-Mail an " . $this->send_as_mail['email'] . " versand.");
! }
}
}
Index: class.Site.php
===================================================================
RCS file: /cvsroot/nextcms/nextcms/class.Site.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** class.Site.php 5 Apr 2002 14:45:09 -0000 1.4
--- class.Site.php 30 Apr 2002 23:58:18 -0000 1.5
***************
*** 8,11 ****
--- 8,15 ----
var $root;
var $id;
+ var $url;
+ var $virtual_url;
+
+ var $no_id_counter;
var $template_files;
***************
*** 20,25 ****
function Site($file) {
! $this->document_root = $GLOBALS['document_root'];
!
// is there such a site file ?
$this->filename = $file;
--- 24,29 ----
function Site($file) {
! $this->no_id_counter = 0;
!
// is there such a site file ?
$this->filename = $file;
***************
*** 35,38 ****
--- 39,44 ----
if (!isset($this->root))
$this->root = dirname($this->filename);
+ if ($this->root == '/')
+ $this->root = '';
$this->title = $this->xmltree->getAttribute('/site[1]', 'title');
***************
*** 40,46 ****
$this->title = "";
- // get some data from template section of the site file
- $this->setTemplates();
-
$this->setIDs();
}
--- 46,49 ----
***************
*** 110,113 ****
--- 113,118 ----
function setTemplates() {
+ $this->template_files = array();
+ $this->template_nodes = array();
$templates = $this->xmltree->getNode("/site[1]/templates[1]", false, "template");
foreach($templates as $template) {
***************
*** 131,134 ****
--- 136,142 ----
function getTemplate($nodepath, $template_att = "file") {
+ if (!isset($this->template_files) || !isset($this->template_nodes))
+ $this->setTemplates();
+
$template_id = $this->xmltree->getAttribute($nodepath, 'template');
***************
*** 157,161 ****
$template_file_path = relToAbs($template_file, dirname($this->filename));
! return new Template($template_file_path);
}
--- 165,169 ----
$template_file_path = relToAbs($template_file, dirname($this->filename));
! return $template_file_path;
}
***************
*** 167,188 ****
function setIDs() {
! $nodepath = array_merge($this->xmltree->getNode("/site[1]/resources[1]", true, 'resource', 'id'),
! $this->xmltree->getNode('/site[1]/pages[1]', true, 'page', 'id'));
! foreach ($nodepath as $path) {
! $id = $this->xmltree->getAttribute($path, 'id');
! $this->id[$id] = $path;
}
}
!
function getUrlByID($id) {
! if (isset($this->id[$id])) {
! $url = $this->xmltree->getAttribute($this->id[$id], 'url');
! if (!isset($url)) $url = $this->xmltree->getAttribute($this->id[$id], 'file');
! if (!isset($url)) return;
! if (strstr($url, ':'))
! return $url;
! else
! return relToAbs($url, dirname($this->filename));
! }
}
--- 175,241 ----
function setIDs() {
! $this->id = array();
! $this->virtual_url = array();
! // $nodepath = array_merge($this->xmltree->getNode("/site[1]/resources[1]", true, 'resource'),
! // $this->xmltree->getNode('/site[1]/pages[1]', true, 'page'));
! for ($i=0;$i<2;$i++) {
! if ($i == 0) $nodepath = $this->xmltree->getNode('/site[1]/resources[1]', true, 'resource');
! if ($i == 1) $nodepath = $this->xmltree->getNode('/site[1]/pages[1]', true, 'page');
!
! foreach ($nodepath as $path) {
! $id = $this->xmltree->getAttribute($path, 'id');
!
! if (empty($id)) {
! $id = '_ID' . $this->no_id_counter;
! $this->no_id_counter++;
! // $this->xmltree->setAttribute($path, 'id', $id);
! }
!
! if (isset($this->id[$id])) continue;
!
! $this->id[$id] = $path;
!
! $url = $this->xmltree->getAttribute($this->id[$id], 'url');
! if (!isset($url)) $url = $this->xmltree->getAttribute($this->id[$id], 'file');
! if (!isset($url)) return;
! if (!strstr($url, ':'))
! $url = relToAbs($url, dirname($this->filename));
!
! $this->url[$id] = $url;
!
!
! $as = $this->xmltree->getAttribute($path, 'as');
! if ($i==1) {
! if (isset($as))
! $this->virtual_url[$this->generateVirtualUrl($as)] = $id;
! else
! $this->virtual_url[$url] = $id;
! }
!
! }
}
}
!
! function generateVirtualUrl($param) {
! return relToAbs($param, $this->root);
! }
!
function getUrlByID($id) {
! if (isset($this->url[$id]))
! return $this->url[$id];
! }
!
! function getVirtualUrlByID($id) {
! $vurl = array_search($id, $this->virtual_url);
! if ($vurl !== false)
! return $vurl;
! }
!
! function getVirtualUrlByPath($path) {
! // $id = $this->xmltree->getAttribute($path, 'id');
! $id = array_search($path, $this->id);
! $vurl = array_search($id, $this->virtual_url);
! if ($vurl !== false)
! return $vurl;
}
***************
*** 196,199 ****
--- 249,265 ----
return $this->id[$id];
}
+
+ function &getIDUrlList() {
+ $id = array();
+ foreach ($this->id as $key => $value) {
+ $id[$key] = $this->getUrlByID($key);
+ }
+
+ return $id;
+ }
+
+ function &getVirtualUrlIDList() {
+ return $this->virtual_url;
+ }
}
?>
Index: class.Template.php
===================================================================
RCS file: /cvsroot/nextcms/nextcms/class.Template.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** class.Template.php 19 Mar 2002 17:51:06 -0000 1.1.1.1
--- class.Template.php 30 Apr 2002 23:58:18 -0000 1.2
***************
*** 1,7 ****
<?php
- /**
- * some parts of this class are based on TemplatePower
- *
- */
class Template {
var $filename;
--- 1,3 ----
***************
*** 13,25 ****
function Template($file) {
! if (isset($GLOBALS['NOIDENT']))
! $this->noident = $GLOBALS['NOIDENT'];
! else
! $this->noident = false;
!
!
$this->template = array();
! $this->document_root = getDocRoot();
$this->filename = $file;
--- 9,18 ----
function Template($file) {
! // ident support is broken so it's disabled
! $this->noident = true;
!
$this->template = array();
! $this->document_root = $GLOBALS['document_root'];
$this->filename = $file;
Index: processor.conf.php-dist
===================================================================
RCS file: /cvsroot/nextcms/nextcms/processor.conf.php-dist,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** processor.conf.php-dist 5 Apr 2002 14:51:42 -0000 1.5
--- processor.conf.php-dist 30 Apr 2002 23:58:18 -0000 1.6
***************
*** 1,12 ****
<?php
! $PARSER_DIR = '/nextCMS';
! $EXTENSION_DIR = $PARSER_DIR . "/extensions";
// if $LOG_FILE is set logging is enabled
! $LOG_DIR = $PARSER_DIR . '/logs';
$LOG_FILE = $LOG_DIR . '/site.log';
// if $CACHE_DIR is set caching is enabled
! $CACHE_DIR = $PARSER_DIR . '/cache';
// each site should be registered here
--- 1,24 ----
<?php
! // The document_root can be detected automaticly.
! // If you exprience problems with the automatic detection
! // or for speed reasons you can setup the document root
! // manually.
!
! // $document_root = '/usr/local/httpd/htdocs';
!
! // The install path of nextcms.
! $INSTALL_DIR = '/nextcms';
!
! // The path in which the extensions are in.
! $EXTENSION_DIR = $INSTALL_DIR . "/extensions";
// if $LOG_FILE is set logging is enabled
! // remember to set write permissions
! $LOG_DIR = $INSTALL_DIR . '/logs';
$LOG_FILE = $LOG_DIR . '/site.log';
// if $CACHE_DIR is set caching is enabled
! // remember to set write permissions
! $CACHE_DIR = $INSTALL_DIR . '/cache';
// each site should be registered here
***************
*** 25,31 ****
// should host names be resolved
$RESOLVE_HOST_NAMES = true;
- // the document_root can be detected automaticly
- // should only be used for speed reasons
- // $document_root = '/usr/local/httpd/htdocs';
?>
--- 37,43 ----
// should host names be resolved
$RESOLVE_HOST_NAMES = true;
+
+ // sending a last modified header can lower your traffic
+ $SEND_LAST_MODIFIED_HEADER = false;
?>
Index: processor.php
===================================================================
RCS file: /cvsroot/nextcms/nextcms/processor.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** processor.php 5 Apr 2002 14:45:09 -0000 1.3
--- processor.php 30 Apr 2002 23:58:18 -0000 1.4
***************
*** 1,18 ****
<?php
- include('processor.conf.php');
-
- //startTimer();
-
ob_start('ob_gzhandler');
if (!isset($document_root)) {
! include('utils.php');
$document_root = getDocRoot();
}
! $input_vars = getGetParams(); if (!isset($input_vars['file'])) die(); else
! $file = $input_vars['file']; if (!isset($input_vars['show']))
! $input_vars['show'] = ""; if (!isset($input_vars['action']))
! $input_vars['action'] = "";
if ($CHECK_IF_CONTENTFILE) checkContent($file);
--- 1,22 ----
<?php
ob_start('ob_gzhandler');
+ if (!include('processor.conf.php')) {
+ include_once('utils.php');
+ printError("Can't find the config file processor.conf.php.");
+ }
+
+ // include_once('utils.php');
+ // startTimer();
+
if (!isset($document_root)) {
! include_once('utils.php');
$document_root = getDocRoot();
}
! $input_vars = getGetParams();
! if (!isset($input_vars['file'])) die(); else $file = $input_vars['file'];
! if (!isset($input_vars['show'])) $input_vars['show'] = "";
! if (!isset($input_vars['action'])) $input_vars['action'] = "";
if ($CHECK_IF_CONTENTFILE) checkContent($file);
***************
*** 20,28 ****
if ($input_vars['action'] == 'edit') {
include_once('utils.php');
! include('class.Admin.php');
! $admin = new Admin($file);
} else {
include('class.Cache.php');
$cache = new Cache($file);
if ($cache->is_cached && empty($input_vars['show'])) {
--- 24,34 ----
if ($input_vars['action'] == 'edit') {
include_once('utils.php');
! // include('class.Admin.php');
! // $admin = new Admin($file);
} else {
include('class.Cache.php');
$cache = new Cache($file);
+
+ //$cache->is_cached = false;
if ($cache->is_cached && empty($input_vars['show'])) {
***************
*** 35,44 ****
}
! include('class.Log.php');
! $log = new Log($file);
}
! //stopTimer();
! //print "<br>\n<div align=\"center\"><b>created in: $totaltime sec</b></div>";
function getGetParams() {
--- 41,53 ----
}
! if (isset($GLOBALS['LOG_FILE'])) {
! include('class.Log.php');
! $log = new Log($file);
! }
}
! // stopTimer();
! if (isset($totaltime))
! print "<br>\n<div align=\"center\"><b>created in: $totaltime sec</b></div>";
function getGetParams() {
***************
*** 54,93 ****
}
function checkContent($file) {
include_once('utils.php');
$code = loadFile($file);
// could be unsafe (just for testing)
if (strpos($code, "<contentpage") === false) {
! print($code);
! exit();
}
! }
!
! function printError($errormsg) {
! print "<html><title>Parse Error</title><body>\n";
! print "<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\" bgcolor=\"#f8ecc4\">\n";
! print "<tr><td>";
! print "<font size=\"4\">" . $errormsg . "</font>";
! print "</td></tr>";
! print "</table>\n";
! print "\n</body></html>";
! exit();
! }
!
! // activate this if you want
! /*
! function startTimer() {
! global $starttime;
! $mtime = explode(" ",microtime());
! $starttime = $mtime[1] + $mtime[0];
! }
!
! function stopTimer() {
! global $totaltime, $starttime;
! $mtime = explode(" ",microtime());
! $endtime = $mtime[1] + $mtime[0];
! $totaltime = round($endtime - $starttime,5);
! }
! */
?>
--- 63,80 ----
}
+ /**
+ * check whether the reqested file is a html file
+ */
function checkContent($file) {
+ global $document_root;
include_once('utils.php');
+
+ if (!file_exists($document_root . $file)) return;
$code = loadFile($file);
// could be unsafe (just for testing)
if (strpos($code, "<contentpage") === false) {
! die($code);
}
! }
?>
Index: utils.php
===================================================================
RCS file: /cvsroot/nextcms/nextcms/utils.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** utils.php 5 Apr 2002 14:45:09 -0000 1.3
--- utils.php 30 Apr 2002 23:58:18 -0000 1.4
***************
*** 119,126 ****
*/
function loadFile($filename, $in_lines = false) {
! global $loaded_files, $document_root;
$file = $document_root . $filename;
- if (!isset($loaded_files))
- $loaded_files = array();
if (!file_exists($file)) printError("Die Datei '$file' kann nicht gefunden werden.");
if (!is_readable($file)) printError("Es fehlen die Rechte zum Zugriff auf die Datei '$file'.");
--- 119,124 ----
*/
function loadFile($filename, $in_lines = false) {
! global $loaded_files, $loaded_files_enabled, $document_root;
$file = $document_root . $filename;
if (!file_exists($file)) printError("Die Datei '$file' kann nicht gefunden werden.");
if (!is_readable($file)) printError("Es fehlen die Rechte zum Zugriff auf die Datei '$file'.");
***************
*** 135,143 ****
}
! array_push($loaded_files,$filename);
return $file_contents;
}
! $document_root = getDocRoot();
?>
--- 133,172 ----
}
! if ($loaded_files_enabled) array_push($loaded_files,$filename);
return $file_contents;
}
+
+ function printError($errormsg) {
+ print "<html><head><meta name=\"ROBOTS\" content=\"NOINDEX, NOFOLLOW\" /><title>Process Error</title></head>\n";
+ print "<body bgcolor=\"#EEEEEE\">\n";
+ print "<table border=\"0\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#000000\" align=\"center\" width=\"600\">\n";
+ print "<tr bgcolor=\"#f8ecc4\"><td>\n";
+ print "<h2>Error:</h2>\n";
+ print "<font size=\"4\">" . $errormsg . "</font>";
+ print "</td></tr>\n";
+ print "</table>\n";
+ print "\n</body></html>";
+ exit();
+ }
!
! if (!function_exists('array_search')) {
! function array_search($str, $vars) {
! foreach ($vars as $key => $val) {
! if ($val == $str)
! return $key;
! }
! return false;
! }
! }
!
! function enableLoadedFiles() {$GLOBALS['loaded_files_enabled'] = true;}
! function disableLoadedFiles() {$GLOBALS['loaded_files_enabled'] = false;}
!
! $GLOBALS['loaded_files'] = array();
! $GLOBALS['loaded_files_enabled'] = true;
!
! if (!isset($GLOBALS['document_root']))
! $document_root = getDocRoot();
?>
Index: xml.php
===================================================================
RCS file: /cvsroot/nextcms/nextcms/xml.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** xml.php 19 Mar 2002 17:51:06 -0000 1.1.1.1
--- xml.php 30 Apr 2002 23:58:18 -0000 1.2
***************
*** 91,94 ****
--- 91,99 ----
}
+ function setAttribute($path, $name, $value) {
+ if (isset($this->nodes[$path]['attributes'][$name]))
+ $this->nodes[$path]['attributes'][$name] = $value;
+ }
+
function getAttributes($path) {
if (isset($this->nodes[$path]))
|