diff options
Diffstat (limited to 'admin/news/functions.php')
-rw-r--r-- | admin/news/functions.php | 96 |
1 files changed, 78 insertions, 18 deletions
diff --git a/admin/news/functions.php b/admin/news/functions.php index 6feabcf..9645311 100644 --- a/admin/news/functions.php +++ b/admin/news/functions.php @@ -21,24 +21,20 @@ function ListNews(){ global $db; - $result = $db->Query("SELECT n.news_id, n.title, n.message, n.date, n.category_id, u.username AS author, c.name AS catname, c.image AS catimage ". + $result = $db->Query("SELECT n.news_id, n.title, n.date, n.category_id, u.username AS author, c.name AS catname, c.image AS catimage ". "FROM `bayonet_news` AS n ". "INNER JOIN `bayonet_news_categories` AS c ON c.category_id = n.category_id ". - "LEFT OUTER JOIN `mybb_users` AS u ON u.uid = n.author_id ORDER BY `date` DESC"); + "LEFT OUTER JOIN `bayonet_users` AS u ON u.user_id = n.author_id ORDER BY `date` DESC"); $row = $db->Fetch($result); foreach($row as $news) { - $newsBody = $news['message']; - echo "<a href=\"?op=news&edit={$news['news_id']}\">"; - echo "<span class=\"bold\">{$news['title']}</span> | <span class=\"blue\">{$news['catname']}</span> <img src=\"images/page.png\" /></a><br />"; - if(($len = strlen($newsBody))>150) - echo substr($newsBody, 0, 150)."..."; - else - echo $newsBody; - echo '<br />'; - echo "Posted By: {$news['author']} on ".date('D M j, Y g:i a T', strtotime($news['date'])); - echo '<br /><br />'; +?> + <a href="?op=news&edit=<?php echo $news['news_id']; ?>"> + <span class="bold"><?php echo $news['title']; ?></span> | <span class="blue"><?php echo $news['catname']; ?></span> <img src="images/page.png" /></a><br /> + Posted By: <?php echo $news['author']; ?> on <?php echo date('n/j/Y @ g:ia T', strtotime($news['date'])); ?> + <br /><br /> +<?php } } @@ -49,26 +45,90 @@ function EditNews($news_id){ if(isset($_POST['processed'])){ + $title = $_POST['title']; + //$datetime = $_POST['year']."-".$_POST['month']."-".$_POST['day']." ".$_POST['time']; + date_default_timezone_set('America/New_York'); + $datetime = date('Y-m-d H:i:s'); + $text = $_POST['text']; + $author_id = $_POST['author']; + $edited_id = ADMIN_ID; + //$category_id = 1; + $text = addslashes($text); + + $db->Query("UPDATE `bayonet_news` SET `title` = '$title', `message` = '$text', `author_id` = '$author_id', `edited` = '$datetime', `edited_id` = '$edited_id' WHERE `news_id` = '$news_id'"); + decho("UPDATE `bayonet_news` SET `title` = '$title', `message` = '$text', `author_id` = '$author_id', `edited` = '$datetime', `edited_id` = '$edited_id' WHERE `news_id` = '$news_id'"); + PageRedirect(1, "?op=news"); return; } - $result = $db->Query("SELECT `author_id`, `title`, `message`, `date`, `category_id` FROM `bayonet_news` WHERE `news_id` = '$news_id' LIMIT 1"); + $result = $db->Query("SELECT `author_id`, `title`, `message`, `date`, `category_id`, `edited`, `edited_id` FROM `bayonet_news` WHERE `news_id` = '$news_id' LIMIT 1"); $row = $db->FetchRow($result); - ?> +?> +<style type="text/css"> +input { + height: 35px; + width: 300px; + font-size: 18px; + } +</style> <h3>Edit News</h3> - <form action="<?php $_SERVER['PHP_SELF']?>" method="post"> + <form action="" method="post"> + Originally posted on <?php echo date('n/j/Y @ g:ia e', strtotime($row['date'])); ?> +<?php + if($row['edited'] != NULL){ + echo "<br />Last edited on ".date('n/j/Y @ g:ia e', strtotime($row['edited'])); + } +?> <table> <tr><th>Author</th><td><?php SelectAuthor($row['author_id']); ?></td></tr> <tr><th>Title</th><td><input type="text" name="title" value="<?php echo $row['title']; ?>" /></td></tr> - <tr><th>Date</th><td><?php SelectDate($row['date']); ?></td></tr> - <tr><th>Time</th><td><input type="text" name="time" value="<?php echo date('G:i', strtotime($row['date'])); ?>" maxlength="5" size="5" /></td></tr> <tr><th>Text</th><td><textarea id="markItUp" rows="30" cols="80" name="text"><?php echo $row['message']; ?></textarea></td> <tr><th colspan="2"><input type="submit" name="processed" value="Submit" /></th></tr> </table> </form> - <?php +<?php +} + +function CreateNews(){ + + global $db; + + if(isset($_POST['processed'])){ + + $title = $_POST['title']; + //$datetime = $_POST['year']."-".$_POST['month']."-".$_POST['day']." ".$_POST['time']; + date_default_timezone_set('America/New_York'); + $datetime = date('Y-m-d H:i:s'); + $text = $_POST['text']; + $author_id = ADMIN_ID; + $category_id = 1; + $text = addslashes($text); + + $db->Query("INSERT INTO `bayonet_news` SET `title` = '$title', `message` = '$text', `author_id` = '$author_id', `date` = '$datetime', `category_id` = '$category_id'"); + + decho("INSERT INTO `bayonet_news` SET `title` = '$title', `message` = '$text', `author_id` = '$author_id', `date` = '$datetime', `category_id` = '$category_id'"); + PageRedirect(1, "?op=news"); + return; + } +?> +<style type="text/css"> +input { + height: 35px; + width: 300px; + font-size: 18px; + } +</style> + <h3>Post News</h3> + <form action="" method="post"> + <table> + <tr><td> <input type="text" name="title" value="" /></td></tr> + <tr><td><textarea id="markItUp" rows="30" cols="80" name="text"></textarea></td> + <tr><th colspan="2"><input type="submit" name="processed" value="Post" /></th></tr> + </table> + </form> +<?php } /** |