当前位置: 首页>>代码示例>>PHP>>正文


PHP DevblocksPlatform::strToRegExp方法代码示例

本文整理汇总了PHP中DevblocksPlatform::strToRegExp方法的典型用法代码示例。如果您正苦于以下问题:PHP DevblocksPlatform::strToRegExp方法的具体用法?PHP DevblocksPlatform::strToRegExp怎么用?PHP DevblocksPlatform::strToRegExp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DevblocksPlatform的用法示例。


在下文中一共展示了DevblocksPlatform::strToRegExp方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getMatches


//.........这里部分代码省略.........
                             if ($current_hour == $from_hour && (int) $current_min < $from_min) {
                                 break;
                             }
                             // If we're in the last hour, are we minutes late?
                             if ($current_hour == $to_hour && (int) $current_min > $to_min) {
                                 break;
                             }
                             $passed++;
                         }
                         break;
                     case 'event':
                         if (!empty($event) && is_array($rule) && isset($rule[$event])) {
                             $passed++;
                         }
                         break;
                     case 'groups':
                         if (null !== @($group_buckets = $rule['groups'][$ticket->team_id]) && (empty($group_buckets) || in_array($ticket->category_id, $group_buckets))) {
                             $passed++;
                         }
                         break;
                     case 'next_worker_id':
                         // If it's an assigned event, we only care about the filter's owner
                         if (!empty($event) && 0 == strcasecmp($event, 'ticket_assignment')) {
                             if (intval($value) == intval($filter->worker_id)) {
                                 $passed++;
                                 break;
                             }
                         }
                         if (intval($value) == intval($ticket->next_worker_id)) {
                             $passed++;
                         }
                         break;
                     case 'mask':
                         $regexp_mask = DevblocksPlatform::strToRegExp($value);
                         if (@preg_match($regexp_mask, $ticket->mask)) {
                             $passed++;
                         }
                         break;
                     case 'from':
                         $regexp_from = DevblocksPlatform::strToRegExp($value);
                         if (@preg_match($regexp_from, $ticket_from->email)) {
                             $passed++;
                         }
                         break;
                     case 'subject':
                         $regexp_subject = DevblocksPlatform::strToRegExp($value);
                         if (@preg_match($regexp_subject, $ticket->subject)) {
                             $passed++;
                         }
                         break;
                     case 'body':
                         if (null == ($message_body = $message_last->getContent())) {
                             break;
                         }
                         // Line-by-line body scanning (sed-like)
                         $lines = preg_split("/[\r\n]/", $message_body);
                         if (is_array($lines)) {
                             foreach ($lines as $line) {
                                 if (@preg_match($value, $line)) {
                                     $passed++;
                                     break;
                                 }
                             }
                         }
                         break;
                     case 'header1':
开发者ID:Hildy,项目名称:cerb5,代码行数:67,代码来源:App.php

示例2: getMatches

 static function getMatches(Model_Address $fromAddress, CerberusParserMessage $message)
 {
     //		print_r($fromAddress);
     //		print_r($message);
     $matches = array();
     $rules = DAO_MailToGroupRule::getWhere();
     $message_headers = $message->headers;
     $custom_fields = DAO_CustomField::getAll();
     // Lazy load when needed on criteria basis
     $address_field_values = null;
     $org_field_values = null;
     // Check filters
     if (is_array($rules)) {
         foreach ($rules as $rule) {
             /* @var $rule Model_MailToGroupRule */
             $passed = 0;
             // check criteria
             foreach ($rule->criteria as $crit_key => $crit) {
                 @($value = $crit['value']);
                 switch ($crit_key) {
                     case 'dayofweek':
                         $current_day = strftime('%w');
                         //						$current_day = 1;
                         // Forced to English abbrevs as indexes
                         $days = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
                         // Is the current day enabled?
                         if (isset($crit[$days[$current_day]])) {
                             $passed++;
                         }
                         break;
                     case 'timeofday':
                         $current_hour = strftime('%H');
                         $current_min = strftime('%M');
                         //						$current_hour = 17;
                         //						$current_min = 5;
                         if (null != ($from_time = @$crit['from'])) {
                             list($from_hour, $from_min) = explode(':', $from_time);
                         }
                         if (null != ($to_time = @$crit['to'])) {
                             if (list($to_hour, $to_min) = explode(':', $to_time)) {
                             }
                         }
                         // Do we need to wrap around to the next day's hours?
                         if ($from_hour > $to_hour) {
                             // yes
                             $to_hour += 24;
                             // add 24 hrs to the destination (1am = 25th hour)
                         }
                         // Are we in the right 24 hourly range?
                         if ((int) $current_hour >= $from_hour && (int) $current_hour <= $to_hour) {
                             // If we're in the first hour, are we minutes early?
                             if ($current_hour == $from_hour && (int) $current_min < $from_min) {
                                 break;
                             }
                             // If we're in the last hour, are we minutes late?
                             if ($current_hour == $to_hour && (int) $current_min > $to_min) {
                                 break;
                             }
                             $passed++;
                         }
                         break;
                     case 'tocc':
                         $tocc = array();
                         $destinations = DevblocksPlatform::parseCsvString($value);
                         // Build a list of To/Cc addresses on this message
                         @($to_list = imap_rfc822_parse_adrlist($message_headers['to'], 'localhost'));
                         @($cc_list = imap_rfc822_parse_adrlist($message_headers['cc'], 'localhost'));
                         if (is_array($to_list)) {
                             foreach ($to_list as $addy) {
                                 $tocc[] = $addy->mailbox . '@' . $addy->host;
                             }
                         }
                         if (is_array($cc_list)) {
                             foreach ($cc_list as $addy) {
                                 $tocc[] = $addy->mailbox . '@' . $addy->host;
                             }
                         }
                         $dest_flag = false;
                         // bail out when true
                         if (is_array($destinations) && is_array($tocc)) {
                             foreach ($destinations as $dest) {
                                 if ($dest_flag) {
                                     break;
                                 }
                                 $regexp_dest = DevblocksPlatform::strToRegExp($dest);
                                 foreach ($tocc as $addy) {
                                     if (@preg_match($regexp_dest, $addy)) {
                                         $passed++;
                                         $dest_flag = false;
                                         break;
                                     }
                                 }
                             }
                         }
                         break;
                     case 'from':
                         $regexp_from = DevblocksPlatform::strToRegExp($value);
                         if (@preg_match($regexp_from, $fromAddress->email)) {
                             $passed++;
                         }
//.........这里部分代码省略.........
开发者ID:rmiddle,项目名称:cerb4,代码行数:101,代码来源:Model.class.php

示例3: getMatches

 /**
  * @return Model_Sensor[]|false
  */
 public function getMatches($sensors)
 {
     $matches = array();
     // Check the sensor
     if (empty($sensors)) {
         return false;
     }
     $custom_fields = DAO_CustomField::getAll();
     // Lazy load when needed on criteria basis
     $sensor_field_values = null;
     // Criteria extensions
     $alert_criteria_exts = DevblocksPlatform::getExtensions('portsensor.alert.criteria', false);
     if (is_array($sensors)) {
         foreach ($sensors as $sensor) {
             // Check filters
             $passed = 0;
             // Skip alerts with no criteria
             if (!is_array($this->criteria) || empty($this->criteria)) {
                 continue;
             }
             // check criteria
             if (is_array($this->criteria)) {
                 foreach ($this->criteria as $rule_key => $rule) {
                     @($value = $rule['value']);
                     switch ($rule_key) {
                         case 'dayofweek':
                             $current_day = strftime('%w');
                             //						$current_day = 1;
                             // Forced to English abbrevs as indexes
                             $days = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
                             // Is the current day enabled?
                             if (isset($rule[$days[$current_day]])) {
                                 $passed++;
                             }
                             break;
                         case 'timeofday':
                             $current_hour = strftime('%H');
                             $current_min = strftime('%M');
                             //						$current_hour = 17;
                             //						$current_min = 5;
                             if (null != ($from_time = @$rule['from'])) {
                                 list($from_hour, $from_min) = explode(':', $from_time);
                             }
                             if (null != ($to_time = @$rule['to'])) {
                                 if (list($to_hour, $to_min) = explode(':', $to_time)) {
                                 }
                             }
                             // Do we need to wrap around to the next day's hours?
                             if ($from_hour > $to_hour) {
                                 // yes
                                 $to_hour += 24;
                                 // add 24 hrs to the destination (1am = 25th hour)
                             }
                             // Are we in the right 24 hourly range?
                             if ((int) $current_hour >= $from_hour && (int) $current_hour <= $to_hour) {
                                 // If we're in the first hour, are we minutes early?
                                 if ($current_hour == $from_hour && (int) $current_min < $from_min) {
                                     break;
                                 }
                                 // If we're in the last hour, are we minutes late?
                                 if ($current_hour == $to_hour && (int) $current_min > $to_min) {
                                     break;
                                 }
                                 $passed++;
                             }
                             break;
                         case 'event':
                             switch ($sensor->status) {
                                 case 0:
                                     // OK
                                     if (isset($rule['ok'])) {
                                         $passed++;
                                     }
                                     break;
                                 case 1:
                                     // WARNING
                                     if (isset($rule['warning'])) {
                                         $passed++;
                                     }
                                     break;
                                 case 2:
                                     // CRITICAL
                                     if (isset($rule['critical'])) {
                                         $passed++;
                                     }
                                     break;
                             }
                             break;
                         case 'alert_last_ran':
                             @($from = DevblocksPlatform::importGPC($rule['from'], 'string', ''));
                             @($to = DevblocksPlatform::importGPC($rule['to'], 'string', ''));
                             if (intval(@strtotime($from)) <= $this->last_alert_date && intval(@strtotime($to)) >= $this->last_alert_date) {
                                 $passed++;
                             }
                             break;
                         case 'sensor_name':
                             $regexp_sensor_name = DevblocksPlatform::strToRegExp($value);
//.........这里部分代码省略.........
开发者ID:jstanden,项目名称:portsensor,代码行数:101,代码来源:Model.class.php

示例4: _checkPreParseRules

 /**
  * Returns a Model_PreParserRule on a match, or NULL
  *
  * @param boolean $is_new
  * @param string $from
  * @param string $to
  * @param CerberusParserMessage $message
  * @return Model_PreParserRule
  */
 private static function _checkPreParseRules($is_new, $from, $group_id, CerberusParserMessage $message)
 {
     $filters = DAO_PreParseRule::getAll();
     $headers = $message->headers;
     // check filters
     if (is_array($filters)) {
         foreach ($filters as $filter) {
             $passed = 0;
             // check criteria
             foreach ($filter->criteria as $rule_key => $rule) {
                 @($value = $rule['value']);
                 switch ($rule_key) {
                     case 'type':
                         if ($is_new && 0 == strcasecmp($value, 'new') || !$is_new && 0 == strcasecmp($value, 'reply')) {
                             $passed++;
                         }
                         break;
                     case 'from':
                         $regexp_from = DevblocksPlatform::strToRegExp($value);
                         if (preg_match($regexp_from, $from)) {
                             $passed++;
                         }
                         break;
                     case 'to':
                         if (intval($group_id) == intval($value)) {
                             $passed++;
                         }
                         break;
                     case 'header1':
                     case 'header2':
                     case 'header3':
                     case 'header4':
                     case 'header5':
                         $header = strtolower($rule['header']);
                         if (empty($value)) {
                             // we're checking for null/blanks
                             if (!isset($headers[$header]) || empty($headers[$header])) {
                                 $passed++;
                             }
                         } elseif (isset($headers[$header]) && !empty($headers[$header])) {
                             $regexp_header = DevblocksPlatform::strToRegExp($value);
                             // handle arrays like Received: and (broken)Content-Type headers  (farking spammers)
                             if (is_array($headers[$header])) {
                                 foreach ($headers[$header] as $array_header) {
                                     if (preg_match($regexp_header, str_replace(array("\r", "\n"), ' ', $array_header))) {
                                         $passed++;
                                         break;
                                     }
                                 }
                             } else {
                                 // Flatten CRLF
                                 if (preg_match($regexp_header, str_replace(array("\r", "\n"), ' ', $headers[$header]))) {
                                     $passed++;
                                 }
                             }
                         }
                         break;
                     case 'body':
                         $regexp_body = DevblocksPlatform::strToRegExp($value);
                         // Flatten CRLF
                         if (preg_match($regexp_body, str_replace(array("\r", "\n"), ' ', $message->body))) {
                             $passed++;
                         }
                         break;
                     case 'body_encoding':
                         $regexp_bodyenc = DevblocksPlatform::strToRegExp($value);
                         if (preg_match($regexp_bodyenc, $message->body_encoding)) {
                             $passed++;
                         }
                         break;
                     case 'attachment':
                         $regexp_file = DevblocksPlatform::strToRegExp($value);
                         // check the files in the raw message
                         foreach ($message->files as $file_name => $file) {
                             /* @var $file ParserFile */
                             if (preg_match($regexp_file, $file_name)) {
                                 $passed++;
                                 break;
                             }
                         }
                         break;
                     default:
                         // ignore invalids
                         continue;
                         break;
                 }
             }
             // If our rule matched every criteria, stop and return the filter
             if ($passed == count($filter->criteria)) {
                 DAO_PreParseRule::increment($filter->id);
                 // ++ the times we've matched
//.........这里部分代码省略.........
开发者ID:Hildy,项目名称:cerb4,代码行数:101,代码来源:Parser.php

示例5: getMatches

 /**
  * @return Model_GroupInboxFilter|false
  */
 static function getMatches($group_id, $ticket_id, $only_rule_id = 0)
 {
     $matches = array();
     if (empty($group_id)) {
         return false;
     }
     if (!empty($only_rule_id)) {
         $filters = array(DAO_GroupInboxFilter::get($only_rule_id));
     } else {
         $filters = DAO_GroupInboxFilter::getByGroupId($group_id);
     }
     // Check the ticket
     if (null === ($ticket = DAO_Ticket::getTicket($ticket_id))) {
         return false;
     }
     // Build our objects
     $ticket_from = DAO_Address::get($ticket->last_wrote_address_id);
     $ticket_group_id = $ticket->team_id;
     // [TODO] These expensive checks should only populate when needed
     $messages = DAO_Ticket::getMessagesByTicket($ticket_id);
     if (empty($messages)) {
         return false;
     }
     if (null == @($message = array_pop($messages))) {
         /* @var $message CerberusMessage */
         return false;
     }
     $message_headers = $message->getHeaders();
     $custom_fields = DAO_CustomField::getAll();
     // Lazy load when needed on criteria basis
     $ticket_field_values = null;
     $address_field_values = null;
     $org_field_values = null;
     // Check filters
     if (is_array($filters)) {
         foreach ($filters as $filter) {
             /* @var $filter Model_GroupInboxFilter */
             $passed = 0;
             // check criteria
             foreach ($filter->criteria as $rule_key => $rule) {
                 @($value = $rule['value']);
                 switch ($rule_key) {
                     case 'tocc':
                         $destinations = DevblocksPlatform::parseCsvString($value);
                         // Build a list of To/Cc addresses on this message
                         @($to_list = imap_rfc822_parse_adrlist($message_headers['to'], 'localhost'));
                         @($cc_list = imap_rfc822_parse_adrlist($message_headers['cc'], 'localhost'));
                         if (is_array($to_list)) {
                             foreach ($to_list as $addy) {
                                 $tocc[] = $addy->mailbox . '@' . $addy->host;
                             }
                         }
                         if (is_array($cc_list)) {
                             foreach ($cc_list as $addy) {
                                 $tocc[] = $addy->mailbox . '@' . $addy->host;
                             }
                         }
                         $dest_flag = false;
                         // bail out when true
                         if (is_array($destinations) && is_array($tocc)) {
                             foreach ($destinations as $dest) {
                                 if ($dest_flag) {
                                     break;
                                 }
                                 $regexp_dest = DevblocksPlatform::strToRegExp($dest);
                                 foreach ($tocc as $addy) {
                                     if (@preg_match($regexp_dest, $addy)) {
                                         $passed++;
                                         $dest_flag = false;
                                         break;
                                     }
                                 }
                             }
                         }
                         break;
                     case 'from':
                         $regexp_from = DevblocksPlatform::strToRegExp($value);
                         if (@preg_match($regexp_from, $ticket_from->email)) {
                             $passed++;
                         }
                         break;
                     case 'subject':
                         $regexp_subject = DevblocksPlatform::strToRegExp($value);
                         if (@preg_match($regexp_subject, $ticket->subject)) {
                             $passed++;
                         }
                         break;
                     case 'header1':
                     case 'header2':
                     case 'header3':
                     case 'header4':
                     case 'header5':
                         @($header = strtolower($rule['header']));
                         if (empty($header)) {
                             $passed++;
                             break;
                         }
//.........这里部分代码省略.........
开发者ID:Hildy,项目名称:cerb4,代码行数:101,代码来源:Model.class.php


注:本文中的DevblocksPlatform::strToRegExp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。