isEmail() public static method

returns email legitimacy (bool)
public static isEmail ( $_address )
Exemplo n.º 1
0
function check_notifyMails($value, $empty, &$params, &$formvars)
{
    $mails = Pommo_Helper::trimArray(explode(',', $value));
    $ret = true;
    foreach ($mails as $mail) {
        if (!empty($mail) && !Pommo_Helper::isEmail($mail)) {
            $ret = false;
        }
    }
    return $ret;
}
Exemplo n.º 2
0
 public static function validate(&$in)
 {
     $logger = Pommo::$_logger;
     $invalid = array();
     if (!Pommo_Helper::isEmail($in['email'])) {
         $invalid[] = 'email';
     }
     if (!is_numeric($in['registered'])) {
         $invalid[] = 'registered';
     }
     if (!empty($in['flag']) && !is_numeric($in['flag'])) {
         $invalid[] = 'flag';
     }
     if (!is_array($in['data'])) {
         $invalid[] = 'data';
     }
     switch ($in['status']) {
         case 0:
         case 1:
         case 2:
             break;
         default:
             $invalid[] = 'status';
     }
     if ($in['status'] == 2) {
         if (empty($in['pending_code'])) {
             $invalid[] = 'pending_code';
         }
         switch ($in['pending_type']) {
             case 'add':
             case 'del':
             case 'change':
             case 'password':
                 break;
             default:
                 $invalid[] = 'pending_type';
         }
     }
     if (!empty($invalid)) {
         $logger->addErr("Subscriber failed validation on; " . implode(',', $invalid), 1);
         return false;
     }
     return true;
 }
Exemplo n.º 3
0
$smarty = new Pommo_Template();
// attempt to detect if referer was set
//  TODO; enable HTTP_REFERER after stripping out ?input= tags. These will continually repeat
//$referer = (!empty($_POST['bmReferer'])) ? $_POST['bmReferer'] : $_SERVER['HTTP_REFERER'];
$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;
/**********************************
Exemplo n.º 4
0
 function validate()
 {
     if (empty($this->_fromname)) {
         $this->logger->addMsg("Name cannot be blank.");
         return false;
     }
     if (!Pommo_Helper::isEmail($this->_fromemail)) {
         $this->logger->addMsg("From email must be a valid email address.");
         return false;
     }
     if (!Pommo_Helper::isEmail($this->_frombounce)) {
         $this->logger->addMsg("Bounce email must be a valid email address.");
         return false;
     }
     if (empty($this->_subject)) {
         $this->logger->addMsg("Subject cannot be blank.");
         return false;
     }
     if (empty($this->_body)) {
         $this->logger->addMsg("Message content cannot be blank.");
         return false;
     }
     return true;
 }
Exemplo n.º 5
0
             Pommo::kill('Could not write to temp CSV file (' . Pommo::$_workDir . '/import.csv)');
         }
         fclose($handle);
     } else {
         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');
Exemplo n.º 6
0
 function validate(&$in)
 {
     $logger =& Pommo::$_logger;
     $invalid = array();
     if (empty($in['fromemail']) || !Pommo_Helper::isEmail($in['fromemail'])) {
         $invalid[] = 'fromemail';
     }
     if (empty($in['frombounce']) || !Pommo_Helper::isEmail($in['frombounce'])) {
         $invalid[] = 'frombounce';
     }
     if (empty($in['subject'])) {
         $invalid[] = 'subject';
     }
     if (empty($in['body'])) {
         $invalid[] = 'body';
     }
     if (!is_numeric($in['tally']) || $in['tally'] < 1) {
         $invalid[] = 'subscriberCount';
     }
     if (!empty($in['start']) && !is_numeric($in['start'])) {
         $invalid[] = 'started';
     }
     if (!empty($in['end']) && !is_numeric($in['end'])) {
         $invalid[] = 'finished';
     }
     if (!empty($in['sent']) && !is_numeric($in['sent'])) {
         $invalid[] = 'sent';
     }
     switch ($in['status']) {
         case 0:
         case 1:
         case 2:
             break;
         default:
             $invalid[] = 'status';
     }
     if ($in['status'] == 1) {
         switch ($in['command']) {
             case 'none':
             case 'restart':
             case 'stop':
                 break;
             default:
                 $invalid[] = 'command';
         }
         if (!empty($in['serial']) && !is_numeric($in['serial'])) {
             $invalid[] = 'serial';
         }
         switch ($in['current_status']) {
             case 'started':
             case 'stopped':
                 break;
             default:
                 $invalid[] = 'current_status';
         }
     }
     if (!empty($invalid)) {
         $logger->addErr("Mailing failed validation on; " . implode(',', $invalid), 1);
         return false;
     }
     return true;
 }
Exemplo n.º 7
0
require_once Pommo::$_baseDir . 'classes/Pommo_Subscribers.php';
require_once Pommo::$_baseDir . 'classes/Pommo_Validate.php';
Pommo::init(array('keep' => TRUE));
$logger = Pommo::$_logger;
$dbo = Pommo::$_dbo;
$dupes = $tally = $flagged = 0;
$dupe_emails = array();
$fp = fopen(Pommo::$_workDir . '/import.csv', 'r') or die('Unable to open CSV file');
$includeUnsubscribed = isset($_REQUEST['excludeUnsubscribed']) ? false : true;
while (($row = fgetcsv($fp, 2048, ',', '"')) !== FALSE) {
    $subscriber = array('email' => false, 'registered' => time(), 'ip' => $_SERVER['REMOTE_ADDR'], 'status' => 1, 'data' => array());
    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;
        }
Exemplo n.º 8
0
    $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.'));
        } 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');
            }
        }