isDupe() public static méthode

returns an array of duplicate found emails. FALSE if no dupes were found.
public static isDupe ( &$in, $includeUnsubscribed = false )
Exemple #1
0
$referer = !empty($_POST['bmReferer']) ? $_POST['bmReferer'] : Pommo::$_http . Pommo::$_baseUrl . '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 (!Pommo_Helper::isEmail($subscriber['email'])) {
    $logger->addErr(Pommo::_T('Invalid Email Address'));
}
// ** check if email already exists in DB ("duplicates are bad..")
if (Pommo_Helper::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() || !Pommo_Validate::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 = Pommo_Api::configGet(array('site_success', 'site_confirm', 'list_confirm', 'notices'));
$notices = unserialize($config['notices']);
Exemple #2
0
        // check if email is valid
        if (!Pommo_Helper::isEmail($_REQUEST['Email'])) {
            echo 1;
            $json->fail(Pommo::_T('Invalid email.'));
        }
        // check if email has unsubscribed
        if (!isset($_REQUEST['force'])) {
            $unsubscribed = Pommo_Subscribers::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 (Pommo_Helper::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 (!Pommo_Validate::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);
                }
                $json->fail();
            }
            $flag = true;
            $subscriber['flag'] = 9;
Exemple #3
0
 foreach ($row as $key => $col) {
     $fid =& $_POST['f'][$key];
     if (is_numeric($fid)) {
         $subscriber['data'][$fid] = $col;
     } elseif ($fid == 'email' && Pommo_Helper::isEmail($col)) {
         $subscriber['email'] = $col;
     } elseif ($fid == 'registered') {
         $subscriber['registered'] = Pommo_Helper::timeFromStr($col);
     } elseif ($fid == 'ip') {
         $subscriber['ip'] = $col;
     }
 }
 if ($subscriber['email']) {
     // check for dupe
     // TODO -- DO THIS IN BATCH ??
     if (Pommo_Helper::isDupe($subscriber['email'], $includeUnsubscribed)) {
         $dupes++;
         $dupe_emails[] = $subscriber['email'];
         continue;
     }
     // validate/fix data
     if (!Pommo_Validate::subscriberData($subscriber['data'], array('log' => false, 'ignore' => true, 'active' => false))) {
         $subscriber['flag'] = 9;
     }
     // add subscriber
     if (Pommo_Subscribers::add($subscriber)) {
         $tally++;
         if (isset($subscriber['flag'])) {
             $flagged++;
         }
     }
Exemple #4
0
                if (!move_uploaded_file($_FILES[$fname]['tmp_name'], Pommo::$_workDir . '/import.csv')) {
                    Pommo::kill('Could not write to temp CSV file (' . Pommo::$_workDir . '/import.csv)');
                }
            }
            Pommo::set(array('preview' => $a));
            Pommo::redirect('import_csv.php' . (isset($_REQUEST['excludeUnsubscribed']) ? '?excludeUnsubscribed=true' : ''));
        } else {
            //	Saves all parsed E-mails in an array
            $a = array();
            while (($data = fgetcsv($fp, 2048, ',', '"')) !== false) {
                foreach ($data as $email) {
                    if (Pommo_Helper::isEmail($email)) {
                        $email = strtolower($email);
                        $a[$email] = $email;
                    }
                }
            }
            //	Removes from the array E-mails that are already on the database
            $includeUnsubscribed = isset($_REQUEST['excludeUnsubscribed']) ? false : true;
            $dupes = Pommo_Helper::isDupe($a, $includeUnsubscribed);
            if (!$dupes) {
                $dupes = array();
            }
            $emails = array_diff($a, $dupes);
            //	Saves emails in session and redirects to confirmation page
            Pommo::set(array('emails' => $emails, 'dupes' => count($dupes)));
            Pommo::redirect('import_txt.php');
        }
    }
}
$view->display('admin/subscribers/subscribers_import');
Exemple #5
0
}
$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.'));
        } elseif (!Pommo_Helper::isEmail($_POST['newemail'])) {
            $logger->addErr(Pommo::_T('Invalid Email Address'));
        } elseif (Pommo_Helper::isDupe($_POST['newemail'])) {
            $logger->addMsg(Pommo::_T('Email address already exists. Duplicates are not allowed.'));
        } else {
            $newsub['email'] = $_POST['newemail'];
            $code = Pommo_Pending::add($newsub, 'change');
            if (!$code) {
                die('Failed to Generate Pending Subscriber Code');
            }
            require_once Pommo::$_baseDir . 'classes/Pommo_Helper_Messages.php';
            Pommo_Helper_Messages::sendMessage(array('to' => $newsub['email'], 'code' => $code, 'type' => 'update'));
            if (isset($notices['update']) && $notices['update'] == 'on') {
                Pommo_Helper_Messages::notify($notices, $newsub, 'update');
            }
        }
    } elseif (!Pommo_Subscribers::update($newsub, 'REPLACE_ACTIVE')) {
        $logger->addErr('Error updating subscriber.');