<div id="center-column">
<div class="top-bar">
<h1>Cpanel - Media</h1>
<div class="breadcrumbs"><a href="index.php?act=addcode" title="Ad Code">Agregar codigo</a> / <a href="index.php?act=managegames" title="Manage Games">Administrar Juegos</a> / <a href="index.php?act=uploadgames" title="Upload Games">Subir juegos</a> / <a href="index.php?act=brokenfiles" title="Broken Files">Archivos en mal estado</a></div>
</div><br />
<div class="select-bar">
<label>
<h3>Agregar Media</h3>
</label>
</div>
<?php
if(isset($_POST['add'])) {
		$title = yasDB_clean($_POST['title']);
		$desc = yasDB_clean($_POST['description']);
		$thumb = yasDB_clean($_POST['thumbnail']);
		$file = yasDB_clean($_POST['file']);
		$height = yasDB_clean($_POST['height']);
		$width = yasDB_clean($_POST['width']);
		yasDB_insert("INSERT INTO games (title, description, category, thumbnail, file, height, width, type) values ('$title', '$desc', '{$_POST['category']}', '$thumb', '$file', '$height', '$width', '{$_POST['type']}')",false);
		echo '<center>Media agregado con exito!</font><br/>';
		echo '<a href="index.php?act=addmedia">Haga clic aqui para continuar</a></center>';
	
} else {
?><div class="table">
		<img src="img/bg-th-left.gif" width="8" height="7" alt="" class="left" />
	    <img src="img/bg-th-right.gif" width="7" height="7" alt="" class="right" />
		<form enctype="multipart/form-data" action="" method="post">
		<table class="listing form" cellpadding="0" cellspacing="0">
		<tr>
	    <th class="full" colspan="2">Subir un juego</th>
	    </tr>
		<tr>
		<td class="first" width="172"><strong>Titulo</strong></td>
		<td class="last"><input type="text" name="title" /></td>
		</tr>
		<tr class="bg">
		<td class="first"><strong>Descripcion</strong></td>
		<td class="last"><textarea name="description"></textarea></td>
		</tr>
		<tr>
		<td class="first" width="172"><strong>Categoria</strong></td>
		<td class="last"><select name="category">
	    <?php
	    $query = yasDB_select("SELECT * FROM categories");
	    while($row = $query->fetch_array(MYSQLI_ASSOC)) {
		echo '<option value="' . $row['id'] . '">' . $row['name'] . '</option>';
	    }
	    $query->close();
	    ?>
	    </select></td>
	    </tr>
	    <tr class="bg">
		<td class="first"><strong>Archivos</strong></td>
		<td class="last"><select name="type">
	    <option value="WMV">wmv</option>
	    <option value="AVI">avi</option>
	    <option value="MPG">mpg</option>
	    <option value="MOV">mov</option>
	    <option value="IMAGE">image</option>
	    <option value="YOUTUBE">youtube</option>
	    <option value="FLV">flv</option>
	    <option value="SWF">swf</option>
	    <option value="DCR">dcr</option>
	</select></td>
		</tr>
		<tr>
		<td class="first" width="172"><strong>Ruta del archivo</strong></td>
		<td class="last"><input type="text" name="file" value="media/files/" /></td>
		<tr class="bg">
		<td class="first" width="172"><strong>Height:*</strong></td>
		<td class="last"><input type="text" name="height" /></td>
		</tr>
		<tr>
		<td class="first"><strong>Width:*</strong></td>
		<td class="last"><input type="text" name="width" /></td>
		</tr>
		<tr class="bg">
		<td class="first" width="172"><strong>Agregar</strong></td>
		<td class="last"><input type="submit" class="button" name="add" value="Agregar Media!" /></td>
		</tr>
		</table>
		</div>
		</form>
<?php
}
?>
</div>