X-Git-Url: https://disinclined.org/git/?a=blobdiff_plain;f=index.php;h=8cb1d62e4db4d149033f1e520d63d5f8ffbf8cfa;hb=61419ce10ec920aae29537f9bc0f8295d94baddf;hp=b29d6295d37b9e582fff279e77742f409b2911ae;hpb=8e2162275207d63fd73a335c9a16f62bf8e40a41;p=dylansserver.git diff --git a/index.php b/index.php index b29d629..8cb1d62 100644 --- a/index.php +++ b/index.php @@ -13,10 +13,10 @@ abstract class cms { public function __construct() { $config = parse_ini_file($this->config_file, true); $this->db = new mysqli( - $config[database]['domain'], - $config[database]['user'], - $config[database]['password'], - $config[database]['database']); + $config['database']['domain'], + $config['database']['user'], + $config['database']['password'], + $config['database']['database']); if (mysqli_connect_errno()) { echo "Problem connecting to database: "; echo mysqli_connect_error(); @@ -40,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'; } } @@ -91,7 +93,7 @@ abstract class cms { $scripts - +
"; $this->write_navigation(); @@ -318,8 +350,27 @@ class note extends cms { public $number_of_comments; public function __construct() { - if (isset($_GET['comments'])) { $this->scripts = " + + + + + + "; + + if (isset($_GET['comments'])) { + $this->scripts .= " "; } @@ -391,8 +442,8 @@ class note extends cms { // and a default author needs to be set // for no-javascript users. $stmt->bind_param('sss', - htmlspecialchars($_POST['name']), - htmlspecialchars($_POST['text']), + $_POST['name'], + $_POST['text'], $this->id); $stmt->execute(); } @@ -409,7 +460,7 @@ END_OF_NOTE; private function write_navigation() { echo << +



END_OF_NAVIGATION; @@ -447,7 +498,7 @@ END_OF_NAVIGATION; $date_posted = $entry['date_posted']; $author = $entry['author']; $text = htmlspecialchars($entry['text']); - $head = "

$author

"; + $head = "

" . htmlspecialchars($author) . "

"; echo << $head @@ -483,20 +534,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); @@ -614,6 +665,50 @@ class archive extends cms { } +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() { @@ -660,10 +755,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();