<?php
/*
	DevSaver Web Framework
	Copyright (c) 2002-2018 DevSaver. 
	All rights reserved.
		web:  www.devsaver.com
		mail: support@devsaver.com
*/

if (!defined("STPBase")) {
	die("This file can't be accessed directly!");
}
// dependencies

/**
* description
*
* @library	
* @author	
* @since	
*/
class CAntiSpam extends CPlugin{
	
	var $tplvars; 

	function __constructor() {
		//$this->CPlugin($db, $tables , $templates);
		$this->name = "antispam";
	}

	function DoEvents(){
		global $base, $_CONF, $_TSM , $_VARS , $_USER , $_BASE , $_SESS;

		if ($_GET["mod"] == $this->name) {
			$this->tpl_module = $this->module->plugins["modules"]->LoadDefaultModule($this->name); 

			parent::DoEvents();

			$sub = $_GET["sub"];
			$action = $_GET["action"];


			switch ($sub) {

				case "captcha":
				case "akismet":
					$data = new CFormSettings($this->forms_path  . $sub . ".xml" ,$_CONF["forms"]["admintemplate"] , $this->db,$this->tables);
					$this->PrepareDashboard($data->form);

					$fields = CForm::KeyFields($data->form);

					if ($data->Done()) {

						$fields = CForm::KeyFields($data->form);

					
						$this->vars->SetVars(
							$this->vars->ExtractVals(
								$fields,
								$_POST
							)
						);
					}
					
					return $data->Show(							
						$this->vars->GetVars(
							$fields
						)					
					);

				break;

				case "landing":					
					$sub = "domains";
				case "domains":					
				case "burners":					
					$data = new CSQLAdmin($sub, $this->__parent_templates,$this->db,$this->tables,$extra);
					$data->setAclMod($this->tpl_module);
					$this->PrepareFields($data->forms["forms"], $sub);
					return $data->DoEvents();
				break;

				case "flush":
					return $this->FlushDomains();
				break;
			}
			
		}
	}


	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function FlushDomains() {
		//delete errors
		$this->db->Query("DELETE FROM  {$this->tables['core:antispam_banned_domains']} WHERE domain_burner=%d" , array($_GET["domain_burner"]));
		urlredirect($_GET["returnURL"]);
	}

	
}

?>