<?
include "../../conf.php";
include "../../style.php";
include "../../functions.php";
//
// Hinzufügen von Einträgen
//
print "<html>\n";
print_stylesheet("../../style.php");
print_body($bgcolor,"../../style.php");
print "<div align=center>\n";
$setdate = strftime("%d.%m.%y",time());
$settime = strftime("%H:%M:%S",time());
$ip = getenv("REMOTE_ADDR");
$host = $ip;
if (ereg("Edit", $todo))
{
$id = strtok($todo," ");
$id = strtok(" ");
$id = strtok(" ");
print "<h3>Header-Eintrag (ID: $id) aus \"$table2\" editieren.</h3><br><hr>\n";
if (!mysql_connect ($dbhost, $username, $password))
error_header("ERROR",1);
if (!mysql_select_db ($database))
error_header("Datenbank existiert nicht.",1);
if (!$result = mysql_query("SELECT * from $table2 WHERE id=$id"))
admin_error2("Tabelle existiert nicht",1);
while ($data = mysql_fetch_array ($result))
{
print "<p><br>\n";
print "<TABLE width=80% border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=$general >\n";
print "<form name=newpost action=editmainthread.php method=post>\n";
print "<tr><td colspan=2 height=30 align=center> Mainthread:</td>\n";
print "<tr><td colspan=2 height=100 align=center><textarea cols=80 rows=4 name=mainthread wrap=physical>$data[6]</textarea></td></tr>\n";
print "<tr><td align=center><br><input type=submit name=arg value=preview></td><td align=center><input type=reset name=Reset></tr></td>\n";
print "</table>\n\n";
print "<input type=hidden name=table2 value=$table2>\n";
print "<input type=hidden name=todo value=preview>\n";
print "<input type=hidden name=id value=$id>\n";
print "<input type=hidden name=date value=$data[1]>\n";
print "<input type=hidden name=time value=$data[2]>\n";
print "<input type=hidden name=ip value=$data[7]>\n";
print "<input type=hidden name=table2 value=$table2>\n";
print "<input type=hidden name=access value=$access>\n";
print "<input type=hidden name=passwort value=$passwort>\n";
print "</form>\n\n";
}
mysql_free_result($result);
mysql_close ();
}
elseif ($todo=="preview")
{
if (empty($mainthread)) {
print "<h2>Bitte ergänzen Sie den Header-Namen!</h2>\n";
}
else
{
print "<h3>Mainthread aus \"$table2\" editieren.</h3><br><hr>\n";
print "<h3><u>Preview</u></h3>\n";
print "<p>\n";
print "<table width=90% border=0 cellpadding=2 cellspacing=2 bgcolor=$threadback>\n";
print "<tr>\n";
print "<td align=left>\n";
print "<tr>\n";
print "<td width=50><b><font color=$general>  </font></b></td>\n";
print "<td ><b><font color=$general>Forum</font></b></td>\n";
print "<td width=60><b><font color=$general>Themen</font></b></td>\n";
print "<td width=60><b><font color=$general>Beiträge</font></b></td>\n";
print "<td width=60><b><font color=$general>Letzter Beitrag</font></b></td>\n";
print "</tr>\n";
if (!mysql_connect ($dbhost, $username, $password))
error_header("ERROR",1);
if (!mysql_select_db ($database))
error_header("Datenbank existiert nicht.",1);
if (!$result = mysql_query("SELECT * from $table2 WHERE id=$id"))
admin_error2("Tabelle existiert nicht",1);
while ($data = mysql_fetch_array ($result))
{
if (!$result2 = mysql_query("SELECT * from $table2 WHERE id=$data[9]"))
admin_error2("Tabelle existiert nicht",1);
while ($data2 = mysql_fetch_array($result2))
view_mainthreads("", $data2[3], $data2[6], $data2[1], $data2[2], "../../style.php", "../../pics", "../../smilies");
}
// view_mainthreads($new, $name, $msg, $date, $time, $stylepath="../style.php", $picspath="../pics", $directory="../smilies", $admin="0",$id="", $selected="0", $delete="0", $edit="0", $insert="0")
view_mainthreads("", "", $mainthread, "", "", "../../style.php", "../../pics", "../../smilies",0,$id,0,0,0,1);
print "</tr></table>\n";
print "<form action=editmainthread.php method=post name=postitnow>\n";
print "<input type=hidden name=mainthread value=\"$mainthread\">\n";
print "<input type=hidden name=access value=$access>\n";
print "<input type=hidden name=passwort value=$passwort>\n";
print "<p>\n";
print "<h3>Eintrag so übernehmen ? (ID: $id) </h3>\n";
print "<form action=edit.php method=post name=postitnow>\n";
print "<input type=hidden name=id value=\"$id\">\n";
print "<input type=hidden name=table2 value=\"$table2\">\n";
print "<input type=hidden name=access value=$access>\n";
print "<input type=hidden name=passwort value=$passwort>\n";
print "<input type=hidden name=todo value=write>\n";
print "<input type=submit value=JA>\n";
print "</form>\n";
}
}
elseif ($todo=="write")
{
print "<h3>Table: $table2 - Id: $id</h3>\n";
if (!$connect = mysql_connect ($dbhost, $username, $password))
error_header("ERROR",1);
if (!mysql_select_db ($database))
error_header("Datenbank existiert nicht.",1);
$query="UPDATE $table2 set msg=\"$mainthread\" WHERE id=$id";
if (!$result = mysql_query($query))
admin_error2("Tabelle existiert nicht",1);
if ($result == "1")
print "<h3>Eintrag wurde erfolgreich geändert!</h3><br>\n";
else
print "<h3>Eintrag existiert nicht!</h3><br>\n";
mysql_close ($connect);
}
else
{
print "<h3>Mainthread in \"$table2\" editieren.</h3><br><hr>\n";
print "<form name=newpost action=editmainthread.php method=post>\n";
print "<input type=hidden name=table2 value=$table2>\n";
if (!$connect = mysql_connect ($dbhost, $username, $password))
admin_error2("ERROR",1);
if (!mysql_select_db ($database))
admin_error2("Datenbank existiert nicht",1);
if (!$result = mysql_query("SELECT * from $table2 WHERE system='forum' AND toid='0' ORDER BY 'name' ASC"))
admin_error2("Tabelle existiert nicht !",1);
$postcount = mysql_num_rows($result);
if ($postcount)
{
print "<table width=90% border=0 cellpadding=2 cellspacing=2 bgcolor=$threadback>\n";
print "<tr>\n";
print "<td width=50><b><font color=$general>  </font></b></td>\n";
print "<td width=70%><b><font color=$general>Forum</font></b></td>\n";
print "<td width=60><b><font color=$general>Themen</font></b></td>\n";
print "<td width=60><b><font color=$general>Beiträge</font></b></td>\n";
print "<td width=60><b><font color=$general>Letzter Beitrag</font></b></td>\n";
print "</tr>\n";
}
while ($data = mysql_fetch_array($result))
{
if (!$result2 = mysql_query("SELECT * from $table2 WHERE system='forum' AND toid='$data[0]' ORDER BY 'id' ASC"))
admin_error2("Tabelle existiert nicht",1);
$postcount2 = mysql_num_rows($result2);
// view_mainthreads($new, $name, $msg, $date, $time, $stylepath="../style.php", $picspath="../pics", $directory="../smilies", $admin="0",$id="", $selected="0", $delete="0", $edit="0", $insert="0")
view_mainthreads(0, $data[3], $data[6], $data[1], $data[2],"../../style.php", "../../pics", "../../smilies",0,$data[0],0,0,0,0);
$count=1;
if ($postcount2)
{
while ($data2 = mysql_fetch_array($result2))
{
$countposts = count_threads_post($data2[0]);
if (($count%2)==0)
$threadcolor=$threadtwo;
else
$threadcolor=$threadone;
view_mainthreads(0, $data2[3], $data2[6], $data2[1], $data2[2],"../../style.php", "../../pics", "../../smilies",1,$data2[0],0,0,1,0);
$count++;
}
}
}
if ($postcount)
{
print "</td>\n";
print "</tr>\n";
print "</table>\n";
}
if (! $postcount)
error_header("Keine Header vorhanden.",1);
mysql_close();
print "</form>\n";
}
print "</div>\n";
print "</body>\n";
print "</html>\n";
?>