home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / modules / Journal / search.php < prev   
PHP Script  |  2004-08-14  |  10KB  |  197 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", $_SERVER['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 (($bywhat != 'aid') && ($bywhat != 'title') && ($bywhat != 'bodytext') && ($bywhat != 'comment'))
  47. {
  48.    $bywhat = 'naddaanythang';
  49. }
  50.  
  51. if (!isset($forwhat))
  52. {
  53.    $forwhat = 'naddaanythang';
  54. }
  55.  
  56. startjournal($sitename,$user);
  57.  
  58. function displaySearch($sitename,$username,$bgcolor2,$bgcolor3,$bgcolor1) {
  59.     global $module_name;
  60.     echo "<br>";
  61.     OpenTable();
  62.     echo ("<div align=center class=title>");
  63.     echo ("<strong>"._JOURNALSEARCH."</strong></div><br><br>");
  64.     echo ("<div align=center>");
  65.     echo ("<form action='modules.php?name=$module_name&file=search' method='post'>");
  66.     echo ("<input type='hidden' name='disp' value='search'>");
  67.     echo ("<input type='text' name='forwhat' size='30' maxlength='150'> "._IN." <select name='bywhat'>");
  68.     echo ("<option value=\"aid\" SELECTED>Members</option>");
  69.     echo ("<option value=\"title\">"._TITLE."</option>");
  70.     echo ("<option value=\"bodytext\">"._BODYTEXT."</option>");
  71.     echo ("<option value=\"comment\">"._UCOMMENTS."</option>");    
  72.     echo ("</select>  <input type='submit' name='submit' value='"._SEARCH."'>");
  73.     echo ("</form>");
  74.     echo ("</div>");
  75.     CloseTable();
  76. }
  77.  
  78. function search($username,$bywhat,$forwhat,$sitename,$bgcolor2,$bgcolor3,$user) {
  79.     global $prefix, $user_prefix, $db, $module_name, $exact;
  80.    
  81.     //$forwhat2 = htmlentities(stripslashes($forwhat));
  82.     $forwhat2 = htmlentities($forwhat, ENT_QUOTES);
  83.    
  84.     echo "<br>";
  85.     OpenTable();
  86.    
  87.    
  88.     echo ("<div align=center>");
  89.     if ($exact == '1') {
  90.         echo ("<strong>"._JOURNALFOR.": \"$forwhat2\"</strong><br><br>");
  91.     } else {
  92.         echo ("<strong>"._SEARCHRESULTS.": \"$forwhat2\"</strong><br><br>");
  93.     }
  94.     if ($forwhat == "naddaanythang") :
  95.         displaySearch($sitename,$username,$bgcolor2,$bgcolor3, $bgcolor1);
  96.     else :
  97.         echo ("<table align=center width=\"90%\" border=2>");
  98.     echo ("<tr>");
  99.     echo ("<td align=center width=100><strong><div align=\"center\">"._PROFILE."</div></strong></td>");
  100.     echo ("<td align=center><strong>"._TITLE."</strong> "._CLICKTOVIEW."</td>");
  101.     echo ("<td align=center width=\"5%\"><strong>"._VIEW."</strong></td>");
  102.         if ($exact == '1') {
  103.             if ($forwhat == $username) {
  104.                 $editdel = 1;
  105.             }
  106.         } else {
  107.             if (eregi($forwhat, $username)) {
  108.                 $editdel = 2;
  109.             }
  110.         }
  111.     if ($editdel == '1') {
  112.         echo ("<td align=center width=\"5%\"><strong>"._EDIT."</strong></td>");
  113.         echo ("<td align=center width=\"5%\"><strong>"._DELETE."</strong></td>");
  114.     } elseif ($editdel == '2') {
  115.         echo ("<td align=center width=\"5%\"><strong>"._EDIT."/<br>"._PROFILE."</strong></td>");
  116.         echo ("<td align=center width=\"5%\"><strong>"._DELETE."/<br> </strong></td>");
  117.     } else {
  118.         echo ("<td align=center width=\"5%\"><strong>"._PROFILE."</strong></td>");
  119.     }
  120.     echo ("</tr>");
  121.     $forwhat = addslashes($forwhat);
  122.     if ($bywhat == 'aid'):
  123.         if ($exact == '1') {
  124.             $sql = "SELECT j.jid, j.aid, j.title, j.pdate, j.ptime, j.mdate, j.mtime, u.user_id, u.username FROM ".$prefix."_journal j, ".$user_prefix."_users u WHERE u.username=j.aid and j.aid='$forwhat' order by j.jid DESC";
  125.         } else {
  126.             $sql = "SELECT j.jid, j.aid, j.title, j.pdate, j.ptime, j.mdate, j.mtime, u.user_id, u.username FROM ".$prefix."_journal j, ".$user_prefix."_users u WHERE u.username=j.aid and j.aid like '%$forwhat%' order by j.jid DESC";
  127.         }
  128.     elseif ($bywhat == 'title'):
  129.         $sql = "SELECT j.jid, j.aid, j.title, j.pdate, j.ptime, j.mdate, j.mtime, u.user_id, u.username FROM ".$prefix."_journal j, ".$user_prefix."_users u WHERE u.username=j.aid and j.title like '%$forwhat%' order by j.jid DESC";
  130.     elseif ($bywhat == 'bodytext'):
  131.         $sql = "SELECT j.jid, j.aid, j.title, j.pdate, j.ptime, j.mdate, j.mtime, u.user_id, u.username FROM ".$prefix."_journal j, ".$user_prefix."_users u WHERE u.username=j.aid and j.bodytext LIKE '%$forwhat%' order by j.jid DESC";
  132.     elseif ($bywhat == 'comment'):
  133.         $sql = "SELECT j.jid, j.aid, j.title, j.pdate, j.ptime, j.mdate, j.mtime, u.user_id, u.username FROM ".$prefix."_journal j, ".$user_prefix."_users u, ".$prefix."_journal_comments c WHERE u.username=j.aid and c.rid=j.jid and c.comment LIKE '%$forwhat%' order by j.jid DESC";
  134.     endif;
  135.     $result = $db->sql_query($sql);
  136.     while ($row = $db->sql_fetchrow($result)) {
  137.             if ($row[status] == "no") :
  138.         $dcount = $dcount + 0;
  139.         else :
  140.         $dcount = $dcount + 1;
  141.         print  ("<tr>");
  142. //The follwing line made reference to non-existing field uname.//
  143.         printf ("<td align=center bgcolor=$bgcolor2><a href=\"modules.php?name=Your_Account&op=userinfo&username=$row[username]\">%s</a></td>", $row[aid], $row[aid]);
  144.         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]);
  145.         $sqlscnd = "SELECT cid from ".$prefix."_journal_comments where rid=$row[jid]";
  146.         $rstscnd = $db->sql_query($sqlscnd);
  147.         $scndcount=0;
  148.         while ($rowscnd = $db->sql_fetchrow($rstscnd)) {
  149.             $scndcount = $scndcount + 1;
  150.         }
  151.         if ($scndcount>0):
  152.             printf (" —— $scndcount comments</td>");
  153.         endif;
  154.         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]);
  155.         if ($row[aid] == $username) :
  156.           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]);
  157.           printf ("<td align=center bgcolor=$bgcolor2><a href=\"modules.php?name=$module_name&file=delete&jid=%s&forwhat=$forwhat2\"><img src='modules/$module_name/images/trash.gif' border='0' alt=\""._DELETE."\" title=\""._DELETE."\"></a></td>", $row[jid], $row[title]);
  158.                 else :
  159.             //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]);
  160. //The follwing line made reference to non-existing field uname.//
  161.             printf ("<td align=center bgcolor=$bgcolor2><a href=\"modules.php?name=Your_Account&op=userinfo&username=$row[username]\"><img src=\"modules/$module_name/images/nuke.gif\" border=\"0\" alt=\""._USERPROFILE2."\" title=\""._USERPROFILE2."\"></a></td>", $row[uid], $row[aid]);
  162.             
  163.             /*
  164.             if ($username == "") {
  165.             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>");
  166.             } elseif ($username != "" AND is_active("Private_Messages")) {
  167.             printf ("<td align=center bgcolor=$bgcolor2><a href=\"modules.php?name=Private_Messages&mode=post&u=$row[user_id]\"><img src='modules/$module_name/images/chat.gif' border='0' alt='"._PRIVMSGJ2."'></a></td>", $row[aid], $row[aid]);
  168.             }
  169.             */
  170.         endif;
  171.         endif;
  172.     }
  173.     echo ("</table>");
  174.     if ($dcount == "") { $dcount = 0; }
  175.     echo ("<br><div align=center>$dcount "._PUBLICFOR." \"$forwhat2\"</div>");
  176.     endif;
  177.     echo ("</div>");
  178.     CloseTable();
  179. }
  180.  
  181. switch($disp) {
  182.     case "showsearch":
  183.     displaySearch($sitename,$username,$bgcolor2,$bgcolor3,$bgcolor1,$forwhat,$user);
  184.     break;
  185.  
  186.     case "search":
  187.     search($username,$bywhat,$forwhat,$sitename,$bgcolor2,$bgcolor3,$user);
  188.     break;
  189.     
  190.     default:
  191.     search($username,$bywhat,$forwhat,$sitename,$bgcolor2,$bgcolor3,$user);
  192.     break;
  193. }
  194.  
  195. journalfoot();
  196.  
  197. ?>