';
if (is_array($serendipity['POST']['plugin']['exifdata'])) {
//create new array
$exif_array = array();
foreach($serendipity['POST']['plugin']['exifdata'] as $key => $value) {
$exif_array[$key] = $key.'-'.$value;
}
//build new optionstring and save it
$newexifstring = implode(',', array_values($exif_array));
$this->set_config('exif_data', $newexifstring);
//break down the array and rebuild for immediate recycling on the page
foreach($exif_array as $key => $value) {
list($newkey, $newvalue) = explode('-', $value);
$res1_exif_array[] = $newkey;
$res2_exif_array[] = $newvalue;
}
$exif_array = array_combine($res1_exif_array, $res2_exif_array);
} else {
//get the optionstring
$exifsettings = $this->get_config('exif_data','Copyright Notice-no,Camera Make-no,Camera Model-no,Orientation-no,Resolution Unit-no,X Resolution-no,Y Resolution-no,Date and Time-no,YCbCr Positioning-no,Exposure Time-no,Aperture-no,Exposure Program-no,ISO-no,Exif Version-no,Date (Original)-no,Date (Digitized)-no,APEX Exposure Bias-no,APEX Max Aperture-no,Metering Mode-no,Light Source-no,Flash-no,FocalLength-no,User Comment-no,FlashPix Version-no,Colour Space-no,Pixel X Dimension-no,Pixel Y Dimension-no,File Source-no,Special Processing-no,Exposure Mode-no,White Balance-no,Digital Zoom Ratio-no,Scene Capture Type-no,Gain Control-no,Contrast-no,Saturation-no,Sharpness-no,Components Config-no');
if(!$exifsettings) {
//return empty array if invalid or non-existant
$exifsettings = array();
$selector .= '
An error occured. Your website will function AS NORMAL. But EXIF tags cannot be shown.
Error: $this->get_config(\'exif_data\') is not fetched from the database properly.
Please contact support at http://www.s9y.org/forums/.
';
} else {
//split the string into options
$exifstring = explode(',', $exifsettings);
//split the options into name and value
foreach($exifstring as $key => $value) {
$display = explode('-', $exifstring[$key]);
$exif_array[$display[0]] = $display[1];
}
}
}
//output options
foreach($exif_array as $key => $value) {
$selector .= '
'.$key.'
';
$selector .= '
';
}
$selector .= '
';
return $selector;
}
function event_hook($event, &$bag, &$eventData, $addData = null) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'entry_display':
if ($this->selected()) {
if (is_array($eventData)) {
$eventData['clean_page'] = true; // This is important to not display an entry list!
} else {
$eventData = array('clean_page' => true);
}
}
return true;
break;
case 'entries_header':
if ($this->selected()) {
$this->show();
}
return true;
break;
case 'css':
$out = serendipity_getTemplateFile('serendipity_event_usergallery.css', 'serendipityPath');
if ($out && $out != 'serendipity_event_usergallery.css') {
$eventData .= file_get_contents($out);
} else {
$eventData .= file_get_contents(dirname(__FILE__) . '/serendipity_event_usergallery.css');
}
return true;
break;
case 'frontend_configure':
if (isset($_REQUEST['gallery'])) {
// Disallow RSS-caching, because the entry age that is used for caching does not apply here.
$_GET['nocache'] = $_REQUEST['nocache'] = true;
// We need to set this variable to circumvent FeedBurner relocation
$_GET['type'] = 'comments';
}
return true;
break;
case 'frontend_rss':
$this->showRSS($eventData);
return true;
break;
case 'genpage':
$args = implode('/', serendipity_getUriArguments($eventData, true));
if ((empty($args) || trim($args) == $serendipity['indexFile']) && empty($serendipity['GET']['subpage'])) {
if ($this->get_config('frontpage','no') == 'yes') {
$serendipity['GET']['subpage'] = $this->get_config('subpage');
}
}
if ($serendipity['rewrite'] != 'none') {
$nice_url = $serendipity['serendipityHTTPPath'] . $args;
} else {
$nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
}
if (empty($serendipity['GET']['subpage'])) {
$serendipity['GET']['subpage'] = $nice_url;
}
if ($this->selected()) {
if ($this->get_config('base_directory') == 'gallery') {
// this is to avoid having the word "gallery" as blog title
$serendipity['head_title'] = preg_replace('@[^a-z0-9]@i', ' ',$this->get_config('title'));
} else {
$serendipity['head_title'] = preg_replace('@[^a-z0-9]@i', ' ',$this->get_config('base_directory'));
}
$serendipity['head_subtitle'] = $serendipity['blogTitle'];
}
return true;
break;
default:
return false;
break;
}
}
}
function generate_content(&$title) {
$title = $this->get_config('title', PLUGIN_EVENT_USERGALLERY_TITLE);
}
function show() {
global $serendipity;
if (!headers_sent()) {
header('HTTP/1.0 200');
header('Status: 200');
}
if (!is_object($serendipity['smarty'])) {
serendipity_smarty_init();
}
//I hate to do this, but there is a condition between 1.0 and 1.1.beta3 which could result in data loss
if (preg_match('@(1\.1\-alpha|1\.1\-beta1|1\.1\-beta2)@i', $serendipity['version'])) {
echo "You are running beta software (Serendipity version". $serendipity['version'].")! The use of this version with the Usergallery plugin could result of dataloss! Please update to 1.1-beta3 minimium to use the Usergallery plugin.";
return;
}
$serendipity['smarty']->assign('staticpage_pagetitle', preg_replace('@[^a-z0-9]@i', '_',$this->get_config('base_directory')));
$serendipity['smarty']->assign('const', array('filesize' => PLUGIN_EVENT_USERGALLERY_FILESIZE,
'filename' => PLUGIN_EVENT_USERGALLERY_FILENAME,
'dimension' => PLUGIN_EVENT_USERGALLERY_DIMENSION,
'uponelevel' => PLUGIN_EVENT_USERGALLERY_UPONELEVEL,
'back' => PLUGIN_EVENT_USERGALLERY_BACK,
'previous' => PLUGIN_EVENT_USERGALLERY_PREVIOUS,
'next' => PLUGIN_EVENT_USERGALLERY_NEXT,
'PREVIOUS_PAGE' => PREVIOUS_PAGE,
'NEXT_PAGE' => NEXT_PAGE)
);
$sub_page = $this->get_config('subpage');
$permalink = $this->get_config('permalink');
$serendipity['smarty']->assign('plugin_usergallery_httppath',$serendipity['rewrite'] != 'none'
? $permalink
: $serendipity['indexFile'] . '?serendipity[subpage]='.$sub_page);
$serendipity['smarty']->assign('plugin_usergallery_httppath_extend',$serendipity['rewrite'] != 'none'
? $permalink.'?'
: $serendipity['indexFile'] . '?serendipity[subpage]='.$sub_page.'&');
//Can't trust $serendipity['GET'] on all servers.... so we build it ourselves from subpage
if ($serendipity['rewrite'] != 'none') {
$uri_parts = explode('?', str_replace('&', '&', $serendipity['GET']['subpage']));
$parts = explode('&', $uri_parts[1]);
if (count($parts) > 1) {
foreach($parts as $key => $value) {
$val = explode('=', $value);
$val0 = str_replace('serendipity[','',$val[0]);
if ($val[0] == $val0) {
$_GET[$val[0]] = $val[1];
} else {
$val0 = str_replace(']','',$val0);
$serendipity['GET'][$val0] = $val[1];
}
}
} else {
$val = explode('=', $parts[0]);
$val0 = str_replace('serendipity[','',$val[0]);
if ($val[0] == $val0) {
$_GET[$val[0]] = $val[1];
} else {
$val0 = str_replace(']','',$val0);
$serendipity['GET'][$val0] = $val[1];
}
}
}
if (version_compare($serendipity['version'],"1.1.beta3") >= 0) {
switch ($this->get_config("image_order")) {
case 'nameacs':
$orderby= 'i.name';
$order= 'ASC';
break;
case 'namedesc':
$orderby= 'i.name';
$order= 'DESC';
break;
case 'dateacs':
$orderby= 'i.date';
$order= 'ASC';
break;
case 'datedesc':
$orderby= 'i.date';
$order= 'DESC';
break;
}
} else {
switch ($this->get_config("image_order")) {
case 'nameacs':
$orderby= 'name';
$order= 'ASC';
break;
case 'namedesc':
$orderby= 'name';
$order= 'DESC';
break;
case 'dateacs':
$orderby= 'date';
$order= 'ASC';
break;
case 'datedesc':
$orderby= 'date';
$order= 'DESC';
break;
}
}
if (isset($serendipity['GET']['image'])) {
$this->displayImage($serendipity['GET']['image'],$orderby,$order);
} else {
$num_cols = $this->get_config('num_cols');
$base_directory = $this->get_config('base_directory');
if ($this->get_config('style') == "thumbpage") {
$images_per_page = $this->get_config('images_per_page');
$display_dir_tree = $this->get_config('display_dir_tree','no');
$show_1lvl_sub = $this->get_config('show_1lvl_sub','no');;
$dir_list = $this->get_config('dir_list');
$num_cols = $this->get_config('num_cols');
$permitted_gallery = false;
if ($base_directory == 'gallery') {
$limit_directory = '';
} else {
$limit_directory = $base_directory;
}
$limit_images_directory = $limit_directory;
$limit_output = $limit_directory;
$serendipity['smarty']->assign('plugin_usergallery_currentgal','');
$serendipity['smarty']->assign('plugin_usergallery_uppath','');
$serendipity['smarty']->assign('plugin_usergallery_toplevel','yes');
//Let's get a directory listing that has all our ACLs applied already!
if (version_compare($serendipity['version'],"1.1.beta3") >= 0) {
$directories_temp = serendipity_traversePath($serendipity['serendipityPath'].$serendipity['uploadPath'],$limit_directory,true,NULL,1, NULL,"read",NULL);
} else {
$directories_temp = serendipity_traversePath($serendipity['serendipityPath'].$serendipity['uploadPath'],$limit_directory);
}
//Check to see if we are calling a gallery directly
if (isset($_GET['gallery']) && $_GET['gallery'] != '') {
//replace weird characters. Was more important before we used the database.
$getpathtemp = str_replace("//","/",str_replace("..","",urldecode ($_GET['gallery'])));
//Ok, let's check the out directory is actually in the returned directories.
if (is_array($directories_temp)) {
foreach($directories_temp AS $f => $dir) {
if ($getpathtemp == $dir['relpath']) {
//yay! We have access to the directory.
$permitted_gallery = true;
break;
}
}
}
//If we have a matching directory, let's set the gallery up.
if ($permitted_gallery) {
$limit_images_directory = $getpathtemp;
$temp_array = explode('/',$getpathtemp);
array_pop($temp_array);
$limit_output = array_pop($temp_array);
if ($display_dir_tree == 'no' ) {
$up_path = implode('/',$temp_array);
if ($up_path != "") {$up_path = $up_path."/";}
}
$serendipity['smarty']->assign('plugin_usergallery_currentgal',$getpathtemp);
$serendipity['smarty']->assign('plugin_usergallery_uppath',$up_path);
$serendipity['smarty']->assign('plugin_usergallery_toplevel','no');
}
} else {
//We weren't calling a gallery directory, so it is set up in the configuration. If it is the base 'uploads' directory there are never any permissions on it.
if (($limit_images_directory != '') && (version_compare($serendipity['version'],"1.1.beta3") >= 0)) {
$perm_test_array = array ( array ( 'name'=>str_replace("/","", $limit_images_directory),'depth'=>1,'relpath'=> $limit_images_directory,'directory'=>1));
if (serendipity_directoryACL($perm_test_array, 'read')) {
$permitted_gallery = true;
}
} else {
$permitted_gallery = true;
}
}
$query = "SELECT path, count(id) FROM {$serendipity['dbPrefix']}images GROUP BY path";
$rs = serendipity_db_query($query, false, 'assoc');
if (is_array($rs)) {
foreach($rs AS $f => $record) {
if ($limit_directory != '') {
$temp_count = strlen($limit_directory);
if (strcmp(substr($record['path'],0,$temp_count),$limit_directory) == 0) {
$temp_filecount[$record['path']] = $record['count(id)'];
}
} else {
$temp_filecount[$record['path']] = $record['count(id)'];
}
}
}
if ($dir_list=='yes') {
if ($display_dir_tree == 'yes') {
if (!isset($temp_filecount[$limit_directory])) {
$temp_filecount[$limit_directory] = '0';
}
$serendipity['smarty']->assign('plugin_usergallery_maindir_filecount', $temp_filecount[$limit_directory]);
} else {
if ($up_path == '') {
$temp_filecount[$up_path] = $temp_filecount[$limit_directory];
}
if (!isset($temp_filecount[$up_path])) {
$temp_filecount[$up_path] = '0';
}
$serendipity['smarty']->assign('plugin_usergallery_maindir_filecount', $temp_filecount[$up_path]);
}
}
if (is_array($directories_temp)) {
if (version_compare($serendipity['version'],"1.1.beta3") >= 0) {
usort($directories_temp, 'serendipity_sortPath');
}
foreach($directories_temp AS $f => $dir) {
$directory = $dir['relpath'];
$dir['filecount'] = $temp_filecount[$directory];
if (isset($dir['depth'])) {$dir['pxdepth'] = $dir['depth'] * $this->get_config('dir_tab', 10); }
if ($dir['filecount'] == '') {$dir['filecount'] = 0; }
if ($display_dir_tree == 'yes' ) {
$directories[$dir['relpath']] = $dir;
} else {
if ($show_1lvl_sub == 'yes') {
$temp_count = strlen($limit_images_directory);
if (strcmp(substr($directory,0,$temp_count),$limit_images_directory) == 0 && $directory!=$limit_images_directory) {
$full_length = strlen($directory);
if (substr_count(substr($directory,$temp_count,$full_length),'/') == 1) {
$directories[$dir['relpath']] = $dir;
} else {
$temp_count = $temp_count + 1 + strpos(substr($directory,$temp_count,$full_length),'/');
$directories[substr($directory,0,$temp_count)]['filecount'] = $directories[substr($directory,0,$temp_count)]['filecount'] + $dir['filecount'];
}
}
} else {
$temp_count = strlen($limit_images_directory);
if (strcmp(substr($directory,0,$temp_count),$limit_images_directory) == 0 && $directory !=$limit_images_directory) {
$directories[$directory] = $dir;
}
}
}
}
}
$serendipity['smarty']->assign('plugin_usergallery_subdirectories', $directories);
$lower_limit = 0;
$showpage = false;
if ($images_per_page != 0 && $permitted_gallery) {
$showpage = true;
$total_count = $temp_filecount[$limit_images_directory];
if ($total_count <= $images_per_page ) {
$showpage = false;
}
if ($showpage) {
if (isset($_GET['page']) && $_GET['page'] != '') {
$current_page = intval($_GET['page']);
} else {
$current_page = 1;
}
$total_pages = ceil($total_count/$images_per_page);
$previous_page = $current_page-1;
if ($previous_page == 0) {
$lower_limit = 0;
} else {
$lower_limit = ($previous_page * $images_per_page);
}
}
}
$serendipity['smarty']->assign(
array(
'plugin_usergallery_pagination' => $showpage,
'plugin_usergallery_total_count' => $total_count,
'plugin_usergallery_total_pages' => $total_pages,
'plugin_usergallery_current_page' => $current_page,
'plugin_usergallery_next_page' => $current_page+1,
'plugin_usergallery_previous_page' => $current_page-1
)
);
if (version_compare($serendipity['version'],"1.1.beta3") >= 0) {
if ($this->get_config('image_strict') == 'yes') {
$images = serendipity_fetchImagesFromDatabase($lower_limit, $images_per_page, $total, $orderby, $order, $limit_images_directory,'','', array(), true);
} else {
$images = serendipity_fetchImagesFromDatabase($lower_limit, $images_per_page, $total, $orderby, $order, $limit_images_directory);
}
} else {
if ($this->get_config('image_strict') == 'yes') {
$images = $this->usergallery_showimages( $lower_limit, $images_per_page, $orderby, $order, $limit_images_directory);
} else {
$images = serendipity_fetchImagesFromDatabase($lower_limit, $images_per_page, $total, $orderby, $order, $limit_images_directory);
}
}
if (is_array($images)) {
foreach($images AS $f => $image) {
$is_image = serendipity_isImage($image);
if ($is_image) {
$image['link'] = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $image['path'] . $image['name'] . '.' . $image['thumbnail_name'] . '.' . $image['extension'];
$image['dimension'] = $image['dimensions_width'].'x'.$image['dimensions_height'];
$image['isimage'] = true;
} else {
$image['isimage'] = false;
$image['link'] = serendipity_getTemplateFile('admin/img/mime_unknown.png');
}
$image['fullimage'] = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $image['path'] . $image['name'] . '.' . $image['extension'];
$image['filesize'] = round($image['size']/1024);
$image['popupwidth'] = ($is_image ? ($image['dimensions_width'] + 20) : 600);
$image['popupheight'] = ($is_image ? ($image['dimensions_height'] + 20) : 500);
$process_images[$image['name']] = $image;
}
}
$gallery_array = explode('/',$up_path);
foreach($gallery_array AS $f => $gallery) {
$gallery_path = $gallery_path.$gallery."/";
if ($gallery_path != $base_directory ) {
$path_array[$gallery]['path'] = $gallery_path;
$path_array[$gallery]['name'] = $gallery;
}
}
unset($path_array['']);
if ($limit_output == $base_directory) {
$limit_output = '';
}
$serendipity['smarty']->assign(
array(
'plugin_usergallery_title' => $this->get_config('title'),
'plugin_usergallery_cols' => $num_cols,
'plugin_usergallery_preface' => $this->get_config('intro'),
'plugin_usergallery_fixed_width' => $this->get_config('fixed_width'),
'plugin_usergallery_image_display' => $this->get_config('image_display'),
'plugin_usergallery_gallery_breadcrumb' => $path_array,
'plugin_usergallery_dir_list' => $dir_list,
'plugin_usergallery_display_dir_tree'=> $display_dir_tree,
'plugin_usergallery_colwidth' => round((10/$num_cols*10)-6,2),
'plugin_usergallery_limit_directory' => preg_replace('@[^a-z0-9]@i', ' ',$limit_output),
'plugin_usergallery_images' => $process_images
)
);
$tfile = serendipity_getTemplateFile('plugin_usergallery.tpl', 'serendipityPath');
if (!$tfile || $tfile == 'plugin_usergallery.tpl') {
$tfile = dirname(__FILE__) . '/plugin_usergallery.tpl';
}
$inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY];
$serendipity['smarty']->security_settings[INCLUDE_ANY] = true;
$content = $serendipity['smarty']->fetch('file:'. $tfile);
$serendipity['smarty']->security_settings[INCLUDE_ANY] = $inclusion;
echo $content;
} else {
$add_url = '?serendipity[subpage]='.$this->get_config('subpage');
if (version_compare($serendipity['version'], '0.9') >= 0) {
if ($base_directory == 'gallery') {
$limit_directory = '';
} else {
$limit_directory = $base_directory;
}
serendipity_displayImageList(
isset($serendipity['GET']['page']) ? $serendipity['GET']['page'] : 1,
$num_cols,
false,
$add_url,
false,
$limit_directory
);
} else {
serendipity_displayImageList(
isset($serendipity['GET']['page']) ? $serendipity['GET']['page'] : 1,
$num_cols,
false,
$add_url,
false
);
}
}
}
}
function setResData($res, $unit) {
$dir_arr = explode(' ', $res);
$dir_arr[1] = trim($dir_arr[1], '()');
$res_unit = rtrim($unit, 'es');
$exif_res = $dir_arr[1].' '.$dir_arr[2].' '.$dir_arr[3].' '.$res_unit;
return($exif_res);
}
function changeExifDate($date) {
$dt_arr = explode(' ', $date);
$date_arr = explode(':', $dt_arr[0]);
$time_arr = explode(':', $dt_arr[1]);
$year = $date_arr[0];
$month = $date_arr[1];
$day = $date_arr[2];
$hour = $time_arr[0];
$minute = $time_arr[1];
$second = $time_arr[2];
$timestamp = mktime($hour, $minute, $second, $month, $day, $year);
if ($timestamp != -1) {
$date_str = date('M j Y H:i:s \G\M\T O', $timestamp);
} else {
$date_str = 'Unknown';
}
$exif_date = $date_str;
return($exif_date);
}
function getExifTags($path, $name, $type) {
$exif_data = array();
// Display additonal exif information if allowed.
$JPEG_TOOLKIT = $serendipity['baseURL'].'plugins/serendipity_event_usergallery/JPEG_TOOLKIT/';
if(is_file($JPEG_TOOLKIT.'EXIF.php')) {
include_once $JPEG_TOOLKIT.'EXIF.php';
if (strtolower($type) == 'jpeg' || strtolower($type) == 'jpg') {
$filename = $name.'.'.$type;
if ($exif = get_EXIF_JPEG($path.$filename)) {
$exif_arr_num_1 = array(116 => 'Copyright Notice',
271 => 'Camera Make',
272 => 'Camera Model',
274 => 'Orientation',
296 => 'Resolution Unit',
282 => 'X Resolution',
283 => 'Y Resolution',
306 => 'Date and Time',
531 => 'YCbCr Positioning',
34665 => '');
$exif_arr_num_2 = array(33434 => 'Exposure Time',
33437 => 'Aperture',
34850 => 'Exposure Program',
34855 => 'ISO',
36864 => 'Exif Version',
36867 => 'Date (Original)',
36868 => 'Date (Digitized)',
37380 => 'APEX Exposure Bias',
37381 => 'APEX Max Aperture',
37383 => 'Metering Mode',
37384 => 'Light Source',
37385 => 'Flash',
37386 => 'FocalLength',
37510 => 'User Comment',
40960 => 'FlashPix Version',
40961 => 'Colour Space',
40962 => 'Pixel X Dimension',
40963 => 'Pixel Y Dimension',
41728 => 'File Source',
41985 => 'Special Processing',
41986 => 'Exposure Mode',
41987 => 'White Balance',
41988 => 'Digital Zoom Ratio',
41990 => 'Scene Capture Type',
41991 => 'Gain Control',
41992 => 'Contrast',
41993 => 'Saturation',
41994 => 'Sharpness',
37121 => 'Components Config');
foreach ($exif_arr_num_1 as $num1 => $value1) {
if ($num1 != 34665) {
if (isset($exif[0][$num1]['Text Value'])) {
if ($exif[0][$num1]['Text Value'] == '') { $exif_data[$value1] = 'Unknown'; }
else { $exif_data[$value1] = $exif[0][$num1]['Text Value']; }
}
} else {
foreach ($exif_arr_num_2 as $num2 => $value2) {
if (isset($exif[0][$num1]['Data'][0][$num2]['Text Value'])) {
if ($exif[0][$num1]['Data'][0][$num2]['Text Value'] == '') { $exif_data[$value2] = 'Unknown'; }
else { $exif_data[$value2] = $exif[0][$num1]['Data'][0][$num2]['Text Value']; }
}
}
}
}
} else {
$exif_data = array();
}
} else {
$exif_data = array();
}
if (isset($exif_data['X Resolution']) && isset($exif_data['Resolution Unit'])) {
$exif_data['X Resolution'] = $this->setResData($exif_data['X Resolution'], $exif_data['Resolution Unit']);
}
if (isset($exif_data['Y Resolution']) && isset($exif_data['Resolution Unit'])) {
$exif_data['Y Resolution'] = $this->setResData($exif_data['Y Resolution'], $exif_data['Resolution Unit']);
}
if (isset($exif_data['Date and Time'])) {
$exif_data['Date and Time'] = $this->changeExifDate($exif_data['Date and Time']);
}
if (isset($exif_data['Orientation'])) {
$pos = explode(' ', $exif_data['Orientation']);
$exif_data['Orientation'] = $pos[0].' '.$pos[1].' '.$pos[2].' '.$pos[3];
}
if (isset($exif_data['YCbCr Positioning'])) {
$exif_data['YCbCr Positioning'] = str_replace('components', '', $exif_data['YCbCr Positioning']);
}
} else {
$exif_data = array();
}
return($exif_data);
}
function displayImage($id,$orderby,$order) {
global $serendipity;
$extended_data = array();
$base_directory = $this->get_config('base_directory');
$file = serendipity_fetchImageFromDatabase($id);
$file['link'] = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . '.' . $file['extension'];
$test_string = $serendipity['serendipityPath'].$serendipity['uploadHTTPPath'] . $base_directory;
$path_len = strlen($test_string);
$pic_string = substr($serendipity['serendipityPath'].$serendipity['uploadHTTPPath'] . $file['path'],0,$path_len);
if (isset($file['id'])) {
$file['size_txt'] = round($file['size']/1024);
$file['is_image'] = serendipity_isImage($file);
$max_width = $this->get_config('image_width',480);
if ($file['dimensions_width'] > $max_width && $max_width != 0) {
$file['alt_width'] = $max_width;
$file['alt_height'] = round(($max_width/$file['dimensions_width']) * $file['dimensions_height']);
} else {
$file['alt_width'] = $file['dimensions_width'];
$file['alt_height'] = $file['dimensions_height'];
}
if (version_compare($serendipity['version'],"1.1.beta3") >= 0) {
if ($this->get_config('image_strict') == 'yes') {
$images = serendipity_fetchImagesFromDatabase($lower_limit, $images_per_page, $total, $orderby, $order, $file['path'],'','', array(), true);
} else {
$images = serendipity_fetchImagesFromDatabase($lower_limit, $images_per_page, $total, $orderby, $order, $file['path']);
}
$capable = true;
$extended_data = serendipity_fetchMediaProperties($id);
} else {
if ($this->get_config('image_strict') == 'yes') {
$images = $this->usergallery_showimages( $lower_limit, $images_per_page, $orderby, $order, $file['path']);
} else {
$images = serendipity_fetchImagesFromDatabase($lower_limit, $images_per_page, $total, $orderby, $order, $file['path']);
}
$capable = false;
}
$base_directory = str_replace('gallery','',$base_directory);
$previous_attempt = -1;
$previous_id = -1;
$next_id = -1;
if (is_array($images)) {
$stop = false;
$onecount = false;
while ((list($f, $image) = each($images)) && !$stop) {
if ($image['id'] == $file['id']) {
$path = $image['path'];
$previous_id = $previous_attempt;
$onecount = true;
} else {
if ($onecount == true) {
$next_id = $image['id'];
$stop = true;
} else {
$previous_attempt = $image['id'];
}
}
}
}
$gallery_array = explode('/',$path);
foreach($gallery_array AS $f => $gallery) {
$gallery_path = $gallery_path.$gallery."/";
if ($gallery_path != $base_directory ) {
$path_array[$gallery]['path'] = $gallery_path;
$path_array[$gallery]['name'] = $gallery;
}
}
// EXIF DATA
if ($this->get_config('exif_show_data') == 'yes') {
// If any exif tags that are available.
$filepath = $serendipity['serendipityPath'] . $serendipity['uploadHTTPPath'] . $file['path'];
$exif_data = $this->getExifTags($filepath, $file['name'], $file['extension']);
$exifsettings_one = $this->get_config('exif_data',$this->makeExifSelector());
// Create array of exif display settings for main information table.
$exif_arr = explode(',', $exifsettings_one);
foreach ($exif_arr as $key => $value) {
$display = explode('-', $exif_arr[$key]);
$exif_display_one[$display[0]] = $display[1];
}
$data_written = false;
$exif_output .= '