<?php
session_start();
if(!defined('access') or !access) die('This file cannot be directly accessed.');
if (!isset($_SESSION['random']) || $_SESSION['random-pos'] == (sizeof($_SESSION['random']) - 1))
{
$_SESSION['random-pos'] = -1;
$_SESSION['random'] = getFiles();
shuffle($_SESSION['random']);
}
$_SESSION['random-pos']++;
$rImg = $_SESSION['random'][$_SESSION['random-pos']];
include_theme_header(); ?>
<div id="content" class="pages" style="text-align: center;">
<h1 style="text-align: center;"><?php print(chevereto_config('site_name')); ?> Aléatoire</h1>
<p><a href="<?php show_base_url(); ?>random">Un autre image au hasard</a></p>
<p>Url de l'image <a href="<?php show_base_url(); ?>?v=<?php print($rImg); ?>"><?php show_base_url(); ?>?v=<?php print($rImg); ?></a></p>
<p><img src="<?php print(absolute_to_url(__CHV_PATH_IMAGES__.$rImg)); ?>" style="max-width: 900px; width: expression(width > 900?"900px":"auto");" /></p>
<p>Url de l'image <a href="<?php show_base_url(); ?>?v=<?php print($rImg); ?>"><?php show_base_url(); ?>?v=<?php print($rImg); ?></a></p>
<p><a href="<?php show_base_url(); ?>random">Un autre image au hasard</a></p>
<p><a href="<?php show_base_url(); ?>">Uploader une image</a></p>
</div>
</div><!-- wrap -->
<?php include_theme_footer();
function fileExtension($fileName)
{
return substr($fileName, strrpos($fileName, '.') + 1);
}
function getFiles()
{
$array = array();
$allowedExt = array('gif', 'png', 'jpg', 'jpeg');
if ($handle = opendir(__CHV_PATH_IMAGES__))
{
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..' && in_array(fileExtension($file), $allowedExt))
{
$array[] = $file;
}
}
closedir($handle);
}
return $array;
}
?>
<script type="text/javascript">
$(document).ready(function()
{
$("div#content img").each(function()
{
if ($(this).width() > 400)
{
$(this).css("width", "400px");
}
});
});
</script>