[Phpcms-plugins-cvs] guestbook4phpCMS/include class.guestbook4phpCMS.php,NONE,1.1 config.inc.php,NON
Brought to you by:
mjahn
Update of /cvsroot/phpcms-plugins/guestbook4phpCMS/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24168/include Added Files: class.guestbook4phpCMS.php config.inc.php class.template.php xmlwriterclass.php rss_writer_class.php class.bbcode.php Log Message: updated the header of the files included GPL and README --- NEW FILE: class.guestbook4phpCMS.php --- <?php include_once(dirname(__FILE__).'/class.template.php'); include_once(dirname(__FILE__).'/class.bbcode.php'); include_once (dirname (__FILE__).'/rss_writer_class.php'); require_once('XML/Serializer.php'); require_once('XML/Unserializer.php'); error_reporting (E_ALL); class guestbook4phpCMS { var $_xml_options = array ('indent'=>' ', 'linebreak'=>"\n", 'addDecl'=>true, 'tagName'=>'guestbook', 'defaultTagName'=>'guest', 'encoding'=>'iso-8859-1'); var $_loaded = false; var $_datafile = ''; function guestbook4phpCMS ($datafile = '') { return $this->__construct ($datafile); } function __construct ($datafile = '') { if ($datafile != '' && !$this->load ($datafile)) { return false; } $this->docroot = realpath ($_SERVER ['DOCUMENT_ROOT']); return true; } function load ($datafile) { if (!file_exists ($datafile)) { return false; } $this->_datafile = $datafile; $unserializer =& new XML_Unserializer(); $unserializer->unserialize($datafile, true); $this->data =& $unserializer->getUnserializedData(); if (!is_array ($this->data)) { $this->_loaded = false; return false; } $this->_DATA =& $this->data['guest']; if (!is_array ($this->_DATA)) { $this->_loaded = false; return false; } usort($this->_DATA, array ('guestbook4phpCMS', 'compare')); $this->_loaded = true; } function save ($datafile = '') { global $CONFIG; if (isset ($this->_datafile) && $this->_datafile != '' && $datafile == '') { $datafile = $this->_datafile; } if (!file_exists ($datafile) || !is_writeable ($datafile) || !$this->_loaded) { return false; } $serializer = &new XML_Serializer($this->_xml_options); $result = $serializer->serialize($this->_DATA); $fh = fopen($datafile, 'wb'); fwrite($fh, $serializer->getSerializedData()); fclose($fh); $fh = fopen($_SERVER['DOCUMENT_ROOT'].$CONFIG ['rss-file'], 'wb'); fwrite($fh, $this->rss (0, -1, true)); fclose($fh); } function parse () { } function compare ($a, $b) { if ($a['time'] == $b['time']) return 0; return $a['time'] > $b['time'] ? 1 : -1; } function bbcode ($text) { $parser = new bbcode(); return $parser->qparse($text); } function view ($start = 0, $count = -1) { if (!$this->_loaded) { return 'false'; } $TPL = &new cTemplate(); $TPL->load(dirname(__FILE__).'/../gb.tpl'); $TPL->parse(); $o = explode("\n", $TPL->process('GB.PRE')); $kontaktfields = array('email','hp'); $num = count ($this->_DATA); if ($count != -1 && $start + $count < $num - 1) { $num = $start + $count; } for ($i = $num - 1; $i >= $start; $i--) { $entry = $this->_DATA [$i]; $entry['time'] = strftime('am %d. %m. %Y um %H:%M', $entry['time']); $entry['counter'] = $i + 1; if (isset($entry['hp']) && $entry['hp'] != '' && strpos($entry['hp'], '://') == 0) { $entry['hp'] = 'http://'.$entry['hp']; } $kontakt = false; foreach ($entry as $id=>$value) { if (!isset($value) || trim($value) == '') { $TPL->delField('GB.'.strtoupper($id)); $TPL->delField(strtoupper($id)); continue; } if (in_array($id, $kontaktfields)) { $kontakt = true; } $TPL->setFieldValue('GB.'.strtoupper($id), $TPL->getFieldValue('GB.TPL.'.strtoupper($id))); $TPL->setFieldValue(strtoupper($id), str_replace("\n", '<br />', strip_tags(trim($value)))); } $TPL->delField('GB.KONTAKT'); if ($kontakt) { $TPL->setFieldValue('GB.KONTAKT', $TPL->getFieldValue('GB.TPL.KONTAKT')); } $o = array_merge($o, explode("\n", $this->bbcode($TPL->process('GB.NORMAL')))); } $o = array_merge($o, explode("\n", $TPL->process('GB.PAST'))); // process output with phpCMS-MAIL2CRYPT if available if (isset ($GLOBALS ['PHPCMS_INCLUDEPATH']) && file_exists ($GLOBALS ['PHPCMS_INCLUDEPATH'].'/class.mail2crypt_phpcms.php')) { include_once($GLOBALS ['PHPCMS_INCLUDEPATH'].'/class.mail2crypt_phpcms.php'); $Mail2Crypt = new Mail2Crypt(); $o = @$Mail2Crypt->crypt_mailto($o); } return join("\n", $o); } function rss ($start = 0, $count = -1, $no_header = true) { global $CONFIG; if (!$this->_loaded) { return false; } // First create an object of the class. $rss_writer_object=new rss_writer_class; // Second: choose the version of specification that the generated RSS document should conform. $rss_writer_object->specification="1.0"; // Third: Specify the URL where the RSS document will be made available. $rss_writer_object->about = 'http://'.$_SERVER ['HTTP_HOST'].$_SERVER['PHP_SELF']; /* * Specify the URL of an optional XSL stylesheet. * This lets the document be rendered automatically in XML capable browsers * such as Internet Explore 5, Mozilla 5/Netscape 6 or better. */ $rss_writer_object->stylesheet = $CONFIG ['rss-xsl-web'];//"http://mjahn.homelinux.org/guestbook.xsl"; /* * When generating RSS version 1.0, you may declare additional * namespaces that enable the use of more property tags defined * by extension modules of the RSS specification. */ $rss_writer_object->rssnamespaces["dc"]="http://purl.org/dc/elements/1.1/"; /* * Define the properties of the channel. */ $properties=array(); $properties["description"] = $CONFIG ['rss-desc']; $properties["link"] = $CONFIG ['rss-link']; $properties["title"] = $CONFIG ['rss-title']; $properties["dc:date"] = strftime ('', time ());//"2004-05-14T23:30:00Z"; $rss_writer_object->addchannel($properties); // add the rss-items $num = count ($this->_DATA); if ($count != -1 && $start + $count < $num - 1) { $num = $start + $count; } for ($i = $start; $i < $num; $i++) { $properties=array(); $properties["description"] = $this->_DATA[$i]['text']; $properties["link"] = $CONFIG ['rss-link']; $properties["title"]=$this->_DATA[$i]['name'].' aus '.$this->_DATA[$i]['place'].' schrieb'; $properties["dc:date"] = strftime ('', time ()); //"2002-05-06T00:00:00Z"; $rss_writer_object->additem($properties); } // generate RSS document. if($rss_writer_object->writerss($output)) { if (!$no_header) { Header("Content-Type: text/xml; charset=\"".$rss_writer_object->outputencoding."\""); Header("Content-Length: ".strval(strlen($output))); } return $output; } else { if (!$no_header) { Header("Content-Type: text/plain"); } return ("Error: ".$rss_writer_object->error); } } function add ($dataset = array ()) { if (count ($dataset) == 0) { return false; } if (!$this->_loaded) { return false; } $this->_DATA[] = $dataset; } function del ($id) { } } ?> --- NEW FILE: xmlwriterclass.php --- <?php if(!defined("METAL_LIBRARY_XML_XML_WRITER_CLASS")) { define("METAL_LIBRARY_XML_XML_WRITER_CLASS",1); /* * * Copyright © (C) Manuel Lemos 2001-2002 * * @(#) $Id: xmlwriterclass.php,v 1.1 2004/07/29 03:47:19 mjahn Exp $ * */ class xml_writer_class { /* * Protected variables * */ var $structure=array(); var $nodes=array(); /* * Public variables * */ var $stylesheet=""; var $stylesheettype="text/xsl"; var $dtdtype=""; var $dtddefinition=""; var $dtdurl=""; var $outputencoding="utf-8"; var $inputencoding="iso-8859-1"; var $linebreak="\n"; var $indenttext=" "; var $generatedcomment="Generated by: http://www.phpclasses.org/xmlwriter \$Revision: 1.1 $"; var $error=""; /* * Protected functions * */ Function escapedata($data) { $position=0; $length=strlen($data); $escapeddata=""; for(;$position<$length;) { $character=substr($data,$position,1); $code=Ord($character); switch($code) { case 34: $character="""; break; case 38: $character="&"; break; case 39: $character="'"; break; case 60: $character="<"; break; case 62: $character=">"; break; default: if($code<32) $character=("&#".strval($code).";"); break; } $escapeddata.=$character; $position++; } return $escapeddata; } Function encodedata($data,&$encodeddata) { if(!strcmp($this->inputencoding,$this->outputencoding)) $encodeddata=$this->escapedata($data); else { switch(strtolower($this->outputencoding)) { case "utf-8": if(!strcmp(strtolower($this->inputencoding),"iso-8859-1")) { $encoded_data=utf8_encode($this->escapedata($data)); $encodeddata=$encoded_data; } else { $this->error=("can not encode iso-8859-1 data in ".$this->outputencoding); return 0; } break; case "iso-8859-1": if(!strcmp(strtolower($this->inputencoding),"utf-8")) { $decoded=utf8_decode($data); $encodeddata=$this->escapedata($decoded); } else { $this->error=("can not encode utf-8 data in ".$this->outputencoding); return 0; } break; default: $this->error=("can not encode data in ".$this->inputencoding); return 0; } } return 1; } Function writetag(&$output,$path,$indent) { $tag=$this->structure[$path]["Tag"]; $output.=("<".$tag); $attributecount=count($this->structure[$path]["Attributes"]); if($attributecount>0) { $attributes=$this->structure[$path]["Attributes"]; Reset($attributes); $end=(GetType($key=Key($attributes))!="string"); for(;!$end;) { $output.=(" ".$key."=\"".$attributes[$key]."\""); Next($attributes); $end=(GetType($key=Key($attributes))!="string"); } } $elements=$this->structure[$path]["Elements"]; if($elements>0) { $output.=">"; $doindent=$this->structure[$path]["Indent"]; $elementindent=(($doindent) ? $this->linebreak.$indent.$this->indenttext : ""); $element=0; for(;$element<$elements;) { $elementpath=($path.",".strval($element)); $output.=$elementindent; if(IsSet($this->nodes[$elementpath])) { if(!($this->writetag($output,$elementpath,$indent.$this->indenttext))) return 0; } else $output.=$this->structure[$elementpath]; $element++; } $output.=((($doindent) ? $this->linebreak.$indent : "")."</".$tag.">"); } else $output.="/>"; return 1; } /* * Public functions * */ Function write(&$output) { if(strcmp($this->error,"")) return 0; if(!(IsSet($this->structure["0"]))) { $this->error="XML document structure is empty"; return 0; } $output=("<?xml version=\"1.0\" encoding=\"".$this->outputencoding."\"?>".$this->linebreak); if(strcmp($this->dtdtype,"")) { $output.=("<!DOCTYPE ".$this->structure["0"]["Tag"]." "); switch($this->dtdtype) { case "INTERNAL": if(!strcmp($this->dtddefinition,"")) { $this->error="it was not specified a valid internal DTD definition"; return 0; } $output.=("[".$this->linebreak.$this->dtddefinition.$this->linebreak."]"); break; case "SYSTEM": if(!strcmp($this->dtdurl,"")) { $this->error="it was not specified a valid system DTD url"; return 0; } $output.="SYSTEM"; if(strcmp($this->dtddefinition,"")) $output.=(" \"".$this->dtddefinition."\""); $output.=(" \"".$this->dtdurl."\""); break; case "PUBLIC": if(!strcmp($this->dtddefinition,"")) { $this->error="it was not specified a valid public DTD definition"; return 0; } $output.=("PUBLIC \"".$this->dtddefinition."\""); if(strcmp($this->dtdurl,"")) $output.=(" \"".$this->dtdurl."\""); break; default: $this->error="it was not specified a valid DTD type"; return 0; } $output.=(">".$this->linebreak); } if(strcmp($this->stylesheet,"")) { if(!strcmp($this->stylesheettype,"")) { $this->error="it was not specified a valid stylesheet type"; return 0; } $output.=("<?xml-stylesheet type=\"".$this->stylesheettype."\" href=\"".$this->stylesheet."\"?>".$this->linebreak); } if(strcmp($this->generatedcomment,"")) $output.=("<!-- ".$this->generatedcomment." -->".$this->linebreak); return $this->writetag($output,"0",""); } Function addtag($tag,&$attributes,$parent,&$path,$indent) { if(strcmp($this->error,"")) return 0; $path=((!strcmp($parent,"")) ? "0" : ($parent.",".strval($this->structure[$parent]["Elements"]))); if(IsSet($this->structure[$path])) { $this->error=("tag with path ".$path." is already defined"); return 0; } $encodedattributes=array(); Reset($attributes); $end=(GetType($attribute_name=Key($attributes))!="string"); for(;!$end;) { $encodedattributes[$attribute_name]=""; if(!($this->encodedata($attributes[$attribute_name],$encoded_data))) return 0; $encodedattributes[$attribute_name]=$encoded_data; Next($attributes); $end=(GetType($attribute_name=Key($attributes))!="string"); } $this->structure[$path]=array( "Tag"=>$tag, "Attributes"=>$encodedattributes, "Elements"=>0, "Indent"=>$indent ); $this->nodes[$path]=1; if(strcmp($parent,"")) $this->structure[$parent]["Elements"]=($this->structure[$parent]["Elements"]+1); return 1; } Function adddata($data,$parent,&$path) { if(strcmp($this->error,"")) return 0; if(!(IsSet($this->structure[$parent]))) { $this->error=("the parent tag path".$path."is not defined"); return 0; } if(!strcmp($data,"")) return 1; $path=($parent.",".strval($this->structure[$parent]["Elements"])); if(!($this->encodedata($data,$encoded_data))) return 0; $this->structure[$path]=$encoded_data; $this->structure[$parent]["Elements"]=($this->structure[$parent]["Elements"]+1); return 1; } Function adddatatag($tag,&$attributes,$data,$parent,&$path) { return $this->addtag($tag,$attributes,$parent,$path,0) && $this->adddata($data,$path,$datapath); } }; } ?> --- NEW FILE: class.template.php --- <?php class cTemplate { var $limiter = array ('{', '}'); var $tpl = array(); function load ($tplfilename) { if (!file_exists($tplfilename)) { return false; } $this->filename = $tplfilename; } function parse () { $beginlen = strlen($this->limiter[0]); $endlen = strlen($this->limiter[1]); $cofi = file($this->filename); reset($cofi); // einen DUMMY für ersten Text übernehmen $vol = ''; //durch die Zeilen iterieren und zuordung aus //geklammerten anweisungen lesen while( list($key,$val) = each($cofi)) { //$val = trim($val); //Start gefunden ? if ( substr($val,0,$beginlen) == $this->limiter[0] ) { //Das Ende der Klammer finden $end = strpos($val,$this->limiter[1],$beginlen); //Den Inhalt der Klammer als Key übernehmen $vol = trim(substr($val,$beginlen, $end-1)); //Den Rest der Zeile dem Key zuordnen $this->tpl[$vol] = isset($this->tpl[$vol]) ? $this->tpl[$vol].substr($val,$end+$endlen) : substr($val,$end+$endlen); continue; } //Zeile dem aktuellen Key zuordnen $this->tpl[$vol] .= $val; } } function process ($fieldname) { $outtext = ''; $text = $this->tpl[$fieldname]; $replaces = $this->tpl; $beginlen = strlen($this->limiter[0]); $endlen = strlen($this->limiter[1]); $count = 0; $pos = strpos($text,$this->limiter[0], $count); while( $pos > 0) { $endpos = strpos($text,$this->limiter[1],$pos + $beginlen); if ( $endpos > 0) { $tag = trim(substr($text,$pos+$beginlen, ($endpos-($pos+$beginlen)) ) ); if (isset($replaces[$tag])) { $text = substr($text,0,$pos) . $replaces[$tag] . substr($text,$endpos+$endlen); $count = $pos;// + strlen($replaces[$tag]); } else { $text = substr($text,0,$pos) . substr($text,$endpos+$endlen); $count = $pos; } } else { break; } $pos = @strpos($text,$this->limiter[0], $count); //echo 'process['.$fieldname.'] = '.$text."\n"; } return $text; } function setFieldValue ($fieldname, $value) { $this->tpl[$fieldname] = $value; } function getFieldValue ($fieldname) { if (!isset($this->tpl[$fieldname])) { return false; } return $this->tpl[$fieldname]; } function delField ($fieldname) { if (!isset($this->tpl[$fieldname])) { return false; } unset ($this->tpl[$fieldname]); } } ?> --- NEW FILE: rss_writer_class.php --- <?php if(!defined("METAL_LIBRARY_XML_RSS_WRITER_CLASS")) { define("METAL_LIBRARY_XML_RSS_WRITER_CLASS",1); include_once (dirname (__FILE__).'/xmlwriterclass.php'); /* * * Copyright © (C) Manuel Lemos 2002 * * @(#) $Id: rss_writer_class.php,v 1.1 2004/07/29 03:47:19 mjahn Exp $ * */ class rss_writer_class extends xml_writer_class { /* * Protected variables * */ var $root=""; var $channel=""; var $image=""; var $textinput=""; var $items=0; var $itemsequence=""; /* * Public variables * */ var $specification="1.0"; var $about=""; var $rssnamespaces=array(); var $allownoitems=0; var $generatedcomment="Generated by: http://www.phpclasses.org/rsswriter \$Revision: 1.1 $"; /* * Protected functions * */ function addrssproperties(&$properties,$parent,&$required,&$optional,$scope) { $noattributes=array(); $required_properties=0; Reset($properties); $end=(GetType($property=Key($properties))!="string"); for(;!$end;) { if(IsSet($required[$property])) { if($required[$property]) { $this->error=("required ".$scope." property \"".$property."\" is already set"); return 0; } $required[$property]=1; $required_properties++; } else { if(IsSet($optional[$property])) { if($optional[$property]) { $this->error=("optional ".$scope." property \"".$property."\" is already set"); return 0; } $optional[$property]=1; } else { if(GetType($colon=strpos($property,":",0))=="integer") { $namespace=substr($property,0,$colon); if(!(!strcmp($namespace,"rdf") || IsSet($this->rssnamespaces[$namespace]))) $this->error=("the name space of property \"".$property."\" was not declared"); } else $this->error=("\"".$property."\" is not a supported ".$scope." property"); } } if(!($this->adddatatag($property,$noattributes,$properties[$property],$parent,$path))) return 0; Next($properties); $end=(GetType($property=Key($properties))!="string"); } if($required_properties<count($required)) { Reset($required); $end=(GetType($property=Key($required))!="string"); for(;!$end;) { if(!($required[$property])) { $this->error=("it was not specified the required ".$scope." property \"".$property."\""); return 0; } Next($required); $end=(GetType($property=Key($required))!="string"); } } return 1; } /* * Public functions * */ Function addchannel(&$properties) { if(strcmp($this->error,"")) return 0; if(strcmp($this->channel,"")) { $this->error="a channel was already added"; return 0; } $channel_attributes=array(); switch($this->specification) { case "0.9": $root="rdf:RDF"; $attributes=array("xmlns:rdf"=>"http://www.w3.org/1999/02/22-rdf-syntax-ns#","xmlns"=>"http://my.netscape.com/rdf/simple/0.9/"); $required=array("description"=>0,"link"=>0,"title"=>0); $optional=array(); break; case "0.91": $root="rss"; $attributes=array("version"=>$this->specification); $required=array("description"=>0,"language"=>0,"link"=>0,"title"=>0); $optional=array("copyright"=>0,"docs"=>0,"lastBuildDate"=>0,"managingEditor"=>0,"pubDate"=>0,"rating"=>0,"webMaster"=>0); break; case "1.0": if(!strcmp($this->about,"")) { $this->error="it was not specified the about URL attribute"; return 0; } $root="rdf:RDF"; $attributes=array("xmlns:rdf"=>"http://www.w3.org/1999/02/22-rdf-syntax-ns#","xmlns"=>"http://purl.org/rss/1.0/"); Reset($this->rssnamespaces); $end=(GetType($namespace=Key($this->rssnamespaces))!="string"); for(;!$end;) { if(!strcmp($namespace,"rdf")) { $this->error="the rdf namespace is being redeclared"; return 0; } $attributes[("xmlns:".$namespace)]=$this->rssnamespaces[$namespace]; Next($this->rssnamespaces); $end=(GetType($namespace=Key($this->rssnamespaces))!="string"); } $channel_attributes=array("rdf:about"=>$this->about); $required=array("description"=>0,"link"=>0,"title"=>0); $optional=array(); break; default: $this->error="it was not specified a supported RSS specification version"; return 0; } $this->addtag($root,$attributes,"",$path,1); $this->root=$path; if(!($this->addtag("channel",$channel_attributes,$this->root,$path,1))) return 0; if(!($this->addrssproperties($properties,$path,$required,$optional,"channel"))) return 0; $this->channel=$path; return 1; } Function additem(&$properties) { if(strcmp($this->error,"")) return 0; if(!strcmp($this->channel,"")) { $this->error="the channel was not yet added"; return 0; } if(strcmp($this->textinput,"")) { $this->error="items can not be added to the channel after defining the textinput"; return 0; } $attributes=array(); switch($this->specification) { case "0.9": $parent=$this->root; break; case "0.91": $parent=$this->channel; break; case "1.0": if(IsSet($properties["link"])) $attributes["rdf:about"]=$properties["link"]; $parent=$this->root; break; default: $this->error="it was not specified a supported RSS specification version"; return 0; } if(!($this->addtag("item",$attributes,$parent,$path,1))) return 0; $required=array("link"=>0,"title"=>0); $optional=array("description"=>0); if(!($this->addrssproperties($properties,$path,$required,$optional,"item"))) return 0; if(!strcmp($this->specification,"1.0")) { if(!strcmp($this->itemsequence,"")) { $attributes=array(); if(!($this->addtag("items",$attributes,$this->channel,$path,1) && $this->addtag("rdf:Seq",$attributes,$path,$path,1))) return 0; $this->itemsequence=$path; } $attributes=array("rdf:resource"=>$properties["link"]); if(!($this->addtag("rdf:li",$attributes,$this->itemsequence,$path,0))) return 0; } $this->items++; return 1; } Function addimage(&$properties) { if(strcmp($this->error,"")) return 0; if(!strcmp($this->channel,"")) { $this->error="the channel was not yet added"; return 0; } if(strcmp($this->image,"")) { $this->error="the channel image was already associated"; return 0; } if($this->items!=0) { $this->error="the image can only be defined before adding the channel items"; return 0; } $attributes=array(); switch($this->specification) { case "0.9": $parent=$this->root; break; case "0.91": $parent=$this->channel; break; case "1.0": if(IsSet($properties["url"])) $attributes["rdf:about"]=$properties["url"]; $parent=$this->root; break; default: $this->error="it was not specified a supported RSS specification version"; return 0; } if(!($this->addtag("image",$attributes,$parent,$path,1))) return 0; $this->image=$path; $required=array("link"=>0,"title"=>0,"url"=>0); $optional=array("description"=>0,"width"=>0,"height"=>0); if(!($this->addrssproperties($properties,$this->image,$required,$optional,"image"))) return 0; if(!strcmp($this->specification,"1.0")) { $attributes=array("rdf:resource"=>$properties["url"]); return $this->addtag("image",$attributes,$this->channel,$path,0); } return 1; } Function addtextinput(&$properties) { if(strcmp($this->error,"")) return 0; if(!strcmp($this->channel,"")) { $this->error="the channel was not yet added"; return 0; } if(strcmp($this->textinput,"")) { $this->error="the channel text input was already associated"; return 0; } if($this->items==0 && !$this->allownoitems) { $this->error="it were not specified any items before defining the channel text input"; return 0; } $attributes=array(); switch($this->specification) { case "0.9": $parent=$this->root; break; case "0.91": $parent=$this->channel; break; case "1.0": if(IsSet($properties["link"])) $attributes["rdf:about"]=$properties["link"]; $parent=$this->root; break; default: $this->error="it was not specified a supported RSS specification version"; return 0; } if(!($this->addtag("textinput",$attributes,$parent,$path,1))) return 0; $this->textinput=$path; $required=array("description"=>0,"link"=>0,"name"=>0,"title"=>0); $optional=array(); if(!($this->addrssproperties($properties,$this->textinput,$required,$optional,"textinput"))) return 0; if(!strcmp($this->specification,"1.0")) { $attributes=array("rdf:resource"=>$properties["link"]); return $this->addtag("textinput",$attributes,$this->channel,$path,0); } return 1; } Function writerss(&$output) { if(strcmp($this->error,"")) return 0; if(!strcmp($this->channel,"")) { $this->error="it was not defined the RSS channel"; return 0; } if($this->items==0 && !$this->allownoitems) { $this->error="it were not defined any RSS channel items"; return 0; } switch($this->specification) { case "0.9": $this->dtdtype="PUBLIC"; $this->dtddefinition="-//Netscape Communications//DTD RSS 0.9//EN"; $this->dtdurl="http://my.netscape.com/publish/formats/rss-0.9.dtd"; break; case "0.91": $this->dtdtype="PUBLIC"; $this->dtddefinition="-//Netscape Communications//DTD RSS 0.91//EN"; $this->dtdurl="http://my.netscape.com/publish/formats/rss-0.91.dtd"; break; case "1.0": $this->dtdtype=""; break; default: $this->error="it was not specified a supported RSS specification version"; return 0; } return $this->write($output); } }; } ?> --- NEW FILE: config.inc.php --- <?php /** * Guestbook4phpCMS - a simple XML-guestbook with RSS-Feed * * <b>License</b> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @author Martin Jahn <mj...@us...> * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @copyright Copyright (c) 2004, Martin Jahn * @version $Id: config.inc.php,v 1.1 2004/07/29 03:47:19 mjahn Exp $ * @package guestbook4phpCMS **/ /* * $Log: config.inc.php,v $ * Revision 1.1 2004/07/29 03:47:19 mjahn * updated the header of the files * included GPL and README * */ /** * Set the path to the PEAR-repository * * You may insert the path to the directory with the necessary PEAR-packages. * This script needs the following PEAR-packages: * <ul> * <li>PEAR</li> * <li>XML_Serializer</li> * <li>XML_Parser</li> * <li>XML_Util</li> * <li>HTML_Common</li> * <li>HTML_BBCodeParser</li> * <li>HTML_QuickForm</li> * </ul> * * If you have not installed PEAR on your webserver, please download these packages * from http://pear.php.net/packages.php and put them into a sub-directory in this directory, * i.e. pear/. Then put the path to the directory into the following line, where * <ul> * <li><b>dirname (__FILE__)</b> is the directory of the actual file</li> * </ul> * * If you have installed the pear packages into the subdirectory pear/, you may not have to * change anything. **/ ini_set ('include_path', dirname(__FILE__).'/../pear/:'.ini_get ('include_path')); error_reporting (E_ALL); $CONFIG = array (); global $CONFIG; $CONFIG ['datafile'] = dirname(__FILE__).'/../guestbook.xml'; $CONFIG ['admin_mail'] = 'ma...@ma...'; $CONFIG ['admin_from'] = 'gae...@ma...'; $CONFIG ['rss-file'] = '/gaestebuch.xml'; $CONFIG ['rss-desc'] = 'Gästebuch'; $CONFIG ['rss-link'] = 'http://mjahn.homelinux.org/gaestebuch.xml'; $CONFIG ['rss-title'] = 'martin-jahn.info'; $CONFIG ['rss-xsl-web'] = 'http://martin-jahn.info/gaestebuch.xsl'; ?> --- NEW FILE: class.bbcode.php --- <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2003 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | li...@ph... so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Author: Stijn de Reede <sj...@gm...> | // +----------------------------------------------------------------------+ // // $Id: class.bbcode.php,v 1.1 2004/07/29 03:47:19 mjahn Exp $ // /** * @package HTML_BBCodeParser * @author Stijn de Reede <sj...@gm...> */ require_once('HTML/BBCodeParser.php'); class bbcode extends HTML_BBCodeParser { /** * An array of tags parsed by the engine * * @access private * @var array */ var $_definedTags = array( 'quote' => array('htmlopen' => 'q', 'htmlclose' => 'q', 'allowed' => 'all', 'attributes'=> array('quote' =>'cite=%2$s%1$s%2$s')), 'code' => array('htmlopen' => 'code', 'htmlclose' => 'code', 'allowed' => 'all', 'attributes'=> array()), 'b' => array( 'htmlopen' => 'strong', 'htmlclose' => 'strong', 'allowed' => 'all', 'attributes'=> array()), 'u' => array( 'htmlopen' => 'u', 'htmlclose' => 'u', 'allowed' => 'all', 'attributes'=> array()), 'url' => array( 'htmlopen' => 'a', 'htmlclose' => 'a', 'allowed' => 'none^img', 'attributes'=> array( 'url' => 'href=%2$s%1$s%2$s', 't' => 'target=%2$s%1$s%2$s') ) ); /** * Executes statements before the actual array building starts * * This method should be overwritten in a filter if you want to do * something before the parsing process starts. This can be useful to * allow certain short alternative tags which then can be converted into * proper tags with preg_replace() calls. * The main class walks through all the filters and and calls this * method if it exists. The filters should modify their private $_text * variable. * * @return none * @access private * @see $_text * @author Stijn de Reede <sj...@gm...> */ function _preparse() { $options = PEAR::getStaticProperty('HTML_BBCodeParser','_options'); $o = $options['open']; $c = $options['close']; $oe = $options['open_esc']; $ce = $options['close_esc']; $pattern = array( "!(^|\s|\()((((http(s?)|ftp)://)|www)[-a-z0-9.]+\.[a-z]{2,4}[^\s()]*)!i", "!".$oe."url(".$ce."|\s.*".$ce.")(.*)".$oe."/url".$ce."!iU"); $replace = array( "\\1".$o."url".$c."\\2".$o."/url".$c, $o."url=\\2\\1\\2".$o."/url".$c); $this->_preparsed = preg_replace($pattern, $replace, $this->_text); } } ?> |