<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program 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.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
defined('MAXIMUS') or Header("Location: index.php");

if (!defined('USER_ALLOW') && $anonpost == 0) {
		incoh();
		title("$module_name");
		Max_OpenTable();
		echo "<center><b>"._RESTRICTEDAREA."</b><br /><br />"._MODULEUSERS."";
		Max_CloseTable();
		incof();
		die();
	}
	if ($xanonpost) {
		$uname = $anonymous;
	}
	$comments = stripslashes(FixQuotes(check_html($comments)));
	$id = $db->XMFnum($id);
	$score = $db->XMFnum($score);
	if (defined('USER_ALLOW')) {
		$krow = $db->sql_fetchrow($db->sql_query("SELECT karma FROM ".TABLE_USERS." WHERE username='$uname'"));
		if ($krow['karma'] == 2) {
			$db->sql_query("insert into ".TABLE_REVIEWS_COMMENTS."_moderated values (NULL, '$id', '$uname', now(), '$comments', '$score')");
			incoh();
			title(""._MODERATEDTITLE."");
			Max_OpenTable();
			echo "<center>"._COMMENTMODERATED."";
			br('2');
			echo "<a href=\"modules.php?name=$module_name&rop=showcontent&id=$id\">"._MODERATEDTITLE."</a>";
			Max_CloseTable();
			incof();
			die();
		} elseif ($krow['karma'] == 3) {
			redirect_url("modules.php?name=$module_name&rop=showcontent&id=$id");
			die();
		}
	}
	$db->sql_query("insert into ".TABLE_REVIEWS_COMMENTS." values (NULL, '$id', '$uname', now(), '$comments', '$score')");
	//update_points(12);
	redirect_url("modules.php?name=$module_name&rop=showcontent&id=$id");