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

  1. <?php
  2.  
  3. /************************************************************************/
  4. /* PHP-NUKE: Advanced Content Management System                         */
  5. /* ============================================                         */
  6. /*                                                                      */
  7. /* Copyright (c) 2002 by Francisco Burzi                                */
  8. /* http://phpnuke.org                                                   */
  9. /*                                                                      */
  10. /* =========================                                            */
  11. /* Part of phpBB integration                                            */
  12. /* Copyright (c) 2001 by                                                */
  13. /*    Richard Tirtadji AKA King Richard (rtirtadji@hotmail.com)         */
  14. /*    Hutdik Hermawan AKA hotFix (hutdik76@hotmail.com)                 */
  15. /* http://www.phpnuke.web.id                                            */
  16. /*                                                                      */
  17. /* This program is free software. You can redistribute it and/or modify */
  18. /* it under the terms of the GNU General Public License as published by */
  19. /* the Free Software Foundation; either version 2 of the License.       */
  20. /************************************************************************/
  21.  
  22. $forumpage = 1;
  23.  
  24. if($cancel) {
  25.     header("Location: modules.php?name=$module_name");
  26. }
  27.  
  28. require_once("mainfile.php");
  29. $module_name = basename(dirname(__FILE__));
  30. get_lang($module_name);
  31.  
  32. include("modules/$module_name/functions.php");
  33. include("modules/$module_name/auth.php");
  34.  
  35. if (!is_user($user)) {
  36.     Header("Location: modules.php?name=Your_Account");
  37. } else {    
  38.     $pagetitle = "- "._PRIVATEMESSAGE."";
  39.     include('header.php');
  40.     title(""._PRIVATEMESSAGE."");
  41.  
  42.     if (is_user($user)) {
  43.     include("modules/Your_Account/navbar.php");
  44.     OpenTable();
  45.     nav();
  46.     CloseTable();
  47.     echo "<br>";
  48.     }
  49.  
  50.     $userdata = explode(":", base64_decode($user));
  51.     if (!$result = check_user_pw($userdata[1],$userdata[2],$db,$system))
  52.     $userdata = get_userdata($userdata[1], $db);
  53. if($submit) {
  54.     if($subject == "") {
  55.     OpenTable();
  56.     echo "<center>"._NOSUBJECT."<br><br>"._GOBACK."";
  57.     CloseTable();
  58.     include("footer.php");
  59.     exit();
  60.     }
  61.     if (check_html($subject, "nohtml") != $subject) {
  62.     OpenTable();
  63.     echo "<center><b>I don't like you... Nice Try!</b></center>";
  64.     CloseTable();
  65.     include("footer.php");
  66.     die();
  67.     }
  68.     if($message == '') {
  69.     OpenTable();
  70.     echo "<center>"._NOMESSAGE."<br><br>"._GOBACK."";
  71.     CloseTable();
  72.     include("footer.php");
  73.     exit();
  74.     }
  75.     if($allow_html == 0 && isset($html)) {
  76.         $message = htmlspecialchars($message);
  77.     }
  78.     if($allow_bbcode == 1 && !isset($bbcode)) {
  79.     $message = bbencode_priv($message);
  80.     }
  81.     if($sig) {
  82.         $message .= "<br>-----------------<br>" . $userdata[user_sig];
  83.     }
  84.     $message = str_replace("\n", "<br>", $message);
  85.     if(!$smile) {
  86.     $message = smile($message);
  87.     }
  88.     $message = make_clickable($message);
  89.     $message = addslashes($message);
  90.     $time = date("Y-m-d H:i");
  91.     $res = sql_query("select uid from ".$user_prefix."_users where uname='$to_user'", $dbi);
  92.     list($to_userid) = sql_fetch_row($res, $dbi);
  93.     if ($to_userid == "") {
  94.         OpenTable();
  95.         echo "<center>"._USERNOTINDB."<br>"
  96.             .""._CHECKNAMEANDTRY."<br><br>"
  97.             .""._GOBACK."</center>";
  98.         CloseTable();
  99.         include("footer.php");
  100.     } else {    
  101.         $sql = "INSERT INTO ".$prefix."_priv_msgs (msg_image, subject, from_userid, to_userid, msg_time, msg_text) ";
  102.         $sql .= "VALUES ('$image', '$subject', '$userdata[uid]', '$to_userid', '$time', '$message')";
  103.     sql_query($sql, $dbi);
  104.     OpenTable();
  105.     echo "<center>"._MSGPOSTED."<br><a href=\"modules.php?name=$module_name\">"._RETURNTOPMSG."</a></center>";
  106.     CloseTable();
  107.     }    
  108. }
  109. if ($delete_messages.x && $delete_messages.y) {
  110.     for ($i=0;$i<$total_messages;$i++) {
  111.     $sql = "DELETE FROM ".$prefix."_priv_msgs WHERE msg_id='$msg_id[$i]' AND to_userid='$userdata[uid]'";
  112.     $result = sql_query($sql, $dbi);
  113.     $status = 1;
  114.     if ($i == 0) {
  115.         OpenTable();
  116.             echo "<center>"._MSGDELETED."<br><a href=\"modules.php?name=$module_name\">"._RETURNTOPMSG."</a></center>";
  117.             CloseTable();
  118.     }
  119.     }
  120. }
  121. if ($delete) {
  122.     $sql = "DELETE FROM ".$prefix."_priv_msgs WHERE msg_id='$msg_id' AND to_userid='$userdata[uid]'";
  123.     $result = sql_query($sql, $dbi);
  124.     OpenTable();
  125.     echo "<center>"._MSGDELETED."<br><a href=\"modules.php?name=$module_name\">"._RETURNTOPMSG."</a></center>";
  126.     CloseTable();
  127. }
  128.  
  129. if ($reply || $send) {
  130.  
  131.     if ($uname != "") {
  132.     $res = sql_num_rows(sql_query("select * from ".$user_prefix."_users where uname='$uname'", $dbi), $dbi);
  133.     if ($res == 0) {
  134.         title("$sitename: "._PRIVATEMESSAGE."");
  135.         OpenTable();
  136.         echo "<center><b>"._PRIVMSGERROR."</b><br><br>"
  137.         .""._USERDOESNTEXIST."<br><br>"
  138.         .""._GOBACK."</center>";
  139.         CloseTable();
  140.         include("footer.php");
  141.         die();
  142.     }
  143.     }
  144.  
  145.     if ($reply) {
  146.     $sql = "SELECT msg_image, subject, from_userid, to_userid FROM ".$prefix."_priv_msgs WHERE msg_id = $msg_id";
  147.     $result = sql_query($sql, $dbi);
  148.     $row = sql_fetch_array($result, $dbi);
  149.     $fromuserdata = get_userdata_from_id($row[from_userid], $db);
  150.     $touserdata = get_userdata_from_id($row[to_userid], $db);
  151.     if ( is_user($user) && ($userdata[0] != $touserdata[uid]) ) {
  152.         forumerror(0024);
  153.     }
  154.     }
  155.     OpenTable();
  156.     echo "<FORM ACTION=\"modules.php?name=$module_name&file=reply\" METHOD=\"POST\" NAME=\"coolsus\">"
  157.         ."<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACEING=\"0\" ALIGN=\"CENTER\" VALIGN=\"TOP\" WIDTH=\"100%\"><TR><TD bgcolor=\"$bgcolor2\">"
  158.         ."<TABLE BORDER=\"0\" CALLPADDING=\"1\" CELLSPACEING=\"1\" WIDTH=\"100%\">"
  159.         ."<TR BGCOLOR=\"$bgcolor2\" ALIGN=\"LEFT\">"
  160.         ."<TD width=\"25%\"><FONT COLOR=\"$textcolor2\"><b>"._ABOUTPOSTING.":</b></FONT></TD>"
  161.         ."<TD><FONT COLOR=\"$textcolor2\">"._ALLREGCANPOST."</FONT></TD>"
  162.         ."</TR>"
  163.         ."<TR ALIGN=\"LEFT\">"
  164.         ."<TD BGCOLOR=\"$bgcolor3\" width=\"25%\"><b>"._TO.":<b></TD>";
  165.     if ($reply) {
  166.         echo "<TD BGCOLOR=\"$bgcolor1\"><INPUT TYPE=\"HIDDEN\" NAME=\"to_user\" VALUE=\"$fromuserdata[uname]\">$fromuserdata[uname]</TD>";
  167.     } else {
  168.         if ($uname) {
  169.         echo "<TD BGCOLOR=\"$bgcolor1\"><INPUT NAME=\"to_user\" SIZE=\"26\" maxlength=\"25\" value=\"$uname\">";
  170.     } else {
  171.         echo "<TD BGCOLOR=\"$bgcolor1\"><INPUT NAME=\"to_user\" SIZE=\"26\" maxlength=\"25\">";
  172.     }
  173.     echo "</td>";
  174.     }
  175.     echo "</TR>"
  176.         ."<TR ALIGN=\"LEFT\">"
  177.         ."<TD BGCOLOR=\"$bgcolor3\" width=\"25%\"><b>"._SUBJECT.":<b></TD>";
  178.     if ($reply) {
  179.         echo "<TD  BGCOLOR=\"$bgcolor1\"><INPUT TYPE=\"TEXT\" NAME=\"subject\" VALUE='"._RE.": $row[subject]' SIZE=\"50\" MAXLENGTH=\"100\"></TD>";
  180.     } else { 
  181.         echo "<TD  BGCOLOR=\"$bgcolor1\"><INPUT TYPE=\"TEXT\" NAME=\"subject\" SIZE=\"50\" MAXLENGTH=\"100\"></TD>";
  182.     }
  183.     echo "</TR>"
  184.         ."<TR ALIGN=\"LEFT\" VALIGN=\"TOP\">"
  185.         ."<TD  BGCOLOR=\"$bgcolor3\" width=\"25%\"><b>"._MESSAGEICON.":<b></TD>"
  186.         ."<TD  BGCOLOR=\"$bgcolor1\">";
  187.     $handle=opendir("images/forum/subject");
  188.     while ($file = readdir($handle)) {
  189.         $filelist[] = $file;
  190.     }
  191.     asort($filelist);
  192.     $a = 1;
  193.     while (list ($key, $file) = each ($filelist)) {
  194.     ereg(".gif|.jpg",$file);
  195.     if ($file == "." || $file == "..") {
  196.         $a=1;
  197.     } else {    
  198.         if ($file == $row[msg_image] && $row[msg_image] != "") {
  199.             echo "<INPUT TYPE='radio' NAME='image' VALUE='$file' checked><IMG SRC=images/forum/subject/$file BORDER=0> ";
  200.         } else {
  201.             if ($a == 1 && $row[msg_image] == "") {
  202.             $sel = "checked";
  203.         } else {
  204.             $sel = "";
  205.         }
  206.         echo "<INPUT TYPE='radio' NAME='image' VALUE='$file' $sel><IMG SRC=images/forum/subject/$file BORDER=0> ";
  207.         $a++;
  208.         }
  209.     }
  210.     if ($count >= 10) {
  211.         $count=1; echo "<br>";
  212.     }
  213.     $count++;
  214.     }
  215.     echo "</TD>"
  216.         ."</TR>"
  217.         ."<TR ALIGN=\"LEFT\" VALIGN=\"TOP\">"
  218.         ."<TD BGCOLOR=\"$bgcolor3\" width=\"25%\"><b>"._MESSAGE.":</b>";
  219.     if ($reply) {
  220.         $sql = "SELECT p.msg_text, p.msg_time, u.uname FROM ".$prefix."_priv_msgs p, ".$user_prefix."_users u ";
  221.         $sql .= "WHERE (p.msg_id = $msg_id) AND (p.from_userid = u.uid)";
  222.         if($result = sql_query($sql, $dbi)) {
  223.             $row = sql_fetch_array($result, $dbi);
  224.         $text = desmile($row[msg_text]);
  225.         $text = str_replace("<BR>", "\n", $text);
  226.         $text = stripslashes($text);
  227.         $text = bbdecode($text);
  228.         $reply = "[quote]\n"._PMON." $row[msg_time], $row[uname] "._WROTE.":\n$text\n[/quote]";
  229.     } else {
  230.         $reply = "Error Contacting database. Please try again.\n";
  231.     }
  232.     }                
  233.     echo "</font></TD>"
  234.         ."<TD BGCOLOR=\"$bgcolor1\"><TEXTAREA NAME=\"message\" ROWS=\"10\" COLS=\"45\" WRAP=\"VIRTUAL\">";
  235.     if ($reply) {
  236.         echo "$reply";
  237.     }
  238.     echo "</TEXTAREA><BR>";
  239.     putitems();
  240.     echo "</TD>"
  241.         ."</TR>"
  242.         ."<TR ALIGN=\"LEFT\">"
  243.         ."<TD BGCOLOR=\"$bgcolor3\" width=\"25%\"><b>"._OPTIONS.":</b></TD>"
  244.         ."<TD BGCOLOR=\"$bgcolor1\">"
  245.         ."<INPUT TYPE=\"CHECKBOX\" NAME=\"html\">"._HTMLDISSABLE."<br>"
  246.     ."<INPUT TYPE=\"CHECKBOX\" NAME=\"smile\">"._SMILEDISSABLE."<br>"
  247.     ."</TD>"
  248.         ."</TR>"
  249.         ."<TR>"
  250.         ."<TD BGCOLOR=\"$bgcolor1\" colspan=\"2\" ALIGN=\"CENTER\">"
  251.         ."<INPUT TYPE=\"HIDDEN\" NAME=\"msg_id\" VALUE=\"$msg_id\">"
  252.         ."<INPUT TYPE=\"SUBMIT\" NAME=\"submit\" VALUE=\""._SUBMIT."\"> <INPUT TYPE=\"RESET\" VALUE=\""._CLEAR."\">";
  253.     if (reply) {
  254.         echo " <INPUT TYPE=\"SUBMIT\" NAME=\"cancel\" VALUE=\""._CANCELREPLY."\">";
  255.     } else {
  256.         echo " <INPUT TYPE=\"SUBMIT\" NAME=\"cancel\" VALUE=\""._CANCELSEND."\">";
  257.     }
  258.     echo "</TD>"
  259.         ."</TR>"
  260.         ."</TABLE></TD></TR></TABLE>"
  261.         ."</FORM>";
  262.     }
  263.     CloseTable();
  264. }
  265.  
  266. include('footer.php');
  267.  
  268. ?>