session_start();
/* --------------------------------------------------
randuri.php: Random Uniform Resource Identificator
2002 Alfredo Rahn
http://alfredorahn.com
Versión 1.1 2002-11-21
Licenced under the GPL
--------------------------------------------------
Que es [What is it]:
--------------------
Randuri es un script de php, que redirecciona al cliente web utilizando http a un url aleatorio.
Dicho de una manera mas simple, randuri puede ser empleado para mostrar contenido
aleatorio como: imagenes, iconos, fondos, musica, etc.
[Randuri is a php script that redirects the web client using http to a random url.
Put in a simpler way, randuri can be used to show random contents
like: pictures, icons, backgrounds, music, etc.]
Para Configurarlo [To configure it]:
------------------------------------
- Cree las carpetas con los recursos que desea publicar,
en algun lugar por debajo de la raiz web.
- En la variable $_Conf debe indicar la ruta relativa al script
de la o las carpetas de las cuales el script publicará los
recursos de forma aleatoria. Un ejemplo, teniendo
"Fotos" y "Musica" sería:
[- Mkdir the folders which will contain the resources
being published anywhere below web root folder.
- In the $_Conf variable you must put which folder or folders
the script will be publishing random resources from.
An example, having pictures as "Fotos" and midi files
as "Musica" it would be: ]
$_Conf = array( "Fotos" => "./img/album",
"Musica" => "./midis"
);
Otro ejemplo teniendo solo "Fotos":
[ Another example, having just pictures as "Fotos": ]
$_Conf = array( "Fotos" => "./photos" );
Para utilizarlo [For using it]:
-------------------------------
Invoque el script pasando a la variable get O el parametro apropiado, por ejemplo:
[Invoque the script, passing the appropiate parameter as get variable O, for example:]

etc.
--------------------------------------------
[
Changelog:
2002-11-21 Versión 1.1 released. Changes include:
- Added session_start call on top.
- Complete rewrite of output phase. Before, the script
redirected the client to the random url. Sometimes it
failed, so now it pumps the whole file to the client
via readfile(). Anyway, less http calls and less bandwidth
consumed.
- Added customizable goodbye message.
2002-07-31 Versión 1.0 released
]
*/
// ******* Seccion Configurable [Customizable Settings] ********
// Esto es lo que hace falta que modifiques para que el script funcione
// [ This is what you should modify for the script to work ]
// [ Configuration Array: Name => Path to stuff ]
$_Conf = array( "Fondo" => "./med/fondos",
"Foto" => "./med/fotos" );
//$_Conf = array( "Fondo" => "./fondos",
// "Foto" => "./fotos" );
// [ Error Response: What to say on neatty endings. ]
$_Error = "No Hay!";
// ******* Fin de la Seccion Configurable [End of Customizable Settings] ********
$O = $HTTP_GET_VARS["O"];
// ******* Seccion de Programa [Program Section] ********
/* En teoría, no hace falta que modifiques nada de aqui en adelante para
que esto funcione pero como la experiencia practica eventualmente supera
a la teorica si debes o quieres modificalo, pero hazlo a tu propio riesgo!!!
[ In theory, there's no need for you to modify nothing from here on for this
to work but as practical experience eventually superbs theoretics modify it
as you may want or need to, but do it at your own risk!!! ]
*/
if (empty($_Conf[$O])) {
die ($_Error);
}
// seed with microseconds
function make_seed() {
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
// If it has not scanned path files yet
if (empty($_SESSION['Archivos'][$O])) {
// List files in corresponding path
if ($handle = @opendir($_Conf[$O])) {
while (false !== ($file = readdir($handle))) {
// Adds file to list, in session
if ($file != "." && $file != "..")
$_SESSION['Archivos'][$O][] = $file;
}
closedir($handle);
$_SESSION['Ultimo'][$O] = -1;
} else {
// If it could not open path
die ($_Error);
}
}
// Ooops! No files found...
(count($_SESSION['Archivos'][$O])==0) and die ($_Error);
// Otherwise, draws a number of which file to show that
// it's prefereably not the last one drawn...
mt_srand(make_seed());
do {
$aleato = @mt_rand(0, count($_SESSION['Archivos'][$O])-1);
} while ($_SESSION['Ultimo'][$O] == $aleato);
// Parses the corresponding file to the client
$_SESSION['Ultimo'][$O] = $aleato;
@readfile ($_Conf[$O] . "/" . $_SESSION['Archivos'][$O][$aleato]);
// ******* Fin del cuento [End of story] ********
?>
/* --------------------------------------------------
randuri.php: Random Uniform Resource Identificator
2002 Alfredo Rahn
http://alfredorahn.com
Versión 1.1 2002-11-21
Licenced under the GPL
--------------------------------------------------
Que es [What is it]:
--------------------
Randuri es un script de php, que redirecciona al cliente web utilizando http a un url aleatorio.
Dicho de una manera mas simple, randuri puede ser empleado para mostrar contenido
aleatorio como: imagenes, iconos, fondos, musica, etc.
[Randuri is a php script that redirects the web client using http to a random url.
Put in a simpler way, randuri can be used to show random contents
like: pictures, icons, backgrounds, music, etc.]
Para Configurarlo [To configure it]:
------------------------------------
- Cree las carpetas con los recursos que desea publicar,
en algun lugar por debajo de la raiz web.
- En la variable $_Conf debe indicar la ruta relativa al script
de la o las carpetas de las cuales el script publicará los
recursos de forma aleatoria. Un ejemplo, teniendo
"Fotos" y "Musica" sería:
[- Mkdir the folders which will contain the resources
being published anywhere below web root folder.
- In the $_Conf variable you must put which folder or folders
the script will be publishing random resources from.
An example, having pictures as "Fotos" and midi files
as "Musica" it would be: ]
$_Conf = array( "Fotos" => "./img/album",
"Musica" => "./midis"
);
Otro ejemplo teniendo solo "Fotos":
[ Another example, having just pictures as "Fotos": ]
$_Conf = array( "Fotos" => "./photos" );
Para utilizarlo [For using it]:
-------------------------------
Invoque el script pasando a la variable get O el parametro apropiado, por ejemplo:
[Invoque the script, passing the appropiate parameter as get variable O, for example:]
etc.
--------------------------------------------
[
Changelog:
2002-11-21 Versión 1.1 released. Changes include:
- Added session_start call on top.
- Complete rewrite of output phase. Before, the script
redirected the client to the random url. Sometimes it
failed, so now it pumps the whole file to the client
via readfile(). Anyway, less http calls and less bandwidth
consumed.
- Added customizable goodbye message.
2002-07-31 Versión 1.0 released
]
*/
// ******* Seccion Configurable [Customizable Settings] ********
// Esto es lo que hace falta que modifiques para que el script funcione
// [ This is what you should modify for the script to work ]
// [ Configuration Array: Name => Path to stuff ]
$_Conf = array( "Fondo" => "./med/fondos",
"Foto" => "./med/fotos" );
//$_Conf = array( "Fondo" => "./fondos",
// "Foto" => "./fotos" );
// [ Error Response: What to say on neatty endings. ]
$_Error = "No Hay!";
// ******* Fin de la Seccion Configurable [End of Customizable Settings] ********
$O = $HTTP_GET_VARS["O"];
// ******* Seccion de Programa [Program Section] ********
/* En teoría, no hace falta que modifiques nada de aqui en adelante para
que esto funcione pero como la experiencia practica eventualmente supera
a la teorica si debes o quieres modificalo, pero hazlo a tu propio riesgo!!!
[ In theory, there's no need for you to modify nothing from here on for this
to work but as practical experience eventually superbs theoretics modify it
as you may want or need to, but do it at your own risk!!! ]
*/
if (empty($_Conf[$O])) {
die ($_Error);
}
// seed with microseconds
function make_seed() {
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
// If it has not scanned path files yet
if (empty($_SESSION['Archivos'][$O])) {
// List files in corresponding path
if ($handle = @opendir($_Conf[$O])) {
while (false !== ($file = readdir($handle))) {
// Adds file to list, in session
if ($file != "." && $file != "..")
$_SESSION['Archivos'][$O][] = $file;
}
closedir($handle);
$_SESSION['Ultimo'][$O] = -1;
} else {
// If it could not open path
die ($_Error);
}
}
// Ooops! No files found...
(count($_SESSION['Archivos'][$O])==0) and die ($_Error);
// Otherwise, draws a number of which file to show that
// it's prefereably not the last one drawn...
mt_srand(make_seed());
do {
$aleato = @mt_rand(0, count($_SESSION['Archivos'][$O])-1);
} while ($_SESSION['Ultimo'][$O] == $aleato);
// Parses the corresponding file to the client
$_SESSION['Ultimo'][$O] = $aleato;
@readfile ($_Conf[$O] . "/" . $_SESSION['Archivos'][$O][$aleato]);
// ******* Fin del cuento [End of story] ********
?>
No hay comentarios.:
Publicar un comentario