getCommentType($table);
if (isset($_POST['moderate'])) {
if (isset($_POST['comment_comment'])) {
$sql->db_Update("comments", "comment_comment='".$tp -> todb($_POST['comment_comment'])."' WHERE comment_id='$editid' ");
header("location: ".e_ADMIN."modcomment.php?{$table}.{$id}"); exit;
}
if (isset($_POST['comment_lock']) && $_POST['comment_lock'] == "1" && $_POST['comment_lock'] != $_POST['current_lock']) {
$sql->db_Update("comments", "comment_lock='1' WHERE comment_item_id='$id' ");
}
if ((!isset($_POST['comment_lock']) || $_POST['comment_lock'] == "0") && $_POST['comment_lock'] != $_POST['current_lock']) {
$sql->db_Update("comments", "comment_lock='0' WHERE comment_item_id='$id' ");
}
if (is_array($_POST['comment_blocked'])) {
while (list ($key, $cid) = each ($_POST['comment_blocked'])) {
$sql->db_Update("comments", "comment_blocked='1' WHERE comment_id='$cid' ");
}
}
if (is_array($_POST['comment_unblocked'])) {
while (list ($key, $cid) = each ($_POST['comment_unblocked'])) {
$sql->db_Update("comments", "comment_blocked='0' WHERE comment_id='$cid' ");
}
}
if (is_array($_POST['comment_delete'])) {
while (list ($key, $cid) = each ($_POST['comment_delete'])) {
if ($sql->db_Select("comments", "*", "comment_id='$cid' ")) {
$row = $sql->db_Fetch();
delete_children($row, $cid);
}
}
}
$e107cache->clear("comment");
$e107cache->clear("news");
$e107cache->clear($table);
$message = MDCLAN_1;
}
if (isset($message)) {
$ns->tablerender("", "
".$message."
");
}
$text = "
";
$ns->tablerender(MDCLAN_8, $text);
require_once("footer.php"); exit;
}
if (!$sql->db_Select("comments", "*", "(comment_type='".$type."' OR comment_type='".$table."') AND comment_item_id=$id")) {
$text .= "
";
} else {
$con = new convert;
$commentArray = $sql -> db_getList();
$total_comments = count($commentArray);
$comments = "";
foreach($commentArray as $row)
{
$comment_lock = $row['comment_lock'];
$total_blocked += $row['comment_blocked'];
$datestamp = $con->convert_date($row['comment_datestamp'], "short");
$comment_author_id = substr($row['comment_author'], 0, strpos($row['comment_author'], "."));
if ($comment_author_id) {
$sql->db_Select("user", "*", "user_id='$comment_author_id' ");
$rowu = $sql->db_Fetch();
$comment_nick = "".$rowu['user_name']."";
$comment_str = MDCLAN_3." #".$rowu['user_id'];
} else {
$comment_str = MDCLAN_4;
$comment_nick = preg_replace("#[0-9]+\.#", "", $row['comment_author']);
}
$row['comment_comment'] = $tp->toHTML($row['comment_comment'], TRUE, "");
$comments .= "
";
}
$text .= "
".MDCLAN_10." |
comments (".$total_comments." ".($total_comments == "1" ? MDCLAN_11 : MDCLAN_12).", ".$total_blocked." ".MDCLAN_13.") |
".$comments."
";
}
$text .= "";
$ns->tablerender(MDCLAN_8, $text);
require_once("footer.php");
function delete_children($row, $cid) {
global $sql, $sql2, $table;
$tmp = explode(".", $row['comment_author']);
$u_id = $tmp[0];
if ($u_id >= 1) {
$sql->db_Update("user", "user_comments=user_comments-1 WHERE user_id='$u_id'");
}
if($table == "news"){
$sql->db_Update("news", "news_comment_total=news_comment_total-1 WHERE news_id='".$row['comment_item_id']."'");
}
if ($sql2->db_Select("comments", "*", "comment_pid='".$row['comment_id']."'")) {
while ($row2 = $sql2->db_Fetch()) {
delete_children($row2, $row2['comment_id']);
}
}
$c_del[] = $cid;
while (list ($key, $cid) = each ($c_del)) {
$sql->db_Delete("comments", "comment_id='$cid'");
}
}
?>