Ver Mensaje Individual
  #4 (permalink)  
Antiguo 19/07/2009, 18:53
Avatar de chulifo
chulifo
 
Fecha de Ingreso: abril-2009
Ubicación: perdido en codigos del PHP, pero aprendo rapido!
Mensajes: 524
Antigüedad: 15 años, 1 mes
Puntos: 18
Respuesta: tomar imagenes random..

Mira usa esto

lo colocas arriba del todo el codigo
Código PHP:
<?php
$editFormAction 
$_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

// Aqui editas a tu gusto 
if (!session_id()) session_start(); 
$fx_links = array();
$fx_extallowed = array("gif","jpg","png");
$fx_path "imagenes/";
$fx_x 0;
$fx_display "";
$fx_count = -1;
$fx_imgs=opendir($fx_path);
while ((
$file readdir($fx_imgs)) !== false) {
  
$fx_x++;
}
rewind($fx_imgs);
while ((
$fx_file readdir($fx_imgs)) !== false) {
  
$fx_count++;
  if (
$fx_file != "." && $fx_file != "..") {
    
$fx_pos strpos($fx_file".");
    if (
$fx_pos 1$fx_Ext strtolower(substr($fx_file$fx_pos+1));
    if (!
is_dir($fx_path.$fx_file) && isset($fx_Ext) && array_search($fx_Ext,$fx_extallowed) !== false) {
      if (isset(
$_SESSION['fx_img'])) {
        if (
$fx_count $_SESSION['fx_img']) {
          
$fx_display '<img src="'.$fx_path.$fx_file.'" border="0">';
          
session_unregister("fx_img");
          
$fx_img $fx_count;
          
session_register("fx_img");
          break;
        }
      } else {
        if (isset(
$_SESSION['fx_rdm'])) {
          
$fx_rdm $fx_count;
        } else {
          
$fx_rdm mt_rand(1,$fx_x);
          
session_register("fx_rdm");
        }
        if (
$fx_count == $fx_rdm) {
          
$fx_display '<img src="'.$fx_path.$fx_file.'" border="0">';
          
$fx_img $fx_count;
          
session_register("fx_img");
          break;
        }
      }
    }
  }
}
closedir($fx_imgs);
if (
$fx_display == "") {
  
session_unregister("fx_img");
  
header ("Location: " $editFormAction);
}
for (
$i=0$i<sizeof($fx_links); $i++) {
  
$fx_ref split("=",$fx_links[$i]);
  if (
$fx_file == $fx_ref[0]) {
    if (isset(
$fx_ref[2]) && $fx_ref[2] != ""$fx_display str_replace('>'' alt="'.$fx_ref[2].'" title="'.$fx_ref[2].'">'$fx_display);
    if (isset(
$fx_ref[1]) && $fx_ref[1] != ""$fx_display '<a href="http://'.$fx_ref[1].'" target="_blank">'.$fx_display.'</a>';
    break;
  }
}
?>
y esto donde quieras que parescan las imagenes
Código PHP:
<?php echo $fx_display?>