Пример #1
0
 function removeComment($tid, $sid, $ok = 0)
 {
     global $ultramode, $prefix, $db, $admin_file;
     if ($ok) {
         $tid = intval($tid);
         $result = $db->sql_query("SELECT date from " . $prefix . "_comments where pid='{$tid}'");
         $numresults = $db->sql_numrows($result);
         $sid = intval($sid);
         $db->sql_query("update " . $prefix . "_stories set comments=comments-1-'{$numresults}' where sid='{$sid}'");
         /* Call recursive delete function to delete the comment and all its childs */
         removeSubComments($tid);
         if ($ultramode) {
             ultramode();
         }
         Header("Location: modules.php?name=News&file=article&sid={$sid}");
     } else {
         include "header.php";
         GraphicAdmin();
         OpenTable();
         echo "<center><font class=\"title\"><b>" . _REMOVECOMMENTS . "</b></font></center>";
         CloseTable();
         echo "<br>";
         OpenTable();
         echo "<center>" . _SURETODELCOMMENTS . "";
         echo "<br><br>[ <a href=\"javascript:history.go(-1)\">" . _NO . "</a> | <a href=\"" . $admin_file . ".php?op=RemoveComment&tid={$tid}&sid={$sid}&ok=1\">" . _YES . "</a> ]</center>";
         CloseTable();
         include "footer.php";
     }
 }
Пример #2
0
function removeSubComments($tid, $table)
{
    global $prefix, $db;
    $result = $db->sql_query("SELECT tid FROM " . $prefix . "_{$table} WHERE pid='{$tid}'");
    $numrows = $db->sql_numrows($result);
    if ($numrows > 0) {
        while (list($ctid) = $db->sql_fetchrow($result)) {
            $numrows += removeSubComments($ctid, $table);
        }
        $db->sql_query("DELETE FROM " . $prefix . "_{$table} WHERE pid='{$tid}'");
    }
    $db->sql_freeresult($result);
    return $numrows;
}