From 3365014e2cd20a514fe49c10d348a0f1fe1e9b25 Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Wed, 22 Mar 2023 02:34:18 -0400 Subject: New upstream version 4.10.0. --- index.php | 3968 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 3968 insertions(+) create mode 100644 index.php (limited to 'index.php') diff --git a/index.php b/index.php new file mode 100644 index 0000000..b261c55 --- /dev/null +++ b/index.php @@ -0,0 +1,3968 @@ + 'Document Title', + '2#010' => 'Urgency', + '2#015' => 'Category', + '2#020' => 'Subcategories', + '2#040' => 'Special Instructions', + '2#055' => 'Creation Date', + '2#080' => 'Author Byline', + '2#085' => 'Author Title', + '2#090' => 'City', + '2#095' => 'State', + '2#101' => 'Country', + '2#103' => 'OTR', + '2#105' => 'Headline', + '2#110' => 'Source', + '2#115' => 'Photo Source', + '2#116' => 'Copyright', + '2#120' => 'Caption', + '2#122' => 'Caption Writer', + ]); + + option('COLOR_BODY_BACK', '#000000'); + option('COLOR_BODY_TEXT', '#aaaaaa'); + option('COLOR_BODY_LINK', '#ffffff'); + option('COLOR_BODY_HOVER', '#aaaaaa'); + + option('COLOR_THUMB_BORDER', '#606060'); + option('COLOR_FULLIMG_BORDER', '#ffffff'); + + option('COLOR_MARKED_BACK', '#ff0000'); + option('COLOR_MARKED_TEXT', '#000000'); + + option('COLOR_DIR_BOX_BORDER', '#505050'); + option('COLOR_DIR_BOX_BACK', '#000000'); + option('COLOR_DIR_BOX_TEXT', '#aaaaaa'); + option('COLOR_DIR_HOVER', '#ffffff'); + option('COLOR_DIR_HOVER_TEXT', '#000000'); + + option('COLOR_IMG_BOX_BORDER', '#505050'); + option('COLOR_IMG_BOX_BACK', '#202020'); + option('COLOR_IMG_BOX_TEXT', '#aaaaaa'); + option('COLOR_IMG_HOVER', '#ffffff'); + option('COLOR_IMG_HOVER_TEXT', '#000000'); + + option('COLOR_FILE_BOX_BORDER', '#404040'); + option('COLOR_FILE_BOX_BACK', '#101010'); + option('COLOR_FILE_BOX_TEXT', '#aaaaaa'); + option('COLOR_FILE_HOVER', '#ffffff'); + option('COLOR_FILE_HOVER_TEXT', '#000000'); + + option('COLOR_DESC_BOX_BORDER', '#404040'); + option('COLOR_DESC_BOX_BACK', '#202020'); + option('COLOR_DESC_BOX_TEXT', '#aaaaaa'); + + option('COLOR_MENU_BACK', '#000000'); + option('COLOR_MENU_TOP', '#303030'); + + option('COLOR_NAVBAR_BACK', '#202020'); + option('COLOR_NAVBAR_TOP', '#303030'); + + option('COLOR_BUTTON_NAV_BORDER', '#404040'); + option('COLOR_BUTTON_NAV_BACK', '#101010'); + option('COLOR_BUTTON_NAV_TEXT', '#808080'); + + option('COLOR_INFO_BACK', '#000000'); + option('COLOR_INFO_BORDER', '#606060'); + option('COLOR_INFO_TEXT', '#aaaaaa'); + + option('COLOR_INFOBOX_BORDER', '#404040'); + option('COLOR_INFOBOX_BACK', '#101010'); + + option('COLOR_BUTTON_BORDER', '#808080'); + option('COLOR_BUTTON_BACK', '#000000'); + option('COLOR_BUTTON_TEXT', '#aaaaaa'); + option('COLOR_BUTTON_BORDER_OFF', '#505050'); + option('COLOR_BUTTON_BACK_OFF', '#000000'); + option('COLOR_BUTTON_TEXT_OFF', '#505050'); + option('COLOR_BUTTON_HOVER', '#ffffff'); + option('COLOR_BUTTON_HOVER_TEXT', '#000000'); + option('COLOR_BUTTON_ON', '#aaaaaa'); + option('COLOR_BUTTON_TEXT_ON', '#000000'); + + option('COLOR_OVERLAY', '#000000'); + + // ----------- CONFIGURATION END ------------ + + + function option($name, $value) + { + if (!defined($name)) + { + define($name, $value); + } + } + + + function sfpg_array_sort(&$arr, &$arr_time, $sort_by_time, $sort_reverse) + { + if ($sort_by_time) + { + if ($sort_reverse) + { + array_multisort ($arr_time, SORT_DESC, SORT_NUMERIC, $arr); + } + else + { + array_multisort ($arr_time, SORT_ASC, SORT_NUMERIC, $arr); + } + } + else + { + if (SORT_ALL_NATURAL) + { + natcasesort ($arr); + $arr = array_values($arr); + if ($sort_reverse) + { + $arr = array_reverse ($arr); + } + } + else + { + if ($sort_reverse) + { + rsort ($arr); + } + else + { + sort ($arr); + } + } + } + } + + + function sfpg_file_size($size) + { + $sizename = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + return ($size ? round($size/pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$sizename[$i] : '0 Bytes'); + } + + + function sfpg_base64url_encode($plain) + { + $base64 = base64_encode($plain); + $base64url = strtr($base64, '+/', '-_'); + return rtrim($base64url, '='); + } + + + function sfpg_base64url_decode($base64url) + { + $base64 = strtr($base64url, '-_', '+/'); + $plain = base64_decode($base64); + return ($plain); + } + + + function sfpg_url_string($dir = '', $img = '') + { + $res = $dir.'*'.$img.'*'; + return sfpg_base64url_encode($res.hash('sha256', $res.SECURITY_PHRASE)); + } + + + function sfpg_url_decode($string) + { + $get = explode('*', sfpg_base64url_decode($string)); + if (is_array($get) and (count($get)==3) and (hash('sha256', $get[0].'*'.$get[1].'*'.SECURITY_PHRASE) === $get[2]) and (strpos(GALLERY_ROOT.$get[0].$get[1], '/../') === FALSE) and (strpos($get[0].$get[1], '\\') === FALSE)) + { + return [$get[0], $get[1]]; + } + else + { + return FALSE; + } + } + + + function block_html($str) + { + return str_replace(['&', '"', "'", '<', '>'], ['&', '"', ''', '<', '>'], $str); + } + + + function clean_html($str) + { + if (HTML_DESCRIPTIONS === TRUE) + { + return $str; + } + elseif (is_string(HTML_DESCRIPTIONS) or is_array(HTML_DESCRIPTIONS)) + { + // allowed tags + $str = strip_tags($str, HTML_DESCRIPTIONS); + return $str; + } + return block_html($str); + } + + + function sts($str, $nl_to_br=true) + { + return str_replace(["\r", "\n", "\\", "\"", "'"], ["", ($nl_to_br?"
":" "), "\\\\", "\\\"", "\'"], $str); + } + + + function sfpg_display_name($name, $show_ext) + { + $break_pos = strpos($name, SORT_DIVIDER); + if ($break_pos !== FALSE) + { + $display_name = substr($name, $break_pos + strlen(SORT_DIVIDER)); + } + else + { + $display_name = $name; + } + if (UNDERSCORE_AS_SPACE) + { + $display_name = str_replace('_', ' ', $display_name); + } + if (!$show_ext) + { + $display_name = substr($display_name, 0, strrpos($display_name, '.')); + } + return $display_name; + } + + + function sfpg_ext($file) + { + if (strrpos($file, '.') === FALSE) + { + return 'nodot'; + } + else + { + return strtolower(substr($file, strrpos($file, '.'))); + } + } + + + function sfpg_image_type($file) + { + $type = sfpg_ext($file); + if (($type == '.jpg') or ($type == '.jpeg') or ((MPO_FULL_IMAGE or MPO_STEREO_IMAGE) and ($type == '.mpo'))) + { + return 'jpeg'; + } + elseif ($type == '.png') + { + return 'png'; + } + elseif ($type == '.gif') + { + return 'gif'; + } + return FALSE; + } + + + function sfpg_mpo_image($file) + { + if (!$mpo = @file_get_contents($file)) + { + return false; + } + $offset = 0; + $marker = true; + $imgOffset = []; + $markA = chr(0xFF).chr(0xD8).chr(0xFF).chr(0xE1); + $markB = chr(0xFF).chr(0xD9).chr(0xFF).chr(0xE0); + while ($marker!==false) + { + $marker = strpos($mpo, $markA, $offset); + if ($marker===false) + { + $marker = strpos($mpo, $markB, $offset); + } + if ($marker!==false) + { + $imgOffset[] = $marker; + $offset = $marker+4; + } + } + $imgOffset[] = strlen($mpo); + if (count($imgOffset)<2) + { + return false; + } + if (count($imgOffset)>2) + { + $img_left = imagecreatefromstring(substr($mpo, $imgOffset[0], $imgOffset[1]-$imgOffset[0])); + $img_right = imagecreatefromstring(substr($mpo, $imgOffset[1], $imgOffset[2]-$imgOffset[1])); + list($mpo_stereo_width, $mpo_stereo_height) = sfpg_aspect_resize(imagesx($img_left), imagesy($img_left), MPO_STEREO_MAX_WIDTH, MPO_STEREO_MAX_HEIGHT, true); + list($mpo_full_width, $mpo_full_height) = sfpg_aspect_resize(imagesx($img_left), imagesy($img_left), MPO_FULL_MAX_WIDTH, MPO_FULL_MAX_HEIGHT, false); + $stereo_dot_space = 0; + if (MPO_STEREO_DOTS) + { + $dot_size=3; + $stereo_dot_space = 2*$dot_size+2*MPO_SPACING; + } + $stereo_align = 0; + $new_img_width = 0; + $new_img_height = 0; + $full_offset_y = 0; + if (MPO_STEREO_IMAGE) + { + $new_img_width += $mpo_stereo_width*2+MPO_SPACING; + $new_img_height += $stereo_dot_space + $mpo_stereo_height + (MPO_FULL_IMAGE ? MPO_SPACING : 0); + $full_offset_y = $mpo_stereo_height+MPO_SPACING+$stereo_dot_space; + } + $full_offset_x = round(($new_img_width-$mpo_full_width)/2); + if (MPO_FULL_IMAGE) + { + if ($mpo_full_width > $new_img_width) + { + $new_img_width = $mpo_full_width; + $stereo_align = (int)(($mpo_full_width-($mpo_stereo_width*2+MPO_SPACING))/2); + $full_offset_x = 0; + } + $new_img_height += $mpo_full_height; + } + $new_image = imagecreatetruecolor($new_img_width, $new_img_height); + $tmp_left = imagecreatetruecolor($mpo_full_width, $mpo_full_height); + imagecopyresampled($tmp_left, $img_left, 0, 0, 0, 0, $mpo_full_width, $mpo_full_height, imagesx($img_left), imagesy($img_left)); + $tmp_right = imagecreatetruecolor($mpo_full_width, $mpo_full_height); + imagecopyresampled($tmp_right, $img_right, 0, 0, 0, 0, $mpo_full_width, $mpo_full_height, imagesx($img_right), imagesy($img_right)); + if (MPO_FULL_IMAGE) + { + if (MPO_FULL_ANAGLYPH) + { + $anaglyph_image = imagecreatetruecolor($mpo_full_width, $mpo_full_height); + imagealphablending($anaglyph_image, false); + for($y=0; $y<$mpo_full_height; $y++) + { + for($x=0; $x<$mpo_full_width; $x++) + { + $left_color = imagecolorat($tmp_left, $x, $y); + $r = (int)(($left_color >> 16) & 255) * 0.299 + (($left_color >> 8) & 255) * 0.587 + (($left_color) & 255) * 0.114; + if ($r > 255) + { + $r = 255; + } + $g = (imagecolorat($tmp_right, $x, $y) >> 8) & 255; + $b = (imagecolorat($tmp_right, $x, $y)) & 255; + imagesetpixel($anaglyph_image, $x, $y, imagecolorallocate($anaglyph_image, $r, $g, $b)); + } + } + imagecopyresampled($new_image, $anaglyph_image, $full_offset_x, $full_offset_y, 0, 0, $mpo_full_width, $mpo_full_height, $mpo_full_width, $mpo_full_height); + imagedestroy($anaglyph_image); + imagedestroy($tmp_left); + imagedestroy($tmp_right); + } + else + { + imagecopyresampled($new_image, $img_left, $full_offset_x, $full_offset_y, 0, 0, $mpo_full_width, $mpo_full_height, imagesx($img_left), imagesy($img_left)); + } + } + if (MPO_STEREO_IMAGE) + { + imagecopyresampled($new_image, $img_left, $stereo_align, $stereo_dot_space, 0, 0, $mpo_stereo_width, $mpo_stereo_height, imagesx($img_left), imagesy($img_left)); + imagedestroy($img_left); + imagecopyresampled($new_image, $img_right, $stereo_align+$mpo_stereo_width+MPO_SPACING, $stereo_dot_space, 0, 0, $mpo_stereo_width, $mpo_stereo_height, imagesx($img_right), imagesy($img_right)); + imagedestroy($img_right); + $white = imagecolorallocate($new_image, 255, 255, 255); + imagefilledrectangle($new_image, $stereo_align+(int)($mpo_stereo_width/2)-3, MPO_SPACING-3, $stereo_align+(int)($mpo_stereo_width/2)+3, MPO_SPACING+3, $white); + imagefilledrectangle($new_image, $stereo_align+MPO_SPACING+(int)($mpo_stereo_width*1.5)-3, MPO_SPACING-3, $stereo_align+MPO_SPACING+(int)($mpo_stereo_width*1.5)+3, MPO_SPACING+3, $white); + } + return $new_image; + } + else + { + $image = imagecreatefromstring(substr($mpo, $imgOffset[0], $imgOffset[1]-$imgOffset[0])); + list($mpo_width, $mpo_height) = sfpg_aspect_resize(imagesx($image), imagesy($image), MPO_FULL_MAX_WIDTH, MPO_FULL_MAX_HEIGHT, false); + $new_image = imagecreatetruecolor($mpo_width, $mpo_height); + imagecopyresampled($new_image, $image, 0, 0, 0, 0, $mpo_width, $mpo_height, imagesx($image), imagesy($image)); + imagedestroy($image); + return $new_image; + } + } + + + function sfpg_aspect_resize($image_width, $image_height, $max_width, $max_height, $enlarge) + { + if (($image_width < $max_width) and ($image_height < $max_height) and !$enlarge) + { + $new_img_height = $image_height; + $new_img_width = $image_width; + } + else + { + $aspect_x = $image_width / $max_width; + $aspect_y = $image_height / $max_height; + if ($aspect_x > $aspect_y) + { + $new_img_width = $max_width; + $new_img_height = $image_height / $aspect_x; + } + else + { + $new_img_height = $max_height; + $new_img_width = $image_width / $aspect_y; + } + } + return [(int)round($new_img_width), (int)round($new_img_height)]; + } + + + function sfpg_mkdir($dir) + { + if (!is_dir($dir)) + { + mkdir($dir, 0777, TRUE); + return true; + } + return false; + } + + + function sfpg_get_dir($dir, $for_dir_info=FALSE, $for_zip=FALSE) + { + $dirs = []; + $dirs_time = []; + $images = []; + $images_time = []; + $files = []; + $files_time = []; + $misc = []; + $directory_handle = @opendir(GALLERY_ROOT.$dir); + if ($directory_handle != FALSE) + { + while(($var=readdir($directory_handle))!==false) + { + if (is_dir(GALLERY_ROOT.$dir.$var)) + { + if (($var != '.') and ($var != '..') and !in_array(strtolower($var), DIR_EXCLUDE) and !@preg_match(DIR_EXCLUDE_REGEX, $var)) + { + $dirs[] = $var; + if (DIR_SORT_BY_TIME) + { + $dirs_time[] = filemtime(GALLERY_ROOT.$dir.$var.'/.'); + } + } + } + elseif (sfpg_image_type($var)) + { + if (($var != DIR_THUMB_FILE) and !@preg_match(IMAGE_EXCLUDE_REGEX, $var)) + { + if ((DELETE_IMAGE_DAYS) and (filemtime(GALLERY_ROOT.$dir.$var)<(time()-(DELETE_IMAGE_DAYS*86400)))) + { + unlink(GALLERY_ROOT.$dir.$var); + } + else + { + $images[] = $var; + if (IMAGE_SORT_BY_TIME) + { + if (IMAGE_EXIF_TIME) + { + if ($img_info=@file_get_contents(DATA_ROOT.'info/'.$dir.$var)) + { + $spl=unserialize($img_info); + if (isset($spl['exifDate'])) + { + $images_time[]=$spl['exifDate']; + } + else + { + $images_time[]=filemtime(GALLERY_ROOT.$dir.$var); + } + } + else + { + $images_time[]=filemtime(GALLERY_ROOT.$dir.$var); + } + } + else + { + $images_time[]=filemtime(GALLERY_ROOT.$dir.$var); + } + } + } + } + } + elseif (SHOW_FILES) + { + if (!in_array(strtolower($var), FILE_EXCLUDE) and !in_array(sfpg_ext($var), FILE_EXT_EXCLUDE) and !@preg_match(FILE_EXCLUDE_REGEX, $var)) + { + $files[] = $var; + if (FILE_SORT_BY_TIME) + { + $files_time[] = filemtime(GALLERY_ROOT.$dir.$var); + } + } + } + if ((sfpg_ext($var)==DESC_EXT)or(sfpg_ext($var)==PAYPAL_EXTENSION)) + { + $misc[] = $var; + } + } + if ($for_dir_info) + { + $misc = 0; + } + if (SHOW_FILES and !($for_zip and ZIP_FILES and ZIP_FILE_THUMBS)) // removes thumbnail images from being listed as images. Unless needed for zip. + { + foreach ($files as $val) + { + $fti = array_search($val.FILE_THUMB_EXT, $images); + if ($fti !== FALSE) + { + if ($for_dir_info) + { + $misc++; + } + else + { + array_splice($images, $fti, 1); + array_splice($images_time, $fti, 1); + } + } + } + } + closedir($directory_handle); + sfpg_array_sort($dirs, $dirs_time, DIR_SORT_BY_TIME, DIR_SORT_REVERSE); + sfpg_array_sort($images, $images_time, IMAGE_SORT_BY_TIME, IMAGE_SORT_REVERSE); + sfpg_array_sort($files, $files_time, FILE_SORT_BY_TIME, FILE_SORT_REVERSE); + return [$dirs, $images, $files, $misc]; + } + else + { + if ($dir=='') + { + exit('GALLERY_ROOT is not is not accessible.'); + } + else + { + header('Location: '.$_SERVER['PHP_SELF']); + } + exit; + } + } + + + function get_files_for_zip($dir_to_zip) + { + list($dirs, $images, $files, $misc) = sfpg_get_dir($dir_to_zip,FALSE,TRUE); + $zip_list = $images; + if (ZIP_FILES) + { + $zip_list = array_merge($zip_list, $files); + } + if (ZIP_DESCRIPTIONS) + { + $zip_list = array_merge($zip_list, $misc); + } + for($i=0; $i

'. + ' '.TEXT_MOVE_TO.': '.TEXT_HOME.'/'.GALLERY.'

'. + 'OK'. + ''.TEXT_CANCEL.'

'. + ''.TEXT_HOME.''; + $dirs=explode('/',GALLERY); + $path=''; + $postDiv=''; + foreach($dirs as $dir) + { + if ($dir) + { + $path.=$dir.'/'; + echo '
'.$dir.''; + $postDiv.='
'; + } + } + $items=@scandir(GALLERY_ROOT.GALLERY); + if ($items!==false) + { + echo '
'; + foreach($items as $var) + { + if ((is_dir(GALLERY_ROOT.GALLERY.$var)) and ($var != '.') and ($var != '..')) + { + echo ''.$var.'
'; + } + } + } + echo $postDiv.'
'; + } + + + function sfpg_div_num($input) + { + $tmp = explode('/', $input); + if (count($tmp)==2) // if input contains one /, like: "1/250" + { + if(is_numeric($tmp[0]) and is_numeric($tmp[1]) and ($tmp[1]!=0)) // if both sides are numbers and $tmp[1] is not 0. + { + return $tmp[0]/$tmp[1]; + } + } + if (is_numeric($input)) + { + return $input; + } + return 0; + } + + + function sfpg_image($image_dir, $image_file, $func, $download=FALSE) + { + $image_path_file = DATA_ROOT.$func.'/'.$image_dir.$image_file; + $image_type = sfpg_image_type($image_file); + if ($func == 'image') + { + if (!file_exists($image_path_file)) + { + $image_path_file = GALLERY_ROOT.$image_dir.$image_file; + } + if ($download) + { + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename="'.$image_file.'"'); + } + else + { + header('Content-Type: image/'.$image_type); + header('Content-Disposition: filename="'.$image_file.'"'); + } + readfile($image_path_file); + exit; + } + if ($func == 'thumb') + { + if (file_exists($image_path_file)) + { + header('Content-Type: image/'.$image_type); + header('Content-Disposition: filename="'.$func.'_'.$image_file.'"'); + readfile($image_path_file); + exit; + } + else + { + $max_width = THUMB_MAX_WIDTH; + $max_height = THUMB_MAX_HEIGHT; + $enlarge = THUMB_ENLARGE; + $jpeg_quality = THUMB_JPEG_QUALITY; + $source_img = GALLERY_ROOT.$image_dir.$image_file; + $image_changed = FALSE; + if ((MPO_FULL_IMAGE or MPO_STEREO_IMAGE) and (sfpg_ext($image_file)=='.mpo')) + { + if (!$image = sfpg_mpo_image($source_img)) + { + exit; + } + $image_changed = TRUE; + } + elseif (!$image = imagecreatefromstring(file_get_contents($source_img))) + { + exit; + } + if (($func == 'thumb') and ($image_dir != ICONS_DIR)) + { + sfpg_mkdir(DATA_ROOT.'info/'.$image_dir); + $image_info = []; + if (function_exists('exif_read_data')) + { + if (SHOW_EXIF_INFO) + { + $exif_data = @exif_read_data(GALLERY_ROOT.$image_dir.$image_file, 'IFD0'); + if ($exif_data !== FALSE) + { + if(isset($exif_data['DateTimeOriginal'])) + { + $exif_time = explode(':', str_replace(' ', ':', $exif_data['DateTimeOriginal'])); + $image_info['exifDate'] = block_html(mktime($exif_time[3], $exif_time[4], $exif_time[5], $exif_time[1], $exif_time[2], $exif_time[0])); + } + if (isset($exif_data['Model'])) + { + $image_info['exifModel'] = block_html($exif_data['Model']); + } + if (isset($exif_data['ISOSpeedRatings'])) + { + $image_info['exifISOSpeedRatings'] = block_html($exif_data['ISOSpeedRatings']); + } + if(isset($exif_data['ExposureTime'])) + { + $exp_time = round(sfpg_div_num($exif_data['ExposureTime']),2); + if ($exp_time > 0.25) + { + $image_info['exifExposureTime'] = block_html($exp_time.'s'); + } + else + { + $image_info['exifExposureTime'] = block_html($exif_data['ExposureTime'].'s'); + } + } + if(isset($exif_data['FNumber'])) + { + $image_info['exifFNumber'] = block_html('f'.number_format(round(sfpg_div_num($exif_data['FNumber']),1),1)); + } + if(isset($exif_data['FocalLength'])) + { + $image_info['exifFocalLength'] = block_html(number_format(round(sfpg_div_num($exif_data['FocalLength']),1),1).'mm'); + } + if(isset($exif_data['Flash'])) + { + $image_info['exifFlash'] = block_html((($exif_data['Flash'] & 1) ? TEXT_YES : TEXT_NO)); + } + if (isset($exif_data['GPSLatitude']) and isset($exif_data['GPSLongitude'])) + { + $lat = $exif_data['GPSLatitude']; + $lng = $exif_data['GPSLongitude']; + $image_info['exifGPSLatitude'] = block_html(sfpg_div_num($lat[0])).'°'.block_html(sfpg_div_num($lat[1]).'\''.sfpg_div_num($lat[2]).'"'.@$exif_data['GPSLatitudeRef']); + $image_info['exifGPSLongitude'] = block_html(sfpg_div_num($lng[0])).'°'.block_html(sfpg_div_num($lng[1]).'\''.sfpg_div_num($lng[2]).'"'.@$exif_data['GPSLongitudeRef']); + $image_info['exifGPSLatitudeDec'] = block_html(round(((sfpg_div_num($lat[0]) + sfpg_div_num($lat[1])/60 + sfpg_div_num($lat[2])/3600)*(@$exif_data['GPSLatitudeRef']=='N'?1:-1)),12)); // limited to 12 decimals + $image_info['exifGPSLongitudeDec'] = block_html(round(((sfpg_div_num($lng[0]) + sfpg_div_num($lng[1])/60 + sfpg_div_num($lng[2])/3600)*(@$exif_data['GPSLongitudeRef']=='W'?-1:1)),12)); // limited to 12 decimals + } + } + } + if (ROTATE_IMAGES and isset($exif_data['Orientation'])) + { + $orientation = (int)$exif_data['Orientation']; + if (($orientation>1) and ($orientation<9)) + { + $image_width = imagesx($image); + $image_height = imagesy($image); + switch ($orientation) + { + case 2: + { + $rotate = @imagecreatetruecolor($image_width, $image_height); + if (LOW_IMAGE_RESAMPLE_QUALITY) + { + imagecopyresized($rotate, $image, 0, 0, $image_width-1, 0, $image_width, $image_height, -$image_width, $image_height); + } + else + { + imagecopyresampled($rotate, $image, 0, 0, $image_width-1, 0, $image_width, $image_height, -$image_width, $image_height); + } + imagedestroy($image); + $image_changed = TRUE; + break; + } + case 3: + { + $rotate = imagerotate($image, 180, 0); + imagedestroy($image); + $image_changed = TRUE; + break; + } + case 4: + { + $rotate = @imagecreatetruecolor($image_width, $image_height); + if (LOW_IMAGE_RESAMPLE_QUALITY) + { + imagecopyresized($rotate, $image, 0, 0, 0, $image_height-1, $image_width, $image_height, $image_width, -$image_height); + } + else + { + imagecopyresampled($rotate, $image, 0, 0, 0, $image_height-1, $image_width, $image_height, $image_width, -$image_height); + } + imagedestroy($image); + $image_changed = TRUE; + break; + } + case 5: + { + $rotate = imagerotate($image, 270, 0); + imagedestroy($image); + $image = $rotate; + $rotate = @imagecreatetruecolor($image_height, $image_width); + if (LOW_IMAGE_RESAMPLE_QUALITY) + { + imagecopyresized($rotate, $image, 0, 0, 0, $image_width-1, $image_height, $image_width, $image_height, -$image_width); + } + else + { + imagecopyresampled($rotate, $image, 0, 0, 0, $image_width-1, $image_height, $image_width, $image_height, -$image_width); + } + $image_changed = TRUE; + break; + } + case 6: + { + $rotate = imagerotate($image, 270, 0); + imagedestroy($image); + $image_changed = TRUE; + break; + } + case 7: + { + $rotate = imagerotate($image, 90, 0); + imagedestroy($image); + $image = $rotate; + $rotate = @imagecreatetruecolor($image_height, $image_width); + if (LOW_IMAGE_RESAMPLE_QUALITY) + { + imagecopyresized($rotate, $image, 0, 0, 0, $image_width-1, $image_height, $image_width, $image_height, -$image_width); + } + else + { + imagecopyresampled($rotate, $image, 0, 0, 0, $image_width-1, $image_height, $image_width, $image_height, -$image_width); + } + $image_changed = TRUE; + break; + } + case 8: + { + $rotate = imagerotate($image, 90, 0); + imagedestroy($image); + $image_changed = TRUE; + break; + } + } + $image = $rotate; + } + } + } + if(SHOW_IPTC_INFO) + { + $only_used_for_iptc = getimagesize(GALLERY_ROOT.$image_dir.$image_file, $info); + if (isset($info['APP13'])) + { + $iptcParsed = iptcparse($info['APP13']); + foreach(IPTC as $iptcID => $iptcText) + { + if (isset($iptcParsed[$iptcID])) + { + $image_info[$iptcID] = block_html($iptcParsed[$iptcID][0]); + } + } + } + } + if (WATERMARK) + { + $wm_file = GALLERY_ROOT.ICONS_DIR.WATERMARK; + if (file_exists($wm_file)) + { + if ($watermark = imagecreatefromstring(file_get_contents($wm_file))) + { + $image_width = imagesx($image); + $image_height = imagesy($image); + $ww = imagesx($watermark); + $wh = imagesy($watermark); + if (WATERMARK_FRACTION) + { + if ($image_width < $image_height) + { + $ww_new = round($image_width * WATERMARK_FRACTION); + } + else + { + $ww_new = round($image_height * WATERMARK_FRACTION); + } + $wh_new = round($wh * ($ww_new / $ww)); + } + else + { + $ww_new = $ww; + $wh_new = $wh; + } + imagecopyresampled ($image, $watermark, $image_width-$ww_new, $image_height-$wh_new, 0, 0, $ww_new, $wh_new, $ww, $wh); + imagedestroy($watermark); + $image_changed = TRUE; + } + } + } + if ($image_changed) + { + sfpg_mkdir(DATA_ROOT.'image/'.$image_dir); + $new_full_img = DATA_ROOT.'image/'.$image_dir.$image_file; + if ($image_type == 'jpeg') + { + imagejpeg($image, $new_full_img, IMAGE_JPEG_QUALITY); + } + elseif ($image_type == 'png') + { + imagepng($image, $new_full_img); + } + elseif ($image_type == 'gif') + { + imagegif($image, $new_full_img); + } + } + $image_info['fileMTime'] = filemtime(GALLERY_ROOT.$image_dir.$image_file); // also used for deleting data if time have changed + $image_info['fileSize'] = sfpg_file_size(filesize(GALLERY_ROOT.$image_dir.$image_file)); + $image_info['imageSizeX'] = block_html(imagesx($image)); + $image_info['imageSizeY'] = block_html(imagesy($image)); + file_put_contents(DATA_ROOT.'info/'.$image_dir.$image_file, serialize($image_info)); + } + list($new_img_width, $new_img_height) = sfpg_aspect_resize(imagesx($image), imagesy($image), $max_width, $max_height, $enlarge); + if(THUMB_SQUARE) + { + $new_img_width = $max_width; + $new_img_height = $max_width; + } + $new_image = imagecreatetruecolor($new_img_width, $new_img_height); + if(THUMB_PNG_ALPHA and ($image_type == 'png')) + { + imagealphablending($new_image, false); + imagesavealpha($new_image,true); + } + if(LOW_IMAGE_RESAMPLE_QUALITY) + { + if(THUMB_SQUARE) + { + $min_size = min(imagesx($image), imagesy($image)); + imagecopyresized($new_image, $image, 0, 0, round((imagesx($image)- $min_size)/2), 0, $new_img_width, $new_img_height, $min_size, $min_size); + } + else + { + imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_img_width, $new_img_height, imagesx($image), imagesy($image)); + } + } + else + { + if(THUMB_SQUARE) + { + $min_size = min(imagesx($image), imagesy($image)); + imagecopyresampled($new_image, $image, 0, 0, round((imagesx($image)- $min_size)/2), 0, $new_img_width, $new_img_height, $min_size, $min_size); + } + else + { + imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_img_width, $new_img_height, imagesx($image), imagesy($image)); + } + } + imagedestroy($image); + sfpg_mkdir(DATA_ROOT.$func.'/'.$image_dir); + header('Content-type: image/'.$image_type); + header('Content-Disposition: filename="'.$func.'_'.$image_file.'"'); + if ($image_type == 'jpeg') + { + imagejpeg($new_image, NULL, $jpeg_quality); + imagejpeg($new_image, $image_path_file, $jpeg_quality); + } + elseif ($image_type == 'png') + { + imagepng($new_image); + imagepng($new_image, $image_path_file); + } + elseif ($image_type == 'gif') + { + imagegif($new_image); + imagegif($new_image, $image_path_file); + } + imagedestroy($new_image); + } + } + } + + + function sfpg_dir_info($dir, $initial=TRUE) + { + list($dirs, $images, $files, $misc) = sfpg_get_dir($dir, TRUE); + if ($initial) + { + $info['dirDirs'] = count($dirs); + $info['dirImages'] = (int)(count($images)-$misc); + $info['dirFiles'] = count($files); + $info['dirTime'] = filemtime(GALLERY_ROOT.GALLERY.'.'); + } + else + { + $info = []; + } + if ((DIR_THUMB_FILE) and file_exists(GALLERY_ROOT.$dir.DIR_THUMB_FILE)) + { + $info['dirThumb'] = sfpg_url_string($dir, DIR_THUMB_FILE); + return $info; + } + if (DIR_THUMB_FROM_ICONS_DIR and file_exists(GALLERY_ROOT.ICONS_DIR.DIR_THUMB_FILE)) + { + $info['dirThumb'] = sfpg_url_string(ICONS_DIR, DIR_THUMB_FILE); + return $info; + } + if (isset($images[0])) + { + $info['dirThumb'] = sfpg_url_string($dir, $images[0]); + return $info; + } + foreach ($dirs as $subdir) // searching for dir-thumb in subdirs + { + $subresult = sfpg_dir_info($dir.$subdir.'/', FALSE); + if (isset($subresult['dirThumb'])) + { + $info['dirThumb'] = $subresult['dirThumb']; + return $info; + } + } + if ($initial and file_exists(GALLERY_ROOT.ICONS_DIR.DIR_THUMB_FILE)) + { + $info['dirThumb'] = sfpg_url_string(ICONS_DIR, DIR_THUMB_FILE); + return $info; + } + return $info; + } + + + function sfpg_set_dir_info($dir) + { + if (!sfpg_mkdir(DATA_ROOT.'info/'.$dir)) + { + sfpg_clean_data_root($dir); + } + file_put_contents(DATA_ROOT.'info/'.$dir.'_sfpg_dir', serialize(sfpg_dir_info($dir))); + } + + + function sfpg_delete($element) + { + if (is_dir($element)) + { + $items = array_diff(scandir($element),['.','..']); + foreach ($items as $item) + { + sfpg_delete($element.'/'.$item); + } + rmdir($element); + } + elseif (file_exists($element)) + { + unlink($element); + } + } + + + function sfpg_delete_from_data_root($element) + { + sfpg_delete(DATA_ROOT.'info/'.$element); + sfpg_delete(DATA_ROOT.'thumb/'.$element); + sfpg_delete(DATA_ROOT.'image/'.$element); + sfpg_delete(DATA_ROOT.'zip/'.$element); + } + + + function sfpg_clean_data_root($dir) + { + $items = array_diff(scandir(DATA_ROOT.'info/'.$dir),['.','..','_sfpg_dir']); + foreach($items as $item) + { + if (!is_dir(GALLERY_ROOT.$dir.$item) and !file_exists(GALLERY_ROOT.$dir.$item)) + { + sfpg_delete_from_data_root($dir.$item); + } + } + $path=''; + $dirs=explode('/',$dir); + foreach($dirs as $dirout) + { + if(file_exists(DATA_ROOT.'info/'.$path.'_sfpg_dir')) + { + unlink(DATA_ROOT.'info/'.$path.'_sfpg_dir'); + } + $path.=$dirout.'/'; + } + } + + + function echo_js_array($name, $id, $array, $nl_to_br=true) + { + if(is_array($array)) + { + $sep=''; + echo $name.'['.$id.'] = {'; + foreach($array as $key=>$val) + { + echo $sep.'"'.$key.'":"'.sts($val, $nl_to_br).'"'; + $sep=', '; + } + echo "};\n"; + } + } + + + function sfpg_random($nr) + { + $a='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $res=''; + for($i = 0; $i<$nr; $i++) + { + $res.=$a[mt_rand(0,strlen($a)-1)]; + } + return $res; + } + + + function sfpg_javascript() + { + global $dirs, $images, $files, $misc; + echo ""; + } + + @include(DATA_ROOT.'sp.php'); + if (!defined('SECURITY_PHRASE')) + { + sfpg_mkdir(DATA_ROOT); + file_put_contents(DATA_ROOT.'sp.php',""); + @include(DATA_ROOT.'sp.php'); + if (!defined('SECURITY_PHRASE')) + { + echo '
PHP do not have access to create files in the defined DATA_ROOT ("'.DATA_ROOT.'").
See readme.txt for DATA_ROOT description.'; + exit; + } + } + if (SECURITY_PHRASE=='') + { + echo '
The SECURITY_PHRASE in "'.DATA_ROOT.'sp.php" cannot be empty.
See readme.txt for DATA_ROOT description.'; + exit; + } + + if (PASSWORD!=='') + { + session_name('SFPG_SESSID'); + session_start(); + if (isset($_GET['cmd']) and ($_GET['cmd']=='logout')) + { + session_unset(); + header('Location: '.$_SERVER['PHP_SELF']); + exit; + } + if ((($_SESSION['sfpg_access']??FALSE)!==TRUE) or ($_SESSION['sfpg_self']!==$_SERVER['PHP_SELF'])) + { + if (isset($_POST['pw']) and ($_POST['pw']===PASSWORD)) + { + $_SESSION['sfpg_access']=TRUE; + $_SESSION['sfpg_self']=$_SERVER['PHP_SELF']; + } + else + { + header('Content-Type: text/html; charset="'.CHARSET.'"'); + echo ''. + '
'. + ''. + ''. + '
'; + session_write_close(); + exit; + } + } + session_write_close(); + } + + $get_set = FALSE; + if (isset($_GET['sfpg'])) + { + $get = sfpg_url_decode($_GET['sfpg']); + if ($get) + { + define('GALLERY', $get[0]); + define('IMAGE', $get[1]); + $get_set = TRUE; + } + } + if (!$get_set) + { + define('GALLERY', ''); + define('IMAGE', ''); + } + + if (ZIP_ENABLE and isset($_POST['zipdl'])) + { + sfpg_mkdir(DATA_ROOT.'zip'); + $zip_link='./_sfpg_zip'; + if (!is_link($zip_link)) + { + if (!symlink(realpath(DATA_ROOT.'zip'), $zip_link)) + { + echo 'Unable to create symlink for zip download.'; + exit; + } + } + if (ZIP_CACHE_DAYS !== FALSE) + { + cleanup_zip_days(time()-(ZIP_CACHE_DAYS*86400), DATA_ROOT.'zip'); + } + $files_for_zip = get_files_for_zip(GALLERY); + if (count($files_for_zip)>0) + { + sort($files_for_zip); // sorting before hash to make sure that hash function gets input in same order every time. + $zip_hash = hash('sha256', serialize($files_for_zip)); + + $zip_dir = DATA_ROOT.'zip/'.GALLERY; + if (GALLERY == '') + { + $zip_name = TEXT_ZIP_ROOT_NAME.'.zip'; + } + else + { + $from = strrpos(rtrim(GALLERY, '/'), '/'); + if ($from===FALSE) + { + $from = -1; + } + $zip_name = substr(GALLERY, $from+1, -1).'.zip'; + } + if (file_exists($zip_dir.$zip_name) and file_exists($zip_dir.$zip_name.'.hash') and ($zip_hash === file_get_contents($zip_dir.$zip_name.'.hash'))) + { + header('Location: '.$zip_link.'/'.GALLERY.$zip_name); + exit; + } + else + { + sfpg_delete($zip_dir.$zip_name); + sfpg_delete($zip_dir.$zip_name.'.hash'); + } + sfpg_mkdir($zip_dir); + file_put_contents($zip_dir.$zip_name.'.hash', $zip_hash); + + $zip = new ZipArchive(); + $zip->open($zip_dir.$zip_name, ZipArchive::CREATE | ZipArchive::OVERWRITE); + $zip_index = 0; + foreach($files_for_zip as $file) + { + $zip->addFile(realpath(GALLERY_ROOT.$file), substr($file, strlen(GALLERY))); + if (ZIP_COMPRESSION) + { + $zip->setCompressionIndex($zip_index, ZipArchive::CM_DEFLATE); + } + else + { + $zip->setCompressionIndex($zip_index, ZipArchive::CM_STORE); + } + $zip_index++; + } + if ($zip->close()) + { + header('Location: '.$zip_link.'/'.GALLERY.$zip_name); + exit; + } + echo 'Unable to create zip file.'; + exit; + } + else + { + echo TEXT_ZIP_NOTHING; + exit; + } + } + + if (isset($_GET['cmd']) and $get_set) + { + if ($_GET['cmd'] == 'thumb') + { + sfpg_image(GALLERY, IMAGE, 'thumb'); + exit; + } + + if ($_GET['cmd'] == 'image') + { + sfpg_image(GALLERY, IMAGE, 'image'); + exit; + } + + if (($_GET['cmd'] == 'dl') and TEXT_DOWNLOAD!='') + { + sfpg_image(GALLERY, IMAGE, 'image', TRUE); + exit; + } + + if (SHOW_FILES and ($_GET['cmd'] == 'file')) + { + if (preg_match("#^(/|([A-Z]:)?(\\\\|/))#i", GALLERY_ROOT)) // if GALLERY_ROOT is an absolute path + { + $download_path='./_sfpg_download'; + if (is_link($download_path)) + { + $prefix = $download_path.'/'; + } + elseif (symlink(rtrim(GALLERY_ROOT, '/'), $download_path)) + { + $prefix = $download_path.'/'; + } + else + { + echo 'Unable to access file.'; + exit; + } + } + else + { + $prefix = GALLERY_ROOT; + } + header('Location: '.$prefix.GALLERY.IMAGE); + exit; + } + } + + header('Content-Type: text/html; charset="'.CHARSET.'"'); + + if (PAYPAL_ENABLED) + { + if (isset($_GET['sold'])) + { + echo '
'.TEXT_PAYPAL_THANKS; + echo ''.TEXT_HOME.''; + exit(); + } + } + + if (ADMIN===TRUE) + { + if (isset($_POST['func'])) + { + if ($_POST['func']==='move') + { + if (isset($_POST['toFolder']) and isset($_POST['elems']) and is_array($_POST['elems']) and (count($_POST['elems']) > 0)) + { + $to_dir_array = sfpg_url_decode($_POST['toFolder']); + if (($to_dir_array!==false) and ($to_dir_array[1]==='') and is_dir(GALLERY_ROOT.$to_dir_array[0])) + { + $to_dir=GALLERY_ROOT.$to_dir_array[0]; + foreach ($_POST['elems'] as $elem) + { + $move_elem = sfpg_url_decode($elem); + if ($move_elem) + { + if (($move_elem[1]==='') and (is_dir(GALLERY_ROOT.$move_elem[0]))) + { + $slash_pos=strrpos($move_elem[0],'/',-2); + if($slash_pos!==FALSE) + { + $slash_pos+=1; + } + else + { + $slash_pos=0; + } + $dir_name = substr($move_elem[0],$slash_pos); + rename(GALLERY_ROOT.$move_elem[0], $to_dir.$dir_name); + } + else + { + $file_to_move=GALLERY_ROOT.$move_elem[0].$move_elem[1]; + rename($file_to_move, $to_dir.$move_elem[1]); + if (file_exists($file_to_move.DESC_EXT)) + { + rename($file_to_move.DESC_EXT, $to_dir.$move_elem[1].DESC_EXT); + } + if (sfpg_image_type($file_to_move) and (file_exists($file_to_move.PAYPAL_EXTENSION))) + { + rename($file_to_move.PAYPAL_EXTENSION, $to_dir.$move_elem[1].PAYPAL_EXTENSION); + } + elseif (file_exists($file_to_move.FILE_THUMB_EXT)) + { + rename($file_to_move.FILE_THUMB_EXT, $to_dir.$move_elem[1].FILE_THUMB_EXT); + } + } + } + } + } + } + } + if ($_POST['func']==='setthumb') + { + if (isset($_POST['elems'])) + { + if (count($_POST['elems']) == 1) + { + $new_thumb = sfpg_url_decode($_POST['elems'][0]); + if ($new_thumb) + { + if (sfpg_image_type($new_thumb[1])===sfpg_image_type(DIR_THUMB_FILE)) + { + copy(GALLERY_ROOT.$new_thumb[0].$new_thumb[1], GALLERY_ROOT.$new_thumb[0].DIR_THUMB_FILE); + sfpg_set_dir_info($new_thumb[0]); + } + else + { + echo TEXT_WRONG_FILETYPE.sfpg_image_type(DIR_THUMB_FILE); + exit; + } + } + } + } + else + { + if (isset($_POST['path'])) + { + $path = sfpg_url_decode($_POST['path']); + if ($path) + { + sfpg_delete(GALLERY_ROOT.$path[0].DIR_THUMB_FILE); + sfpg_set_dir_info($path[0]); + } + } + } + } + if ($_POST['func']==='delete') + { + if (isset($_POST['elems']) and is_array($_POST['elems']) and (count($_POST['elems']) > 0)) + { + foreach ($_POST['elems'] as $elem) + { + $del_elem = sfpg_url_decode($elem); + if ($del_elem) + { + $element=GALLERY_ROOT.$del_elem[0].$del_elem[1]; + sfpg_delete($element); + if (!is_dir($element)) + { + sfpg_delete($element.DESC_EXT); + if (sfpg_image_type($element)) + { + sfpg_delete($element.PAYPAL_EXTENSION); + } + else + { + sfpg_delete($element.FILE_THUMB_EXT); + } + } + } + } + } + } + if (($_POST['func']==='makedir') and (isset($_POST['dir'])) and (isset($_POST['path']))) + { + $new_dir=$_POST['dir']; + $path=$_POST['path']; + if (($new_dir!=='') and $path) + { + $path = sfpg_url_decode($path); + if ($path and ($path[1]==='')) + { + $path=GALLERY_ROOT.$path[0]; + sfpg_mkdir($path.$new_dir); + } + } + } + if (($_POST['func']==='rename') and (isset($_POST['eleToRen'])) and (isset($_POST['newName']))) + { + $newName=$_POST['newName']; + $eleToRen=$_POST['eleToRen']; + if ($newName!=='' and $eleToRen) + { + $eleToRen = sfpg_url_decode($eleToRen); + if ($eleToRen) + { + if ($eleToRen[1]!=='') + { + $newName.=((!SHOW_IMAGE_EXT and sfpg_image_type($eleToRen[1]))?sfpg_ext($eleToRen[1]):''); + if ((!file_exists(GALLERY_ROOT.$eleToRen[0].$newName)) and (!is_dir(GALLERY_ROOT.$eleToRen[0].$newName))) + { + if (sfpg_image_type($eleToRen[1])) + { + if (file_exists(GALLERY_ROOT.$eleToRen[0].$eleToRen[1].PAYPAL_EXTENSION)) + { + rename(GALLERY_ROOT.$eleToRen[0].$eleToRen[1].PAYPAL_EXTENSION, GALLERY_ROOT.$eleToRen[0].$newName.PAYPAL_EXTENSION); + } + } + elseif (file_exists(GALLERY_ROOT.$eleToRen[0].$eleToRen[1].FILE_THUMB_EXT)) + { + rename(GALLERY_ROOT.$eleToRen[0].$eleToRen[1].FILE_THUMB_EXT, GALLERY_ROOT.$eleToRen[0].$newName.FILE_THUMB_EXT); + } + if (file_exists(GALLERY_ROOT.$eleToRen[0].$eleToRen[1].DESC_EXT)) + { + rename(GALLERY_ROOT.$eleToRen[0].$eleToRen[1].DESC_EXT, GALLERY_ROOT.$eleToRen[0].$newName.DESC_EXT); + } + rename(GALLERY_ROOT.$eleToRen[0].$eleToRen[1], GALLERY_ROOT.$eleToRen[0].$newName); + } + } + else + { + $oldPath=GALLERY_ROOT.$eleToRen[0]; + $oldPath=rtrim($oldPath,'/'); + $newPath = substr($oldPath, 0, strrpos($oldPath, '/')+1).$newName; + if ((!file_exists($newPath)) and (!is_dir($newPath))) + { + rename(GALLERY_ROOT.$eleToRen[0], $newPath); + } + } + } + } + } + if ($_POST['func']==='desc') + { + $action=@$_POST['action']; + $text=@$_POST['text']; + $ele=@$_POST['ele']; + if (($action==='del') or ($text==='')) + { + $eleWd = sfpg_url_decode($ele); + if ($eleWd) + { + $element=GALLERY_ROOT.$eleWd[0].$eleWd[1]; + if (is_dir($element)) + { + sfpg_delete($element.DIR_DESC_FILE); + } + else + { + sfpg_delete($element.DESC_EXT); + } + } + } + elseif ($action==='save') + { + $eleWd = sfpg_url_decode($ele); + if ($eleWd) + { + $element=GALLERY_ROOT.$eleWd[0].$eleWd[1]; + if (is_dir($element)) + { + $element.=DIR_DESC_FILE; + } + else + { + $element.=DESC_EXT; + } + file_put_contents($element,$text); + } + } + } + if ($_POST['func']==='sell') + { + $action=$_POST['action']; + $ele=$_POST['ele']; + if ($action==='del') + { + $eleWd = sfpg_url_decode($ele); + if ($eleWd) + { + sfpg_delete(GALLERY_ROOT.$eleWd[0].$eleWd[1].PAYPAL_EXTENSION); + } + } + elseif ($action==='save') + { + $eleWd = sfpg_url_decode($ele); + if ($eleWd) + { + file_put_contents(GALLERY_ROOT.$eleWd[0].$eleWd[1].PAYPAL_EXTENSION,$_POST['ePrice']."\r\n".$_POST['eStatus']."\r\n".$_POST['eIdent']); + } + } + } + if ($_POST['func']==='upload') + { + if (isset($_FILES['ulele'])) + { + $nrUlEle=count($_FILES['ulele']['name']); + for ($i=0; $i<$nrUlEle; $i++) + { + if ($_FILES['ulele']['error'][$i]===0) + { + move_uploaded_file($_FILES['ulele']['tmp_name'][$i],GALLERY_ROOT.GALLERY.$_FILES['ulele']['name'][$i]); + } + } + } + } + } + if (isset($_GET['cmd']) and ($_GET['cmd'] == 'dirs')) + { + sfpg_browse_dirs(); + exit; + } + } + + + list($dirs, $images, $files, $misc) = sfpg_get_dir(GALLERY); + echo ''.TEXT_GALLERY_NAME.''; + sfpg_javascript(); + echo ''; + + if (PAYPAL_ENABLED and $get_set and (@$_GET['cmd'] == 'buy') and IMAGE!='') + { + $sell=@file(GALLERY_ROOT.GALLERY.IMAGE.PAYPAL_EXTENSION,FILE_IGNORE_NEW_LINES); + if (($sell==false) or ($sell[1]!=1)) + { + echo '
'.TEXT_PAYPAL_OUT_BACK.''; + } + else + { + echo ''. + '
'.TEXT_PAYPAL_REDIRECT. + '
'. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + '
'. + ''; + } + } + else + { + echo ''. + '
'. + ''. + ''. + ''. + '
'. + '
'. + '
'. + ''. + '
'. + '
'. + '
'. + '
'. + '
'. + '
'. + '
'. + ''; + if (ADMIN===TRUE) + { + echo'
'; + echo'
'; + } + echo'
'. + '
'. + '
'. + ''; + } + echo ''; +?> \ No newline at end of file -- cgit v1.2.3