iFoto
My Simple Photo Gallery
Click on the left category to view photos.
Current release : 0.6 (Non-MySQL)
';
echo 'Home';
while (false !== ($folder = readdir($handle))) {
if (!is_file($folder) && $folder != '.' && $folder != '..') {
if(strlen($folder) > 20){$folder_sub = substr($folder,0,20).'...';}else{$folder_sub = $folder;}
if(get_param('dir') == $folder){$style_on_current = 'class="active"';}else{$style_on_current = '';}
echo ''.$folder_sub.'';
}
}
closedir($handle);
echo '';
}
}
function html_contents(){
if(get_param('pic')){
if(!get_param('dir')){ exit('Get dir error.
'); }
$current_image_list = readDirectory(get_param('dir'));
$total_images = count($current_image_list);
$search_key = multi_array_search(get_param('pic'), $current_image_list);
$current_key = $search_key[0];
@$curr_image = $current_image_list[$current_key];
@$prev_image = $current_image_list[$current_key-1];
@$next_image = $current_image_list[$current_key+1];
?>
$image){
?>
}
}else{
echo ' Sorry. No photos found in this directory.';
}
}else{
home_page();
}
}
function html_LastAddition(){
?>
Latest Photos Added
$image){
?>
}
}else{
echo ' Sorry. No photos submitted yet.';
}
?>
src_file = $opendir.'/'.$file;
$tis->dest_type = THUMB_JPEG;
$tis->dest_file = 'data/thumbdata_'.base64_encode($current_dir.']|['.$file . ']|[' . filemtime('gallery/'.$current_dir.'/'.$file));
$tis->max_width = 120;
$tis->max_height = 4000;
$tis->Output();
}
$file_title = substr($file,0,-4);
list($file_width, $file_height, $type, $attr) = getimagesize('gallery/'.$current_dir.'/'.$file);
if(is_file('data/thumbdata_'.base64_encode($current_dir . ']|[' . $file . ']|[' . filemtime('gallery/'.$current_dir.'/'.$file)))){
$the_thumbnail = 'data/thumbdata_'.base64_encode($current_dir . ']|[' . $file . ']|[' . filemtime('gallery/'.$current_dir.'/'.$file));
}else{
$the_thumbnail = 'img_holder.jpg';
}
if(STRIP_SORT_NUMBER AND (is_numeric(substr($file_title,0,1))) AND (substr($file_title,1,1) == '_')){
$file_title_return = substr($file_title,2);
}else{
$file_title_return = $file_title;
}
$image_list_arr[] = array('dir' => $current_dir, 'filename' => $file, 'title' => $file_title_return, 'thumb' => $the_thumbnail, 'width'=> $file_width, 'height' => $file_height, 'filesize' => filesize('gallery/'.$current_dir.'/'.$file), 'modified' => filemtime('gallery/'.$current_dir.'/'.$file));
}
}
closedir($handle);
return $image_list_arr;
}else{
return false;
}
}
function readLastAddition(){
$image_list_arr = array();
$opendir = 'data';
if ($handle = opendir($opendir)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' AND $file != '..' AND (substr($file,0,10) == 'thumbdata_')) {
$file_data_arr = explode(']|[', base64_decode(str_replace('thumbdata_','',$file)));
$image_list_arr[] = array('dir' => $file_data_arr[0], 'filename' => $file_data_arr[1], 'title' => substr($file_data_arr[1],0,-4), 'last_modify' => $file_data_arr[2]);
}
}
closedir($handle);
$image_list_arr = multi_array_sort($image_list_arr, 'last_modify');
$i = 1;
$maximum_img_at_homepage = 4;
$image_at_homepage = array();
if($image_list_arr){
foreach($image_list_arr as $image_list_key => $image_list_value){
$image_at_homepage[$image_list_key] = $image_list_value;
if($i == $maximum_img_at_homepage){ break; }
$i++;
}
}
return $image_at_homepage;
}else{
return false;
}
}
function errorMsg($error_text){
echo 'ERROR : '.$error_text.'';
exit();
}
function requirement_checker(){
if(!is_writable('data/')){ errorMsg('Oh no! You have make a boo boo...! Please make sure the "data" directory is writable. Click here for more info.'); }
if(function_exists("gd_info")){ $info=gd_info();
if(!strstr($info['GD Version'],"2.")){errorMsg('Please make sure you PHP compiled with GD2. Click here for more information.');}
}else{
errorMsg('Please make sure you PHP compiled with GD2. Click here for more information.');
}
}
function get_param($get_param){
if(@$return_filtered = $_GET[$get_param]){
$return_filtered = str_replace('<','',$return_filtered);
$return_filtered = str_replace('>','',$return_filtered);
$return_filtered = str_replace('"','',$return_filtered);
$return_filtered = str_replace("'",'',$return_filtered);
$return_filtered = str_replace(";",' ',$return_filtered);
$return_filtered = str_replace(":",' ',$return_filtered);
$return_filtered = stripslashes($return_filtered);
return $return_filtered;
}else{
return false;
}
}
function multi_array_sort($array='', $key='', $order='asc')
{
if($array AND $key){
foreach ($array as $i => $k) {
$sort_values[$i] = $array[$i][$key];
}
if($order == 'desc'){
rsort ($sort_values);
}else{
asort ($sort_values);
}
reset ($sort_values);
while (list ($arr_key, $arr_val) = each ($sort_values)) {
$sorted_arr[] = $array[$arr_key];
}
return $sorted_arr;
}else{
return false;
}
}
function multi_array_search($search_value, $the_array)
{
if (is_array($the_array))
{
foreach ($the_array as $key => $value)
{
$result = multi_array_search($search_value, $value);
if (is_array($result))
{
$return = $result;
array_unshift($return, $key);
return $return;
}
elseif ($result == true)
{
$return[] = $key;
return $return;
}
}
return false;
}
else
{
if ($search_value == $the_array)
{
return true;
}
else return false;
}
}
/* for debug purpose */
function pre($sting_to_pre = ''){
if($sting_to_pre){
echo '';
print_r($sting_to_pre);
echo '';
}
}
?>