<?php
//  Mod by Svarc                        //
//  http://www.fun-kids-games.biz       //
//  Edits for v2.4 by YAS developers    //
//////////////////////////////////////////
?>
<div id="center-column">
<div class="top-bar">
				<a href="index.php?act=uploadgames" title="Upload Games" class="button">Añadir juego</a>
				<h1>Cpanel - Cpanel - Seccion de Descarga del juego</h1>
				<div class="breadcrumbs"><a href="index.php?act=addmedia" title="Ad Media">Agregar Media</a> / <a href="index.php?act=addcode" title="Ad Code">Agregar codigo</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>Añadir el juego para descargar la Seccion</h3>
		    </label>
		  </div>
		  <center>
<?php
if (isset($_POST['upload']) && $_POST['upload']=="1")
{
include_once ("../includes/db_functions.inc.php");
$path1= "../ourgames/img/".$_FILES['file']['name'][0];
$path2= "../ourgames/games/".$_FILES['file']['name'][1];
copy($_FILES['file']['tmp_name'][0], $path1);
copy($_FILES['file']['tmp_name'][1], $path2);
$gamename=yasDB_clean($_POST["gamename"]);
$gamedescript=yasDB_clean($_POST["description"]);
$thumbpath=yasDB_clean($path1);
$gamefilepath=($path2);
$mochilink=yasDB_clean($_POST['mochigame']);
$query = yasDB_insert("INSERT INTO downgames (title, description, thumbnail, file, mochi) VALUES ('$gamename', '$gamedescript', '$thumbpath', '$gamefilepath', '$mochilink')",false);
if (!$query){
	echo("Database Error!");
	} else
	{
	echo("<center>Archivos subidos con exito!</center>");
	echo('<center><a href="index.php?act=managedowngame">Haga clic aqui para volver</a></center>');
	}
if (isset($_POST['notify'])){
	$select_emails = yasDB_select("SELECT * FROM notifydown ORDER BY `id` ",false);
	while($emails = $select_emails->fetch_array(MYSQLI_ASSOC)) {
	$message = 'New game for your website available for download at '.$setting['siteurl']."\r\n";
	$message .= 'Click here to go to the download section: '.$setting['siteurl'].'/index.php?act=download'."\r\n";
	$message .= 'Name of the game : '.$gamename."\r\n";
	$message .= 'Description: '.$gamedescript."\r\n";
	$message .= 'To unsubscribe from the notification list please visit this link: '.$setting['siteurl'].'index.php?act=unsubscribe&id='.$emails['id'];
	$headers = 'From: '.$setting['sitename'].' <'.$setting['sitename'].'>';
	$subject = 'New game for your website available to download at '.$setting['siteurl'];
	@mail($emails['email'], $subject, $message, $headers);
	}
	echo ('<br /><center>Su juego fue enviado a los correos electronicos suscritos.</center>');
}
} else {
?>
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="upload" value="1" />
Nombre del juego:
<br />
<input type="text" name="gamename" maxlength="30" width="300" />
<br /><br />
Descripcion del juego:
<br />
<textarea name="description" rows="7" cols="50"></textarea>
<br /><br />
Seleccione imagen en miniatura<br />
<input type="file" name="file[]" />
<br /><br />
Seleccione Zip:<br />
<input type="file" name="file[]" />
<br /><br />
Link a la versión del juego de Mochi:
<br />
<input type="text" name="mochigame" maxlength="300" width="300" />
<br /><br />
Enviar notificacion a los correos electronicos suscritos sobre el nuevo juego:
<br />
<input type="checkbox" name="notify" value="notify" /> Comprobado = si | no comprobado = No
<br /><br />
<input type="submit" class="button" value="Añadir" />
</form>
<?php
}
?>
</center>
</div>