Changeset 17
- Timestamp:
- May 25, 2003, 10:31:39 AM (21 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/configuration.php
r10 r17 243 243 } 244 244 } 245 $query.= " where pseudo = 'visiteur';";245 $query.= " where username = 'guest';"; 246 246 mysql_query( $query ); 247 247 } … … 796 796 $vtp->addSession( $sub, 'line' ); 797 797 $vtp->addSession( $sub, 'param_line' ); 798 $vtp->setVar( $sub, 'param_line.name', $lang['conf_upload_maxwidth_thumbnail']);798 $vtp->setVar( $sub, 'param_line.name',$lang['conf_upload_maxwidth_thumbnail']); 799 799 $vtp->addSession( $sub, 'text' ); 800 800 $vtp->setVar( $sub, 'text.name', 'upload_maxwidth_thumbnail' ); 801 801 $vtp->setVar( $sub, 'text.value', $upload_maxwidth_thumbnail ); 802 802 $vtp->closeSession( $sub, 'text' ); 803 $vtp->setVar( $sub, 'param_line.def', $lang['conf_upload_maxwidth_thumbnail_info']);803 $vtp->setVar($sub,'param_line.def',$lang['conf_upload_maxwidth_thumbnail_info']); 804 804 $vtp->closeSession( $sub, 'param_line' ); 805 805 $vtp->closeSession( $sub, 'line' ); … … 807 807 $vtp->addSession( $sub, 'line' ); 808 808 $vtp->addSession( $sub, 'param_line' ); 809 $vtp->setVar( $sub, 'param_line.name', $lang['conf_upload_maxheight_thumbnail']);809 $vtp->setVar( $sub,'param_line.name',$lang['conf_upload_maxheight_thumbnail']); 810 810 $vtp->addSession( $sub, 'text' ); 811 811 $vtp->setVar( $sub, 'text.name', 'upload_maxheight_thumbnail' ); -
trunk/category.php
r16 r17 171 171 if ( $page['cat'] == 'search' ) 172 172 { 173 $url.= '&search='.$_GET['search'] ;173 $url.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; 174 174 } 175 175 $vtp->setVar( $handle, 'summary.url', add_session_id( $url ) ); … … 244 244 $query.= ' LIMIT '.$page['start'].','.$page['nb_image_page']; 245 245 $query.= ';'; 246 echo $query; 246 247 $result = mysql_query( $query ); 247 248 … … 249 250 $vtp->addSession( $handle, 'line' ); 250 251 // iteration counter to use a new <tr> every "$nb_image_line" pictures 251 $i = 1; 252 $cell_number = 1; 253 // iteration counter to be sure not to create too much lines in the table 254 $line_number = 1; 252 255 while ( $row = mysql_fetch_array( $result ) ) 253 256 { … … 295 298 if ( $page['cat'] == 'search' ) 296 299 { 297 $url_link.= '&search='.$_GET['search'] ;300 $url_link.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; 298 301 } 299 302 // date of availability for creation icon 300 $date= explode( '-', $row['date_available'] );301 $date = mktime( 0, 0, 0, $ date[1], $date[2], $date[0]);303 list( $year,$month,$day ) = explode( '-', $row['date_available'] ); 304 $date = mktime( 0, 0, 0, $month, $day, $year ); 302 305 // sending vars to display 303 306 $vtp->addSession( $handle, 'thumbnail' ); … … 323 326 $vtp->closeSession( $handle, 'thumbnail' ); 324 327 325 if ( $i == $user['nb_image_line'] ) 326 { 328 if ( $cell_number++ == $user['nb_image_line'] ) 329 { 330 // creating a new line 327 331 $vtp->closeSession( $handle, 'line' ); 328 $vtp->addSession( $handle, 'line' ); 329 $i = 1; 330 } 331 else 332 { 333 $i++; 334 } 335 } 336 if ( $i < $user['nb_image_line'] ) 337 { 338 $vtp->closeSession( $handle, 'line' ); 332 // the number of the next cell is 1 333 $cell_number = 1; 334 // we only create a new line if it does not exceed the maximum line 335 // per page for the logged user 336 if ( $line_number++ < $user['nb_line_page'] ) 337 { 338 $vtp->addSession( $handle, 'line' ); 339 } 340 } 339 341 } 340 342 $vtp->closeSession( $handle, 'thumbnails' ); … … 348 350 349 351 $subcats = get_non_empty_sub_cat_ids( $page['cat'] ); 350 $ i= 1;351 foreach ( $subcats as $ subcat) {352 $cell_number = 1; 353 foreach ( $subcats as $id => $subcat ) { 352 354 $result = get_cat_info( $subcat['non_empty_cat'] ); 353 355 $cat_directory = $result['dir']; … … 374 376 $image_row = mysql_fetch_array( $image_result ); 375 377 376 $file = substr ( $image_row['file'], 0, 377 strrpos ( $image_row['file'], '.' ) ); 378 $file = get_filename_wo_extension( $image_row['file'] ); 378 379 379 380 // creating links for thumbnail and associated category … … 384 385 $lien_image.= $image_row['file']; 385 386 386 $thumbnail_title = '';387 $thumbnail_title = $lang['hint_category']; 387 388 388 389 $url_link = './category.php?cat='.$subcat['id']; 389 390 if ( !in_array( $page['cat'], $page['tab_expand'] ) ) 390 391 { 391 $page['tab_expand'][sizeof( $page['tab_expand'] )] = $page['cat'];392 array_push( $page['tab_expand'], $page['cat'] ); 392 393 $page['expand'] = implode( ',', $page['tab_expand'] ); 393 394 } 394 395 $url_link.= '&expand='.$page['expand']; 396 list( $year,$month,$day ) = explode( '-', $subcat['date_dernier'] ); 397 $date = mktime( 0, 0, 0, $month, $day, $year ); 395 398 396 399 // sending vars to display … … 401 404 $vtp->setVar( $handle, 'thumbnail.title', $thumbnail_title ); 402 405 $vtp->setVar( $handle, 'thumbnail.name', $name ); 403 404 list( $year,$month,$day ) = explode( '-', $subcat['date_dernier'] );405 $date = mktime( 0, 0, 0, $month, $day, $year );406 406 $vtp->setVar( $handle, 'thumbnail.icon', get_icon( $date ) ); 407 408 407 $vtp->closeSession( $handle, 'thumbnail' ); 409 408 410 if ( $ i== $user['nb_image_line'] )409 if ( $cell_number++ == $user['nb_image_line'] ) 411 410 { 412 411 $vtp->closeSession( $handle, 'line' ); 413 $vtp->addSession( $handle, 'line' ); 414 $i = 1; 415 } 416 else 417 { 418 $i++; 419 } 412 $cell_number = 1; 413 // we open a new line if the subcat was not the last one 414 if ( $id < count( $subcats ) - 1 ) 415 { 416 $vtp->addSession( $handle, 'line' ); 417 } 418 } 419 } 420 if ( $id < count( $subcats ) - 1 ) 421 { 422 $vtp->closeSession( $handle, 'line' ); 420 423 } 421 424 $vtp->closeSession( $handle, 'thumbnails' ); -
trunk/include/config.inc.php
r14 r17 38 38 // will only order pictures by file ascending 39 39 // without taking into account the date_available 40 $conf['order_by'] = ' order by date_available desc, file asc';40 $conf['order_by'] = ' ORDER BY date_available DESC, file ASC'; 41 41 42 $conf['repertoire_image'] = './images/';43 42 $conf['nb_image_row'] = array('4','5','6','7','8'); 44 43 $conf['nb_row_page'] = array('2','3','4','5','6','7','10','20','1000'); -
trunk/include/functions.inc.php
r15 r17 170 170 while ( $file = readdir ( $opendir ) ) 171 171 { 172 if ( $file != "." and $file != ".."and is_dir ( $rep.$file ) )172 if ( $file != '.' and $file != '..' and is_dir ( $rep.$file ) ) 173 173 { 174 174 array_push( $sub_rep, $file ); … … 275 275 } 276 276 277 // - The replace_search function replaces a $search string by the search in 278 // another color 277 // - add_style replaces the 278 // $search into <span style="$style">$search</span> 279 // in the given $string. 279 280 // - The function does not replace characters in HTML tags 280 function replace_search( $string, $search)281 function add_style( $string, $search, $style ) 281 282 { 282 283 //return $string; 283 $style_search = "background-color:white;color:red;"; 284 $return_string = ""; 284 $return_string = ''; 285 285 $remaining = $string; 286 286 … … 292 292 { 293 293 $treatment = substr ( $remaining, 0, $start ); 294 $treatment = str_replace( $search, '<span style="'.$style _search.'">'.294 $treatment = str_replace( $search, '<span style="'.$style.'">'. 295 295 $search.'</span>', $treatment ); 296 $return_string.= $treatment.substr ( $remaining, $start, 297 $end - $start + 1 ); 296 $return_string.= $treatment.substr( $remaining, $start, $end-$start+1 ); 298 297 $remaining = substr ( $remaining, $end + 1, strlen( $remaining ) ); 299 298 $start = strpos ( $remaining, '<' ); 300 299 $end = strpos ( $remaining, '>' ); 301 300 } 302 $treatment = str_replace( $search, '<span style="'.$style _search.'">'.301 $treatment = str_replace( $search, '<span style="'.$style.'">'. 303 302 $search.'</span>', $remaining ); 304 303 $return_string.= $treatment; 305 304 306 305 return $return_string; 306 } 307 308 // replace_search replaces a searched words array string by the search in 309 // another style for the given $string. 310 function replace_search( $string, $search ) 311 { 312 $words = explode( ',', $search ); 313 $style = 'background-color:white;color:red;'; 314 foreach ( $words as $word ) { 315 $string = add_style( $string, $word, $style ); 316 } 317 return $string; 307 318 } 308 319 -
trunk/include/functions_category.inc.php
r16 r17 133 133 if ( $page['cat'] == 'search' ) 134 134 { 135 $url.= "&search=".$_GET['search'] ;135 $url.= "&search=".$_GET['search'].'&mode='.$_GET['mode']; 136 136 } 137 137 $lien_cat = add_session_id( $url ); … … 382 382 else 383 383 { 384 $query = ''; 384 if ( $page['cat'] == 'search' or $page['cat'] == 'most_visited' 385 or $page['cat'] == 'recent' or $page['cat'] == 'best_rated' ) 386 { 387 // we must not show pictures of a forbidden category 388 $restricted_cats = get_all_restrictions( $user['id'],$user['status'] ); 389 foreach ( $restricted_cats as $restricted_cat ) { 390 $where_append.= ' AND cat_id != '.$restricted_cat; 391 } 392 } 385 393 // search result 386 394 if ( $page['cat'] == 'search' ) … … 392 400 $page['title'].= $_GET['search']."</span>"; 393 401 } 394 $page['where'] = " WHERE ( file LIKE '%".$_GET['search']."%'"; 395 $page['where'].= " OR name LIKE '%".$_GET['search']."%'"; 396 $page['where'].= " OR comment LIKE '%".$_GET['search']."%' )"; 402 403 $page['where'] = ' WHERE ('; 404 $fields = array( 'file', 'name', 'comment' ); 405 $words = explode( ',', $_GET['search'] ); 406 $sql_search = array(); 407 foreach ( $words as $i => $word ) { 408 if ( $_GET['mode'] == 'OR' ) 409 { 410 if ( $i != 0 ) $page['where'].= ' OR'; 411 foreach ( $fields as $j => $field ) { 412 if ( $j != 0 ) $page['where'].= ' OR'; 413 $page['where'].= ' '.$field." LIKE '%".$word."%'"; 414 } 415 } 416 else if ( $_GET['mode'] == 'AND' ) 417 { 418 if ( $i != 0 ) $page['where'].= ' AND'; 419 $page['where'].= ' ('; 420 foreach ( $fields as $j => $field ) { 421 if ( $j != 0 ) $page['where'].= ' OR'; 422 $page['where'].= ' '.$field." LIKE '%".$word."%'"; 423 } 424 $page['where'].= ' )'; 425 } 426 } 427 $page['where'].= ' )'; 428 $page['where'].= $where_append; 397 429 398 430 $query = 'SELECT COUNT(*) AS nb_total_images'; … … 401 433 $query.= ';'; 402 434 403 $url.= '&search='.$_GET['search'] ;435 $url.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; 404 436 } 405 437 // favorites displaying … … 426 458 $page['where'] = " WHERE date_available > '"; 427 459 $page['where'].= date( 'Y-m-d', $date )."'"; 460 $page['where'].= $where_append; 428 461 429 462 $query = 'SELECT COUNT(*) AS nb_total_images'; … … 436 469 { 437 470 $page['title'] = $conf['top_number'].' '.$lang['most_visited_cat']; 438 $page['where'] = ' WHERE cat_id != -1' ;471 $page['where'] = ' WHERE cat_id != -1'.$where_append; 439 472 $conf['order_by'] = ' ORDER BY hit DESC, file ASC'; 440 473 $page['cat_nb_images'] = $conf['top_number']; … … 450 483 $row = mysql_fetch_array( $result ); 451 484 $page['cat_nb_images'] = $row['nb_total_images']; 452 }453 454 if ( $page['cat'] == 'search' or $page['cat'] == 'most_visited'455 or $page['cat'] == 'recent' or $page['cat'] == 'best_rated' )456 {457 // we must not show pictures of a forbidden category458 $restricted_cats = get_all_restrictions( $user['id'],$user['status'] );459 foreach ( $restricted_cats as $restricted_cat ) {460 $page['where'].= ' AND cat_id != '.$restricted_cat;461 }462 485 } 463 486 } … … 519 542 while ( $row = mysql_fetch_array( $result ) ) 520 543 { 521 if ( $row['nb_images'] == 0 )522 {523 $non_empty_cat = get_first_non_empty_cat_id( $row['id'] );524 }525 else526 {527 $non_empty_cat = $row['id'];528 }529 544 // only categories with findable picture in any of its subcats is 530 545 // represented. 531 if ( $non_empty_cat != false ) 546 if ( ( $row['nb_images'] != 0 and $non_empty_cat = $row['id'] ) 547 or $non_empty_cat = get_first_non_empty_cat_id( $row['id'] ) ) 532 548 { 533 549 $temp_cat = array( 534 'id' => $row['id'],535 'name' => $row['name'],536 'dir' => $row['dir'],537 'date_dernier' => $row['date_dernier'],550 'id' => $row['id'], 551 'name' => $row['name'], 552 'dir' => $row['dir'], 553 'date_dernier' => $row['date_dernier'], 538 554 'non_empty_cat' => $non_empty_cat ); 539 555 array_push( $cats, $temp_cat ); -
trunk/language/francais.php
r13 r17 181 181 // page search 182 182 $lang['search_title'] = 'Recherche'; 183 $lang['invalid_search'] = 'La recherche doit porter sur 3 caractères ou plus'; 183 // start version 1.3 184 $lang['invalid_search'] = 'Les mots recherchés doivent comporter plus de 3 caractères et ne doivent pas inclure de caractères de ponctuation'; 185 $lang['search_mode_or'] = 'au moins un mot'; 186 $lang['search_mode_and'] = 'tous les mots'; 187 // end version 1.3 184 188 $lang['search_field_search'] = 'Rechercher'; 185 189 $lang['search_return_main_page'] = 'Retour à la page des miniatures'; -
trunk/picture.php
r10 r17 133 133 if ( $page['cat'] == 'search' ) 134 134 { 135 $redirect.= '&search='.$_GET['search'] ;135 $redirect.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; 136 136 } 137 137 $url = add_session_id( $redirect, true ); … … 212 212 if ( $page['cat'] == 'search' ) 213 213 { 214 $url_link.= '&search='.$_GET['search'] ;214 $url_link.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; 215 215 } 216 216 // sending vars for display … … 286 286 if ( $page['cat'] == 'search' ) 287 287 { 288 $url_link.= "&search=".$_GET['search'] ;288 $url_link.= "&search=".$_GET['search'].'&mode='.$_GET['mode']; 289 289 } 290 290 $vtp->setGlobalVar( $handle, 'picture_link', add_session_id( $url_link ) ); … … 386 386 if ( $page['cat'] == 'search' ) 387 387 { 388 $url.= '&search='.$_GET['search'] ;388 $url.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; 389 389 } 390 390 $vtp->addSession( $handle, 'favorite' ); … … 459 459 if ( $page['cat'] == 'search' ) 460 460 { 461 $url_link.= "&search=".$_GET['search'] ;461 $url_link.= "&search=".$_GET['search'].'&mode='.$_GET['mode']; 462 462 } 463 463 // sending vars for display … … 512 512 if ( $page['cat'] == 'search' ) 513 513 { 514 $url.= '&search='.$_GET['search'] ;514 $url.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; 515 515 } 516 516 if( !isset( $_GET['start'] ) -
trunk/profile.php
r14 r17 133 133 if ( $page['cat'] == 'search' ) 134 134 { 135 $url.= '&search='.$_GET['search'] ;135 $url.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; 136 136 } 137 137 $url = add_session_id( $url, true ); … … 153 153 if ( $page['cat'] == 'search' ) 154 154 { 155 $url.= '&search='.$_GET['search'] ;155 $url.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; 156 156 } 157 157 $vtp->setGlobalVar( $handle, 'form_action', add_session_id( $url ) ); -
trunk/search.php
r10 r17 24 24 if ( isset( $_POST['search'] ) ) 25 25 { 26 $i = 0; 27 if ( strlen( $_POST['search'] ) > 2 ) 26 $redirect = true; 27 $search = array(); 28 $words = preg_split( '/\s+/', $_POST['search'] ); 29 foreach ( $words as $i => $word ) { 30 if ( strlen( $word ) > 2 and !preg_match( '/[,;:\']/', $word ) ) 31 { 32 array_push( $search, $word ); 33 } 34 else 35 { 36 $redirect = false; 37 array_push( $error, $lang['invalid_search'] ); 38 break; 39 } 40 } 41 $search = array_unique( $search ); 42 $search = implode( ',', $search ); 43 if ( $redirect ) 28 44 { 29 $url = add_session_id( 'category.php?cat=search&search='.30 $_POST['search'], true );45 $url = 'category.php?cat=search&search='.$search.'&mode='.$_POST['mode']; 46 $url = add_session_id( $url, true ); 31 47 header( 'Request-URI: '.$url ); 32 48 header( 'Content-Location: '.$url ); 33 49 header( 'Location: '.$url ); 34 50 exit(); 35 }36 else37 {38 $error[$i++] = $lang['invalid_search'];39 51 } 40 52 } … … 68 80 $vtp->closeSession( $handle, 'errors' ); 69 81 } 70 //---------------------------------------------------------------- search field 82 //------------------------------------------------------------------------ form 83 // search field 71 84 $vtp->addSession( $handle, 'line' ); 72 85 $vtp->setVar( $handle, 'line.name', $lang['search_field_search'] ); … … 77 90 $vtp->closeSession( $handle, 'text' ); 78 91 $vtp->closeSession( $handle, 'line' ); 92 // mode of search : match all words or at least one of this words 93 $vtp->addSession( $handle, 'line' ); 94 $vtp->addSession( $handle, 'group' ); 95 96 $vtp->addSession( $handle, 'radio' ); 97 $vtp->setVar( $handle, 'radio.name', 'mode' ); 98 $vtp->setVar( $handle, 'radio.value', 'OR' ); 99 $vtp->setVar( $handle, 'radio.option', $lang['search_mode_or'] ); 100 if ( $_POST['mode'] == 'OR' or $_POST['mode'] == '' ) 101 { 102 $vtp->setVar( $handle, 'radio.checked', ' checked="checked"' ); 103 } 104 $vtp->closeSession( $handle, 'radio' ); 105 106 $vtp->addSession( $handle, 'radio' ); 107 $vtp->setVar( $handle, 'radio.name', 'mode' ); 108 $vtp->setVar( $handle, 'radio.value', 'AND' ); 109 $vtp->setVar( $handle, 'radio.option', $lang['search_mode_and'] ); 110 if ( $_POST['mode'] == 'AND' ) 111 { 112 $vtp->setVar( $handle, 'radio.checked', ' checked="checked"' ); 113 } 114 $vtp->closeSession( $handle, 'radio' ); 115 116 $vtp->closeSession( $handle, 'group' ); 117 $vtp->closeSession( $handle, 'line' ); 79 118 //---------------------------------------------------- return to main page link 80 119 $vtp->setGlobalVar( $handle, 'back_url', add_session_id( './category.php' ) ); … … 83 122 echo $code; 84 123 //------------------------------------------------------------ log informations 124 pwg_log( 'category', $page['title'] ); 125 mysql_close(); 85 126 $query = 'insert into '.PREFIX_TABLE.'history'; 86 127 $query.= '(date,login,IP,page) values'; -
trunk/template/default/search.vtp
r2 r17 48 48 <input type="text" name="{#name}" size="{#size}" value="{#value}" /> 49 49 <!--/VTP_text--> 50 <!--VTP_group--> 51 <!--VTP_radio--> 52 <input type="radio" name="{#name}" value="{#value}"{#checked}/>{#option} 53 <!--/VTP_radio--> 54 <!--/VTP_group--> 50 55 </td> 51 56 </tr>
Note: See TracChangeset
for help on using the changeset viewer.