Foro de elhacker.net

Programación => PHP => Mensaje iniciado por: Brian1511 en 22 Junio 2013, 18:55 pm



Título: !Ayuda! Reemplazar un Texto por Digitos
Publicado por: Brian1511 en 22 Junio 2013, 18:55 pm
Hola a todos amigos de El HACKER bueno tiempo sin publicar nada pero aqui estoy , bueno a lo que vine...

Bueno para empezar mi duda es como ago para cambiar Un Texto por una serie de 5 digitos al azar .

Bueno talves esto suena un poco confuso pero ahora se los aclaro.

Es lo siguiente estoy creando una pequeña pagina de descara y pues bueno esto es lo que tengo este es el Upload.php

Código:
<?php
// Simple Script Para Subir Archivos Por :  Por Brian1511

$uploadpath = 'apk/';      // directory to store the uploaded files
$max_size = 15000;          // maximum file size, in KiloBytes
$alwidth = 1200;            // maximum allowed width, in pixels
$alheight = 900;           // maximum allowed height, in pixels
$allowtype = array('bmp', 'gif', 'jpg', 'jpe', 'png', 'apk', 'exe', 'jar', 'zip', 'rar', 'jdk', 'tar');        // allowed extensions

if(isset($_FILES['fileup']) && strlen($_FILES['fileup']['name']) > 1) {
  $uploadpath = $uploadpath . basename( $_FILES['fileup']['name']);       // gets the file name
  $sepext = explode('.', strtolower($_FILES['fileup']['name']));
  $type = end($sepext);       // gets extension
  list($width, $height) = getimagesize($_FILES['fileup']['tmp_name']);     // gets image width and height
  $err = '';         // to store the errors

  // Checks if the file has allowed type, size, width and height (for images)
  if(!in_array($type, $allowtype)) $err .= 'El Archivo: <b>'. $_FILES['fileup']['name']. '</b> not has the allowed extension type.';
  if($_FILES['fileup']['size'] > $max_size*1000) $err .= '<br/>Maximum file size must be: '. $max_size. ' KB.';
  if(isset($width) && isset($height) && ($width >= $alwidth || $height >= $alheight)) $err .= '<br/>The maximum Width x Height must be: '. $alwidth. ' x '. $alheight;

  // If no errors, upload the image, else, output the errors
  if($err == '') {
    if(move_uploaded_file($_FILES['fileup']['tmp_name'], $uploadpath)) {
      echo 'File: <b>'. basename( $_FILES['fileup']['name']). '</b> Carga Completa:';
      echo '<br/>Tipo de Archivo: <b>'. $_FILES['fileup']['type'] .'</b>';
      echo '<br />Tamaño: <b>'. number_format($_FILES['fileup']['size']/1024, 3, '.', '') .'</b> KB';
      if(isset($width) && isset($height)) echo '<br/>Image Width x Height: '. $width. ' x '. $height;
      echo '<br/><br/>Direccion del Archivo: <b>http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['REQUEST_URI']), '\\/').'/'.$uploadpath.'</b>';




?>


<?



}
    else echo '<b>Imposible cargar el archivo.</b>';
  }
  else echo $err;
}
?>
<div style="margin:1em auto; width:333px; text-align:center;">
 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
  Subir Archivo: <input type="file" name="fileup" /><br/>
  <input type="submit" name='submit' value="Subir Archivo" />
 </form>
</div>

Y bueno lo que quiero es que a la hora de darme el Link de descarga el Nombre del Archivo se Reemplaze con 5 digitos que se generen aleatorio .

Esta es la Parte que me da la Info y el Link de Ultimo...


Citar
// If no errors, upload the image, else, output the errors
  if($err == '') {
    if(move_uploaded_file($_FILES['fileup']['tmp_name'], $uploadpath)) {
      echo 'File: <b>'. basename( $_FILES['fileup']['name']). '</b> Carga Completa:';
      echo '<br/>Tipo de Archivo: <b>'. $_FILES['fileup']['type'] .'</b>';
      echo '<br />Tamaño: <b>'. number_format($_FILES['fileup']['size']/1024, 3, '.', '') .'</b> KB';
      if(isset($width) && isset($height)) echo '<br/>Image Width x Height: '. $width. ' x '. $height;
      echo '<br/><br/>Direccion del Archivo: <b>http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['REQUEST_URI']),

'\\/').'/'.$uploadpath.'</b>';

Bueno esto es todo....
espero que me puedan ayudar , gracias de antemano.