Welcome to CMS13

Click here to setup the site for the first time.

'); } #################################################### #################################################### // this variable gives us the root level of whichever server we're on. So if the site system is being run from http://www.thing.net, then $sitelocation = http://www.thing.net - don't change this. $root = "http://".$_SERVER['SERVER_NAME']; // subfolder must be in the format "/subfolder" $subfolder = getXMLdata('setup.xml', 'subfolder'); $sitelocation = $root.$subfolder; #################################################### // prevent seesion IDs from screwing up the URL ini_set('session.use_trans_sid', false); // ensure php-written separators are XHTML valid ini_set('arg_separator.output', "&"); // remove hash to turn off error reporting # ini_set('display_errors','0'); #################################################### // get other required files require_once ("13/inc/markdown.php"); #require_once ("13/inc/classTextile.php"); #################################################### # # perform initiation and processing functions # #################################################### session_start(); // if login cookie is present, pass details to session variables as normal if (isset($_COOKIE['id'])) { $_SESSION['validusername'] = $_COOKIE['id']; $_SESSION['userlevel'] = $_COOKIE['level']; } #################################################### # fetch overall and site config details $configarray = getXML('config.xml'); // the getXML function produces a true reflection of the XML file // and we want to access the first level as an array, not an array within an array. $config = $configarray[config]; #################################################### # decide which page has been asked for $page = process_uri(); # now get stuff for that page $pageinfoarray = getXML($page); $page_info = $pageinfoarray[page]; #################################################### #################################################### // get all variables... foreach( $_REQUEST as $key => $value ){ $$key = $value; } foreach( $_SESSION as $skey => $svalue ){ $$skey = $svalue; } #################################################### # get contents of XML file and put it in an array, with keys function getXML($file) { $output = array(); $data = getcontents($file); $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0); xml_parse_into_struct($parser, $data, $values, $tags); xml_parser_free($parser); $hash_stack = array(); foreach ($values as $key => $val) { switch ($val['type']) { case 'open': array_push($hash_stack, $val['tag']); break; case 'close': array_pop($hash_stack); break; case 'complete': array_push($hash_stack, $val['tag']); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['value']}\";"); array_pop($hash_stack); break; } } return $output; } #################################################### # XHTML tag handling... so that it can be stored as XML # note that & goes FIRST so that subsequent encodings aren't screwed with. function encodeTags($code){ $encoded = ereg_replace('&', '&', $code); $encoded = ereg_replace('<', '<', $encoded); $encoded = ereg_replace('>', '>', $encoded); $encoded = ereg_replace('=', '=', $encoded); $encoded = ereg_replace("'", ''', $encoded); $encoded = ereg_replace('"', '"', $encoded); return ($encoded); } #################################################### # XHTML tag handling... so that it can be stored as XML function decodeTags($code){ $decoded = ereg_replace('<', '<', $code); $decoded = ereg_replace('>', '>', $decoded); return $encoded; } #################################################### # encoding difficult characters function EncodeEntities ( $string ) { $trans_tbl = array() ; #$trans_tbl[chr(34)] = '"' ; // quote $trans_tbl[chr(38)] = '&' ; // ampersand #$trans_tbl[chr(60)] = '<' ; // less-than #$trans_tbl[chr(62)] = '>' ; // more-than $trans_tbl[chr(128)] = '€' ; // euro $trans_tbl[chr(129)] = '€' ; // euro $trans_tbl[chr(130)] = '‚' ; // low quote $trans_tbl[chr(131)] = 'ƒ' ; // florin $trans_tbl[chr(132)] = '„' ; // double low quote $trans_tbl[chr(133)] = '…' ; // ellipsis $trans_tbl[chr(134)] = '†' ; // dagger $trans_tbl[chr(135)] = '‡' ; // double dagger $trans_tbl[chr(136)] = 'ˆ' ; // circumflex $trans_tbl[chr(137)] = '‰' ; // per thousand $trans_tbl[chr(138)] = 'Š' ; // S caron $trans_tbl[chr(139)] = '‹' ; // left angle quote $trans_tbl[chr(140)] = 'Œ' ; // OE ligature $trans_tbl[chr(142)] = 'Ž' ; // Z caron $trans_tbl[chr(145)] = '‘' ; // left single quote $trans_tbl[chr(146)] = '’' ; // right single quote $trans_tbl[chr(147)] = '“' ; // left double quote $trans_tbl[chr(148)] = '”' ; // right double quote $trans_tbl[chr(149)] = '•' ; // bullet $trans_tbl[chr(150)] = '–' ; // en dash $trans_tbl[chr(151)] = '—' ; // em dash $trans_tbl[chr(152)] = '˜' ; // small tilde $trans_tbl[chr(153)] = '™' ; // trademark $trans_tbl[chr(154)] = 'š' ; // small s caron $trans_tbl[chr(155)] = '›' ; // right angle quote $trans_tbl[chr(156)] = 'œ' ; // oe ligature $trans_tbl[chr(158)] = 'ž' ; // small z caron $trans_tbl[chr(159)] = 'Ÿ' ; // Y with diaeresis for ( $i=160; $i<=255; $i++ ) { $trans_tbl[chr($i)] = '&#' . $i . ';' ; } return strtr ( $string , $trans_tbl ) ; } #################################################### # security things // This function checks the current request uri, to make sure it's not too long // and therefore potentially full of shit. The default values are // for a max uri size of 50 chars, and if too big to redirect to google. function limit_uri($length = 75, $redirect = "http://www.google.com/"){ if( strlen($_SERVER['REQUEST_URI']) > $length ){ die("

Sorry

Not allowed, I'm afraid.

(error 1)

"); } } # this needs to be more clever... function prevent_view(){ if( strstr($_SERVER['REQUEST_URI'], 'setup.inc') ){ die("

Sorry

Not allowed, I'm afraid.

(error 2)

"); } } #################################################### # uri processing things // this code needs to check the URI and feed it to the page fetching functions // with necessary alternatives for certain circumstances... etc. function process_uri(){ global $debug, $subfolder, $config; limit_uri(); // security check #prevent_view(); // stop certain files from being accessed from browser #--------------------------------------------------- # 1. check to see if a file with that name really exists if(file_exists ($_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI']) and ($_SERVER['REQUEST_URI'] != "$subfolder/index.php") and ($_SERVER['REQUEST_URI'] != "$subfolder/") and ($_SERVER['REQUEST_URI'] != "$subfolder")){ $url=$_SERVER['REQUEST_URI']; #echo '

This is an actual file, not from the database

'; include($_SERVER['DOCUMENT_ROOT'].$url); exit; } #--------------------------------------------------- # 2. if not, check for content and get it $url=strip_tags($_SERVER['REQUEST_URI']); // need to rewrite this as a switch... construction. if ($debug){ echo "

processing uri: $url

"; } if ($url=="" || $url=="/" || $url=="/index.html" || $url=="$subfolder/index.html" || $url=="$subfolder/" || $url=="$subfolder" ){ $specific_page = $config[homepage]; return($specific_page); } elseif (strstr($url,"$subfolder/editor/?")) { $specific_page = "editor.xml"; return($specific_page); } elseif (strstr($url,"$subfolder/modify/?")) { $specific_page = "modify.xml"; return($specific_page); } elseif ($url=="/add") { $specific_page = "add.xml"; return($specific_page); } elseif (strstr($url,"$subfolder/prefs")) { $specific_page = "prefs.xml"; return($specific_page); } elseif (strstr($url,"$subfolder/login")) { $specific_page = "login.xml"; return($specific_page); } elseif (strstr($url,"$subfolder/resources")) { $specific_page = "resources.xml"; return($specific_page); } elseif (strstr($url,"$subfolder/userpass")) { $specific_page = "userpass.xml"; return($specific_page); } elseif (strstr($url,"$subfolder/upload")) { $specific_page = "upload.xml"; return($specific_page); } elseif (strstr($url,"$subfolder/help")) { $specific_page = "help.xml"; return($specific_page); } elseif (checkForPage($url) != "nope"){ // the page request isn't one of the system pages // and the page request does match something in the datastore #print_r (checkForPage($url_array[$n])); $getpage = checkForPage($url); $thepage = $url; return $getpage[$thepage]; } else { $result='404.xml'; return $result; } } ############################################################ # function to draw dynamic body tag function bodytag(){ global $page_info; $body_id = str_replace(" ", "", strtolower($page_info[title])); echo ""; } ############################################################ # function to insert code, for example for editor and login function insertCode($page){ $codecheck = getXMLData($page, "code"); if ($codecheck != ""){ ob_start(); $code = getXMLData($page, "code"); @include_once ($code); $buffer = ob_get_contents(); ob_end_clean(); print $buffer; } } ############################################################ # function to check for page existance... function checkForPage($filename){ global $datastore; global $subfolder; $files = dirList($datastore); // process foreach ($files as $file){ $thispagearray = getXML($file); $thispage = $thispagearray[page]; $pname = $thispage[pagename]; $name = $thispage[name]; $title = $thispage[title]; $type = $thispage[type]; $archive_date = $thispage[archive_date]; $archiveitem = strftime("/%G/%m",$archive_date).'/'.$pname; #$archiveitem = $subfolder.$archiveitem; // check to see if published $pub = $thispage[publish]; // unpublished pages CANNOT be displayed if($pub == "on"){ if($filename == $name){ $result = array($filename => $file); break; } elseif( $type == "alog" || $type == "qlog" ){ if ($filename == $archiveitem){ $result = array($filename => $file); break; } } else { $result = "nope"; } } } #print_r ($result); return $result; } ############################################################ # function to exclude atomz. call function above and below code to be excluded, with # variable 'start' and 'stop' to add the necessary bits # function xatomz($mode) { if($mode=='start') { #echo ''; if ($HTTP_USER_AGENT == "Atomz/1.0") { echo ""; } } else { #echo ''; if ($HTTP_USER_AGENT == "Atomz/1.0") { echo ""; } } } ############################################################ # function to get directory listing # function dirList($folder){ //Load Directory Into Array $handle=opendir($folder) or die ("Can't open $folder: $php_errormsg"); while ($item = readdir($handle)) if ( !strstr($item, '.trash') && $item != "notverysecurepasswordfile.inc" && $item != ".DS_Store" && $item != ".htaccess" && $item != "." && $item != ".." ){ $files[] = $item; } //Clean up closedir($handle); return $files; } ############################################################ # function to get an array containing the directories in a certain place... # function pagelist($folder){ //Load Directory Into Array $files = dirList($folder); // process foreach ($files as $file){ // check to see if protected, and if so, don't show if ( # getXMLData($file, 'title') != 'Main Preferences' getXMLData($file, 'protected') != 'on' ){ /*$fields = array( 'id', 'parent', 'type', 'archive_date', 'title', 'sort', 'name', 'publish', 'menu', 'protected', 'locked', 'excerpt' );*/ $filelistarray = getXML($file); $filelist[] = $filelistarray[page]; } } return $filelist; } ############################################################ # function to count number of files. # function filecount(){ global $datastore; //Load Directory Into Array - special version which only picks up unprotected files... $handle=opendir($datastore) or die ("Can't open $datastore: $php_errormsg"); while ($item = readdir($handle)) if ( !strstr($item, '.trash') && $item != "notverysecurepasswordfile.inc" && $item != ".DS_Store" && $item != ".htaccess" && $item != "." && $item != ".." && getXMLData("$item", 'protected') != 'on' && getXMLData("$item", 'name') != '404' && getXMLData("$item", 'name') != 'help' ){ $files[] = $item; #echo $item; } //Clean up closedir($handle); // process $filecount = count($files); return $filecount; } ############################################################ # function to sort out which pages to display # function filter($menuitems){ foreach ($menuitems as $file => $info){ if ( $info[menu] == "on" && $info[publish] == "on" && $info[type] != "alog" && $info[type] != "qlog" ){ $filtered[] = $info; } } return $filtered; } ############################################################ # function to get only the archive pages # function editfilter($menuitems){ foreach ($menuitems as $file => $info){ if ( $info[type] != "alog" && $info[type] != "qlog" ){ $editfiltered[] = $info; } } return $editfiltered; } ############################################################ # function to get only the archive pages # function archivefilter($menuitems){ foreach ($menuitems as $file => $info){ if ( $info[type] == "alog" || $info[type] == "qlog" ){ $archivefiltered[] = $info; } } return $archivefiltered; } ############################################################ # function to sort out and draw menu # function makepath($page){ # ------------------------------------------- # start tracking page lineages $n=0; $lineage[$n] = $page[parent]; while ($lineage[$n] > 0){ $work = lookupName($lineage[$n]); $n++; $lineage[$n] = getXMLData($work, 'parent'); } $lineage = array_reverse($lineage); # reset path, otherwise we get section1/section1/section1 etc. unset($path); unset($itemdepth); # build up URL foreach ($lineage as $ancestor){ $par = lookupParent($ancestor); if(!empty($par)){ $pararray = explode('/', $par); $justname = array_pop($pararray); $par = $justname; if ($par == ''){ $path = ''; } else { $path .= "$par/"; } $itemdepth++; } } #if($path==''){ $path ='/'; } #echo $path; return $path; } ############################################################ # function to sort out and draw menu # function menu($folder, $mode='open', $parent=0, $level=0, $id='menu', $editmode='off'){ global $page, $debug; if (strstr($_SERVER['REQUEST_URI'], 'editor')){ $mode = 'open'; } $files = pageList($folder); arraySort ($files, "sort"); # filtering is here to decide which files get shown when in the editor/dashbaord if ($editmode=='editmode'){ $files = editfilter($files); } elseif ($editmode=='archivemode'){ $files = archivefilter($files); arraySort ($files, "archive_date", "SORT_DESC"); } else { $files = filter($files); } if($level > 0){ $parent = getXMLData($page, 'id'); } # ------------------------------------------------- #echo count($files); #foreach ($files as $i => $menuitem){ for ($i = 0; $i <= count(pageList($folder)); $i++) { #echo $i; foreach ($files as $x => $menuitemcrosscheck){ $ans = ""; if ($menuitemcrosscheck[parent] == $i ){ $structure[$i][] = $menuitemcrosscheck; $ans = " *********"; } if ($debug) { echo 'looking at page id '.$menuitemcrosscheck[id].' (called '.$menuitemcrosscheck[title].') which has parent '.$menuitemcrosscheck[parent].' to see if the parent matches '.$i.$ans.'
'; } } } #echo '
';
#print_r($structure);
#echo '
'; foreach ($structure as $s => $sections){ $sectionsize[$s] = count($sections); } foreach ($sectionsize as $n => $section){ #echo "
in section $n : $sectionsize[$n]
"; } # ------------------------------------------------- // process if ($editmode == "archivemode") { $hidestatus = " class=\"togglehide\""; } else { $hidestatus = ""; } echo "\n"; } ############################################################ # function to draw menu function displayMenu($menuitems, $mode, $parent, $level, $sectionsize, $editmode){ // $menuitems is the array with pages and their data in // $parent is the level to start at: 0 is root level // $level is the level we are currently at while looping through... global $page, $subfolder; foreach ($menuitems as $s => $menuitem){ if (isset($_SESSION['validusername']) && $editmode != "editmode" && $editmode != "archivemode"){ #$mode='closed'; // prevent open menus during editing, but not in editmenu or archive } # ------------------------------------------- // indicate if a section has subitems if($sectionsize[$menuitem{id}] > 0) { $exp = " exp"; # additional class for expandable items } else { $exp = ""; } # ------------------------------------------- // add active status for list item tags // ie. if active *or within an active section* if (getXMLData($page, 'id') == $menuitem[id] || getXMLData($page, 'parent') == $menuitem[id] ){ $listatus = " class=\"on\""; } else { $listatus = ""; } # ------------------------------------------- if (getXMLData($page, 'id') == $menuitem[id] ){ // css-free active items - do we need BOTH? $stropen = ''; $strclose = ''; $astatus = " class=\"on$exp\""; } elseif(getXMLData($page, 'parent') == $menuitem[id]) { // active within sections $astatus = " class=\"on$exp\""; } else { // clear variables if not $stropen = ''; $strclose = ''; $astatus = " class=\"off$exp\""; } # ------------------------------------------- # ------------------------------------------- if($editmode == "editmode"){ // if in edit mode - indicate publish status // (instead of 'on' class) $astatus = ' class="p"'; $pstatus = 'published, and is set to appear in the menu'; if($menuitem[menu] != 'on') { $astatus = ' class="xm"'; $pstatus = 'published, but is not set to appear in the menu'; } elseif($menuitem[publish] != 'on') { $astatus = ' class="xp"'; $pstatus = 'not published, but is set to appear in the menu'; } if($menuitem[menu] != 'on' && $menuitem[publish] != 'on') { $astatus = ' class="xp"'; $pstatus = 'not published, and set not to appear in the menu'; } } # start drawing the menu if ($menuitem[parent] == $parent){ if ($level > 0 && $i == 0 ){ // first loop only echo ""; } } } } ############################################################ # function to check for page existance... # NB. location set to 's', which defeats the object of $datastore function lookup($title, $location='s'){ global $datastore; $files = dirList($datastore); // process foreach ($files as $file){ $name = getXMLData($file, 'name'); if($name == $title){ $result = array($title => $file); break; } else { $result = "nope"; } } # print_r ($result); return $result; } ############################################################ # function to check for page existance... # NB. location set to 's', which defeats the object of $datastore function lookupName($id, $location='s'){ global $datastore; $files = dirList($datastore); // process foreach ($files as $file){ $fileid = getXMLData($file, 'id'); if($fileid == $id){ $result = $file; break; } else { $result = "nope"; } } # print_r ($result); return $result; } ############################################################ # function to find parents function lookupID($pagename){ global $datastore; //Load Directory Into Array $files = dirList($datastore); // process foreach ($files as $file){ $name = getXMLData($file, 'name'); // check to see if published $pub = getXMLData($file, 'publish'); if( $pub == "on" && $name == $pagename){ $id = getXMLData($file, 'id'); } } return $id; } ############################################################ # function to find parents function lookupParent($pageid){ global $datastore; //Load Directory Into Array $files = dirList($datastore); // process foreach ($files as $file){ $id = getXMLData($file, 'id'); // check to see if published $pub = getXMLData($file, 'publish'); if( $pub == "on" && $id == $pageid){ $name = getXMLData($file, 'name'); } } return $name; } ############################################################ # function to grab the contents of a file for examimation... function getContents($thepage) { global $datastore; $filename = "$datastore/$thepage"; $handle = fopen ($filename, "r") or die ("Can't open $filename: $php_errormsg");; $contents = fread ($handle, filesize ($filename)); fclose ($handle); return $contents; } ############################################################ # function to grab xml tag data... function getXMLData($thepage, $taglist) { $contents = getContents($thepage); if (is_array($taglist)){ foreach($taglist as $tag){ $start = "<$tag>"; $end = ""; $data[$tag] = symbol_replace(stripslashes(get_string($contents, $start, $end))); // perform plugin transformations, but only on content, and not in editor or prefs #if( $tag == 'content' && # !strstr($_SERVER['REQUEST_URI'], 'editor') && # !strstr($_SERVER['REQUEST_URI'], 'prefs') # ){ # # $data[$tag] = transform($data[$tag]); # # } } } else { $tag= $taglist; $start = "<$tag>"; $end = ""; $data = symbol_replace(stripslashes(get_string($contents, $start, $end))); // perform plugin transformations, but only on content, and not in editor or prefs #if( $tag == 'content' && # !strstr($_SERVER['REQUEST_URI'], 'editor') && # !strstr($_SERVER['REQUEST_URI'], 'prefs') # ){ # # $data = transform($data); # # } } return $data; } ############################################################ # function to strip bits from a string - eg. to remove start # and end tags and read title function get_string($h, $s, $e) { $sp = strpos($h, $s, 0) + strlen($s); $ep = strpos($h, $e, 0); return substr($h, $sp, $ep-$sp); } ############################################################ # function to sort an array # function arraySort(&$array, $column=0, $order=SORT_ASC, $first=0, $last= -2) { // $array - the array to be sorted // $column - index (column) on which to sort // can be a string if using an associative array // $order - SORT_ASC (default) for ascending or SORT_DESC for descending // $first - start index (row) for partial array sort // $last - stop index (row) for partial array sort if($last == -2) $last = count($array) - 1; if($last > $first) { $alpha = $first; $omega = $last; $guess = $array[$alpha][$column]; while($omega >= $alpha) { if($order == SORT_ASC) { while($array[$alpha][$column] < $guess) $alpha++; while($array[$omega][$column] > $guess) $omega--; } else { while($array[$alpha][$column] > $guess) $alpha++; while($array[$omega][$column] < $guess) $omega--; } if($alpha > $omega) break; $temporary = $array[$alpha]; $array[$alpha++] = $array[$omega]; $array[$omega--] = $temporary; } arraySort ($array, $column, $order, $first, $omega); arraySort ($array, $column, $order, $alpha, $last); } } ############################################################ # Adds stuff to a data file. # function addData($filename, $data) { $check = implode('', $data); #$check = htmlspecialchars($check); #$check = stripslashes($check); if ($check == ""){ echo 'no data '; return false;} else { #$filename = $file.'.txt'; $fd = @fopen($filename, "w") or die ("Can't open $filename: $php_errormsg");; $dataLine = implode('|', $data)."\n"; fputs($fd, $dataLine); fclose($fd); return true; } } ############################################################ # Gets data from datafile # function getData($filename) { #$filename = $file.'.txt'; $file = @file($filename); # reads the datafile into an array called $file if ($file) { foreach ($file as $line) { $line = stripslashes($line); $output = explode('|', $line); $data = $output; } return $data; } else { echo "

problem reading from $filename

";} } ############################################################ # Gets sensible filesize info # function getFilesize($filename){ $type = Array ('bytes', 'KB', 'MB', 'GB'); $filesize = filesize ($filename); for ($i = 0; $filesize > 1024; $i++) $filesize /= 1024; return round ($filesize, 2)." $type[$i]"; } ############################################################ # content transformations, based on plugins found in the plugins folder. # # plugins must be named identically to the single function they contain. function transform($data) { // check to see if if(getXMLData('config.xml', 'plugins') == "on"){ //Load Directory Into Array $plugins = dirList('13/plugins'); foreach($plugins as $plugin){ $plugin = str_replace('.plugin', '', $plugin); @require_once ("13/plugins/$plugin.plugin"); $data = $plugin($data); } } return $data; } #################################################### # replace out template placeholders function template($content){ global $version; global $config, $page_info; $replacement = array('copyright' => '© '.date ('Y'), 'contact' => "$config[site_owner]", 'cms13' => 'Powered by CMS13', 'XHTML' => 'XHTML', 'CSS' => 'CSS', 'AAA' => 'AAA', 'validity' => '', 'lastmod' => time_since($page_info[last_mod]), '-' => ' | ' ); $this_position = true; // as long as we keep finding placeholders, keep going while($this_position != false){ // find first occurence of tag after $position $this_position = strpos($content, "{{", $position); // if we get one... if ($this_position){ // find corresponding close tag $stop_position = strpos($content, "}}", $this_position); // find distance bertween them... $l = $stop_position - $this_position; $l = $l - 2; // get the title itelf (only) $placeholder = substr($content, $this_position+2, $l); #// put the title into an array #$placeholders[$i] = $placeholder; // put in the $toc_id as an id $content = substr_replace($content, $replacement[$placeholder], $this_position , $l+4); // get ready for next loop... $position = $this_position; $i++; } } return $content; } #################################################### # convert strange characters function symbol_replace($text){ //$text = ereg_replace(";", ";", $text); $text = ereg_replace('%', '%', $text); $text = ereg_replace('', 'ü', $text); $text = ereg_replace('', 'ï', $text); $text = ereg_replace('', 'ë', $text); $text = ereg_replace('', 'à', $text); $text = ereg_replace('', 'é', $text); $text = ereg_replace('', 'è', $text); $text = ereg_replace('', 'ç', $text); #$text = ereg_replace("'", "'", $text); $text = ereg_replace("", "€", $text); $text = ereg_replace("", "ê", $text); $text = ereg_replace('', 'œ', $text); $text = ereg_replace('', 'À', $text); $text = ereg_replace('', 'Æ', $text); $text = ereg_replace('', 'Ì', $text); $text = ereg_replace('', 'Ò', $text); $text = ereg_replace('', 'ä', $text); $text = ereg_replace('', 'ö', $text); $text = ereg_replace('', 'Á', $text); $text = ereg_replace('', 'Ç', $text); $text = ereg_replace('', 'Í', $text); $text = ereg_replace('', 'Ó', $text); $text = ereg_replace('', 'Ù', $text); $text = ereg_replace('', 'ß', $text); $text = ereg_replace('', 'Œ', $text); $text = ereg_replace('', 'Â', $text); $text = ereg_replace('', 'È', $text); $text = ereg_replace('', 'Î', $text); $text = ereg_replace('', 'Ô', $text); $text = ereg_replace('', 'Ú', $text); $text = ereg_replace('', 'æ', $text); $text = ereg_replace('', 'ì', $text); $text = ereg_replace('', 'ò', $text); $text = ereg_replace('', 'É', $text); $text = ereg_replace('', 'Ï', $text); $text = ereg_replace('', 'Û', $text); $text = ereg_replace('', 'á', $text); $text = ereg_replace('', 'í', $text); $text = ereg_replace('', 'ó', $text); $text = ereg_replace('', 'ù', $text); $text = ereg_replace('', 'Ä', $text); $text = ereg_replace('', 'Ê', $text); $text = ereg_replace('', 'Ö', $text); $text = ereg_replace('', 'Ü', $text); $text = ereg_replace('', 'â', $text); $text = ereg_replace('', 'î', $text); $text = ereg_replace('', 'ô', $text); $text = ereg_replace('', 'ú', $text); $text = ereg_replace('', 'Ë', $text); $text = ereg_replace('', 'û', $text); // this must be with spaces around so that & are not replaced in codes... $text = ereg_replace(' & ', ' & ', $text); return $text; } ############################################################ # Chop a string into a smaller string. /* * @author Aidan Lister * @version 1.1 * @param mixed $string The string you want to shorten * @param int $length The length you want to shorten the string to * @param bool $center If true, chop in the middle of the string * @param mixed $append String appended if it is shortened */ function str_chop($string, $length = 13, $center = false, $append = null) { // Set the default append string if ($append === null) { $append = ($center === true) ? '... ' : '...'; } // Get some measurements $len_string = strlen($string); $len_append = strlen($append); // If the string is longer than the maximum length, we need to chop it if ($len_string > $length) { // Check if we want to chop it in half if ($center === true) { // Get the lengths of each segment $len_start = $length / 2; $len_end = $len_start - $len_append; // Get each segment $seg_start = substr($string, 0, $len_start); $seg_end = substr($string, $len_string - $len_end, $len_end); // Stick them together $string = $seg_start . $append . $seg_end; } else { // Otherwise, just chop the end off $string = substr($string, 0, $length - $len_append) . $append; } } return $string; } ################################################# # time since function # from http://www.1976design.com/blog/archive/2004/07/23/redesign-time-presentation/ // adapted from original code by Natalie Downe // http://blog.natbat.co.uk/archive/2003/Jun/14/time_since // inputs must be unix timestamp (seconds) // $newer_date variable is optional function time_since($older_date, $newer_date = false) { // array of time period chunks $chunks = array( array(60 * 60 * 24 * 365 , 'year'), array(60 * 60 * 24 * 30 , 'month'), array(60 * 60 * 24 * 7, 'week'), array(60 * 60 * 24 , 'day'), array(60 * 60 , 'hour'), array(60 , 'minute'), ); // $newer_date will equal false if we want to know the time elapsed between a date and the current time // $newer_date will have a value if we want to work out time elapsed between two known dates $newer_date = ($newer_date == false) ? time() : $newer_date; // difference in seconds $since = $newer_date - $older_date; // we only want to output two chunks of time here, eg: // x years, xx months // x days, xx hours // so there's only two bits of calculation below: // step one: the first chunk for ($i = 0, $j = count($chunks); $i < $j; $i++) { $seconds = $chunks[$i][0]; $name = $chunks[$i][1]; // finding the biggest chunk (if the chunk fits, break) if (($count = floor($since / $seconds)) != 0) { break; } } // set output var $output = ($count == 1) ? '1 '.$name : "$count {$name}s"; // step two: the second chunk if ($i + 1 < $j) { $seconds2 = $chunks[$i + 1][0]; $name2 = $chunks[$i + 1][1]; if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0) { // add to output var $output .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s"; } } return $output; } ?> <? echo "$config[site_title] • $page_info[title]"; ?> " /> \r"; } ?>

'; print $config[page_ahem]; ######################### echo '
'; } ?>
\n"; echo $config[stats_code]; echo "\n
\n\n"; } # -------------------------------------------------------------------- ?>
'; if ($config[search_show] == "on"){ require_once ("13/inc/search.php"); } if ($config[submenu_show] == "on"){ require_once ("13/inc/submenu.php"); } echo ''; } # -------------------------------------------------------------------- ?>

login