нещо като галерия

koychev

Registered
пичове трябва ми скрипт за нещо като динамична галерия ама не точно. Значи искам да ми извежда картинките от дадена папка, ама като се щракне върху картинката (например 1.jpg), да ми отваря в нов прозорец друг файл със същото име (например 1.doc).
ей тука съм си избрал една галерийка. Нещо само трябва да се пипне в нов прозорец да не изкарва същата картинка ами другия файл.

Код:
<!doctype html public "-//w3c//dtd html 4.01 transitional//en">
<html>
<head>
<meta http-equiv="content-language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Gallery</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<script language="JavaScript" type="text/javascript">
<!-- ;
var newwindow;
var wheight = 0, wwidth = 0;
function popimg(url, title, iwidth, iheight, colour) {
var pwidth, pheight;

if ( !newwindow || newwindow.closed ) {
pwidth=iwidth+30;
pheight=iheight+30;
newwindow=window.open('','htmlname','width=' + pwidth +',height=' +pheight + ',resizable=1,top=50,left=10');
wheight=iheight;
wwidth=iwidth;
}

if (wheight!=iheight || wwidth!=iwidth ) {
pwidth=iwidth+30;
pheight=iheight+60;
newwindow.resizeTo(pwidth, pheight);
wheight=iheight;
wwidth=iwidth;
}

newwindow.document.clear();
newwindow.focus();
newwindow.document.writeln('<html> <head> <title>' + title + '<\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>');
newwindow.document.writeln('<a title="Hit to close!""><img src=' + url + ' border=0></a>');
newwindow.document.writeln('<\/center> <\/body> <\/html>');
newwindow.document.close();
newwindow.focus();
}

// Routines to tidy up popup windows when page is left
// Call with an onUnload="tidy5()" in body tag

function tidy5() {
if (newwindow && !newwindow.closed) { newwindow.close(); }
}

</script>

<body bgcolor="#003333" text="#000000" leftmargin="20" topmargin="10" marginwidth="10" marginheight="10">

<?php

$upload_dir = "docs/"; 

// get the all extensions from the array
for($i=0;$i<count($limitedext);$i++){
if (($i>count($limitedext)-1))$commas=", ";else $commas="";
list($key,$value)=each($limitedext);
$all_ext .= $value.$commas;
}

//print the form

//end of else


echo "<br><hr><center>
  <p><b>.:: Welcome to my galeries  ::.</b></p>
  </center><br>";

// set number of columns for the Gallery.
$cols = 4;
// set aloop for defining columns.
$i =1;
// creating table inorder to use it for columns.
echo "<table width=100% border ='5' bordercolor='#003333' cellpadding='25' cellspacing='15'>
<tr>";

//open the dir where files were uploaded inside.
$opendir =opendir($upload_dir);
// create a loop and define a variable called ($file)
// to hold the value of file name located in the directory .
while ($file = readdir($opendir)) {
//exclude anything that doen't look like files.
if($file != '..' && $file !='.' && $file !=''){
//dont't read direcories insde our directory.
if (!is_dir($file)){

// since i am using gallery we have to get the width and hieght of photos.
$imgsize = getimagesize ($upload_dir."".$file);



//for images width.
if ($imgsize[0] > 200){
$base_img = "<img src=\"$upload_dir$file\" border=\"2\" width=\"200\" height=\"200\">";
}else{
$base_img = "<img src=\"$upload_dir$file\" border=\"5\">";
}
//define a variable to hold everthing that will be printed in table's columns.
$all_stuff = "<b> $file</b> <hr size=>
<div style=\"width: 200px; height: 200px; z-index: 1; float: left; border: 0px dotted #C0C0C0\">
<a href=\"javascript:popimg('$upload_dir$file','$file', $imgsize[0], $imgsize[1],'black')\">
$base_img</a>
</div>
";


//divide the loop ($i) and ($cols) if the result is integer
//then print column number 1.
if (is_int($i / $cols)){
echo "<td align='center' valign='top' bgcolor='#F2F2F2'>$all_stuff</td></tr><tr>";
}else{
//else then print column number 2 etc for the next loop.
echo "<td align='center' valign='top' bgcolor='#F2F2F2'>$all_stuff</td>";
}
//add only 1 for the loop ($i).
$i++;
}
}
}//end while loop
closedir($opendir);
clearstatcache();
// print the rest of table.
echo "</tr>
</table>";

</body>
</html>
 

Back
Горе