[2] | 1 | <?php |
---|
| 2 | /*************************************************************************** |
---|
| 3 | * category.php * |
---|
| 4 | * ------------------- * |
---|
[57] | 5 | * application : PhpWebGallery 1.3 <http://phpwebgallery.net> * |
---|
| 6 | * author : Pierrick LE GALL <pierrick@z0rglub.com> * |
---|
[2] | 7 | * * |
---|
[57] | 8 | * $Id: category.php 64 2003-09-05 19:27:45Z z0rglub $ |
---|
| 9 | * * |
---|
[2] | 10 | ***************************************************************************/ |
---|
| 11 | |
---|
| 12 | /*************************************************************************** |
---|
| 13 | * * |
---|
| 14 | * This program is free software; you can redistribute it and/or modify * |
---|
| 15 | * it under the terms of the GNU General Public License as published by * |
---|
| 16 | * the Free Software Foundation; * |
---|
| 17 | * * |
---|
| 18 | ***************************************************************************/ |
---|
| 19 | // determine the initial instant to indicate the generation time of this page |
---|
| 20 | $t1 = explode( ' ', microtime() ); |
---|
| 21 | $t2 = explode( '.', $t1[0] ); |
---|
| 22 | $t2 = $t1[1].'.'.$t2[1]; |
---|
| 23 | //----------------------------------------------------------- personnal include |
---|
| 24 | include_once( './include/init.inc.php' ); |
---|
[45] | 25 | //---------------------------------------------------------------------- logout |
---|
| 26 | if ( $_GET['act'] == 'logout' and isset( $_COOKIE['id'] ) ) |
---|
| 27 | { |
---|
| 28 | // cookie deletion if exists |
---|
| 29 | setcookie( 'id', '', 0, cookie_path() ); |
---|
| 30 | $url = 'category.php'; |
---|
| 31 | header( 'Request-URI: '.$url ); |
---|
| 32 | header( 'Content-Location: '.$url ); |
---|
| 33 | header( 'Location: '.$url ); |
---|
| 34 | exit(); |
---|
| 35 | } |
---|
[2] | 36 | //-------------------------------------------------- access authorization check |
---|
[26] | 37 | // creating the plain structure : array of all the available categories and |
---|
| 38 | // their relative informations, see the definition of the function |
---|
| 39 | // get_plain_structure for further details. |
---|
| 40 | $page['plain_structure'] = get_plain_structure(); |
---|
| 41 | |
---|
[2] | 42 | check_cat_id( $_GET['cat'] ); |
---|
| 43 | check_login_authorization(); |
---|
| 44 | if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) |
---|
| 45 | { |
---|
| 46 | check_restrictions( $page['cat'] ); |
---|
| 47 | } |
---|
| 48 | //-------------------------------------------------------------- initialization |
---|
| 49 | // creation of the array containing the cat ids to expand in the menu |
---|
| 50 | // $page['tab_expand'] contains an array with the category ids |
---|
| 51 | // $page['expand'] contains the string to display in URL with comma |
---|
| 52 | $page['tab_expand'] = array(); |
---|
| 53 | if ( isset ( $_GET['expand'] ) and $_GET['expand'] != 'all' ) |
---|
| 54 | { |
---|
[26] | 55 | $tab_expand = explode( ',', $_GET['expand'] ); |
---|
| 56 | foreach ( $tab_expand as $id ) { |
---|
| 57 | if ( is_numeric( $id ) ) array_push( $page['tab_expand'], $id ); |
---|
[2] | 58 | } |
---|
| 59 | $page['expand'] = implode( ',', $page['tab_expand'] ); |
---|
| 60 | } |
---|
| 61 | // in case of expanding all authorized cats |
---|
| 62 | // The $page['expand'] equals 'all' and |
---|
| 63 | // $page['tab_expand'] contains all the authorized cat ids |
---|
[26] | 64 | if ( $user['expand'] or $_GET['expand'] == 'all' ) |
---|
[2] | 65 | { |
---|
| 66 | $page['tab_expand'] = array(); |
---|
| 67 | $page['expand'] = 'all'; |
---|
| 68 | } |
---|
| 69 | // detection of the start picture to display |
---|
| 70 | if ( !isset( $_GET['start'] ) |
---|
| 71 | or !is_numeric( $_GET['start'] ) |
---|
| 72 | or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) ) |
---|
| 73 | { |
---|
| 74 | $page['start'] = 0; |
---|
| 75 | } |
---|
| 76 | else |
---|
| 77 | { |
---|
| 78 | $page['start'] = $_GET['start']; |
---|
| 79 | } |
---|
| 80 | // Sometimes, a "num" is provided in the URL. It is the number |
---|
| 81 | // of the picture to show. This picture must be in the thumbnails page. |
---|
| 82 | // We have to find the right $page['start'] that show the num picture |
---|
| 83 | // in this category |
---|
| 84 | if ( is_numeric( $_GET['num'] ) and $_GET['num'] >= 0 ) |
---|
| 85 | { |
---|
| 86 | $page['start'] = floor( $_GET['num'] / $user['nb_image_page'] ); |
---|
| 87 | $page['start']*= $user['nb_image_page']; |
---|
| 88 | } |
---|
[26] | 89 | // creating the structure of the categories (useful for displaying the menu) |
---|
| 90 | $page['structure'] = create_structure( '', $user['restrictions'] ); |
---|
| 91 | $page['structure'] = update_structure( $page['structure'] ); |
---|
[2] | 92 | initialize_category(); |
---|
| 93 | //----------------------------------------------------- template initialization |
---|
| 94 | $vtp = new VTemplate; |
---|
| 95 | $handle = $vtp->Open( './template/'.$user['template'].'/category.vtp' ); |
---|
| 96 | initialize_template(); |
---|
[26] | 97 | $tpl = array( |
---|
| 98 | 'categories','hint_category','sub-cat','images_available','total', |
---|
| 99 | 'title_menu','nb_image_category','send_mail','title_send_mail', |
---|
| 100 | 'generation_time','connected_user','recent_image','days','generation_time', |
---|
| 101 | 'favorite_cat_hint','favorite_cat','stats','most_visited_cat_hint', |
---|
| 102 | 'most_visited_cat','recent_cat','recent_cat_hint','upload_picture' ); |
---|
[9] | 103 | templatize_array( $tpl, 'lang', $handle ); |
---|
[2] | 104 | |
---|
| 105 | $tpl = array( 'mail_webmaster','webmaster','top_number','version','site_url' ); |
---|
[9] | 106 | templatize_array( $tpl, 'conf', $handle ); |
---|
[2] | 107 | |
---|
[14] | 108 | $tpl = array( 'short_period','long_period','lien_collapsed', 'username' ); |
---|
[9] | 109 | templatize_array( $tpl, 'user', $handle ); |
---|
[2] | 110 | |
---|
| 111 | $tpl = array( 'title','navigation_bar','cat_comment','cat_nb_images' ); |
---|
[9] | 112 | templatize_array( $tpl, 'page', $handle ); |
---|
[2] | 113 | |
---|
| 114 | // special global template vars |
---|
| 115 | $vtp->setGlobalVar( $handle, 'icon_short', get_icon( time() ) ); |
---|
| 116 | $icon_long = get_icon( time() - ( $user['short_period'] * 24 * 60 * 60 + 1 ) ); |
---|
| 117 | $vtp->setGlobalVar( $handle, 'icon_long', $icon_long ); |
---|
[26] | 118 | $nb_total_pictures = count_images( $page['structure'] ); |
---|
[2] | 119 | $vtp->setGlobalVar( $handle, 'nb_total_pictures',$nb_total_pictures ); |
---|
| 120 | //------------------------------------------------------------- categories menu |
---|
| 121 | // normal categories |
---|
[26] | 122 | foreach ( $page['structure'] as $category ) { |
---|
| 123 | // display category is a function relative to the template |
---|
| 124 | display_category( $category, ' ', $handle ); |
---|
| 125 | } |
---|
[2] | 126 | // favorites cat |
---|
| 127 | if ( !$user['is_the_guest'] ) |
---|
| 128 | { |
---|
| 129 | $vtp->addSession( $handle, 'favorites' ); |
---|
[26] | 130 | $url = './category.php?cat=fav&expand='.$page['expand']; |
---|
| 131 | $vtp->setVar( $handle, 'favorites.url', add_session_id( $url ) ); |
---|
[2] | 132 | // searching the number of favorite picture |
---|
[16] | 133 | $query = 'SELECT COUNT(*) AS count'; |
---|
| 134 | $query.= ' FROM '.PREFIX_TABLE.'favorites'; |
---|
| 135 | $query.= ' WHERE user_id = '.$user['id'].';'; |
---|
[2] | 136 | $result = mysql_query( $query ); |
---|
| 137 | $row = mysql_fetch_array( $result ); |
---|
| 138 | $vtp->setVar( $handle, 'favorites.nb_favorites', $row['count'] ); |
---|
| 139 | $vtp->closeSession( $handle, 'favorites' ); |
---|
| 140 | } |
---|
| 141 | // most visited pictures category |
---|
[26] | 142 | $url = './category.php?cat=most_visited&expand='.$page['expand']; |
---|
| 143 | $vtp->setGlobalVar( $handle, 'most_visited_url', add_session_id( $url ) ); |
---|
[2] | 144 | // recent pictures |
---|
[26] | 145 | $url = './category.php?cat=recent&expand='.$page['expand']; |
---|
| 146 | $vtp->setGlobalVar( $handle, 'recent_url', add_session_id( $url ) ); |
---|
[2] | 147 | //--------------------------------------------------------------------- summary |
---|
| 148 | $vtp->addSession( $handle, 'summary' ); |
---|
| 149 | $vtp->setVar( $handle, 'summary.url', './identification.php' ); |
---|
| 150 | if ( !$user['is_the_guest'] ) |
---|
| 151 | { |
---|
| 152 | $vtp->setVar( $handle, 'summary.title', '' ); |
---|
[26] | 153 | $vtp->setVar( $handle, 'summary.name',replace_space($lang['change_login'])); |
---|
[2] | 154 | } |
---|
| 155 | else |
---|
| 156 | { |
---|
| 157 | $vtp->setVar( $handle, 'summary.title', $lang['hint_login'] ); |
---|
[26] | 158 | $vtp->setVar( $handle, 'summary.name', replace_space( $lang['login'] ) ); |
---|
[2] | 159 | } |
---|
| 160 | $vtp->closeSession( $handle, 'summary' ); |
---|
| 161 | // links for registered users |
---|
| 162 | if ( !$user['is_the_guest'] ) |
---|
| 163 | { |
---|
| 164 | // logout link |
---|
| 165 | $vtp->addSession( $handle, 'summary' ); |
---|
[45] | 166 | $vtp->setVar( $handle, 'summary.url', './category.php?act=logout' ); |
---|
[2] | 167 | $vtp->setVar( $handle, 'summary.title', '' ); |
---|
| 168 | $vtp->setVar( $handle, 'summary.name', replace_space( $lang['logout'] ) ); |
---|
| 169 | $vtp->closeSession( $handle, 'summary' ); |
---|
| 170 | // customization link |
---|
| 171 | $vtp->addSession( $handle, 'summary' ); |
---|
| 172 | $url = './profile.php?cat='.$page['cat']; |
---|
| 173 | $url.= '&expand='.$page['expand']; |
---|
| 174 | if ( $page['cat'] == 'search' ) |
---|
| 175 | { |
---|
[17] | 176 | $url.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; |
---|
[2] | 177 | } |
---|
| 178 | $vtp->setVar( $handle, 'summary.url', add_session_id( $url ) ); |
---|
| 179 | $vtp->setVar( $handle, 'summary.title', $lang['hint_customize'] ); |
---|
| 180 | $vtp->setVar( $handle, 'summary.name', replace_space( $lang['customize'] ) ); |
---|
| 181 | $vtp->closeSession( $handle, 'summary' ); |
---|
| 182 | } |
---|
| 183 | // search link |
---|
| 184 | $vtp->addSession( $handle, 'summary' ); |
---|
| 185 | $vtp->setVar( $handle, 'summary.url', add_session_id( './search.php' ) ); |
---|
| 186 | $vtp->setVar( $handle, 'summary.title', $lang['hint_search'] ); |
---|
| 187 | $vtp->setVar( $handle, 'summary.name', replace_space( $lang['search'] ) ); |
---|
| 188 | $vtp->closeSession( $handle, 'summary' ); |
---|
| 189 | // about link |
---|
| 190 | $vtp->addSession( $handle, 'summary' ); |
---|
[26] | 191 | $vtp->setVar( $handle, 'summary.url', './about.php?'. |
---|
| 192 | str_replace( '&', '&', $_SERVER['QUERY_STRING'] ) ); |
---|
[2] | 193 | $vtp->setVar( $handle, 'summary.title', $lang['hint_about'] ); |
---|
| 194 | $vtp->setVar( $handle, 'summary.name', replace_space( $lang['about'] ) ); |
---|
| 195 | $vtp->closeSession( $handle, 'summary' ); |
---|
| 196 | // administration link |
---|
| 197 | if ( $user['status'] == 'admin' ) |
---|
| 198 | { |
---|
| 199 | $vtp->addSession( $handle, 'summary' ); |
---|
| 200 | $vtp->setVar( $handle, 'summary.url', |
---|
| 201 | add_session_id( './admin/admin.php' ) ); |
---|
| 202 | $vtp->setVar( $handle, 'summary.title', $lang['hint_admin'] ); |
---|
| 203 | $vtp->setVar( $handle, 'summary.name', replace_space( $lang['admin'] ) ); |
---|
| 204 | $vtp->closeSession( $handle, 'summary' ); |
---|
| 205 | } |
---|
| 206 | //-------------------------------------------------------------- category title |
---|
| 207 | if ( isset ( $page['cat'] ) ) |
---|
| 208 | { |
---|
| 209 | if ( is_numeric( $page['cat'] ) ) |
---|
| 210 | { |
---|
| 211 | $cat_title = get_cat_display_name( $page['cat_name'], '<br />', |
---|
| 212 | 'font-style:italic;' ); |
---|
| 213 | $vtp->setGlobalVar( $handle, "cat_title", $cat_title ); |
---|
| 214 | } |
---|
| 215 | else |
---|
| 216 | { |
---|
| 217 | if ( $page['cat'] == 'search' ) |
---|
| 218 | { |
---|
| 219 | $page['title'].= ' : <span style="font-style:italic;">'; |
---|
| 220 | $page['title'].= $_GET['search']."</span>"; |
---|
| 221 | } |
---|
| 222 | $page['title'] = replace_space( $page['title'] ); |
---|
| 223 | $vtp->setGlobalVar( $handle, "cat_title", $page['title'] ); |
---|
| 224 | } |
---|
| 225 | } |
---|
| 226 | else |
---|
| 227 | { |
---|
| 228 | $vtp->setGlobalVar( $handle, "cat_title", |
---|
| 229 | replace_space( $lang['no_category'] ) ); |
---|
| 230 | } |
---|
| 231 | //------------------------------------------------------------------ thumbnails |
---|
| 232 | if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 ) |
---|
| 233 | { |
---|
[61] | 234 | $array_cat_directories = array(); |
---|
[2] | 235 | |
---|
[64] | 236 | $query = 'SELECT distinct(id),file,date_available,tn_ext,name,filesize'; |
---|
| 237 | $query.= ',storage_category_id'; |
---|
| 238 | $query.= ' FROM '.PREFIX_TABLE.'images AS i'; |
---|
| 239 | $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category AS ic ON id=ic.image_id'; |
---|
[2] | 240 | $query.= $page['where']; |
---|
| 241 | $query.= $conf['order_by']; |
---|
[16] | 242 | $query.= ' LIMIT '.$page['start'].','.$page['nb_image_page']; |
---|
[2] | 243 | $query.= ';'; |
---|
| 244 | $result = mysql_query( $query ); |
---|
| 245 | |
---|
| 246 | $vtp->addSession( $handle, 'thumbnails' ); |
---|
| 247 | $vtp->addSession( $handle, 'line' ); |
---|
[16] | 248 | // iteration counter to use a new <tr> every "$nb_image_line" pictures |
---|
[17] | 249 | $cell_number = 1; |
---|
| 250 | // iteration counter to be sure not to create too much lines in the table |
---|
| 251 | $line_number = 1; |
---|
[2] | 252 | while ( $row = mysql_fetch_array( $result ) ) |
---|
| 253 | { |
---|
[64] | 254 | // retrieving the storage dir of the picture |
---|
[61] | 255 | if ( $array_cat_directories[$row['storage_category_id']] == '' ) |
---|
[2] | 256 | { |
---|
[61] | 257 | $array_cat_directories[$row['storage_category_id']] = |
---|
| 258 | get_complete_dir( $row['storage_category_id'] ); |
---|
[2] | 259 | } |
---|
[61] | 260 | $cat_directory = $array_cat_directories[$row['storage_category_id']]; |
---|
| 261 | |
---|
[16] | 262 | $file = get_filename_wo_extension( $row['file'] ); |
---|
[2] | 263 | // name of the picture |
---|
[61] | 264 | if ( $row['name'] != '' ) $name = $row['name']; |
---|
| 265 | else $name = str_replace( '_', ' ', $file ); |
---|
| 266 | |
---|
[2] | 267 | if ( $page['cat'] == 'search' ) |
---|
| 268 | { |
---|
| 269 | $name = replace_search( $name, $_GET['search'] ); |
---|
| 270 | } |
---|
| 271 | // thumbnail url |
---|
| 272 | $thumbnail_url = $cat_directory; |
---|
[20] | 273 | $thumbnail_url.= 'thumbnail/'.$conf['prefix_thumbnail']; |
---|
[2] | 274 | $thumbnail_url.= $file.'.'.$row['tn_ext']; |
---|
| 275 | // message in title for the thumbnail |
---|
[16] | 276 | $thumbnail_title = $row['file']; |
---|
[2] | 277 | if ( $row['filesize'] == '' ) |
---|
| 278 | { |
---|
| 279 | $poids = floor( filesize( $lien_image ) / 1024 ); |
---|
| 280 | } |
---|
| 281 | else |
---|
| 282 | { |
---|
| 283 | $poids = $row['filesize']; |
---|
| 284 | } |
---|
[16] | 285 | $thumbnail_title .= ' : '.$poids.' KB'; |
---|
[2] | 286 | // url link on picture.php page |
---|
| 287 | $url_link = './picture.php?cat='.$page['cat']; |
---|
| 288 | $url_link.= '&image_id='.$row['id'].'&expand='.$page['expand']; |
---|
| 289 | if ( $page['cat'] == 'search' ) |
---|
| 290 | { |
---|
[17] | 291 | $url_link.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; |
---|
[2] | 292 | } |
---|
| 293 | // date of availability for creation icon |
---|
[17] | 294 | list( $year,$month,$day ) = explode( '-', $row['date_available'] ); |
---|
| 295 | $date = mktime( 0, 0, 0, $month, $day, $year ); |
---|
[2] | 296 | // sending vars to display |
---|
| 297 | $vtp->addSession( $handle, 'thumbnail' ); |
---|
| 298 | $vtp->setVar( $handle, 'thumbnail.url', add_session_id( $url_link ) ); |
---|
| 299 | $vtp->setVar( $handle, 'thumbnail.src', $thumbnail_url ); |
---|
| 300 | $vtp->setVar( $handle, 'thumbnail.alt', $row['file'] ); |
---|
| 301 | $vtp->setVar( $handle, 'thumbnail.title', $thumbnail_title ); |
---|
| 302 | $vtp->setVar( $handle, 'thumbnail.name', $name ); |
---|
| 303 | $vtp->setVar( $handle, 'thumbnail.icon', get_icon( $date ) ); |
---|
| 304 | |
---|
| 305 | if ( $conf['show_comments'] and $user['show_nb_comments'] ) |
---|
| 306 | { |
---|
| 307 | $vtp->addSession( $handle, 'nb_comments' ); |
---|
[16] | 308 | $query = 'SELECT COUNT(*) AS nb_comments'; |
---|
| 309 | $query.= ' FROM '.PREFIX_TABLE.'comments'; |
---|
| 310 | $query.= ' WHERE image_id = '.$row['id']; |
---|
[26] | 311 | $query.= " AND validated = 'true'"; |
---|
[2] | 312 | $query.= ';'; |
---|
| 313 | $row = mysql_fetch_array( mysql_query( $query ) ); |
---|
| 314 | $vtp->setVar( $handle, 'nb_comments.nb', $row['nb_comments'] ); |
---|
| 315 | $vtp->closeSession( $handle, 'nb_comments' ); |
---|
| 316 | } |
---|
| 317 | |
---|
| 318 | $vtp->closeSession( $handle, 'thumbnail' ); |
---|
| 319 | |
---|
[17] | 320 | if ( $cell_number++ == $user['nb_image_line'] ) |
---|
[2] | 321 | { |
---|
[17] | 322 | // creating a new line |
---|
[2] | 323 | $vtp->closeSession( $handle, 'line' ); |
---|
[17] | 324 | // the number of the next cell is 1 |
---|
| 325 | $cell_number = 1; |
---|
| 326 | // we only create a new line if it does not exceed the maximum line |
---|
| 327 | // per page for the logged user |
---|
| 328 | if ( $line_number++ < $user['nb_line_page'] ) |
---|
| 329 | { |
---|
| 330 | $vtp->addSession( $handle, 'line' ); |
---|
| 331 | } |
---|
[2] | 332 | } |
---|
| 333 | } |
---|
| 334 | $vtp->closeSession( $handle, 'thumbnails' ); |
---|
| 335 | } |
---|
[26] | 336 | //-------------------------------------------------------------- empty category |
---|
| 337 | elseif ( ( isset( $page['cat'] ) |
---|
| 338 | and is_numeric( $page['cat'] ) |
---|
| 339 | and $page['cat_nb_images'] == 0 ) |
---|
| 340 | or $_GET['cat'] == '' ) |
---|
[2] | 341 | { |
---|
| 342 | $vtp->addSession( $handle, 'thumbnails' ); |
---|
[16] | 343 | $vtp->addSession( $handle, 'line' ); |
---|
| 344 | |
---|
[26] | 345 | $subcats = get_non_empty_subcat_ids( $page['cat'] ); |
---|
[17] | 346 | $cell_number = 1; |
---|
[26] | 347 | $i = 0; |
---|
| 348 | foreach ( $subcats as $subcat_id => $non_empty_id ) { |
---|
[61] | 349 | $subcat_infos = get_cat_info( $subcat_id ); |
---|
[2] | 350 | |
---|
[26] | 351 | $name ='[ <span style="font-weight:bold;">'; |
---|
| 352 | $name.= $subcat_infos['name'][0]; |
---|
[7] | 353 | $name.= '</span> ]'; |
---|
[61] | 354 | |
---|
| 355 | $query = 'SELECT file,tn_ext,storage_category_id'; |
---|
[16] | 356 | $query.= ' FROM '.PREFIX_TABLE.'images'; |
---|
[61] | 357 | $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; |
---|
| 358 | $query.= ' WHERE category_id = '.$non_empty_id; |
---|
[16] | 359 | $query.= ' ORDER BY RAND()'; |
---|
| 360 | $query.= ' LIMIT 0,1'; |
---|
[2] | 361 | $query.= ';'; |
---|
| 362 | $image_result = mysql_query( $query ); |
---|
[26] | 363 | $image_row = mysql_fetch_array( $image_result ); |
---|
[2] | 364 | |
---|
[17] | 365 | $file = get_filename_wo_extension( $image_row['file'] ); |
---|
[2] | 366 | |
---|
| 367 | // creating links for thumbnail and associated category |
---|
[61] | 368 | $thumbnail_link = get_complete_dir( $image_row['storage_category_id'] ); |
---|
[26] | 369 | $thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail']; |
---|
| 370 | $thumbnail_link.= $file.'.'.$image_row['tn_ext']; |
---|
[2] | 371 | |
---|
[17] | 372 | $thumbnail_title = $lang['hint_category']; |
---|
[2] | 373 | |
---|
[26] | 374 | $url_link = './category.php?cat='.$subcat_id; |
---|
[2] | 375 | if ( !in_array( $page['cat'], $page['tab_expand'] ) ) |
---|
| 376 | { |
---|
[17] | 377 | array_push( $page['tab_expand'], $page['cat'] ); |
---|
[2] | 378 | $page['expand'] = implode( ',', $page['tab_expand'] ); |
---|
| 379 | } |
---|
| 380 | $url_link.= '&expand='.$page['expand']; |
---|
[26] | 381 | list( $year,$month,$day ) = explode( '-', $subcat_infos['date_last'] ); |
---|
[17] | 382 | $date = mktime( 0, 0, 0, $month, $day, $year ); |
---|
[2] | 383 | |
---|
| 384 | // sending vars to display |
---|
| 385 | $vtp->addSession( $handle, 'thumbnail' ); |
---|
| 386 | $vtp->setVar( $handle, 'thumbnail.url', add_session_id( $url_link ) ); |
---|
[26] | 387 | $vtp->setVar( $handle, 'thumbnail.src', $thumbnail_link ); |
---|
[2] | 388 | $vtp->setVar( $handle, 'thumbnail.alt', $image_row['file'] ); |
---|
| 389 | $vtp->setVar( $handle, 'thumbnail.title', $thumbnail_title ); |
---|
| 390 | $vtp->setVar( $handle, 'thumbnail.name', $name ); |
---|
| 391 | $vtp->setVar( $handle, 'thumbnail.icon', get_icon( $date ) ); |
---|
| 392 | $vtp->closeSession( $handle, 'thumbnail' ); |
---|
| 393 | |
---|
[17] | 394 | if ( $cell_number++ == $user['nb_image_line'] ) |
---|
[2] | 395 | { |
---|
| 396 | $vtp->closeSession( $handle, 'line' ); |
---|
[17] | 397 | $cell_number = 1; |
---|
| 398 | // we open a new line if the subcat was not the last one |
---|
[26] | 399 | if ( $i++ < count( $subcats ) - 1 ) |
---|
[17] | 400 | { |
---|
| 401 | $vtp->addSession( $handle, 'line' ); |
---|
| 402 | } |
---|
[2] | 403 | } |
---|
| 404 | } |
---|
[26] | 405 | if ( $i < count( $subcats ) - 1 ) |
---|
[17] | 406 | { |
---|
| 407 | $vtp->closeSession( $handle, 'line' ); |
---|
| 408 | } |
---|
[2] | 409 | $vtp->closeSession( $handle, 'thumbnails' ); |
---|
| 410 | } |
---|
| 411 | //------------------------------------------------------- category informations |
---|
| 412 | if ( isset ( $page['cat'] ) ) |
---|
| 413 | { |
---|
| 414 | $vtp->addSession( $handle, 'cat_infos' ); |
---|
| 415 | // navigation bar |
---|
| 416 | if ( $page['navigation_bar'] != '' ) |
---|
| 417 | { |
---|
| 418 | $vtp->addSession( $handle, 'navigation' ); |
---|
| 419 | $vtp->closeSession( $handle, 'navigation' ); |
---|
| 420 | } |
---|
| 421 | // category comment |
---|
| 422 | if ( isset( $page['comment'] ) and $page['comment'] != '' ) |
---|
| 423 | { |
---|
[14] | 424 | $vtp->addSession( $handle, 'comment' ); |
---|
| 425 | $vtp->setVar( $handle, 'comment.cat_comment', $page['comment'] ); |
---|
| 426 | $vtp->closeSession( $handle, 'comment' ); |
---|
[2] | 427 | } |
---|
| 428 | // total number of pictures in the category |
---|
| 429 | if ( is_numeric( $page['cat'] ) ) |
---|
| 430 | { |
---|
| 431 | $vtp->setVar( $handle, 'cat_infos.cat_name', |
---|
| 432 | get_cat_display_name( $page['cat_name'], ' - ', |
---|
| 433 | 'font-style:italic;' ) ); |
---|
| 434 | } |
---|
| 435 | else |
---|
| 436 | { |
---|
| 437 | $vtp->setVar( $handle, 'cat_infos.cat_name', $page['title'] ); |
---|
| 438 | } |
---|
| 439 | // upload a picture in the category |
---|
[38] | 440 | if ( $page['cat_site_id'] == 1 |
---|
| 441 | and $conf['upload_available'] |
---|
| 442 | and $page['cat_uploadable'] ) |
---|
[2] | 443 | { |
---|
| 444 | $vtp->addSession( $handle, 'upload' ); |
---|
| 445 | $url = './upload.php?cat='.$page['cat'].'&expand='.$page['expand']; |
---|
| 446 | $vtp->setVar( $handle, 'upload.url', add_session_id( $url ) ); |
---|
| 447 | $vtp->closeSession( $handle, 'upload' ); |
---|
| 448 | } |
---|
| 449 | $vtp->closeSession( $handle, 'cat_infos' ); |
---|
| 450 | } |
---|
| 451 | //------------------------------------------------------------ log informations |
---|
| 452 | pwg_log( 'category', $page['title'] ); |
---|
| 453 | mysql_close(); |
---|
| 454 | //------------------------------------------------------------- generation time |
---|
| 455 | $time = get_elapsed_time( $t2, get_moment() ); |
---|
| 456 | $vtp->setGlobalVar( $handle, 'time', $time ); |
---|
| 457 | //----------------------------------------------------------- html code display |
---|
| 458 | $code = $vtp->Display( $handle, 0 ); |
---|
| 459 | echo $code; |
---|
| 460 | ?> |
---|