*
* *
***************************************************************************/
/***************************************************************************
* *
* 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; *
* *
***************************************************************************/
// determine the initial instant to indicate the generation time of this page
$t1 = explode( ' ', microtime() );
$t2 = explode( '.', $t1[0] );
$t2 = $t1[1].'.'.$t2[1];
//----------------------------------------------------------- personnal include
include_once( './include/init.inc.php' );
//-------------------------------------------------- access authorization check
check_cat_id( $_GET['cat'] );
check_login_authorization();
if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
{
check_restrictions( $page['cat'] );
}
//-------------------------------------------------------------- initialization
// creation of the array containing the cat ids to expand in the menu
// $page['tab_expand'] contains an array with the category ids
// $page['expand'] contains the string to display in URL with comma
$page['tab_expand'] = array();
if ( isset ( $_GET['expand'] ) and $_GET['expand'] != 'all' )
{
$j = 0;
$tab_expand = explode( ",", $_GET['expand'] );
$size = sizeof( $tab_expand );
for ( $i = 0; $i < $size; $i++ )
{
if ( is_numeric( $tab_expand[$i] ) )
{
$page['tab_expand'][$j++] = $tab_expand[$i];
}
}
$page['expand'] = implode( ',', $page['tab_expand'] );
}
// in case of expanding all authorized cats
// The $page['expand'] equals 'all' and
// $page['tab_expand'] contains all the authorized cat ids
if ( $user['expand'] == 'true' or $_GET['expand'] == 'all' )
{
$page['tab_expand'] = array();
$query = 'SELECT id';
$query.= ' FROM '.PREFIX_TABLE.'categories';
$query.= ' WHERE id_uppercat IS NULL;';
$result = mysql_query( $query );
$i = 0;
while ( $row = mysql_fetch_array( $result ) )
{
$page['tab_expand'][$i++] = $row['id'];
}
$page['expand'] = 'all';
}
// detection of the start picture to display
if ( !isset( $_GET['start'] )
or !is_numeric( $_GET['start'] )
or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )
{
$page['start'] = 0;
}
else
{
$page['start'] = $_GET['start'];
}
// Sometimes, a "num" is provided in the URL. It is the number
// of the picture to show. This picture must be in the thumbnails page.
// We have to find the right $page['start'] that show the num picture
// in this category
if ( is_numeric( $_GET['num'] ) and $_GET['num'] >= 0 )
{
$page['start'] = floor( $_GET['num'] / $user['nb_image_page'] );
$page['start']*= $user['nb_image_page'];
}
initialize_category();
//----------------------------------------------------- template initialization
$vtp = new VTemplate;
$handle = $vtp->Open( './template/'.$user['template'].'/category.vtp' );
initialize_template();
$tpl = array( 'categories','hint_category','sub-cat','images_available',
'total','title_menu','nb_image_category','send_mail',
'title_send_mail','generation_time','upload_name',
'connected_user','recent_image','days','generation_time',
'favorite_cat_hint','favorite_cat','stats',
'most_visited_cat_hint','most_visited_cat','recent_cat',
'recent_cat_hint' );
templatize_array( $tpl, 'lang', $handle );
$tpl = array( 'mail_webmaster','webmaster','top_number','version','site_url' );
templatize_array( $tpl, 'conf', $handle );
$tpl = array( 'short_period','long_period','lien_collapsed', 'username' );
templatize_array( $tpl, 'user', $handle );
$tpl = array( 'title','navigation_bar','cat_comment','cat_nb_images' );
templatize_array( $tpl, 'page', $handle );
// special global template vars
$vtp->setGlobalVar( $handle, 'icon_short', get_icon( time() ) );
$icon_long = get_icon( time() - ( $user['short_period'] * 24 * 60 * 60 + 1 ) );
$vtp->setGlobalVar( $handle, 'icon_long', $icon_long );
$nb_total_pictures = get_total_image( "", $user['restrictions'] );
$vtp->setGlobalVar( $handle, 'nb_total_pictures',$nb_total_pictures );
//------------------------------------------------------------- categories menu
// normal categories
display_cat( '', ' ', $user['restrictions'], $page['tab_expand'] );
// favorites cat
if ( !$user['is_the_guest'] )
{
$vtp->addSession( $handle, 'favorites' );
$url = add_session_id('./category.php?cat=fav&expand='.$page['expand'] );
$vtp->setVar( $handle, 'favorites.url', $url );
// searching the number of favorite picture
$query = 'SELECT COUNT(*) AS count';
$query.= ' FROM '.PREFIX_TABLE.'favorites';
$query.= ' WHERE user_id = '.$user['id'].';';
$result = mysql_query( $query );
$row = mysql_fetch_array( $result );
$vtp->setVar( $handle, 'favorites.nb_favorites', $row['count'] );
$vtp->closeSession( $handle, 'favorites' );
}
// most visited pictures category
$url = add_session_id( './category.php?cat=most_visited'.
'&expand='.$page['expand'] );
$vtp->setGlobalVar( $handle, 'most_visited_url', $url );
// recent pictures
$url = add_session_id( './category.php?cat=recent'.
'&expand='.$page['expand'] );
$vtp->setGlobalVar( $handle, 'recent_url', $url );
//--------------------------------------------------------------------- summary
$vtp->addSession( $handle, 'summary' );
$vtp->setVar( $handle, 'summary.url', './identification.php' );
if ( !$user['is_the_guest'] )
{
$vtp->setVar( $handle, 'summary.title', '' );
$vtp->setVar( $handle, 'summary.name',
replace_space( $lang['change_login'] ) );
}
else
{
$vtp->setVar( $handle, 'summary.title', $lang['hint_login'] );
$vtp->setVar( $handle, 'summary.name',
replace_space( $lang['login'] ) );
}
$vtp->closeSession( $handle, 'summary' );
// links for registered users
if ( !$user['is_the_guest'] )
{
// logout link
$vtp->addSession( $handle, 'summary' );
$vtp->setVar( $handle, 'summary.url', './category.php?cat='.$page['cat'] );
$vtp->setVar( $handle, 'summary.title', '' );
$vtp->setVar( $handle, 'summary.name', replace_space( $lang['logout'] ) );
$vtp->closeSession( $handle, 'summary' );
// customization link
$vtp->addSession( $handle, 'summary' );
$url = './profile.php?cat='.$page['cat'];
$url.= '&expand='.$page['expand'];
if ( $page['cat'] == 'search' )
{
$url.= '&search='.$_GET['search'];
}
$vtp->setVar( $handle, 'summary.url', add_session_id( $url ) );
$vtp->setVar( $handle, 'summary.title', $lang['hint_customize'] );
$vtp->setVar( $handle, 'summary.name', replace_space( $lang['customize'] ) );
$vtp->closeSession( $handle, 'summary' );
}
// search link
$vtp->addSession( $handle, 'summary' );
$vtp->setVar( $handle, 'summary.url', add_session_id( './search.php' ) );
$vtp->setVar( $handle, 'summary.title', $lang['hint_search'] );
$vtp->setVar( $handle, 'summary.name', replace_space( $lang['search'] ) );
$vtp->closeSession( $handle, 'summary' );
// about link
$vtp->addSession( $handle, 'summary' );
$vtp->setVar( $handle, 'summary.url',
add_session_id( './about.php?expand='.$page['expand'] ) );
$vtp->setVar( $handle, 'summary.title', $lang['hint_about'] );
$vtp->setVar( $handle, 'summary.name', replace_space( $lang['about'] ) );
$vtp->closeSession( $handle, 'summary' );
// administration link
if ( $user['status'] == 'admin' )
{
$vtp->addSession( $handle, 'summary' );
$vtp->setVar( $handle, 'summary.url',
add_session_id( './admin/admin.php' ) );
$vtp->setVar( $handle, 'summary.title', $lang['hint_admin'] );
$vtp->setVar( $handle, 'summary.name', replace_space( $lang['admin'] ) );
$vtp->closeSession( $handle, 'summary' );
}
//-------------------------------------------------------------- category title
if ( isset ( $page['cat'] ) )
{
if ( is_numeric( $page['cat'] ) )
{
$cat_title = get_cat_display_name( $page['cat_name'], '
',
'font-style:italic;' );
$vtp->setGlobalVar( $handle, "cat_title", $cat_title );
}
else
{
if ( $page['cat'] == 'search' )
{
$page['title'].= ' : ';
$page['title'].= $_GET['search']."";
}
$page['title'] = replace_space( $page['title'] );
$vtp->setGlobalVar( $handle, "cat_title", $page['title'] );
}
}
else
{
$vtp->setGlobalVar( $handle, "cat_title",
replace_space( $lang['no_category'] ) );
}
//------------------------------------------------------------------ thumbnails
if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 )
{
if ( is_numeric( $page['cat'] ) )
{
$cat_directory = $page['cat_dir'];
}
else if ( $page['cat'] == 'search' or $page['cat'] == 'fav' )
{
$array_cat_directories = array();
}
$query = 'SELECT id,file,date_available,tn_ext,name,filesize,cat_id';
$query.= ' FROM '.PREFIX_TABLE.'images';
$query.= $page['where'];
$query.= $conf['order_by'];
$query.= ' LIMIT '.$page['start'].','.$page['nb_image_page'];
$query.= ';';
$result = mysql_query( $query );
$vtp->addSession( $handle, 'thumbnails' );
$vtp->addSession( $handle, 'line' );
// iteration counter to use a new