<?
# Slashster: Open Source Friend of a Friend Software
# Copyright 2004 Mark El-Wakil
# Contact: hide@address.com
# http://seventhcycle.net
#
# This file is part of Slashster.
#
# Slashster is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Slashster is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Slashster; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import_request_variables("gPc");
require_once("PageClass.php");
$mpage = new PageClass("authonly");
$tmel = 24 * 3600 * 5;
if ($mpage->user[ModToday] < 1) GoHome();
$sql = "select *, UNIX_TIMESTAMP(DateSub) as UT from CommentTable where Id = \"$id\" ";
$r = $mpage->DoQuery($sql,1);
if (!sizeof($r)) GoHome();
$r = $r[0];
if ($r[UT] < (time() - $tmel)) GoHome();
if ($r[Rating]) GoHome();
$sql = "select * from CommentHead where Id = \"$r[Head]\" ";
$ch = $mpage->DoQuery($sql,1);
if (!sizeof($ch)) GoHome();
$ch = $ch[0];
if ($ch[FSubm] != $mpage->IdNum) GoHome();
$rt = (!$d) ? 1 : -1;
$ud = (!$d) ? "up" : "down";
$sql = "update CommentTable set Rating = Rating + '$rt' where Id = $r[Id]";
$mpage->DoQuery($sql);
if ($mpage->UserDistance($r[Submittee]) == 2)
{
$sql = "update UserTable set Karma = Karma + '$rt' where Id = \"$r[Submittee]\" ";
$mpage->DoQuery($sql);
}
$sql = "update UserTable set Karma = Karma + 0.2 where Id = \"$mpage->IdNum\" ";
$mpage->DoQuery($sql);
$sql = "update UserTable set ModToday = ModToday - 1 where Id = $mpage->IdNum";
$mpage->DoQuery($sql);
$msg = $mpage->PrintSnippit("Moderated-$ud", array("id" => $r[Id], "mod" => $md));
$mpage->MailSchedule($mpage->IdNum, $r[Submittee], "Post moderated $ud", $msg, 1,0);
GoHome($r[Id]);
function GoHome($g = "")
{
if (!$g)
{
$g = $_SERVER[HTTP_REFERER] . "?" . sid;
}
else
{
$g = "bbs.php?showcomment=$g&" . sid;
}
header("Location: " . $g);
exit;
}
?>