[ PHPXref.com ] [ Generated: Sun Jul 20 17:08:59 2008 ] [ CuteNews 1.4.1 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> search.php (source)

   1  <?php
   2  error_reporting (E_ALL ^ E_NOTICE);
   3  
   4  $cutepath =  __FILE__;
   5  $cutepath = preg_replace( "'\\\search\.php'", "", $cutepath);
   6  $cutepath = preg_replace( "'/search\.php'", "", $cutepath);
   7  
   8  require_once("$cutepath/inc/functions.inc.php");
   9  
  10  $user_query = cute_query_string($QUERY_STRING, array("search_in_archives", "start_from", "archive", "subaction", "id", "cnshow",
  11  "ucat","dosearch", "story", "title", "user", "from_date_day", "from_date_month", "from_date_year", "to_date_day", "to_date_month", "to_date_year"));
  12  $user_post_query = cute_query_string($QUERY_STRING, array("search_in_archives", "start_from", "archive", "subaction", "id", "cnshow",
  13  "ucat","dosearch", "story", "title", "user", "from_date_day", "from_date_month", "from_date_year", "to_date_day", "to_date_month", "to_date_year"), "post");
  14  
  15  // Define Users

  16  $all_users = file("$cutepath/data/users.db.php");
  17  foreach($all_users as $my_user)
  18  {
  19          if(!eregi("<\?",$member_db_line)){
  20                  $user_arr = explode("|",$my_user);
  21                  if($user_arr[4] != ""){ $my_names[$user_arr[2]] = "$user_arr[4]"; }
  22                  else{ $my_names[$user_arr[2]] = "$user_arr[2]"; }
  23      }
  24  }
  25  // Show Search Form

  26  echo<<<HTML
  27  <script language='javascript' type="text/javascript">
  28          function mySelect(form){
  29              form.select();
  30      }
  31          function ShowOrHide(d1, d2) {
  32            if (d1 != '') DoDiv(d1);
  33            if (d2 != '') DoDiv(d2);
  34          }
  35          function DoDiv(id) {
  36            var item = null;
  37            if (document.getElementById) {
  38                  item = document.getElementById(id);
  39            } else if (document.all){
  40                  item = document.all[id];
  41            } else if (document.layers){
  42                  item = document.layers[id];
  43            }
  44            if (!item) {
  45            }
  46            else if (item.style) {
  47                  if (item.style.display == "none"){ item.style.display = ""; }
  48                  else {item.style.display = "none"; }
  49            }else{ item.visibility = "show"; }
  50           }
  51  </script>
  52  <form method=GET action="$PHP_SELF?subaction=search">
  53  <input type=hidden name=dosearch value=yes>
  54  
  55  <div align="center">
  56    <table border="0" cellspacing="0" cellpadding="0">
  57      <tr>
  58        <td><table width="100%" cellspacing="0" cellpadding="0">
  59            <td width="100%">
  60              <p align="right">News <input type=text value="$story" name=story size="24">
  61          </table></td>
  62      </tr>
  63      <tr>
  64        <td>
  65  
  66  <div id='advanced' style='display:none;z-index:1;'>
  67  <table width="100%" cellspacing="0" cellpadding="0">
  68            <td width="100%" align="right">
  69              <p align="right">Title&nbsp;<input type=text value="$title" name=title size="24">
  70    <tr>
  71      <td width="100%" align="right">Author&nbsp;<input type=text value="$user" name=user size="24">
  72    </tr>
  73  
  74  
  75  
  76    <tr>
  77      <td width="100%" align="right">From date
  78         <select name=from_date_day>
  79         <option value="">  </option>
  80  HTML;
  81  for($i=1;$i<32;$i++){
  82      if($from_date_day == $i){ echo"<option selected value=$i>$i</option>"; }
  83      else{ echo"<option value=$i>$i</option>"; }
  84  }
  85  
  86  echo"</select><select name=from_date_month>       <option value=\"\">  </option>";
  87  
  88  for($i=1;$i<13;$i++){
  89      $timestamp = mktime(0,0,0,$i,1,2003);
  90      if($from_date_month == $i){ echo"<option selected value=$i>". date("M", $timestamp) ."</option>"; }
  91      else{ echo"<option value=$i>". date("M", $timestamp) ."</option>"; }
  92  }
  93  
  94  echo"</select><select name=from_date_year>       <option value=\"\">  </option>";
  95  
  96  for($i=2003;$i<2011;$i++){
  97      if($from_date_year == $i){ echo"<option selected value=$i>$i</option>"; }
  98      else{ echo"<option value=$i>$i</option>"; }
  99  }
 100  //////////////////////////////////////////////////////////////////////////

 101  echo<<<HTML
 102    </tr>
 103    <tr>
 104      <td width="100%" align="right">To date
 105         <select name=to_date_day>
 106         <option value="">  </option>
 107  HTML;
 108  for($i=1;$i<32;$i++){
 109      if($to_date_day == $i){ echo"<option selected value=$i>$i</option>"; }
 110      else{ echo"<option value=$i>$i</option>"; }
 111  }
 112  
 113  echo"</select><select name=to_date_month><option value=\"\">  </option>";
 114  
 115  for($i=1;$i<13;$i++){
 116      $timestamp = mktime(0,0,0,$i,1,2003);
 117      if($to_date_month == $i){ echo"<option selected value=$i>". date("M", $timestamp) ."</option>"; }
 118      else{ echo"<option value=$i>". date("M", $timestamp) ."</option>"; }
 119  }
 120  
 121  echo"</select><select name=to_date_year><option value=\"\">  </option>";
 122  
 123  for($i=2003;$i<2011;$i++){
 124      if($to_date_year == $i){ echo"<option selected value=$i>$i</option>"; }
 125      else{ echo"<option value=$i>$i</option>"; }
 126  }
 127  
 128  if($search_in_archives){ $selected_search_arch = "checked=\"checked\""; }
 129  
 130  echo<<<HTML
 131        </select>
 132    </tr>
 133    <tr>
 134      <td width="100%" align="right">
 135        <p align="right"><label>Search and archives
 136      <input type=checkbox $selected_search_arch name="search_in_archives" value="TRUE"></label>
 137    </tr>
 138  </table>
 139  </div>
 140  
 141            </td>
 142      </tr>
 143      <tr>
 144        <td>
 145          <p align="right">&nbsp;
 146      <a href="javascript:ShowOrHide('advanced','')">advanced</a>&nbsp;&nbsp; <input type=submit value=Search>
 147        </td>
 148      </tr>
 149    </table>
 150  </div>
 151  $user_post_query
 152  </form>
 153  <center>
 154  HTML;
 155  
 156  // Don't edit below this line unless you know what you are doing !!!

 157  
 158  if($dosearch == "yes")
 159  {
 160  
 161      if( $from_date_day != "" and $from_date_month != "" and $from_date_year != "" and $to_date_day != "" and $to_date_month != "" and $to_date_year != "" )
 162      {
 163          $date_from         = mktime(0,0,0,$from_date_month,$from_date_day,$from_date_year);
 164          $date_to         = mktime(0,0,0,$to_date_month,$to_date_day,$to_date_year);
 165  
 166          $do_date = TRUE;
 167      }
 168  
 169  
 170          $story = trim($story);
 171  
 172          if($search_in_archives){
 173              if(!$handle = opendir("$cutepath/data/archives")){ die("<center>Can not open directory $cutepath/data/archives "); }
 174                  while (false !== ($file = readdir($handle)))
 175                  {
 176                          if($file != "." and $file != ".." and eregi("news", $file))
 177                          {
 178                                  $files_arch[] = "$cutepath/data/archives/$file";
 179                  }
 180                  }
 181          }
 182      $files_arch[] = "$cutepath/data/news.txt";
 183  
 184      foreach($files_arch as $file)
 185      {
 186          $archive = FALSE;
 187          if(ereg("([[:digit:]]{0,})\.news\.arch", $file, $regs)){ $archive = $regs[1]; }
 188          $all_news_db = file("$file");
 189              foreach($all_news_db as $news_line){
 190                          $news_db_arr = explode("|",$news_line);
 191                          $found  = 0;
 192  
 193                          $fuser  = FALSE;
 194                          $ftitle = FALSE;
 195                          $fstory = FALSE;
 196                          if($title and @preg_match("/$title/i", "$news_db_arr[2]")){ $ftitle = TRUE; }
 197                          if($user  and @preg_match("/\b$user\b/i", "$news_db_arr[1]")){ $fuser = TRUE; }
 198                          if($story and (@preg_match("/$story/i", "$news_db_arr[4]") or @preg_match("/$story/i", "$news_db_arr[3]"))){ $fstory = TRUE;}
 199  
 200                          if($title and $ftitle){ $ftitle = TRUE; }elseif(!$title){ $ftitle = TRUE; }else{ $ftitle = FALSE; }
 201                          if($story and $fstory){ $fstory = TRUE; }elseif(!$story){ $fstory = TRUE; }else{ $fstory = FALSE; }
 202                          if($user  and $fuser) { $fuser  = TRUE; }elseif(!$user) { $fuser  = TRUE; }else{ $fuser  = FALSE; }
 203              if($do_date)
 204              {
 205                      if($date_from < $news_db_arr[0] and  $news_db_arr[0] < $date_to){ $fdate = TRUE; }else{ $fdate = FALSE; }
 206              }else{ $fdate = TRUE; }
 207  
 208                          if($fdate and $ftitle and $fuser and $fstory){ $found_arr[$news_db_arr[0]] = $archive; }
 209  
 210                  }//foreach news line

 211          }
 212  
 213  
 214          echo"<br /><b>Founded News articles [". count($found_arr)."]:</b><br />";
 215  
 216  
 217              if($do_date){echo"from ".@date("d F Y",$date_from)." to ".@date("d F Y",$date_to)."<br />";}
 218  
 219  
 220      // Display Search Results

 221      if(is_array($found_arr)){
 222          foreach($found_arr as $news_id => $archive)
 223          {
 224              if($archive){$all_news = file("$cutepath/data/archives/$archive.news.arch");}
 225              else{ $all_news = file("$cutepath/data/news.txt"); }
 226  
 227              foreach($all_news as $single_line)
 228                             {
 229                                     $item_arr = explode("|",$single_line);
 230                                     $local_id = $item_arr[0];
 231  
 232                                     if($local_id == $news_id){
 233  ////////// Showing Result

 234  
 235                      echo"<br /><b><a href=\"$PHP_SELF?misc=search&subaction=showfull&id=$local_id&archive=$archive&cnshow=news&ucat=$item_arr[6]&start_from=&$user_query\">$item_arr[2]</a></b> (". date("d F, Y", $item_arr[0]) .")";
 236  
 237  ////////// End Showing Result

 238                  }
 239                             }
 240                     }
 241       }else{ echo"There are no news matching your search criteria"; }
 242  
 243  }//if user wants to search

 244  elseif( ($misc == "search") and ($subaction == "showfull" or $subaction == "showcomments" or $_POST["subaction"] == "addcomment" or $subaction == "addcomment")){
 245  
 246          require_once("$cutepath/show_news.php");
 247  
 248          unset($action,$subaction);
 249  }
 250  
 251  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]