Jump to content
php.lv forumi

galerija


Puika1

Recommended Posts

kāds var man palīdzēt šis ir galerijas scripts viņš velk bildes ārā no htdoc kā var lai vilktu no piem htdoc/img (localhsot/img)

 

<?
//************************************************************//
//															//
//				PHP Slideshow v0.1						  //
//				Author: Brian Mahler						//
//				Copyright (c) 2006 Brian Mahler			 //
//															//		  
//************************************************************//
//
// CSS to position and change appearance
// Modify these settings to change the appearance of the page
//
?>
<!doctype html public "-//W3C//DTD HTML 4.01//EN"
  "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
  <title>PHP Slideshow v0.1 by Brian Mahler</title>
	<style type="text/css">
		body{
			background-color:#eee;
		}
		a:link, a:active, a:visited{
			text-decoration:none;
			color: #000;	
		}
		a:hover{
			color: #bbb;	
		}
		table#images{ /* Includes PageNav,ImageNav and Image */
			margin:auto;
		}
		td#copy{
			font-family: times;
			font-size:8pt;
		}
		Table#nav{ /* Navigation table */

		}
		img#view{

		}

	</style>
</head>
<body>
<?
//Definitions
//
//To change the number of thumbnails on a page, simply change the number  below
//
define("PER_PAGE",8);


//---------------------------------------------Do not Edit below this line-----------------------------------------------

//Get the path to the current directory
$z = split('/', $_SERVER['SCRIPT_FILENAME']);
$thisname = $z[count($z)-1];
$path = str_replace($thisname, '', $_SERVER['SCRIPT_FILENAME']);

//Define allowed file extensions
$allowed = array('jpg','gif','png');

//Read through the directory and find all files with proper file extensions
$dir = dir($path);
while ($file = $dir->read()) {
if (($file != '.') && ($file != 'CVS') && ($file != '..')) {
	$file_size = filesize($path . $file);
	$file_extension = file_ext($file);
	if(!is_dir($path . $file) && isset($file_extension) && in_array($file_extension, $allowed)) {
		$images[] = array('name' => $file,
						  'size' => $file_size);
	} 	
}
}

//Check for images present in the directory
$count = count($images);
if ($count < 1){
die('<center>No images present in current directory</center>');
}

//Calculate the number of pages
$pages = ceil($count / PER_PAGE);

//Get the current page
$current_page = $_GET['page'];
if (!isset($_GET['page'])){
$current_page = 1;
}

//Page Navigation
if ($current_page == 1) {
	$next = $current_page + 1;
$pagehtml = '<b>Page ' . $current_page . ' of ' . $pages . '</b> | <a class="navi" href="index.php?page=' . $next . '">Next Page ></a>';
}elseif ($current_page == $pages){
	$back = $current_page - 1;
$pagehtml = '<a class="navi" href="index.php?page=' . $back . '">< Previous Page</a> | <b>Page '  . $current_page . ' of ' . $pages . '</b>';		 	
}else{
$next = $current_page + 1;
$back = $current_page - 1;
	$pagehtml = '<a class="navi" href="index.php?page=' . $back . '">< Previous Page</a> | <b>Page '  . $current_page . ' of ' . $pages . '</b> | <a class="navi" href="index.php?page=' . $next . '">Next Page ></a>';
}


//Build the thumbnail navigation table
$y = $current_page * PER_PAGE;
$start = $y - PER_PAGE + 1;
$image_nav = '<table width="500px" id="nav"><tr>';
for ($x=$start; $x<=$y; $x++){
	if ($x <= $count){
 	$url = $images[$x -1]['name'];
	$image_nav .= '<td align="center" valign="center" width="12.5%"><a href="index.php?page=' . $current_page . '&id=' . $x . '"><img src="' . $url . '" border="0" width="60px"></a></td>';

}
}
$image_nav .= '</tr></table>';

//The image to be shown
$image_view = $_GET['id'];
if (!isset($_GET['id'])){
$image_view = $current_page * 8 - 7;
}
$image = '<img id="view" src="' . $images[$image_view - 1]['name'] . '" width="512px">'; 

$copy = 'PHP Slideshow v0.1 ©2006 Brian Mahler';

//Display the slideshow
echo '<table id="images" width="500px" border="0" cellpadding="2px">';
echo '<tr><td align="center">' . $pagehtml . '</td></tr><tr><td align="center">' . $image_nav . '</td></tr><tr><td id="pic" align="center" valign="center" style="padding:2px;">' . $image . '</td></tr>';
echo '<tr><td id="copy" align="center">' . $copy . '</td></tr>';
echo '</table>';

//function to get file extension of files
function file_ext($file) {
$extension = split("[.]", $file);
$ext_file = $extension[count($extension)-1];
return strtolower($ext_file);
}
?>
</body>
</html>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...