Changeset 1082
- Timestamp:
- Mar 15, 2006, 11:44:35 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/about.php
r1072 r1082 52 52 $template->assign_vars( 53 53 array( 54 'U_HOME' => PHPWG_ROOT_PATH.'category.php'54 'U_HOME' => make_index_url(), 55 55 ) 56 56 ); -
trunk/admin.php
r1072 r1082 96 96 'U_USERS'=> $link_start.'user_list', 97 97 'U_GROUPS'=> $link_start.'group_list', 98 'U_RETURN'=> PHPWG_ROOT_PATH.'category.php',98 'U_RETURN'=> make_index_url(), 99 99 'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php', 100 100 'L_ADMIN' => $lang['admin'], -
trunk/admin/cat_list.php
r1072 r1082 270 270 'category', 271 271 array( 272 'NAME'=>$category['name'], 273 'ID'=>$category['id'], 274 'RANK'=>$category['rank']*10, 275 276 'U_JUMPTO'=>PHPWG_ROOT_PATH.'category.php?cat='.$category['id'], 277 'U_CHILDREN'=>$cat_list_url.'&parent_id='.$category['id'], 278 'U_EDIT'=>$base_url.'cat_modify&cat_id='.$category['id'] 272 'NAME' => $category['name'], 273 'ID' => $category['id'], 274 'RANK' => $category['rank']*10, 275 276 'U_JUMPTO' => make_index_url( 277 array( 278 'category' => $category['id'], 279 ) 280 ), 281 282 'U_CHILDREN' => $cat_list_url.'&parent_id='.$category['id'], 283 'U_EDIT' => $base_url.'cat_modify&cat_id='.$category['id'], 279 284 ) 280 285 ); -
trunk/admin/cat_modify.php
r1072 r1082 270 270 } 271 271 272 $template->assign_vars(array( 273 'CATEGORIES_NAV'=>$navigation, 274 'CAT_NAME'=>$category['name'], 275 'CAT_COMMENT'=>$category['comment'], 276 277 $status=>'checked="checked"', 278 $lock=>'checked="checked"', 279 $commentable=>'checked="checked"', 280 $uploadable=>'checked="checked"', 281 282 'L_EDIT_NAME'=>$lang['name'], 283 'L_STORAGE'=>$lang['storage'], 284 'L_REMOTE_SITE'=>$lang['remote_site'], 285 'L_EDIT_COMMENT'=>$lang['description'], 286 'L_EDIT_STATUS'=>$lang['conf_access'], 287 'L_STATUS_PUBLIC'=>$lang['public'], 288 'L_STATUS_PRIVATE'=>$lang['private'], 289 'L_EDIT_LOCK'=>$lang['lock'], 290 'L_EDIT_UPLOADABLE'=>$lang['editcat_uploadable'], 291 'L_EDIT_COMMENTABLE'=>$lang['comments'], 292 'L_YES'=>$lang['yes'], 293 'L_NO'=>$lang['no'], 294 'L_SUBMIT'=>$lang['submit'], 295 'L_SET_RANDOM_REPRESENTANT'=>$lang['cat_representant'], 296 297 'U_JUMPTO'=>PHPWG_ROOT_PATH.'category.php?cat='.$category['id'], 298 'U_CHILDREN'=>$cat_list_url.'&parent_id='.$category['id'], 299 'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=cat_modify', 300 301 'F_ACTION'=>$form_action 302 )); 272 $template->assign_vars( 273 array( 274 'CATEGORIES_NAV' => $navigation, 275 'CAT_NAME' => $category['name'], 276 'CAT_COMMENT' => $category['comment'], 277 278 $status => 'checked="checked"', 279 $lock => 'checked="checked"', 280 $commentable => 'checked="checked"', 281 $uploadable => 'checked="checked"', 282 283 'L_EDIT_NAME' => $lang['name'], 284 'L_STORAGE' => $lang['storage'], 285 'L_REMOTE_SITE' => $lang['remote_site'], 286 'L_EDIT_COMMENT' => $lang['description'], 287 'L_EDIT_STATUS' => $lang['conf_access'], 288 'L_STATUS_PUBLIC' => $lang['public'], 289 'L_STATUS_PRIVATE' => $lang['private'], 290 'L_EDIT_LOCK' => $lang['lock'], 291 'L_EDIT_UPLOADABLE' => $lang['editcat_uploadable'], 292 'L_EDIT_COMMENTABLE' => $lang['comments'], 293 'L_YES' => $lang['yes'], 294 'L_NO' => $lang['no'], 295 'L_SUBMIT' => $lang['submit'], 296 'L_SET_RANDOM_REPRESENTANT'=>$lang['cat_representant'], 297 298 'U_JUMPTO' => make_index_url( 299 array( 300 'category' => $category['id'], 301 ) 302 ), 303 304 'U_CHILDREN' => $cat_list_url.'&parent_id='.$category['id'], 305 'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=cat_modify', 306 307 'F_ACTION' => $form_action, 308 ) 309 ); 303 310 304 311 -
trunk/admin/include/functions.php
r1070 r1082 781 781 $query = ' 782 782 UPDATE '.$tablename.' AS t1, '.$temporary_tablename.' AS t2 783 SET '.implode("\n , ", 784 array_map( 785 create_function('$s', 'return "t1.$s = t2.$s";') 786 , $dbfields['update'])).' 787 WHERE '.implode("\n AND ", 788 array_map( 789 create_function('$s', 'return "t1.$s = t2.$s";') 790 , $dbfields['primary'])).' 783 SET '. 784 implode( 785 "\n , ", 786 array_map( 787 create_function('$s', 'return "t1.$s = t2.$s";'), 788 $dbfields['update'] 789 ) 790 ).' 791 WHERE '. 792 implode( 793 "\n AND ", 794 array_map( 795 create_function('$s', 'return "t1.$s = t2.$s";'), 796 $dbfields['primary'] 797 ) 798 ).' 791 799 ;'; 792 800 pwg_query($query); … … 841 849 foreach ($uppercats_array as $id => $uppercats) 842 850 { 843 $data = array(); 844 $data['id'] = $id; 845 $global_rank = preg_replace('/(\d+)/e', 846 "\$ranks_array['$1']", 847 str_replace(',', '.', $uppercats)); 848 $data['global_rank'] = $global_rank; 849 array_push($datas, $data); 850 } 851 852 $fields = array('primary' => array('id'), 'update' => array('global_rank')); 853 mass_updates(CATEGORIES_TABLE, $fields, $datas); 851 array_push( 852 $datas, 853 array( 854 'id' => $id, 855 'global_rank' => preg_replace( 856 '/(\d+)/e', 857 "\$ranks_array['$1']", 858 str_replace(',', '.', $uppercats) 859 ), 860 ) 861 ); 862 } 863 864 mass_updates( 865 CATEGORIES_TABLE, 866 array( 867 'primary' => array('id'), 868 'update' => array('global_rank') 869 ), 870 $datas 871 ); 854 872 } 855 873 … … 1254 1272 // users present in user related tables must be present in the base user 1255 1273 // table 1256 $tables = 1257 array(1258 USER_MAIL_NOTIFICATION_TABLE,1259 USER_FEED_TABLE,1260 USER_INFOS_TABLE,1261 USER_ACCESS_TABLE,1262 USER_CACHE_TABLE,1263 USER_GROUP_TABLE1264 );1274 $tables = array( 1275 USER_MAIL_NOTIFICATION_TABLE, 1276 USER_FEED_TABLE, 1277 USER_INFOS_TABLE, 1278 USER_ACCESS_TABLE, 1279 USER_CACHE_TABLE, 1280 USER_GROUP_TABLE 1281 ); 1282 1265 1283 foreach ($tables as $table) 1266 1284 { … … 1269 1287 FROM '.$table.' 1270 1288 ;'; 1271 $to_delete = 1272 array_diff( 1273 array_from_query($query, 'user_id'), 1274 $base_users 1275 ); 1289 $to_delete = array_diff( 1290 array_from_query($query, 'user_id'), 1291 $base_users 1292 ); 1276 1293 1277 1294 if (count($to_delete) > 0) -
trunk/admin/picture_modify.php
r1072 r1082 334 334 // linked category 335 335 // 4. if no category reachable, no jumpto link 336 $base_url_img = PHPWG_ROOT_PATH.'picture.php';337 $base_url_img.= '?image_id='.$_GET['image_id'];338 $base_url_img.= '&cat=';339 unset($url_img);340 336 341 337 $query = ' … … 344 340 WHERE image_id = '.$_GET['image_id'].' 345 341 ;'; 342 346 343 $authorizeds = array_diff( 347 344 array_from_query($query, 'category_id'), 348 explode(',', calculate_permissions($user['id'], $user['status'])) 345 explode( 346 ',', 347 calculate_permissions($user['id'], $user['status']) 348 ) 349 349 ); 350 350 … … 352 352 and in_array($_GET['cat_id'], $authorizeds)) 353 353 { 354 $url_img = $base_url_img.$_GET['cat_id']; 354 $url_img = make_picture_URL( 355 array( 356 'image_id' => $_GET['image_id'], 357 'category' => $_GET['cat_id'], 358 ) 359 ); 355 360 } 356 361 else … … 358 363 foreach ($authorizeds as $category) 359 364 { 360 $url_img = $base_url_img.$category; 365 $url_img = make_picture_URL( 366 array( 367 'image_id' => $_GET['image_id'], 368 'category' => $category, 369 ) 370 ); 361 371 break; 362 372 } -
trunk/category.php
r1081 r1082 58 58 59 59 redirect( 60 PHPWG_ROOT_PATH 61 .'category.php' 62 .get_query_string_diff(array('image_order')) 60 make_index_URL( 61 array(), 62 array('image_order') 63 ) 63 64 ); 64 65 } 65 66 //-------------------------------------------------------------- initialization 67 include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); 66 68 // detection of the start picture to display 67 if ( !isset( $_GET['start'] ) 68 or !is_numeric( $_GET['start'] ) 69 or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) ) 69 if (!isset($page['start'])) 70 70 { 71 71 $page['start'] = 0; 72 72 } 73 else74 {75 $page['start'] = $_GET['start'];76 }77 78 include(PHPWG_ROOT_PATH.'include/section_init.inc.php');79 73 80 74 // access authorization check 81 if (isset($page['cat ']) and is_numeric($page['cat']))82 { 83 check_restrictions($page['cat ']);84 } 85 86 if ( 75 if (isset($page['category'])) 76 { 77 check_restrictions($page['category']); 78 } 79 80 if (isset($page['cat_nb_images']) 87 81 and $page['cat_nb_images'] > $user['nb_image_page']) 88 82 { 89 // $nav_url is used to create the navigation bar90 $nav_url = PHPWG_ROOT_PATH.'category.php?';91 if ( isset($page['cat']) )92 {93 $nav_url .= 'cat='.$page['cat'].'&';94 95 switch ($page['cat'])96 {97 case 'search':98 {99 $nav_url.= 'search='.$_GET['search'].'&';100 break;101 }102 case 'list':103 {104 $nav_url.= 'list='.$_GET['list'].'&';105 break;106 }107 }108 }109 110 if ( isset($_GET['calendar']) )111 {112 $nav_url.= 'calendar='.$_GET['calendar'];113 }114 else115 {116 $nav_url = preg_replace('/&$/', '', $nav_url);117 }118 119 83 $page['navigation_bar'] = create_navigation_bar( 120 $nav_url,84 duplicate_index_URL(array(), array('start')), 121 85 $page['cat_nb_images'], 122 86 $page['start'], … … 134 98 { 135 99 fill_caddie($page['items']); 100 // redirect(); 136 101 } 137 102 … … 146 111 $template->set_filenames( array('category'=>'category.tpl') ); 147 112 //-------------------------------------------------------------- category title 148 if (isset($page['cat']) and is_numeric($page['cat'])) 149 { 150 $template_title = get_cat_display_name($page['cat_name'], 151 'category.php?cat=', 152 false); 113 if (isset($page['category'])) 114 { 115 $template_title = get_cat_display_name( 116 $page['cat_name'], 117 'category.php?/category/', 118 false 119 ); 153 120 } 154 121 else … … 157 124 } 158 125 159 if ( isset( $page['cat_nb_images'] ) and $page['cat_nb_images'] > 0)126 if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0) 160 127 { 161 128 $template_title.= ' ['.$page['cat_nb_images'].']'; … … 164 131 $icon_recent = get_icon(date('Y-m-d')); 165 132 166 $calendar_view_link = PHPWG_ROOT_PATH.'category.php' 167 .get_query_string_diff(array('start','calendar')); 168 if ( ! isset($_GET['calendar']) ) 169 { 170 $calendar_view_link .= (empty($_GET)? '?':'&' ) . 'calendar='; 133 $calendar_view_link = duplicate_index_URL( 134 array(), // nothing to redefine 135 array('chronology_type', 'start') // what to remove ? 136 ); 137 138 if (!isset($page['chronology_type'])) 139 { 140 $calendar_view_link.= '/calendar-'; 141 171 142 $template->assign_block_vars( 172 143 'mode_created', 173 array( 'URL' => $calendar_view_link.'created' ) 174 ); 144 array( 145 'URL' => $calendar_view_link.'created' 146 ) 147 ); 148 175 149 $template->assign_block_vars( 176 150 'mode_posted', 177 array( 'URL' => $calendar_view_link.'posted' ) 178 ); 179 151 array( 152 'URL' => $calendar_view_link.'posted' 153 ) 154 ); 180 155 } 181 156 else … … 183 158 $template->assign_block_vars( 184 159 'mode_normal', 185 array( 'URL' => $calendar_view_link ) 186 ); 187 if (get_query_string_diff( array('start','calendar') )=='') 188 { 189 $calendar_view_link .= '?'; 190 } 191 else 192 { 193 $calendar_view_link .= '&'; 194 } 195 196 $calendar_view_link .= 'calendar='; 197 if ( strpos($_GET['calendar'], 'posted') === false) 160 array( 161 'URL' => $calendar_view_link 162 ) 163 ); 164 165 $calendar_view_link .= '/calendar-'; 166 if ($page['chronology_type'] == 'created') 198 167 { 199 168 $template->assign_block_vars( 200 169 'mode_posted', 201 array( 'URL' => $calendar_view_link.'posted' ) 170 array( 171 'URL' => $calendar_view_link.'posted' 172 ) 202 173 ); 203 174 } … … 206 177 $template->assign_block_vars( 207 178 'mode_created', 208 array( 'URL' => $calendar_view_link.'created' ) 179 array( 180 'URL' => $calendar_view_link.'created' 181 ) 209 182 ); 210 183 } … … 213 186 $template->assign_vars( 214 187 array( 215 'NB_PICTURE' => $user['nb_total_images'],216 'TITLE' => $template_title,217 'USERNAME' => $user['username'],218 'TOP_NUMBER'=>$conf['top_number'],219 'MENU_CATEGORIES_CONTENT'=>get_categories_menu(),220 221 'L_CATEGORIES' => $lang['categories'],222 'L_HINT_CATEGORY' => $lang['hint_category'],223 'L_SUBCAT' => $lang['sub-cat'],224 'L_IMG_AVAILABLE' => $lang['images_available'],225 'L_TOTAL' => $lang['total'],226 'L_SPECIAL_CATEGORIES' => $lang['special_categories'],227 'L_SUMMARY' => $lang['title_menu'],228 'L_UPLOAD' => $lang['upload_picture'],229 'L_COMMENT' => $lang['comments'],230 'L_IDENTIFY' => $lang['identification'],231 'L_PASSWORD' => $lang['password'],232 'L_HELLO' => $lang['hello'],233 'L_REGISTER' => $lang['ident_register'],234 'L_LOGOUT' => $lang['logout'],235 'L_ADMIN' => $lang['admin'],236 'L_ADMIN_HINT' => $lang['hint_admin'],237 'L_PROFILE' => $lang['customize'],238 'L_PROFILE_HINT' => $lang['hint_customize'],239 'L_REMEMBER_ME' => $lang['remember_me'],240 241 'F_IDENTIFY' => PHPWG_ROOT_PATH.'identification.php',242 'T_RECENT' => $icon_recent,243 244 'U_HOME' => PHPWG_ROOT_PATH.'category.php',245 'U_REGISTER' => PHPWG_ROOT_PATH.'register.php',246 'U_LOST_PASSWORD' => PHPWG_ROOT_PATH.'password.php',247 'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout',248 'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php',249 'U_PROFILE'=> PHPWG_ROOT_PATH.'profile.php',250 )251 );252 253 if ( isset($page['cat']) and 'search' == $page['cat'])188 'NB_PICTURE' => $user['nb_total_images'], 189 'TITLE' => $template_title, 190 'USERNAME' => $user['username'], 191 'TOP_NUMBER' => $conf['top_number'], 192 'MENU_CATEGORIES_CONTENT' => get_categories_menu(), 193 194 'L_CATEGORIES' => $lang['categories'], 195 'L_HINT_CATEGORY' => $lang['hint_category'], 196 'L_SUBCAT' => $lang['sub-cat'], 197 'L_IMG_AVAILABLE' => $lang['images_available'], 198 'L_TOTAL' => $lang['total'], 199 'L_SPECIAL_CATEGORIES' => $lang['special_categories'], 200 'L_SUMMARY' => $lang['title_menu'], 201 'L_UPLOAD' => $lang['upload_picture'], 202 'L_COMMENT' => $lang['comments'], 203 'L_IDENTIFY' => $lang['identification'], 204 'L_PASSWORD' => $lang['password'], 205 'L_HELLO' => $lang['hello'], 206 'L_REGISTER' => $lang['ident_register'], 207 'L_LOGOUT' => $lang['logout'], 208 'L_ADMIN' => $lang['admin'], 209 'L_ADMIN_HINT' => $lang['hint_admin'], 210 'L_PROFILE' => $lang['customize'], 211 'L_PROFILE_HINT' => $lang['hint_customize'], 212 'L_REMEMBER_ME' => $lang['remember_me'], 213 214 'F_IDENTIFY' => PHPWG_ROOT_PATH.'identification.php', 215 'T_RECENT' => $icon_recent, 216 217 'U_HOME' => make_index_URL(), 218 'U_REGISTER' => PHPWG_ROOT_PATH.'register.php', 219 'U_LOST_PASSWORD' => PHPWG_ROOT_PATH.'password.php', 220 'U_LOGOUT' => make_index_URL().'&act=logout', 221 'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php', 222 'U_PROFILE'=> PHPWG_ROOT_PATH.'profile.php', 223 ) 224 ); 225 226 if ('search' == $page['section']) 254 227 { 255 228 $template->assign_block_vars( 256 229 'search_rules', 257 230 array( 258 'URL' => PHPWG_ROOT_PATH.'/search_rules.php?search_id='.$ _GET['search'],231 'URL' => PHPWG_ROOT_PATH.'/search_rules.php?search_id='.$page['search'], 259 232 ) 260 233 ); … … 272 245 'URL' => $url, 273 246 'LABEL' => $label 274 )); 247 ) 248 ); 275 249 } 276 250 } … … 284 258 'special_cat', 285 259 array( 286 'URL' => PHPWG_ROOT_PATH.'category.php?cat=fav',260 'URL' => make_index_URL(array('section' => 'favorites')), 287 261 'TITLE' => $lang['favorite_cat_hint'], 288 262 'NAME' => $lang['favorite_cat'] … … 293 267 'special_cat', 294 268 array( 295 'URL' => PHPWG_ROOT_PATH.'category.php?cat=most_visited',269 'URL' => make_index_URL(array('section' => 'most_visited')), 296 270 'TITLE' => $lang['most_visited_cat_hint'], 297 271 'NAME' => $lang['most_visited_cat'] … … 303 277 'special_cat', 304 278 array( 305 'URL' => PHPWG_ROOT_PATH.'category.php?cat=best_rated',279 'URL' => make_index_URL(array('section' => 'best_rated')), 306 280 'TITLE' => $lang['best_rated_cat_hint'], 307 281 'NAME' => $lang['best_rated_cat'] … … 321 295 'special_cat', 322 296 array( 323 'URL' => PHPWG_ROOT_PATH.'category.php?cat=recent_pics',297 'URL' => make_index_URL(array('section' => 'recent_pics')), 324 298 'TITLE' => $lang['recent_pics_cat_hint'], 325 299 'NAME' => $lang['recent_pics_cat'] … … 329 303 'special_cat', 330 304 array( 331 'URL' => PHPWG_ROOT_PATH.'category.php?cat=recent_cats',305 'URL' => make_index_URL(array('section' => 'recent_cats')), 332 306 'TITLE' => $lang['recent_cats_cat_hint'], 333 307 'NAME' => $lang['recent_cats_cat'] 334 308 )); 309 335 310 // calendar 336 if ( $conf['calendar_datefield'] == 'date_available' )337 {338 $calendar_link = 'posted';339 }340 else341 {342 $calendar_link = 'created';343 }344 $calendar_link .= '-monthly-c';345 311 $template->assign_block_vars( 346 312 'special_cat', 347 313 array( 348 'URL' => PHPWG_ROOT_PATH.'category.php?calendar='.$calendar_link, 314 'URL' => 315 make_index_URL() 316 .'/calendar-' 317 .($conf['calendar_datefield'] == 'date_available' ? 'posted' : 'created') 318 .'-monthly-c', 349 319 'TITLE' => $lang['calendar_hint'], 350 320 'NAME' => $lang['calendar'] 351 )); 321 ) 322 ); 352 323 //--------------------------------------------------------------------- summary 353 324 … … 386 357 387 358 // search link 388 $template->assign_block_vars('summary', array( 389 'TITLE'=>$lang['hint_search'], 390 'NAME'=>$lang['search'], 391 'U_SUMMARY'=> 'search.php', 392 'REL'=> 'rel="search"' 393 )); 359 $template->assign_block_vars( 360 'summary', 361 array( 362 'TITLE'=>$lang['hint_search'], 363 'NAME'=>$lang['search'], 364 'U_SUMMARY'=> 'search.php', 365 'REL'=> 'rel="search"' 366 ) 367 ); 394 368 395 369 // comments link 396 $template->assign_block_vars('summary', array( 397 'TITLE'=>$lang['hint_comments'], 398 'NAME'=>$lang['comments'], 399 'U_SUMMARY'=> 'comments.php', 400 )); 370 $template->assign_block_vars( 371 'summary', 372 array( 373 'TITLE'=>$lang['hint_comments'], 374 'NAME'=>$lang['comments'], 375 'U_SUMMARY'=> 'comments.php', 376 ) 377 ); 401 378 402 379 // about link 403 $template->assign_block_vars('summary', array( 404 'TITLE'=>$lang['about_page_title'], 405 'NAME'=>$lang['About'], 406 'U_SUMMARY'=> 'about.php?'.str_replace( '&', '&', $_SERVER['QUERY_STRING'] ) 407 )); 380 $template->assign_block_vars( 381 'summary', 382 array( 383 'TITLE' => $lang['about_page_title'], 384 'NAME' => $lang['About'], 385 'U_SUMMARY' => 'about.php?'.str_replace( 386 '&', 387 '&', 388 $_SERVER['QUERY_STRING'] 389 ) 390 ) 391 ); 408 392 409 393 // notification … … 415 399 'U_SUMMARY'=> PHPWG_ROOT_PATH.'notification.php', 416 400 'REL'=> 'rel="nofollow"' 417 )); 418 419 if (isset($page['cat']) 420 and is_numeric($page['cat']) 421 and is_admin()) 401 ) 402 ); 403 404 if (isset($page['category']) and is_admin()) 422 405 { 423 406 $template->assign_block_vars( … … 425 408 array( 426 409 'URL' => 427 428 .'&cat_id='.$page['cat']410 PHPWG_ROOT_PATH.'admin.php?page=cat_modify' 411 .'&cat_id='.$page['category'] 429 412 ) 430 413 ); … … 432 415 433 416 //------------------------------------------------------ main part : thumbnails 434 if ( isset($page['thumbnails_include']))417 if (isset($page['thumbnails_include'])) 435 418 { 436 419 include(PHPWG_ROOT_PATH.$page['thumbnails_include']); 437 420 } 438 421 //------------------------------------------------------- category informations 439 if ( $page['navigation_bar'] != '' 440 or ( isset( $page['comment'] ) and $page['comment'] != '' ) ) 422 if ( 423 $page['navigation_bar'] != '' 424 or (isset($page['comment']) and $page['comment'] != '') 425 ) 441 426 { 442 427 $template->assign_block_vars('cat_infos',array()); 443 428 } 444 429 // navigation bar 445 if ( $page['navigation_bar'] != '')430 if ($page['navigation_bar'] != '') 446 431 { 447 432 $template->assign_block_vars( 448 433 'cat_infos.navigation', 449 array( 'NAV_BAR' => $page['navigation_bar'])450 );451 } 452 453 if ( ( isset($page['cat_nb_images']) and $page['cat_nb_images']>0 ) 454 and 455 ( !isset($page['cat']) 456 or ($page['cat'] != 'most_visited' and $page['cat'] != 'best_rated') )457 )434 array( 435 'NAV_BAR' => $page['navigation_bar'], 436 ) 437 ); 438 } 439 440 if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0 441 and $page['section'] != 'most_visited' 442 and $page['section'] != 'best_rated') 458 443 { 459 444 // image order 460 445 $template->assign_block_vars( 'preferred_image_order', array() ); 461 446 462 $order_idx = isset($_COOKIE['pwg_image_order']) ? 463 $_COOKIE['pwg_image_order'] : 0; 447 $order_idx = isset($_COOKIE['pwg_image_order']) 448 ? $_COOKIE['pwg_image_order'] 449 : 0 450 ; 464 451 465 452 $orders = get_category_preferred_image_orders(); 466 for ( 453 for ($i = 0; $i < count($orders); $i++) 467 454 { 468 455 if ($orders[$i][2]) 469 456 { 470 $ url = PHPWG_ROOT_PATH.'category.php'471 .get_query_string_diff(array('image_order'));472 $url .= '&image_order='.$i;473 $template->assign_block_vars( 'preferred_image_order.order', array(474 'DISPLAY' => $orders[$i][0],475 'URL' => $url,476 'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : '' ),477 ) );457 $template->assign_block_vars( 458 'preferred_image_order.order', 459 array( 460 'DISPLAY' => $orders[$i][0], 461 'URL' => duplicate_index_URL().'&image_order='.$i, 462 'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''), 463 ) 464 ); 478 465 } 479 466 } 480 467 } 481 468 482 if ( isset ( $page['cat'] ))469 if (isset($page['category'])) 483 470 { 484 471 // upload a picture in the category 485 if (is_numeric($page['cat']) 486 // and $page['cat_site_id'] == 1 487 and $page['cat_dir'] != '' 488 and $page['cat_uploadable']) 489 { 490 $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat']; 472 if ($page['cat_uploadable']) 473 { 474 $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['category']; 491 475 $template->assign_block_vars( 492 476 'upload', 493 array('U_UPLOAD'=> $url ) 477 array( 478 'U_UPLOAD'=> $url 479 ) 494 480 ); 495 481 } 482 496 483 // category comment 497 if ( isset( $page['comment'] ) and $page['comment'] != '')484 if (isset($page['comment']) and $page['comment'] != '') 498 485 { 499 486 $template->assign_block_vars( 500 487 'cat_infos.comment', 501 array('COMMENTS' => $page['comment']) 488 array( 489 'COMMENTS' => $page['comment'] 490 ) 502 491 ); 503 492 } 504 493 } 505 494 //------------------------------------------------------------ log informations 506 pwg_log( 'category', $page['title']);495 pwg_log('category', $page['title']); 507 496 508 497 $template->parse('category'); -
trunk/comments.php
r1072 r1082 185 185 'F_AUTHOR'=>@$_GET['author'], 186 186 187 'U_HOME' => PHPWG_ROOT_PATH.'category.php'187 'U_HOME' => make_index_url(), 188 188 ) 189 189 ); -
trunk/identification.php
r1068 r1082 65 65 } 66 66 log_user( $row['id'], $remember_me); 67 redirect(empty($redirect_to) ? 'category.php': $redirect_to);67 redirect(empty($redirect_to) ? make_index_url() : $redirect_to); 68 68 } 69 69 else … … 95 95 'U_REGISTER' => PHPWG_ROOT_PATH.'register.php', 96 96 'U_LOST_PASSWORD' => PHPWG_ROOT_PATH.'password.php', 97 'U_HOME' => PHPWG_ROOT_PATH.'category.php',97 'U_HOME' => make_index_url(), 98 98 'U_REDIRECT' => $redirect_to, 99 99 -
trunk/include/category_default.inc.php
r1056 r1082 27 27 28 28 /** 29 * This file is included by category.phpto show thumbnails for the default29 * This file is included by the main page to show thumbnails for the default 30 30 * case 31 31 * … … 82 82 83 83 // url link on picture.php page 84 $url_link = PHPWG_ROOT_PATH.'picture.php? image_id='.$row['id'];84 $url_link = PHPWG_ROOT_PATH.'picture.php?/'.$row['id']; 85 85 86 if (isset($page['cat']))86 switch ($page['section']) 87 87 { 88 $url_link.= '&cat='.$page['cat']; 89 90 if ($page['cat'] == 'search') 88 case 'categories' : 91 89 { 92 $url_link.= '&search='.$_GET['search']; 90 $url_link.= '/category/'.$page['category']; 91 break; 93 92 } 94 else if ($page['cat'] == 'list')93 case 'tags' : 95 94 { 96 $url_link.= '&list='.$_GET['list']; 95 // TODO 96 break; 97 } 98 case 'search' : 99 { 100 $url_link.= '/search/'.$page['search']; 101 break; 102 } 103 case 'list' : 104 { 105 $url_link.= '/list/'.implode(',', $page['list']); 106 break; 107 } 108 default : 109 { 110 $url_link.= '/'.$page['section']; 97 111 } 98 112 } 99 113 100 if (isset($ _GET['calendar']))114 if (isset($page['chronology'])) 101 115 { 102 $url_link.= ' &calendar='.$_GET['calendar'];116 $url_link.= '/chronology='.$page['chronology']; 103 117 } 104 118 … … 126 140 $name = str_replace('_', ' ', get_filename_wo_extension($row['file'])); 127 141 } 128 if ( isset($page['cat']) ) 142 143 switch ($page['section']) 129 144 { 130 if ($page['cat'] == 'best_rated')145 case 'best_rated' : 131 146 { 132 147 $name = '('.$row['average_rate'].') '.$name; 148 break; 133 149 } 134 elseif ($page['cat'] == 'most_visited')150 case 'most_visited' : 135 151 { 136 152 $name = '('.$row['hit'].') '.$name; 153 break; 137 154 } 138 139 if ($page['cat'] == 'search') 155 case 'search' : 140 156 { 141 157 $name = replace_search($name, $_GET['search']); 158 break; 142 159 } 143 160 } … … 152 169 153 170 if ($user['show_nb_comments'] 154 and is _numeric($page['cat'])171 and isset($page['category']) 155 172 and $page['cat_commentable']) 156 173 { -
trunk/include/category_recent_cats.inc.php
r1004 r1082 27 27 28 28 /** 29 * This file is included by category.phpto show thumbnails for recent_cats29 * This file is included by the main page to show thumbnails for recent_cats 30 30 * category 31 31 * … … 66 66 while ( $row = mysql_fetch_array( $result ) ) 67 67 { 68 $name = get_cat_display_name_cache($row['uppercats'], '', false);69 70 $thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']);71 72 $url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['category_id'];73 74 68 $template->assign_block_vars( 75 69 'thumbnails.line.thumbnail', 76 70 array( 77 'IMAGE' => $thumbnail_src, 78 'IMAGE_ALT' => $row['file'], 79 'IMAGE_TITLE' => $lang['hint_category'], 80 81 'U_IMG_LINK' => $url_link 71 'IMAGE' => get_thumbnail_src($row['path'], @$row['tn_ext']), 72 'IMAGE_ALT' => $row['file'], 73 'IMAGE_TITLE' => $lang['hint_category'], 74 75 'U_IMG_LINK' => make_index_url( 76 array( 77 'category' => $row['category_id'], 78 ) 79 ), 82 80 ) 83 81 ); … … 86 84 'thumbnails.line.thumbnail.category_name', 87 85 array( 88 'NAME' => $name86 'NAME' => get_cat_display_name_cache($row['uppercats'], '', false), 89 87 ) 90 88 ); -
trunk/include/category_subcats.inc.php
r1004 r1082 27 27 28 28 /** 29 * This file is included by category.phpto show thumbnails for a category29 * This file is included by the main page to show thumbnails for a category 30 30 * that have only subcategories 31 31 * … … 35 35 SELECT id, name, date_last, representative_picture_id 36 36 FROM '.CATEGORIES_TABLE.' 37 WHERE id_uppercat '; 38 if (!isset($page['cat']) or !is_numeric($page['cat'])) 39 { 40 $query.= 'is NULL'; 41 } 42 else 43 { 44 $query.= '= '.$page['cat']; 45 } 46 $query.= ' 37 WHERE id_uppercat '. 38 (!isset($page['category']) ? 'is NULL' : '= '.$page['category']).' 47 39 AND id NOT IN ('.$user['forbidden_categories'].') 48 40 ORDER BY rank … … 143 135 foreach ($cat_thumbnails as $item) 144 136 { 145 $url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['id'];146 147 137 $template->assign_block_vars( 148 138 'thumbnails.line.thumbnail', 149 139 array( 150 'IMAGE' => $images[$item['picture']],151 'IMAGE_ALT' => $item['name'],140 'IMAGE' => $images[$item['picture']], 141 'IMAGE_ALT' => $item['name'], 152 142 'IMAGE_TITLE' => $lang['hint_category'], 153 'IMAGE_TS' => get_icon(@$item['date_last']), 154 'U_IMG_LINK' => 155 PHPWG_ROOT_PATH.'category.php?cat='.$item['category'] 143 'IMAGE_TS' => get_icon(@$item['date_last']), 144 145 'U_IMG_LINK' => make_index_url( 146 array( 147 'category' => $item['category'], 148 ) 149 ), 156 150 ) 157 151 ); -
trunk/include/functions.inc.php
r1070 r1082 583 583 if ($tn_ext != '') 584 584 { 585 $src = substr_replace(get_filename_wo_extension($path), 586 '/thumbnail/'.$conf['prefix_thumbnail'], 587 strrpos($path,'/'), 588 1); 585 $src = substr_replace( 586 get_filename_wo_extension($path), 587 '/thumbnail/'.$conf['prefix_thumbnail'], 588 strrpos($path,'/'), 589 1 590 ); 589 591 $src.= '.'.$tn_ext; 590 592 } … … 1001 1003 return $available_upgrade_ids; 1002 1004 } 1005 1006 /** 1007 * build an index URL for a specific section 1008 * 1009 * @param array 1010 * @return string 1011 */ 1012 function make_index_URL($params = array()) 1013 { 1014 $url = 1015 PHPWG_ROOT_PATH.'category.php?' 1016 .'/'.make_section_in_URL($params) 1017 ; 1018 1019 if (isset($params['start']) and $params['start'] > 0) 1020 { 1021 $url.= '/start-'.$params['start']; 1022 } 1023 1024 return $url; 1025 } 1026 1027 /** 1028 * build an index URL with current page parameters, but with redefinitions 1029 * and removes. 1030 * 1031 * duplicate_index_URL(array('category' => 12), array('start')) will create 1032 * an index URL on the current section (categories), but on a redefined 1033 * category and without the start URL parameter. 1034 * 1035 * @param array redefined keys 1036 * @param array removed keys 1037 * @return string 1038 */ 1039 function duplicate_index_URL($redefined = array(), $removed = array()) 1040 { 1041 return make_index_URL( 1042 params_for_duplication($redefined, $removed) 1043 ); 1044 } 1045 1046 /** 1047 * returns $page global array with key redefined and key removed 1048 * 1049 * @param array redefined keys 1050 * @param array removed keys 1051 * @return array 1052 */ 1053 function params_for_duplication($redefined, $removed) 1054 { 1055 global $page; 1056 1057 if (count($removed) > 0) 1058 { 1059 $params = array(); 1060 1061 foreach ($page as $page_item_key => $page_item_value) 1062 { 1063 if (!in_array($page_item_key, $removed)) 1064 { 1065 $params[$page_item_key] = $page_item_value; 1066 } 1067 } 1068 } 1069 else 1070 { 1071 $params = $page; 1072 } 1073 1074 foreach ($redefined as $redefined_param => $redefined_value) 1075 { 1076 $params[$redefined_param] = $redefined_value; 1077 } 1078 1079 return $params; 1080 } 1081 1082 /** 1083 * create a picture URL with current page parameters, but with redefinitions 1084 * and removes. See duplicate_index_URL. 1085 * 1086 * @param array redefined keys 1087 * @param array removed keys 1088 * @return string 1089 */ 1090 function duplicate_picture_URL($redefined = array(), $removed = array()) 1091 { 1092 return make_picture_URL( 1093 params_for_duplication($redefined, $removed) 1094 ); 1095 } 1096 1097 /** 1098 * create a picture URL on a specific section for a specific picture 1099 * 1100 * @param array 1101 * @return string 1102 */ 1103 function make_picture_URL($params) 1104 { 1105 if (!isset($params['image_id'])) 1106 { 1107 die('make_picture_URL: image_id is a required parameter'); 1108 } 1109 1110 $url = 1111 PHPWG_ROOT_PATH.'picture.php?' 1112 .'/'.$params['image_id'] 1113 .'/'.make_section_in_URL($params) 1114 ; 1115 1116 // first comment to start on 1117 if (isset($params['start']) and $params['start'] > 0) 1118 { 1119 $url.= '/start-'.$params['start']; 1120 } 1121 1122 return $url; 1123 } 1124 1125 /** 1126 * return the section token of an index or picture URL. 1127 * 1128 * Depending on section, other parameters are required (see function code 1129 * for details) 1130 * 1131 * @param array 1132 * @return string 1133 */ 1134 function make_section_in_URL($params) 1135 { 1136 $section_string = ''; 1137 1138 if (!isset($params['section'])) 1139 { 1140 if (isset($params['section'])) 1141 { 1142 $params['section'] = 'categories'; 1143 } 1144 else if (isset($params['tags'])) 1145 { 1146 $params['section'] = 'tags'; 1147 } 1148 else if (isset($params['list'])) 1149 { 1150 $params['section'] = 'list'; 1151 } 1152 else if (isset($params['search'])) 1153 { 1154 $params['section'] = 'search'; 1155 } 1156 } 1157 1158 if (!isset($params['section'])) 1159 { 1160 $params['section'] = 'categories'; 1161 } 1162 1163 switch($params['section']) 1164 { 1165 case 'categories' : 1166 { 1167 if (!isset($params['category'])) 1168 { 1169 $section_string.= 'categories'; 1170 } 1171 else 1172 { 1173 $section_string.= 'category/'.$params['category']; 1174 } 1175 1176 break; 1177 } 1178 case 'tags' : 1179 { 1180 if (!isset($params['tags']) or count($params['tags']) == 0) 1181 { 1182 die('make_section_in_URL: require at least one tag'); 1183 } 1184 1185 $section_string.= 'tags'; 1186 1187 foreach ($params['tags'] as $tag) 1188 { 1189 $section_string.= '/'.$tag; 1190 } 1191 1192 break; 1193 } 1194 case 'search' : 1195 { 1196 if (!isset($params['search'])) 1197 { 1198 die('make_section_in_URL: require a search identifier'); 1199 } 1200 1201 $section_string.= 'search/'.$params['search']; 1202 1203 break; 1204 } 1205 case 'list' : 1206 { 1207 if (!isset($params['list'])) 1208 { 1209 die('make_section_in_URL: require a list of items'); 1210 } 1211 1212 $section_string.= 'list/'.implode(',', $params['list']); 1213 1214 break; 1215 } 1216 default : 1217 { 1218 $section_string.= $params['section']; 1219 } 1220 } 1221 1222 return $section_string; 1223 } 1003 1224 ?> -
trunk/include/functions_category.inc.php
r1081 r1082 47 47 if (in_array($category_id, explode(',', $user['forbidden_categories']))) 48 48 { 49 $login_url = './identification.php?redirect='. 50 urlencode(urlencode($_SERVER['REQUEST_URI'])); 51 if ( ! $user['is_the_guest'] ) 52 { 53 echo '<div style="text-align:center;">'; 54 echo $lang['hello'].' '.$user['username'].'! '; 55 echo $lang['access_forbiden'].'<br />'; 56 echo '<a href="./category.php">'.$lang['thumbnails'].'</a> '; 57 echo '</div>'; 58 exit(); 49 $login_url = 50 './identification.php?redirect=' 51 .urlencode(urlencode($_SERVER['REQUEST_URI'])); 52 53 if (!$user['is_the_guest']) 54 { 55 die('Fatal: you are trying to reach a forbidden category'); 59 56 } 60 57 else -
trunk/include/functions_html.inc.php
r1040 r1082 248 248 */ 249 249 function get_cat_display_name($cat_informations, 250 $url = 'category.php? cat=',250 $url = 'category.php?/category/', 251 251 $replace_space = true) 252 252 { … … 301 301 */ 302 302 function get_cat_display_name_cache($uppercats, 303 $url = 'category.php? cat=',303 $url = 'category.php?/category/', 304 304 $replace_space = true) 305 305 { … … 356 356 357 357 /** 358 * returns the HTML code for a category item in the menu (for category.php)358 * returns the HTML code for a category item in the menu (for the main page) 359 359 * 360 360 * HTML code generated uses logical list tags ul and each category is an … … 375 375 // $page_cat value remains 0 for special sections 376 376 $page_cat = 0; 377 if (isset($page['cat']) and is_numeric($page['cat']) ) 378 { 379 $page_cat = $page['cat']; 380 } 377 if (isset($page['category'])) 378 { 379 $page_cat = $page['category']; 380 } 381 381 382 foreach ($categories as $category) 382 383 { … … 405 406 $menu.= '>'; 406 407 407 $url = PHPWG_ROOT_PATH.'category.php?cat='.$category['id']; 408 $url = make_index_url(array('category' => $category['id'])); 409 408 410 $menu.= "\n".'<a href="'.$url.'"'; 409 411 if ($page_cat != 0 … … 467 469 468 470 function get_cat_display_name_from_id($cat_id, 469 $url = 'category.php? cat=',471 $url = 'category.php?/category/', 470 472 $replace_space = true) 471 473 { -
trunk/include/index.php
r675 r1082 25 25 // | USA. | 26 26 // +-----------------------------------------------------------------------+ 27 $url = '../category.php'; 27 28 $url = '../index.php'; 28 29 header( 'Request-URI: '.$url ); 29 30 header( 'Content-Location: '.$url ); -
trunk/include/section_init.inc.php
r1051 r1082 41 41 */ 42 42 43 unset($page['cat']); 44 45 if (isset($_GET['cat'])) 43 // "index.php?/category/12-foo/start-24&action=fill_caddie" must return : 44 // 45 // array( 46 // 'section' => 'categories', 47 // 'category' => 12, 48 // 'start' => 24 49 // 'action' => 'fill_caddie' 50 // ); 51 52 $page['section'] = 'categories'; 53 54 foreach (array_keys($_GET) as $keynum => $key) 46 55 { 47 if (is_numeric($_GET['cat'])) 48 { 49 $page['cat'] = $_GET['cat']; 50 } 51 else if ($_GET['cat'] == 'fav' 52 or $_GET['cat'] == 'most_visited' 53 or $_GET['cat'] == 'best_rated' 54 or $_GET['cat'] == 'recent_pics' 55 or $_GET['cat'] == 'recent_cats') 56 { 57 $page['cat'] = $_GET['cat']; 58 } 59 else if ($_GET['cat'] == 'search') 60 { 61 if (!isset($_GET['search'])) 62 { 63 die('search GET parameter is missing'); 64 } 65 else if (!is_numeric($_GET['search'])) 66 { 67 die('wrong format on search GET parameter'); 56 if (0 == $keynum) 57 { 58 // deleting first "/" if displayed 59 $tokens = explode( 60 '/', 61 preg_replace('#^/#', '', $key) 62 ); 63 64 // $tokens = array( 65 // 0 => category, 66 // 1 => 12-foo, 67 // 2 => start-24 68 // ); 69 70 $next_token = 0; 71 72 if (basename($_SERVER['PHP_SELF']) == 'picture.php') 73 { 74 // the first token must be the numeric identifier of the picture 75 preg_match('/(\d+)/', $tokens[$next_token], $matches); 76 if (!isset($matches[1])) 77 { 78 die('Fatal: picture identifier is missing'); 79 } 80 $page['image_id'] = $matches[1]; 81 82 $next_token++; 83 } 84 85 if (0 === strpos($tokens[$next_token], 'cat')) 86 { 87 $page['section'] = 'categories'; 88 $next_token++; 89 90 if (isset($tokens[$next_token]) 91 and preg_match('/(\d+)/', $tokens[$next_token], $matches)) 92 { 93 $page['category'] = $matches[1]; 94 $next_token++; 95 } 96 } 97 else if (0 === strpos($tokens[$next_token], 'tag')) 98 { 99 $page['section'] = 'tags'; 100 $page['tags'] = array(); 101 102 $next_token++; 103 104 for ($i = $next_token; ; $i++) 105 { 106 if (!isset($tokens[$i])) 107 { 108 break; 109 } 110 111 preg_match('/^(\d+)/', $tokens[$i], $matches); 112 if (!isset($matches[1])) 113 { 114 if (0 == count($page['tags'])) 115 { 116 die('Fatal: at least one tag required'); 117 } 118 else 119 { 120 break; 121 } 122 } 123 array_push($page['tags'], $matches[1]); 124 } 125 126 $next_token = $i; 127 } 128 else if (0 === strpos($tokens[$next_token], 'fav')) 129 { 130 $page['section'] = 'favorites'; 131 $next_token++; 132 } 133 else if ('most_visited' == $tokens[$next_token]) 134 { 135 $page['section'] = 'most_visited'; 136 $next_token++; 137 } 138 else if ('best_rated' == $tokens[$next_token]) 139 { 140 $page['section'] = 'best_rated'; 141 $next_token++; 142 } 143 else if ('recent_pics' == $tokens[$next_token]) 144 { 145 $page['section'] = 'recent_pics'; 146 $next_token++; 147 } 148 else if ('recent_cats' == $tokens[$next_token]) 149 { 150 $page['section'] = 'recent_cats'; 151 $next_token++; 152 } 153 else if ('search' == $tokens[$next_token]) 154 { 155 $page['section'] = 'search'; 156 $next_token++; 157 158 preg_match('/(\d+)/', $tokens[$next_token], $matches); 159 if (!isset($matches[1])) 160 { 161 die('Fatal: search identifier is missing'); 162 } 163 $page['search'] = $matches[1]; 164 $next_token++; 165 } 166 else if ('list' == $tokens[$next_token]) 167 { 168 $page['section'] = 'list'; 169 $next_token++; 170 171 $page['list'] = array(); 172 if (!preg_match('/^\d+(,\d+)*$/', $tokens[$next_token])) 173 { 174 die('wrong format on list GET parameter'); 175 } 176 foreach (explode(',', $tokens[$next_token]) as $image_id) 177 { 178 array_push($page['list'], $image_id); 179 } 180 $next_token++; 68 181 } 69 182 else 70 183 { 71 $page['cat'] = 'search'; 72 } 73 } 74 else if ($_GET['cat'] == 'list') 75 { 76 if (!isset($_GET['list'])) 77 { 78 die('list GET parameter is missing'); 79 } 80 else if (!preg_match('/^\d+(,\d+)*$/', $_GET['list'])) 81 { 82 die('wrong format on list GET parameter'); 83 } 84 else 85 { 86 $page['cat'] = 'list'; 87 } 88 } 89 else 90 { 91 die('unknown cat GET parameter value'); 184 $page['section'] = 'categories'; 185 $next_token++; 186 } 187 188 for ($i = $next_token; ; $i++) 189 { 190 if (!isset($tokens[$i])) 191 { 192 break; 193 } 194 195 if (preg_match('/^start-(\d+)/', $tokens[$i], $matches)) 196 { 197 $page['start'] = $matches[1]; 198 } 199 200 if (preg_match('/^calendar-(.+)$/', $tokens[$i], $matches)) 201 { 202 // TODO: decide with rvelices how we name calendar/chronology is the 203 // URL 204 $_GET['calendar'] = $matches[1]; 205 } 206 } 92 207 } 93 208 } … … 111 226 } 112 227 113 if (isset($page['cat'])) 228 // +-----------------------------------------------------------------------+ 229 // | category | 230 // +-----------------------------------------------------------------------+ 231 if ('categories' == $page['section']) 114 232 { 115 116 // +-----------------------------------------------------------------------+ 117 // | category | 118 // +-----------------------------------------------------------------------+ 119 if (is_numeric($page['cat'])) 120 { 121 $result = get_cat_info($page['cat']); 122 233 if (isset($page['category'])) 234 { 235 $result = get_cat_info($page['category']); 236 123 237 $page = array_merge( 124 238 $page, … … 133 247 'cat_id_uppercat' => $result['id_uppercat'], 134 248 'uppercats' => $result['uppercats'], 135 249 136 250 'title' => get_cat_display_name($result['name'], '', false), 137 251 ) 138 252 ); 139 if ( !isset($_GET['calendar']) ) 253 254 if (!isset($_GET['calendar'])) 140 255 { 141 256 $query = ' … … 143 258 FROM '.IMAGE_CATEGORY_TABLE.' 144 259 INNER JOIN '.IMAGES_TABLE.' ON id = image_id 145 WHERE category_id = '.$page['cat '].'260 WHERE category_id = '.$page['category'].' 146 261 '.$conf['order_by'].' 147 262 ;'; 148 263 $page['items'] = array_from_query($query, 'image_id'); 264 149 265 $page['thumbnails_include'] = 150 $result['nb_images'] > 0 151 ? 'include/category_default.inc.php' 152 : 'include/category_subcats.inc.php'; 153 }//otherwise the calendar will requery all subitems 154 } 155 // special section 266 $result['nb_images'] > 0 267 ? 'include/category_default.inc.php' 268 : 'include/category_subcats.inc.php'; 269 } //otherwise the calendar will requery all subitems 270 } 156 271 else 157 272 { 158 if (!empty($user['forbidden_categories'])) 159 { 160 $forbidden = 161 ' category_id NOT IN ('.$user['forbidden_categories'].')'; 162 } 163 else 164 { 165 $forbidden = ' 1=1'; 166 } 167 273 $page['title'] = $lang['no_category']; 274 $page['thumbnails_include'] = 'include/category_subcats.inc.php'; 275 } 276 } 277 // special sections 278 else 279 { 280 if (!empty($user['forbidden_categories'])) 281 { 282 $forbidden = 283 ' category_id NOT IN ('.$user['forbidden_categories'].')'; 284 } 285 else 286 { 287 $forbidden = ' 1 = 1'; 288 } 168 289 // +-----------------------------------------------------------------------+ 169 290 // | search section | 170 291 // +-----------------------------------------------------------------------+ 171 if ( $page['cat'] == 'search')172 173 292 if ($page['section'] == 'search') 293 { 294 $query = ' 174 295 SELECT DISTINCT(id) 175 296 FROM '.IMAGES_TABLE.' … … 180 301 ;'; 181 302 182 183 184 185 186 187 188 189 190 303 $page = array_merge( 304 $page, 305 array( 306 'title' => $lang['search_result'], 307 'items' => array_from_query($query, 'id'), 308 'thumbnails_include' => 'include/category_default.inc.php', 309 ) 310 ); 311 } 191 312 // +-----------------------------------------------------------------------+ 192 313 // | favorite section | 193 314 // +-----------------------------------------------------------------------+ 194 else if ($page['cat'] == 'fav')195 196 197 198 315 else if ($page['section'] == 'favorites') 316 { 317 check_user_favorites(); 318 319 $query = ' 199 320 SELECT image_id 200 321 FROM '.FAVORITES_TABLE.' … … 204 325 ;'; 205 326 206 207 208 209 210 211 212 213 214 327 $page = array_merge( 328 $page, 329 array( 330 'title' => $lang['favorites'], 331 'items' => array_from_query($query, 'image_id'), 332 'thumbnails_include' => 'include/category_default.inc.php', 333 ) 334 ); 335 } 215 336 // +-----------------------------------------------------------------------+ 216 337 // | recent pictures section | 217 338 // +-----------------------------------------------------------------------+ 218 else if ($page['cat'] == 'recent_pics')219 220 339 else if ($page['section'] == 'recent_pics') 340 { 341 $query = ' 221 342 SELECT DISTINCT(id) 222 343 FROM '.IMAGES_TABLE.' 223 344 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 224 345 WHERE date_available > \''. 225 346 date('Y-m-d', time() - 60*60*24*$user['recent_period']).'\' 226 347 AND '.$forbidden.' 227 348 '.$conf['order_by'].' 228 349 ;'; 229 350 230 231 232 233 234 235 236 237 238 351 $page = array_merge( 352 $page, 353 array( 354 'title' => $lang['recent_pics_cat'], 355 'items' => array_from_query($query, 'id'), 356 'thumbnails_include' => 'include/category_default.inc.php', 357 ) 358 ); 359 } 239 360 // +-----------------------------------------------------------------------+ 240 361 // | recently updated categories section | 241 362 // +-----------------------------------------------------------------------+ 242 else if ($page['cat'] == 'recent_cats')243 244 245 246 247 248 249 250 251 252 363 else if ($page['section'] == 'recent_cats') 364 { 365 $page = array_merge( 366 $page, 367 array( 368 'title' => $lang['recent_cats_cat'], 369 'cat_nb_images' => 0, 370 'thumbnails_include' => 'include/category_recent_cats.inc.php', 371 ) 372 ); 373 } 253 374 // +-----------------------------------------------------------------------+ 254 375 // | most visited section | 255 376 // +-----------------------------------------------------------------------+ 256 else if ($page['cat'] == 'most_visited')257 258 259 260 377 else if ($page['section'] == 'most_visited') 378 { 379 $page['super_order_by'] = true; 380 $conf['order_by'] = ' ORDER BY hit DESC, file ASC'; 381 $query = ' 261 382 SELECT DISTINCT(id) 262 383 FROM '.IMAGES_TABLE.' 263 384 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 264 385 WHERE hit > 0 265 AND '.$forbidden. 266 $conf['order_by'].'386 AND '.$forbidden.' 387 '.$conf['order_by'].' 267 388 LIMIT 0, '.$conf['top_number'].' 268 389 ;'; 269 270 271 272 273 274 275 276 277 278 390 391 $page = array_merge( 392 $page, 393 array( 394 'title' => $conf['top_number'].' '.$lang['most_visited_cat'], 395 'items' => array_from_query($query, 'id'), 396 'thumbnails_include' => 'include/category_default.inc.php', 397 ) 398 ); 399 } 279 400 // +-----------------------------------------------------------------------+ 280 401 // | best rated section | 281 402 // +-----------------------------------------------------------------------+ 282 else if ($page['cat'] == 'best_rated')283 284 285 286 287 403 else if ($page['section'] == 'best_rated') 404 { 405 $page['super_order_by'] = true; 406 $conf['order_by'] = ' ORDER BY average_rate DESC, id ASC'; 407 408 $query =' 288 409 SELECT DISTINCT(id) 289 410 FROM '.IMAGES_TABLE.' 290 411 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 291 412 WHERE average_rate IS NOT NULL 292 AND '.$forbidden. 293 $conf['order_by'].'413 AND '.$forbidden.' 414 '.$conf['order_by'].' 294 415 LIMIT 0, '.$conf['top_number'].' 295 416 ;'; 296 297 298 299 300 301 302 303 304 417 $page = array_merge( 418 $page, 419 array( 420 'title' => $conf['top_number'].' '.$lang['best_rated_cat'], 421 'items' => array_from_query($query, 'id'), 422 'thumbnails_include' => 'include/category_default.inc.php', 423 ) 424 ); 425 } 305 426 // +-----------------------------------------------------------------------+ 306 427 // | list section | 307 428 // +-----------------------------------------------------------------------+ 308 else if ($page['cat'] == 'list')309 310 429 else if ($page['section'] == 'list') 430 { 431 $query =' 311 432 SELECT DISTINCT(id) 312 433 FROM '.IMAGES_TABLE.' 313 434 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 314 WHERE image_id IN ('. $_GET['list'].')435 WHERE image_id IN ('.implode(',', $page['list']).') 315 436 AND '.$forbidden.' 316 437 '.$conf['order_by'].' 317 438 ;'; 318 $page = array_merge(319 $page,320 array(321 'title' => $lang['random_cat'],322 'items' => array_from_query($query, 'id'),323 'thumbnails_include' => 'include/category_default.inc.php',324 )325 ) ;326 }327 328 if (!isset($page['cat_nb_images']))329 {330 $page['cat_nb_images'] = count($page['items']);331 }439 440 $page = array_merge( 441 $page, 442 array( 443 'title' => $lang['random_cat'], 444 'items' => array_from_query($query, 'id'), 445 'thumbnails_include' => 'include/category_default.inc.php', 446 ) 447 ); 448 } 449 450 if (!isset($page['cat_nb_images'])) 451 { 452 $page['cat_nb_images'] = count($page['items']); 332 453 } 333 454 } 334 // +-----------------------------------------------------------------------+ 335 // | root category | 336 // +-----------------------------------------------------------------------+ 337 else 338 { 339 $page['title'] = $lang['no_category']; 340 $page['thumbnails_include'] = 'include/category_subcats.inc.php'; 341 } 342 343 if ( isset($_GET['calendar']) ) 455 456 // +-----------------------------------------------------------------------+ 457 // | chronology | 458 // +-----------------------------------------------------------------------+ 459 460 if (isset($_GET['calendar'])) 344 461 { 345 462 include_once( PHPWG_ROOT_PATH.'include/functions_calendar.inc.php' ); … … 347 464 } 348 465 466 // echo '<pre>'; print_r($page); echo '</pre>'; 467 468 349 469 ?> -
trunk/notification.php
r1072 r1082 64 64 array( 65 65 'FEED_URL' => PHPWG_ROOT_PATH.'feed.php?feed='.$page['feed'], 66 'U_HOME' => PHPWG_ROOT_PATH.'category.php'66 'U_HOME' => make_index_url(), 67 67 ) 68 68 ); -
trunk/password.php
r1070 r1082 151 151 $template->assign_vars( 152 152 array( 153 'U_HOME' => PHPWG_ROOT_PATH.'category.php'153 'U_HOME' => make_index_url(), 154 154 ) 155 155 ); -
trunk/picture.php
r1078 r1082 26 26 // +-----------------------------------------------------------------------+ 27 27 28 $rate_items = array(0,1,2,3,4,5);29 //--------------------------------------------------------------------- include30 28 define('PHPWG_ROOT_PATH','./'); 31 29 include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); 32 33 // +-----------------------------------------------------------------------+ 34 // | Check Access and exit when user status is not ok | 35 // +-----------------------------------------------------------------------+ 30 include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); 31 32 // Check Access and exit when user status is not ok 36 33 check_status(ACCESS_GUEST); 37 34 38 include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); 39 //-------------------------------------------------- access authorization check 40 if (isset($page['cat']) and is_numeric($page['cat'])) 41 { 42 check_restrictions($page['cat']); 43 } 44 //-------------------------------------------------------------- initialization 35 // access authorization check 36 if (isset($page['category'])) 37 { 38 check_restrictions($page['category']); 39 } 40 45 41 // if this image_id doesn't correspond to this category, an error message is 46 42 // displayed, and execution is stopped 47 if (!in_array($ _GET['image_id'], $page['items']))48 { 49 echo '50 <div style="text-align:center;">'.$lang['access_forbiden'].'<br /> 51 <a href="'.PHPWG_ROOT_PATH.'category.php'.'">'.$lang['thumbnails'].'</a> 52 </div>'; 53 exit(); 54 } 43 if (!in_array($page['image_id'], $page['items'])) 44 { 45 die('Fatal: this picture does not belong to this section'); 46 } 47 48 // +-----------------------------------------------------------------------+ 49 // | initialization | 50 // +-----------------------------------------------------------------------+ 55 51 56 52 $page['rank_of'] = array_flip($page['items']); … … 60 56 $page['first_rank'] = 0; 61 57 $page['last_rank'] = count($page['items']) - 1; 62 $page['current_rank'] = $page['rank_of'][ $ _GET['image_id'] ];58 $page['current_rank'] = $page['rank_of'][ $page['image_id'] ]; 63 59 64 60 // caching current item : readability purpose 65 $page['current_item'] = $ _GET['image_id'];61 $page['current_item'] = $page['image_id']; 66 62 67 63 if ($page['current_rank'] != $page['first_rank']) … … 72 68 'first', 73 69 array( 74 'U_IMG' => 75 PHPWG_ROOT_PATH.'picture.php'. 76 get_query_string_diff( 77 array('image_id', 'add_fav', 'slideshow') 78 ). 79 '&image_id='.$page['items'][ $page['first_rank'] ], 70 'U_IMG' => duplicate_picture_URL( 71 // redefinitions 72 array( 73 'image_id' => $page['items'][ $page['first_rank'] ], 74 ), 75 // removes 76 array() 77 ) 80 78 ) 81 79 ); … … 92 90 'last', 93 91 array( 94 'U_IMG' => 95 PHPWG_ROOT_PATH.'picture.php'. 96 get_query_string_diff( 97 array('image_id', 'add_fav', 'slideshow') 98 ). 99 '&image_id='.$page['items'][ $page['last_rank'] ], 92 'U_IMG' => duplicate_picture_URL( 93 // redefinitions 94 array( 95 'image_id' => $page['items'][ $page['last_rank'] ], 96 ), 97 // removes 98 array() 99 ) 100 100 ) 101 101 ); … … 105 105 } 106 106 107 //---------------------------------------- incrementation of the number of hits 108 if ( count(array_intersect( 109 array_keys($_GET), 110 array('add_fav', 'caddie', 'rate', 'representative', 'del') ) 111 )==0 ) 112 { 113 $query = ' 114 UPDATE '.IMAGES_TABLE.' 115 SET hit = hit+1 116 WHERE id = '.$_GET['image_id'].' 117 ;'; 118 @pwg_query( $query ); 119 } 120 121 //-------------------------------------------------------------- representative 122 if (is_admin() and isset($_GET['representative'])) 123 { 124 $query = ' 107 $url_up = duplicate_index_URL( 108 array( 109 'start' => 110 floor($page['current_rank'] / $user['nb_image_page']) 111 * $user['nb_image_page'] 112 ), 113 array( 114 'start', 115 ) 116 ); 117 118 $url_self = duplicate_picture_URL(); 119 120 // +-----------------------------------------------------------------------+ 121 // | actions | 122 // +-----------------------------------------------------------------------+ 123 124 /** 125 * Actions are favorite adding, user comment deletion, setting the picture 126 * as representative of the current category... 127 * 128 * Actions finish by a redirection 129 */ 130 131 if (isset($_GET['action'])) 132 { 133 switch ($_GET['action']) 134 { 135 case 'add_to_favorites' : 136 { 137 $query = ' 138 INSERT INTO '.FAVORITES_TABLE.' 139 (image_id,user_id) 140 VALUES 141 ('.$page['image_id'].','.$user['id'].') 142 ;'; 143 pwg_query($query); 144 145 redirect($url_self); 146 147 break; 148 } 149 case 'remove_from_favorites' : 150 { 151 $query = ' 152 DELETE FROM '.FAVORITES_TABLE.' 153 WHERE user_id = '.$user['id'].' 154 AND image_id = '.$page['image_id'].' 155 ;'; 156 pwg_query($query); 157 158 if ('favorites' == $page['section']) 159 { 160 redirect($url_up); 161 } 162 else 163 { 164 redirect($url_self); 165 } 166 167 break; 168 } 169 case 'set_as_representative' : 170 { 171 if (is_admin() and isset($page['category'])) 172 { 173 $query = ' 125 174 UPDATE '.CATEGORIES_TABLE.' 126 SET representative_picture_id = '.$_GET['image_id'].' 127 WHERE id = '.$page['cat'].' 128 ;'; 129 pwg_query($query); 130 131 $url = 132 PHPWG_ROOT_PATH 133 .'picture.php' 134 .get_query_string_diff(array('representative')); 135 redirect($url); 136 } 137 138 //-------------------------------------------------------------- caddie filling 139 140 if (isset($_GET['caddie'])) 141 { 142 fill_caddie(array($_GET['image_id'])); 143 144 $url = 145 PHPWG_ROOT_PATH 146 .'picture.php' 147 .get_query_string_diff(array('caddie')); 148 redirect($url); 149 } 150 151 152 //----------------------------------------------------------- rate registration 153 if (isset($_GET['rate']) 154 and $conf['rate'] 155 and ( !$user['is_the_guest'] or $conf['rate_anonymous'] ) 156 and in_array($_GET['rate'], $rate_items)) 157 { 158 if ($user['is_the_guest']) 159 { 160 $ip_components = explode('.', $_SERVER["REMOTE_ADDR"]); 161 if ( count($ip_components)>3 ) 175 SET representative_picture_id = '.$page['image_id'].' 176 WHERE id = '.$page['category'].' 177 ;'; 178 pwg_query($query); 179 } 180 181 redirect($url_self); 182 183 break; 184 } 185 case 'toggle_metadata' : 162 186 { 163 array_pop($ip_components);187 break; 164 188 } 165 $anonymous_id = implode ('.', $ip_components); 166 167 if ( isset($_COOKIE['pwg_anonymous_rater']) ) 189 case 'add_to_caddie' : 168 190 { 169 if ($anonymous_id != $_COOKIE['pwg_anonymous_rater'] ) 170 { // client has changed his IP adress or he's trying to fool us 171 $query = ' 191 fill_caddie(array($page['image_id'])); 192 redirect($url_self); 193 break; 194 } 195 case 'rate' : 196 { 197 if (isset($_GET['rate']) 198 and $conf['rate'] 199 and (!$user['is_the_guest'] or $conf['rate_anonymous']) 200 and in_array($_GET['rate'], $rate_items)) 201 { 202 if ($user['is_the_guest']) 203 { 204 $ip_components = explode('.', $_SERVER["REMOTE_ADDR"]); 205 if (count($ip_components) > 3) 206 { 207 array_pop($ip_components); 208 } 209 $anonymous_id = implode ('.', $ip_components); 210 211 if (isset($_COOKIE['pwg_anonymous_rater'])) 212 { 213 if ($anonymous_id != $_COOKIE['pwg_anonymous_rater']) 214 { // client has changed his IP adress or he's trying to fool us 215 $query = ' 172 216 SELECT element_id FROM '. RATE_TABLE . ' 173 217 WHERE user_id=' . $user['id'] . ' 174 218 AND anonymous_id=\'' . $anonymous_id . '\''; 175 $result = pwg_query($query); 176 $already_there = array(); 177 while ( $row = mysql_fetch_array($result) ) 219 $result = pwg_query($query); 220 $already_there = array(); 221 while ($row = mysql_fetch_array($result)) 222 { 223 array_push($already_there, $row['element_id']); 224 } 225 226 if (count($already_there) > 0) 227 { 228 $query = ' 229 DELETE 230 FROM '.RATE_TABLE.' 231 WHERE user_id = '.$user['id'].' 232 AND anonymous_id = \''.$_COOKIE['pwg_anonymous_rater'].'\' 233 AND element_id NOT IN ('.implode(',', $already_there).') 234 ;'; 235 pwg_query($query); 236 } 237 238 $query = ' 239 UPDATE 240 '.RATE_TABLE.' 241 SET anonymous_id = \'' .$anonymous_id.'\' 242 WHERE user_id = '.$user['id'].' 243 AND anonymous_id = \'' . $_COOKIE['pwg_anonymous_rater'].'\' 244 ;'; 245 pwg_query($query); 246 247 setcookie( 248 'pwg_anonymous_rater', 249 $anonymous_id, 250 strtotime('+10 years'), 251 cookie_path() 252 ); 253 } 254 } 255 else 256 { 257 setcookie( 258 'pwg_anonymous_rater', 259 $anonymous_id, 260 strtotime('+10 years'), 261 cookie_path() 262 ); 263 } 264 } 265 266 $query = ' 267 DELETE 268 FROM '.RATE_TABLE.' 269 WHERE element_id = '.$page['image_id'] . ' 270 AND user_id = '.$user['id'].' 271 '; 272 if (isset($anonymous_id)) 178 273 { 179 array_push( $already_there, $row['element_id'] );274 $query.= ' AND anonymous_id = \''.$anonymous_id.'\''; 180 275 } 181 182 if ( count($already_there)>0 ) 183 { 184 $query = ' 185 DELETE FROM '. RATE_TABLE . ' 186 WHERE user_id=' . $user['id'] . ' 187 AND anonymous_id=\'' . $_COOKIE['pwg_anonymous_rater'] . '\' 188 AND element_id NOT IN (' . implode(',',$already_there) . ')'; 189 pwg_query($query); 190 } 191 276 pwg_query($query); 192 277 $query = ' 193 UPDATE '. RATE_TABLE . ' 194 SET anonymous_id=\'' . $anonymous_id . '\' 195 WHERE user_id=' . $user['id'] . ' 196 AND anonymous_id=\'' . $_COOKIE['pwg_anonymous_rater'] . '\''; 197 pwg_query($query); 198 199 setcookie('pwg_anonymous_rater', $anonymous_id, 200 strtotime('+10 years'), cookie_path() ); 201 } 202 } 203 else 204 { 205 setcookie('pwg_anonymous_rater', $anonymous_id, 206 strtotime('+10 years'), cookie_path() ); 207 } 208 } 209 210 $query = ' 211 DELETE FROM '.RATE_TABLE.' 212 WHERE element_id = '.$_GET['image_id'] . ' 213 AND user_id = '.$user['id'] 214 ; 215 if (isset($anonymous_id)) 216 { 217 $query.= ' AND anonymous_id=\'' . $anonymous_id .'\''; 218 } 219 pwg_query($query); 220 $query = ' 221 INSERT INTO '.RATE_TABLE.' 278 INSERT 279 INTO '.RATE_TABLE.' 222 280 (user_id,anonymous_id,element_id,rate,date) 223 281 VALUES 224 ('.$user['id'].','.(isset($anonymous_id)?'\''.$anonymous_id.'\'':"''").','. 225 $_GET['image_id'].','.$_GET['rate'].',NOW()) 226 ;'; 227 pwg_query($query); 228 229 // update of images.average_rate field 230 $query = ' 282 (' 283 .$user['id'].',' 284 .(isset($anonymous_id) ? '\''.$anonymous_id.'\'' : "''").',' 285 .$page['image_id'].',' 286 .$_GET['rate'] 287 .',NOW()) 288 ;'; 289 pwg_query($query); 290 291 // update of images.average_rate field 292 $query = ' 231 293 SELECT ROUND(AVG(rate),2) AS average_rate 232 294 FROM '.RATE_TABLE.' 233 WHERE element_id = '.$ _GET['image_id'].'234 ;'; 235 $row = mysql_fetch_array(pwg_query($query));236 $query = '295 WHERE element_id = '.$page['image_id'].' 296 ;'; 297 $row = mysql_fetch_array(pwg_query($query)); 298 $query = ' 237 299 UPDATE '.IMAGES_TABLE.' 238 300 SET average_rate = '.$row['average_rate'].' 239 WHERE id = '.$_GET['image_id'].' 240 ;'; 241 pwg_query($query); 242 $url = 243 PHPWG_ROOT_PATH 244 .'picture.php' 245 .get_query_string_diff(array('rate')); 246 redirect($url); 247 } 248 301 WHERE id = '.$page['image_id'].' 302 ;'; 303 pwg_query($query); 304 } 305 306 redirect($url_self); 307 } 308 case 'delete_comment' : 309 { 310 if (isset($_GET['comment_to_delete']) 311 and is_numeric($_GET['comment_to_delete']) 312 and is_admin()) 313 { 314 $query = ' 315 DELETE FROM '.COMMENTS_TABLE.' 316 WHERE id = '.$_GET['comment_to_delete'].' 317 ;'; 318 pwg_query( $query ); 319 } 320 321 redirect($url_self); 322 } 323 } 324 } 325 326 // incrementation of the number of hits, we do this only if no action 327 $query = ' 328 UPDATE 329 '.IMAGES_TABLE.' 330 SET hit = hit+1 331 WHERE id = '.$page['image_id'].' 332 ;'; 333 pwg_query($query); 249 334 250 335 //---------------------------------------------------------- related categories … … 253 338 FROM '.IMAGE_CATEGORY_TABLE.' 254 339 INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id 255 WHERE image_id = '.$ _GET['image_id'].'340 WHERE image_id = '.$page['image_id'].' 256 341 AND category_id NOT IN ('.$user['forbidden_categories'].') 257 342 ;'; … … 266 351 $picture = array(); 267 352 268 $ids = array($ _GET['image_id']);353 $ids = array($page['image_id']); 269 354 if (isset($page['previous_item'])) 270 355 { … … 362 447 } 363 448 364 $picture[$i]['url'] = 365 PHPWG_ROOT_PATH.'picture.php' 366 .get_query_string_diff(array('image_id', 'add_fav', 'slideshow')) 367 .'&image_id='.$row['id']; 368 } 369 370 $url_up = PHPWG_ROOT_PATH.'category.php?'; 371 if ( isset($page['cat']) ) 372 { 373 $url_up .= 'cat='.$page['cat']; 374 } 375 elseif ( isset($_GET['calendar']) ) 376 { 377 $url_up .= 'calendar='.$_GET['calendar']; 378 } 379 380 $url_up_start = floor( $page['current_rank'] / $user['nb_image_page'] ); 381 $url_up_start *= $user['nb_image_page']; 382 if ($url_up_start>0) 383 { 384 $url_up .= '&start='.$url_up_start; 385 } 386 387 if ( isset($page['cat']) ) 388 { 389 if ( $page['cat'] == 'search' ) 390 { 391 $url_up.= '&search='.$_GET['search']; 392 } 393 if ( $page['cat'] == 'list' ) 394 { 395 $url_up.= '&list='.$_GET['list']; 396 } 449 $picture[$i]['url'] = duplicate_picture_URL( 450 array( 451 'image_id' => $row['id'], 452 ), 453 array( 454 'start', 455 ) 456 ); 397 457 } 398 458 399 459 $url_admin = 400 460 PHPWG_ROOT_PATH.'admin.php?page=picture_modify' 401 .'&cat_id='. ( isset($page['cat']) ? $page['cat'] : '' ) 402 .'&image_id='.$_GET['image_id']; 461 .'&cat_id='.(isset($page['category']) ? $page['category'] : '') 462 .'&image_id='.$page['image_id'] 463 ; 403 464 404 465 $url_slide = 405 $picture['current']['url'].'&slideshow='.$conf['slideshow_period']; 406 407 //--------------------------------------------------------- favorite management 408 if ( isset( $_GET['add_fav'] ) ) 409 { 410 $query = 'DELETE FROM '.FAVORITES_TABLE; 411 $query.= ' WHERE user_id = '.$user['id']; 412 $query.= ' AND image_id = '.$picture['current']['id']; 413 $query.= ';'; 414 $result = pwg_query( $query ); 415 416 if ( $_GET['add_fav'] == 1 ) 417 { 418 $query = 'INSERT INTO '.FAVORITES_TABLE; 419 $query.= ' (image_id,user_id) VALUES'; 420 $query.= ' ('.$picture['current']['id'].','.$user['id'].')'; 421 $query.= ';'; 422 $result = pwg_query( $query ); 423 } 424 if ( !$_GET['add_fav'] and isset($page['cat']) and 'fav'==$page['cat'] ) 425 { 426 if (!isset($page['previous_item']) and !isset($page['next_item'])) 427 { 428 // there is no favorite picture anymore we redirect the user to the 429 // category page 430 redirect($url_up); 431 } 432 else if (!isset($page['previous_item'])) 433 { 434 $url = str_replace( '&', '&', $picture['next']['url'] ); 435 redirect( $url ); 436 } 437 else 438 { 439 $url = str_replace('&', '&', $picture['prev']['url'] ); 440 redirect( $url ); 441 } 442 redirect( $url ); 443 } 444 } 445 446 //------------------------------------------------------ comment registeration 447 if ( isset( $_POST['content'] ) && !empty($_POST['content']) ) 448 { 449 $register_comment = true; 450 $author = !empty($_POST['author'])?$_POST['author']:$lang['guest']; 451 // if a guest try to use the name of an already existing user, he must be 452 // rejected 453 if ( $author != $user['username'] ) 454 { 455 $query = 'SELECT COUNT(*) AS user_exists'; 456 $query.= ' FROM '.USERS_TABLE; 457 $query.= ' WHERE '.$conf['user_fields']['username']." = '".$author."'"; 458 $query.= ';'; 459 $row = mysql_fetch_array( pwg_query( $query ) ); 460 if ( $row['user_exists'] == 1 ) 461 { 462 $template->assign_block_vars( 463 'information', 464 array('INFORMATION'=>$lang['comment_user_exists'])); 465 $register_comment = false; 466 } 467 } 468 469 if ( $register_comment ) 470 { 471 // anti-flood system 472 $reference_date = time() - $conf['anti-flood_time']; 473 $query = 'SELECT id FROM '.COMMENTS_TABLE; 474 $query.= ' WHERE date > FROM_UNIXTIME('.$reference_date.')'; 475 $query.= " AND author = '".$author."'"; 476 $query.= ';'; 477 if ( mysql_num_rows( pwg_query( $query ) ) == 0 478 or $conf['anti-flood_time'] == 0 ) 479 { 480 list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); 481 482 $data = array(); 483 $data{'author'} = $author; 484 $data{'date'} = $dbnow; 485 $data{'image_id'} = $_GET['image_id']; 486 $data{'content'} = htmlspecialchars( $_POST['content'], ENT_QUOTES); 487 488 if (!$conf['comments_validation'] or is_admin()) 489 { 490 $data{'validated'} = 'true'; 491 $data{'validation_date'} = $dbnow; 492 } 493 else 494 { 495 $data{'validated'} = 'false'; 496 } 497 498 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 499 $fields = array('author', 'date', 'image_id', 'content', 'validated', 500 'validation_date'); 501 mass_inserts(COMMENTS_TABLE, $fields, array($data)); 502 503 // information message 504 $message = $lang['comment_added']; 505 506 if (!$conf['comments_validation'] or is_admin()) 507 508 if ( $conf['comments_validation'] and !is_admin() ) 509 { 510 $message.= '<br />'.$lang['comment_to_validate']; 511 } 512 $template->assign_block_vars('information', 513 array('INFORMATION'=>$message)); 514 } 515 else 516 { 517 // information message 518 $template->assign_block_vars( 519 'information', 520 array('INFORMATION'=>$lang['comment_anti-flood'])); 521 } 522 } 523 } 524 // comment deletion 525 if ( isset( $_GET['del'] ) 526 and is_numeric( $_GET['del'] ) 527 and is_admin() ) 528 { 529 $query = 'DELETE FROM '.COMMENTS_TABLE; 530 $query.= ' WHERE id = '.$_GET['del']; 531 $query.= ';'; 532 pwg_query( $query ); 533 } 534 535 // 536 // Start output of page 537 // 466 $picture['current']['url'] 467 .'&slideshow='.$conf['slideshow_period'] 468 ; 538 469 539 470 $title = $picture['current']['name']; … … 572 503 } 573 504 574 $picture_size = get_picture_size($original_width, $original_height, 575 @$user['maxwidth'], @$user['maxheight']); 505 $picture_size = get_picture_size( 506 $original_width, 507 $original_height, 508 @$user['maxwidth'], 509 @$user['maxheight'] 510 ); 576 511 577 512 // metadata … … 585 520 } 586 521 587 $url_metadata = PHPWG_ROOT_PATH.'picture.php'; 588 $url_metadata .= get_query_string_diff(array('add_fav', 'slideshow', 'show_metadata')); 589 if ($metadata_showable and !isset($_GET['show_metadata'])) 590 { 591 $url_metadata.= '&show_metadata=1'; 592 } 522 // $url_metadata = PHPWG_ROOT_PATH.'picture.php'; 523 // $url_metadata .= get_query_string_diff(array('add_fav', 'slideshow', 'show_metadata')); 524 // if ($metadata_showable and !isset($_GET['show_metadata'])) 525 // { 526 // $url_metadata.= '&show_metadata=1'; 527 // } 528 529 // TODO: rewrite metadata display to toggle on/off user_infos.show_metadata 530 $url_metadata = duplicate_picture_URL(); 593 531 594 532 $page['body_id'] = 'thePicturePage'; … … 623 561 $template->set_filenames(array('picture'=>'picture.tpl')); 624 562 625 $template->assign_vars(array( 626 'CATEGORY' => $title_img, 627 'PHOTO' => $title_nb, 628 'TITLE' => $picture['current']['name'], 629 'SRC_IMG' => $picture['current']['src'], 630 'ALT_IMG' => $picture['current']['file'], 631 'WIDTH_IMG' => $picture_size[0], 632 'HEIGHT_IMG' => $picture_size[1], 633 634 'LEVEL_SEPARATOR' => $conf['level_separator'], 635 636 'L_HOME' => $lang['home'], 637 'L_SLIDESHOW' => $lang['slideshow'], 638 'L_STOP_SLIDESHOW' => $lang['slideshow_stop'], 639 'L_PREV_IMG' =>$lang['previous_page'].' : ', 640 'L_NEXT_IMG' =>$lang['next_page'].' : ', 641 'L_ADMIN' =>$lang['link_info_image'], 642 'L_COMMENT_TITLE' =>$lang['comments_title'], 643 'L_ADD_COMMENT' =>$lang['comments_add'], 644 'L_DELETE_COMMENT' =>$lang['comments_del'], 645 'L_DELETE' =>$lang['delete'], 646 'L_SUBMIT' =>$lang['submit'], 647 'L_AUTHOR' => $lang['upload_author'], 648 'L_COMMENT' =>$lang['comment'], 649 'L_DOWNLOAD' => $lang['download'], 650 'L_DOWNLOAD_HINT' => $lang['download_hint'], 651 'L_PICTURE_METADATA' => $lang['picture_show_metadata'], 652 'L_PICTURE_HIGH' => $lang['picture_high'], 653 'L_UP_HINT' => $lang['home_hint'], 654 'L_UP_ALT' => $lang['home'], 655 656 'U_HOME' => (PHPWG_ROOT_PATH.'category.php'), 657 'U_UP' => $url_up, 658 'U_METADATA' => $url_metadata, 659 'U_ADMIN' => $url_admin, 660 'U_SLIDESHOW'=> $url_slide, 661 'U_ADD_COMMENT' => str_replace( '&', '&', $_SERVER['REQUEST_URI'] ) 662 ) 663 ); 563 $template->assign_vars( 564 array( 565 'CATEGORY' => $title_img, 566 'PHOTO' => $title_nb, 567 'TITLE' => $picture['current']['name'], 568 'SRC_IMG' => $picture['current']['src'], 569 'ALT_IMG' => $picture['current']['file'], 570 'WIDTH_IMG' => $picture_size[0], 571 'HEIGHT_IMG' => $picture_size[1], 572 573 'LEVEL_SEPARATOR' => $conf['level_separator'], 574 575 'L_HOME' => $lang['home'], 576 'L_SLIDESHOW' => $lang['slideshow'], 577 'L_STOP_SLIDESHOW' => $lang['slideshow_stop'], 578 'L_PREV_IMG' =>$lang['previous_page'].' : ', 579 'L_NEXT_IMG' =>$lang['next_page'].' : ', 580 'L_ADMIN' =>$lang['link_info_image'], 581 'L_COMMENT_TITLE' =>$lang['comments_title'], 582 'L_ADD_COMMENT' =>$lang['comments_add'], 583 'L_DELETE_COMMENT' =>$lang['comments_del'], 584 'L_DELETE' =>$lang['delete'], 585 'L_SUBMIT' =>$lang['submit'], 586 'L_AUTHOR' => $lang['upload_author'], 587 'L_COMMENT' =>$lang['comment'], 588 'L_DOWNLOAD' => $lang['download'], 589 'L_DOWNLOAD_HINT' => $lang['download_hint'], 590 'L_PICTURE_METADATA' => $lang['picture_show_metadata'], 591 'L_PICTURE_HIGH' => $lang['picture_high'], 592 'L_UP_HINT' => $lang['home_hint'], 593 'L_UP_ALT' => $lang['home'], 594 595 'U_HOME' => make_index_URL(), 596 'U_UP' => $url_up, 597 'U_METADATA' => $url_metadata, 598 'U_ADMIN' => $url_admin, 599 'U_SLIDESHOW'=> $url_slide, 600 'U_ADD_COMMENT' => $url_self, 601 ) 602 ); 664 603 665 604 if ($conf['show_picture_name_on_title']) … … 669 608 670 609 //------------------------------------------------------- upper menu management 610 671 611 // download link if file is not a picture 672 612 if (!$picture['current']['is_picture']) … … 674 614 $template->assign_block_vars( 675 615 'download', 676 array('U_DOWNLOAD' => $picture['current']['download'])); 677 } 616 array( 617 'U_DOWNLOAD' => $picture['current']['download'] 618 ) 619 ); 620 } 621 678 622 // display a high quality link if present 679 623 if (isset($picture['current']['high'])) 680 624 { 681 625 $uuid = uniqid(rand()); 682 $template->assign_block_vars('high', array( 683 'U_HIGH' => $picture['current']['high'], 684 'UUID'=>$uuid 685 )); 626 627 $template->assign_block_vars( 628 'high', 629 array( 630 'U_HIGH' => $picture['current']['high'], 631 'UUID' => $uuid, 632 ) 633 ); 634 686 635 $template->assign_block_vars( 687 636 'download', 688 array('U_DOWNLOAD' => PHPWG_ROOT_PATH.'action.php?dwn=' 689 .$picture['current']['high'] 690 ) 691 ); 692 } 637 array( 638 'U_DOWNLOAD' => PHPWG_ROOT_PATH.'action.php?dwn=' 639 .$picture['current']['high'] 640 ) 641 ); 642 } 643 693 644 // button to set the current picture as representative 694 if (is_admin() and 695 isset($page['cat']) and is_numeric($page['cat'])) 645 if (is_admin() and isset($page['category'])) 696 646 { 697 647 $template->assign_block_vars( 698 648 'representative', 699 649 array( 700 'URL' => 701 PHPWG_ROOT_PATH.'picture.php' 702 .get_query_string_diff(array('add_fav')) 703 .'&representative=1' 704 ) 705 ); 706 } 707 650 'URL' => $url_self.'&action=set_as_representative' 651 ) 652 ); 653 } 654 655 // caddie button 708 656 if (is_admin()) 709 657 { … … 711 659 'caddie', 712 660 array( 713 'URL' => 714 PHPWG_ROOT_PATH.'picture.php' 715 .get_query_string_diff(array('add_fav')).'&caddie=1') 716 ); 717 } 718 719 //------------------------------------------------------- favorite manipulation 720 if ( !$user['is_the_guest'] ) 661 'URL' => $url_self.'&action=add_to_caddie' 662 ) 663 ); 664 } 665 666 // favorite manipulation 667 if (!$user['is_the_guest']) 721 668 { 722 669 // verify if the picture is already in the favorite of the user 723 $query = 'SELECT COUNT(*) AS nb_fav'; 724 $query.= ' FROM '.FAVORITES_TABLE.' WHERE image_id = '.$_GET['image_id']; 725 $query.= ' AND user_id = '.$user['id'].';'; 726 $result = pwg_query( $query ); 727 $row = mysql_fetch_array( $result ); 728 if (!$row['nb_fav']) 729 { 730 $url = PHPWG_ROOT_PATH.'picture.php'; 731 $url.= get_query_string_diff(array('add_fav')); 732 $url.= '&add_fav=1'; 670 $query = ' 671 SELECT COUNT(*) AS nb_fav 672 FROM '.FAVORITES_TABLE.' 673 WHERE image_id = '.$page['image_id'].' 674 AND user_id = '.$user['id'].' 675 ;'; 676 $result = pwg_query($query); 677 $row = mysql_fetch_array($result); 678 679 if ($row['nb_fav'] == 0) 680 { 681 $url = $url_self.'&action=add_to_favorites'; 733 682 734 683 $template->assign_block_vars( 735 684 'favorite', 736 685 array( 737 'FAVORITE_IMG' => get_themeconf('icon_dir').'/favorite.png', 738 'FAVORITE_HINT' =>$lang['add_favorites_hint'], 739 'FAVORITE_ALT' =>$lang['add_favorites_alt'], 740 'U_FAVORITE' => $url 741 )); 686 'FAVORITE_IMG' => get_themeconf('icon_dir').'/favorite.png', 687 'FAVORITE_HINT' => $lang['add_favorites_hint'], 688 'FAVORITE_ALT' => $lang['add_favorites_alt'], 689 'U_FAVORITE' => $url_self.'&action=add_to_favorites', 690 ) 691 ); 742 692 } 743 693 else 744 694 { 745 $url = PHPWG_ROOT_PATH.'picture.php';746 $url.= get_query_string_diff(array('add_fav'));747 $url.= '&add_fav=0';748 749 695 $template->assign_block_vars( 750 696 'favorite', 751 697 array( 752 'FAVORITE_IMG' => get_themeconf('icon_dir').'/del_favorite.png', 753 'FAVORITE_HINT' =>$lang['del_favorites_hint'], 754 'FAVORITE_ALT' =>$lang['del_favorites_alt'], 755 'U_FAVORITE'=> $url 756 )); 698 'FAVORITE_IMG' => get_themeconf('icon_dir').'/del_favorite.png', 699 'FAVORITE_HINT' => $lang['del_favorites_hint'], 700 'FAVORITE_ALT' => $lang['del_favorites_alt'], 701 'U_FAVORITE' => $url_self.'&action=remove_from_favorites', 702 ) 703 ); 757 704 } 758 705 } … … 888 835 } 889 836 890 //------------------------------------------------------------------- metadata891 if ($metadata_showable and isset($_GET['show_metadata']))892 {893 include_once(PHPWG_ROOT_PATH.'/include/functions_metadata.inc.php');894 $template->assign_block_vars('metadata', array());895 if ($conf['show_exif'])896 {897 if (!function_exists('read_exif_data'))898 {899 die('Exif extension not available, admin should disable exif display');900 }901 902 if ($exif = @read_exif_data($picture['current']['src']))903 {904 $template->assign_block_vars(905 'metadata.headline',906 array('TITLE' => 'EXIF Metadata')907 );908 909 foreach ($conf['show_exif_fields'] as $field)910 {911 if (strpos($field, ';') === false)912 {913 if (isset($exif[$field]))914 {915 $key = $field;916 if (isset($lang['exif_field_'.$field]))917 {918 $key = $lang['exif_field_'.$field];919 }920 921 $template->assign_block_vars(922 'metadata.line',923 array(924 'KEY' => $key,925 'VALUE' => $exif[$field]926 )927 );928 }929 }930 else931 {932 $tokens = explode(';', $field);933 if (isset($exif[$tokens[0]][$tokens[1]]))934 {935 $key = $tokens[1];936 if (isset($lang['exif_field_'.$tokens[1]]))937 {938 $key = $lang['exif_field_'.$tokens[1]];939 }940 941 $template->assign_block_vars(942 'metadata.line',943 array(944 'KEY' => $key,945 'VALUE' => $exif[$tokens[0]][$tokens[1]]946 )947 );948 }949 }950 }951 }952 }953 if ($conf['show_iptc'])954 {955 $iptc = get_iptc_data($picture['current']['src'],956 $conf['show_iptc_mapping']);957 958 if (count($iptc) > 0)959 {960 $template->assign_block_vars(961 'metadata.headline',962 array('TITLE' => 'IPTC Metadata')963 );964 }965 966 foreach ($iptc as $field => $value)967 {968 $key = $field;969 if (isset($lang[$field]))970 {971 $key = $lang[$field];972 }973 974 $template->assign_block_vars(975 'metadata.line',976 array(977 'KEY' => $key,978 'VALUE' => $value979 )980 );981 }982 }983 }984 837 //slideshow end 985 if ( isset( $_GET['slideshow'] ) ) 986 { 987 if ( !is_numeric( $_GET['slideshow'] ) ) $_GET['slideshow'] = $conf['slideshow_period']; 988 989 $template->assign_block_vars('stop_slideshow', array( 990 'U_SLIDESHOW'=>$picture['current']['url'] 991 )); 992 } 993 994 //------------------------------------------------------------------- rating 995 if ($conf['rate']) 996 { 997 $query = ' 998 SELECT COUNT(rate) AS count 999 , ROUND(AVG(rate),2) AS average 1000 , ROUND(STD(rate),2) AS STD 1001 FROM '.RATE_TABLE.' 1002 WHERE element_id = '.$picture['current']['id'].' 1003 ;'; 1004 $row = mysql_fetch_array(pwg_query($query)); 1005 if ($row['count'] == 0) 1006 { 1007 $value = $lang['no_rate']; 1008 } 1009 else 1010 { 1011 $value = sprintf( 1012 l10n('%.2f (rated %d times, standard deviation = %.2f)'), 1013 $row['average'], 1014 $row['count'], 1015 $row['STD'] 1016 ); 1017 } 1018 1019 if ($conf['rate_anonymous'] or !$user['is_the_guest']) 1020 { 1021 if ($row['count']>0) 1022 { 1023 $query = 'SELECT rate 1024 FROM '.RATE_TABLE.' 1025 WHERE element_id = '.$_GET['image_id'] . ' 1026 AND user_id = '.$user['id'] ; 1027 1028 if ($user['is_the_guest']) 1029 { 1030 $ip_components = explode('.', $_SERVER['REMOTE_ADDR']); 1031 if ( count($ip_components)>3 ) 1032 { 1033 array_pop($ip_components); 1034 } 1035 $anonymous_id = implode ('.', $ip_components); 1036 $query .= ' AND anonymous_id = \''.$anonymous_id . '\''; 1037 } 1038 1039 $result = pwg_query($query); 1040 if (mysql_num_rows($result) > 0) 1041 { 1042 $row = mysql_fetch_array($result); 1043 $sentence = $lang['already_rated']; 1044 $sentence.= ' ('.$row['rate'].'). '; 1045 $sentence.= $lang['update_rate']; 1046 } 1047 else 1048 { 1049 $sentence = $lang['never_rated'].'. '.$lang['Rate']; 1050 } 1051 } 1052 else 1053 { 1054 $sentence = $lang['never_rated'].'. '.$lang['Rate']; 1055 } 1056 $template->assign_block_vars( 1057 'rate', 1058 array( 1059 'CONTENT' => $value, 1060 'SENTENCE' => $sentence 1061 )); 1062 1063 $template->assign_block_vars('info_rate', array('CONTENT' => $value)); 1064 1065 $template->assign_vars( 1066 array( 1067 'INFO_RATE' => $value 1068 ) 1069 ); 1070 1071 foreach ($rate_items as $num => $mark) 1072 { 1073 if ($num > 0) 1074 { 1075 $separator = '|'; 1076 } 1077 else 1078 { 1079 $separator = ''; 1080 } 1081 1082 $url = PHPWG_ROOT_PATH.'picture.php'; 1083 $url.= get_query_string_diff(array('add_fav')); 1084 $url.= '&rate='.$mark; 1085 1086 $template->assign_block_vars( 1087 'rate.rate_option', 1088 array( 1089 'OPTION' => $mark, 1090 'URL' => $url, 1091 'SEPARATOR' => $separator 1092 )); 1093 } 1094 } 1095 } 1096 1097 //---------------------------------------------------- users's comments display 1098 1099 // the picture is commentable if it belongs at least to one category which 1100 // is commentable 1101 $page['show_comments'] = false; 1102 foreach ($related_categories as $category) 1103 { 1104 if ($category['commentable'] == 'true') 1105 { 1106 $page['show_comments'] = true; 1107 } 1108 } 1109 1110 if ($page['show_comments']) 1111 { 1112 // number of comment for this picture 1113 $query = 'SELECT COUNT(*) AS nb_comments'; 1114 $query.= ' FROM '.COMMENTS_TABLE.' WHERE image_id = '.$_GET['image_id']; 1115 $query.= " AND validated = 'true'"; 1116 $query.= ';'; 1117 $row = mysql_fetch_array( pwg_query( $query ) ); 1118 1119 // navigation bar creation 1120 $url = PHPWG_ROOT_PATH.'picture.php'; 1121 $url.= get_query_string_diff(array('add_fav','start')); 1122 1123 if (!isset( $_GET['start'] ) 1124 or !is_numeric( $_GET['start'] ) 1125 or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) ) 1126 { 1127 $page['start'] = 0; 1128 } 1129 else 1130 { 1131 $page['start'] = $_GET['start']; 1132 } 1133 $page['navigation_bar'] = create_navigation_bar( $url, $row['nb_comments'], 1134 $page['start'], 1135 $conf['nb_comment_page'], 1136 '' ); 1137 $template->assign_block_vars('comments', array( 1138 'NB_COMMENT'=>$row['nb_comments'], 1139 'NAV_BAR'=>$page['navigation_bar'])); 1140 1141 if ($row['nb_comments']>0) 1142 { 1143 $query = 'SELECT id,author,date,image_id,content'; 1144 $query.= ' FROM '.COMMENTS_TABLE.' WHERE image_id = '.$_GET['image_id']; 1145 $query.= " AND validated = 'true'"; 1146 $query.= ' ORDER BY date ASC'; 1147 $query.= ' LIMIT '.$page['start'].', '.$conf['nb_comment_page'].';'; 1148 $result = pwg_query( $query ); 1149 1150 while ( $row = mysql_fetch_array( $result ) ) 1151 { 1152 $template->assign_block_vars( 1153 'comments.comment', 1154 array( 1155 'COMMENT_AUTHOR'=>empty($row['author'])?$lang['guest']:$row['author'], 1156 'COMMENT_DATE'=>format_date($row['date'], 'mysql_datetime', true), 1157 'COMMENT'=>parse_comment_content($row['content']) 1158 )); 1159 1160 if ( is_admin() ) 1161 { 1162 $template->assign_block_vars( 1163 'comments.comment.delete', 1164 array('U_COMMENT_DELETE'=> $url.'&del='.$row['id'] 1165 )); 1166 } 1167 } 1168 } 1169 1170 if (!$user['is_the_guest'] 1171 or ($user['is_the_guest'] and $conf['comments_forall'])) 1172 { 1173 $template->assign_block_vars('comments.add_comment', array()); 1174 // display author field if the user is not logged in 1175 if (!$user['is_the_guest']) 1176 { 1177 $template->assign_block_vars( 1178 'comments.add_comment.author_known', 1179 array('KNOWN_AUTHOR'=>$user['username']) 1180 ); 1181 } 1182 else 1183 { 1184 $template->assign_block_vars( 1185 'comments.add_comment.author_field', array() 1186 ); 1187 } 1188 } 1189 } 838 if (isset($_GET['slideshow'])) 839 { 840 if (!is_numeric($_GET['slideshow'])) 841 { 842 $_GET['slideshow'] = $conf['slideshow_period']; 843 } 844 845 $template->assign_block_vars( 846 'stop_slideshow', 847 array( 848 'U_SLIDESHOW' => $picture['current']['url'], 849 ) 850 ); 851 } 852 853 // +-----------------------------------------------------------------------+ 854 // | sub pages | 855 // +-----------------------------------------------------------------------+ 856 857 include(PHPWG_ROOT_PATH.'include/picture_rate.inc.php'); 858 include(PHPWG_ROOT_PATH.'include/picture_comment.inc.php'); 859 include(PHPWG_ROOT_PATH.'include/picture_metadata.inc.php'); 860 1190 861 //------------------------------------------------------------ log informations 1191 862 pwg_log( 'picture', $title_img, $picture['current']['file'] ); -
trunk/profile.php
r1072 r1082 159 159 160 160 // redirection 161 $url = PHPWG_ROOT_PATH.'category.php?'.$_SERVER['QUERY_STRING']; 162 redirect($url); 161 redirect(make_index_url()); 163 162 } 164 163 } … … 222 221 'L_RETURN_HINT' => $lang['home_hint'], 223 222 224 'U_RETURN' => PHPWG_ROOT_PATH.'category.php',223 'U_RETURN' => make_index_url(), 225 224 226 225 'F_ACTION'=>$url_action, -
trunk/random.php
r1072 r1082 29 29 // | define and include | 30 30 // +-----------------------------------------------------------------------+ 31 31 32 define('PHPWG_ROOT_PATH','./'); 32 33 include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); … … 41 42 // +-----------------------------------------------------------------------+ 42 43 43 // we must not show pictures of a forbidden category44 $where = '';45 if ( $user['forbidden_categories'] != '' )46 {47 $where = 'WHERE category_id NOT IN ('.$user['forbidden_categories'].')';48 }49 50 44 $query = ' 51 45 SELECT DISTINCT(id) 52 46 FROM '.IMAGES_TABLE.' 53 47 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 54 '.$where.' 48 '.( 49 $user['forbidden_categories'] != '' 50 ? 'WHERE category_id NOT IN ('.$user['forbidden_categories'].')' 51 : '' 52 ).' 55 53 ORDER BY RAND(NOW()) 56 54 LIMIT 0, '.$conf['top_number'].' 57 55 ;'; 58 $result = pwg_query($query); 59 $ids = array(); 60 while ($row = mysql_fetch_array($result)) 61 { 62 array_push($ids, $row['id']); 63 } 56 64 57 // +-----------------------------------------------------------------------+ 65 58 // | redirect | 66 59 // +-----------------------------------------------------------------------+ 67 $url = PHPWG_ROOT_PATH.'category.php?cat=list&list='.implode(',', $ids); 68 redirect( $url);60 61 redirect(make_index_URL(array('list' => array_from_query($query, 'id')))); 69 62 ?> -
trunk/register.php
r1068 r1082 50 50 $user_id = get_userid($_POST['login']); 51 51 log_user( $user_id, false); 52 redirect( 'category.php');52 redirect(make_index_url()); 53 53 } 54 54 } … … 75 75 'L_EMAIL' => $lang['mail_address'], 76 76 77 'U_HOME' => PHPWG_ROOT_PATH.'category.php',77 'U_HOME' => make_index_url(), 78 78 79 79 'F_ACTION' => 'register.php', -
trunk/search.php
r1072 r1082 143 143 if (isset($_POST['submit']) and count($errors) == 0) 144 144 { 145 $url = 'category.php?cat=search&search='.$search_id; 146 redirect($url); 145 redirect( 146 make_index_url( 147 array( 148 'section' => 'search', 149 'search' => $search_id, 150 ) 151 ) 152 ); 147 153 } 148 154 //----------------------------------------------------- template initialization … … 194 200 'S_SEARCH_ACTION' => 'search.php', 195 201 'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=search', 196 'U_HOME' => 'category.php'202 'U_HOME' => make_index_url(), 197 203 ) 198 204 ); -
trunk/upload.php
r1058 r1082 126 126 $page['cat_name'] = $result['name']; 127 127 $page['cat_uploadable'] = $result['uploadable']; 128 if ( url_is_remote($page['cat_dir']) or !$page['cat_uploadable']) 129 { 130 echo '<div style="text-align:center;">'.$lang['upload_forbidden'].'<br />'; 131 echo '<a href="./category.php">'; 132 echo $lang['thumbnails'].'</a></div>'; 133 exit(); 128 129 if (url_is_remote($page['cat_dir']) or !$page['cat_uploadable']) 130 { 131 die('Fatal: you take a wrong way, bye bye'); 134 132 } 135 133 } … … 281 279 $comment = !empty($_POST['comment'])?$_POST['comment']:''; 282 280 283 $template->assign_vars(array( 284 'ADVISE_TITLE' => $advise_title, 285 'NAME' => $username, 286 'EMAIL' => $mail_address, 287 'NAME_IMG' => $name, 288 'AUTHOR_IMG' => $author, 289 'DATE_IMG' => $date_creation, 290 'COMMENT_IMG' => $comment, 291 292 'L_TITLE' => $lang['upload_title'], 293 'L_USERNAME' => $lang['upload_username'], 294 'L_EMAIL' => $lang['mail_address'], 295 'L_NAME_IMG' => $lang['upload_name'], 296 'L_SUBMIT' => $lang['submit'], 297 'L_AUTHOR' => $lang['upload_author'], 298 'L_CREATION_DATE' => $lang['upload_creation_date'], 299 'L_COMMENT' => $lang['comment'], 300 'L_RETURN' => $lang['home'], 301 'L_RETURN_HINT' => $lang['home_hint'], 302 'L_UPLOAD_DONE' => $lang['upload_successful'], 303 'L_MANDATORY' => $lang['mandatory'], 304 305 'F_ACTION' => $u_form, 306 307 'U_RETURN' => PHPWG_ROOT_PATH.'category.php?'.$_SERVER['QUERY_STRING'] 308 )); 281 $template->assign_vars( 282 array( 283 'ADVISE_TITLE' => $advise_title, 284 'NAME' => $username, 285 'EMAIL' => $mail_address, 286 'NAME_IMG' => $name, 287 'AUTHOR_IMG' => $author, 288 'DATE_IMG' => $date_creation, 289 'COMMENT_IMG' => $comment, 290 291 'L_TITLE' => $lang['upload_title'], 292 'L_USERNAME' => $lang['upload_username'], 293 'L_EMAIL' => $lang['mail_address'], 294 'L_NAME_IMG' => $lang['upload_name'], 295 'L_SUBMIT' => $lang['submit'], 296 'L_AUTHOR' => $lang['upload_author'], 297 'L_CREATION_DATE' => $lang['upload_creation_date'], 298 'L_COMMENT' => $lang['comment'], 299 'L_RETURN' => $lang['home'], 300 'L_RETURN_HINT' => $lang['home_hint'], 301 'L_UPLOAD_DONE' => $lang['upload_successful'], 302 'L_MANDATORY' => $lang['mandatory'], 303 304 'F_ACTION' => $u_form, 305 306 'U_RETURN' => make_index_url(array('category' => $page['cat'])), 307 ) 308 ); 309 309 310 310 if ( !$page['upload_successful'] )
Note: See TracChangeset
for help on using the changeset viewer.