connect(); $db['logos']->connect(); $db['sources']->connect(); if (isset($_GET['article_id']) || $_POST['formName'] == 'createArticle') { include "../includes/post_parser.php"; $parser = new post_parser; } // Edit an article // Opens up the article from the database if (isset($_GET['article_id'])) { $db['articles']->buildSelectQuery('*', 'article_id='.$_GET['article_id']); $db['articles']->query(); $data = $db['articles']->getRow(); $data['body'] = $parser->unconvert(stripslashes($data['body'])); } // If the user created an article else if ($_POST['formName'] == 'createArticle') { $data['name'] = $_POST['name']; $data['ref'] = $_POST['ref']; $data['source_id'] = $_POST['source_id']; $data['body'] = $_POST['body']; $data['html'] = $_POST['html']; $data['date'] = $_POST['date']; // The article contains HTML? if ($data['html'] != 'yes') $data['html'] = 'no'; // build the date that the article is to be created on $data['date'] = $_POST['year'].'-'.$_POST['month'].'-'.$_POST['day']; if ($_POST['submit'] == 'Create') { // If there are no errors, then insert the article in the database if (empty($data['name'])) $errorMsg = "A name must be specified!"; else { $temp_source_id = $data['source_id']; $temp_date = $data['date']; $data['ref'] = addslashes($data['ref']); $data['name'] = addslashes($data['name']); $data['body'] = addslashes($parser->convert($data['body'])); $db['articles']->buildInsertQuery(array_keys($data), array_values($data)); $db['articles']->query(); unset($data); $data['source_id'] = $temp_source_id; $data['date'] = $temp_date; } } // If the user is modifying an existing article then update the article else if ($_POST['submit'] == 'Update') { $data['body'] = addslashes($parser->convert($data['body'])); $db['articles']->buildUpdateQuery(array_keys($data), array_values($data), 'article_id='.$_POST['article_id']); $db['articles']->query(); unset($data); } // Otherwise, the user must be deleting an existing article // So display the delete confirmation screen. else {?> Delete Article
Are you sure you want to delete this article?
buildDeleteQuery('article_id='.$_POST['article_id']); $db['articles']->query(); } // If the date hasn't been set, then this must be a new article, so the date // will be set to today if (!isset($data['date'])) { $data['month'] = date('m'); $data['day'] = date('d'); $data['year'] = date('Y'); } else { $data['month'] = date('m', strtotime($data['date'])); $data['day'] = date('d', strtotime($data['date'])); $data['year'] = date('Y', strtotime($data['date'])); } // Select all the articles out of the database $db['articles']->buildSelectQuery('*',null,'ORDER BY name ASC'); $db['articles']->query(); ?> Articles
New Article
Name
Ref
Source edit sources
Date
(m/d/y)
Article Body
> Contains HTML or JavaScript
Only use this if can't get the above formatting buttons to do what you need to do.
Back Back
Existing Articles