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


PHP get_preg_expression函数代码示例

本文整理汇总了PHP中get_preg_expression函数的典型用法代码示例。如果您正苦于以下问题:PHP get_preg_expression函数的具体用法?PHP get_preg_expression怎么用?PHP get_preg_expression使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: is_valid_flash_bbcode

function is_valid_flash_bbcode($cleaned_content, $uid)
{
    $regex = get_flash_regex($uid);
    $url_regex = get_preg_expression('url');
    $www_url_regex = get_preg_expression('www_url');
    if (preg_match_all($regex, $cleaned_content, $matches)) {
        foreach ($matches[3] as $flash_url) {
            if (!preg_match("#^({$url_regex}|{$www_url_regex})\$#i", $flash_url)) {
                return false;
            }
        }
    }
    return true;
}
开发者ID:Rahber,项目名称:phpbb3,代码行数:14,代码来源:check_flash_bbcodes.php

示例2: user_ipwhois

function user_ipwhois($ip)
{
    $ipwhois = '';
    // Check IP
    // Only supporting IPv4 at the moment...
    if (empty($ip) || !preg_match(get_preg_expression('ipv4'), $ip)) {
        return '';
    }
    if ($fsk = @fsockopen('whois.arin.net', 43)) {
        // CRLF as per RFC3912
        fputs($fsk, "{$ip}\r\n");
        while (!feof($fsk)) {
            $ipwhois .= fgets($fsk, 1024);
        }
        @fclose($fsk);
    }
    $match = array();
    // Test for referrals from ARIN to other whois databases, roll on rwhois
    if (preg_match('#ReferralServer: whois://(.+)#im', $ipwhois, $match)) {
        if (strpos($match[1], ':') !== false) {
            $pos = strrpos($match[1], ':');
            $server = substr($match[1], 0, $pos);
            $port = (int) substr($match[1], $pos + 1);
            unset($pos);
        } else {
            $server = $match[1];
            $port = 43;
        }
        $buffer = '';
        if ($fsk = @fsockopen($server, $port)) {
            fputs($fsk, "{$ip}\r\n");
            while (!feof($fsk)) {
                $buffer .= fgets($fsk, 1024);
            }
            @fclose($fsk);
        }
        // Use the result from ARIN if we don't get any result here
        $ipwhois = empty($buffer) ? $ipwhois : $buffer;
    }
    return $ipwhois = htmlspecialchars($ipwhois);
}
开发者ID:yukisky,项目名称:clipbucket,代码行数:41,代码来源:whois.php

示例3: main

 /**
  * Main ACP module
  *
  * @param int $id
  * @param string $mode
  * @return null
  * @access public
  */
 public function main($id, $mode)
 {
     $this->tpl_name = 'acp_teamsecurity';
     $this->page_title = $this->user->lang('ACP_TEAM_SECURITY_SETTINGS');
     // Only allow founders to view/manage these settings
     if ($this->user->data['user_type'] != USER_FOUNDER) {
         trigger_error($this->user->lang('ACP_FOUNDER_MANAGE_ONLY'), E_USER_WARNING);
     }
     $form_key = 'acp_teamsecurity';
     add_form_key($form_key);
     if ($this->request->is_set_post('submit')) {
         if (!check_form_key($form_key)) {
             trigger_error($this->user->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING);
         }
         // Validate the email address submitted by the user
         $sec_contact = $this->request->variable('sec_contact', '');
         if ($sec_contact != '' && !preg_match('/^' . get_preg_expression('email') . '$/i', $sec_contact)) {
             trigger_error($this->user->lang('EMAIL_INVALID_EMAIL') . adm_back_link($this->u_action), E_USER_WARNING);
         }
         $this->config->set('sec_contact', $sec_contact);
         $this->config->set('sec_contact_name', $this->request->variable('sec_contact_name', '', true));
         $this->config->set('sec_login_email', $this->request->variable('sec_login_email', 0));
         $this->config->set('sec_login_attempts', $this->request->variable('sec_login_attempts', 0));
         $this->config->set('sec_email_changes', $this->request->variable('sec_email_changes', 0));
         $this->config->set('sec_strong_pass', $this->request->variable('sec_strong_pass', 0));
         $this->config->set('sec_min_pass_chars', $this->request->variable('sec_min_pass_chars', 0));
         $this->config->set('sec_usergroups', json_encode($this->request->variable('sec_usergroups', array(0))));
         $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_TEAM_SEC_UPDATED');
         trigger_error($this->user->lang('CONFIG_UPDATED') . adm_back_link($this->u_action));
     }
     // Set template vars for usergroups multi-select box
     $group_id_ary = !$this->config['sec_usergroups'] ? array() : json_decode(trim($this->config['sec_usergroups']), true);
     $this->get_group_options($group_id_ary);
     // Set output vars for display in the template
     $this->template->assign_vars(array('S_ACP_LOGIN_EMAIL' => $this->config['sec_login_email'], 'ACP_CONTACT_EMAIL' => $this->config['sec_contact'], 'ACP_CONTACT_NAME' => $this->config['sec_contact_name'], 'S_ACP_LOGIN_ATTEMPTS' => $this->config['sec_login_attempts'], 'S_ACP_EMAIL_CHANGES' => $this->config['sec_email_changes'], 'S_ACP_STRONG_PASS' => $this->config['sec_strong_pass'], 'ACP_MIN_PASS_CHARS' => $this->config['sec_min_pass_chars'], 'U_ACTION' => $this->u_action));
 }
开发者ID:Nicofuma,项目名称:teamsecurity,代码行数:44,代码来源:teamsecurity_module.php

示例4: check_admin_data

 /**
  * Check admin data
  *
  * @param string	$username	Admin username
  * @param string	$pass1		Admin password
  * @param string	$pass2		Admin password confirmation
  * @param string	$email		Admin e-mail address
  *
  * @return bool	True if data is valid, false otherwise
  */
 protected function check_admin_data($username, $pass1, $pass2, $email)
 {
     $data_valid = true;
     // Check if none of admin data is empty
     if (in_array('', array($username, $pass1, $pass2, $email), true)) {
         $this->io_handler->add_error_message('INST_ERR_MISSING_DATA');
         $data_valid = false;
     }
     if (utf8_strlen($username) < 3) {
         $this->io_handler->add_error_message('INST_ERR_USER_TOO_SHORT');
         $data_valid = false;
     }
     if (utf8_strlen($username) > 20) {
         $this->io_handler->add_error_message('INST_ERR_USER_TOO_LONG');
         $data_valid = false;
     }
     if ($pass1 !== $pass2 && $pass1 !== '') {
         $this->io_handler->add_error_message('INST_ERR_PASSWORD_MISMATCH');
         $data_valid = false;
     }
     // Test against the default password rules
     if (utf8_strlen($pass1) < 6) {
         $this->io_handler->add_error_message('INST_ERR_PASSWORD_TOO_SHORT');
         $data_valid = false;
     }
     if (utf8_strlen($pass1) > 30) {
         $this->io_handler->add_error_message('INST_ERR_PASSWORD_TOO_LONG');
         $data_valid = false;
     }
     if (!preg_match('/^' . get_preg_expression('email') . '$/i', $email)) {
         $this->io_handler->add_error_message('INST_ERR_EMAIL_INVALID');
         $data_valid = false;
     }
     return $data_valid;
 }
开发者ID:007durgesh219,项目名称:phpbb,代码行数:45,代码来源:obtain_admin_data.php

示例5: make_clickable

/**
* make_clickable function
*
* Replace magic urls of form http://xxx.xxx., www.xxx. and xxx@xxx.xxx.
* Cuts down displayed size of link if over 50 chars, turns absolute links
* into relative versions when the server/script path matches the link
*/
function make_clickable($text, $server_url = false, $class = 'postlink')
{
    if ($server_url === false) {
        $server_url = generate_board_url();
    }
    static $static_class;
    static $magic_url_match_args;
    if (!isset($magic_url_match_args[$server_url]) || $static_class != $class) {
        $static_class = $class;
        $class = $static_class ? ' class="' . $static_class . '"' : '';
        $local_class = $static_class ? ' class="' . $static_class . '-local"' : '';
        if (!is_array($magic_url_match_args)) {
            $magic_url_match_args = array();
        }
        // relative urls for this board
        $magic_url_match_args[$server_url][] = array('#(^|[\\n\\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#iu', MAGIC_URL_LOCAL, $local_class);
        // matches a xxxx://aaaaa.bbb.cccc. ...
        $magic_url_match_args[$server_url][] = array('#(^|[\\n\\t (>.])(' . get_preg_expression('url_inline') . ')#iu', MAGIC_URL_FULL, $class);
        // matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
        $magic_url_match_args[$server_url][] = array('#(^|[\\n\\t (>])(' . get_preg_expression('www_url_inline') . ')#iu', MAGIC_URL_WWW, $class);
        // matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode.
        $magic_url_match_args[$server_url][] = array('/(^|[\\n\\t (>])(' . get_preg_expression('email') . ')/iu', MAGIC_URL_EMAIL, '');
    }
    foreach ($magic_url_match_args[$server_url] as $magic_args) {
        if (preg_match($magic_args[0], $text, $matches)) {
            $text = preg_replace_callback($magic_args[0], function ($matches) use($magic_args) {
                $relative_url = isset($matches[3]) ? $matches[3] : '';
                return make_clickable_callback($magic_args[1], $matches[1], $matches[2], $relative_url, $magic_args[2]);
            }, $text);
        }
    }
    return $text;
}
开发者ID:41px,项目名称:phpbb-auth-passage,代码行数:40,代码来源:functions_content.php

示例6: setUp

	public function setUp()
	{
		$this->regex = get_preg_expression('ipv6');
	}
开发者ID:Noxwizard,项目名称:phpbb3,代码行数:4,代码来源:ipv6.php

示例7: phpbb_inet_pton

/**
* Wrapper for inet_pton()
*
* Converts a human readable IP address to its packed in_addr representation
* inet_pton() is supported by PHP since 5.1.0, since 5.3.0 also on Windows.
*
* @param string $address	A human readable IPv4 or IPv6 address.
*
* @return mixed		false if address is invalid,
*					in_addr representation of the given address otherwise (string)
*/
function phpbb_inet_pton($address)
{
    $ret = '';
    if (preg_match(get_preg_expression('ipv4'), $address)) {
        foreach (explode('.', $address) as $part) {
            $ret .= ($part <= 0xf ? '0' : '') . dechex($part);
        }
        return pack('H*', $ret);
    }
    if (preg_match(get_preg_expression('ipv6'), $address)) {
        $parts = explode(':', $address);
        $missing_parts = 8 - sizeof($parts) + 1;
        if (substr($address, 0, 2) === '::') {
            ++$missing_parts;
        }
        if (substr($address, -2) === '::') {
            ++$missing_parts;
        }
        $embedded_ipv4 = false;
        $last_part = end($parts);
        if (preg_match(get_preg_expression('ipv4'), $last_part)) {
            $parts[sizeof($parts) - 1] = '';
            $last_part = phpbb_inet_pton($last_part);
            $embedded_ipv4 = true;
            --$missing_parts;
        }
        foreach ($parts as $i => $part) {
            if (strlen($part)) {
                $ret .= str_pad($part, 4, '0', STR_PAD_LEFT);
            } else {
                if ($i && $i < sizeof($parts) - 1) {
                    $ret .= str_repeat('0000', $missing_parts);
                }
            }
        }
        $ret = pack('H*', $ret);
        if ($embedded_ipv4) {
            $ret .= $last_part;
        }
        return $ret;
    }
    return false;
}
开发者ID:WarriorMachines,项目名称:warriormachines-phpbb,代码行数:54,代码来源:functions.php

示例8: validate_url

 /**
  * Validate url
  *
  * @param string $var1 optional url parameter for url bbcode: [url(=$var1)]$var2[/url]
  * @param string $var2 url bbcode content: [url(=$var1)]$var2[/url]
  */
 function validate_url($var1, $var2)
 {
     global $config;
     $var1 = str_replace("\r\n", "\n", str_replace('\\"', '"', trim($var1)));
     $var2 = str_replace("\r\n", "\n", str_replace('\\"', '"', trim($var2)));
     $url = $var1 ? $var1 : $var2;
     if ($var1 && !$var2) {
         $var2 = $var1;
     }
     if (!$url) {
         return '[url' . ($var1 ? '=' . $var1 : '') . ']' . $var2 . '[/url]';
     }
     $valid = false;
     $url = str_replace(' ', '%20', $url);
     // Checking urls
     if (preg_match('#^' . get_preg_expression('url') . '$#i', $url) || preg_match('#^' . get_preg_expression('www_url') . '$#i', $url) || preg_match('#^' . preg_quote(generate_board_url(), '#') . get_preg_expression('relative_url') . '$#i', $url)) {
         $valid = true;
     }
     if ($valid) {
         $this->parsed_items['url']++;
         // if there is no scheme, then add http schema
         if (!preg_match('#^[a-z][a-z\\d+\\-.]*:/{2}#i', $url)) {
             $url = 'http://' . $url;
         }
         // Is this a link to somewhere inside this board? If so then remove the session id from the url
         if (strpos($url, generate_board_url()) !== false && strpos($url, 'sid=') !== false) {
             $url = preg_replace('/(&amp;|\\?)sid=[0-9a-f]{32}&amp;/', '\\1', $url);
             $url = preg_replace('/(&amp;|\\?)sid=[0-9a-f]{32}$/', '', $url);
             $url = append_sid($url);
         }
         return $var1 ? '[url=' . $this->bbcode_specialchars($url) . ':' . $this->bbcode_uid . ']' . $var2 . '[/url:' . $this->bbcode_uid . ']' : '[url:' . $this->bbcode_uid . ']' . $this->bbcode_specialchars($url) . '[/url:' . $this->bbcode_uid . ']';
     }
     return '[url' . ($var1 ? '=' . $var1 : '') . ']' . $var2 . '[/url]';
 }
开发者ID:jvinhit,项目名称:php,代码行数:40,代码来源:message_parser.php

示例9: make_clickable

 function make_clickable($text, $server_url = false, $class = 'postlink')
 {
     //$server_url is for phpBB3 only $class is for later phpBB3 only
     global $IN_WORDPRESS;
     if ($IN_WORDPRESS) {
         return wp_make_clickable($text);
         //WP version
     } else {
         //phpBB version
         global $wpuAbs;
         if ('PHPBB2' == $wpuAbs->ver) {
             $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1&#058;", $text);
             $ret = ' ' . $text;
             $ret = preg_replace("#(^|[\n ])([\\w]+?://[\\w\\#\$%&~/.\\-;:=,?@\\[\\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret);
             $ret = preg_replace("#(^|[\n ])((www|ftp)\\.[\\w\\#\$%&~/.\\-;:=,?@\\[\\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
             $ret = preg_replace("#(^|[\n ])([a-z0-9&\\-_.]+?)@([\\w\\-]+\\.([\\w\\-\\.]+\\.)*[\\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
             $ret = substr($ret, 1);
             return $ret;
         } else {
             //phpBB3 BRANCH:
             if ($server_url === false) {
                 $server_url = generate_board_url();
             }
             static $magic_url_match;
             static $magic_url_replace;
             static $static_class;
             if (!is_array($magic_url_match)) {
                 $magic_url_match = $magic_url_replace = array();
                 if (function_exists('make_clickable_callback')) {
                     //latest phpBB3s
                     $magic_url_match[] = '#(^|[\\n\\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#ie';
                     $magic_url_replace[] = "make_clickable_callback(MAGIC_URL_LOCAL, '\$1', '\$2', '\$3', '{$local_class}')";
                     $magic_url_match[] = '#(^|[\\n\\t (>.])(' . get_preg_expression('url_inline') . ')#ie';
                     $magic_url_replace[] = "make_clickable_callback(MAGIC_URL_FULL, '\$1', '\$2', '', '{$class}')";
                     $magic_url_match[] = '#(^|[\\n\\t (>])(' . get_preg_expression('www_url_inline') . ')#ie';
                     $magic_url_replace[] = "make_clickable_callback(MAGIC_URL_WWW, '\$1', '\$2', '', '{$class}')";
                     $magic_url_match[] = '/(^|[\\n\\t (>])(' . get_preg_expression('email') . ')/ie';
                     $magic_url_replace[] = "make_clickable_callback(MAGIC_URL_EMAIL, '\$1', '\$2', '', '')";
                 } else {
                     // phpBB3 v1.0
                     $magic_url_match[] = '#(^|[\\n\\t (])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#ie';
                     $magic_url_replace[] = "'\$1<!-- l --><a href=\"\$2/' . preg_replace('/(&amp;|\\?)sid=[0-9a-f]{32}/', '\\\\1', '\$3') . '\">' . preg_replace('/(&amp;|\\?)sid=[0-9a-f]{32}/', '\\\\1', '\$3') . '</a><!-- l -->'";
                     $magic_url_match[] = '#(^|[\\n\\t (])(' . get_preg_expression('url_inline') . ')#ie';
                     $magic_url_replace[] = "'\$1<!-- m --><a href=\"\$2\">' . ((strlen('\$2') > 55) ? substr(str_replace('&amp;', '&', '\$2'), 0, 39) . ' ... ' . substr(str_replace('&amp;', '&', '\$2'), -10) : '\$2') . '</a><!-- m -->'";
                     $magic_url_match[] = '#(^|[\\n\\t (])(' . get_preg_expression('www_url_inline') . ')#ie';
                     $magic_url_replace[] = "'\$1<!-- w --><a href=\"http://\$2\">' . ((strlen('\$2') > 55) ? substr(str_replace('&amp;', '&', '\$2'), 0, 39) . ' ... ' . substr(str_replace('&amp;', '&', '\$2'), -10) : '\$2') . '</a><!-- w -->'";
                     $magic_url_match[] = '/(^|[\\n\\t )])(' . get_preg_expression('email') . ')/ie';
                     $magic_url_replace[] = "'\$1<!-- e --><a href=\"mailto:\$2\">' . ((strlen('\$2') > 55) ? substr('\$2', 0, 39) . ' ... ' . substr('\$2', -10) : '\$2') . '</a><!-- e -->'";
                 }
             }
             return preg_replace($magic_url_match, $magic_url_replace, $text);
         }
     }
 }
开发者ID:Oddsor,项目名称:lpt-forum,代码行数:54,代码来源:wp-functions.php

示例10: build_regexp

 function build_regexp(&$bbcode_match, &$bbcode_tpl)
 {
     $bbcode_match = trim($bbcode_match);
     $bbcode_tpl = trim($bbcode_tpl);
     $utf8 = strpos($bbcode_match, 'INTTEXT') !== false;
     $utf8_pcre_properties = phpbb_pcre_utf8_support();
     $fp_match = preg_quote($bbcode_match, '!');
     $fp_replace = preg_replace('#^\\[(.*?)\\]#', '[$1:$uid]', $bbcode_match);
     $fp_replace = preg_replace('#\\[/(.*?)\\]$#', '[/$1:$uid]', $fp_replace);
     $sp_match = preg_quote($bbcode_match, '!');
     $sp_match = preg_replace('#^\\\\\\[(.*?)\\\\\\]#', '\\[$1:$uid\\]', $sp_match);
     $sp_match = preg_replace('#\\\\\\[/(.*?)\\\\\\]$#', '\\[/$1:$uid\\]', $sp_match);
     $sp_replace = $bbcode_tpl;
     // @todo Make sure to change this too if something changed in message parsing
     $tokens = array('URL' => array('!(?:(' . str_replace(array('!', '\\#'), array('\\!', '#'), get_preg_expression('url')) . ')|(' . str_replace(array('!', '\\#'), array('\\!', '#'), get_preg_expression('www_url')) . '))!ie' => "\$this->bbcode_specialchars(('\$1') ? '\$1' : 'http://\$2')"), 'LOCAL_URL' => array('!(' . str_replace(array('!', '\\#'), array('\\!', '#'), get_preg_expression('relative_url')) . ')!e' => "\$this->bbcode_specialchars('\$1')"), 'RELATIVE_URL' => array('!(' . str_replace(array('!', '\\#'), array('\\!', '#'), get_preg_expression('relative_url')) . ')!e' => "\$this->bbcode_specialchars('\$1')"), 'EMAIL' => array('!(' . get_preg_expression('email') . ')!ie' => "\$this->bbcode_specialchars('\$1')"), 'TEXT' => array('!(.*?)!es' => "str_replace(array(\"\\r\\n\", '\\\"', '\\'', '(', ')'), array(\"\\n\", '\"', '&#39;', '&#40;', '&#41;'), trim('\$1'))"), 'SIMPLETEXT' => array('!([a-zA-Z0-9-+.,_ ]+)!' => "\$1"), 'INTTEXT' => array($utf8_pcre_properties ? '!([\\p{L}\\p{N}\\-+,_. ]+)!u' : '!([a-zA-Z0-9\\-+,_. ]+)!u' => "\$1"), 'IDENTIFIER' => array('!([a-zA-Z0-9-_]+)!' => "\$1"), 'COLOR' => array('!([a-z]+|#[0-9abcdef]+)!i' => '$1'), 'NUMBER' => array('!([0-9]+)!' => '$1'));
     $sp_tokens = array('URL' => '(?i)((?:' . str_replace(array('!', '\\#'), array('\\!', '#'), get_preg_expression('url')) . ')|(?:' . str_replace(array('!', '\\#'), array('\\!', '#'), get_preg_expression('www_url')) . '))(?-i)', 'LOCAL_URL' => '(?i)(' . str_replace(array('!', '\\#'), array('\\!', '#'), get_preg_expression('relative_url')) . ')(?-i)', 'RELATIVE_URL' => '(?i)(' . str_replace(array('!', '\\#'), array('\\!', '#'), get_preg_expression('relative_url')) . ')(?-i)', 'EMAIL' => '(' . get_preg_expression('email') . ')', 'TEXT' => '(.*?)', 'SIMPLETEXT' => '([a-zA-Z0-9-+.,_ ]+)', 'INTTEXT' => $utf8_pcre_properties ? '([\\p{L}\\p{N}\\-+,_. ]+)' : '([a-zA-Z0-9\\-+,_. ]+)', 'IDENTIFIER' => '([a-zA-Z0-9-_]+)', 'COLOR' => '([a-zA-Z]+|#[0-9abcdefABCDEF]+)', 'NUMBER' => '([0-9]+)');
     $pad = 0;
     $modifiers = 'i';
     $modifiers .= $utf8 && $utf8_pcre_properties ? 'u' : '';
     if (preg_match_all('/\\{(' . implode('|', array_keys($tokens)) . ')[0-9]*\\}/i', $bbcode_match, $m)) {
         foreach ($m[0] as $n => $token) {
             $token_type = $m[1][$n];
             reset($tokens[strtoupper($token_type)]);
             list($match, $replace) = each($tokens[strtoupper($token_type)]);
             // Pad backreference numbers from tokens
             if (preg_match_all('/(?<!\\\\)\\$([0-9]+)/', $replace, $repad)) {
                 $repad = $pad + sizeof(array_unique($repad[0]));
                 $replace = preg_replace('/(?<!\\\\)\\$([0-9]+)/e', "'\${' . (\$1 + \$pad) . '}'", $replace);
                 $pad = $repad;
             }
             // Obtain pattern modifiers to use and alter the regex accordingly
             $regex = preg_replace('/!(.*)!([a-z]*)/', '$1', $match);
             $regex_modifiers = preg_replace('/!(.*)!([a-z]*)/', '$2', $match);
             for ($i = 0, $size = strlen($regex_modifiers); $i < $size; ++$i) {
                 if (strpos($modifiers, $regex_modifiers[$i]) === false) {
                     $modifiers .= $regex_modifiers[$i];
                     if ($regex_modifiers[$i] == 'e') {
                         $fp_replace = "'" . str_replace("'", "\\'", $fp_replace) . "'";
                     }
                 }
                 if ($regex_modifiers[$i] == 'e') {
                     $replace = "'.{$replace}.'";
                 }
             }
             $fp_match = str_replace(preg_quote($token, '!'), $regex, $fp_match);
             $fp_replace = str_replace($token, $replace, $fp_replace);
             $sp_match = str_replace(preg_quote($token, '!'), $sp_tokens[$token_type], $sp_match);
             // Prepend the board url to local relative links
             $replace_prepend = $token_type === 'LOCAL_URL' ? generate_board_url() . '/' : '';
             $sp_replace = str_replace($token, $replace_prepend . '${' . ($n + 1) . '}', $sp_replace);
         }
         $fp_match = '!' . $fp_match . '!' . $modifiers;
         $sp_match = '!' . $sp_match . '!s' . ($utf8 ? 'u' : '');
         if (strpos($fp_match, 'e') !== false) {
             $fp_replace = str_replace("'.'", '', $fp_replace);
             $fp_replace = str_replace(".''.", '.', $fp_replace);
         }
     } else {
         // No replacement is present, no need for a second-pass pattern replacement
         // A simple str_replace will suffice
         $fp_match = '!' . $fp_match . '!' . $modifiers;
         $sp_match = $fp_replace;
         $sp_replace = '';
     }
     // Lowercase tags
     $bbcode_tag = preg_replace('/.*?\\[([a-z0-9_-]+=?).*/i', '$1', $bbcode_match);
     $bbcode_search = preg_replace('/.*?\\[([a-z0-9_-]+)=?.*/i', '$1', $bbcode_match);
     if (!preg_match('/^[a-zA-Z0-9_-]+=?$/', $bbcode_tag)) {
         global $user;
         trigger_error($user->lang['BBCODE_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
     }
     $fp_match = preg_replace('#\\[/?' . $bbcode_search . '#ie', "strtolower('\$0')", $fp_match);
     $fp_replace = preg_replace('#\\[/?' . $bbcode_search . '#ie', "strtolower('\$0')", $fp_replace);
     $sp_match = preg_replace('#\\[/?' . $bbcode_search . '#ie', "strtolower('\$0')", $sp_match);
     $sp_replace = preg_replace('#\\[/?' . $bbcode_search . '#ie', "strtolower('\$0')", $sp_replace);
     return array('bbcode_tag' => $bbcode_tag, 'first_pass_match' => $fp_match, 'first_pass_replace' => $fp_replace, 'second_pass_match' => $sp_match, 'second_pass_replace' => $sp_replace);
 }
开发者ID:abhinay100,项目名称:phpbb2_app,代码行数:77,代码来源:acp_bbcodes.php

示例11: time

        if ($submit) {
            if (!check_form_key('memberlist_email')) {
                $error[] = 'FORM_INVALID';
            }
            if ($user_id) {
                if (!$subject) {
                    $error[] = $user->lang['EMPTY_SUBJECT_EMAIL'];
                }
                if (!$message) {
                    $error[] = $user->lang['EMPTY_MESSAGE_EMAIL'];
                }
                $name = $row['username'];
                $email_lang = $row['user_lang'];
                $email = $row['user_email'];
            } else {
                if (!$email || !preg_match('/^' . get_preg_expression('email') . '$/i', $email)) {
                    $error[] = $user->lang['EMPTY_ADDRESS_EMAIL'];
                }
                if (!$name) {
                    $error[] = $user->lang['EMPTY_NAME_EMAIL'];
                }
            }
            if (!sizeof($error)) {
                $sql = 'UPDATE ' . USERS_TABLE . '
					SET user_emailtime = ' . time() . '
					WHERE user_id = ' . $user->data['user_id'];
                $result = $db->sql_query($sql);
                include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                $messenger = new messenger(false);
                $email_tpl = $user_id ? 'profile_send_email' : 'email_notify';
                $mail_to_users = array();
开发者ID:html,项目名称:PI,代码行数:31,代码来源:memberlist.php

示例12: format_message

 /**
  */
 function format_message(&$text, $uid_param = '', $keep_bbcodes = true)
 {
     global $user;
     $uid = $uid_param ? $uid_param : '[0-9a-z]{5,}';
     // If there is a spoiler, remove the spoiler content.
     $search = '@\\[spoiler(?:=[^]]*)?:' . $uid . '\\](.*?)\\[/spoiler:' . $uid . '\\]@s';
     $replace = '[spoiler](' . $user->lang['NA'] . ')[/spoiler]';
     $text = preg_replace($search, $replace, $text);
     if ($keep_bbcodes) {
         // Strip unique ids out of BBCodes
         $text = preg_replace("#\\[(\\/?[a-z0-9\\*\\+\\-]+(?:=.*?)?(?::[a-z])?)(\\:?{$uid})\\]#", '[\\1]', $text);
         // If there is a URL between BBCode URL tags, then add spacing so
         // the email program won't think the BBCode is part of the URL.
         $text = preg_replace('@](http://.*?)\\[@', '] $1 [', $text);
     } else {
         // Change quotes
         $text = preg_replace('@\\[quote=(?:"|&quot;)([^"]*)(?:"|&quot;):' . $uid . '\\]@', "[quote=\"\$1\"]", $text);
         $text = preg_replace('@\\[code=([a-z]+):' . $uid . '\\]@', "[code=\$1]", $text);
         $text = preg_replace('@\\[(/)?(quote|code):' . $uid . '\\]@', "[\$1\$2]", $text);
         // Change lists (quick & dirty, no checking if we're actually in a list, much less if it's ordered or unordered)
         $text = str_replace('[*]', '* ', $text);
         $text = $uid_param ? str_replace('[*:' . $uid . ']', '* ', $text) : preg_replace('\\[\\*:' . $uid . ']', '* ', $text);
         // Change [url=http://www.example.com]Example[/url] to Example (http://www.example.com)
         $text = preg_replace('@\\[url=([^]]*):' . $uid . '\\]([^[]*)\\[/url:' . $uid . '\\]@', '$2 ($1)', $text);
         // Remove all remaining BBCodes
         //strip_bbcode($text, $uid_param); // This function replaces BBCodes with spaces, which we don't want
         $text = preg_replace("#\\[\\/?[a-z0-9\\*\\+\\-]+(?:=(?:&quot;.*&quot;|[^\\]]*))?(?::[a-z])?(\\:{$uid})\\]#", '', $text);
         $match = get_preg_expression('bbcode_htm');
         $replace = array('\\1', '\\1', '\\2', '\\1', '', '');
         $text = preg_replace($match, $replace, $text);
     }
     // Change HTML smiley images to text smilies
     $text = preg_replace('#<!-- s[^ >]* --><img src="[^"]*" alt="([^"]*)" title="[^"]*" /><!-- s[^ >]* -->#', ' $1 ', $text);
     // Change HTML links to text links
     $text = preg_replace('#<!-- [lmw] --><a .*?href="([^"]*)">.*?</a><!-- [lmw] -->#', '$1', $text);
     // Change HTML e-mail links to text links
     $text = preg_replace('#<!-- e --><a .*?href="[^"]*">(.*?)</a><!-- e -->#', '$1', $text);
     // Transform special BBCode characters into human-readable characters
     $transform = array('&lt;' => '<', '&gt;' => '>', '&#91;' => '[', '&#93;' => ']', '&#46;' => '.', '&#58;' => ':');
     $text = str_replace(array_keys($transform), array_values($transform), $text);
     // Remove backslashes that appear directly before single quotes
     $text = stripslashes(trim($text));
 }
开发者ID:sietf,项目名称:sietf.org,代码行数:45,代码来源:prime_notify.php

示例13: test_path_remove_dot_trailing_slash

 /**
  * @dataProvider data_path_remove_dot_trailing_slash
  */
 public function test_path_remove_dot_trailing_slash($input, $replace, $expected)
 {
     $this->assertSame($expected, preg_replace(get_preg_expression('path_remove_dot_trailing_slash'), $replace, $input));
 }
开发者ID:phpbb,项目名称:phpbb,代码行数:7,代码来源:get_preg_expression_test.php

示例14: test_url

	/**
	* @dataProvider url_test_data
	*/
	public function test_url($url, $expected)
	{
		$this->assertEquals($expected, preg_match('#^' . get_preg_expression('url') . '$#i', $url));
	}
开发者ID:naderman,项目名称:phpbb-orchestra,代码行数:7,代码来源:url_test.php

示例15: validate_generic_email

/**
 * Generic validation of e-mail address
 *
 * @param string $email
 * @return mixed
 */
function validate_generic_email($email)
{
    if (!preg_match('/^' . get_preg_expression('email') . '$/i', $email)) {
        return 'EMAIL_INVALID';
    }
    return false;
}
开发者ID:phpbb,项目名称:umil,代码行数:13,代码来源:create.php


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