From e7e54aa96806d55204812f9e6ca5fa06e2943fa2 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Sat, 28 Nov 2009 13:47:25 -0500 Subject: Organized blog module Previously, welcome.php was always loaded if no module was specified. Because of this, the index page blog section was there, while the rest of the blog code (plus archive code) was in blog.php. Now, the all of the blog is in blog.php and all of the archive is in archive.php. --- .htaccess | 8 ++-- includes/functions.php | 11 ++++-- index.php | 2 +- pages/archive.php | 99 ++++++++++++++++++++++++++++++++++++++++++++++ pages/blog.php | 105 ++++++++++++++++++++++++------------------------- pages/welcome.php | 105 ------------------------------------------------- 6 files changed, 164 insertions(+), 166 deletions(-) create mode 100644 pages/archive.php delete mode 100755 pages/welcome.php diff --git a/.htaccess b/.htaccess index 1d64272..7304983 100755 --- a/.htaccess +++ b/.htaccess @@ -7,9 +7,11 @@ RewriteEngine On RewriteCond %{HTTP_HOST} ^www.fourisland.com [NC] RewriteRule ^(.*)$ http://fourisland.com/$1 [R=301,NC,L] -RewriteRule ^blog/$ /index.php?area=blog [QSA,L] -RewriteRule ^blog/author/(.+).php /index.php?area=blog&author=$1 [QSA,L] -RewriteRule ^blog/tag/(.+).php /index.php?area=blog&tag=$1 [QSA,L] +RewriteRule ^blog/$ /index.php?area=archive [QSA,L] +RewriteRule ^blog/author/(.+).php /index.php?area=archive&author=$1 [QSA,L] +RewriteRule ^blog/tag/(.+).php /index.php?area=archive&tag=$1 [QSA,L] + +RewriteRule ^$ /index.php?area=blog [QSA,L] RewriteRule ^blog/(.+)/ /index.php?area=blog&post=$1 [QSA,L] RewriteRule ^wiki/$ /wiki/Main_Page [QSA] diff --git a/includes/functions.php b/includes/functions.php index dc5a549..efb3c13 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -398,6 +398,14 @@ function getRewriteURL() } } else { if ($_GET['area'] == 'blog') + { + if (isset($_GET['post'])) + { + return '/blog/' . $_GET['post'] . '/'; + } else { + return '/'; + } + } else if ($_GET['area'] == 'archive') { if (isset($_GET['author'])) { @@ -405,9 +413,6 @@ function getRewriteURL() } else if (isset($_GET['tag'])) { return '/blog/tag/' . $_GET['tag'] . '.php'; - } else if (isset($_GET['post'])) - { - return '/blog/' . $_GET['post'] . '/'; } else { return '/blog/'; } diff --git a/index.php b/index.php index 83cdd99..79fce10 100755 --- a/index.php +++ b/index.php @@ -34,7 +34,7 @@ if (strpos($_SERVER['REQUEST_URI'],'index.php')) ob_start(); -$pageName = isset($_GET['area']) ? $_GET['area'] : 'welcome'; +$pageName = basename($_GET['area']); if (file_exists('pages/' . $pageName . '.php')) { diff --git a/pages/archive.php b/pages/archive.php new file mode 100644 index 0000000..39a9fa7 --- /dev/null +++ b/pages/archive.php @@ -0,0 +1,99 @@ +add('HEADER', 'Posts by ' . $_GET['author']); + $getposts = "SELECT * FROM updates AS u WHERE author = \"" . $_GET['author'] . "\" ORDER BY id DESC"; + $getbio = "SELECT * FROM bio WHERE username = \"" . $_GET['author'] . "\""; + $getbio2 = mysql_query($getbio); + $getbio3 = mysql_fetch_array($getbio2); + if ($getbio3['username'] == $_GET['author']) + { + $template->adds_block('BIO', array( 'TEXT' => $getbio3['text'], + 'USERNAME' => $getbio3['username'], + 'DATE' => date('F jS Y \a\\t g:i:s a',strtotime($getbio3['lastUpdated'])))); + } +} elseif (isset($_GET['tag'])) +{ + $title = 'Tag: ' . $_GET['tag'] . ' - Blog Archive'; + $template->add('HEADER', 'Posts tagged with ' . $_GET['tag']); + $getposts = "SELECT * FROM updates AS u, tags AS t WHERE u.id = t.post_id AND t.post_type = \"published\" AND t.tag = \"" . $_GET['tag'] . "\" ORDER BY u.id DESC"; +} else { + $title = 'Blog Archive'; + $template->add('HEADER', 'Blog Archive'); + $getposts = "SELECT * FROM updates AS u ORDER BY id DESC"; +} +$getposts2 = mysql_query($getposts); +$i=0; +while ($getposts3[$i] = mysql_fetch_array($getposts2)) +{ + if ((!isset($lastmonth)) || ($lastmonth != date('m-Y',strtotime($getposts3[$i]['pubDate'])))) + { + if (!isset($curID)) + { + $curID = 0; + } else { + $curID++; + } + $template->add_ref($curID, 'MONTH', array('TITLE' => date('F Y',strtotime($getposts3[$i]['pubDate'])))); + $lastmonth = date('m-Y',strtotime($getposts3[$i]['pubDate'])); + } + + $page_id = 'updates-' . $getposts3[$i]['id']; + $getcomments = "SELECT * FROM comments WHERE page_id = \"" . $page_id . "\" ORDER BY posttime"; + $getcomments2 = mysql_query($getcomments); + $total_post=0; + while ($getcomments3[$total_post] = mysql_fetch_array($getcomments2)) + { + $total_post++; + } + if ($total_post >= 2) + { + $plural = 's'; + } + if ($total_post == 0) + { + $comText = 'No Comments'; + } elseif ($total_post == 1) + { + $comText = '1 Comment'; + } else { + $comText = $total_post . ' Comments'; + } + + $template->adds_ref_sub($curID, 'SMALL',array( 'DATE' => date('m-d-Y',strtotime($getposts3[$i]['pubDate'])), + 'CODED' => $getposts3[$i]['slug'], + 'TITLE' => htmlentities($getposts3[$i]['title']))); + $i++; +} +if ($i==0) +{ + generateError('404'); +} +$template->display(); + +?> diff --git a/pages/blog.php b/pages/blog.php index a96edea..d4e95c1 100755 --- a/pages/blog.php +++ b/pages/blog.php @@ -25,14 +25,18 @@ require('headerproc.php'); $pageCategory = 'blog'; $pageAID = 'archive'; +$hatNav = array( array( 'title' => 'Archive', + 'url' => 'http://fourisland.com/blog/', + 'icon' => '16-file-archive')); + +$template = new FITemplate('post'); +$template->adds_block('INTERNAL',array('exi'=>1)); +$template->add('IFXAMP', $xhtml ? '&' : '&'); +$template->add('IFXLT', $xhtml ? '<' : '<'); +$template->add('IFXGT', $xhtml ? '>' : '>'); + if (isset($_GET['post'])) { - $template = new FITemplate('post'); - $template->adds_block('INTERNAL',array('exi'=>1)); - $template->add('IFXAMP', $xhtml ? '&' : '&'); - $template->add('IFXLT', $xhtml ? '<' : '<'); - $template->add('IFXGT', $xhtml ? '>' : '>'); - $getpost = "SELECT * FROM updates WHERE slug = \"" . urldecode($_GET['post']) . "\""; $getpost2 = mysql_query($getpost); $getpost3 = mysql_fetch_array($getpost2); @@ -122,48 +126,21 @@ if (isset($_GET['post'])) generateError('404'); } } else { - $template = new FITemplate('archive'); - if (isset($_GET['author'])) - { - $title = 'Author: ' . $_GET['author'] . ' - Blog Archive'; - $template->add('HEADER', 'Posts by ' . $_GET['author']); - $getposts = "SELECT * FROM updates AS u WHERE author = \"" . $_GET['author'] . "\" ORDER BY id DESC"; - $getbio = "SELECT * FROM bio WHERE username = \"" . $_GET['author'] . "\""; - $getbio2 = mysql_query($getbio); - $getbio3 = mysql_fetch_array($getbio2); - if ($getbio3['username'] == $_GET['author']) - { - $template->adds_block('BIO', array( 'TEXT' => $getbio3['text'], - 'USERNAME' => $getbio3['username'], - 'DATE' => date('F jS Y \a\\t g:i:s a',strtotime($getbio3['lastUpdated'])))); - } - } elseif (isset($_GET['tag'])) - { - $title = 'Tag: ' . $_GET['tag'] . ' - Blog Archive'; - $template->add('HEADER', 'Posts tagged with ' . $_GET['tag']); - $getposts = "SELECT * FROM updates AS u, tags AS t WHERE u.id = t.post_id AND t.post_type = \"published\" AND t.tag = \"" . $_GET['tag'] . "\" ORDER BY u.id DESC"; - } else { - $title = 'Blog Archive'; - $template->add('HEADER', 'Blog Archive'); - $getposts = "SELECT * FROM updates AS u ORDER BY id DESC"; - } - $getposts2 = mysql_query($getposts); - $i=0; - while ($getposts3[$i] = mysql_fetch_array($getposts2)) + $curID = 0; + + $gettrack = "SELECT * FROM tracking WHERE ip = \"" . $_SERVER['REMOTE_ADDR'] . "\""; + $gettrack2 = mysql_query($gettrack); + $gettrack3 = mysql_fetch_array($gettrack2); + + $trackArr = explode(',',$gettrack3['rating']); + + $getpost = "SELECT * FROM updates ORDER BY id DESC LIMIT 0,4"; + $getpost2 = mysql_query($getpost); + while ($getpost3 = mysql_fetch_array($getpost2)) { - if ((!isset($lastmonth)) || ($lastmonth != date('m-Y',strtotime($getposts3[$i]['pubDate'])))) - { - if (!isset($curID)) - { - $curID = 0; - } else { - $curID++; - } - $template->add_ref($curID, 'MONTH', array('TITLE' => date('F Y',strtotime($getposts3[$i]['pubDate'])))); - $lastmonth = date('m-Y',strtotime($getposts3[$i]['pubDate'])); - } + updatePop($getpost3['id'],'home_views'); - $page_id = 'updates-' . $getposts3[$i]['id']; + $page_id = 'updates-' . $getpost3['id']; $getcomments = "SELECT * FROM comments WHERE page_id = \"" . $page_id . "\" ORDER BY posttime"; $getcomments2 = mysql_query($getcomments); $total_post=0; @@ -185,15 +162,35 @@ if (isset($_GET['post'])) $comText = $total_post . ' Comments'; } - $template->adds_ref_sub($curID, 'SMALL',array( 'DATE' => date('m-d-Y',strtotime($getposts3[$i]['pubDate'])), - 'CODED' => $getposts3[$i]['slug'], - 'TITLE' => htmlentities($getposts3[$i]['title']))); - $i++; - } - if ($i==0) - { - generateError('404'); + $template->add_ref($curID, 'POST', array( 'ID' => $getpost3['id'], + 'YEARID' => ((date('Y',strtotime($getpost3['pubDate']))-2006) % 4), + 'DATE' => date('F jS Y \a\\t g:i:s a',strtotime($getpost3['pubDate'])), + 'MONTH' => date('M',strtotime($getpost3['pubDate'])), + 'DAY' => date('d',strtotime($getpost3['pubDate'])), + 'CODED' => $getpost3['slug'], + 'TITLE' => htmlentities(stripslashes($getpost3['title'])), + 'AUTHOR' => $getpost3['author'], + 'PLURALCOMMENT' => (isset($plural) ? $plural : ''), + 'COMMENTS' => $comText, + 'RATING' => $getpost3['rating'], + 'TEXT' => parseText(stripslashes($getpost3['text'])))); + + $tags = getTags($getpost3['id']); + foreach ($tags as $tag) + { + $template->adds_ref_sub($curID, 'TAGS', array('TAG' => $tag)); + } + + if (($gettrack3['ip'] != $_SERVER['REMOTE_ADDR']) || (array_search($getpost3['id'],$trackArr) === FALSE)) + { + $template->adds_ref_sub($curID, 'CANVOTE', array('exi'=>1)); + } else { + $template->adds_ref_sub($curID, 'NOVOTE', array('exi'=>1)); + } + + $curID++; } + $template->display(); } diff --git a/pages/welcome.php b/pages/welcome.php deleted file mode 100755 index 819420b..0000000 --- a/pages/welcome.php +++ /dev/null @@ -1,105 +0,0 @@ - 'Archive', - 'url' => 'http://fourisland.com/blog/', - 'icon' => '16-file-archive')); - - -$template = new FITemplate('post'); -$template->adds_block('EXTERNAL',array('exi'=>1)); -$template->add('IFXAMP', $xhtml ? '&' : '&'); -$template->add('IFXLT', $xhtml ? '<' : '<'); -$template->add('IFXGT', $xhtml ? '>' : '>'); - -$curID = 0; - -$gettrack = "SELECT * FROM tracking WHERE ip = \"" . $_SERVER['REMOTE_ADDR'] . "\""; -$gettrack2 = mysql_query($gettrack); -$gettrack3 = mysql_fetch_array($gettrack2); - -$trackArr = explode(',',$gettrack3['rating']); - -$getpost = "SELECT * FROM updates ORDER BY id DESC LIMIT 0,4"; -$getpost2 = mysql_query($getpost); -while ($getpost3 = mysql_fetch_array($getpost2)) -{ - updatePop($getpost3['id'],'home_views'); - - $page_id = 'updates-' . $getpost3['id']; - $getcomments = "SELECT * FROM comments WHERE page_id = \"" . $page_id . "\" ORDER BY posttime"; - $getcomments2 = mysql_query($getcomments); - $total_post=0; - while ($getcomments3[$total_post] = mysql_fetch_array($getcomments2)) - { - $total_post++; - } - if ($total_post >= 2) - { - $plural = 's'; - } - if ($total_post == 0) - { - $comText = 'No Comments'; - } elseif ($total_post == 1) - { - $comText = '1 Comment'; - } else { - $comText = $total_post . ' Comments'; - } - - $template->add_ref($curID, 'POST', array( 'ID' => $getpost3['id'], - 'YEARID' => ((date('Y',strtotime($getpost3['pubDate']))-2006) % 4), - 'DATE' => date('F jS Y \a\\t g:i:s a',strtotime($getpost3['pubDate'])), - 'MONTH' => date('M',strtotime($getpost3['pubDate'])), - 'DAY' => date('d',strtotime($getpost3['pubDate'])), - 'CODED' => $getpost3['slug'], - 'TITLE' => htmlentities(stripslashes($getpost3['title'])), - 'AUTHOR' => $getpost3['author'], - 'PLURALCOMMENT' => (isset($plural) ? $plural : ''), - 'COMMENTS' => $comText, - 'RATING' => $getpost3['rating'], - 'TEXT' => parseText(stripslashes($getpost3['text'])))); - - $tags = getTags($getpost3['id']); - foreach ($tags as $tag) - { - $template->adds_ref_sub($curID, 'TAGS', array('TAG' => $tag)); - } - - if (($gettrack3['ip'] != $_SERVER['REMOTE_ADDR']) || (array_search($getpost3['id'],$trackArr) === FALSE)) - { - $template->adds_ref_sub($curID, 'CANVOTE', array('exi'=>1)); - } else { - $template->adds_ref_sub($curID, 'NOVOTE', array('exi'=>1)); - } - - $curID++; -} - -$template->display(); - -?> -- cgit 1.4.1