Viewing file: libro_modificacion.php (5.23 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php if ($_REQUEST['sinopsis']){ header ("Location: ./sinopsis.php?ID=".$_REQUEST['ID']); } ?><head>
<link rel="stylesheet" type="text/css" href="frames/nuevo.css">
<link rel="STYLESHEET" type="text/css" href="estilo.css"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head> <? $debug=true; include("conn.php"); include("class.ftp.php"); echo "<pre>"; //print_r($_REQUEST); //http://papyre.bplaced.net/frames PRINT_R($_FILES['upload']['name']);
if (((!strpos($_FILES['upload']['name'],".zip") and !strpos($_FILES['upload']['name'],".ZIP") and ($_FILES['upload']['name'])))){ echo "<h1>solo se admiten ficheros en formato ZIP</h1>"; die(); } $autor=str_replace(",","�",$_REQUEST['nombre']); $titulo=elimina_acentos_light(TRIM(ucwords(strtolower($_REQUEST['titulo']))));
echo "<br>titulo con acentos:"; echo $titulo=TRIM(ucwords(strtolower($_REQUEST['titulo'])));
$genero=$_REQUEST['genero']; $subgenero=$_REQUEST['subgenero']; $anyo=$_REQUEST['anyo'];
if ($_REQUEST['provinciaList']>''){ $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)); $genero=$gen['genero']; $subgenero=$gen['subgenero'];
echo mysql_error(); } if ($debug){ echo "$genero, $subgenero<br>"; } $fichero= str_replace(" ","_", str_replace(", ",",", str_replace("�",",", elimina_acentos(TRIM(ucwords(strtolower($autor)))))."-". elimina_acentos(strtoupper(trim($_POST['titulo'])))). elimina_acentos("-({$genero}"). ",". elimina_acentos("$subgenero)"). ".zip" ); // subida de fichero IF ($_FILES['upload']['name']){ $fecha_hora=STRVAL(INTVAL((date("H"))+DIF_HORARIA)); IF (STRLEN($fecha_hora)==1){$fecha_hora='0'.$fecha_hora;} $fecha=date("Y-m-d")." ".$fecha_hora.date(":i:s"); $localfile = $_FILES['upload']['tmp_name'];
$tamano=intval(filesize($localfile)/1000); } if ($debug){ echo $fichero."<br>"; } mysql_close($conn); $ruta="http://www.cocido-maragato.com/extras/fb2/".$fichero; $ftp_server = "62.193.202.9"; // add server name $ftp_user_name = "gp571133"; // add user name $ftp_user_pass = "j41ondtj"; // add password $dst_dir = "web/extras/fb2/"; // add destination directory ( www/upload/ ) //class constructor $ftp = new ftp($ftp_server,$ftp_user_name,$ftp_user_pass,$dst_dir);
if ($_FILES['upload']['name']) {
// sending any file // FTP_ASCII or FTP_BINARY
$array_titulo=split("http://www.cocido-maragato.com/extras/fb2/",$_REQUEST['ruta']); $nombre_antiguo=$array_titulo[1]; //$resultado1=$ftp->rename($nombre_antiguo, $_REQUEST['ID']."-".$nombre_antiguo); if (1==1){ $resultado = $ftp->sendfile($fichero, $localfile, "FTP_BINARY"); }else{ echo "Fallo en renombrado fichero antiguo"; }
if (debug){
echo "<pre>"; print_r($ftp); } $ftp->disconnect();
if ($resultado) {
echo $error = '<h1>Fichero subido correctamente.'.$fichero."</h1>"; $conn=mysql_connect($bbddhost,$bbdduser,$bbddpassword); mysql_select_db($bbdd,$conn)or die(mysql_error()); $query="update libros set autor=trim('{$_REQUEST['nombre']}'),titulo=trim('$titulo'),genero='$genero',subgenero='$subgenero',fecha_subida='$fecha',ruta='$ruta',tamano='$tamano',anyo='$anyo' where id='{$_REQUEST['ID']}'"; // dejamos una copia del antiguo, con el id por delante! if ($debug){ echo $query;} mysql_query($query,$conn); echo mysql_error(); $ftp->disconnect(); mysql_close($conn); } else {
echo "<h2>Error al subir el fichero.({$error})<br>No registro no actualizado</h2>"; echo $error; $ftp->disconnect(); die(); } } else { // no hay fichero para subir, solo actualizamos datos y renombramos $array_titulo=split("http://www.cocido-maragato.com/extras/fb2/",$_REQUEST['ruta']); $nombre_antiguo=$array_titulo[1]; if ($debug){ echo "nombre anterior:$nombre_antiguo<br>Nombre nuevo: $fichero<br>"; }
$ftp->rename($nombre_antiguo, $fichero); if (debug){ echo "<pre>"; print_r($ftp); } if (!$ftp->error){ $conn=mysql_connect($bbddhost,$bbdduser,$bbddpassword); mysql_select_db($bbdd,$conn)or die(mysql_error()); $query="update libros set autor='{$_REQUEST['nombre']}',titulo='$titulo',genero='$genero',subgenero='$subgenero',anyo='$anyo', ruta='http://www.cocido-maragato.com/extras/fb2/$fichero' where id='{$_REQUEST['ID']}'"; if ($debug){ echo $query;} mysql_query($query,$conn); if (!mysql_error()){ echo "<br><h1>libro actualizado</h1><br>"; $ftp->disconnect(); mysql_close($conn); } else { echo $sql."<br>"; echo "error renombrando libro<br>"; echo mysql_error(); mysql_close($conn); $ftp->disconnect(); mysql_close($conn); die(); }
} echo '<center><a href ="entradilla.php"><img src="papyreicon.gif" WIDTH=32 HEIGHT=32></img><B>P�gina Principal</B></a>';
@mysql_close($conn); @$ftp->disconnect();
} ?>
|