X-Git-Url: https://disinclined.org/git/?a=blobdiff_plain;f=index.php;h=e58f7372827636c539df32504df2a1c2b96925a0;hb=2cf7880d4afdde09707d4fc62e82597d6bfea7a0;hp=a2c85eacf2196dbc8b4a5e75f09efc72ed879b94;hpb=353b047dd912955763184787347927b58bd0e84f;p=dylansserver.git diff --git a/index.php b/index.php index a2c85ea..e58f737 100644 --- a/index.php +++ b/index.php @@ -6,6 +6,7 @@ abstract class cms { protected $db; protected $recaptcha_publickey; protected $recaptcha_privatekey; + protected $scripts; public $title; public $home_link; @@ -39,7 +40,9 @@ abstract class cms { return 'index'; } else if (isset($_GET['project'])) { return 'project'; - } else if (isset($_GET['challenge'])) { + } else if (isset($_GET['rss'])) { + return 'rss'; + } else if (isset($_GET['challenge'])) { return 'captcha'; } } @@ -71,17 +74,9 @@ abstract class cms { public function display_head($title = "dylansserver", $home_link = "/") { - $scripts = ""; + $scripts = $this->scripts; $stylesheets = ""; - if (cms::determine_type() == "index") { - $scripts = ""; - $home_link = "http://validator.w3.org/unicorn/check?ucn_uri=dylansserver.com&ucn_task=conformance#"; - } else if ($this->determine_type() == 'note') { - $scripts = ""; - $scripts .= ""; - $scripts .= ""; - $scripts .= ""; - } + $home_link = "http://validator.w3.org/unicorn/check?ucn_uri=dylansserver.com&ucn_task=conformance#"; echo << @@ -93,12 +88,12 @@ abstract class cms { $this->title - + $stylesheets $scripts - +
+END_NOTE; } echo "
"; $this->write_navigation(); @@ -294,7 +313,7 @@ class page extends cms { private function write_navigation() { echo ""; } @@ -324,6 +343,30 @@ class note extends cms { public $number_of_comments; public function __construct() { + $this->scripts = " + + + + + + "; + + if (isset($_GET['comments'])) { + $this->scripts .= " + + "; + } parent::__construct(); if (isset($_GET['comments'])) { $this->comments_enabled = true; @@ -402,7 +445,7 @@ class note extends cms { private function display_note() { echo << -

$this->year_posted/$this->month_posted/$this->day_posted/$this->title

+

$this->year_posted/$this->month_posted/$this->day_posted/$this->title

$this->text END_OF_NOTE; @@ -410,16 +453,16 @@ END_OF_NOTE; private function write_navigation() { echo << +



END_OF_NAVIGATION; } @@ -484,20 +527,20 @@ END_CAPTCHA_STYLE;
-

what's this say?

-

enter the numbers you hear:

- - ( another / - audio / - imagehelp ) - -

+
+

what's this say?

+
+
+


+




-
-
-
-



+

enter the numbers you hear:

+ + another? / + audio? / + image?help? +
END_OF_FORM; echo recaptcha_get_html($this->recaptcha_publickey); @@ -589,9 +632,9 @@ class archive extends cms { $datetime_posted = explode(' ', $date_posted[2]); $day_posted = $datetime_posted[0]; echo "
"; - echo "

"; + echo "

"; echo "$year_posted/$month_posted/$day_posted/"; - echo "$title

"; + echo "
$title

"; echo $entry['text']; echo "
"; } @@ -599,7 +642,7 @@ class archive extends cms { $this->write_navigation(); } else { echo "
"; - echo "

sorry, nothing here

"; + echo "

sorry, nothing here

"; echo "
Empty set (0.00 sec)
"; } $this->display_close(); @@ -608,15 +651,57 @@ class archive extends cms { private function write_navigation() { echo "
"; echo ""; } } +class rss extends cms { + public function display() { + $result = $this->db->query("SELECT date_posted, title, text, url + FROM notes ORDER BY date_posted DESC + LIMIT 5"); + echo << + + dylanstestserver.com/notes/rss + http://dylanstestserver.com/notes + dylanstestserver.com/notes/rss + +END_OF_ENTRY; + while ($entry = $result->fetch_object()) { + $title = $entry->title; + $date_posted = $entry->date_posted; + $url = "http://dylanstestserver.com/note/" . $entry->url; + $text = $entry->text; + $text = strip_tags($text); + $end_of_first_sentence = strpos($text, '.'); + if ($end_of_first_sentence) { + $end_of_second_sentence = strpos($text, '.', ($end_of_first_sentence + 1)); + if ($end_of_second_sentence) { + $description = substr($text, '0', ($end_of_second_sentence + 1)); + } else { + $description = substr($text, '0', ($end_of_first_sentence + 1)); + } + } + echo << + $title + $url + $url + $description + +END_OF_ENTRY; + } + echo ""; + echo ""; + + } +} + + class notFound extends Exception { public function __construct() { @@ -663,10 +748,13 @@ switch (cms::determine_type()) { $page = new page; $page->display(); break; + case "rss": + $rss = new rss(); + $rss->display(); case 'archive': $archive = new archive; - $archive->display(); - break; + $archive->display(); + break; case "captcha": $captcha = new captcha; $captcha->display();