<?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 = "Badges"; 

if(isset($_POST['badge'])){ 

    if(!empty($_POST['badge'])){ 
$query = 'select badge from badges where badge = "' . $_POST['badge'] . '"';
$result = mysql_query($query) or die(mysql_error());
if(mysql_num_rows($result) == 1)
{ 
$msg = "La placa ya existe.";
}
else
{ 

            mysql_query("INSERT INTO badges (badge) VALUES ('".addslashes($_POST['badge'])."')") or die(mysql_error()); 
            $msg = "La placa se ha agregado."; 

            mysql_query("INSERT INTO system_stafflog (action,message,note,userid,targetid,timestamp) VALUES ('Housekeeping','Nueva Placa ".addslashes($_POST['badge'])."','add_placas.php','".$my_id."','','".$date_full."')") or die(mysql_error()); 

        } }
    } else { 

        $msg = "No dejes ningun campo vacio."; 

    } 


@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(isset($msg)){ ?><p><strong><?php echo $msg; ?></p></strong><?php } ?> 
  
<form action='index.php?p=addplaca&do=create' method='post' name='theAdminForm' id='theAdminForm'> 
<div class='tableborder'> 
<div class='tableheaderalt'>A&ntilde;adir placa a la shop</div> 



<table width='100%' cellspacing='0' cellpadding='5' align='center' border='0'> 
<tr> 
<td class='tablerow1'  width='40%'  valign='middle'><strong>Codigo de la placa</strong><div class='graytext'>El c&oacute;digo de la placa a vender. Ejemplos: ADM, HC1, HC2. (Revisa en Habborator)</div></td> 
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='badge' size='30' class='textinput'></td> 
</tr> 



<tr><td align='center' class='tablesubheader' colspan='2' ><input type='submit' value='Agregar Placa' class='realbutton' accesskey='s'></td></tr> 
</form></table></div><br /> 

<?php 
$get_badges = mysql_query("SELECT * FROM badges") or die(mysql_error()); 
?> 

 <div class='tableborder'> 
 <div class='tableheaderalt'>Placas a la venta</div> 
 <table cellpadding='4' cellspacing='0' width='100%'> 
 <tr> 
  <td class='tablesubheader' width='40%' align='center'>C&oacute;digo</td> 
  <td class='tablesubheader' width='40%' align='center'>Im&aacute;gen</td> 
<td class='tablesubheader' width='20%' align='center'>Borrar</td> 
 </tr> 
<?php 
while($row = mysql_fetch_assoc($get_badges)){ 
$image = "<img src=\"http://images.habbogroup.com/c_images/Badges/".$row['badge'].".gif\">";
$delete = "<a href=\"index.php?p=deleteplaca&do=delete&key=".$row['id']."\"><img src=\"images/delete.gif\"></a>";
    printf(" <tr> 
  <td class='tablerow1' align='center'>%s</td> 
  <td class='tablerow2' align='center'>%s</td> 
  <td class='tablerow3' align='center'>%s</td> 
</tr>", $row['badge'], $image, $delete); 
}
?> 
  
 </table> 
</div> 
     </div><!-- / RIGHT CONTENT BLOCK --> 
     </td></tr> 
</table> 
</div><!-- / OUTERDIV --> 
<div align='center'><br /> 
<?php 
$mtime = explode(' ', microtime()); 
$totaltime = $mtime[0] + $mtime[1] - $starttime; 
printf('Time: %.3f', $totaltime); 
?> 
</div> 