home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / modules / Journal / edit.php < prev    next >
PHP Script  |  2004-01-10  |  11KB  |  228 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. /* Required: PHPNuke 5.5 ( http://www.phpnuke.org/ ) and phpbb2         */
  15. /* ( http://bbtonuke.sourceforge.net/ ) forums port.                    */
  16. /*                                                                      */
  17. /* Member's Journal did not work on a PHPNuke 5.5 portal which had      */
  18. /* phpbb2 port integrated.  Thus was Journal § ZX created with the  */
  19. /* Member's Journal author's blessings.                                 */
  20. /*                                                                      */
  21. /* To install, backup everything first and then FTP the Journal package */
  22. /* files into your site's module directory.  Also run the tables.sql    */
  23. /* script so the proper tables and fields can be created and used.  The */
  24. /* default table prefix is "nuke" which is hard-coded throughout the    */
  25. /* entire system as a left-over from Member's Journal.  If a demand     */
  26. /* exists, that can be changed for a future release.                    */
  27. /*                                                                      */
  28. /* This program is free software. You can redistribute it and/or modify */
  29. /* it under the terms of the GNU General Public License as published by */
  30. /* the Free Software Foundation; either version 2 of the License.       */
  31. /************************************************************************/
  32.  
  33. if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
  34.     die ("You can't access this file directly...");
  35. }
  36.  
  37. require_once("mainfile.php");
  38. $module_name = basename(dirname(__FILE__));
  39. get_lang($module_name);
  40.  
  41. $pagetitle = "- "._USERSJOURNAL."";
  42.  
  43. include("header.php");
  44. include("modules/$module_name/functions.php");
  45.  
  46. cookiedecode($user);
  47. $username = $cookie[1];
  48.  
  49. $jid = intval($jid);
  50. if ($edit == 1) {
  51.     $htime = date(h);
  52.     $mtime = date(i);
  53.     $ntime = date(a);
  54.     $mtime = "$htime:$mtime $ntime";
  55.     $mdate = date(m);
  56.     $ddate = date(d);
  57.     $ydate = date(Y);
  58.     $ndate = "$mdate-$ddate-$ydate";
  59.     $pdate = $ndate;
  60.     $ptime = $mtime;
  61.     $micro = microtime();
  62.     $sql = "SELECT * FROM ".$prefix."_journal WHERE jid = '$jid'";
  63.     $result = $db->sql_query($sql);
  64.     while ($row = $db->sql_fetchrow($result)) {
  65.     if ($username != $row[aid]):
  66.             echo ("<br>");
  67.         openTable();
  68.         echo ("<div align=center>".NOTYOURS."</div>");
  69.         closeTable();
  70.         journalfoot();
  71.         die();
  72.         endif;
  73.     }
  74.     echo ("<div align=center><strong>"._UPDATEOK."</strong></div><br>");
  75.     $sql="UPDATE ".$prefix."_journal SET title='$title', bodytext='$bodytext', mood='$mood', status='$status', mdate='$ndate', mtime='$mtime' WHERE jid='$jid'";
  76.     $db->sql_query($sql);
  77.     $edited = "<br><br><center><b>"._UPDATED."</b></center>";
  78. } else {
  79.     $edited = "";
  80. }
  81.  
  82. if ($debug == "true") :
  83.     echo ("UserName:$username<br>SiteName: $sitename");
  84. endif;
  85.  
  86. startjournal($sitename,$user);
  87.  
  88. echo "<br>";
  89. OpenTable();
  90. echo ("<div align=center class=title>"._JOURNALFOR." $username</div><br>");
  91. echo ("<div align=center> [ <a href=\"modules.php?name=$module_name&file=add\">"._ADDENTRY."</a> | <a href=\"modules.php?name=$module_name&file=edit&disp=last\">"._YOURLAST20."</a> | <a href=\"modules.php?name=$module_name&file=edit&disp=all\">"._LISTALLENTRIES."</a> ]</div>");
  92. echo "$edited";
  93. CloseTable();
  94. echo "<br>";
  95.  
  96. function list20($username,$bgcolor1,$bgcolor2,$bgcolor3) {
  97.     global $prefix, $user_prefix, $db, $module_name;
  98.     openTable();
  99.     echo ("<div align=\"center\" class=title>"._LAST20FOR." $username</div><br>");
  100.     echo ("<table align=center border=1 width=\"90%\">");
  101.     echo ("<tr>");
  102.     echo ("<td align=center bgcolor=$bgcolor1 width=70><strong><div align=\"center\">"._DATE."</div></strong></td>");
  103.     echo ("<td align=center bgcolor=$bgcolor1 width=70><strong><div align=\"center\">"._TIME."</div></strong></td>");
  104.     echo ("<td align=center bgcolor=$bgcolor1><strong>"._TITLE."</strong> "._CLICKTOVIEW."</td>");
  105.     echo ("<td align=center bgcolor=$bgcolor1 width=\"5%\"><strong><div align=\"center\">"._PUBLIC."</div></strong></td>");
  106.     echo ("<td align=center bgcolor=$bgcolor1 width=\"5%\"><strong><div align=\"center\">"._EDIT."</div></strong></td>");
  107.     echo ("<td align=center bgcolor=$bgcolor1 width=\"5%\"><strong><div align=\"center\">"._DELETE."</div></strong></td>");
  108.     echo ("</tr>");
  109.     $sql = "SELECT jid, aid, title, pdate, ptime, mdate, mtime, status, mood FROM ".$prefix."_journal WHERE aid='$username' order by 'jid' DESC";
  110.     $result = $db->sql_query($sql);
  111.     while ($row = $db->sql_fetchrow($result)) {
  112.     if ($dcount >= 21) :
  113.         echo ("</tr></table>");
  114.         closeTable();
  115.         echo ("<br>");
  116.         journalfoot();
  117.         die();
  118.     else :
  119.         $dcount = $dcount + 1;
  120.         print  ("<tr>");
  121.         printf ("<td align=center bgcolor=$bgcolor2><div align=\"center\">%s</div></td>", $row[pdate]);
  122.         printf ("<td align=center bgcolor=$bgcolor2><div align=\"center\">%s</div></td>", $row[ptime]);
  123.         printf ("<td align=left bgcolor=$bgcolor2> <a href=\"modules.php?name=$module_name&file=display&jid=%s\">%s</a>", $row[jid], $row[title]);
  124.         $sqlscnd = "SELECT cid from ".$prefix."_journal_comments where rid='$row[jid]'";
  125.         $rstscnd = $db->sql_query($sqlscnd);
  126.         $scndcount=0;
  127.         while ($rowscnd = $db->sql_fetchrow($rstscnd)) {
  128.         $scndcount = $scndcount + 1;
  129.         }
  130.         if ($scndcount == 1) {
  131.         printf (" —— $scndcount "._COMMENT."</td>");
  132.         } else {
  133.         printf (" —— $scndcount "._COMMENTS."</td>");
  134.         }
  135.         if ($row[status] == "yes") {
  136.         $row[status] = _YES;
  137.         } else {
  138.         $row[status] = _NO;
  139.         }
  140.         printf ("<td align=center bgcolor=$bgcolor2><div align=\"center\">%s</div></td>", $row[status]);
  141.         printf ("<td align=center bgcolor=$bgcolor2><div align=\"center\"><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></div></td>", $row[jid], $row[title]);
  142.         printf ("<td align=center bgcolor=$bgcolor2><div align=\"center\"><a href=\"modules.php?name=$module_name&file=delete&jid=%s\"><img src='modules/$module_name/images/trash.gif' border='0' alt=\""._DELETE."\" title=\""._DELETE."\"></a></div></td>", $row[jid], $row[title]);
  143.         print  ("</tr>");
  144.     endif;
  145.     }
  146.     echo ("</table>");
  147.     closeTable();
  148. }
  149.  
  150. function listall($username,$bgcolor1,$bgcolor2,$bgcolor3,$sitename) {
  151.     global $prefix, $user_prefix, $db, $module_name;
  152.     openTable();
  153.     echo ("<div align=\"center\" class=title>"._COMPLETELIST." $username</div><br>");
  154.     echo ("<table align=center border=1 width=\"90%\">");
  155.     echo ("<tr>");
  156.     echo ("<td align=center bgcolor=$bgcolor1 width=70><strong><div align=\"center\">"._DATE."</div></strong></td>");
  157.     echo ("<td align=center bgcolor=$bgcolor1 width=70><strong><div align=\"center\">"._TIME."</div></strong></td>");
  158.     echo ("<td align=center bgcolor=$bgcolor1><strong>Title</strong></td>");
  159.     echo ("<td align=center bgcolor=$bgcolor1 width=\"5%\"><strong><div align=\"center\">"._PUBLIC."</div></strong></td>");
  160.     echo ("<td align=center bgcolor=$bgcolor1 width=\"5%\"><strong><div align=\"center\">"._EDIT."</div></strong></td>");
  161.     echo ("<td align=center bgcolor=$bgcolor1 width=\"5%\"><strong><div align=\"center\">"._DELETE."</div></strong></td>");
  162.     echo ("</tr>");
  163.     $sql = "SELECT jid, aid, title, pdate, ptime, mdate, mtime, status, mood FROM ".$prefix."_journal WHERE aid='$username' order by 'jid' DESC";
  164.     $result = $db->sql_query($sql);
  165.     while ($row = $db->sql_fetchrow($result)) {
  166.     $dcount = $dcount + 1;
  167.     if ($row[status] == "yes"):
  168.         $pubcount = $pubcount +1;
  169.         $row[status] = _YES;
  170.     else:
  171.         $prvcount = $prvcount + 1;
  172.         $row[status] = _NO;
  173.     endif;
  174.     print  ("<tr>");
  175.     printf ("<td align=center bgcolor=$bgcolor2><div align=\"center\">%s</div></td>", $row[pdate]);
  176.     printf ("<td align=center bgcolor=$bgcolor2><div align=\"center\">%s</div></td>", $row[ptime]);
  177.     printf ("<td align=left bgcolor=$bgcolor2><a href=\"modules.php?name=$module_name&file=display&jid=%s\">%s</a>", $row[jid], $row[title]);
  178.     $sqlscnd = "SELECT cid from ".$prefix."_journal_comments where rid='$row[jid]'";
  179.     $rstscnd = $db->sql_query($sqlscnd);
  180.     $scndcount=0;
  181.     while ($rowscnd = $db->sql_fetchrow($rstscnd)) {
  182.         $scndcount = $scndcount + 1;
  183.     }
  184.     if ($scndcount == 1) {
  185.         printf (" —— $scndcount "._COMMENT."</td>");
  186.     } else {
  187.         printf (" —— $scndcount "._COMMENTS."</td>");
  188.     }
  189.     printf ("<td align=center bgcolor=$bgcolor2><div align=\"center\">%s</div></td>", $row[status]);
  190.     printf ("<td align=center bgcolor=$bgcolor2><div align=\"center\"><a href=\"modules.php?name=$module_name&file=modify&jid=%s\"><img src='modules/$module_name/images/edit.gif' border='0' alt='"._EDIT."'></a></div></td>", $row[jid]);
  191.     printf ("<td align=center bgcolor=$bgcolor2><div align=\"center\"><a href=\"modules.php?name=$module_name&file=delete&jid=%s\"><img src='modules/$module_name/images/trash.gif' border='0' alt='"._DELETE."'></a></div></td>", $row[jid]);
  192.     print  ("</tr>");
  193.     }
  194.     echo ("</table>");
  195.     if ($prvcount == "") {
  196.     $prvcount = 0;
  197.     }
  198.     if ($pubcount == "") {
  199.     $pubcount = 0;
  200.     }
  201.     if ($dcount == "") {
  202.     $dcount = 0;
  203.     }
  204.     echo "<br><div align=center>$pubcount "._PUBLICENTRIES." - "
  205.     ."$prvcount "._PRIVATEENTRIES." - "
  206.     ."$dcount "._TOTALENTRIES."</div>";
  207.     closeTable();
  208. }
  209.  
  210. switch($disp) {
  211.  
  212.     case "last":
  213.     list20($username,$bgcolor1,$bgcolor2,$bgcolor3);
  214.     break;
  215.  
  216.     case "all":
  217.     listall($username,$bgcolor1,$bgcolor2,$bgcolor3,$sitename);
  218.     break;
  219.  
  220.     default:
  221.     list20($username,$bgcolor1,$bgcolor2,$bgcolor3);
  222.     break;
  223.  
  224. }
  225.  
  226. journalfoot();
  227.  
  228. ?>