338 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			338 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?
 | 
						||
if ( $user_auth && $user_level <= -1 )
 | 
						||
{
 | 
						||
 $blq1 ="Nombre,Apellido,Instrumento,url,comentario";
 | 
						||
 $blq2 ="e_Mail,NIF,Calle,Localidad,Provincia,CP,Telefono1,Telefono2,FechaNacimiento";
 | 
						||
 | 
						||
 $list = true;
 | 
						||
 | 
						||
 if ( isset( $sins ) )
 | 
						||
 {
 | 
						||
	displayForm( "./?dgo=adm/artistas.php&ins=new" );
 | 
						||
	$list = false;
 | 
						||
 }
 | 
						||
 if ( isset( $smod ) ) 
 | 
						||
 {	
 | 
						||
	$res = @mysql_query( "SELECT id,$blq1,$blq2  FROM artistas WHERE id=$smod", $conexion );
 | 
						||
	$datos = @mysql_fetch_array( $res );
 | 
						||
 | 
						||
	list( $db_id, $db_nombre,$db_apellidos,$db_instrumento,$db_url,$db_comentario,
 | 
						||
		$db_email,$db_nif,$db_calle,$db_localidad,$db_provincia,$db_cp,$db_tlf1,$db_tlf2,$db_fechaN ) = $datos;
 | 
						||
 | 
						||
	displayForm( "./?dgo=adm/artistas.php&mod=$smod" );
 | 
						||
	$list = false;
 | 
						||
 }
 | 
						||
 if ( isset( $mod ) )
 | 
						||
 {
 | 
						||
	if ( !empty($imgData_name) && $imgData_size > 0 )
 | 
						||
		  {
 | 
						||
			$img_prop = GetImageSize($imgData);
 | 
						||
			$db_Foto_w = $img_prop[0];
 | 
						||
			$db_Foto_h = $img_prop[1];
 | 
						||
			$addsql_p1 = ",Foto_mime='$imgData_name', Foto_w='$db_Foto_w', Foto_h='$db_Foto_h'";
 | 
						||
		  }	
 | 
						||
 | 
						||
	$sql = "UPDATE artistas SET ".
 | 
						||
		"Nombre='$db_nombre' ".
 | 
						||
		",Apellido='$db_apellidos' ".
 | 
						||
		",Instrumento='$db_instrumento' ".
 | 
						||
		",url='$db_url' ".
 | 
						||
		",comentario='".urlencode($db_comentario)."' ".
 | 
						||
 | 
						||
		",e_Mail='$db_email' ".
 | 
						||
		",NIF='$db_nif' ".
 | 
						||
		",Calle='$db_calle' ".
 | 
						||
		",Localidad='$db_localidad' ".
 | 
						||
		",Provincia='$db_provincia' ".
 | 
						||
		",CP='$db_cp' ".
 | 
						||
		",Telefono1='$db_tlf1' ".
 | 
						||
		",Telefono2='$db_tlf2' ".
 | 
						||
		",FechaNacimiento='$db_ano/$db_mes/$db_dia' $addsql_p1".
 | 
						||
		" WHERE id=$mod";
 | 
						||
	$res = @mysql_query( $sql, $conexion );
 | 
						||
 | 
						||
	if ( !empty($imgData_name) && $imgData_size > 0 )
 | 
						||
	{
 | 
						||
		$file_size = filesize($imgData);
 | 
						||
		$imgDEL = "db/artistas/$mod"."_i001@*";
 | 
						||
		echo `rm  -rf $imgDEL`;
 | 
						||
		fwrite( fopen("db/artistas/".$mod."_i001@$imgData_name", "wb"),
 | 
						||
			fread(fopen($imgData,"rb"),$file_size), $file_size);
 | 
						||
 | 
						||
		
 | 
						||
	}
 | 
						||
 | 
						||
	$list = true;
 | 
						||
 }
 | 
						||
 if( isset( $ins ) )
 | 
						||
 {
 | 
						||
	if ( !empty($imgData_name) && $imgData_size > 0 )
 | 
						||
		  {
 | 
						||
			$img_prop = GetImageSize($imgData);
 | 
						||
			$db_Foto_w = $img_prop[0];
 | 
						||
			$db_Foto_h = $img_prop[1];
 | 
						||
			$addsql_p1 = ",Foto_mime, Foto_w, Foto_h";
 | 
						||
			$addsql_p2 = ",'$imgData_name', '$db_Foto_w', '$db_Foto_h'";
 | 
						||
		  }	
 | 
						||
	$sql = "INSERT INTO artistas (FAlta, $blq1,$blq2 $addsql_p1) VALUES (NOW(),'$db_nombre','$db_apellidos','$db_instrumento','$db_url','".urlencode($db_comentario).
 | 
						||
               "','$db_email','$db_nif','$db_calle','$db_localidad','$db_provincia','$db_cp','$db_tlf1','$db_tlf2','$db_ano/$db_mes/$db_dia' $addsql_p2)";
 | 
						||
	$res = @mysql_query( $sql, $conexion ) OR die( "Error<br>".@mysql_error($conexion) );
 | 
						||
 | 
						||
	if ( !empty($imgData_name) && $imgData_size > 0 )
 | 
						||
	{
 | 
						||
		$file_size = filesize($imgData);
 | 
						||
		fwrite( fopen("db/artistas/".$last_id."_i001@$imgData_name", "wb"),
 | 
						||
			fread(fopen($imgData,"rb"),$file_size), $file_size);
 | 
						||
		
 | 
						||
	}
 | 
						||
 | 
						||
        echo "<h1>Artista insertado</h1><br><br><br>";
 | 
						||
        echo "<p class=remark>ID asignado = ".@mysql_insert_id($conexion)."</p>";
 | 
						||
	$list = true;
 | 
						||
 }
 | 
						||
 if( isset( $del ) )
 | 
						||
 {
 | 
						||
		$imgDEL = "db/artistas/$del"."_i001*";
 | 
						||
		echo `rm  -rf $imgDEL`;
 | 
						||
 | 
						||
	$res = @mysql_query( "DELETE FROM artistas WHERE id=$del" );
 | 
						||
	$list = true;
 | 
						||
 }
 | 
						||
 | 
						||
 if ( isset( $list ) && $list )
 | 
						||
 {
 | 
						||
   if ( !isset($orderBy) ) $orderBy ="id";
 | 
						||
   if ( !isset($orderDir) ) $orderDir ="ASC";
 | 
						||
 | 
						||
   displayList($conexion, $orderBy, $orderDir);
 | 
						||
 }
 | 
						||
 displayMenu();
 | 
						||
}
 | 
						||
 | 
						||
 | 
						||
function displayList($cnx, $orderBy, $orderDir)
 | 
						||
{
 | 
						||
 $thisLOCATION = "./?dgo=adm/artistas.php";
 | 
						||
 $res = @mysql_query( "SELECT id, CONCAT(Apellido,', ',Nombre) Nombre, Telefono1, Telefono2 FROM artistas ORDER BY $orderBy $orderDir" );
 | 
						||
 | 
						||
 echo "<br><br><br><table width=100% cellpadding=0 cellspacing=0 class=td_lista>";
 | 
						||
 | 
						||
 echo "<td class=menuL>id <a href=\"$thisLOCATION&oderBy=id&orderDir=DESC\"><img src=\"images/actions/down.gif\" border=0></a><a href=\"$thisLOCATION&oderBy=id&orderDESC=ASC\"><img src=\"images/actions/up.gif\" border=0></a></td>".
 | 
						||
      "<td class=menuL>Nombre <a href=\"$thisLOCATION&oderBy=Apellidos+Nombre&orderDir=DESC\"><img src=\"images/actions/down.gif\" border=0></a><a href=\"$thisLOCATION&oderBy=Apellidos+Nombre&orderDESC=ASC\"><img src=\"images/actions/up.gif\" border=0></a></td>".
 | 
						||
      "<td class=menuL>Telefonos</td>".
 | 
						||
      "<td class=menuL>Borrar</td>";
 | 
						||
 while( $datos=@mysql_fetch_array($res) )
 | 
						||
 {
 | 
						||
  list ( $db_id, $db_nombre, $db_tlf1, $db_tlf2 )= $datos;
 | 
						||
  echo "<tr><td><a href=\"./?dgo=adm/artistas.php&smod=$db_id\">$db_id</a></td><td>$db_nombre</td><td>$db_tlf1 # $db_tlf2</td><td><a href=\"javascript::deleteUser($db_id)\"><img src=\"images/actions/cancel.gif\" border=0></a></td></tr>";
 | 
						||
 }
 | 
						||
 echo "</table>";
 | 
						||
 echo '<script language="JavaScript"> 
 | 
						||
	function deleteUser( which )
 | 
						||
	{
 | 
						||
	  var submitOK = confirm("Atencion: Esta a punto de eliminar al artista.");
 | 
						||
	  if ( submitOK )
 | 
						||
		  document.location.href = "'.$thisLOCATION.'&orderBy='.$orderBy.'&orderDir='.$orderDir.'&del="+which;
 | 
						||
	}
 | 
						||
	</script>';
 | 
						||
}
 | 
						||
 | 
						||
function displayMenu()
 | 
						||
{
 | 
						||
 echo '<hr noshade color="#800000">';
 | 
						||
 echo '<p align="center"><a href="./?dgo=adm/artistas.php&sins=new">Insertar nuevo artista</a></p>';
 | 
						||
 echo '<hr noshade color="#800000">';
 | 
						||
}
 | 
						||
 | 
						||
function displayForm( $form_action )
 | 
						||
{
 | 
						||
 global $db_nombre, $db_apellidos, $db_instrumento, $db_url, $db_comentario;
 | 
						||
 global $db_email, $db_nif, $db_calle, $db_localidad, $db_provincia, $db_cp, $db_tlf1, $db_tlf2, $db_fechaN;
 | 
						||
global $imgData;
 | 
						||
 | 
						||
      // Dividimos la fecha de nacimiento en DIA/MES/A<>O
 | 
						||
 	$db_dia = substr($db_fechaN, 8, 2 );
 | 
						||
	$db_mes = substr($db_fechaN, 5, 2 );
 | 
						||
	$db_ano = substr($db_fechaN, 0, 4 );
 | 
						||
 | 
						||
 echo '<form action="'.$form_action.'" method="POST" name="register" enctype="multipart/form-data" onsubmit="return validateform( this.form )">';
 | 
						||
 echo '<p align="center"> </p><div align="center"><center><table border="0" cellpadding="0" cellspacing="0" width="100%">';
 | 
						||
 echo '<tr>
 | 
						||
            <td><h1>Datos del artista</h1>
 | 
						||
            <p> </p>
 | 
						||
            <table border="0" cellpadding="0" cellspacing="0"
 | 
						||
            width="100%" bgcolor="#800000">
 | 
						||
                <tr>
 | 
						||
                    <td> </td>
 | 
						||
                </tr>
 | 
						||
            </table>
 | 
						||
            <table border="0" width="100%">
 | 
						||
                <tr>
 | 
						||
                    <td width="30%">Nombre:</td>
 | 
						||
                    <td width="20%"><input type="text" size="15"
 | 
						||
                    name="db_nombre"
 | 
						||
                    value="'.$db_nombre.'"></td>
 | 
						||
                    <td valign="top" rowspan="5" width="50%"
 | 
						||
                    bgcolor="#B4CCE9" class="tdSuave"><strong>Informaci<63>n
 | 
						||
                    del artista</strong><p>Estos son los datos
 | 
						||
                    que cualquier usuario de la p<>gina puede
 | 
						||
                    consultar. <br>
 | 
						||
                    (Cuando Escoja un disco y/o se muestre la
 | 
						||
                    informaci<63>n de un Grupo, saldran sus
 | 
						||
                    componentes y esta es la informaci<63>n de cada
 | 
						||
                    uno de ellos).</p>
 | 
						||
                    <p>ATENCION: <20><> Se admiten controles HTML
 | 
						||
                    !!, por lo que aconsejamos sea muy cuidadoso
 | 
						||
                    con los mismos.</p>
 | 
						||
                    </td>
 | 
						||
                </tr>
 | 
						||
                <tr>
 | 
						||
                    <td width="30%">Apellidos:</td>
 | 
						||
                    <td width="20%"><input type="text" size="15"
 | 
						||
                    name="db_apellidos"
 | 
						||
                    value="'. $db_apellidos .'"></td>
 | 
						||
                </tr>
 | 
						||
                <tr>
 | 
						||
                    <td width="30%">Instrumento:</td>
 | 
						||
                    <td width="20%"><input type="text" size="15"
 | 
						||
                    name="db_instrumento"
 | 
						||
                    value="'. $db_instrumento .'"></td>
 | 
						||
                </tr>
 | 
						||
                <tr>
 | 
						||
                    <td width="30%" colspan=2>Fotografia:
 | 
						||
			<input type="file" size="15"
 | 
						||
                    name="imgData"
 | 
						||
                    value=""></td>
 | 
						||
                </tr>
 | 
						||
                <tr>
 | 
						||
                    <td>url:</td>
 | 
						||
                    <td><input type="text" size="15"
 | 
						||
                    name="db_url" value="'.$db_url.'"></td>
 | 
						||
                </tr>
 | 
						||
                <tr>
 | 
						||
                    <td colspan="3" width="30%">Comentarios
 | 
						||
                    adicionales:<p><textarea name="db_comentario" rows="5"
 | 
						||
                    cols="40">'.urldecode($db_comentario).'</textarea></p>
 | 
						||
                    </td>
 | 
						||
                </tr>
 | 
						||
            </table>
 | 
						||
            <hr noshade color="#800000">
 | 
						||
            <table border="0" width="100%">
 | 
						||
                <tr>
 | 
						||
                    <td width="30%">email:</td>
 | 
						||
                    <td width="20%"><input type="text" size="15"
 | 
						||
                    name="db_email"
 | 
						||
                    value="'.$db_email.'"></td>
 | 
						||
                    <td valign="top" rowspan="9" width="50%"
 | 
						||
                    bgcolor="#B4CCE9" class="tdSuave"><strong>Informaci<63>n
 | 
						||
                    de contacto</strong><p>Estos datos solo son
 | 
						||
                    accesibles por el administrador/es de la p<>gina.
 | 
						||
                    Por lo que nadie mas tendr<64> acceso a los
 | 
						||
                    mismos.</p>
 | 
						||
                    </td>
 | 
						||
                </tr>
 | 
						||
                <tr>
 | 
						||
                    <td width="30%">NIF:</td>
 | 
						||
                    <td width="20%"><input type="text" size="15"
 | 
						||
                    name="db_nif"
 | 
						||
                    value="'.$db_nif.'"></td>
 | 
						||
                </tr>
 | 
						||
                <tr>
 | 
						||
                    <td width="30%">Direcci<63>n:</td>
 | 
						||
                    <td width="20%"><input type="text" size="15"
 | 
						||
                    name="db_calle"
 | 
						||
                    value="'.$db_calle.'"></td>
 | 
						||
                </tr>
 | 
						||
                <tr>
 | 
						||
                    <td width="30%">Localidad:</td>
 | 
						||
                    <td width="20%"><input type="text" size="15"
 | 
						||
                    name="db_localidad"
 | 
						||
                    value="'.$db_localidad.'"></td>
 | 
						||
                </tr>
 | 
						||
                <tr>
 | 
						||
                    <td width="30%">Provincia:</td>
 | 
						||
                    <td width="20%"><input type="text" size="15"
 | 
						||
                    name="db_provincia"
 | 
						||
                    value="'.$db_provincia.'"></td>
 | 
						||
                </tr>
 | 
						||
                <tr>
 | 
						||
                    <td width="30%">C<>d. Postal:</td>
 | 
						||
                    <td width="20%"><input type="text" size="15"
 | 
						||
                    name="db_cp" value="'.$db_cp.'"></td>
 | 
						||
                </tr>
 | 
						||
                <tr>
 | 
						||
                    <td width="30%">Telefono</td>
 | 
						||
                    <td width="20%"><input type="text" size="15"
 | 
						||
                    name="db_tlf1"
 | 
						||
                    value="'.$db_tlf1.'"></td>
 | 
						||
                </tr>
 | 
						||
                <tr>
 | 
						||
                    <td>Movil:</td>
 | 
						||
                    <td><input type="text" size="15"
 | 
						||
                    name="db_tlf2"
 | 
						||
                    value="'.$db_tlf2.'"></td>
 | 
						||
                </tr>
 | 
						||
                <tr>
 | 
						||
                    <td>Cumplea<65>os:</td>
 | 
						||
                    <td><select name="db_dia" size="1">
 | 
						||
                        <option>Dia...</option>';
 | 
						||
        for ( $i=1;$i<32; $i++) 
 | 
						||
	{
 | 
						||
          echo "<option "; if ( $i==$db_dia ) echo " SELECTED "; echo ">$i"; echo "</option>";
 | 
						||
	} 
 | 
						||
  echo '              </select>
 | 
						||
	  	   <br>
 | 
						||
                    <select name="db_mes" size="1">
 | 
						||
                        <option>Mes...</option>
 | 
						||
                        <option value="1"'; if($db_mes==1)echo" selected "; echo '>Enero</option>
 | 
						||
                        <option value="2"'; if($db_mes==2)echo" selected "; echo '>Febrero</option>
 | 
						||
                        <option value="3"'; if($db_mes==3)echo" selected "; echo '>Marzo</option>
 | 
						||
                        <option value="4"'; if($db_mes==4)echo" selected "; echo '>Abril</option>
 | 
						||
                        <option value="5"'; if($db_mes==5)echo" selected "; echo '>Mayo</option>
 | 
						||
                        <option value="6"'; if($db_mes==6)echo" selected "; echo '>Junio</option>
 | 
						||
                        <option value="7"'; if($db_mes==7)echo" selected "; echo '>Julio</option>
 | 
						||
                        <option value="8"'; if($db_mes==8)echo" selected "; echo '>Agosto</option>
 | 
						||
                        <option value="9"'; if($db_mes==9)echo" selected "; echo '>Septiembre</option>
 | 
						||
                        <option value="10"'; if($db_mes==10)echo" selected "; echo '>Octubre</option>
 | 
						||
                        <option value="11"'; if($db_mes==11)echo" selected "; echo '>Noviembre</option>
 | 
						||
                        <option value="12"'; if($db_mes==12)echo" selected "; echo '>Diciembre</option>
 | 
						||
                    </select><br>
 | 
						||
                    <select name="db_ano" size="1">
 | 
						||
                        <option>A<>o...</option>';
 | 
						||
	for($i=2003;$i>1900;$i--)
 | 
						||
	{
 | 
						||
          echo "<option"; if ( $i==$db_ano ) echo " SELECTED "; echo ">$i";echo "</option>"; 
 | 
						||
	}
 | 
						||
 echo '</select></td>
 | 
						||
                    <td> </td>
 | 
						||
                </tr>
 | 
						||
            </table>
 | 
						||
            <hr noshade color="#800000">
 | 
						||
            <p align="center"><input type="button" name="btCancelar" value="Cancelar"><input
 | 
						||
            type="submit" name="B2" value="Enviar >>"></p>
 | 
						||
            <p><script language="JavaScript"><!--
 | 
						||
 | 
						||
function validateform(wf)
 | 
						||
{
 | 
						||
 | 
						||
if (document.register.db_nombre.value=="")
 | 
						||
{
 | 
						||
	window.alert ("Por favor, introduce el nombre")
 | 
						||
	return false;
 | 
						||
}
 | 
						||
if (document.register.db_nif.value=="")
 | 
						||
{
 | 
						||
	window.alert ("Por favor, introduce el NIF")
 | 
						||
	return false;
 | 
						||
}
 | 
						||
}
 | 
						||
// --></script><br>
 | 
						||
            </p>
 | 
						||
            </td>
 | 
						||
        </tr>
 | 
						||
    </table>
 | 
						||
    </center></div>
 | 
						||
</form>';
 | 
						||
}
 | 
						||
?>
 |