This repository has been archived on 2023-09-19. You can view files and clone it, but cannot push or open issues or pull requests.
AcmlmboardZero/editthread.php

170 lines
5.7 KiB
PHP

<?php
require("function.php");
require("layout.php");
//GET doesn't carry over through POST, so I do it this way
$fid = $_GET['id'];
if(!$_GET[id]) $fid=$_POST[fid];
//Get the data
$threads=mysqli_fetch_array(mysqli_query($con,"SELECT * FROM threads WHERE id = $fid"));
$forums=mysqli_fetch_array(mysqli_query($con,"SELECT * FROM forums WHERE id = $threads[forum]"));
$users=mysqli_fetch_array(mysqli_query($con,"SELECT * FROM users WHERE id = $loguserid"));
$smilies=readsmilies();
$posticons=file("posticons.dat");
//Gotta be logged in
if (!$loguserid) {
print "$header<br><table border=0 bgcolor=$tableborder width=$tablewidth align=center cellpadding=0 cellspacing=0>
<td>
<table border=0 cellpadding=2 cellspacing=1 width=100% bgcolor=$tableborder>
$tccell1 You are not logged it!</table></td></table>$footer";
die('');
}
//Do we have permission to edit?
//Until permissions are finished, checks is user is a "debug" user
if (!$users[debug]) {
print "$header<br><table border=0 bgcolor=$tableborder width=$tablewidth align=center cellpadding=0 cellspacing=0>
<td>
<table border=0 cellpadding=2 cellspacing=1 width=100% bgcolor=$tableborder>
$tccell1 You do not have permission to edit this thread!</table></td></table>$footer";
die('');
}
$tccellha="<td bgcolor=$tableheadbg";
$tccellhb="><center>$fonthead";
print $header;
if ($_POST[action]=="") {
print "$fonttag<a href=index.php>$boardname</a> - <a href=forum.php?id=$forums[id]>".$forums[title]."</a>
<table border=0 bgcolor=$tableborder width=$tablewidth align=center cellpadding=0 cellspacing=0>
<td>
<table border=0 cellpadding=2 cellspacing=1 width=100% bgcolor=$tableborder>
<FORM ACTION=\"editthread.php\" NAME=\"REPLIER\" METHOD=\"POST\">
";
$posticonlist="";
$i=0;
while ($posticons[$i]!="") {
$checked="";
$ico=strip_tags($threads[icon]);
$ico2=strip_tags($posticons[$i]);
if (strcmp("$ico","$ico2")==-2) {
$checked="checked=1";
}
$posticonlist.="<INPUT type=radio name=\"iconid\" value=$posticons[$i] $checked>&nbsp;<IMG SRC=$posticons[$i] HEIGHT=15 WIDTH=15>&nbsp;&nbsp;&nbsp";
$i++;
if (round($i/10)==($i/10)) {
$posticonlist.="<br>";
}
}
$checked="";
if ($threads[icon]=="") {
$checked="checked=1";
}
$posticonlist.="<br><INPUT type=radio name=\"iconid\" value=\"\" $checked>&nbsp;None";
$checked1="";
$checked2="";
if ($threads[closed]==0) {
$checked1="checked=1";
} else {
$checked2="checked=1";
}
/*
$forummovelist="<select name=\"forummove\">";
$f=0;
while ($forums[$f][0]!="") {
$checked="";
if ($threads[$id][0]==$f) {
$checked="selected";
}
$forummovelist.="<option value=$f $checked>".$forums[$f][0]."</option>";
$f++;
}
*/
$forummovelist.="</select>";
$replytable="$tccellha width=150$tccellhb"."&nbsp;</font></td>";
$replytable.="$tccellh"."&nbsp;</td><tr>";
$replytable.="$tccell1"."<b>Thread title:</td>";
$replytable.="$tccell2"."</center><INPUT TYPE=TEXT NAME=\"subject\" VALUE=\"".$threads[title]."\" SIZE=40 MAXLENGTH=40></td><tr>";
$replytable.="$tccell1"."<b>Thread icon:</td>";
$replytable.="$tccell2"."</center>$posticonlist</td><tr>";
$replytable.="$tccell1"."&nbsp;</td>";
$replytable.="$tccell2"."</center><INPUT type=radio name=\"closed\" value=0 $checked1> Open&nbsp;&nbsp;&nbsp;<INPUT type=radio name=\"closed\" value=1 $checked2> Closed</td><tr>";
$replytable.="$tccell1"."<b>Forum</b></td>";
$replytable.="$tccell2"."</center><select name=movethread>";
$forumslist=mysqli_query($con,"SELECT * FROM forums ORDER BY catid");
while($forumlist=mysqli_fetch_array($forumslist)) {
if ($forums[id]==$forumlist[id]) {
$selected="selected=0";
}
else {
$selected="";
}
$replytable.="<option $selected value=\"$forumlist[id]\" >$forumlist[title]</option>";
}
$replytable.="</select></td><tr>";
$replytable.="$tccell1"."&nbsp;</td>";
$replytable.="$tccell2"."</center>
<INPUT TYPE=HIDDEN NAME=\"action\" VALUE=\"editthread\">
<INPUT TYPE=HIDDEN NAME=\"fid\" VALUE=\"$fid\">
<INPUT TYPE=Submit NAME=\"submit\" VALUE=\"Edit thread\"></td></FORM>";
print "$replytable
</td>
</table>
<table border=0 cellpadding=2 cellspacing=1 width=100% bgcolor=$tableborder>
";
print "
</table>
</td>
</table>
$fonttag<a href=index.php>$boardname</a> - <a href=forum.php?id=$forums[id]>".$forums[title]."</a>
";
}
if ($_POST[action]=="editthread") {
print "
<table border=0 bgcolor=$tableborder width=$tablewidth align=center cellpadding=0 cellspacing=0>
<td>
<table border=0 cellpadding=2 cellspacing=1 width=100% bgcolor=$tableborder>
";
if (0==0) {
$date=time();
$subject1=mysqli_real_escape_string($con,$_POST[subject]);
mysqli_query($con,"UPDATE threads SET title = '$subject1', icon = '$_POST[iconid]', closed = '$_POST[closed]', forum = '$_POST[movethread]' WHERE id = $_POST[fid]");
print "$tccell1"."Thank you, ".$users[name].", for editing the thread.
Click <a href=thread.php?id=$_POST[fid]>here</a> to return to the thread.
</table></td></table>
";
// if ($delete==1) {
// $forummove=-1;
// }
// $threads[$id][0]=$forummove;
// $threads[$id][3]=$closed;
// $threads[$id][4]=$subject;
// $threads[$id][5]=$posticons[$iconid];
} else {
print "$tccell1"."Couldn't edit the post. Either you didn't enter an existing username, ";
print "or you haven't entered the right password for the username, or you are not allowed to edit this post.";
print "<br>Click <a href=thread.php?id=$id>here</a> to return to the thread.";
}
}
print $footer;
?>