Beispiel #1
0
    SmartyValidate::register_validator('email', 'Email', 'isEmail', false, false, 'trim');
    $formError = array();
    $formError['email'] = Pommo::_T('Invalid email address');
    $smarty->assign('formError', $formError);
    // Assign email to form if pre-provided
    if (isset($_REQUEST['Email'])) {
        $smarty->assign('Email', $_REQUEST['Email']);
    } elseif (isset($_REQUEST['email'])) {
        $smarty->assign('Email', $_REQUEST['email']);
    }
} else {
    // ___ USER HAS SENT FORM ___
    SmartyValidate::connect($smarty);
    if (SmartyValidate::is_valid($_POST)) {
        // __ FORM IS VALID __
        if (PommoHelper::isDupe($_POST['Email'])) {
            if (PommoPending::isEmailPending($_POST['Email'])) {
                $input = urlencode(serialize(array('Email' => $_POST['Email'])));
                SmartyValidate::disconnect();
                Pommo::redirect('pending.php?input=' . $input);
            } else {
                // __ EMAIL IN SUBSCRIBERS TABLE, REDIRECT
                SmartyValidate::disconnect();
                Pommo::redirect('activate.php?email=' . $_POST['Email']);
            }
        } else {
            // __ REPORT STATUS
            $logger->addMsg(Pommo::_T('Email address not found! Please try again.'));
            $logger->addMsg(sprintf(Pommo::_T('To subscribe, %sclick here%s'), '<a href="' . $pommo->_baseUrl . 'user/subscribe.php?Email=' . $_POST['Email'] . '">', '</a>'));
        }
    }
 foreach ($row as $key => $col) {
     $fid =& $_POST['f'][$key];
     if (is_numeric($fid)) {
         $subscriber['data'][$fid] = $col;
     } elseif ($fid == 'email' && PommoHelper::isEmail($col)) {
         $subscriber['email'] = $col;
     } elseif ($fid == 'registered') {
         $subscriber['registered'] = PommoHelper::timeFromStr($col);
     } elseif ($fid == 'ip') {
         $subscriber['ip'] = $col;
     }
 }
 if ($subscriber['email']) {
     // check for dupe
     // TODO -- DO THIS IN BATCH ??
     if (PommoHelper::isDupe($subscriber['email'], $includeUnsubscribed)) {
         $dupes++;
         continue;
     }
     // validate/fix data
     if (!PommoValidate::subscriberData($subscriber['data'], array('log' => false, 'ignore' => true, 'active' => false))) {
         $subscriber['flag'] = 9;
     }
     // add subscriber
     if (PommoSubscriber::add($subscriber)) {
         $tally++;
         if (isset($subscriber['flag'])) {
             $flagged++;
         }
     }
 }
Beispiel #3
0
$referer = !empty($_POST['bmReferer']) ? $_POST['bmReferer'] : $pommo->_http . $pommo->_baseUrl . 'user/subscribe.php';
// append stored input
$smarty->assign('referer', $referer . '?input=' . urlencode(serialize($_POST)));
/**********************************
	VALIDATE INPUT
 *********************************/
if (empty($_POST['pommo_signup'])) {
    Pommo::redirect('login.php');
}
$subscriber = array('email' => $_POST['Email'], 'registered' => time(), 'ip' => $_SERVER['REMOTE_ADDR'], 'status' => 1, 'data' => @$_POST['d']);
// ** check for correct email syntax
if (!PommoHelper::isEmail($subscriber['email'])) {
    $logger->addErr(Pommo::_T('Invalid Email Address'));
}
// ** check if email already exists in DB ("duplicates are bad..")
if (PommoHelper::isDupe($subscriber['email'])) {
    $logger->addErr(Pommo::_T('Email address already exists. Duplicates are not allowed.'));
    $smarty->assign('dupe', TRUE);
}
// check if errors exist with data, if so print results and die.
if ($logger->isErr() || !PommoValidate::subscriberData($subscriber['data'], array('active' => FALSE))) {
    $smarty->assign('back', TRUE);
    $smarty->display('user/process.tpl');
    Pommo::kill();
}
$comments = isset($_POST['comments']) ? substr($_POST['comments'], 0, 255) : false;
/**********************************
	ADD SUBSCRIBER
 *********************************/
$config = PommoAPI::configGet(array('site_success', 'site_confirm', 'list_confirm', 'notices'));
$notices = unserialize($config['notices']);
     $box = true;
 }
 if (is_resource($fp)) {
     if ($_POST['type'] == 'txt') {
         // list of emails
         $a = array();
         while (($data = fgetcsv($fp, 2048, ',', '"')) !== FALSE) {
             foreach ($data as $email) {
                 if (PommoHelper::isEmail($email)) {
                     array_push($a, $email);
                 }
             }
         }
         // remove dupes
         $includeUnsubscribed = isset($_REQUEST['excludeUnsubscribed']) ? false : true;
         $dupes =& PommoHelper::isDupe($a, $includeUnsubscribed);
         if (!$dupes) {
             $dupes = array();
         }
         $emails = array_diff($a, $dupes);
         $pommo->set(array('emails' => $emails, 'dupes' => count($dupes)));
         Pommo::redirect('import_txt.php');
     } elseif ($_POST['type'] == 'csv') {
         // csv of subscriber data, store first 10 for preview
         $a = array();
         $i = 1;
         while (($data = fgetcsv($fp, 2048, ',', '"')) !== FALSE) {
             array_push($a, $data);
             if ($i > 9) {
                 // only get first 10 lines -- move file
                 break;
Beispiel #5
0
}
$config = PommoAPI::configGet(array('notices'));
$notices = unserialize($config['notices']);
if (!isset($_POST['d'])) {
    $smarty->assign('d', $subscriber['data']);
}
// check for an update + validate new subscriber info (also converts dates to ints)
if (!empty($_POST['update']) && PommoValidate::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.'));
        } elseif (!PommoHelper::isEmail($_POST['newemail'])) {
            $logger->addErr(Pommo::_T('Invalid Email Address'));
        } elseif (PommoHelper::isDupe($_POST['newemail'])) {
            $logger->addMsg(Pommo::_T('Email address already exists. Duplicates are not allowed.'));
        } else {
            $newsub['email'] = $_POST['newemail'];
            $code = PommoPending::add($newsub, 'change');
            if (!$code) {
                die('Failed to Generate Pending Subscriber Code');
            }
            Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/messages.php');
            PommoHelperMessages::sendMessage(array('to' => $newsub['email'], 'code' => $code, 'type' => 'update'));
            if (isset($notices['update']) && $notices['update'] == 'on') {
                PommoHelperMessages::notify($notices, $newsub, 'update');
            }
        }
    } elseif (!PommoSubscriber::update($newsub, 'REPLACE_ACTIVE')) {
        $logger->addErr('Error updating subscriber.');