-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
79 lines (79 loc) · 1.79 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* @author Nwachukwu patrick
* @category Dhtml slideshow in php
* @contact Nwachukwupatrick06@gmail.com
* you can make changes on it in order to suit your specific need.
**/
//open the image directory directory
$dh = new DirectoryIterator( "../pics" );
$files = array( );
// cross check the image to ake sure it ends with .jpg
foreach( $dh as $file )
{
if ( preg_match( "/[.]jpg$/", $file ) ) $files []= "$file";
}
?>
<html>
<head>
<title>Slideshow</title>
<style>
body { background: none; }
#thumbnails {
height: 140px;
width: 100%;
overflow: auto;
border: 2px solid grey;
background-color: blue;
padding: 0;
margin: 0;
}
#pic {
text-align: center;
height: 400px;
padding: 20px;
}
</style>
<script>
var image_list = [
<?php $first = true; foreach( $files as $image ) { ?>
<?php echo( $first ? "" : ", " ); ?>"<?php echo( $image ); ?>"
<?php $first = false; } ?>
];
var curimage = 0;
function switchimg( ind )
{
var image = image_list[ind];
var obj = document.getElementById( "selimg" );
obj.src = "scale.php?image="+image+"&y=400";
curimage = ind;
}
function nextimage( )
{
curimage++;
if ( curimage >= image_list.length ) curimage = 0;
switchimg( curimage );
}
window.setInterval( "nextimage( )", 4000 );
</script>
</head>
<body>
<div id="thumbnails">
<table width="100%">
<tr>
<?php $ind = 0; foreach( $files as $image ) { ?>
<td width="160" nowrap align="center">
<a href="javascript:switchimg( <?php echo($ind); ?> )">
<img height="100" src="scale.php?image=<?php echo($image); ?>&y=100" border="0" /
>
</a>
</td>
<?php $ind++; } ?>
</tr>
</table>
</div>
<div id="pic">
<img id="selimg" height="400" src="scale.php?image=<?php echo($files[0]);
?>&y=400" />
</div>
</body>