Viewing file: ftp_upload.php (5.93 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es-es">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="../nuevo.css">
<link rel="STYLESHEET" type="text/css" href="../estilo.css">
</head>
<body>
<?php
// require the htmlform class
include("../zebraforms/class.htmlform.php");
require_once "../classes/dUnzip2.inc.php";
require_once "../classes/dZip.inc.php";
include("../classes/fb2.classtxapuza.php");
include("../conn.php") ;
//deltree("../includes2");
//mkdir("../includes2/",0777,true);
//chmod("../includes2/",0777);
$debug=false;
if (!$_POST) {
echo "<center><h3><b>AVISO</b> En esta web no se permite la subida de libros convertidos con el <b>grammata conversor</b>, ni con <b>calibre</b>, debido a la escasa calidad de sus adaptaciones.</h3></center>";
}
// instantiate the class
$form = new HTMLForm('form', 'post','ftp_upload.php');
$form->maxFileSize=10240000;
// add a label to the 'name' control - used in the template file as {controls.label_name}
@$obj = $form->add('file', 'upload');
$obj->setRule(array('mandatory' => array('e1', 'Fichero Obligatorio: fichero')));
$obj = $form->add('file', 'portada');
$obj->setRule(array('mandatory' => array('e2', 'Fichero Obligatorio: portada')));
$obj = $form->add('textarea', 'sinopsis', '');
$obj->setRule(array('mandatory' => array('e3', 'Campo Obligatorio: sinopsis')));
$obj->setAttributes(array('rows'=>7,'cols'=>60));
// los radio
$sql="select distinct genero as genero from tipo";
$res=mysql_query($sql,$conn);
while ($rowgenero=mysql_fetch_array($res)){
$sql2="select subgenero , id from tipo where genero='{$rowgenero['genero']}' and subgenero<>'Cl�sicos'";
$res2=mysql_query($sql2,$conn);
while ($row=mysql_fetch_array($res2)){
$obj=$form->add('radio', 'options',$row['id']);
$form->add('label', 'label_'.$row['id'], 'options_'.$row['id'],$row['subgenero']);
}
}
$form->add('submit', 'submit', 'enviar datos');
$form->add('reset', 'reset', 'Borrar campo');
$obj=$form->add('button', 'control_atras', 'Volver atr�s');
$obj->setAttributes(array('onclick' =>'history.back()'));
// validate the form
if ($form->validate()) {
if ($debug){
echo "<pre>";
print_r($_FILES);
print_r($_REQUEST);
}
if (!isset($_POST['options'])) {
// notice that we bind the error message to the last label - we do this so that we won't trigger an error when choosing
// to let the script to automatically generate our form's output
$form->addError('e4', 'Debes seleccionar un g�nero','');
} else {
//aqui iria la validacion del $options
$sqlgenero="select * from tipo where id={$_REQUEST['options']}";
$tipo=mysql_fetch_array(mysql_query($sqlgenero,$conn));
$rnd=rand(1111,9999);
@ mkdir("../includes2/$rnd/",0777,true);
@ mkdir("../includes2/$rnd/libro/",0777,true);
copy ($_FILES['portada']['tmp_name'],"../includes2/$rnd/".str_replace("/tmp/",'',$_FILES['portada']['tmp_name']));
copy ($_FILES['upload']['tmp_name'],"../includes2/$rnd/libro/".str_replace("/tmp/",'',$_FILES['upload']['tmp_name']));
@chmod("../includes2/$rnd/".str_replace("/tmp/",'',$_FILES['portada']['tmp_name']),0777);
@chmod("../includes2/$rnd/".str_replace("/tmp/",'',$_FILES['upload']['tmp_name']),0777);
/*
echo $_REQUEST['sinopsis']."<br>";
echo htmlentities($_REQUEST['sinopsis'])."<br>";
echo rawurlencode($_REQUEST['sinopsis'])."<br>";
echo utf8_encode($_REQUEST['sinopsis'])."<br>";
echo urlencode($_REQUEST['sinopsis'])."<br>";
*/
$form2 = new HTMLForm('form', 'post',"ftp_paso2.php?sinopsis=".htmlentities($_REQUEST['sinopsis'])."&file=../includes2/$rnd/libro/".str_replace("/tmp/",'',$_FILES['upload']['tmp_name'])."&portada=".str_replace("/tmp/",'',$_FILES['portada']['tmp_name'])."&portada_orig={$_FILES['portada']['name']}&rnd=$rnd&genero=".htmlentities($tipo['genero'])."&subgenero=".htmlentities($tipo['subgenero'])."&relleno=".rand(3333,7777));
if ($debug){
echo "ftp_paso2.php?sinopsis=".htmlentities($_REQUEST['sinopsis'])."&file=../includes2/$rnd/libro/".str_replace("/tmp/",'',$_FILES['upload']['tmp_name'])."&portada=".str_replace("/tmp/",'',$_FILES['portada']['tmp_name'])."&portada_orig={$_FILES['portada']['name']}&rnd=$rnd&genero=".htmlentities($tipo['genero'])."&subgenero=".htmlentities($tipo['subgenero'])."&relleno=".rand(3333,7777);
}
echo "<center><h2>Ficheros subidos al servidor</h2><br><br>";
$form2->add('submit', 'submit', 'Pulse para procesar');
$form2->render();
die();
}
}
$form->render("./forms/ftp_inicio.xtpl");
function delTree($dir) {
$files = glob( $dir . '*', GLOB_MARK );
foreach( $files as $file ){
if( substr( $file, -1 ) == '/' )
delTree( $file );
else
unlink( $file );
}
if (is_dir($dir)) rmdir( $dir );
}
?>
|