當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Subscriber::getSubscriber方法代碼示例

本文整理匯總了PHP中Subscriber::getSubscriber方法的典型用法代碼示例。如果您正苦於以下問題:PHP Subscriber::getSubscriber方法的具體用法?PHP Subscriber::getSubscriber怎麽用?PHP Subscriber::getSubscriber使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Subscriber的用法示例。


在下文中一共展示了Subscriber::getSubscriber方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: findSubscriber

 /**
  * Find which subscriber this message was sent to
  * @param string $text
  * @return bool|Subscriber
  */
 private function findSubscriber($text)
 {
     $subscriber = false;
     $subscriber_id = '';
     preg_match('/X-ListMember: (.*)\\R/iU', $text, $match);
     if (is_array($match) && isset($match[1])) {
         $subscriber_id = trim($match[1]);
     } else {
         # older version use X-User
         preg_match('/X-User: (.*)\\R/iU', $text, $match);
         if (is_array($match) && isset($match[1])) {
             $subscriber_id = trim($match[1]);
         }
     }
     if ($subscriber_id != '') {
         # some versions used the email to identify the subscribers, some the userid and others the uniqid
         # use backward compatible way to find subscriber
         if (strpos($subscriber_id, '@') !== false) {
             $subscriber = Subscriber::getSubscriberByEmailAddress($subscriber_id);
         } elseif (preg_match('/^\\d$/', $subscriber_id)) {
             $subscriber = Subscriber::getSubscriber($subscriber_id);
         } elseif (!empty($subscriber_id)) {
             $subscriber = Subscriber::getSubscriberByUniqueId($subscriber_id);
         }
     }
     if ($subscriber === false) {
         ### if we didn't find any, parse anything looking like an email address and check if it's a subscriber.
         ## this is probably fairly time consuming, but as the process is only done once every so often
         ## that should not be too bad
         preg_match_all('/[\\S]+@[\\S\\.]+/', $text, $regs);
         foreach ($regs[0] as $match) {
             $subscriberObj = Subscriber::getSubscriberByEmailAddress(Util::cleanEmail($match));
             if ($subscriberObj !== false) {
                 return $subscriberObj;
             }
         }
     }
     return $subscriber;
 }
開發者ID:jbeigh,項目名稱:phpList,代碼行數:44,代碼來源:BounceProcessor.php

示例2: startProcessing


//.........這裏部分代碼省略.........
             $this->counters['total_subscribers_for_campaign ' . $campaign->id] = $subscriberids_result->rowCount();
         }
         if (Config::MAILQUEUE_BATCH_SIZE > 0) {
             ## in case of sending multiple campaigns, reduce batch with "sent"
             $this->num_per_batch -= $this->sent;
             # send in batches of $this->num_per_batch subscribers
             $batch_total = $this->counters['total_subscribers_for_campaign ' . $campaign->id];
             if ($this->num_per_batch > 0) {
                 $subscriberids_query .= sprintf(' LIMIT 0,%d', $this->num_per_batch);
                 if (Config::VERBOSE) {
                     phpList::log()->debug($this->num_per_batch . '  query -> ' . $subscriberids_query, ['page' => 'porcessqueue']);
                 }
                 try {
                     $subscriberids_result = phpList::DB()->query($subscriberids_query);
                 } catch (\PDOException $e) {
                     $this->queueProcessError($e->getMessage());
                 }
             } else {
                 phpList::log()->debug(s('No subscribers to process for this batch'), ['page' => 'porcessqueue']);
                 //TODO: Can we remove this pointless query (will have to change the while loop below)
                 $subscriberids_result = phpList::DB()->query(sprintf('SELECT * FROM %s WHERE id = 0', Config::getTableName('user')));
             }
             $affrows = $subscriberids_result->rowCount();
             phpList::log()->debug(s('Processing batch of ') . ': ' . $affrows, ['page' => 'porcessqueue']);
         }
         while ($subscriberdata = $subscriberids_result->fetch()) {
             $this->counters['processed_subscribers_for_campaign ' . $campaign->id]++;
             $failure_reason = '';
             if ($this->num_per_batch && $this->sent >= $this->num_per_batch) {
                 phpList::log()->debug(s('batch limit reached') . ": {$this->sent} ({$this->num_per_batch})", ['page' => 'porcessqueue']);
                 Config::setRunningConfig('wait', $this->batch_period);
                 return false;
             }
             $subscriber = Subscriber::getSubscriber($subscriberdata[0]);
             # id of the subscriber
             if ($output_speed_stats) {
                 phpList::log()->info('-----------------------------------' . "\n" . 'start process subscriber ' . $subscriber->id);
             }
             $some = 1;
             set_time_limit(120);
             $seconds_to_go = $finish_sending_before - time();
             $stop_sending = $seconds_to_go < 0;
             # check if we have been "killed"
             #   phpList::log()->debug('Process ID '.$this->send_process_id, ['page' => 'porcessqueue']);
             $alive = Process::checkLock($this->send_process_id);
             ## check for max-process-queue-time
             $elapsed = Timer::get('process_queue')->elapsed(true);
             if ($restrictions['max_process_queue_time'] && $elapsed > $restrictions['max_process_queue_time'] && $this->sent > 0) {
                 phpList::log()->info(s('queue processing time has exceeded max processing time ') . $restrictions['max_process_queue_time'], ['page' => 'processqueue']);
                 break;
             } elseif ($alive && !$stop_sending) {
                 Process::keepLock($this->send_process_id);
             } elseif ($stop_sending) {
                 phpList::log()->debug(s('Campaign sending timed out, is past date to process until'), ['page' => 'porcessqueue']);
                 break;
             } else {
                 $this->queueProcessError(s('Process Killed by other process'));
             }
             # check if the campaign we are working on is still there and in process
             $campaign = Campaign::getCampaign($campaign->id);
             if (empty($campaign)) {
                 $this->queueProcessError(s('Campaign I was working on has disappeared'));
             } elseif ($campaign->status != 'inprocess') {
                 $this->queueProcessError(s('Sending of this campaign has been suspended'));
             }
             flush();
開發者ID:jbeigh,項目名稱:phpList,代碼行數:67,代碼來源:QueueProcessor.php


注:本文中的Subscriber::getSubscriber方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。