This file is part of poMMo (http://www.pommo.org)
poMMo 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, or any later version.
poMMo 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 program; see the file docs/LICENSE. If not, write to the
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
$notices = unserialize($config['notices']); if (Pommo_Pending::perform($pending)) { require_once Pommo::$_baseDir . 'classes/Pommo_Helper_Messages.php'; // get subscriber info require_once Pommo::$_baseDir . 'classes/Pommo_Subscribers.php'; $subscriber = current(Pommo_Subscribers::get(array('id' => $pending['subscriber_id']))); switch ($pending['type']) { case "add": // send/print welcome message Pommo_Helper_Messages::sendMessage(array('to' => $subscriber['email'], 'type' => 'subscribe')); if (isset($notices['subscribe']) && $notices['subscribe'] == 'on') { Pommo_Helper_Messages::notify($notices, $subscriber, 'subscribe'); } if (!empty($config['site_success'])) { Pommo::redirect($config['site_success']); } break; case "change": if (isset($notices['update']) && $notices['update'] == 'on') { Pommo_Helper_Messages::notify($notices, $subscriber, 'update'); } $logger->addMsg(Pommo::_T('Your records have been updated.')); break; case "password": break; default: $logger->addMsg('Unknown Pending Type.'); break; } } $view->display('user/confirm');
if (!SmartyValidate::is_registered_form('exchanger') || empty($_POST)) { // ___ USER HAS NOT SENT FORM ___ SmartyValidate::register_form('exchanger', true); SmartyValidate::register_validator('email', 'email', 'isEmail', false, false, false, 'exchanger'); $vMsg = array(); $vMsg['email'] = Pommo::_T('Invalid email address'); $smarty->assign('vMsg', $vMsg); $dbvals = array('exchanger' => $exchanger, 'email' => Pommo::$_config['admin_email']); $smarty->assign($dbvals); } else { // ___ USER HAS SENT FORM ___ /********************************** JSON OUTPUT INITIALIZATION *********************************/ require_once Pommo::$_baseDir . 'classes/Pommo_Json.php'; $json = new Pommo_Json(); if (SmartyValidate::is_valid($_POST, 'exchanger')) { // __ FORM IS VALID require_once Pommo::$_baseDir . 'classes/Pommo_Helper_Messages.php'; $msg = Pommo_Helper_Messages::testExchanger($_POST['email'], $exchanger) ? Pommo::_T('Mail Sent.') : Pommo::_T('Error Sending Mail'); $json->success($msg); } else { // __ FORM NOT VALID $json->addMsg(Pommo::_T('Please review and correct errors with your submission.')); $json->add('fieldErrors', $smarty->getInvalidFields('exchanger')); $json->fail(); } } $smarty->assign($_POST); $smarty->display('admin/setup/config/ajax.testexchanger.tpl'); Pommo::kill();
$msg = Pommo::_T('subscription request'); $pending['type'] = 'confirm'; // normalize for Pommo_Helper_Messages::sendMessage break; case "change": $msg = Pommo::_T('record update request'); $pending['type'] = 'update'; // normalize for Pommo_Helper_Messages::sendMessage break; case "password": $msg = Pommo::_T('password change request'); break; default: Pommo::redirect('login.php?badPendingType=TRUE'); } // check if user wants to reconfirm or cancel their request if (!empty($_POST)) { if (isset($_POST['reconfirm'])) { require_once Pommo::$_baseDir . 'classes/Pommo_Helper_Messages.php'; Pommo_Helper_Messages::sendMessage(array('to' => $input['Email'], 'code' => $pending['code'], 'type' => $pending['type'])); } elseif (isset($_POST['cancel'])) { if (Pommo_Pending::cancel($pending)) { $logger->addMsg(sprintf(Pommo::_T('Your %s has been cancelled.'), $msg)); } } $smarty->assign('nodisplay', TRUE); } else { $logger->addMsg(sprintf(Pommo::_T('Your %s is still pending. To complete this request, please review the confirmation email sent to %s.'), $msg, $input['Email'])); } $smarty->display('user/pending.tpl'); Pommo::kill();
Pommo_Helper_Messages::notify($notices, $subscriber, 'pending', $comments); } if ($config['site_confirm']) { Pommo::redirect($config['site_confirm']); } } else { $smarty->assign('back', TRUE); // delete the subscriber Pommo_Subscribers::delete($id); } } } else { // no email confirmation required if (!Pommo_Subscribers::add($subscriber)) { $logger->addErr('Error adding subscriber! Please contact the administrator.'); $smarty->assign('back', TRUE); } else { // send/print welcome message Pommo_Helper_Messages::sendMessage(array('to' => $subscriber['email'], 'type' => 'subscribe')); $subscriber['registered'] = date("F j, Y, g:i a", $subscriber['registered']); if ($comments || isset($notices['subscribe']) && $notices['subscribe'] == 'on') { Pommo_Helper_Messages::notify($notices, $subscriber, 'subscribe', $comments); } // redirect if ($config['site_success']) { Pommo::redirect($config['site_success']); } } } $smarty->display('user/process.tpl'); Pommo::kill();
SmartyValidate::register_validator('update_msg', 'update_msg:!\\[\\[URL\\]\\]!i', 'isRegExp', false, false, 'trim', 'messages'); SmartyValidate::register_validator('notify_email', 'notify_email', 'isMails', false, false, false, 'messages'); SmartyValidate::register_validator('notify_subscribe', 'notify_subscribe:!^(on|off)$!', 'isRegExp', false, false, false, 'messages'); SmartyValidate::register_validator('notify_unsubscribe', 'notify_unsubscribe:!^(on|off)$!', 'isRegExp', false, false, false, 'messages'); SmartyValidate::register_validator('notify_update', 'notify_update:!^(on|off)$!', 'isRegExp', false, false, false, 'messages'); SmartyValidate::register_validator('notify_pending', 'notify_pending:!^(on|off)$!', 'isRegExp', false, false, false, 'messages'); $vMsg = array(); $vMsg['subscribe_sub'] = $vMsg['subscribe_msg'] = $vMsg['subscribe_web'] = $vMsg['unsubscribe_sub'] = $vMsg['unsubscribe_msg'] = $vMsg['unsubscribe_web'] = $vMsg['confirm_sub'] = $vMsg['update_sub'] = $vMsg['activate_sub'] = Pommo::_T('Cannot be empty.'); $vMsg['confirm_msg'] = $vMsg['update_msg'] = $vMsg['activate_msg'] = Pommo::_T('You must include "[[URL]]" for the confirm link'); $smarty->assign('vMsg', $vMsg); // populate _POST with info from database (fills in form values...) $dbvalues = Pommo_Api::configGet(array('messages', 'notices')); $notices = unserialize($dbvalues['notices']); $messages = unserialize($dbvalues['messages']); if (empty($messages)) { $messages = Pommo_Helper_Messages::resetDefault('all'); } if (empty($notices)) { $notices = array('email' => Pommo::$_config['admin_email'], 'subject' => Pommo::_T('[poMMo Notice]'), 'subscribe' => 'off', 'unsubscribe' => 'off', 'update' => 'off', 'pending' => 'off'); } $p = array(); $p['notify_email'] = $notices['email']; $p['notify_subject'] = $notices['subject']; $p['notify_subscribe'] = $notices['subscribe']; $p['notify_unsubscribe'] = $notices['unsubscribe']; $p['notify_update'] = $notices['update']; $p['notify_pending'] = $notices['pending']; $p['subscribe_sub'] = $messages['subscribe']['sub']; $p['subscribe_msg'] = $messages['subscribe']['msg']; $p['subscribe_web'] = $messages['subscribe']['web']; $p['subscribe_email'] = $messages['subscribe']['email'];
$captcha = substr(md5(rand()), 0, 4); $view->assign('captcha', $captcha); } elseif ($_POST['captcha'] == $_POST['realdeal']) { // user inputted captcha matched. Reset password require_once Pommo::$_baseDir . 'classes/Pommo_Pending.php'; require_once Pommo::$_baseDir . 'classes/Pommo_Helper_Messages.php'; // see if there is already a pending request for the administrator // [subscriber id == 0] if (Pommo_Pending::isPending(0)) { $input = urlencode(serialize(array('adminID' => TRUE, 'Email' => Pommo::$_config['admin_email']))); Pommo::redirect(Pommo::$_http . Pommo::$_baseUrl . 'pending.php?input=' . $input); } // create a password change request, send confirmation mail $subscriber = array('id' => 0); $code = Pommo_Pending::add($subscriber, 'password'); Pommo_Helper_Messages::sendMessage(array('to' => Pommo::$_config['admin_email'], 'code' => $code, 'type' => 'password')); $view->assign('captcha', FALSE); } else { // captcha did not match $logger->addMsg(Pommo::_T('Captcha did not match. Try again.')); } } elseif (!Pommo::$_hasConfigFile && $_POST['configure']) { // Try to connect to database with data entered from the user. // I am not using /inc/classes/db.php because it kills the proccess when // connection is not possible // TODO: db.php shouldnt kill the process $link = @mysql_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass']); if (!$link) { // Could not connect $configErrors[] = 'Could not connect to host. Check your settings and try again.';
*********************************/ require_once Pommo::$_baseDir . 'classes/Pommo_Template.php'; $smarty = new Pommo_Template(); // make sure email/login is valid $subscriber = current(Pommo_Subscribers::get(array('email' => empty($_REQUEST['email']) ? '0' : $_REQUEST['email'], 'status' => 1))); if (empty($subscriber)) { Pommo::redirect('login.php'); } // see if an anctivation email was sent to this subscriber in the last 2 minutes; $query = "\n\tSELECT \n\t\t*\n\tFROM \n\t\t" . $dbo->table['scratch'] . "\n\tWHERE\n\t\t`type`=1\n\t\tAND `int`=%i\n\t\tAND `time` > (NOW() - INTERVAL 2 MINUTE)\n\tLIMIT 1"; $query = $dbo->prepare($query, array($subscriber['id'])); $test = $dbo->query($query, 0); // attempt to send activation code if once has not recently been sent if (empty($test)) { $code = Pommo_Subscribers::getActCode($subscriber); if (Pommo_Helper_Messages::sendMessage(array('to' => $subscriber['email'], 'code' => $code, 'type' => 'activate'))) { $smarty->assign('sent', true); // timestamp this activation email $query = "\n\t\t\tINSERT INTO " . $dbo->table['scratch'] . "\n\t\t\tSET\n\t\t\t\t`type`=1,\n\t\t\t\t`int`=%i"; $query = $dbo->prepare($query, array($subscriber['id'])); $dbo->query($query); // remove ALL activation email timestamps older than 2 minutes $query = "\n\t\t\tDELETE FROM \n\t\t\t\t" . $dbo->table['scratch'] . "\n\t\t\tWHERE\n\t\t\t\t`type`=1\n\t\t\t\tAND `time` < (NOW() - INTERVAL 2 MINUTE)"; $query = $dbo->prepare($query, array()); $dbo->query($query); } } else { $smarty->assign('sent', false); } $smarty->assign('email', $subscriber['email']); $smarty->display('user/activate.tpl');