Return strip picture implementation code

  • 2021-01-03 20:50:48
  • OfStack

randimage.php


<?php
/*
+---------------------------------------------------------+
| By Bleakwind http://www.weaverdream.com
+---------------------------------------------------------+
*/
$dir = "images/";// The images directory , Notice that it's sorted by name ...
$imgwidth = 0;// Image width , for 0 Is the original size 
$iforder = 1;// Sequential display or random display ,1 For sequential display ,0 For random display 
$ifcircle = 0;// Whether to play in loop when the sequence is displayed ,1 Play for loop ,0 For not cycle 
session_start();
if($imgwidth==0){$imgwidth=="";}else{$imgwidth=="width='".$imgwidth."'";}
$handle=opendir($dir);
while ($file_name=readdir($handle)){
if(($file_name!==".")&&($file_name!=="..")){$file_list[]=$file_name; }
}
closedir($handle);
if($iforder==1){
if(isset($_SESSION['sess_order'])){
if($_SESSION['sess_order']<count($file_list)-1){
$_SESSION['sess_order']++;
}else{
if($ifcircle == 1){
$_SESSION['sess_order']=0;
}
}
}else{
$_SESSION['sess_order']=0;
}
$i=$_SESSION['sess_order'];
}else{
$num=count($file_list)-1;
$i=rand(0,$num);
}
readfile($dir.$file_list[$i]);
?>

call


<img src="randimage.php" border="0">


Related articles: