title = "Unset Title"; $this->author = "Unset Author"; $this->chapter = "Unset Chapter"; $this->content = ""; $this->localnav = ""; $this->globalnav = ""; $this->pagenav = ""; $this->itemindex = array(); // Things on this page, menu array; $this->links = array(); $this->meta = array(); $this->debug = array(array(0,"Hello World")); } function build($content=0) { global $_EP; $this->debug[] = array(0, "Building"); #$out .= "\n" #$out = "\n" $out .= "\n" ."\n" ." {$_EP['book']} - ".ucwords($this->chapter)." - $this->title\n" ."\n" ."\n"; foreach ($this->meta as $meta){ $out .= " $value){ $out .= " ".$key."=\"".$value."\""; } $out .= ">\n"; } $out .= "\n"; foreach ($this->links as $link){ $out .= " $value){ $out .= " ".$key."=\"".$value."\""; } $out .= ">\n"; } $out .= "\n" ."\n"; if ($this->chapter != "") { $out .="chapter."\">\n"; } else { $out .="\n"; } $out .= "
\n"; /* ."
\n" ."
 
\n" ."
\n"; if (file_exists("assets/images/daily/logo.".$date.".png")) { $out .= "\"Aquarionics\"
"; } else { $out .= "\"Aquarionics\"
"; } */ $out .= "
\n"; if (file_exists("assets/aq7/logo/logo.".$date.".png")) { $pic .= "\"Aquarionics\""; } elseif (file_exists("assets/aq7/logo/logo.".$this->chapter.".png")) { $pic .= "\"Aquarionics\""; } else { $pic .= "\"Aquarionics\""; #$out .= "\"Aquarionics\""; } $out .= "$pic"; #Aquarionics $globalmenu = array( array ('name' => "About", "link" => "/article/name/about", "title" => "What is this, anyway?"), # array ('name' => "FAQ", "link" => "/article/name/faq", "title" => "Questions Seldom Asked"), array ('name' => "Archive", "link" => "/archive", "title" => "Archived Futility"), array ('name' => "Contact", "link" => "/article/name/contact", "title" => "Speak!"), array ('name' => "Search", "link" => "/search", "title" => "Find!"), array ('name' => "Syndicate", "link" => "/meta", "title" => "Data about data") ); $out .= $this->menu($globalmenu,"tabmenu mainmenu globalmenu"); $out .= "\n" ."
\n"; if (count($this->itemindex) > 1){ $nav .= "
\n" . $this->subheading("Index") ." \n" . $this->menu($this->itemindex, "itemindex") ."\n
\n\n\n"; } if ($this->localnav != "") { $nav .= "
\n" .$this->localnav ."\n" ."
\n\n" ; } //if ($this->pagenav != "") { // $nav .= "
\n" // .$this->pagenav ."\n" // ."
\n\n" ; //} if ($nav != "") { $out .= "
\n"; $out .= $nav; $out .= "
\n\n"; } $out .="
\n" .$this->content."\n
\n
"; $out .= "
".$this->smallprint."
\n" ."\n" ."\n" .""; return $out; } /** void function (void) Short description. */ function newObject($file, $mimetype, $description, $size) { $out = "\n"; foreach ($items as $item){ if($i == 0) {$liclass = " class=\"first\"";} elseif($i == $total) {$liclass = " class=\"last\"";} else {$liclass = "";} $out .= "\t".$item[0]."\n"; $out .= "\t".$item[1]."\n"; } $out .= "\n"; return $out; } function buildlist($items,$ordered = false,$class="", $id=""){ //Menu, Takes an array of items: // array("name" -> "Display Name", "link" -> "Display link" [, "title" => "Tooltip Text"] // and displays it as a list, with associated class. All the magic to put the brackets and // pipes in is now in CSS, as it should be. See either the stylesheets, or // for details. unset($item); if (count($items) == 0) { return ""; } $total = count($items) -1; $i=0; $first = true; $out = ""; if ($class != ""){$ulclass = " class=\"$class\"";}# else { $ulclass = " class=\"pipe\"";} if ($id != ""){$ulid = " id=\"$id\"";}; $out .= "\n"; foreach ($items as $item){ if($i == 0) {$liclass = " class=\"first\"";} elseif($i == $total) {$liclass = " class=\"last\"";} else {$liclass = "";} $out .= "\t".$item."\n"; $i++ ; } $out .= " \n"; return $out; } function menu($items,$class="", $id=""){ //Menu, Takes an array of items: // array("name" -> "Display Name", "link" -> "Display link" [, "title" => "Tooltip Text"] // and displays it as a list, with associated class. All the magic to put the brackets and // pipes in is now in CSS, as it should be. See either the stylesheets, or // for details. unset($item); $total = count($items) -1; $i=0; $first = true; $out = ""; if ($class != ""){$ulclass = " class=\"$class\"";}# else { $ulclass = " class=\"pipe\"";} if ($id != ""){$ulid = " id=\"$id\"";}; $out .= "\n"; foreach ($items as $item){ if($i == 0) {$liclass = " class=\"first\"";} elseif($i == $total) {$liclass = " class=\"last\"";} else {$liclass = "";} $out .= "\t\n"; $i++ ; } $out .= " \n"; return $out; } function item($content=0, $id=false) { if ($id){ return "
\n$content\n
\n"; } else { return "
\n$content\n
\n"; } } function mainmenu($items) { return $this->menu($items,"pipe")."\n"; } function heading($content=0) { return "$content\n"; } function subheading($content=0) { return "

$content

\n"; } function subsubheading($content=0) { return "

$content

\n"; } function itemheader($content=0, $type) { return "

$content

\n"; } function itemdate($content=0) { preg_match("/([0-9]*)\-([0-9]*)\-([0-9]*)\ (.*)/",$content, $d); $out = $this->ulink("/archive/".$d[1], $d[1], "Archive of ".$d[1])."-" .$this->ulink("/archive/".$d[1]."/".$d[2], $d[2], "Archive of ".$d[1]."/".$d[2])."-" .$this->ulink("/archive/".$d[1]."/".$d[2]."/".$d[3], $d[3], "Archive of ".$d[1]."/".$d[2]."/".$d[3]) ." ".$d[4]; return "
$out
\n"; } function ulink($href, $content, $title=false) { if ($title){ $title = " title=\"".$title."\""; } return "
".$content.""; } function image($location, $alt, $height=false, $width=false) { if (file_exists($location)){ $stats = getimagesize($location); if (!$height){ $height = $stats[1]; } if (!$width){ $width = $stats[0]; } } if ($width && $height){ return "\"$alt\""; } else { return "\"$alt\""; } } function forwardto($url, $delay = 0) { return "\n"; } function href($name,$url,$title="",$class="") { $link = ""; return $link; } function comment_box($content, $id=false){ if ($id){ return "
\n$content\n
\n"; } else { return "
\n$content\n
\n"; } } function comment_display($comment, $preview=false){ #url, author, id, content, date_created if ($comment['author'] == ""){ $comment['author'] = "A Nameless One"; } #url, author, id, content, date_created if ($comment['url'] != ""){ $name = "
".$comment['author'].""; } else { $name = $comment['author']; } $out = "".$name." ".$comment['date_created']."
"; $quote = comment_format($comment['content'], "clean"); $out .= $quote[0]."\n"; if ($preview){ $out .="[Reply]"; } else { $item = explode("-",$comment['thread_id']); $out .="[ # " ."| Reply ]"; } return $out; } function journal($array) { return $this->defaultshow($this,"journal","Journal Entries",$array); } function gallery($array) { global $_EP; if ($array['format'] == "readmore"){ $array['content'] = ulink(getPermalink("gallery", $array['id']), $array['description']); } else { $array['content'] = gallery($_EP['galleryRoot']."/".$array['directory'], getPermalink("gallery", $array['id'])); } $array['format'] = "html"; return $this->defaultshow($this,"gallery","Galleries",$array); } function article($array) { return $this->defaultshow($this,"article","Articles",$array); } function link($array) { return $this->defaultshow($this,"article","Articles",$array); } function writing($array) { return $this->defaultshow($this,"writing","Writings",$array); } function defaultshow($page,$type,$display,$array){ global $colours; if ($array['display'] != "single"){ $out .= $page->itemheader(ucwords($type) ." - ". $array['title'], $type); } $out .= $page->itemdate($array['date_created']); #/2003-01-08 14:52:07/ # $out .= preg_replace($array['date_created'], "([0,9]*)\-([0,9]*)\-([0,9]*)\ (.*)",$this->ulink("/archive/\1/\2/\3/") $array['content'] = process($array['content'], $array['format']); if (($array['display'] == "readmore" ) && isset($array['content'])){ $out .= break_string($array['content'],500); $out .= "[ ".$this->ulink(getPermalink($type, $array['id']), "Read More", "Read rest of this")." ]"; } else { $out .= $array['content']; } if ($array['update_timestamp'] != $array['timestamp'] && $array['update_timestamp'] != 0){ $out .= "
Last Modified: ".date("Y-m-d",$array['update_timestamp']); } if ($array['display'] != "readmore"){ $out .= getAttachments($page,$array['id'],$type); } $link = getPermalink($type,$array['id']); /* POSTPOST*/ if ($display != "temporary"){ $out .= "\n
\n
    \n " . "\t
  • ".$this->ulink($link, "#", "Permalink to ".$array['title'])."
  • \n" . "\t
  • ".$this->ulink("/comment?i=".$type."&id=".$array['id'], "Comment", "Comment on ".$array['title'])."
  • \n" . "\t
  • ".$this->ulink("/logging/referrals/".$type."-".$array['id'], "Referrals", "Pages linking to this one")."\n" . "\t
  • ".$page->ulink($_EP['url']."/trackback/".$type."/".$array['id'], "Trackback", "Trackback URL for this post")."
  • \n" . "\t
  • More ".$this->ulink("/".$type."/", $display, $display." front page.")."\n" . "\t
  • Filed under "; $cats = getCat($type,$array['id']); $nocats = count($cats) -1 ; for ($i = 0; $i <= $nocats; $i++) { $out .= "".ucwords($cats[$i]['name']).""; if ($i == $nocats - 1) { $out .= " & ";} elseif ($i != $nocats) { $out .= ", "; } } $out .= "
\n"; $out .= "
"; }; /* END POSTPOST */ /*$this->itemindex[] = array( "name" => $array['title']."[]", "link" => "#".$type."-".$array['id'] );*/ $return .= $page->item($out, $type."-".$array['id'], $array['title']); if ($array['display'] != "readmore"){ $return .= getQV($page,$array['id'],$type); $return .= getComments($page, $type."-".$array['id']); } return $return; } } class item { ##--------------+ #| Field | #+--------------+ #| id | #| title | #| date_created | #| date_edited | #| author | #| content | #+--------------# var $id; var $title; var $date_created; var $author; var $content; var $format; var $cats; var $fields; var $actions; var $filters; var $trackbacks; var $debug; function item($id=0) { global $_EP; #$this->cats = array(); $this->fields = array(); $this->trackbacks = array(); $this->id = 0; $this->date_created = "NOW()"; $this->date_edited = "NOW()"; $this->author = 0; $this->format = "html"; $this->status = "0"; $this->debug = array("Created ".get_class($this)." object"); $q = "select * from category"; $res = safequery($q, false); // don't panic on fail. while ($feline = mysql_fetch_assoc($res)){ $feline['oldstatus'] = false; $feline['newstatus'] = false; $this->cats[$feline['id']] = $feline; } if ($id != 0){ $this->loadData($id); } $fields = mysql_list_fields($_EP['dbname'], get_class($this)); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { $this->fields[] = array(mysql_field_name($fields, $i), mysql_field_type($fields, $i)); } $actions = array(); $filters = array(); $this->setActionsFilters(); } /** void function loadData (int id) Load the data from id $id into the object */ function loadData($id){ $this->debug[] = "Loading data from id ".$id; $res = safequery("select * from ".get_class($this)." where id = ".$id); $idexist = mysql_num_rows($res); if ($idexist != 0){ $row = mysql_fetch_assoc($res); foreach ($row as $key=>$value){ $this->$key = $value; } $cats = getCat(get_class($this),$id);//full version of all cats. foreach ($cats as $cat){ $this->cats[$cat['id']]['oldstatus'] = true; $this->cats[$cat['id']]['newstatus'] = true; } } else { // Attempt to get id broke. Table or ID doesn't exist $this->debug[] = "** Couldn't load ".get_class($this)."-".$id." from DB, object is empty."; return false; } } // end func load Data function setActionsFilters(){ $this->debug[] = "Set defaults for actions & filters"; $actions = array( array("pingback" => true), array("pingBloGs" => true), array("pingWeblogsCom" => true) ); $filters = array( array("html" => false), array("tagify" => true) ); } function validate(){ $this->debug[] = "Validating..."; $required = array("title", "author", "content"); foreach ($required as $check){ if ($this->$required != ""){ $error .= ucwords($required)." cannot be empty\n"; } } if (count($error) == 0){ $this->debug[] = "Validation sucessful"; return array(true,$error); } else { $this->debug[] = "Validation failed."; return array(false,$error); } } function save($notreally=false){ $this->debug[] = "Saving object to database"; $this->content = addslashes($this->doFilters(stripslashes($this->content))); $table = get_class($this); if (!$this->validate()){ return array(false,$error); } elseif($this->id != 0) { $this->debug[] = "ID set, creating update query"; $query = "update ".$table." set "; $index_check = count($this->fields)-1; $index_count = 0; foreach ($this->fields as $field){ if ($field[0] == "date_created" || $field[0] == "date_edited" || $field[0] == "id") { true; } else { if ($field[1] == "blob" || $field[1] == "string"){ $query .= $field[0]." = \"".$this->$field[0]."\""; } else { $query .= $field[0]." = ".$this->$field[0]; } if ($index_count != $index_check){ $query .= ", "; } } $index_count++; } $query .= " where id=".$this->id; $this->debug[] = "Build query: ".$query; if ($notreally){ $this->debug[] = "Not saved to DB, as requested"; $this->saveCats("notreally"); $return = $query; } else { $this->debug[] = "Saving to DB..."; safequery($query, false); $this->saveCats(); $delc_log = deleteCache($this->id,$table); $this->debug[] = "Deleting Cache Files"; foreach ($delc_log as $entry) { $this->debug[] = $entry; } $return = true; } } else { $this->debug[] = "ID not set, creating insert query"; $query = "insert into ".$table." ("; $fields = ""; $values = ""; $index_check = count($this->fields)-1; $index_count = 0; foreach ($this->fields as $field){ $fields .= $field[0]; if ($field[1] == "blob" || $field[1] == "string"){ $values .="\"".$this->$field[0]."\""; } else { $values .=$this->$field[0]; } if ($index_count != $index_check){ $fields .= ", "; $values .= ", "; } $index_count++; } $query .= $fields.") values (".$values.")"; $this->debug[] = "Created query ".$query; if ($notreally){ $this->debug[] = "Not saved to DB, as requested"; $return = $query."\n"; $return .= $this->saveCats("notreally"); } else { $this->debug[] = "Saving to DB..."; safequery($query, true); $this->id = mysql_insert_id(); $this->saveCats(); $this->doActions(); $delc_log = deleteCache($this->id,$table); foreach ($delc_log as $entry) { $this->debug[] = $entry; } } } return $return; } function saveCats($notreally=false){ $this->debug[] = "Saving categories to db..."; foreach($this->cats as $cat){ if ($cat['newstatus'] != $cat['oldstatus']){ if ($cat['newstatus']){ // if it's now categorised as that $query = "insert into cat_links (page_id, page_type, cat_id)" ." values (".$this->id.", \"".get_class($this)."\", ".$cat['id'].")"; $this->debug[] = "Added object to ".$cat['name']; } else { $query = "delete from cat_links where " ." page_type = \"".get_class($this)."\" and page_id = ".$this->id; $this->debug[] = "Deleted object from ".$cat['name']; } if ($notreally){ return $query; } else { safequery($query, false); } } } } function remove(){ $item = get_class($this); $id = $this->id; $queries = array( "delete from $item where id = $id", "delete from cat_links where page_type = \"$item\" and page_id = \"$id\"", "delete from attachment where page_type = \"$item\" and page_id = \"$id\"", "delete from crossreference where attachfromtype = \"$item\" and attachfromid = \"$id\"", "delete from crossreference where attachtotype = \"$item\" and attachtoid = \"$id\"", "delete from comment where thread_id = \"".$item."-".$id."\""); deleteCache($id,$item); foreach ($queries as $query){ safequery($query); } } function doFilters($content){ $this->debug[] = "Applying filters:"; if ($this->filters['htmlize'] == true) { $content = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","\\0", $content); $content = nl2br($content); } if ($this->filters['tagify'] == true) { $content = tagifythis($content); } return $content; } function doActions(){ global $_EP; $this->debug[] = "Doing actions:"; if ($this->actions['pingWeblogsCom'] == true) { $this->debug[] = "Pinging Weblogscom - ".date("H:i");; $client = new IXR_Client('http://rpc.weblogs.com/RPC2'); if (!$client->query("weblogUpdates.ping", $_EP['book'], $_EP['url'])) { echo('Something went wrong - '.$client->getErrorCode().' : '.$client->getErrorMessage()."
\n"); } } if ($this->actions['pingBloGs'] == true) { $this->debug[] = "Pinging blo.gs - ".date("H:i");; $client = new IXR_Client('http://ping.blo.gs/.'); if (!$client->query("weblogUpdates.ping", $_EP['book'], $_EP['url'], $_EP['url'], $_EP['url']."/meta/all.rss2")) { echo('Something went wrong - '.$client->getErrorCode().' : '.$client->getErrorMessage()."
"."weblogUpdates.ping: , ".$_EP['book'].", ".$_EP['url'].", ".$_EP['url'].", ".$_EP['url']."/meta/all.rss2\n"); } } if ($this->actions['pingBack']) { $this->debug[] = "Sending pingbacks - ".date("H:i"); $content = process($this->content, $this->format); $links = liftLinks(stripslashes($this->content)); pingback($links, get_class($this), $this->id, true); } $this->debug[] = "Done actions - ".date("H:i");; } } class journal extends item { } class article extends item { var $status; } class writing extends item { } /** Context of the class Short description. */ class syndication { var $title; var $url; var $description; var $author; var $email; var $items; /** void function syndication (void) Constructor for Syndication Class */ function syndication() { global $_EP; $this->title = $_EP['book']; $this->url = $_EP['url']; $this->description = "Descriptionless Item"; $this->author = "Aquarion"; $this->email = $_EP['admin']; $this->items = array(); } // end func /** void function (void) Short description. */ function build() { $out = "Syndication for ".$this->author." (".$this->email."), who stupidly asked for a syndication without a corresponding class.\n"; $out .= "Lets all laugh at ".$this->author.", shall we? and not read.".$this->title." at ".$this->url."\n"; return $out; } // end func } // end class /** Context of the class Short description. */ class rss2 extends syndication { /** string function build (void) Returns a valid RSS2 feed. */ function build() { global $_EP; $out ="\n" ."\n" ."\n" ."".$this->title."\n" ."".$this->url."\n" ."".$this->description."\n" ."en-gb\n" ."".$this->author." (".$this->email.")\n" ."Copyright ".date("Y")." ".$this->author."\n" ."".date("Y-m-d\TH:i:00O")."\n" ."\n" ."\n" ."daily\n" ."8\n" ."2000-01-01T12:00+00:00\n"; foreach ($this->items as $item){ # title url id content type timestamp $guid = getPermalink($item['epistulatype'],$item['id']); $trackback = $_EP['url']."/trackback/".$item['epistulatype']."/".$item['id']; $comments = count(get_comments_array($item['epistulatype']."-".$item['id'])); $categories = getCat($item['epistulatype'],$item['id']); $text = process($item['content'], $item['format']); $out .="\n" ."\t".$item['title']."\n" ."\t".$guid."\n" ."\t".$guid."\n" ."\t".htmlentities(break_string(strtr($text,"’","'"),400))."\n" ."\t".$guid."\n"; $out .= "\t\n" ."\t".date("Y-m-d\TH:i:00O",$item['timestamp'])."\n"; foreach ($categories as $cat){ $out .= "\t".$cat['name']."\n"; } foreach ($item['attachments'] as $attachment){ $out .= "\n"; } $out .="\t".$comments."\n" ."\t".$item['epistulatype']."\n" ."\t".$trackback."\n" ."\n"; } $out .= "\n" .""; return $out; } // end func } // end class /** Context of the class Short description. */ class rss extends syndication { /** void function build (void) Create and return RSS feed. */ function build() { global $_EP; $out ="\n" ."\n" ."\n" ."".$this->title."\n" ."".$this->url."\n" ."".$this->description."\n" ."en-gb\n" ."".$this->author." (".$this->email.")\n" ."Site Admin (".$_EP['admin'].")\n" ."".date("D, d M Y H:i:00 T")."\n" # Fri, 13 Apr 2001 19:23:02 GMT ."http://backend.userland.com/rss092\n"; foreach ($this->items as $item){ # title url id content type timestamp #$guid = $_EP['url']."/".$item['epistulatype']."/id/".$item['id']; $guid = getPermalink($item['epistulatype'],$item['id']); $text = process($item['content'], $item['format']); $out .="\n" ."\t".$item['title']."\n" ."\t".$guid."\n" ."\t".htmlspecialchars(break_string($text,400))."\n"; foreach ($item['attachments'] as $attachment){ $out .= "\n"; } $out .= "\n"; } $out .= "\n" .""; return $out; } // end func } // end class /** Context of the class Short description. */ class esf extends syndication { /** void function (void) Short description. */ function build() { global $_EP; $out ="#".$this->title." Newsfeed, in Episula Syndication Feed format (ESF)\n" ."#http://www.aquarionics.com/nodes/index.php?name=esf\n" ."title\t".$this->title."\n" ."contact\t".$this->author." (".$this->email.")\n" ."link\t".$this->url."\n\n"; foreach ($this->items as $item){ # title url id content type timestamp $guid = getPermalink($item['epistulatype'],$item['id']); $guid = $_EP['url']."/".$item['epistulatype']."/id/".$item['id']; $out .=$item['timestamp']."\t" .$item['title']."\t" .$guid."\t\n"; } return $out; } // end func } // end class /* // The great generic form creation thing. Started at 3am 10/01/2003 class form{ var $action; var $method; var $name; var $items; var $title; function form($name = "form",$method = "post" ,$action=$_SERVER['PHP_SELF']){ $this->name=$name; $this->method=$method; $this->action=$action; $this->action=array(); $this->title=false; } function buildHtml(){ // Buttons submit reset // Checkboxen label name checked r } }*/ /* Spelchecker server code by Simon Willison, http://simon.incutio.com/archive/2003/03/18/#phpAndJavascriptSpellChecker */ class SpellChecker { var $command; var $text; var $errors = array(); function SpellChecker($command = 'ispell') { $this->command = $command; } function check($text) { // Spell checks text, returns int number of errors found $this->text = $text; // Create temporary file, write text to that file // Important: First, ensure every line starts with ^ to avoid special ispell commands // see http://savannah.gnu.org/download/aspell/manual/user/6_Writing.html $text = '^'.implode("\n^", explode("\n", $text)); $tmp = tempnam('/tmp', 'spl'); $fp = fopen($tmp, 'w'); fwrite($fp, $text); fclose($fp); // Run the spell checking command, capture output $output = `{$this->command} -a < $tmp`; # print '
'; print($output); print '
'; // Delete the temporary file unlink($tmp); // Parse output and populate errors array $num_errors = preg_match_all('|^& (\w+) \d+ \d+: (.*?)$|m', $output, $matches); // This regexp picks up words for which ispell made no suggestions (different pattern) $extra_errors = preg_match_all('|^# (\w+)( ).*$|m', $output, $matches2); // Merge the arrays for ($i = 0; $i < $extra_errors; $i++) { $matches[0][] = $matches2[0][$i]; $matches[1][] = $matches2[1][$i]; $matches[2][] = $matches2[2][$i]; } $num_errors += $extra_errors; for ($i = 0; $i < $num_errors; $i++) { $word = $matches[1][$i]; // Check that word has not already been found as an error if (in_array($word, array_keys($this->errors))) { continue; } $suggestions = explode(', ', $matches[2][$i]); $this->errors[$word] = $suggestions; } return $num_errors; } function getErrors() { return $this->errors; /* errors is an array with the following structure: Array ( [speling] => Array ( [0] => spelling [1] => spewing [2] => spiling ) [twwo] => Array ( [0] => two ) ) */ } } ?>