From b5736e3ad3830fa732dcbd1a518ec3dd6ea7b98a Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Thu, 13 Aug 2009 17:46:09 -0400 Subject: Rewrote Admin panel The following database changes must be made: * A TEXT column called "text" must be added to the end of "polloftheweek" * The transferPollRss.php script must be run * The "pollrss" table must be dropped Closes #113 --- admin/comments.php | 143 ++++++++++++++++++++++++++++++++ admin/drafts.php | 100 ++++++++++++++++++++++ admin/editPoll.php | 118 ++++++++++++++++++++++++++ admin/editPost.php | 224 ++++++++++++++++++++++++++++++++++++++++++++++++++ admin/editQuote.php | 69 ++++++++++++++++ admin/maintenance.php | 61 ++++++++++++++ admin/modquotes.php | 136 ++++++++++++++++++++++++++++++ admin/newPoll.php | 104 +++++++++++++++++++++++ admin/newPost.php | 159 +++++++++++++++++++++++++++++++++++ admin/pending.php | 180 ++++++++++++++++++++++++++++++++++++++++ admin/polls.php | 98 ++++++++++++++++++++++ admin/posts.php | 100 ++++++++++++++++++++++ admin/quotes.php | 116 ++++++++++++++++++++++++++ admin/update.php | 36 ++++++++ admin/welcome.php | 71 ++++++++++++++++ 15 files changed, 1715 insertions(+) create mode 100644 admin/comments.php create mode 100644 admin/drafts.php create mode 100644 admin/editPoll.php create mode 100644 admin/editPost.php create mode 100644 admin/editQuote.php create mode 100644 admin/maintenance.php create mode 100644 admin/modquotes.php create mode 100644 admin/newPoll.php create mode 100644 admin/newPost.php create mode 100644 admin/pending.php create mode 100644 admin/polls.php create mode 100644 admin/posts.php create mode 100644 admin/quotes.php create mode 100644 admin/update.php create mode 100644 admin/welcome.php (limited to 'admin') diff --git a/admin/comments.php b/admin/comments.php new file mode 100644 index 0000000..4cda9ec --- /dev/null +++ b/admin/comments.php @@ -0,0 +1,143 @@ +adds_block('AVAIL',array('exi'=>1)); +} else { + $template->adds_block('NOTAVAIL',array('exi'=>1)); +} + +$pager = &Pager::factory(array( 'mode' => 'Sliding', + 'perPage' => 20, + 'delta' => 2, + 'itemData' => $getcomments3)); + +$j=0; + +foreach ($pager->getPageData() as $comment) +{ + if (!empty($comment)) + { + $template->adds_block('COMMENT', array( 'TEXT' => parseText($comment['comment']), + 'AUTHOR' => $comment['author'], + 'ID' => $comment['id'], + 'ODD' => ($j % 2 ? '' : ' class="odd"'))); + } + + $j++; +} + +$template->add('PAGEID', $pager->getCurrentPageID()); +$template->add('PAGINATION', $pager->links); + +$template->display(); + +?> diff --git a/admin/drafts.php b/admin/drafts.php new file mode 100644 index 0000000..22d8a09 --- /dev/null +++ b/admin/drafts.php @@ -0,0 +1,100 @@ +adds_block('AVAIL',array('exi'=>1)); +} else { + $template->adds_block('NOTAVAIL',array('exi'=>1)); +} + +$pager = &Pager::factory(array( 'mode' => 'Sliding', + 'perPage' => 20, + 'delta' => 2, + 'itemData' => $getposts3)); + +$j=0; + +foreach ($pager->getPageData() as $post) +{ + if (!empty($post)) + { + $template->adds_block('POST', array( 'TITLE' => $post['title'], + 'AUTHOR' => $post['author'], + 'ID' => $post['id'], + 'CODED' => $post['slug'], + 'ODD' => ($j % 2 ? '' : ' class="odd"'))); + } + + $j++; +} + +$template->add('PAGEID', $pager->getCurrentPageID()); +$template->add('PAGINATION', $pager->links); + +$template->display(); + +?> diff --git a/admin/editPoll.php b/admin/editPoll.php new file mode 100644 index 0000000..3a154a3 --- /dev/null +++ b/admin/editPoll.php @@ -0,0 +1,118 @@ +add('TITLE', 'Edit Poll'); +$template->add('ACTION', '/admin/editPoll.php?id=' . $_GET['id'] . '&submit='); + +if (isset($_GET['submit'])) +{ + if (empty($_POST['question'])) + { + $errors[] = array( 'field' => 'question', + 'text' => 'Question is a required field'); + } + + if (empty($_POST['option1'])) + { + $errors[] = array( 'field' => 'option1', + 'text' => 'Option 1 is a required field'); + } + + if (empty($_POST['option2'])) + { + $errors[] = array( 'field' => 'option2', + 'text' => 'Option 2 is a required field'); + } + + if (empty($_POST['option3'])) + { + $errors[] = array( 'field' => 'option3', + 'text' => 'Option 3 is a required field'); + } + + if (empty($_POST['option4'])) + { + $errors[] = array( 'field' => 'option4', + 'text' => 'Option 4 is a required field'); + } + + if (isset($errors)) + { + $template->adds_block('ISERROR',array('exi'=>1)); + + $eid = 0; + foreach ($errors as $error) + { + $template->adds_block('ERROR', array( 'ID' => $eid, + 'TEXT' => $error['text'])); + $template->add('IS' . strtoupper($error['field']) . 'ERROR', ' error'); + $template->adds_block(strtoupper($error['field']) . 'ERROR', array( 'ID' => $eid, + 'TEXT' => $error['text'])); + + $eid++; + } + + $getpoll = "SELECT * FROM polloftheweek WHERE id = " . $_GET['id']; + $getpoll2 = mysql_query($getpoll); + $getpoll3 = mysql_fetch_array($getpoll2); + + $template->add('QUESTIONVALUE', $_POST['question']); + $template->add('OPTION1VALUE', $_POST['option1']); + $template->add('OPTION2VALUE', $_POST['option2']); + $template->add('OPTION3VALUE', $_POST['option3']); + $template->add('OPTION4VALUE', $_POST['option4']); + $template->add('TEXTVALUE', $_POST['text']); + } else { + $inspoll = "UPDATE polloftheweek SET question = \"" . mysql_real_escape_string($_POST['question']) . "\", option1 = \"" . mysql_real_escape_string($_POST['option1']) . "\", option2 = \"" . mysql_real_escape_string($_POST['option2']) . "\", option3 = \"" . mysql_real_escape_string($_POST['option3']) . "\", option4 = \"" . mysql_real_escape_string($_POST['option4']) . "\", text = \"" . mysql_real_escape_string($_POST['text']) . "\" WHERE id = " . $_GET['id']; + $inspoll2 = mysql_query($inspoll); + + $template->add('QUESTIONVALUE', $_POST['question']); + $template->add('OPTION1VALUE', $_POST['option1']); + $template->add('OPTION2VALUE', $_POST['option2']); + $template->add('OPTION3VALUE', $_POST['option3']); + $template->add('OPTION4VALUE', $_POST['option4']); + $template->add('TEXTVALUE', $_POST['text']); + + $template->adds_block('FLASH', array('TEXT' => 'Your poll has been sucessfully edited. View poll.')); + } +} else { + $getpoll = "SELECT * FROM polloftheweek WHERE id = " . $_GET['id']; + $getpoll2 = mysql_query($getpoll); + $getpoll3 = mysql_fetch_array($getpoll2); + + $template->add('QUESTIONVALUE', $getpoll3['question']); + $template->add('OPTION1VALUE', $getpoll3['option1']); + $template->add('OPTION2VALUE', $getpoll3['option2']); + $template->add('OPTION3VALUE', $getpoll3['option3']); + $template->add('OPTION4VALUE', $getpoll3['option4']); + $template->add('TEXTVALUE', $getpoll3['text']); +} + +$template->display(); + +?> diff --git a/admin/editPost.php b/admin/editPost.php new file mode 100644 index 0000000..b01d1e2 --- /dev/null +++ b/admin/editPost.php @@ -0,0 +1,224 @@ + 'draft', + 'pending' => 'article', + 'updates' => 'instant'); +$tableToTags = array( 'drafts' => 'draft', + 'pending' => 'pending', + 'updates' => 'published'); + +if (!isset($_GET['type']) || !isset($_GET['id']) || !is_numeric($_GET['id'])) +{ + generateError('404'); +} else if (!(($_GET['type'] == 'drafts') || ($_GET['type'] == 'pending') || ($_GET['type'] == 'updates'))) +{ + generateError('404'); +} else { + $getpost = 'SELECT * FROM ' . $_GET['type'] . ' WHERE id = ' . $_GET['id']; + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + + if ($getpost3['id'] == $_GET['id']) + { + $template = new FITemplate('admin/writePost'); + + $template->add('TITLE', 'Edit Post'); + + if (isset($_GET['submit'])) + { + if (empty($_POST['title'])) + { + $errors[] = array( 'field' => 'title', + 'text' => 'Title is a required field'); + } + + if (empty($_POST['text'])) + { + $errors[] = array( 'field' => 'text', + 'text' => 'The content of a blog post cannot be empty'); + } + + if (empty($_POST['tags'])) + { + $errors[] = array( 'field' => 'tags', + 'text' => 'Tags is a required field'); + } + + if ( + (strpos($_POST['tags'], ',') === 0) || + (strrpos($_POST['tags'], ',') === strlen($_POST['tags'])-1) || + (strpos($_POST['tags'], ',,') !== FALSE) + ) + { + $errors[] = array( 'field' => 'tags', + 'text' => 'Blank tags are not allowed'); + } + + if (empty($_POST['type'])) + { + $errors[] = array( 'field' => 'type', + 'text' => 'Type is a required field'); + } + + if (isset($errors)) + { + $template->adds_block('ISERROR',array('exi'=>1)); + + $eid = 0; + foreach ($errors as $error) + { + $template->adds_block('ERROR', array( 'ID' => $eid, + 'TEXT' => $error['text'])); + $template->add('IS' . strtoupper($error['field']) . 'ERROR', ' error'); + $template->adds_block(strtoupper($error['field']) . 'ERROR', array( 'ID' => $eid, + 'TEXT' => $error['text'])); + + $eid++; + } + + $template->add('ACTION', '/admin/editPost.php?type=' . $_GET['type'] . '&id=' . $_GET['id'] . '&submit='); + } else { + $tags = explode(',', $_POST['tags']); + removeTags($_GET['id'], $tableToTags[$_GET['type']]); + + if ($tableToForm[$_GET['type']] != $_POST['type']) + { + $delold = "DELETE FROM " . $_GET['type'] . " WHERE id = " . $_GET['id']; + $delold2 = mysql_query($delold); + + if ($_POST['type'] == 'draft') + { + $insdraft = "INSERT INTO drafts (title,author,text,slug) VALUES (\"" . mysql_real_escape_string($_POST['title']) . "\",\"" . getSessionUsername() . "\",\"" . mysql_real_escape_string($_POST['text']) . "\",\"" . generateSlug($_POST['title'],'updates') . "\")"; + $insdraft2 = mysql_query($insdraft); + + $id = mysql_insert_id(); + $type = 'drafts'; + addTags($id, $tags, 'draft'); + } else if ($_POST['type'] == 'instant') + { + $id = postBlogPost($_POST['title'], getSessionUsername(), $tags, $_POST['text']); + $type = 'updates'; + } else { + if ($_POST['type'] == 'article') + { + $getpending = "SELECT * FROM pending ORDER BY id DESC LIMIT 0,1"; + $getpending2 = mysql_query($getpending); + $getpending3 = mysql_fetch_array($getpending2); + if (isset($getpending3['id']) === FALSE) + { + $id = 50; + } else { + $id = $getpending3['id']+1; + } + } else if ($_POST['type'] == 'high') + { + $getpending = "SELECT * FROM pending ORDER BY id ASC LIMIT 0,1"; + $getpending2 = mysql_query($getpending); + $getpending3 = mysql_fetch_array($getpending2); + if (isset($getpending3['id']) === FALSE) + { + $id = 50; + } else { + $id = $getpending3['id']-1; + } + } + + $inspending = "INSERT INTO pending (id,title,author,text,slug) VALUES (" . $id . ",\"" . mysql_real_escape_string($_POST['title']) . "\",\"" . getSessionUsername() . "\",\"" . mysql_real_escape_string($_POST['text']) . "\",\"" . generateSlug($_POST['title'],'updates') . "\")"; + $inspending2 = mysql_query($inspending); + + $type = 'pending'; + addTags($id, $tags, 'pending'); + } + } else if ($_POST['type'] == 'draft') + { + $setdraft = "UPDATE drafts SET title = \"" . mysql_real_escape_string($_POST['title']) . "\", text = \"" . mysql_real_escape_string($_POST['text']) . "\" WHERE id = " . $_GET['id']; + $setdraft2 = mysql_query($setdraft); + + $type = 'drafts'; + $id = $_GET['id']; + addTags($_GET['id'], $tags, 'draft'); + } else if ($_POST['type'] == 'article') + { + $setpending = "UPDATE pending SET title = \"" . mysql_real_escape_string($_POST['title']) . "\", text = \"" . mysql_real_escape_string($_POST['text']) . "\" WHERE id = " . $_GET['id']; + $setpending2 = mysql_query($setpending); + + $type = 'pending'; + $id = $_GET['id']; + addTags($_GET['id'], $tags, 'pending'); + } else if ($_POST['type'] == 'instant') + { + $setpost = "UPDATE updates SET title = \"" . mysql_real_escape_string($_POST['title']) . "\", text = \"" . mysql_real_escape_string($_POST['text']) . "\" WHERE id = " . $_GET['id']; + $setpost2 = mysql_query($setpost); + + $type = 'updates'; + $id = $_GET['id']; + addTags($_GET['id'], $tags); + } + + if ($type == 'updates') + { + $getpost = "SELECT * FROM updates WHERE id = " . $id; + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + + $url = '/blog/' . $getpost3['slug'] . '/'; + } else { + $url = '/viewPost.php?type=' . $type . '&id=' . $id; + } + + $template->adds_block('FLASH', array('TEXT' => 'Your post has been sucessfully edited. View post.')); + $template->add('ACTION', '/admin/editPost.php?type=' . $type . '&id=' . $id . '&submit='); + } + + $template->add('TITLEVALUE', $_POST['title']); + $template->add('TEXTVALUE', $_POST['text']); + $template->add('TAGSVALUE', $_POST['tags']); + $template->add(strtoupper($_POST['type']) . 'SELECTED', ' checked="checked"'); + if ($_POST['type'] != 'draft') $template->add('TAGSDISABLED', ' readonly="readonly"'); + } else { + $template->add('TITLEVALUE', $getpost3['title']); + $template->add('TEXTVALUE', $getpost3['text']); + $template->add('TAGSVALUE', implode(',', getTags($_GET['id'], $tableToTags[$_GET['type']]))); + $template->add(strtoupper($tableToForm[$_GET['type']]) . 'SELECTED', ' checked="checked"'); + if ($_GET['type'] != 'drafts') $template->add('TAGSDISABLED', ' readonly="readonly"'); + $template->add('ACTION', '/admin/editPost.php?type=' . $_GET['type'] . '&id=' . $_GET['id'] . '&submit='); + } + + $template->display(); + } else { + generateError('404'); + } +} + +?> diff --git a/admin/editQuote.php b/admin/editQuote.php new file mode 100644 index 0000000..b250ece --- /dev/null +++ b/admin/editQuote.php @@ -0,0 +1,69 @@ +add('TITLE', 'Edit Quote'); +$template->add('ACTION', '/admin/editQuote.php?id=' . $_GET['id'] . '&submit='); + +if (isset($_GET['submit'])) +{ + if (isset($errors)) + { + $template->adds_block('ISERROR',array('exi'=>1)); + + $eid = 0; + foreach ($errors as $error) + { + $template->adds_block('ERROR', array( 'ID' => $eid, + 'TEXT' => $error['text'])); + $template->add('IS' . strtoupper($error['field']) . 'ERROR', ' error'); + $template->adds_block(strtoupper($error['field']) . 'ERROR', array( 'ID' => $eid, + 'TEXT' => $error['text'])); + + $eid++; + } + + $template->add('QUOTEVALUE', $_POST['quote']); + } else { + $insquote = "UPDATE rash_quotes SET quote = \"" . mysql_real_escape_string($_POST['quote']) . "\" WHERE id = " . $_GET['id']; + $insquote2 = mysql_query($insquote); + + $template->add('QUOTEVALUE', $_POST['quote']); + + $template->adds_block('FLASH', array('TEXT' => 'Your quote has been sucessfully edited. View quote.')); + } +} else { + $getquote = "SELECT * FROM rash_quotes WHERE id = " . $_GET['id']; + $getquote2 = mysql_query($getquote); + $getquote3 = mysql_fetch_array($getquote2); + + $template->add('QUOTEVALUE', $getquote3['quote']); +} + +$template->display(); + +?> diff --git a/admin/maintenance.php b/admin/maintenance.php new file mode 100644 index 0000000..57f2646 --- /dev/null +++ b/admin/maintenance.php @@ -0,0 +1,61 @@ +add('ON', ' selected="selected"'); +} else { + $template->add('OFF', ' selected="selected"'); +} + +$template->display(); + +?> diff --git a/admin/modquotes.php b/admin/modquotes.php new file mode 100644 index 0000000..8340fd1 --- /dev/null +++ b/admin/modquotes.php @@ -0,0 +1,136 @@ +adds_block('AVAIL',array('exi'=>1)); +} else { + $template->adds_block('NOTAVAIL',array('exi'=>1)); +} + +$pager = &Pager::factory(array( 'mode' => 'Sliding', + 'perPage' => 20, + 'delta' => 2, + 'itemData' => $getpendingq3)); + +$j=0; + +foreach ($pager->getPageData() as $quote) +{ + if (!empty($quote)) + { + $template->adds_block('QUOTE', array( 'TEXT' => str_replace("\n","
",htmlentities(stripslashes($quote['quote']))), + 'ID' => $quote['id'], + 'ODD' => ($j % 2 ? '' : ' class="odd"'))); + } + + $j++; +} + +$template->add('PAGEID', $pager->getCurrentPageID()); +$template->add('PAGINATION', $pager->links); + +$template->display(); + +?> diff --git a/admin/newPoll.php b/admin/newPoll.php new file mode 100644 index 0000000..0373980 --- /dev/null +++ b/admin/newPoll.php @@ -0,0 +1,104 @@ + 'question', + 'text' => 'Question is a required field'); + } + + if (empty($_POST['option1'])) + { + $errors[] = array( 'field' => 'option1', + 'text' => 'Option 1 is a required field'); + } + + if (empty($_POST['option2'])) + { + $errors[] = array( 'field' => 'option2', + 'text' => 'Option 2 is a required field'); + } + + if (empty($_POST['option3'])) + { + $errors[] = array( 'field' => 'option3', + 'text' => 'Option 3 is a required field'); + } + + if (empty($_POST['option4'])) + { + $errors[] = array( 'field' => 'option4', + 'text' => 'Option 4 is a required field'); + } + + if (isset($errors)) + { + $template->adds_block('ISERROR',array('exi'=>1)); + + $eid = 0; + foreach ($errors as $error) + { + $template->adds_block('ERROR', array( 'ID' => $eid, + 'TEXT' => $error['text'])); + $template->add('IS' . strtoupper($error['field']) . 'ERROR', ' error'); + $template->adds_block(strtoupper($error['field']) . 'ERROR', array( 'ID' => $eid, + 'TEXT' => $error['text'])); + + $eid++; + } + + $template->add('TITLE', 'New Poll'); + $template->add('ACTION', '/admin/newPoll.php?submit='); + } else { + $inspoll = "INSERT INTO polloftheweek (question,option1,option2,option3,option4,text) VALUES (\"" . mysql_real_escape_string($_POST['question']) . "\",\"" . mysql_real_escape_string($_POST['option1']) . "\",\"" . mysql_real_escape_string($_POST['option2']) . "\",\"" . mysql_real_escape_string($_POST['option3']) . "\",\"" . mysql_real_escape_string($_POST['option4']) . "\",\"" . mysql_real_escape_string($_POST['text']) . "\")"; + $inspoll2 = mysql_query($inspoll); + + $id = mysql_insert_id(); + + $template->add('QUESTIONVALUE', $_POST['question']); + $template->add('OPTION1VALUE', $_POST['option1']); + $template->add('OPTION2VALUE', $_POST['option2']); + $template->add('OPTION3VALUE', $_POST['option3']); + $template->add('OPTION4VALUE', $_POST['option4']); + $template->add('TEXTVALUE', $_POST['text']); + + $template->add('TITLE', 'Edit Poll'); + $template->add('ACTION', '/admin/editPoll.php?id=' . $id . '&submit='); + $template->adds_block('FLASH', array('TEXT' => 'Your poll has been sucessfully created. View poll.')); + } +} else { + $template->add('TITLE', 'New Poll'); + $template->add('ACTION', '/admin/newPoll.php?submit='); +} + +$template->display(); + +?> diff --git a/admin/newPost.php b/admin/newPost.php new file mode 100644 index 0000000..eb6b4e0 --- /dev/null +++ b/admin/newPost.php @@ -0,0 +1,159 @@ + 'title', + 'text' => 'Title is a required field'); + } + + if (empty($_POST['text'])) + { + $errors[] = array( 'field' => 'text', + 'text' => 'The content of a blog post cannot be empty'); + } + + if (empty($_POST['tags'])) + { + $errors[] = array( 'field' => 'tags', + 'text' => 'Tags is a required field'); + } + + if ( + (strpos($_POST['tags'], ',') === 0) || + (strrpos($_POST['tags'], ',') === strlen($_POST['tags'])-1) || + (strpos($_POST['tags'], ',,') !== FALSE) + ) + { + $errors[] = array( 'field' => 'tags', + 'text' => 'Blank tags are not allowed'); + } + + if (empty($_POST['type'])) + { + $errors[] = array( 'field' => 'type', + 'text' => 'Type is a required field'); + } + + if (isset($errors)) + { + $template->adds_block('ISERROR',array('exi'=>1)); + + $eid = 0; + foreach ($errors as $error) + { + $template->adds_block('ERROR', array( 'ID' => $eid, + 'TEXT' => $error['text'])); + $template->add('IS' . strtoupper($error['field']) . 'ERROR', ' error'); + $template->adds_block(strtoupper($error['field']) . 'ERROR', array( 'ID' => $eid, + 'TEXT' => $error['text'])); + + $eid++; + } + + $template->add('TITLE', 'Write New Post'); + $template->add('ACTION', '/admin/newPost.php?submit='); + } else { + $tags = explode(',', $_POST['tags']); + + if ($_POST['type'] == 'draft') + { + $insdraft = "INSERT INTO drafts (title,author,text,slug) VALUES (\"" . mysql_real_escape_string($_POST['title']) . "\",\"" . getSessionUsername() . "\",\"" . mysql_real_escape_string($_POST['text']) . "\",\"" . generateSlug($_POST['title'],'updates') . "\")"; + $insdraft2 = mysql_query($insdraft); + + $id = mysql_insert_id(); + $type = 'drafts'; + addTags($id, $tags, 'draft'); + } else if ($_POST['type'] == 'instant') + { + $id = postBlogPost($_POST['title'], getSessionUsername(), $tags, $_POST['text']); + $type = 'updates'; + } else { + if ($_POST['type'] == 'article') + { + $getpending = "SELECT * FROM pending ORDER BY id DESC LIMIT 0,1"; + $getpending2 = mysql_query($getpending); + $getpending3 = mysql_fetch_array($getpending2); + if (isset($getpending3['id']) === FALSE) + { + $id = 50; + } else { + $id = $getpending3['id']+1; + } + } else if ($_POST['type'] == 'high') + { + $getpending = "SELECT * FROM pending ORDER BY id ASC LIMIT 0,1"; + $getpending2 = mysql_query($getpending); + $getpending3 = mysql_fetch_array($getpending2); + if (isset($getpending3['id']) === FALSE) + { + $id = 50; + } else { + $id = $getpending3['id']-1; + } + } + + $inspending = "INSERT INTO pending (id,title,author,text,slug) VALUES (" . $id . ",\"" . mysql_real_escape_string($_POST['title']) . "\",\"" . getSessionUsername() . "\",\"" . mysql_real_escape_string($_POST['text']) . "\",\"" . generateSlug($_POST['title'],'updates') . "\")"; + $inspending2 = mysql_query($inspending); + + $type = 'pending'; + addTags($id, $tags, 'pending'); + } + + if ($type == 'updates') + { + $getpost = "SELECT * FROM updates WHERE id = " . $id; + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + + $url = '/blog/' . $getpost3['slug'] . '/'; + } else { + $url = '/viewPost.php?type=' . $type . '&id=' . $id; + } + + $template->add('ACTION', '/admin/editPost.php?type=' . $type . '&id=' . $id . '&submit='); + $template->adds_block('FLASH', array('TEXT' => 'Your post has been sucessfully created. View post.')); + $template->add('TITLE', 'Edit Post'); + if ($type != 'drafts') $template->add('TAGSDISABLED', ' readonly="readonly"'); + } + + $template->add('TITLEVALUE', $_POST['title']); + $template->add('TEXTVALUE', $_POST['text']); + $template->add('TAGSVALUE', $_POST['tags']); + $template->add(strtoupper($_POST['type']) . 'SELECTED', ' checked="checked"'); +} else { + $template->add('TITLE', 'Write New Post'); + $template->add('ACTION', '/admin/newPost.php?submit='); +} + +$template->display(); + +?> diff --git a/admin/pending.php b/admin/pending.php new file mode 100644 index 0000000..407cd35 --- /dev/null +++ b/admin/pending.php @@ -0,0 +1,180 @@ + " . $_GET['id'] . " ORDER BY id ASC LIMIT 0,1"; + $get2pending2 = mysql_query($get2pending); + $get2pending3 = mysql_fetch_array($get2pending2); + + if (isset($get2pending3['id'])) + { + $otherPending = $get2pending3; + } + } + + if (isset($otherPending)) + { + $delpending = "DELETE FROM pending WHERE id = " . $_GET['id'] . " OR id = " . $otherPending['id']; + $delpending2 = mysql_query($delpending); + + $inspending = "INSERT INTO pending (id, title, author, text, slug) VALUES (" . $_GET['id'] . ",\"" . $otherPending['title'] . "\",\"" . $otherPending['author'] . "\",\"" . mysql_real_escape_string($otherPending['text']) . "\",\"" . $otherPending['slug'] . "\")"; + $inspending2 = mysql_query($inspending); + + $ins2pending = "INSERT INTO pending (id, title, author, text, slug) VALUES (" . $otherPending['id'] . ",\"" . $getpending3['title'] . "\",\"" . $getpending3['author'] . "\",\"" . mysql_real_escape_string($getpending3['text']) . "\",\"" . $getpending3['slug'] . "\")"; + $ins2pending2 = mysql_query($ins2pending) or die($ins2pending); + + $tags1 = getTags($_GET['id'], 'pending'); + $tags2 = getTags($otherPending['id'], 'pending'); + removeTags($_GET['id'], 'pending'); + removeTags($otherPending['id'], 'pending'); + addTags($_GET['id'], $tags2, 'pending'); + addTags($otherPending['id'], $tags1, 'pending'); + + $flashmsg = 'The selected post was moved sucessfully.'; + } + } + } + } else if ($_GET['action'] == 'deletes') + { + $ids = explode(',', $_POST['ids']); + + if (is_array($ids) && !empty($ids)) + { + foreach ($ids as $id) + { + $delpost = "DELETE FROM pending WHERE id = " . $id; + $delpost2 = mysql_query($delpost); + } + + $flashmsg = 'The selected posts have been deleted.'; + } + } +} + +$template = new FITemplate('admin/pending'); + +$getposts = "SELECT * FROM pending ORDER BY id ASC"; +$getposts2 = mysql_query($getposts); +$i=0; +while ($getposts3[$i] = mysql_fetch_array($getposts2)) +{ + $i++; +} + +if ($i != 0) +{ + $template->adds_block('AVAIL',array('exi'=>1)); +} else { + $template->adds_block('NOTAVAIL',array('exi'=>1)); +} + +$pager = &Pager::factory(array( 'mode' => 'Sliding', + 'perPage' => 20, + 'delta' => 2, + 'itemData' => $getposts3)); + +$j=0; + +if ($pager->isLastPage()) +{ + foreach (array_reverse($pager->getPageData()) as $post) + { + if (!empty($post)) + { + $last = $post; + break; + } + } +} + +foreach ($pager->getPageData() as $post) +{ + if (!empty($post)) + { + $template->add_ref($j, 'POST', array( 'TITLE' => $post['title'], + 'AUTHOR' => $post['author'], + 'ID' => $post['id'], + 'CODED' => $post['slug'], + 'ODD' => ($j % 2 ? '' : ' class="odd"'))); + + if ($pager->isFirstPage() && ($j == 0)) + { + $template->adds_ref_sub($j, 'NOMOVEUP', array('exi'=>1)); + } else { + $template->adds_ref_sub($j, 'CANMOVEUP', array('exi'=>1)); + } + + if ($pager->isLastPage() && ($post == $last)) + { + $template->adds_ref_sub($j, 'NOMOVEDOWN', array('exi'=>1)); + } else { + $template->adds_ref_sub($j, 'CANMOVEDOWN', array('exi'=>1)); + } + } + + $j++; +} + +$template->add('PAGEID', $pager->getCurrentPageID()); +$template->add('PAGINATION', $pager->links); + +$template->display(); + +?> diff --git a/admin/polls.php b/admin/polls.php new file mode 100644 index 0000000..8e1465c --- /dev/null +++ b/admin/polls.php @@ -0,0 +1,98 @@ +adds_block('AVAIL',array('exi'=>1)); +} else { + $template->adds_block('NOTAVAIL',array('exi'=>1)); +} + +$pager = &Pager::factory(array( 'mode' => 'Sliding', + 'perPage' => 20, + 'delta' => 2, + 'itemData' => $getposts3)); + +$j=0; + +foreach ($pager->getPageData() as $post) +{ + if (!empty($post)) + { + $template->adds_block('POST', array( 'TITLE' => $post['question'], + 'ID' => $post['id'], + 'ODD' => ($j % 2 ? '' : ' class="odd"'))); + } + + $j++; +} + +$template->add('PAGEID', $pager->getCurrentPageID()); +$template->add('PAGINATION', $pager->links); + +$template->display(); + +?> diff --git a/admin/posts.php b/admin/posts.php new file mode 100644 index 0000000..ac5b612 --- /dev/null +++ b/admin/posts.php @@ -0,0 +1,100 @@ +adds_block('AVAIL',array('exi'=>1)); +} else { + $template->adds_block('NOTAVAIL',array('exi'=>1)); +} + +$pager = &Pager::factory(array( 'mode' => 'Sliding', + 'perPage' => 20, + 'delta' => 2, + 'itemData' => $getposts3)); + +$j=0; + +foreach ($pager->getPageData() as $post) +{ + if (!empty($post)) + { + $template->adds_block('POST', array( 'TITLE' => $post['title'], + 'AUTHOR' => $post['author'], + 'ID' => $post['id'], + 'CODED' => $post['slug'], + 'ODD' => ($j % 2 ? '' : ' class="odd"'))); + } + + $j++; +} + +$template->add('PAGEID', $pager->getCurrentPageID()); +$template->add('PAGINATION', $pager->links); + +$template->display(); + +?> diff --git a/admin/quotes.php b/admin/quotes.php new file mode 100644 index 0000000..e222b39 --- /dev/null +++ b/admin/quotes.php @@ -0,0 +1,116 @@ +add('TITLE', 'Manage Flagged Quotes'); + $template->add('FLAGGED', 'flagged=&'); + + $getposts = "SELECT * FROM rash_quotes WHERE flag = 1 ORDER BY id DESC"; +} else { + $template->add('TITLE', 'Manage Quotes'); + $template->add('FLAGGED', ''); + + $getposts = "SELECT * FROM rash_quotes ORDER BY id DESC"; +} + +$getposts2 = mysql_query($getposts); +$i=0; +while ($getposts3[$i] = mysql_fetch_array($getposts2)) +{ + $i++; +} + +if ($i != 0) +{ + $template->adds_block('AVAIL',array('exi'=>1)); +} else { + $template->adds_block('NOTAVAIL',array('exi'=>1)); +} + +$pager = &Pager::factory(array( 'mode' => 'Sliding', + 'perPage' => 20, + 'delta' => 2, + 'itemData' => $getposts3)); + +$j=0; + +foreach ($pager->getPageData() as $post) +{ + if (!empty($post)) + { + $template->adds_block('QUOTE', array( 'EXCERPT' => htmlspecialchars(strpos($post['quote'],"\n") !== FALSE ? substr($post['quote'],0,strpos($post['quote'],"\n")) : $post['quote']), + 'ID' => $post['id'], + 'ODD' => ($j % 2 ? '' : ' class="odd"'))); + } + + $j++; +} + +$template->add('PAGEID', $pager->getCurrentPageID()); +$template->add('PAGINATION', $pager->links); + +$template->display(); + +?> diff --git a/admin/update.php b/admin/update.php new file mode 100644 index 0000000..05d4706 --- /dev/null +++ b/admin/update.php @@ -0,0 +1,36 @@ +display(); +} else { + system('hg update'); +} + +?> diff --git a/admin/welcome.php b/admin/welcome.php new file mode 100644 index 0000000..76b42b1 --- /dev/null +++ b/admin/welcome.php @@ -0,0 +1,71 @@ +add('POSTS', $cntposts3['COUNT(*)']); + +$cntpending = "SELECT COUNT(*) FROM pending"; +$cntpending2 = mysql_query($cntpending); +$cntpending3 = mysql_fetch_array($cntpending2); +$template->add('PENDING', $cntpending3['COUNT(*)']); + +$cntdrafts = "SELECT COUNT(*) FROM drafts"; +$cntdrafts2 = mysql_query($cntdrafts); +$cntdrafts3 = mysql_fetch_array($cntdrafts2); +$template->add('DRAFTS', $cntdrafts3['COUNT(*)']); + +$cntcomments = "SELECT COUNT(*) FROM moderation"; +$cntcomments2 = mysql_query($cntcomments); +$cntcomments3 = mysql_fetch_array($cntcomments2); +$template->add('COMMENTS', $cntcomments3['COUNT(*)']); + +$cntpolls = "SELECT COUNT(*) FROM polloftheweek"; +$cntpolls2 = mysql_query($cntpolls); +$cntpolls3 = mysql_fetch_array($cntpolls2); +$template->add('POLLS', $cntpolls3['COUNT(*)']); + +$cntquotes = "SELECT COUNT(*) FROM rash_quotes"; +$cntquotes2 = mysql_query($cntquotes); +$cntquotes3 = mysql_fetch_array($cntquotes2); +$template->add('QUOTES', $cntquotes3['COUNT(*)']); + +$cntflagged = "SELECT COUNT(*) FROM rash_quotes WHERE flag = 1"; +$cntflagged2 = mysql_query($cntflagged); +$cntflagged3 = mysql_fetch_array($cntflagged2); +$template->add('FLAGGED', $cntflagged3['COUNT(*)']); + +$cntmodcom = "SELECT COUNT(*) FROM rash_queue"; +$cntmodcom2 = mysql_query($cntmodcom); +$cntmodcom3 = mysql_fetch_array($cntmodcom2); +$template->add('MODCOM', $cntmodcom3['COUNT(*)']); + +$template->display(); + +?> -- cgit 1.4.1