Changeset 1036
- Timestamp:
- Feb 12, 2006, 10:52:16 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/category.php
r1031 r1036 42 42 redirect( $url ); 43 43 } 44 //-------------------------------------------------- access authorization check 45 if (isset($_GET['cat'])) 46 { 47 check_cat_id($_GET['cat']); 48 } 49 check_login_authorization(); 50 if (isset($page['cat']) and is_numeric($page['cat'])) 51 { 52 check_restrictions($page['cat']); 53 } 54 //----------------------------------------------- change of image dispaly order 55 if ( isset($_GET['image_order']) ) 56 { 57 setcookie( 'pwg_image_order', 58 $_GET['image_order']>0 ? $_GET['image_order'] : '', 0 ); 59 redirect( PHPWG_ROOT_PATH.'category.php'. 60 get_query_string_diff(array('image_order')) ); 44 //---------------------------------------------- change of image display order 45 if (isset($_GET['image_order'])) 46 { 47 setcookie( 48 'pwg_image_order', 49 $_GET['image_order'] > 0 ? $_GET['image_order'] : '', 50 0 51 ); 52 53 redirect( 54 PHPWG_ROOT_PATH 55 .'category.php' 56 .get_query_string_diff(array('image_order')) 57 ); 61 58 } 62 59 //-------------------------------------------------------------- initialization … … 73 70 } 74 71 75 initialize_category(); 72 include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); 73 74 // access authorization check 75 if (isset($page['cat']) and is_numeric($page['cat'])) 76 { 77 check_restrictions($page['cat']); 78 } 79 80 if (isset($page['cat']) 81 and $page['cat_nb_images'] > $user['nb_image_page']) 82 { 83 // $nav_url is used to create the navigation bar 84 $nav_url = PHPWG_ROOT_PATH.'category.php?cat='.$page['cat']; 85 86 switch ($page['cat']) 87 { 88 case 'search': 89 { 90 $nav_url.= '&search='.$_GET['search']; 91 break; 92 } 93 case 'list': 94 { 95 $nav_url.= '&list='.$_GET['list']; 96 break; 97 } 98 } 99 100 $page['navigation_bar'] = create_navigation_bar( 101 $nav_url, 102 $page['cat_nb_images'], 103 $page['start'], 104 $user['nb_image_page'], 105 'back' 106 ); 107 } 108 else 109 { 110 $page['navigation_bar'] = ''; 111 } 76 112 77 113 // caddie filling :-) 78 114 if (isset($_GET['caddie'])) 79 115 { 80 // include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 81 82 $query = ' 83 SELECT DISTINCT(id) 84 FROM '.IMAGES_TABLE.' AS i 85 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 86 '.$page['where'].' 87 ;'; 88 fill_caddie(array_from_query($query, 'id')); 116 fill_caddie($page['items']); 89 117 } 90 118 … … 325 353 326 354 //------------------------------------------------------ main part : thumbnails 327 if (isset($page['cat']) 328 and ((is_numeric($page['cat']) and $page['cat_nb_images'] != 0) 329 or in_array($page['cat'], 330 array('search' 331 ,'most_visited' 332 ,'recent_pics' 333 ,'best_rated' 334 ,'list' 335 ,'fav' 336 )))) 337 { 338 include(PHPWG_ROOT_PATH.'include/category_default.inc.php'); 339 340 if ('admin' == $user['status']) 341 { 342 $template->assign_block_vars( 343 'caddie', 344 array( 345 'URL' => 346 PHPWG_ROOT_PATH.'category.php' 347 .get_query_string_diff(array('caddie')).'&caddie=1') 348 ); 349 } 350 } 351 elseif (isset($page['cat']) and $page['cat'] == 'calendar') 352 { 353 include(PHPWG_ROOT_PATH.'include/category_calendar.inc.php'); 354 } 355 elseif (isset($page['cat']) and $page['cat'] == 'recent_cats') 356 { 357 include(PHPWG_ROOT_PATH.'include/category_recent_cats.inc.php'); 358 } 359 else 360 { 361 include(PHPWG_ROOT_PATH.'include/category_subcats.inc.php'); 362 } 355 include(PHPWG_ROOT_PATH.$page['thumbnails_include']); 363 356 //------------------------------------------------------- category informations 364 357 if ( isset ( $page['cat'] ) ) -
trunk/include/category_default.inc.php
r1014 r1036 32 32 */ 33 33 34 /** 35 * $array_cat_directories is a cache hash associating category id with their 36 * complete directory 37 */ 38 $array_cat_directories = array(); 39 40 $query = ' 41 SELECT DISTINCT(id),path,file,date_available 42 ,tn_ext,name,filesize,storage_category_id,average_rate,hit 43 FROM '.IMAGES_TABLE.' AS i 44 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=ic.image_id 45 '.$page['where'].' 46 '.$conf['order_by'].' 47 LIMIT '.$page['start'].','.$page['nb_image_page'].' 34 $page['rank_of'] = array_flip($page['items']); 35 36 $pictures = array(); 37 38 $selection = array_slice( 39 $page['items'], 40 $page['start'], 41 $page['nb_image_page'] 42 ); 43 44 if (count($selection) > 0) 45 { 46 $query = ' 47 SELECT * 48 FROM '.IMAGES_TABLE.' 49 WHERE id IN ('.implode(',', $selection).') 48 50 ;'; 49 //echo '<pre>'.$query.'</pre>'; 50 $result = pwg_query($query); 51 $result = pwg_query($query); 52 while ($row = mysql_fetch_array($result)) 53 { 54 $row['rank'] = $page['rank_of'][ $row['id'] ]; 55 56 array_push($pictures, $row); 57 } 58 59 usort($pictures, 'rank_compare'); 60 } 51 61 52 62 // template thumbnail initialization 53 if ( mysql_num_rows($result) > 0)63 if (count($pictures) > 0) 54 64 { 55 65 $template->assign_block_vars('thumbnails', array()); … … 60 70 } 61 71 62 while ($row = mysql_fetch_array($result))72 foreach ($pictures as $row) 63 73 { 64 74 $thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']); … … 151 161 } 152 162 } 163 164 pwg_debug('end include/category_default.inc.php'); 153 165 ?> -
trunk/include/common.inc.php
r1029 r1036 199 199 } 200 200 201 if ($conf['gallery_locked']) 202 { 203 echo 204 '<div style="text-align:center;">' 205 .$lang['gallery_locked_message'] 206 .'</div>'; 207 208 if ($user['status'] != 'admin') 209 { 210 exit(); 211 } 212 } 213 201 214 // only now we can set the localized username of the guest user (and not in 202 215 // include/user.inc.php) … … 210 223 // TODO : replace initial $user['template'] by $user['layout'] 211 224 212 include(PHPWG_ROOT_PATH.'template/'.$user['template'].'/theme/'.$user['theme'].'/themeconf.inc.php'); 225 include( 226 PHPWG_ROOT_PATH 227 .'template/'.$user['template'] 228 .'/theme/'.$user['theme'] 229 .'/themeconf.inc.php' 230 ); 213 231 214 232 // template instance -
trunk/include/functions_category.inc.php
r1031 r1036 54 54 } 55 55 56 /**57 * Checks whether the argument is a right parameter category id58 *59 * The argument is a right parameter if corresponds to one of these :60 *61 * - is numeric and corresponds to a category in the database62 * - equals 'fav' (for favorites)63 * - equals 'search' (when the result of a search is displayed)64 * - equals 'most_visited'65 * - equals 'best_rated'66 * - equals 'recent_pics'67 * - equals 'recent_cats'68 * - equals 'calendar'69 * - equals 'list'70 *71 * The function fills the global var $page['cat'] and returns nothing72 *73 * @param mixed category id or special category name74 * @return void75 */76 function check_cat_id( $cat )77 {78 global $page;79 80 unset( $page['cat'] );81 if ( isset( $cat ) )82 {83 if ( isset( $page['plain_structure'][$cat] ) )84 {85 $page['cat'] = $cat;86 }87 else if ( is_numeric( $cat ) )88 {89 $query = 'SELECT id';90 $query.= ' FROM '.CATEGORIES_TABLE.' WHERE id = '.$cat.';';91 $result = pwg_query( $query );92 if ( mysql_num_rows( $result ) != 0 )93 {94 $page['cat'] = $cat;95 }96 }97 if ( $cat == 'fav'98 or $cat == 'most_visited'99 or $cat == 'best_rated'100 or $cat == 'recent_pics'101 or $cat == 'recent_cats'102 or $cat == 'calendar' )103 {104 $page['cat'] = $cat;105 }106 if ($cat == 'search'107 and isset($_GET['search'])108 and is_numeric($_GET['search']))109 {110 $page['cat'] = $cat;111 }112 if ($cat == 'list'113 and isset($_GET['list'])114 and preg_match('/^\d+(,\d+)*$/', $_GET['list']))115 {116 $page['cat'] = 'list';117 }118 }119 }120 121 56 function get_categories_menu() 122 57 { … … 333 268 } 334 269 335 336 // initialize_category initializes ;-) the variables in relation337 // with category :338 // 1. calculation of the number of pictures in the category339 // 2. determination of the SQL query part to ask to find the right category340 // $page['where'] is not the same if we are in341 // - simple category342 // - search result343 // - favorites displaying344 // - most visited pictures345 // - best rated pictures346 // - recent pictures347 // - defined list (used for random)348 // 3. determination of the title of the page349 // 4. creation of the navigation bar350 function initialize_category( $calling_page = 'category' )351 {352 pwg_debug( 'start initialize_category' );353 global $page,$lang,$user,$conf;354 355 if ( isset( $page['cat'] ) )356 {357 // $page['nb_image_page'] is the number of picture to display on this page358 // By default, it is the same as the $user['nb_image_page']359 $page['nb_image_page'] = $user['nb_image_page'];360 // $url is used to create the navigation bar361 $url = PHPWG_ROOT_PATH.'category.php?cat='.$page['cat'];362 if ( isset($page['expand']) ) $url.= '&expand='.$page['expand'];363 // simple category364 if ( is_numeric( $page['cat'] ) )365 {366 $result = get_cat_info( $page['cat'] );367 $page['comment'] = $result['comment'];368 $page['cat_dir'] = $result['dir'];369 $page['cat_name'] = $result['name'];370 $page['cat_nb_images'] = $result['nb_images'];371 $page['cat_site_id'] = $result['site_id'];372 $page['cat_uploadable'] = $result['uploadable'];373 $page['cat_commentable'] = $result['commentable'];374 $page['cat_id_uppercat'] = $result['id_uppercat'];375 $page['uppercats'] = $result['uppercats'];376 $page['title'] =377 get_cat_display_name($page['cat_name'],378 '',379 false);380 $page['where'] = ' WHERE category_id = '.$page['cat'];381 }382 else383 {384 if ($page['cat'] == 'search'385 or $page['cat'] == 'most_visited'386 or $page['cat'] == 'recent_pics'387 or $page['cat'] == 'recent_cats'388 or $page['cat'] == 'best_rated'389 or $page['cat'] == 'calendar'390 or $page['cat'] == 'list')391 {392 // we must not show pictures of a forbidden category393 if ( $user['forbidden_categories'] != '' )394 {395 $forbidden = ' category_id NOT IN ';396 $forbidden.= '('.$user['forbidden_categories'].')';397 }398 }399 // search result400 if ( $page['cat'] == 'search' )401 {402 $page['title'] = $lang['search_result'];403 if ( $calling_page == 'picture' )404 {405 $page['title'].= ' : <span style="font-style:italic;">';406 $page['title'].= $_GET['search']."</span>";407 }408 409 $page['where'] = 'WHERE '.get_sql_search_clause($_GET['search']);410 411 if (isset($forbidden))412 {413 $page['where'].= "\n AND ".$forbidden;414 }415 416 $query = '417 SELECT COUNT(DISTINCT(id)) AS nb_total_images418 FROM '.IMAGES_TABLE.'419 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id420 '.$page['where'].'421 ;';422 $url.= '&search='.$_GET['search'];423 }424 // favorites displaying425 else if ( $page['cat'] == 'fav' )426 {427 check_user_favorites();428 429 $page['title'] = $lang['favorites'];430 431 $page['where'] = ', '.FAVORITES_TABLE.' AS fav';432 $page['where'].= ' WHERE user_id = '.$user['id'];433 $page['where'].= ' AND fav.image_id = id';434 435 $query = 'SELECT COUNT(*) AS nb_total_images';436 $query.= ' FROM '.FAVORITES_TABLE;437 $query.= ' WHERE user_id = '.$user['id'];438 $query.= ';';439 }440 // pictures within the short period441 else if ( $page['cat'] == 'recent_pics' )442 {443 $page['title'] = $lang['recent_pics_cat'];444 // We must find the date corresponding to :445 // today - $conf['periode_courte']446 $date = time() - 60*60*24*$user['recent_period'];447 $page['where'] = " WHERE date_available > '";448 $page['where'].= date( 'Y-m-d', $date )."'";449 if ( isset( $forbidden ) ) $page['where'].= ' AND '.$forbidden;450 451 $query = '452 SELECT COUNT(DISTINCT(id)) AS nb_total_images453 FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic454 ON id = ic.image_id455 '.$page['where'].'456 ;';457 }458 // categories containing recent pictures459 else if ( $page['cat'] == 'recent_cats' )460 {461 $page['title'] = $lang['recent_cats_cat'];462 $page['cat_nb_images'] = 0;463 }464 // most visited pictures465 else if ( $page['cat'] == 'most_visited' )466 {467 $page['title'] = $conf['top_number'].' '.$lang['most_visited_cat'];468 469 $page['where'] = 'WHERE hit > 0';470 if (isset($forbidden))471 {472 $page['where'] .= "\n".' AND '.$forbidden;473 }474 475 $conf['order_by'] = ' ORDER BY hit DESC, file ASC';476 477 // $page['cat_nb_images'] equals $conf['top_number'] unless there478 // are less visited items479 $query ='480 SELECT COUNT(DISTINCT(id)) AS count481 FROM '.IMAGES_TABLE.'482 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id483 '.$page['where'].'484 ;';485 $row = mysql_fetch_array(pwg_query($query));486 if ($row['count'] < $conf['top_number'])487 {488 $page['cat_nb_images'] = $row['count'];489 }490 else491 {492 $page['cat_nb_images'] = $conf['top_number'];493 }494 unset($query);495 496 if ( isset( $page['start'] )497 and ($page['start']+$user['nb_image_page']>=$conf['top_number']))498 {499 $page['nb_image_page'] = $conf['top_number'] - $page['start'];500 }501 }502 else if ( $page['cat'] == 'calendar' )503 {504 $page['cat_nb_images'] = 0;505 $page['title'] = $lang['calendar'];506 if (isset($_GET['year'])507 and preg_match('/^\d+$/', $_GET['year']))508 {509 $page['calendar_year'] = (int)$_GET['year'];510 }511 if (isset($_GET['month'])512 and preg_match('/^(\d+)\.(\d{2})$/', $_GET['month'], $matches))513 {514 $page['calendar_year'] = (int)$matches[1];515 $page['calendar_month'] = (int)$matches[2];516 }517 if (isset($_GET['day'])518 and preg_match('/^(\d+)\.(\d{2})\.(\d{2})$/',519 $_GET['day'],520 $matches))521 {522 $page['calendar_year'] = (int)$matches[1];523 $page['calendar_month'] = (int)$matches[2];524 $page['calendar_day'] = (int)$matches[3];525 }526 if (isset($page['calendar_year']))527 {528 $page['title'] .= ' (';529 if (isset($page['calendar_day']))530 {531 if ($page['calendar_year'] >= 1970)532 {533 $unixdate = mktime(0,0,0,534 $page['calendar_month'],535 $page['calendar_day'],536 $page['calendar_year']);537 $page['title'].= $lang['day'][date("w", $unixdate)];538 }539 $page['title'].= ' '.$page['calendar_day'].', ';540 }541 if (isset($page['calendar_month']))542 {543 $page['title'] .= $lang['month'][$page['calendar_month']].' ';544 }545 $page['title'] .= $page['calendar_year'];546 $page['title'] .= ')';547 }548 549 $page['where'] = 'WHERE '.$conf['calendar_datefield'].' IS NOT NULL';550 if (isset($forbidden))551 {552 $page['where'].= ' AND '.$forbidden;553 }554 }555 else if ($page['cat'] == 'best_rated')556 {557 $page['title'] = $conf['top_number'].' '.$lang['best_rated_cat'];558 559 $page['where'] = ' WHERE average_rate IS NOT NULL';560 561 if (isset($forbidden))562 {563 $page['where'].= ' AND '.$forbidden;564 }565 566 $conf['order_by'] = ' ORDER BY average_rate DESC, id ASC';567 568 // $page['cat_nb_images'] equals $conf['top_number'] unless there569 // are less rated items570 $query ='571 SELECT COUNT(DISTINCT(id)) AS count572 FROM '.IMAGES_TABLE.'573 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id574 '.$page['where'].'575 ;';576 $row = mysql_fetch_array(pwg_query($query));577 if ($row['count'] < $conf['top_number'])578 {579 $page['cat_nb_images'] = $row['count'];580 }581 else582 {583 $page['cat_nb_images'] = $conf['top_number'];584 }585 unset($query);586 587 588 if (isset($page['start'])589 and ($page['start']+$user['nb_image_page']>=$conf['top_number']))590 {591 $page['nb_image_page'] = $conf['top_number'] - $page['start'];592 }593 }594 else if ($page['cat'] == 'list')595 {596 $page['title'] = $lang['random_cat'];597 598 $page['where'] = 'WHERE 1=1';599 if (isset($forbidden))600 {601 $page['where'].= ' AND '.$forbidden;602 }603 $page['where'].= ' AND image_id IN ('.$_GET['list'].')';604 $page['cat_nb_images'] = count(explode(',', $_GET['list']));605 606 $url.= '&list='.$_GET['list'];607 }608 609 if (isset($query))610 {611 $result = pwg_query( $query );612 $row = mysql_fetch_array( $result );613 $page['cat_nb_images'] = $row['nb_total_images'];614 }615 }616 if ( $calling_page == 'category' )617 {618 $page['navigation_bar'] =619 create_navigation_bar( $url, $page['cat_nb_images'], $page['start'],620 $user['nb_image_page'], 'back' );621 }622 623 if ($page['cat'] != 'most_visited' and $page['cat'] != 'best_rated')624 {625 $available_image_orders = get_category_preferred_image_orders();626 627 $order_idx=0;628 if ( isset($_COOKIE['pwg_image_order']) )629 {630 $order_idx = $_COOKIE['pwg_image_order'];631 }632 633 if ( $order_idx > 0 )634 {635 $order = $available_image_orders[$order_idx][1];636 $conf['order_by'] = str_replace('ORDER BY ', 'ORDER BY '.$order.',',637 $conf['order_by'] );638 }639 }640 }641 else642 {643 $page['title'] = $lang['no_category'];644 }645 pwg_debug( 'end initialize_category' );646 }647 648 270 function display_select_categories($categories, 649 271 $selecteds, … … 736 358 return strnatcasecmp($a['global_rank'], $b['global_rank']); 737 359 } 360 361 function rank_compare($a, $b) 362 { 363 if ($a['rank'] == $b['rank']) 364 { 365 return 0; 366 } 367 368 return ($a['rank'] < $b['rank']) ? -1 : 1; 369 } 738 370 ?> -
trunk/include/functions_html.inc.php
r1031 r1036 350 350 $level = 0; 351 351 $menu = ''; 352 352 353 // $page_cat value remains 0 for special sections 353 354 $page_cat = 0; 354 355 if (isset($page['cat']) and is_numeric($page['cat']) ) … … 384 385 $url = PHPWG_ROOT_PATH.'category.php?cat='.$category['id']; 385 386 $menu.= "\n".'<a href="'.$url.'"'; 386 if ($category['id'] == $page['cat_id_uppercat']) 387 if ($page_cat != 0 388 and $category['id'] == $page['cat_id_uppercat']) 387 389 { 388 390 $menu.= ' rel="up"'; -
trunk/include/functions_user.inc.php
r906 r1036 101 101 } 102 102 103 function check_login_authorization($guest_allowed = true)104 {105 global $user,$lang,$conf,$template;106 107 if ($user['is_the_guest'] and !$guest_allowed)108 {109 echo '<div style="text-align:center;">'.$lang['only_members'].'<br />';110 echo '<a href="./identification.php">'.$lang['ident_title'].'</a></div>';111 exit();112 }113 114 if ($conf['gallery_locked'])115 {116 echo '<div style="text-align:center;">';117 echo $lang['gallery_locked_message'];118 echo '</div>';119 if ($user['status'] != 'admin')120 {121 exit();122 }123 }124 }125 126 103 function setup_style($style) 127 104 { -
trunk/include/user.inc.php
r1023 r1036 60 60 } 61 61 62 $use_cache = (defined('IN_ADMIN') and IN_ADMIN) ? false : true; 63 $user = array_merge($user, getuserdata($user['id'], $use_cache)); 62 $user = array_merge( 63 $user, 64 getuserdata( 65 $user['id'], 66 defined('IN_ADMIN') and IN_ADMIN ? false : true // use cache ? 67 ) 68 ); 64 69 65 70 // properties of user guest are found in the configuration -
trunk/picture.php
r1029 r1036 31 31 include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); 32 32 //-------------------------------------------------- access authorization check 33 check_cat_id( $_GET['cat'] ); 34 35 if (!isset($page['cat'])) 36 { 37 die($lang['access_forbiden']); 38 } 39 40 check_login_authorization(); 41 if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) 42 { 43 check_restrictions( $page['cat'] ); 44 } 33 if (isset($page['cat']) and is_numeric($page['cat'])) 34 { 35 check_restrictions($page['cat']); 36 } 37 //-------------------------------------------------------------- initialization 38 include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); 39 40 // if this image_id doesn't correspond to this category, an error message is 41 // displayed, and execution is stopped 42 if (!in_array($_GET['image_id'], $page['items'])) 43 { 44 echo ' 45 <div style="text-align:center;">'.$lang['access_forbiden'].'<br /> 46 <a href="'.PHPWG_ROOT_PATH.'category.php'.'">'.$lang['thumbnails'].'</a> 47 </div>'; 48 exit(); 49 } 50 51 $page['rank_of'] = array_flip($page['items']); 52 53 // caching first_rank, last_rank, current_rank in the displayed 54 // section. This should also help in readability. 55 $page['first_rank'] = 0; 56 $page['last_rank'] = count($page['items']) - 1; 57 $page['current_rank'] = $page['rank_of'][ $_GET['image_id'] ]; 58 59 // caching current item : readability purpose 60 $page['current_item'] = $_GET['image_id']; 61 62 if ($page['current_rank'] != $page['first_rank']) 63 { 64 // "go to first picture of this section" link is displayed only if the 65 // displayed item is not the first. 66 $template->assign_block_vars( 67 'first', 68 array( 69 'U_IMG' => 70 PHPWG_ROOT_PATH.'picture.php'. 71 get_query_string_diff( 72 array('image_id', 'add_fav', 'slideshow', 'rate') 73 ). 74 '&image_id='.$page['items'][ $page['first_rank'] ], 75 ) 76 ); 77 78 // caching previous item : readability purpose 79 $page['previous_item'] = $page['items'][ $page['current_rank'] - 1 ]; 80 } 81 82 if ($page['current_rank'] != $page['last_rank']) 83 { 84 // "go to last picture of this section" link is displayed only if the 85 // displayed item is not the last. 86 $template->assign_block_vars( 87 'last', 88 array( 89 'U_IMG' => 90 PHPWG_ROOT_PATH.'picture.php'. 91 get_query_string_diff( 92 array('image_id', 'add_fav', 'slideshow', 'rate') 93 ). 94 '&image_id='.$page['items'][ $page['last_rank'] ], 95 ) 96 ); 97 98 // caching next item : readability purpose 99 $page['next_item'] = $page['items'][ $page['current_rank'] + 1 ]; 100 } 101 45 102 //---------------------------------------- incrementation of the number of hits 46 103 if ( count(array_intersect( … … 56 113 @pwg_query( $query ); 57 114 } 58 //-------------------------------------------------------------- initialization 59 initialize_category( 'picture' ); 60 // retrieving the number of the picture in its category (in order) 61 $query = ' 62 SELECT DISTINCT(id) 63 FROM '.IMAGES_TABLE.' 64 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 65 '.$page['where'].' 66 '.$conf['order_by'].' 67 ;'; 68 $result = pwg_query( $query ); 69 $page['num'] = 0; 70 $belongs = false; 71 while ($row = mysql_fetch_array($result)) 72 { 73 if ($row['id'] == $_GET['image_id']) 74 { 75 $belongs = true; 76 break; 77 } 78 if ($page['num']==0) 79 { 80 $url_first_last = PHPWG_ROOT_PATH.'picture.php'; 81 $url_first_last.= get_query_string_diff(array('image_id','add_fav', 82 'slideshow','rate')); 83 $url_first_last.= '&image_id='; 84 $template->assign_block_vars( 85 'first', 86 array( 87 'U_IMG' => $url_first_last . $row['id'], 88 )); 89 } 90 $page['num']++; 91 } 92 if ($page['cat_nb_images']>0 and $page['num'] < $page['cat_nb_images'] - 1) 93 { 94 mysql_data_seek($result, $page['cat_nb_images'] - 1); 95 $row = mysql_fetch_array($result); 96 $url_first_last = PHPWG_ROOT_PATH.'picture.php'; 97 $url_first_last.= get_query_string_diff(array('image_id','add_fav', 98 'slideshow','rate')); 99 $url_first_last.= '&image_id='; 100 $template->assign_block_vars( 101 'last', 102 array( 103 'U_IMG' => $url_first_last . $row['id'], 104 )); 105 } 106 107 // if this image_id doesn't correspond to this category, an error message is 108 // displayed, and execution is stopped 109 if (!$belongs) 110 { 111 echo '<div style="text-align:center;">'.$lang['access_forbiden'].'<br />'; 112 echo '<a href="'.PHPWG_ROOT_PATH.'category.php'.'">'; 113 echo $lang['thumbnails'].'</a></div>'; 114 exit(); 115 } 115 116 116 //-------------------------------------------------------------- representative 117 117 if ('admin' == $user['status'] and isset($_GET['representative'])) … … 162 162 $picture = array(); 163 163 164 if ($page['num'] == 0) 165 { 166 $has_prev = false; 167 } 168 else 169 { 170 $has_prev = true; 171 } 172 173 if ($page['num'] == $page['cat_nb_images'] - 1) 174 { 175 $has_next = false; 176 } 177 else 178 { 179 $has_next = true; 164 $ids = array($_GET['image_id']); 165 if (isset($page['previous_item'])) 166 { 167 array_push($ids, $page['previous_item']); 168 } 169 if (isset($page['next_item'])) 170 { 171 array_push($ids, $page['next_item']); 180 172 } 181 173 182 174 $query = ' 183 SELECT DISTINCT(i.id), i.* 184 FROM '.IMAGES_TABLE.' AS i 185 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON i.id = ic.image_id 186 '.$page['where'].' 187 '.$conf['order_by'].' 188 '; 189 190 if ( !$has_prev ) 191 { 192 $query.= ' LIMIT 0,2'; 193 } 194 else 195 { 196 $query.= ' LIMIT '.($page['num'] - 1).',3'; 197 } 198 $query.= ';'; 199 200 $result = pwg_query( $query ); 201 $indexes = array('prev', 'current', 'next'); 202 203 foreach (array('prev', 'current', 'next') as $i) 204 { 205 if ($i == 'prev' and !$has_prev) 206 { 207 continue; 208 } 209 if ($i == 'next' and !$has_next) 210 { 211 break; 212 } 213 214 $row = mysql_fetch_array($result); 175 SELECT * 176 FROM '.IMAGES_TABLE.' 177 WHERE id IN ('.implode(',', $ids).') 178 ;'; 179 180 $result = pwg_query($query); 181 182 while ($row = mysql_fetch_array($result)) 183 { 184 if (isset($page['previous_item']) and $row['id'] == $page['previous_item']) 185 { 186 $i = 'prev'; 187 } 188 else if (isset($page['next_item']) and $row['id'] == $page['next_item']) 189 { 190 $i = 'next'; 191 } 192 else 193 { 194 $i = 'current'; 195 } 196 215 197 foreach (array_keys($row) as $key) 216 198 { … … 235 217 if (isset($row['representative_ext']) and $row['representative_ext'] != '') 236 218 { 237 $picture[$i]['src'] = $cat_directory.'/pwg_representative/'; 238 $picture[$i]['src'].= $file_wo_ext.'.'.$row['representative_ext']; 219 $picture[$i]['src'] = 220 $cat_directory.'/pwg_representative/' 221 .$file_wo_ext.'.'.$row['representative_ext']; 239 222 } 240 223 else … … 275 258 } 276 259 277 $picture[$i]['url'] = PHPWG_ROOT_PATH.'picture.php';278 $picture[$i]['url'].= get_query_string_diff(array('image_id','add_fav',279 'slideshow','rate'));280 $picture[$i]['url'].='&image_id='.$row['id'];260 $picture[$i]['url'] = 261 PHPWG_ROOT_PATH.'picture.php' 262 .get_query_string_diff(array('image_id', 'add_fav', 'slideshow', 'rate')) 263 .'&image_id='.$row['id']; 281 264 } 282 265 283 266 $url_up = PHPWG_ROOT_PATH.'category.php?cat='.$page['cat']; 284 $url_up_start = floor( $page['num'] / $user['nb_image_page'] ); 267 268 $url_up_start = floor( $page['current_rank'] / $user['nb_image_page'] ); 285 269 $url_up_start *= $user['nb_image_page']; 286 270 if ($url_up_start>0) … … 298 282 } 299 283 300 $url_admin = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'; 301 $url_admin.= '&cat_id='.$page['cat']; 302 $url_admin.= '&image_id='.$_GET['image_id']; 303 304 $url_slide = $picture['current']['url']; 305 $url_slide.= '&slideshow='.$conf['slideshow_period']; 284 $url_admin = 285 PHPWG_ROOT_PATH.'admin.php?page=picture_modify' 286 .'&cat_id='.$page['cat'] 287 .'&image_id='.$_GET['image_id']; 288 289 $url_slide = 290 $picture['current']['url'].'&slideshow='.$conf['slideshow_period']; 306 291 307 292 //----------------------------------------------------------- rate registration … … 485 470 { 486 471 $title_img = replace_space(get_cat_display_name($page['cat_name'])); 487 $n = $page[' num'] + 1;472 $n = $page['current_rank'] + 1; 488 473 $title_nb = $n.'/'.$page['cat_nb_images']; 489 474 } … … 527 512 528 513 $page['body_id'] = 'thePicturePage'; 529 //------------------------------------------------------- -navigation management530 if ( $has_prev)514 //------------------------------------------------------- navigation management 515 if (isset($page['previous_item'])) 531 516 { 532 517 $template->assign_block_vars( … … 537 522 'U_IMG' => $picture['prev']['url'], 538 523 'U_IMG_SRC' => $picture['prev']['src'] 539 )); 540 } 541 542 if ($has_next) 524 ) 525 ); 526 } 527 528 if (isset($page['next_item'])) 543 529 { 544 530 $template->assign_block_vars( … … 549 535 'U_IMG' => $picture['next']['url'], 550 536 'U_IMG_SRC' => $picture['next']['src'] // allow navigator to preload 551 )); 537 ) 538 ); 552 539 } 553 540 -
trunk/profile.php
r1020 r1036 33 33 define('PHPWG_ROOT_PATH','./'); 34 34 include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); 35 check_login_authorization(false); 35 36 if ($user['is_the_guest'] and !$guest_allowed) 37 { 38 echo '<div style="text-align:center;">'.$lang['only_members'].'<br />'; 39 echo '<a href="./identification.php">'.$lang['ident_title'].'</a></div>'; 40 exit(); 41 } 42 36 43 $userdata = $user; 37 44 -
trunk/search.php
r1015 r1036 29 29 define('PHPWG_ROOT_PATH','./'); 30 30 include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); 31 //-------------------------------------------------- access authorization check32 check_login_authorization();33 31 //------------------------------------------------------------------ form check 34 32 $errors = array(); -
trunk/upload.php
r1004 r1036 113 113 114 114 //-------------------------------------------------- access authorization check 115 check_login_authorization(); 116 check_cat_id( $_GET['cat'] ); 117 if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) 115 if (is_numeric($_GET['cat'])) 116 { 117 $page['cat'] = $_GET['cat']; 118 } 119 120 if (isset($page['cat'])) 118 121 { 119 122 check_restrictions( $page['cat'] );
Note: See TracChangeset
for help on using the changeset viewer.