addInfos($_GET['updateFile'], $_GET['updateDir']);
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header('Content-Type: image/gif');
echo base64_decode("R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==");
exit;
}
if (isset($_GET['index_all']))
{
if (!isset($_SESSION))
{
session_start();
if (!isset($_SESSION['processed']))
$_SESSION['processed'] = array();
if ($_GET['index_all'] == 'done')
{
$_SESSION = array();
session_destroy();
session_write_close();
setcookie(session_name(), '', time() - 3600);
}
}
if ($_GET['index_all'] != 'done')
{
define('TIMER_START', time());
function update_dir($dir)
{
global $f;
// Let's start again if timer seems too late, because processing a lot of
// directories could be very slow
if ((time() - TIMER_START) >= (ini_get('max_execution_time') - 5))
{
header('Location: '.SELF_URL.'?index_all='.time());
exit;
}
if (in_array($dir, $_SESSION['processed']))
$dont_check = true;
else
$dont_check = false;
$pics = $dirs = $update = $desc = false;
$list = $f->getDirectory($dir, $dont_check);
$_SESSION['processed'][] = $dir;
if (empty($list))
return false;
else
list($dirs, $pics, $update, $desc) = $list;
if (!empty($update))
{
return array($dir, $update);
}
foreach ($dirs as $subdir)
{
$subdir = (!empty($dir) ? $dir . '/' : '') . $subdir;
$res = update_dir($subdir);
if ($res)
return $res;
}
return false;
}
$res = update_dir('');
if (!$res)
{
header('Location: '.SELF_URL.'?index_all=done');
exit;
}
}
else
{
$res = false;
}
echo '';
if ($res)
{
list($dir, $update_list) = $res;
echo "\n"
.'';
}
echo '';
if ($res)
{
echo '
'.__('Updating').'
... '.$dir;
}
else
{
echo ''.__('Update done.').' ';
}
echo '
';
exit;
}
// For cache force url
if (!empty($_GET['r']))
{
unset($_GET['r']);
$_SERVER['QUERY_STRING'] = '';
}
// Small image redirect
if (!empty($_GET['i']) && preg_match('!^(.*)(?:/?([^/]+)[_.](jpe?g))?$!Ui', $_GET['i'], $match))
{
$selected_dir = fotooManager::getValidDirectory($match[1]);
$selected_file = $match[2] . '.' . $match[3];
$pic = $f->getInfos($selected_file, $selected_dir);
header('Content-Type: ', true);
if (!is_array($pic))
{
header('HTTP/1.1 404 Not Found', true, 404);
exit;
}
$orig_url = get_url('real_image', $pic);
if ($pic['width'] <= SMALL_IMAGE_SIZE && $pic['height'] <= SMALL_IMAGE_SIZE)
{
$small_url = $orig_url;
}
elseif (file_exists($f->getSmallPath($pic['hash'])))
{
$small_url = get_url('cache_small', $pic);
}
else
{
$small_url = false;
}
header('HTTP/1.1 302 Found', true, 302);
header('Location: '.($small_url ? $small_url : $orig_url));
exit;
}
// Get which display mode is asked
elseif (isset($_GET['date']) || isset($_GET['timeline']))
{
$day = $year = $month = $date = false;
if (!empty($_GET['date']) && preg_match('!^[0-9]{4}(/[0-9]{2}){0,2}$!', $_GET['date']))
$date = explode('/', $_GET['date']);
if (!empty($date[0]))
$year = $date[0];
if (!empty($date[1]))
$month = $date[1];
if (!empty($date[2]))
$day = $date[2];
if ($day)
$title = __('Pictures for %A %d %B %Y', 'TIME', strtotime($_GET['date']));
elseif ($month)
$title = __('Pictures for %B %Y', 'TIME', strtotime($_GET['date'].'/01'));
elseif ($year)
$title = __('Pictures for %Y', 'REPLACE', array('%Y' => $year));
else
$title = __('Pictures by date');
$mode = 'date';
}
elseif (isset($_GET['tags']))
{
$title = __('Pictures by tag');
$mode = 'tags';
}
elseif (isset($_GET['slideshow']) || isset($_GET['embed']))
{
$mode = isset($_GET['embed']) ? 'embed' : 'slideshow';
$title = __('Slideshow');
if (!empty($_GET['tag']))
{
$selected_tag = explode('/', $_GET['tag']);
$current_index = isset($selected_tag[1]) ? (int) $selected_tag[1] : 1;
$selected_tag = $f->getTagId($selected_tag[0]);
}
else
{
$src = isset($_GET['embed']) ? $_GET['embed'] : $_GET['slideshow'];
$selected_file = basename($src);
if (preg_match('!\.jpe?g$!i', $selected_file))
{
$selected_dir = fotooManager::getValidDirectory(dirname($src));
}
else
{
$selected_dir = fotooManager::getValidDirectory($src);
$selected_file = false;
}
}
}
elseif (!empty($_GET['tag']))
{
$mode = 'tag';
$tag = $f->getTagId($_GET['tag']);
$tag_name = $f->getTagNameFromId($tag);
$title = __('Pictures in tag %TAG', 'REPLACE', array('%TAG' => $tag_name));
}
else
{
$mode = 'dir';
$title = false;
if (isset($_GET['cleanUpdate']))
{
$cleanUpdate = true;
unset($_GET['cleanUpdate']);
$_SERVER['QUERY_STRING'] = '';
}
if (!empty($_SERVER['QUERY_STRING']) && preg_match('!^(.*)(?:/?([^/]+)[_.](jpe?g))?$!Ui', urldecode($_SERVER['QUERY_STRING']), $match))
{
$selected_dir = fotooManager::getValidDirectory($match[1]);
if ($selected_dir !== false)
{
$title = strtr(escape($match[1]), array('/' => ' / ', '_' => ' '));
if (!empty($match[2]))
{
$selected_file = $match[2] . '.' . $match[3];
$mode = 'pic';
$title = strtr(escape($match[2]), array('_' => ' ', '-' => ' - '));
}
}
}
else
{
$selected_dir = '';
}
}
if (file_exists(BASE_DIR . '/user_style.css'))
$css = BASE_URL . 'user_style.css';
else
$css = SELF_URL . '?style.css';
$f->html_tags['tag'] = get_url('tag', 'KEYWORD');
$f->html_tags['date'] = get_url('date', 'KEYWORD');
$menu = '';
header('Content-Type: text/html; charset=UTF-8');
if ($mode != 'slideshow' && $mode != 'embed')
{
if (file_exists(BASE_DIR . '/user_header.php'))
require BASE_DIR . '/user_header.php';
else
{
if (!$title) $title = GALLERY_TITLE;
else $title .= ' - '.GALLERY_TITLE;
echo '
'.escape($title).'
';
}
}
if ($mode == 'date')
{
echo ''.escape($title).' ';
echo '';
$pics = $f->getByDate($year, $month, $day);
if (empty($pics))
echo ''.__('No picture found.').'
';
if ($day)
{
echo ''."\n";
foreach ($pics as &$pic)
{
echo ' '
.' '
." \n";
}
echo " \n";
}
else
{
echo ''."\n";
$current = 0;
$current_y = 0;
$more = false;
foreach ($pics as &$pic)
{
if ($pic['year'] != $current_y)
{
if ($current_y)
echo ' ';
echo '';
if (!$year)
{
echo '';
if (isset($pic['more']))
echo ''.__("(%NB more pictures)", 'REPLACE', array('%NB' => $pic['more'])).'
';
echo '';
}
else
echo '';
$current_y = $pic['year'];
}
if (($month && $pic['day'] != $current) || ($year && !$month && $pic['month'] != $current))
{
if ($current)
echo ' ';
$url = get_url('date', $pic['year'].'/'.zero_pad($pic['month']).($month ? '/'.zero_pad($pic['day']) : ''));
echo '
';
if (isset($pic['more']))
echo ''.__("(%NB more pictures)", 'REPLACE', array('%NB' => $pic['more'])).'
';
echo '
';
$current = $month ? $pic['day'] : $pic['month'];
}
echo ' '
." \n";
}
echo ' ';
}
}
elseif ($mode == 'tags')
{
echo ''.$title.' ';
echo '';
$tags = $f->getTagList();
if (empty($tags))
echo ''.__('No tag found.').'
';
else
{
$max = max(array_values($tags));
$min = min(array_values($tags));
$spread = $max - $min;
if ($spread == 0) $spread = 1;
$step = 200 / $spread;
echo '';
foreach ($tags as $tag=>$nb)
{
$size = 100 + round(($nb - $min) * $step);
echo ''
.escape($tag).' ('.$nb.') ';
}
echo '
';
}
}
elseif ($mode == 'tag')
{
$pics = $f->getByTag($tag);
echo ''.$title.' ';
echo '';
$tags = $f->getNearTags($tag);
if (!empty($tags))
{
$max = max(array_values($tags));
$min = min(array_values($tags));
$spread = $max - $min;
if ($spread == 0) $spread = 1;
$step = 100 / $spread;
echo ''.__("Other tags related to '%TAG':", 'REPLACE', array('%TAG' => $tag)).' ';
foreach ($tags as $name=>$nb)
{
$size = 100 + round(($nb - $min) * $step);
echo ''.escape($name).' ';
echo '('.$nb.') ';
}
echo '
';
}
if (empty($pics))
{
echo ''.__('No picture found.').'
';
}
else
{
echo ''."\n";
foreach ($pics as &$pic)
{
echo ' '
.' '
." \n";
}
echo " \n";
if (ALLOW_EMBED)
{
echo '
'.__('Embed:').'
';
}
}
}
elseif ($mode == 'pic')
{
$pic = $f->getInfos($selected_file, $selected_dir);
if (!is_array($pic))
{
echo ''.__('Picture not found').'
';
exit;
}
echo '
'.$title.'
\n";
$orig_url = get_url('real_image', $pic);
$wh = '';
if (file_exists($f->getSmallPath($pic['hash'])))
{
$small_url = get_url('cache_small', $pic);
}
elseif ($pic['width'] <= MAX_IMAGE_SIZE && $pic['height'] <= MAX_IMAGE_SIZE)
{
$small_url = $orig_url;
list($nw, $nh) = $f->getNewSize($pic['width'], $pic['height'], SMALL_IMAGE_SIZE);
$wh = 'width="'.$nw.'" height="'.$nh.'"';
}
else
{
$small_url = false;
}
echo '
';
if ($small_url)
echo ' ';
else
echo __("This picture is too big (%W x %H) to be displayed in this page.", 'REPLACE', array('%W' => $pic['width'], '%H' => $pic['height']));
echo '
'.__('Download image at original size (%W x %H) - %SIZE KB', 'REPLACE',
array('%W' => $pic['width'], '%H' => $pic['height'], '%SIZE' => round($pic['size'] / 1000))).'
';
echo '
';
if (!empty($pic['comment']))
{
echo '
';
}
if (!empty($pic['tags']))
{
echo '
'.__('Tags:').'
';
foreach ($pic['tags'] as $tag_id=>$tag)
echo ''.escape($tag).' ';
echo ' ';
}
$date = __('%A %d %B %Y at %H:%M');
$date = strtr($date, array(
'%1' => escape(get_url('date', $pic['year'].'/'.zero_pad($pic['month']).'/'.zero_pad($pic['day']))),
'%2' => escape(get_url('date', $pic['year'].'/'.zero_pad($pic['month']))),
'%3' => escape(get_url('date', $pic['year'])),
));
$date = __($date, 'TIME', $pic['time']);
echo '
'.__('Date:').'
'.$date.' ';
if (ALLOW_EMBED)
{
echo '
'.__('Embed:').'
'.__('Embed as image:').'
';
}
echo '
';
if (!empty($pic['details']))
{
$details = $f->formatDetails($pic['details']);
echo '
';
foreach ($details as $name=>$value)
{
echo '
'.$name.'
'.$value.' ';
}
echo '
';
}
list($prev, $next) = $f->getPrevAndNext($selected_dir, $selected_file);
echo '
' .
($prev ?
'← ' : '') .
'
' .
($next ?
'→ ' : '') .
'
';
}
elseif ($mode == 'slideshow' || $mode == 'embed')
{
require 'slideshow.php';
}
else
{
$pics = $dirs = $update = $desc = false;
$list = $f->getDirectory($selected_dir);
echo '
'.escape($title).'
';
if ($list === false)
echo ''.__('No picture found.').'
';
else
list($dirs, $pics, $update, $desc) = $list;
if (!empty($update))
echo ''.__('Updating database, please wait, more pictures will appear in a while...').'
';
if ($desc)
{
echo ''.$f->formatText($desc).'
';
}
if (!empty($dirs))
{
echo '\n";
}
if (!empty($pics))
{
echo ''."\n";
foreach ($pics as &$pic)
{
echo ' '
.' '
." \n";
}
echo " \n";
}
if (!empty($update))
{
echo "\n"
.'';
}
}
if ($mode != 'embed' && $mode != 'slideshow')
{
if (file_exists(BASE_DIR . '/user_footer.php'))
require_once BASE_DIR . '/user_footer.php';
else
{
echo '