flash gallery with php
Posted: Wed Oct 21, 2009 6:43 am
Hi
I have a problem that I can't seem to figure out for the past few days. Basically I downloaded a ridiculously cool flash gallery so I can view images on my website. The thing is I want to get the image location from sql database and only show certain images according to the gallery. my website works like this.
User end
1) Person clicks on gallery of choice.
2) All images assigned to that gallery are shown.
when an image is added the image is sent to server and location saved on sql along side the album that it belongs to via album ID.
Can some one please help out. The code is bellow
I have a problem that I can't seem to figure out for the past few days. Basically I downloaded a ridiculously cool flash gallery so I can view images on my website. The thing is I want to get the image location from sql database and only show certain images according to the gallery. my website works like this.
User end
1) Person clicks on gallery of choice.
2) All images assigned to that gallery are shown.
when an image is added the image is sent to server and location saved on sql along side the album that it belongs to via album ID.
Can some one please help out. The code is bellow
Code: Select all
<!-- Div that contains gallery. -->
<div id="gallery">
<!-- Script that embeds gallery. -->
<script language="javascript" type="text/javascript">
var so = new SWFObject("flashgallery.swf", "gallery", "800", "600", "8"); // You can change gallery width and height here or by styling div that contains gallery (use pixels or percents).
so.addParam("quality", "high");
so.addParam("allowFullScreen", "true");
so.addVariable("content_path","gallery"); // Location of a folder with JPG and PNG files (relative to php script) or a link to Flickr photostream (for example "http://www.flickr.com/photos/username/" or "http://www.flickr.com/photos/username/sets/setid/").
so.addVariable("color_path","default.xml"); // Location of xml file with settings.
so.addVariable("script_path","flashgallery.php"); // Location of php script (not requred if you work with Flickr).
so.write("gallery");
</script>
<br/>
<!--
Please place this link anywhere on the page that uses Flash Gallery.
You can style it anyway you want, but do not change or delete it.
Read the license! Thanks. :-)
-->
Powered by <a href="http://www.flash-gallery.org">Flash Gallery</a>
</body>
</html>
Code: Select all
<?php
$allowed_formats = array("jpg", "jpeg", "JPG", "JPEG", "png", "PNG");
$exclude_files = array(
"_derived",
"_private",
"_vti_cnf",
"_vti_pvt",
"vti_script",
"_vti_txt"
); // add any other folders or files you wish to exclude from the gallery.
$path = array();
if(isset($_GET['file_dir'])){
$file_dir = $_GET['file_dir'];
$dir=opendir($file_dir);
while ($file=readdir($dir))
{
$ext = substr($file, strpos($file, ".")+1);
if(array_search($file, $exclude_files)===false && array_search($ext, $allowed_formats)!==false){
$f=$file_dir.'/'.$file;
$path []=$f;
}
}
closedir($dir);
}
natcasesort($path);
print '<?xml version="1.0" encoding="iso-8859-1"?>';
print '<pics';
print '>';
$directory= $_SERVER['HTTP_HOST'] .$_SERVER['PHP_SELF'];
$directory=dirname($directory);
foreach ($path as $val) print '<pic src="'.'http://'.$directory.'/'.$val.'" title="'.$val.'" />';;
print "</pics>";
?>