returns true if pending exists, false if not (bool)
public isPending ( $id = null ) |
function add(&$subscriber, $type = null) { global $pommo; $dbo =& Pommo::$_dbo; $logger =& Pommo::$_logger; switch ($type) { case 'add': case 'del': case 'change': case 'password': break; default: $logger->addErr('Unknown type passed to Pommo_Pending::add'); return false; } $p = array('subscriber_id' => $subscriber['id'], 'type' => $type, 'code' => Pommo_Helper::makeCode(), 'array' => $type == 'change' ? $subscriber : array()); $pending = Pommo_Pending::make($p); if (!Pommo_Pending::validate($pending)) { $logger->addErr('Pommo_Pending::add() failed validation'); return false; } if (!empty($pending['array'])) { $pending['array'] = serialize($pending['array']); } // check for pre-existing pending request if (Pommo_Pending::isPending($pending['subscriber_id'])) { return false; } $query = "\n\t\t\tINSERT INTO " . $dbo->table['subscriber_pending'] . "\n\t\t\tSET\n\t\t\t\t[pending_array='%S',]\n\t\t\t\tsubscriber_id=%i,\n\t\t\t\tpending_type='%s',\n\t\t\t\tpending_code='%s'"; $query = $dbo->prepare($query, array($pending['array'], $pending['subscriber_id'], $pending['type'], $pending['code'])); if (!$dbo->query($query)) { return false; } return $pending['code']; }
} } elseif (!empty($_POST['resetPassword'])) { // TODO -- visit this function later // Check if a reset password request has been received // check that captcha matched if (!isset($_POST['captcha'])) { // generate captcha $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
SETUP TEMPLATE, PAGE *********************************/ require_once Pommo::$_baseDir . 'classes/Pommo_Template.php'; $view = new Pommo_Template(); // Prepare for subscriber form -- load in fields + POST/Saved Subscribe Form $view->prepareForSubscribeForm(); // fetch the subscriber, validate code $subscriber = current(Pommo_Subscribers::get(array('email' => empty($_REQUEST['email']) ? '0' : $_REQUEST['email'], 'status' => 1))); if (empty($subscriber)) { Pommo::redirect('login.php'); } if ($_REQUEST['code'] != Pommo_Subscribers::getActCode($subscriber)) { Pommo::kill(Pommo::_T('Invalid activation code.')); } // check if we have pending request if (Pommo_Pending::isPending($subscriber['id'])) { $input = urlencode(serialize(array('Email' => $_POST['Email']))); Pommo::redirect('pending.php?input=' . $input); } $config = Pommo_Api::configGet(array('notices')); $notices = unserialize($config['notices']); if (!isset($_POST['d'])) { $view->assign('d', $subscriber['data']); } // check for an update + validate new subscriber info (also converts dates to ints) if (!empty($_POST['update']) && Pommo_Validate::subscriberData($_POST['d'])) { $newsub = array('id' => $subscriber['id'], 'email' => $subscriber['email'], 'data' => $_POST['d']); if (!empty($_POST['newemail'])) { // if change in email, validate and send confirmation of update if ($_POST['newemail'] != $_POST['newemail2']) { $logger->addErr(Pommo::_T('Emails must match.'));