Topic: Question gallery
Hi I am trying to create a gallery and I have this data:
This would be what generates the gallery locate in admin/themes/default
<?php
class gallery {
var $files = array();
var $path;
function loadFolder($path){
$this->path = $path;
//---Save a fix all files in directory
$folder = opendir($this->path);
while ($fil = readdir($folder)) {
//---If not a dir
if(!is_dir($fil)){
$arr = explode('.', $fil);
if(count($arr) > 1){
//---Save the names
$this->files[] = $fil;
}
}
}
//---Close dir
closedir($folder);
//---Sort alphabetically arrangement
sort($this->files);
}
function show($area = 500, $width = 100, $space = 10){
//---Create the gallery with the names of all files
$total = count($this->files);
$cont = 0;
echo '<div name="xx" style="width:'.$area.'px">';
//---Locate the thumbnails
for($i = 0; $i < $total; $i++){
echo '<div style="width:'.$width.'px; float:left; padding-right:'.$space.'px; padding-bottom:'.$space.'px;">
<a href="'.$this->path.'/'.$this->files[$i].'" rel="lightbox">
<img src="'.$this->path.'/'.$this->files[$i].'" width="'.$width.'" height="'.$width.'" />
</a>
</div>';
}
echo '</div>';
}
}
?>And this would call
<?php
include_once('admin/themes/default/assets/gallery.php'); // gallery file
$mygallery = new gallery();
$mygallery->loadFolder('public/uploads/theme-photos'); // gallery folder
$mygallery->show(960, 300, 10); // 960 content 300 photos and 10 margin
?>Preview
this is correct or would have serious security problems?
