54 return preg_match( $regex, $text );
66 if ( substr( $filterEntry, 0, 2 ) ==
'*.' ) {
67 $regex .=
'(?:[A-Za-z0-9.-]+\.|)';
68 $filterEntry = substr( $filterEntry, 2 );
70 $regex .= preg_quote( $filterEntry,
'!' ) .
'!Si';
95 public static function makeLikeArray( $filterEntry, $protocol =
'http://' ) {
98 $target = $protocol . $filterEntry;
101 if ( $bits ==
false ) {
106 if ( substr( $bits[
'host'], 0, 2 ) ==
'*.' ) {
108 $bits[
'host'] = substr( $bits[
'host'], 2 );
109 if ( $bits[
'host'] ==
'' ) {
120 if ( $bits[
'scheme'] ===
'mailto' && strpos( $bits[
'host'],
'@' ) ) {
122 $mailparts = explode(
'@', $bits[
'host'] );
123 $domainpart = strtolower( implode(
'.', array_reverse( explode(
'.', $mailparts[1] ) ) ) );
124 $bits[
'host'] = $domainpart .
'@' . $mailparts[0];
125 } elseif ( $bits[
'scheme'] ===
'mailto' ) {
127 $bits[
'host'] = strtolower( implode(
'.', array_reverse( explode(
'.', $bits[
'host'] ) ) ) );
129 $bits[
'host'] = strtolower( implode(
'.', array_reverse( explode(
'.', $bits[
'host'] ) ) ) );
130 if ( substr( $bits[
'host'], -1, 1 ) !==
'.' ) {
131 $bits[
'host'] .=
'.';
135 $like[] = $bits[
'scheme'] . $bits[
'delimiter'] . $bits[
'host'];
138 $like[] = $db->anyString();
141 if ( isset( $bits[
'port'] ) ) {
142 $like[] =
':' . $bits[
'port'];
144 if ( isset( $bits[
'path'] ) ) {
145 $like[] = $bits[
'path'];
146 } elseif ( !$subdomains ) {
149 if ( isset( $bits[
'query'] ) ) {
150 $like[] =
'?' . $bits[
'query'];
152 if ( isset( $bits[
'fragment'] ) ) {
153 $like[] =
'#' . $bits[
'fragment'];
157 foreach ( $like
as $likepart ) {
158 if ( !( $likepart instanceof
LikeMatch ) && strpos( $likepart,
'*' ) !==
false ) {
165 $like[] = $db->anyString();
179 if ( !is_array( $arr ) ) {
183 foreach ( $arr
as $key =>
$value ) {
185 return array_slice( $arr, 0, $key + 1 );