sendMessage() public static method

code: confirmation code [str]
public static sendMessage ( $p = ['to' => false, 'type' => false, 'code' => false] )
Ejemplo n.º 1
0
    $view->display('user/confirm');
    Pommo::kill();
}
// Load success messages and redirection URL from config
$config = Pommo_Api::configGet(array('site_success', 'messages', 'notices'));
$messages = unserialize($config['messages']);
$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;
Ejemplo n.º 2
0
        $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.';
Ejemplo n.º 3
0
        $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();
Ejemplo n.º 4
0
 *********************************/
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');