<?php
session_start();
include ('../config.php');
include ('secureadmin.php');
if(isset($_POST['submit'])) {
if(get_magic_quotes_gpc()) {
$title = $_POST['title'];
$body = $_POST['body'];
$resource = $_POST['resource'];
} else {
$title = mysql_real_escape_string($_POST['title']);
$body = mysql_real_escape_string($_POST['body']);
$resource = mysql_real_escape_string($_POST['resource']);
}
$catid = $_POST['category'];
$mysqldate = date( 'Y-m-d H:i:s' );
//Get the category's parent id
$catquery = "select * from categories where id =".$catid;
$catresult = mysql_query($catquery,$connection) or die(mysql_error());
$catinfo = mysql_fetch_array($catresult);
$parentid = $catinfo['parentid'];
if (!$parentid) {
$parentid = "NULL";
}
$sql = "INSERT INTO `articles` VALUES ( NULL, 0, 1, '".$mysqldate."', '".$title."',
".$catid.", ".$parentid.", '".$body."', '".$resource."', NULL);";
$query = mysql_query($sql);
header('Location: articleactive.php?add=true');
exit();
}
$metatitle = "New Article - Admin Control Panel";
include ('includes/document_head.php');
?>
<div id="wrapper">
<?php include 'includes/topbar.php'?>
<?php include 'includes/sidebar.php'?>
<div class="main_container container_16 clearfix">
<div class="flat_area grid_16">
<div class="box grid_16 round_all">
<div class="block">
<h2>Submit a New Article</h2>
<p>You can create new articles with your admin account details. NOTE: Admin articles are made live instantly - they skip the editorial queue.</p><br/>
<form style="padding-left: 15px;" name="submission" method="post" action="articlenew.php" >
<p><b>Enter the article title:</b></p>
<input type="text" name="title" style="width:400px;">
<br/><p><b>Select a Category:</b></p>
<select name="category">
<?php
// Populates the Dropdown list with all categories and subcats
$query = "select * from categories where parentid is null order by name;";
$result = mysql_query($query,$connection) or die(mysql_error());
$num_results = mysql_num_rows($result);
for ($i=0; $i <$num_results; $i++) {
$row = mysql_fetch_assoc($result);
echo "<option value=\"".$row['id']."\">".$row['name']."</option><br/>";
$query = "select * from categories where parentid =".$row['id']." order by name;";
$sub_result = mysql_query($query,$connection) or die(mysql_error());
$sub_num_results = mysql_num_rows($sub_result);
for ($x=0; $x <$sub_num_results; $x++) {
$subrow = mysql_fetch_assoc($sub_result);
echo "<option value=\"".$subrow['id']."\"> -- ".$subrow['name']."</option><br/>";
}
}
?>
</select>
<br/><br/><p><b>Enter the article body:</b></p>
</h3><textarea id="body" name="body" style="width:720px; height: 300px;"></textarea>
<br/><br/><p><b>Enter your author resource box:</b></p>
</h3><textarea id="resource" name="resource" style="width:720px; height: 120px;"></textarea>
<br />
<button type="submit" id="submitstyle" name="save" class="button_colour round_all"><img height="24" width="24" alt="Bended Arrow Right" src="images/icons/small/white/Bended Arrow Right.png"><span>Submit Article</span></button>
<input name="submit" type="hidden" id="submit" />
</form>
</div>
</div>
</div>
</div>
<?php include 'includes/closing_items.php'?>