Viewing file: ftpupload2_backup.php (7.1 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<html> <head> <link rel="stylesheet" type="text/css" href="nuevo.css">
<link rel="STYLESHEET" type="text/css" href="estilo.css">
<? include "conn.php"; $debug=1; if ($debug==1){ echo "<pre>"; print_r($_REQUEST); PRINT_R($_FILES); } echo "
<div ID='waitDiv' style='position:absolute;left:300;top:300;visibility:hidden'> <table cellpadding='6' cellspacing='0' border='1' bgcolor='#000000' bordercolor='#FFFFFF'> <tr><td align=center> <font color='#ffffff' face='Verdana' size='4'>Cargando p�gina...</font> <img src='/images/cargando.gif' border='1'> </td> </tr></table> </div>
<SCRIPT> <!-- var DHTML = (document.getElementById || document.all || document.layers); function ap_getObj(name) { if (document.getElementById) { return document.getElementById(name).style; } else if (document.all) { return document.all[name].style; } else if (document.layers) { return document.layers[name]; } } function ap_showWaitMessage(div,flag) { if (!DHTML) return; var x = ap_getObj(div); x.visibility = (flag) ? 'visible':'hidden' if(! document.getElementById) if(document.layers) x.left=280/2; return true; } ap_showWaitMessage('waitDiv', 3); //--> </SCRIPT>
<SCRIPT> ap_showWaitMessage('waitDiv', 2); </SCRIPT> </head> <body>"; flush();
// echo "<pre>"; // print_r($_FILES); $fecha=date("Y-m-d")." ".(date("H")+7).date(":i:s");
if (empty ($_POST['autor']) or empty ($_POST['titulo']) or empty ($_FILES['upload']['name']) or empty ($_POST['provinciaList'])){ echo "<center><h1>campos obligatorios: <b>autor, titulo, fichero, genero, subgenero</b></h1>"; ?><center><a href='javascript:history.back()' style="text-decoration:none"><img src=volver.png border=0></img></a> <?php die(); }
if (!strpos($_FILES['upload']['name'],".zip") and !strpos($_FILES['upload']['name'],".ZIP")){ echo "<h1>solo se admiten ficheros en formato ZIP</h1>"; die(); }
$fichero=str_replace(" ","_",$_FILES['upload']['name']); $fichero=elimina_acentos($fichero); $imagen=str_replace(" ","_",$_FILES['imagen']['name']); $imagen=elimina_acentos($imagen); 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 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 upload (autor,titulo,correo,genero, subgenero,fecha,ruta) values('$autor','$titulo','$correo','$genero','$subgenero','$fecha','$ruta')"; echo mysql_error(); } else { echo '<h2>Error al subir el fichero.({$error})</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)); print_r($ch); flush(); curl_exec ($ch); print_r($ch); $error_no = curl_errno($ch); if (debug==1){ echo $localfile."<br>"; print_r($ch); } curl_close ($ch); if ($error_no == 0) {
$queryx="select genero, subgenero from 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 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); // ahora, toca la imagen y la sinopsis $negativo=0;
$localfile = $_FILES['imagen']['tmp_name']; if (strlen(trim($imagen))==0){ $negativo=1; }else{ copy ($localfile,"./includes/$imagen"); } //primero, tenemos que sacar el id $query="select * from libros where titulo='$titulo' and autor='$autor'"; $res=mysql_query($query,$conn); $rowid=mysql_fetch_array($res); $sinopsis=$_POST['sinopsis']; if (strlen(trim($sinopsis))==0){ $negativo=1; } if ($negativo==0){ $querysip="insert into placasci_papyre.sinopsis (imagename, id_book, sinopsis) values ('$imagen','{$rowid['id']}','{$sinopsis}')";
mysql_query($querysip,$conn); $querysip="update placasci_papyre.libros set sinopsis='*' where id={$rowid['id']}";
mysql_query($querysip,$conn); ECHO mysql_error(); }
// echo "<h3>puede enlazar directamente este libro desde su web, <b>http://placasci.exofire.net/frames/buskador.php?id=".$rowid[0]."</b>"; } else {
echo '<h2>Error al subir el fichero.({$error})</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 = "�������������������������������������������������������+[]?�!�,;�"; $replac = "nnAAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn___----_-i"; return(strtr($cadena,$tofind,$replac)); }
echo "<SCRIPT>ap_showWaitMessage('waitDiv', 0);</SCRIPT>";
?> </body> </html>
|