home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / modules / journal / edit.php < prev    next >
Encoding:
PHP Script  |  2002-09-16  |  10.4 KB  |  227 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", $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. if ($edit == 1) {
  50.     $htime = date(h);
  51.     $mtime = date(i);
  52.     $ntime = date(a);
  53.     $mtime = "$htime:$mtime $ntime";
  54.     $mdate = date(m);
  55.     $ddate = date(d);
  56.     $ydate = date(Y);
  57.     $ndate = "$mdate-$ddate-$ydate";
  58.     $pdate = $ndate;
  59.     $ptime = $mtime;
  60.     $micro = microtime();
  61.     $sql = "SELECT * FROM ".$prefix."_journal WHERE jid = '$jid'";
  62.     $result = sql_query($sql, $dbi);
  63.     while ($row = sql_fetch_array($result, $dbi)) {
  64.     if ($username != $row[aid]):
  65.             echo ("<br>");
  66.         openTable();
  67.         echo ("<div align=center>".NOTYOURS."</div>");
  68.         closeTable();
  69.         journalfoot();
  70.         die();
  71.         endif;
  72.     }
  73.     echo ("<div align=center><strong>"._UPDATEOK."</strong></div><br>");
  74.     $sql="UPDATE ".$prefix."_journal SET title='$title', bodytext='$bodytext', mood='$mood', status='$status', mdate='$ndate', mtime='$mtime' WHERE jid='$jid'";
  75.     sql_query($sql, $dbi);
  76.     $edited = "<br><br><center><b>"._UPDATED."</b></center>";
  77. } else {
  78.     $edited = "";
  79. }
  80.  
  81. if ($debug == "true") :
  82.     echo ("UserName:$username<br>SiteName: $sitename");
  83. endif;
  84.  
  85. startjournal($sitename,$user);
  86.  
  87. echo "<br>";
  88. OpenTable();
  89. echo ("<div align=center class=title>"._JOURNALFOR." $username</div><br>");
  90. 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>");
  91. echo "$edited";
  92. CloseTable();
  93. echo "<br>";
  94.  
  95. function list20($username,$bgcolor1,$bgcolor2,$bgcolor3) {
  96.     global $prefix, $user_prefix, $dbi, $module_name;
  97.     openTable();
  98.     echo ("<div align=\"center\" class=title>"._LAST20FOR." $username</div><br>");
  99.     echo ("<table align=center border=1 width=\"90%\">");
  100.     echo ("<tr>");
  101.     echo ("<td align=center bgcolor=$bgcolor1 width=70><strong><div align=\"center\">"._DATE."</div></strong></td>");
  102.     echo ("<td align=center bgcolor=$bgcolor1 width=70><strong><div align=\"center\">"._TIME."</div></strong></td>");
  103.     echo ("<td align=center bgcolor=$bgcolor1><strong>"._TITLE."</strong> "._CLICKTOVIEW."</td>");
  104.     echo ("<td align=center bgcolor=$bgcolor1 width=\"5%\"><strong><div align=\"center\">"._PUBLIC."</div></strong></td>");
  105.     echo ("<td align=center bgcolor=$bgcolor1 width=\"5%\"><strong><div align=\"center\">"._EDIT."</div></strong></td>");
  106.     echo ("<td align=center bgcolor=$bgcolor1 width=\"5%\"><strong><div align=\"center\">"._DELETE."</div></strong></td>");
  107.     echo ("</tr>");
  108.     $sql = "SELECT jid, aid, title, pdate, ptime, mdate, mtime, status, mood FROM ".$prefix."_journal WHERE aid='$username' order by 'jid' DESC";
  109.     $result = sql_query($sql, $dbi);
  110.     while ($row = sql_fetch_array($result, $dbi)) {
  111.     if ($dcount >= 21) :
  112.         echo ("</tr></table>");
  113.         closeTable();
  114.         echo ("<br>");
  115.         journalfoot();
  116.         die();
  117.     else :
  118.         $dcount = $dcount + 1;
  119.         print  ("<tr>");
  120.         printf ("<td align=center bgcolor=$bgcolor2><div align=\"center\">%s</div></td>", $row[pdate]);
  121.         printf ("<td align=center bgcolor=$bgcolor2><div align=\"center\">%s</div></td>", $row[ptime]);
  122.         printf ("<td align=left bgcolor=$bgcolor2> <a href=\"modules.php?name=$module_name&file=display&jid=%s\">%s</a>", $row[jid], $row[title]);
  123.         $sqlscnd = "SELECT cid from ".$prefix."_journal_comments where rid=$row[jid]";
  124.         $rstscnd = sql_query($sqlscnd, $dbi);
  125.         $scndcount=0;
  126.         while ($rowscnd = sql_fetch_array($rstscnd, $dbi)) {
  127.         $scndcount = $scndcount + 1;
  128.         }
  129.         if ($scndcount == 1) {
  130.         printf (" —— $scndcount "._COMMENT."</td>");
  131.         } else {
  132.         printf (" —— $scndcount "._COMMENTS."</td>");
  133.         }
  134.         if ($row[status] == "yes") {
  135.         $row[status] = _YES;
  136.         } else {
  137.         $row[status] = _NO;
  138.         }
  139.         printf ("<td align=center bgcolor=$bgcolor2><div align=\"center\">%s</div></td>", $row[status]);
  140.         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]);
  141.         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]);
  142.         print  ("</tr>");
  143.     endif;
  144.     }
  145.     echo ("</table>");
  146.     closeTable();
  147. }
  148.  
  149. function listall($username,$bgcolor1,$bgcolor2,$bgcolor3,$sitename) {
  150.     global $prefix, $user_prefix, $dbi, $module_name;
  151.     openTable();
  152.     echo ("<div align=\"center\" class=title>"._COMPLETELIST." $username</div><br>");
  153.     echo ("<table align=center border=1 width=\"90%\">");
  154.     echo ("<tr>");
  155.     echo ("<td align=center bgcolor=$bgcolor1 width=70><strong><div align=\"center\">"._DATE."</div></strong></td>");
  156.     echo ("<td align=center bgcolor=$bgcolor1 width=70><strong><div align=\"center\">"._TIME."</div></strong></td>");
  157.     echo ("<td align=center bgcolor=$bgcolor1><strong>Title</strong></td>");
  158.     echo ("<td align=center bgcolor=$bgcolor1 width=\"5%\"><strong><div align=\"center\">"._PUBLIC."</div></strong></td>");
  159.     echo ("<td align=center bgcolor=$bgcolor1 width=\"5%\"><strong><div align=\"center\">"._EDIT."</div></strong></td>");
  160.     echo ("<td align=center bgcolor=$bgcolor1 width=\"5%\"><strong><div align=\"center\">"._DELETE."</div></strong></td>");
  161.     echo ("</tr>");
  162.     $sql = "SELECT jid, aid, title, pdate, ptime, mdate, mtime, status, mood FROM ".$prefix."_journal WHERE aid='$username' order by 'jid' DESC";
  163.     $result = sql_query($sql, $dbi);
  164.     while ($row = sql_fetch_array($result, $dbi)) {
  165.     $dcount = $dcount + 1;
  166.     if ($row[status] == "yes"):
  167.         $pubcount = $pubcount +1;
  168.         $row[status] = _YES;
  169.     else:
  170.         $prvcount = $prvcount + 1;
  171.         $row[status] = _NO;
  172.     endif;
  173.     print  ("<tr>");
  174.     printf ("<td align=center bgcolor=$bgcolor2><div align=\"center\">%s</div></td>", $row[pdate]);
  175.     printf ("<td align=center bgcolor=$bgcolor2><div align=\"center\">%s</div></td>", $row[ptime]);
  176.     printf ("<td align=left bgcolor=$bgcolor2><a href=\"modules.php?name=$module_name&file=display&jid=%s\">%s</a>", $row[jid], $row[title]);
  177.     $sqlscnd = "SELECT cid from ".$prefix."_journal_comments where rid=$row[jid]";
  178.     $rstscnd = sql_query($sqlscnd, $dbi);
  179.     $scndcount=0;
  180.     while ($rowscnd = sql_fetch_array($rstscnd, $dbi)) {
  181.         $scndcount = $scndcount + 1;
  182.     }
  183.     if ($scndcount == 1) {
  184.         printf (" —— $scndcount "._COMMENT."</td>");
  185.     } else {
  186.         printf (" —— $scndcount "._COMMENTS."</td>");
  187.     }
  188.     printf ("<td align=center bgcolor=$bgcolor2><div align=\"center\">%s</div></td>", $row[status]);
  189.     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]);
  190.     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]);
  191.     print  ("</tr>");
  192.     }
  193.     echo ("</table>");
  194.     if ($prvcount == "") {
  195.     $prvcount = 0;
  196.     }
  197.     if ($pubcount == "") {
  198.     $pubcount = 0;
  199.     }
  200.     if ($dcount == "") {
  201.     $dcount = 0;
  202.     }
  203.     echo "<br><div align=center>$pubcount "._PUBLICENTRIES." - "
  204.     ."$prvcount "._PRIVATEENTRIES." - "
  205.     ."$dcount "._TOTALENTRIES."</div>";
  206.     closeTable();
  207. }
  208.  
  209. switch($disp) {
  210.  
  211.     case "last":
  212.     list20($username,$bgcolor1,$bgcolor2,$bgcolor3);
  213.     break;
  214.  
  215.     case "all":
  216.     listall($username,$bgcolor1,$bgcolor2,$bgcolor3,$sitename);
  217.     break;
  218.  
  219.     default:
  220.     list20($username,$bgcolor1,$bgcolor2,$bgcolor3);
  221.     break;
  222.  
  223. }
  224.  
  225. journalfoot();
  226.  
  227. ?>