[ Index ] |
|
Code source de WebCalendar 1.0.5 |
1 <?php 2 include_once 'includes/init.php'; 3 4 $error = ""; 5 6 $keywords = getValue ( "keywords" ); 7 $advanced = getValue ( "advanced" ); 8 9 if ( strlen ( $keywords ) == 0 ) 10 $error = translate("You must enter one or more search keywords") . "."; 11 12 $matches = 0; 13 14 $search_others = true; 15 16 if ( empty ( $users ) || empty ( $users[0] ) ) 17 $search_others = false; 18 if ( $login == "__public__" && $public_access_others != "Y" ) 19 $search_others = false; 20 if ( $readonly == "Y" || $single_user == "Y" ) 21 $search_others = false; 22 23 print_header(); 24 ?> 25 26 <h2><?php etranslate("Search Results")?></h2> 27 28 <?php 29 if ( ! empty ( $error ) ) { 30 echo "<span style=\"font-weight:bold;\">" . translate("Error") . ":</span> $error"; 31 } else { 32 $ids = array (); 33 $words = split ( " ", $keywords ); 34 for ( $i = 0; $i < count ( $words ); $i++ ) { 35 // Note: we only search approved events 36 $sql = "SELECT webcal_entry.cal_id, webcal_entry.cal_name, " . 37 "webcal_entry.cal_date " . 38 "FROM webcal_entry, webcal_entry_user " . 39 "WHERE webcal_entry.cal_id = webcal_entry_user.cal_id " . 40 "AND webcal_entry_user.cal_status in ('A','W') " . 41 "AND webcal_entry_user.cal_login IN ( "; 42 if ( $search_others ) { 43 if ( empty ( $users[0] ) ) 44 $users[0] = $login; 45 for ( $j = 0; $j < count ( $users ); $j++ ) { 46 if ( $j > 0 ) 47 $sql .= ", "; 48 $sql .= " '$users[$j]'"; 49 } 50 } else 51 $sql .= " '$login' "; 52 $sql .= ") "; 53 if ( $search_others ) { 54 // Don't search confidential entries of other users. 55 $sql .= "AND ( webcal_entry_user.cal_login = '$login' OR " . 56 "( webcal_entry_user.cal_login != '$login' AND " . 57 "webcal_entry.cal_access = 'P' ) ) "; 58 } 59 $sql .= "AND ( UPPER(webcal_entry.cal_name) " . 60 "LIKE UPPER('%" . $words[$i] . "%') " . 61 "OR UPPER(webcal_entry.cal_description) " . 62 "LIKE UPPER('%" . $words[$i] . "%') ) " . 63 "ORDER BY cal_date"; 64 //echo "SQL: $sql<br />"; 65 $res = dbi_query ( $sql ); 66 if ( $res ) { 67 while ( $row = dbi_fetch_row ( $res ) ) { 68 $matches++; 69 $idstr = strval ( $row[0] ); 70 if ( empty ( $ids[$idstr] ) ) 71 $ids[$idstr] = 1; 72 else 73 $ids[$idstr]++; 74 $info[$idstr] = "$row[1] (" . date_to_str ($row[2]) . 75 ")"; 76 } 77 } 78 dbi_free_result ( $res ); 79 } 80 } 81 82 if ( $matches > 0 ) 83 $matches = count ( $ids ); 84 85 if ( $matches == 1 ) 86 echo "<span style=\"font-weight:bold;\">$matches " . translate("match found") . ".</span><br /><br />"; 87 else if ( $matches > 0 ) 88 echo "<span style=\"font-weight:bold;\">$matches " . translate("matches found") . ".</span><br /><br />"; 89 else 90 echo translate("No matches found") . "."; 91 92 // now sort by number of hits 93 if ( empty ( $error ) ) { 94 arsort ( $ids ); 95 echo "<ul>\n"; 96 for ( reset ( $ids ); $key = key ( $ids ); next ( $ids ) ) { 97 echo "<li><a class=\"nav\" href=\"view_entry.php?id=$key\">" . $info[$key] . "</a></li>\n"; 98 } 99 echo "</ul>\n"; 100 } 101 102 ?> 103 <br /><br /> 104 105 <?php print_trailer(); ?> 106 107 </body> 108 </html>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Nov 30 19:09:19 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |