<?php
/*===================================================+
|| # HoloCMS - Website and Content Management System
|+===================================================+
|| # Copyright © 2008 Meth0d. All rights reserved.
|| # http://www.meth0d.org
|+===================================================+
|| # HoloCMS is provided "as is" and comes without
|| # warrenty of any kind. HoloCMS is free software!
|+===================================================+
|| # CREADO POR RAULGAITAN PARA SOLOTRADES.COM
|+===================================================*/

require_once('../core.php');
if($hkzone !== true){ header("Location: index.php?throwBack=true"); exit; }
if(!session_is_registered(acp)){ header("Location: index.php?p=login"); exit; }

$pagename = "Borrar Placas";

if($do == "delete" && is_numeric($key)){

	$check = mysql_query("SELECT id FROM badges WHERE id = '".$key."' LIMIT 1") or die(mysql_error());
	$exists = mysql_num_rows($check);

	if($exists > 0){
		mysql_query("DELETE FROM badges WHERE id = '".$key."' LIMIT 1") or die(mysql_error());
		$msg = "Placa borrada satisfactoriamente.";
	} else {
		$msg = "La placa no se pudo borrar.";
	}

} elseif($do == "edit" && is_numeric($key)){

	$check = mysql_query("SELECT * FROM cms_news WHERE num = '".$key."' LIMIT 1") or die(mysql_error());
	$exists = mysql_num_rows($check);

	if($exists > 0){
		$article = mysql_fetch_assoc($check);
		$editor_mode = true;
	} else {
		$msg = "Unable to edit article; this article does not exist!";
	}

} elseif($do == "save" && is_numeric($key) && isset($_POST['topstory'])){

	$check = mysql_query("SELECT num FROM cms_news WHERE num = '".$key."' LIMIT 1") or die(mysql_error());
	$exists = mysql_num_rows($check);

	if($exists > 0){

		$num = $key;

		$title = addslashes($_POST['title']);
		$category = addslashes($_POST['category']);
		$topstory = addslashes($_POST['topstory']);
		$short_story = addslashes($_POST['short_story']);
		$story = addslashes($_POST['story']);

		mysql_query("UPDATE cms_news SET title = '".$title."', category = '".$category."', topstory = '".$topstory."', short_story = '".$short_story."', story = '".$story."' WHERE num = '".$num."' LIMIT 1") or die(mysql_error());

		$msg = "Article updated successfully.";
		$editor_mode = false;

	} else {

		$msg = "Unable to edit article; this article does not exist!";

	}

} elseif($do == "bounce"){

	$msg = "Article published successfully.";

}

@include('subheader.php');
@include('header.php');
?>
<table cellpadding='0' cellspacing='8' width='100%' id='tablewrap'>
<tr> <td width='22%' valign='top' id='leftblock'>
 <div>
 <!-- LEFT CONTEXT SENSITIVE MENU -->
<?php @include('usermenu.php'); ?>
 <!-- / LEFT CONTEXT SENSITIVE MENU -->
 </div>
 </td>
 <td width='78%' valign='top' id='rightblock'>
 <div><!-- RIGHT CONTENT BLOCK -->
 
<?php if($editor_mode !== true){ ?>
<?php if(isset($msg)){ ?><p><strong><?php echo $msg; ?></strong></p><?php } ?>
 



<?php } ?>

</div><!-- / OUTERDIV -->
<div align='center'><br />
<?php
$mtime = explode(' ', microtime());
$totaltime = $mtime[0] + $mtime[1] - $starttime;
printf('Time: %.3f', $totaltime);
?>
</div>