home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / modules / journal / search.php < prev   
Encoding:
PHP Script  |  2002-09-17  |  9.7 KB  |  190 lines

  1. <?php
  2.  
  3. /************************************************************************/
  4. /* Journal § ZX                                                     */
  5. /* ================                                                     */
  6. /*                                                                      */
  7. /* Original work done by Joseph Howard known as Member's Journal, which */
  8. /* was based on Trevor Scott's vision of Atomic Journal.                */
  9. /*                                                                      */
  10. /* Modified on 25 May 2002 by Paul Laudanski (paul@computercops.biz)    */
  11. /* Copyright (c) 2002 Modifications by Computer Cops.                   */
  12. /* http://computercops.biz                                              */
  13. /*                                                                      */
  14. /* Member's Journal did not work on a PHPNuke 5.5 portal which had      */
  15. /* phpbb2 port integrated.  Thus was Journal § ZX created with the  */
  16. /* Member's Journal author's blessings.                                 */
  17. /*                                                                      */
  18. /* To install, backup everything first and then FTP the Journal package */
  19. /* files into your site's module directory.  Also run the tables.sql    */
  20. /* script so the proper tables and fields can be created and used.  The */
  21. /* default table prefix is "nuke" which is hard-coded throughout the    */
  22. /* entire system as a left-over from Member's Journal.  If a demand     */
  23. /* exists, that can be changed for a future release.                    */
  24. /*                                                                      */
  25. /* This program is free software. You can redistribute it and/or modify */
  26. /* it under the terms of the GNU General Public License as published by */
  27. /* the Free Software Foundation; either version 2 of the License.       */
  28. /************************************************************************/
  29.  
  30. if (!eregi("modules.php", $PHP_SELF)) {
  31.     die ("You can't access this file directly...");
  32. }
  33.  
  34. require_once("mainfile.php");
  35. $module_name = basename(dirname(__FILE__));
  36. get_lang($module_name);
  37.  
  38. $pagetitle = "- "._USERSJOURNAL."";
  39.  
  40. include("header.php");
  41. include("modules/$module_name/functions.php");
  42.  
  43. cookiedecode($user);
  44. $username = $cookie[1];
  45.  
  46. if (!isset($bywhat)):
  47.     $bywhat = "naddaanythang";
  48. else :
  49.     $bywhat = stripslashes($bywhat);
  50. endif;
  51.  
  52. if (!isset($forwhat)):
  53.     $forwhat = "naddaanythang";
  54. else :
  55.     $forwhat = stripslashes($forwhat);
  56. endif;
  57.  
  58. startjournal($sitename,$user);
  59.  
  60. function displaySearch($sitename,$username,$bgcolor2,$bgcolor3,$bgcolor1) {
  61.     global $module_name;
  62.     echo "<br>";
  63.     OpenTable();
  64.     echo ("<div align=center class=title>");
  65.     echo ("<strong>"._JOURNALSEARCH."</strong></div><br><br>");
  66.     echo ("<div align=center>");
  67.     echo ("<form action='modules.php?name=$module_name&file=search' method='post'>");
  68.     echo ("<input type='hidden' name='disp' value='search'>");
  69.     echo ("<input type='text' name='forwhat' size='30' maxlength='150'> "._IN." <select name='bywhat'>");
  70.     echo ("<option value=\"aid\" SELECTED>Members</option>");
  71.     echo ("<option value=\"title\">"._TITLE."</option>");
  72.     echo ("<option value=\"bodytext\">"._BODYTEXT."</option>");
  73.     echo ("<option value=\"comment\">"._UCOMMENTS."</option>");    
  74.     echo ("</select>  <input type='submit' name='submit' value='"._SEARCH."'>");
  75.     echo ("</form>");
  76.     echo ("</div>");
  77.     CloseTable();
  78. }
  79.  
  80. function search($username,$bywhat,$forwhat,$sitename,$bgcolor2,$bgcolor3,$user) {
  81.     global $prefix, $user_prefix, $dbi, $module_name, $exact;
  82.     echo "<br>";
  83.     OpenTable();
  84.     echo ("<div align=center>");
  85.     if ($exact == '1') {
  86.         echo ("<strong>"._JOURNALFOR.": \"$forwhat\"</strong><br><br>");
  87.     } else {
  88.         echo ("<strong>"._SEARCHRESULTS.": \"$forwhat\"</strong><br><br>");
  89.     }
  90.     if ($forwhat == "naddaanythang") :
  91.         displaySearch($sitename,$username,$bgcolor2,$bgcolor3, $bgcolor1);
  92.     else :
  93.         echo ("<table align=center width=\"90%\" border=2>");
  94.     echo ("<tr>");
  95.     echo ("<td align=center width=100><strong><div align=\"center\">"._PROFILE."</div></strong></td>");
  96.     echo ("<td align=center><strong>"._TITLE."</strong> "._CLICKTOVIEW."</td>");
  97.     echo ("<td align=center width=\"5%\"><strong>"._VIEW."</strong></td>");
  98.         if ($exact == '1') {
  99.             if ($forwhat == $username) {
  100.                 $editdel = 1;
  101.             }
  102.         } else {
  103.             if (eregi($forwhat, $username)) {
  104.                 $editdel = 2;
  105.             }
  106.         }
  107.     if ($editdel == '1') {
  108.         echo ("<td align=center width=\"5%\"><strong>"._EDIT."</strong></td>");
  109.         echo ("<td align=center width=\"5%\"><strong>"._DELETE."</strong></td>");
  110.     } elseif ($editdel == '2') {
  111.         echo ("<td align=center width=\"5%\"><strong>"._EDIT."/<br>"._PROFILE."</strong></td>");
  112.         echo ("<td align=center width=\"5%\"><strong>"._DELETE."/<br> </strong></td>");
  113.     } else {
  114.         echo ("<td align=center width=\"5%\"><strong>"._PROFILE."</strong></td>");
  115.     }
  116.     echo ("</tr>");
  117.     if ($bywhat == 'aid'):
  118.         if ($exact == '1') {
  119.             $sql = "SELECT j.jid, j.aid, j.title, j.pdate, j.ptime, j.mdate, j.mtime, u.uid, u.uname FROM ".$prefix."_journal j, ".$user_prefix."_users u WHERE u.uname=j.aid and j.aid='$forwhat' order by j.jid DESC";
  120.         } else {
  121.             $sql = "SELECT j.jid, j.aid, j.title, j.pdate, j.ptime, j.mdate, j.mtime, u.uid, u.uname FROM ".$prefix."_journal j, ".$user_prefix."_users u WHERE u.uname=j.aid and j.aid like '%$forwhat%' order by j.jid DESC";
  122.         }
  123.     elseif ($bywhat == 'title'):
  124.         $sql = "SELECT j.jid, j.aid, j.title, j.pdate, j.ptime, j.mdate, j.mtime, u.uid, u.uname FROM ".$prefix."_journal j, ".$user_prefix."_users u WHERE u.uname=j.aid and j.title like '%$forwhat%' order by j.jid DESC";
  125.     elseif ($bywhat == 'bodytext'):
  126.         $sql = "SELECT j.jid, j.aid, j.title, j.pdate, j.ptime, j.mdate, j.mtime, u.uid, u.uname FROM ".$prefix."_journal j, ".$user_prefix."_users u WHERE u.uname=j.aid and j.bodytext LIKE '%$forwhat%' order by j.jid DESC";
  127.     elseif ($bywhat == 'comment'):
  128.         $sql = "SELECT j.jid, j.aid, j.title, j.pdate, j.ptime, j.mdate, j.mtime, u.uid, u.uname FROM ".$prefix."_journal j, ".$user_prefix."_users u, ".$prefix."_journal_comments c WHERE u.uname=j.aid and c.rid=j.jid and c.comment LIKE '%$forwhat%' order by j.jid DESC";
  129.     endif;
  130.     $result = sql_query($sql, $dbi);
  131.     while ($row = sql_fetch_array($result, $dbi)) {
  132.             if ($row[status] == "no") :
  133.         $dcount = $dcount + 0;
  134.         else :
  135.         $dcount = $dcount + 1;
  136.         print  ("<tr>");
  137.         printf ("<td align=center bgcolor=$bgcolor2><a href=\"modules.php?name=Your_Account&op=userinfo&uname=$row[uname]\">%s</a></td>", $row[aid], $row[aid]);
  138.         printf ("<td align=left bgcolor=$bgcolor2> <a href=\"modules.php?name=$module_name&file=display&jid=%s\">%s</a> <span class=tiny>(%s @ %s)</span>", $row[jid], $row[title], $row[pdate], $row[ptime]);
  139.         $sqlscnd = "SELECT cid from ".$prefix."_journal_comments where rid=$row[jid]";
  140.         $rstscnd = sql_query($sqlscnd, $dbi);
  141.         $scndcount=0;
  142.         while ($rowscnd = sql_fetch_array($rstscnd, $dbi)) {
  143.             $scndcount = $scndcount + 1;
  144.         }
  145.         if ($scndcount>0):
  146.             printf (" —— $scndcount comments</td>");
  147.         endif;
  148.         printf ("<td align=center bgcolor=$bgcolor2><a href=\"modules.php?name=$module_name&file=display&jid=%s\"><img src=\"modules/$module_name/images/read.gif\" border=0 alt=\""._READ."\" title=\""._READ."\"></a></td>", $row[jid], $row[title]);
  149.         if ($row[aid] == $username) :
  150.             printf ("<td align=center bgcolor=$bgcolor2><a href=\"modules.php?name=$module_name&file=modify&jid=%s\"><img src='modules/$module_name/images/edit.gif' border='0' alt=\""._EDIT."\" title=\""._EDIT."\"></a></td>", $row[jid], $row[title]);
  151.             printf ("<td align=center bgcolor=$bgcolor2><a href=\"modules.php?name=$module_name&file=delete&jid=%s&forwhat=$forwhat\"><img src='modules/$module_name/images/trash.gif' border='0' alt=\""._DELETE."\" title=\""._DELETE."\"></a></td>", $row[jid], $row[title]);
  152.         else :
  153.             //printf ("<td align=center bgcolor=$bgcolor2><a href=\"modules.php?name=$module_name&file=display&jid=%s\"><img src=\"modules/$module_name/images/read.gif\" border=0 alt=\""._READ."\" title=\""._READ."\"></a></td>", $row[jid], $row[title]);
  154.             printf ("<td align=center bgcolor=$bgcolor2><a href=\"modules.php?name=Your_Account&op=userinfo&uname=$row[uname]\"><img src=\"modules/$module_name/images/nuke.gif\" border=\"0\" alt=\""._USERPROFILE2."\" title=\""._USERPROFILE2."\"></a></td>", $row[uid], $row[aid]);
  155.             
  156.             /*
  157.             if ($username == "") {
  158.             print ("<td align=center bgcolor=$bgcolor2><a href=\"modules.php?name=Your_Account\"><img src=\"modules/$module_name/images/folder.gif\" border=0 alt=\""._CREATEACCOUNT."\" title=\""._CREATEACCOUNT."\"></a></td>");
  159.             } elseif ($username != "" AND is_active("Private_Messages")) {
  160.             printf ("<td align=center bgcolor=$bgcolor2><a href=\"modules.php?name=Private_Messages&file=reply&send=1&uname=$row[uname]\"><img src='modules/$module_name/images/chat.gif' border='0' alt='"._PRIVMSGJ2."'></a></td>", $row[aid], $row[aid]);
  161.             }
  162.             */
  163.         endif;
  164.         endif;
  165.     }
  166.     echo ("</table>");
  167.     if ($dcount == "") { $dcount = 0; }
  168.     echo ("<br><div align=center>$dcount "._PUBLICFOR." \"$forwhat\"</div>");
  169.     endif;
  170.     echo ("</div>");
  171.     CloseTable();
  172. }
  173.  
  174. switch($disp) {
  175.     case "showsearch":
  176.     displaySearch($sitename,$username,$bgcolor2,$bgcolor3,$bgcolor1,$forwhat,$user);
  177.     break;
  178.  
  179.     case "search":
  180.     search($username,$bywhat,$forwhat,$sitename,$bgcolor2,$bgcolor3,$user);
  181.     break;
  182.     
  183.     default:
  184.     search($username,$bywhat,$forwhat,$sitename,$bgcolor2,$bgcolor3,$user);
  185.     break;
  186. }
  187.  
  188. journalfoot();
  189.  
  190. ?>