Viewing file: ftpupload.php (5.01 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<head> <link rel="stylesheet" type="text/css" href="nuevo.css">
<link rel="STYLESHEET" type="text/css" href="estilo.css"> </head>
<?php
if (empty ($_POST['autor']) or empty ($_POST['titulo']) or empty ($_POST['correo']) or empty ($_FILES['upload']['name']) or empty ($_POST['provinciaList'])){ echo "<h1>todos los campos son obligatorios!</h1>"; die(); }
if (!strpos($_FILES['upload']['name'],".zip") and !strpos($_FILES['upload']['name'],".ZIP")){ echo "<h1>solo se admiten ficheros en formato ZIP</h1>"; die(); } if (!strpos($_POST['correo'],"@") or !strpos($_POST['correo'],".")){ echo "<h1>direccion de correo no valida</h1> "; die(); }
$fichero=str_replace(" ","_",$_FILES['upload']['name']); $fichero=elimina_acentos($fichero); if (!$_REQUEST['fb2']) {
if (isset($_POST['submit'])) { $ch = curl_init(); $localfile = $_FILES['upload']['tmp_name']; $fp = fopen($localfile, 'r'); echo "<h2>fichero: ".$_REQUEST['titulo']." tama�o: <b>".filesize($localfile)."</b> bytes<br></h2>"; curl_setopt($ch, CURLOPT_URL, 'ftp://gp571133:[email protected]/web/extras/pendiente/'.$fichero); curl_setopt($ch, CURLOPT_UPLOAD, 1); curl_setopt($ch, CURLOPT_INFILE, $fp); curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile)); curl_exec ($ch); $error_no = curl_errno($ch); curl_close ($ch); if ($error_no == 0) { $conn=mysql_connect("localhost","placasci_pba","pba"); mysql_select_db("placasci_papyre",$conn);
$queryx="select genero, subgenero from placasci_papyre.tipo where id_ajax='{$_REQUEST['provinciaList']}' and subgenero='{$_REQUEST['localidadList']}' limit 1";
$gen=mysql_fetch_array($resx=mysql_query($queryx,$conn));
echo mysql_error(); echo $error = '<h1>Fichero subido correctamente.'.$fichero."</h1>"; $autor= $_POST['autor']; $titulo=$_POST['titulo']; $correo=$_POST['correo']; $genero=$gen['genero']; $subgenero=$gen['subgenero']; $ruta="http://www.cocido-maragato.com/extras/pendiente/".$fichero; $fecha=date("Y-m-d")." ".(date("H")+7).date(":i:s"); $query="insert into placasci_papyre.upload (autor,titulo,correo,genero, subgenero,fecha,ruta) values('$autor','$titulo','$correo','$genero','$subgenero','$fecha','$ruta')"; mysql_query($query,$conn); echo mysql_error(); } else { echo $error = '<h2>Error al subir el fichero.</h2>'; } } }else{ // si es fb2
if (isset($_POST['submit'])) { $ch = curl_init(); $localfile = $_FILES['upload']['tmp_name']; $fp = fopen($localfile, 'r'); echo "<h2>fichero: ".$_REQUEST['titulo']." tama�o: <b>".filesize($localfile)."</b> bytes<br></h2>"; curl_setopt($ch, CURLOPT_URL, 'ftp://gp571133:[email protected]/web/extras/fb2/'.$fichero); curl_setopt($ch, CURLOPT_UPLOAD, 1); curl_setopt($ch, CURLOPT_INFILE, $fp); curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile)); curl_exec ($ch); $error_no = curl_errno($ch); curl_close ($ch); if ($error_no == 0) { $conn=mysql_connect("localhost","placasci_pba","pba"); mysql_select_db("placasci_papyre",$conn); $queryx="select genero, subgenero from placasci_papyre.tipo where id_ajax='{$_REQUEST['provinciaList']}' and subgenero='{$_REQUEST['localidadList']}' limit 1"; flush(); $gen=mysql_fetch_array($resx=mysql_query($queryx,$conn)); echo mysql_error(); echo $error = '<h1>Fichero subido correctamente.'.$fichero."</h1>"; $autor= $_POST['autor']; $titulo=$_POST['titulo']; $correo=$_POST['correo']; $genero=$gen['genero']; $subgenero=$gen['subgenero']; $fecha=date("Y-m-d")." ".(date("H")+6).date(":i:s"); ; $tamano=intval(filesize($localfile)/1000); $ruta="http://www.cocido-maragato.com/extras/fb2/".$fichero; $query="insert into placasci_papyre.libros (autor,titulo,correo,genero,subgenero,fecha_subida,ruta,tamano) values('$autor','$titulo','$correo','$genero','$subgenero','$fecha','$ruta',$tamano)"; mysql_query($query,$conn); echo mysql_error(); // ahora, sacamos el ID, para que los demas puedan "linkarlo" $query="select id from placasci_papyre.libros order by id desc limit 1" ; $resid=mysql_query($query,$conn); $rowid=mysql_fetch_array($resid,$conn);
// echo "<h3>puede enlazar directamente este libro desde su web, <b>http://placasci.exofire.net/frames/buskador.php?id=".$rowid[0]."</b>"; } else {
$error = '<h2>Error al subir el fichero.</h2>'; echo $error; } } }
echo '<center><a href ="entradilla.php"><img src="papyreicon.gif" WIDTH=32 HEIGHT=32></img><B>P�gina Principal</B></a>';
mysql_close($conn); /* function elimina_acentos($cadena){ $tofind='��"'; $tofind .= "&�������������������������������������������������������+[]?�!�,;�"; $replac='__'; $replac.= "_nnAAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn___----_-i"; return(strtr($cadena,$tofind,$replac)); } */ ?>
|