home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / modules / forums / editpost.php < prev    next >
Encoding:
PHP Script  |  2002-09-16  |  13.9 KB  |  346 lines

  1. <?php
  2.  
  3. ######################################################################
  4. # Modulo Splatt Forum per PHP-NUKE 
  5. #-------------------------
  6. # Versione: 3.2
  7. #
  8. # Copyright (c) 2002 by:
  9. #
  10. # Giorgio Ciranni (~Splatt~)
  11. # (http://www.splatt.it)
  12. # (webmaster@splatt.it)
  13. #
  14. # Supporto tecnico disponibile sul Forum di www.splatt.it 
  15. ######################################################################
  16. # Splatt Forum is free software. You can redistribute it and/or modify
  17. # it under the terms of the GNU General Public License as published by
  18. # the Free Software Foundation; either version 2 of the License.
  19. # Splatt Forum is distributed in the hope that it will be useful,
  20. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22. # GNU General Public License for more details.
  23. #
  24. # You should have received a copy of the GNU General Public License
  25. # along with this program; if not, write to the Free Software
  26. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   
  27. # 02111-1307  USA
  28. ######################################################################
  29.  
  30. $module_name = "$name";
  31.  
  32. include("config.php");
  33. include("modules/".$module_name."/functions.php");
  34. include("modules/".$module_name."/auth.php");
  35.  
  36.  
  37. $sql = "SELECT forum_name, forum_access, forum_moderator, forum_atch FROM ${prefix}_forums WHERE forum_id = '$forum'";
  38. if(!$result = mysql_query($sql, $db))
  39.         die(""._ERRORE1.":<hr>"._FCOULDNOT.".");
  40. $myrow = mysql_fetch_array($result);
  41. $forum_name = $myrow[forum_name];
  42. $moderator = $myrow[forum_moderator];
  43. $moderators = get_moderators($forum, $db);
  44. $atch = $myrow[forum_atch];
  45.  
  46. include("modules/$module_name/attachment.php");
  47.  
  48. $use_forum_password_fix = 1;
  49.  
  50. if($submit1) {
  51.   //include('header.php');
  52.    $sql = "SELECT poster_id FROM ${prefix}_posts WHERE (post_id = $post_id)";
  53.  
  54.    $result = mysql_query($sql, $db);
  55.    if (!$result) {
  56.       die("<br>"._ERRORE1.":<ul>"._ERRQUERY.".</ul><P>");
  57.    }
  58.    $row = mysql_fetch_array($result);
  59.  
  60.    $posterdata = get_userdata_from_id($row[poster_id], $db);
  61.    $date = date("d-m-Y H:i");
  62.    if ($user) {
  63.  
  64.     $user3 = base64_decode($user);
  65.     $cookie = explode(":", $user3);
  66.             $userdata = $cookie;
  67.               $userdata = get_userdata($userdata[1], $db);
  68.  
  69.                 reset ($moderators);
  70.                 while(list($null, $mods) = each($moderators)) {
  71.                         while(list($mod_id, $mod_name) = each($mods)) {
  72.  
  73.                                 if ($userdata[uid] == $mod_id) {
  74.                                         $mod = $mod_id;
  75.                                         break 2;
  76.                                 }
  77.                         }
  78.                 }
  79.  
  80.       // valid session.. just check it's the right user.
  81. if ($userdata[uid] != $posterdata[uid] && $userdata[uid] != $mod && $userdata[user_level] != 3)
  82.            die("<br>"._FERRORE.":<ul>"._FNONTUO.".</ul><P>");
  83. /*
  84.       if (($posterdata[uid] != $userdata[uid] && $userdata[user_level] == 1)) {
  85.          $die = 1;
  86.       }
  87.       // else if($userdata[level] == 2 && $userdata[uid] != get_forum_mod($forum_id, $db)) {
  88.       else if($userdata[user_level] <= 2 && $userdata[uid] != $mod) {
  89.          die("<br>"._FERRORE.":<ul>"._FNONTUO.".</ul><P>");
  90.       }
  91.    } else {
  92.                die("<br>"._FERRORE.":<ul>"._NOPERMESS.".</ul><P>");
  93. */
  94.    }
  95.  
  96.    // IF we made it this far we are allowed to edit this message!
  97.  
  98. if($allow_html == 0)
  99.      $message = htmlspecialchars($message);
  100.    
  101.     $message = secure($message);
  102.        $Message = $message;
  103.        $message = check_words($Message);
  104.        $message = eregi_replace("-----------------", "", $message);
  105.        $message = str_replace("\n", "<BR>", $message);
  106.  
  107.            if ($user_sig)
  108.        $message = str_replace(nl2br($user_sig), "[addsig]", $message);
  109.  
  110.    if($allow_bbcode == 1 && !isset($bbcode))
  111.      $message = bbencode($message);
  112.  
  113.    if(!$smile)
  114.      $message = smile($message);
  115.  
  116.    //$message = str_replace("\n", "<BR>", $message);
  117.  
  118.    $message .= "<BR><BR>[ "._MODBY.": $userdata[uname] "._FIL." $date ]";
  119. //$message = strip_tags($message);
  120.    $message = addslashes($message);
  121.         if(!$delete) {
  122.                 $topic = $topic_id;
  123.                 $forum = $forum_id;
  124.                 $sql = "UPDATE ${prefix}_posts SET post_text = '$message', image='$image_subject' WHERE (post_id = '$post_id')";
  125.  
  126.                 ConfirmAttach($post_id);
  127.                 include('header.php');
  128.  
  129.                 if(!$result = mysql_query($sql, $db))
  130.                         die("<br>"._ERRORE1.":<ul>"._CHECKCONF.".</ul><br>");
  131.  
  132.  
  133.  
  134.                 echo "<center>"._PUPD."<br><a href=\"modules.php?op=modload&name=".$module_name."&file=viewtopic&topic=$topic_id&forum=$forum_id\">"._CLIKVUPD.".<br><a href=\"modules.php?op=modload&name=".$module_name."&file=viewforum&forum=$forum_id\">"._CLIKRETL.".</center><P></font>";
  135.         }
  136.         else {
  137.                 $sql = "DELETE FROM ${prefix}_posts WHERE post_id = '$post_id'";
  138.  
  139. delAllAtchFile($post_id);
  140.                 include('header.php');
  141.  
  142.                 if(!$r = mysql_query($sql))
  143.                         die("<br>"._ERRORE1.":<ul>"._CHECKCONF.".</ul><P>");
  144.                 if(get_total_posts($topic_id, $db, "topic") == 0) {
  145.                         $sql = "DELETE FROM ${prefix}_forumtopics WHERE topic_id = '$topic_id'";
  146.                         if(!$r = mysql_query($sql, $db))
  147.                                 die("<br>"._ERRORE1.":<ul>"._CHECKCONF.".</ul><P>");
  148.                 }
  149.                 echo "<center><b>"._POSTCANC."</b><br><br><a href=\"modules.php?op=modload&name=".$module_name."&file=viewforum&forum=$forum_id\">"._CLIKRETL.".<br><br><a href=\"modules.php?op=modload&name=".$module_name."&file=viewtopic&topic=$topic_id&forum=$forum_id\">Back to Topic.<br><br><a href=\"modules.php?op=modload&name=".$module_name."&file=index\">"._CLIKRET.".</center><P></font>";
  150.         }
  151. }
  152. else {
  153. if (!isset($AtchOp)){
  154.       resetAtchCookie();
  155.    }
  156.    include('header.php');
  157.    $sql = "SELECT p.*, u.uname, u.uid, u.user_sig FROM ${prefix}_posts p, ".$user_prefix."_users u WHERE (p.post_id = '$post_id') AND (p.poster_id = u.uid)";
  158.    if(!$result = mysql_query($sql, $db))
  159.      die("<br>"._ERRORE1.":<ul>"._CHECKCONF.".</ul><P>");
  160.    $myrow = mysql_fetch_array($result);
  161.    if (isset($user)) {
  162.                  # $cookie = base64_decode($user);
  163.                #$cookie = explode(":", $cookie);
  164.                $userdata = $cookie;    
  165.                $userdata = get_userdata($userdata[1], $db);
  166.  
  167.                 reset ($moderators);
  168.                 while(list($null, $mods) = each($moderators)) {
  169.                         while(list($mod_id, $mod_name) = each($mods)) {
  170.  
  171.                                 if ($userdata[uid] == $mod_id) {
  172.                                         $mod = $mod_id;
  173.                                         break 2;
  174.                                 }
  175.                         }
  176.                 }
  177.  
  178.  
  179.        if ($userdata[uid] != $myrow[uid] && $userdata[uid] != $mod && $userdata[user_level] != 3)
  180.            die("<br>"._FERRORE.":<ul>"._FNONTUO.".</ul><P>");
  181.    }
  182.  
  183.  
  184. if (!isset($message)){
  185.    $message = $myrow[post_text];
  186.    $message = eregi_replace("\[addsig]", "\n-----------------\n" .    $myrow[user_sig], $message);
  187.    $message = str_replace("<BR>", "\n", $message);
  188. $message = str_replace("<br>", "\n", $message);
  189.    $message = stripslashes($message);
  190.    $message = desmile($message);
  191.    $message = bbdecode($message);
  192.    $message = undo_htmlspecialchars($message);
  193. } else {
  194.    $message = stripslashes($message);
  195. }
  196.    list($day, $time) = split(" ", $myrow[post_time]);
  197. addForumScripts();
  198. ?>
  199. <FORM ACTION="modules.php?op=modload&name=<?php echo $module_name ?>&file=editpost" METHOD="POST" name="coolsus">
  200. <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" ALIGN="CENTER" VALIGN="TOP" WIDTH="100%"><TR><TD  BGCOLOR="<?php echo $table_bgcolor?>">
  201. <TABLE BORDER="0" CELLPADDING="3" CELLSPACING="1" WIDTH="100%">
  202. <TR BGCOLOR="<?php echo $bgcolor2?>" ALIGN="LEFT">
  203.         <TD ALIGN="CENTER" COLSPAN="2"><FONT COLOR="<?php echo $textcolor1; ?>"><B><?php echo _MODPOST;?></B></FONT></TD>
  204. </TR>
  205.  
  206. <?PHP
  207.         if (isset($user)) {
  208.                 if ($use_forum_password_fix == 1) {
  209.                         $password = $userdata[pass];
  210.                 } else {
  211.                         // if (!$system) $password = base64_decode($userdata[pass]);
  212.  
  213.  
  214.                         // KingRichard Fix
  215.                         if (!$system) $password = crypt($userdata[pass],substr($userdata[pass],0,2));
  216.                         else $password = $userdata[pass];
  217.                 }
  218.                 if ($password == $cookie[2]) {
  219.                 echo "<TR>";
  220.                 echo "<TD  BGCOLOR=$bgcolor3  width=25%><b>"._FNICK."<b></TD>";
  221.                 echo "<TD  BGCOLOR=$bgcolor1>";
  222.                 echo $userdata[uname] . " \n";
  223.                 echo "</TD></TR> \n";
  224.                 }
  225.                 else {
  226.                 die("<br>"._ERRORE1.":<ul>"._FERRPASS."</ul><P>");
  227.                 }
  228.         }
  229.         else {
  230.                 die("<br>"._ERRORE1.":<ul>"._NOPERMESS."</ul><P>");
  231.         }
  232.  
  233.  
  234. ?>
  235. <TR ALIGN="LEFT">
  236.                 <TD  BGCOLOR="<?php echo $bgcolor3?>" width=25% VALIGN="TOP"><b><?php echo _MESSICON;?></b></TD>
  237.                 <TD  BGCOLOR="<?php echo $bgcolor1?>">
  238.         <?php
  239.                 $handle=opendir("./images/forum/subject");
  240. if (!isset($topic)){
  241.                     $topic=$topic_id;
  242.                 }
  243.                 if (!isset($image_subject)){
  244.                      $image_subject = $myrow[image];
  245.                 }
  246.                 while ($file = readdir($handle))
  247.                         {
  248.                         $filelist[] = $file;
  249.                 }
  250.                 asort($filelist);
  251.                 while (list ($key, $file) = each ($filelist))
  252.                 {
  253.                 ereg(".gif|.jpg",$file);
  254.                 if ($file == "." || $file == ".." || $file == "index.html") $count=1;
  255.                 else {
  256.                         if ($file == $image_subject) echo "<input type=\"radio\" value=\"$file\" name=\"image_subject\" checked> ";
  257.                         else echo "<input type=\"radio\" value=\"$file\" name=\"image_subject\"> ";
  258.                         echo "<IMG SRC=\"images/forum/subject/$file\" BORDER=0> ";
  259.                         }
  260.                 if ($count == "9") { echo "<br>"; $count = 1; }
  261.                 $count++;
  262.                 }
  263.         ?>
  264.                  </TD>
  265.         </TR>
  266.         <TR ALIGN="LEFT" VALIGN="TOP">
  267.                 <TD  BGCOLOR="<?php echo $bgcolor3?>" width=25%><b><?php echo _FMESS;?>:</b><br><br>
  268.                 <font size=-1>
  269.                 <?php
  270.                 echo "HTML : ";
  271.                 if($allow_html == 1)
  272.                         echo "On<BR>\n";
  273.                 else
  274.                         echo "Off<BR>\n";
  275.                 echo "<a href=\"modules.php?op=modload&name=".$module_name."&file=bbcode_ref\" TARGET=\"blank\">BBCode</a> : ";
  276.                 if($allow_bbcode == 1)
  277.                         echo "On<br>\n";
  278.                 else
  279.                         echo "Off<BR>\n";
  280.                 ?>
  281.                 </font></TD>
  282.                 <TD  BGCOLOR="<?php echo $bgcolor1?>"><TEXTAREA CLASS=textbox NAME="message" ROWS=10 COLS=75 WRAP="VIRTUAL"><?php echo $message ?></TEXTAREA><br>
  283.  
  284. <?php
  285.     if ($atch == 1){
  286.                 // JoyDivision Start
  287.                 echo ShowAttach($myrow[post_id],true,"coolsus");
  288.                 echo "<br>".getAttachCode($myrow[post_id])."<br>";
  289.                 // JoyDivision End
  290. }
  291. ?>              <br>
  292.  
  293. <?php
  294.  putitems();
  295. ?>
  296.  
  297. </TD>
  298.         </TR>
  299.         <TR ALIGN="LEFT">
  300.                 <TD  BGCOLOR="<?php echo $bgcolor3?>" width=25%><b><?php echo _FOPT;?></b></TD>
  301.                 <TD  BGCOLOR="<?php echo $bgcolor1?>" >
  302.                 <?php
  303.                         $now_hour = date("H");
  304.                         $now_min = date("i");
  305.                         list($hour, $min) = split(":", $time);
  306.                        // if(($now_hour == $hour && $min_now - 30 < $min) || ($now_hour == $hour +1 && $now_min - 30 > 0) ) {
  307.                 ?>
  308.                                 <INPUT TYPE="CHECKBOX" NAME="delete"><?php echo _FDELP;?><BR>
  309.                 <?php
  310.                      //   }
  311.                 
  312.                         if($allow_html == 1) {
  313.                 ?>
  314.                                 <INPUT TYPE="CHECKBOX" NAME="html"><?php echo _DISHTML;?><BR>
  315.                 <?php
  316.                         }
  317.                 
  318.                         if($allow_bbcode == 1) {
  319.                 ?>
  320.                                 <INPUT TYPE="CHECKBOX" NAME="bbcode"><?php echo ""._FDIS." <a href=\"modules.php?op=modload&name=".$module_name."&file=bbcode_ref\" target=\"_blank\"><i>BBCode</i></a>".$module_name." "._FTHISMAIL."";?><BR>
  321.                 <?php
  322.                         }
  323.                 ?>
  324.  
  325.                 <INPUT TYPE="CHECKBOX" NAME="smile"><?php echo ""._FDIS." <a href=\"modules.php?op=modload&name=".$module_name."&file=bb_smilies\" target=\"_blank\"><i>Smilies</i></a> "._FTHISMAIL."";?><BR>
  326.                 </TD>
  327.         </TR>
  328. <TR>
  329.         <TD  BGCOLOR="<?php echo $bgcolor1?>" colspan=2 ALIGN="CENTER">
  330.         <INPUT TYPE="HIDDEN" NAME="post_id" VALUE="<?php echo $post_id?>">
  331.         <INPUT TYPE="HIDDEN" NAME="forum_id" VALUE="<?php echo $forum?>">
  332.         <INPUT TYPE="HIDDEN" NAME="forum" VALUE="<?php echo $forum?>">
  333.         <INPUT TYPE="HIDDEN" NAME="topic_id" VALUE="<?php echo $topic?>">
  334.         
  335.         <INPUT TYPE="SUBMIT" NAME="submit1" VALUE="<?php echo _INVIA;?>"> <INPUT TYPE="RESET" VALUE="<?php echo""._RESETTA."" ?>" NAME="clear">
  336. </TR>
  337. </TABLE></TD></TR></TABLE>
  338. </FORM>
  339. <!-- Don't touch the lines below please! --> 
  340.  
  341. <?php
  342. echo"<p align=\"center\">Splatt Forum © By: <a href=\"http://www.splatt.it\" target=\"_blank\">Splatt.it</a><br>Version: $forumver</font></p><br><br>";
  343. }
  344. include('footer.php');
  345. ?>