Ejemplo n.º 1
0
/**********************************
	JSON OUTPUT INITIALIZATION
 *********************************/
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php');
$json = new PommoJSON();
// EXAMINE CALL
switch ($_REQUEST['call']) {
    case 'addSubscriber':
        $json->setFailMsg(Pommo::_T('Error adding subscriber.'));
        // check if email is valid
        if (!PommoHelper::isEmail($_REQUEST['Email'])) {
            $json->fail(Pommo::_T('Invalid email.'));
        }
        // check if email has unsubscribed
        if (!isset($_REQUEST['force'])) {
            $unsubscribed = PommoSubscriber::GetIDByEmail($_REQUEST['Email'], 0);
            if (!empty($unsubscribed)) {
                $json->fail(sprintf(Pommo::_T('%s has already unsubscribed. To add the subscriber anyway, check the box to force the addition.'), '<strong>' . $_REQUEST['Email'] . '</strong>'));
            }
        }
        // check if duplicate
        if (PommoHelper::isDupe($_POST['Email'])) {
            $json->fail(Pommo::_T('Email address already exists. Duplicates are not allowed.'));
        }
        $subscriber = array('email' => $_REQUEST['Email'], 'registered' => time(), 'ip' => $_SERVER['REMOTE_ADDR'], 'status' => 1, 'data' => $_POST['d']);
        $flag = false;
        if (!PommoValidate::subscriberData($subscriber['data'], array('active' => FALSE, 'ignore' => TRUE))) {
            if (!isset($_REQUEST['force'])) {
                $json->addMsg(Pommo::_T('Invalid or missing information.'));
                foreach ($logger->getAll() as $err) {
                    $json->addErr($err);