priority = 8; $rules[] = $rule; return $rules; } } class MailinglistHandler extends ActionHandler { public function __construct() { DB::register_table('mailinglist'); } private function add_to_list() { $lists = DB::get_column('SELECT DISTINCT list FROM ' . DB::table('mailinglist')); $list = $this->handler_vars['listname']; $email = $this->handler_vars['email']; if(in_array($list, $lists)) { return DB::query('INSERT INTO ' . DB::table('mailinglist') . ' (list, email) VALUES (?,?)', array($list, $email)); } return false; } public function act_ml_add() { $msg = $this->add_to_list() ? 'listok' : 'listerr'; Utils::redirect(URL::get('index_page', array('msg'=>$msg))); } public function act_ml_add_ajax( ) { $msg = $this->add_to_list() ? 'Your email has been added to the list. Thank you!' : 'There was a problem adding your email to the list. Please try again later.'; echo $msg; exit; } public function act_ml_install() { if(User::identify()) { error_reporting(E_ALL); //$drop = DB::query("DROP TABLE ". DB::table('mailinglist') .""); $install = DB::query("CREATE TABLE ". DB::table('mailinglist') ." ( `list` varchar(255) NOT NULL default '', `email` varchar(255) NOT NULL default '', `added` timestamp NOT NULL default CURRENT_TIMESTAMP )"); Utils::debug($install); exit; } die('You do not have access for this.'); } public function act_ml_create() { if(User::identify()) { Utils::debug(DB::query('INSERT INTO ' . DB::table('mailinglist') . ' (list) VALUES (?)', array($this->handler_vars['listname']))); exit; } Utils::redirect(URL::get('index_page', 'msg=error')); } } ?>