# Copyright (c) 2002 Sandino Araico Sánchez /* This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ # Changelog: # 2002-01-25 Tony J. White tjw@tjw.org - DirectoryMediaIndex (dmi) 1.2 # 2002-08-29 Sandino Araico Sánchez # extracted core functions from dmi-lib # 2002-09-08 Sandino Araico Sánchez - Use HOPP # 2002-09-09 Sandino Araico Sánchez - Use dmi-thumb if(!defined('__DMI_CORE__')) { define('__DMI_CORE__',1); //**********************************************************************/ include 'dmi-autoconf.inc'; include 'dmi-lib.inc'; include 'dmi-thumb.inc'; include 'hopp.conf.inc.php'; include __HOPP_INCLUDE_PATH.'template/template-basic.inc'; //**********************************************************************/ // this function is the replacement for /bin/find to make things a // little safer and to possibly allow windows portability function getListing() { if(!is_dir(__DMI_PHOTO_DIR)) { s_log_error(__DMI_PHOTO_DIR." is not a directory!"); return 0; } $dir_handle = opendir(__DMI_PHOTO_DIR); while($file = readdir($dir_handle)) { if($file == ".." || $file == ".") continue; $full_file = __DMI_PHOTO_DIR."/".$file; s_log("full_file: $full_file"); $img_info = @getImageSize($full_file); if(is_array($img_info)) { $img_info['title']=getImageTitle($full_file); $img_info['ctime']=filectime ($full_file); $img_info['full_file']=$full_file; $img_infos[] = $img_info; $files[] = $file; $thumb_name=__DMI_THUMBS_DIR .stripExtension($file)."_thumb" .getExtension($img_info[2]); $thumb_info = @getImageSize($thumb_name); s_log("thumb_name: $thumb_name"); if(is_array($thumb_info)) { foreach($thumb_info as $key => $value) s_log("key: $key\tvalue: $value"); $thumb_infos[] = $thumb_info; } else { if(!defined('_H_CACHE_NO_STORE')) define('_H_CACHE_NO_STORE',1); $thumb_infos[] = ""; } } elseif(is_mpeg_video($file)) { $files[] = $file; $thumb_info = @getImageSize(__DMI_THUMBS_DIR .stripExtension($file)."_thumb.gif"); if(is_array($thumb_info)) $thumb_infos[] = $thumb_info; else $thumb_infos[] = ""; } $img_info = ""; $thumb_info = ""; } $sort_infos=getSortInfos($img_infos); return array($files, $thumb_infos, $img_infos, $sort_infos); } function getTableHead($numfiles,$FIRST,$COLS,$AREA, $template_prefix='fotos') { global $PHP_SELF; if($FIRST==0) $previous=''; else { $prev_last=($AREA>$numfiles)?$numfiles:$AREA; $prev_last=$prev_last==1?"":" - $prev_last"; //$previous="1$prev_last << "; $replace=array( '###FIRST_URL###' => $PHP_SELF, '###FIRST_NAME###' => "1$prev_last" ); $previous=h_template_get_parsed_file("$template_prefix-first", $replace); if($FIRST>$AREA) { $prev_first=$FIRST-$AREA; $prev_first_num=$prev_first+1; $prev_first_num=$prev_first_num==$FIRST?"":"$prev_first_num - "; //$previous.="$prev_first_num$FIRST < "; $replace=array( '###PREV_URL###' => "$PHP_SELF?FIRST=$prev_first", '###PREV_NAME###' => "$prev_first_num$FIRST" ); $previous.=h_template_get_parsed_file("$template_prefix-previous", $replace); } else if(DMI_NAV_SHOW_EDGES) { $replace=array( '###PREV_URL###' => $PHP_SELF, '###PREV_NAME###' => "1$prev_last" ); $previous.=h_template_get_parsed_file("$template_prefix-previous", $replace); } } $LAST=$FIRST+$AREA; #s_log("FIRST: $FIRST\tLAST: $LAST\tAREA: $AREA\tnumfiles: $numfiles"); //$LAST=$LAST>$numfiles?$numfiles:$LAST; if($LAST<$numfiles) { $next_last=$LAST+$AREA; if($next_last<$numfiles) { $next_first_num=$LAST+1; $next_first_num=$next_first_num==$next_last?'':"$next_first_num - "; //$next=" > $next_first_num$next_last"; $replace=array( '###NEXT_URL###' => "$PHP_SELF?FIRST=$LAST", '###NEXT_NAME###' => "$next_first_num$next_last" ); $next=h_template_get_parsed_file("$template_prefix-next", $replace); if($numfiles-$next_last>$AREA) $next_last=$numfiles-$AREA; } else { $next_last=$LAST; if(DMI_NAV_SHOW_EDGES) { $last_first_num=$next_last+1; $last_first_num=$last_first_num==$numfiles?'':"$last_first_num - "; $replace=array( '###NEXT_URL###' => "$PHP_SELF?FIRST=$next_last", '###NEXT_NAME###' => "$last_first_num$numfiles" ); $next=h_template_get_parsed_file("$template_prefix-next", $replace); } } $last_first_num=$next_last+1; $last_first_num=$last_first_num==$numfiles?'':"$last_first_num - "; //$next.=" >> $last_first_num$numfiles"; $replace=array( '###LAST_URL###' => "$PHP_SELF?FIRST=$next_last", '###LAST_NAME###' => "$last_first_num$numfiles" ); $next.=h_template_get_parsed_file("$template_prefix-last", $replace); } else { $LAST=$numfiles; $next=''; } if(empty($previous)&&empty($next)) return; $first_num=$FIRST+1; if(defined('__DMI_BIG')) { $replace=array( '###CENT_URL###' => __DMI_SCRIPT."?FIRST=$FIRST", '###CENT_NAME###' => __DMI_THUMB_LINK ); $center=h_template_get_parsed_file("$template_prefix-center-big", $replace); } else { $replace=array( '###CENT_NAME###' => "$first_num - $LAST" ); $center=h_template_get_parsed_file("$template_prefix-center", $replace); } $replace=array( '###PREV###' => $previous, '###CENT###' => $center, '###NEXT###' => $next ); if(defined('__DMI_BIG')) $return=h_template_get_parsed_file("$template_prefix-table_head-big", $replace); else $return=h_template_get_parsed_file("$template_prefix-table_head", $replace); return $return; } //**********************************************************************/ } // __DMI_CORE__ ?>