本文整理汇总了PHP中get_preg_expression函数的典型用法代码示例。如果您正苦于以下问题:PHP get_preg_expression函数的具体用法?PHP get_preg_expression怎么用?PHP get_preg_expression使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_preg_expression函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 [email protected].
* 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('/(&|\\?)sid=[0-9a-f]{32}&/', '\\1', $url);
$url = preg_replace('/(&|\\?)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:", $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('/(&|\\?)sid=[0-9a-f]{32}/', '\\\\1', '\$3') . '\">' . preg_replace('/(&|\\?)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('&', '&', '\$2'), 0, 39) . ' ... ' . substr(str_replace('&', '&', '\$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('&', '&', '\$2'), 0, 39) . ' ... ' . substr(str_replace('&', '&', '\$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\", '\"', ''', '(', ')'), 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=(?:"|")([^"]*)(?:"|"):' . $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\\*\\+\\-]+(?:=(?:".*"|[^\\]]*))?(?::[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('<' => '<', '>' => '>', '[' => '[', ']' => ']', '.' => '.', ':' => ':');
$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
示例16: ip
private function ip()
{
// Why no forwarded_for et al? Well, too easily spoofed. With the results of my recent requests
// it's pretty clear that in the majority of cases you'll at least be left with a proxy/cache ip.
$this->ip = htmlspecialchars_decode($this->request->server('REMOTE_ADDR'));
$this->ip = preg_replace('# {2,}#', ' ', str_replace(',', ' ', $this->ip));
// split the list of IPs
$ips = explode(' ', trim($this->ip));
// Default IP if REMOTE_ADDR is invalid
$this->ip = '127.0.0.1';
foreach ($ips as $ip) {
if (function_exists('phpbb_ip_normalise')) {
// Normalise IP address
$ip = phpbb_ip_normalise($ip);
if (empty($ip)) {
// IP address is invalid.
break;
}
// IP address is valid.
$this->ip = $ip;
// Skip legacy code.
continue;
}
if (preg_match(get_preg_expression('ipv4'), $ip)) {
$this->ip = $ip;
} else {
if (preg_match(get_preg_expression('ipv6'), $ip)) {
// Quick check for IPv4-mapped address in IPv6
if (stripos($ip, '::ffff:') === 0) {
$ipv4 = substr($ip, 7);
if (preg_match(get_preg_expression('ipv4'), $ipv4)) {
$ip = $ipv4;
}
}
$this->ip = $ip;
} else {
// We want to use the last valid address in the chain
// Leave foreach loop when address is invalid
break;
}
}
}
return $this->ip;
}
开发者ID:bb3mobi,项目名称:bb3top,代码行数:44,代码来源:counter.php
示例17: strip_bbcode
function strip_bbcode(&$text, $uid = '')
{
if (!$uid) {
$uid = '[0-9a-z]{5,}';
}
$text = preg_replace("#\\[\\/?[a-z0-9\\*\\+\\-]+(?:=.*?)?(?::[a-z])?(\\:?{$uid})\\]#", ' ', $text);
$match = get_preg_expression('bbcode_htm');
$replace = array('\\1', '\\2', '\\1', '', '');
$text = preg_replace($match, $replace, $text);
}
开发者ID:patrickrolanddg,项目名称:dragonfly-tapatalk,代码行数:10,代码来源:mobiquo_common.php
示例18: setUp
public function setUp()
{
$this->regex = '#^' . get_preg_expression('email') . '$#i';
}
开发者ID:josh-js,项目名称:phpbb,代码行数:4,代码来源:email_test.php
示例19: session_begin
/**
* Start session management
*
* This is where all session activity begins. We gather various pieces of
* information from the client and server. We test to see if a session already
* exists. If it does, fine and dandy. If it doesn't we'll go on to create a
* new one ... pretty logical heh? We also examine the system load (if we're
* running on a system which makes such information readily available) and
* halt if it's above an admin definable limit.
*
* @param bool $update_session_page if true the session page gets updated.
* This can be set to circumvent certain scripts to update the users last visited page.
*/
function session_begin($update_session_page = true)
{
global $phpEx, $SID, $_SID, $_EXTRA_URL, $db, $config, $phpbb_root_path;
// Give us some basic information
$this->time_now = time();
$this->cookie_data = array('u' => 0, 'k' => '');
$this->update_session_page = $update_session_page;
$this->browser = !empty($_SERVER['HTTP_USER_AGENT']) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : '';
$this->referer = !empty($_SERVER['HTTP_REFERER']) ? htmlspecialchars((string) $_SERVER['HTTP_REFERER']) : '';
$this->forwarded_for = !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? (string) $_SERVER['HTTP_X_FORWARDED_FOR'] : '';
$this->host = $this->extract_current_hostname();
$this->page = $this->extract_current_page($phpbb_root_path);
// if the forwarded for header shall be checked we have to validate its contents
if ($config['forwarded_for_check']) {
$this->forwarded_for = preg_replace('#, +#', ', ', $this->forwarded_for);
// split the list of IPs
$ips = explode(', ', $this->forwarded_for);
foreach ($ips as $ip) {
// check IPv4 first, the IPv6 is hopefully only going to be used very seldomly
if (!empty($ip) && !preg_match(get_preg_expression('ipv4'), $ip) && !preg_match(get_preg_expression('ipv6'), $ip)) {
// contains invalid data, don't use the forwarded for header
$this->forwarded_for = '';
break;
}
}
} else {
$this->forwarded_for = '';
}
if (isset($_COOKIE[$config['cookie_name'] . '_sid']) || isset($_COOKIE[$config['cookie_name'] . '_u'])) {
$this->cookie_data['u'] = request_var($config['cookie_name'] . '_u', 0, false, true);
$this->cookie_data['k'] = request_var($config['cookie_name'] . '_k', '', false, true);
$this->session_id = request_var($config['cookie_name'] . '_sid', '', false, true);
$SID = defined('NEED_SID') ? '?sid=' . $this->session_id : '?sid=';
$_SID = defined('NEED_SID') ? $this->session_id : '';
if (empty($this->session_id)) {
$this->session_id = $_SID = request_var('sid', '');
$SID = '?sid=' . $this->session_id;
$this->cookie_data = array('u' => 0, 'k' => '');
}
} else {
$this->session_id = $_SID = request_var('sid', '');
$SID = '?sid=' . $this->session_id;
}
$_EXTRA_URL = array();
// Why no forwarded_for et al? Well, too easily spoofed. With the results of my recent requests
// it's pretty clear that in the majority of cases you'll at least be left with a proxy/cache ip.
$this->ip = !empty($_SERVER['REMOTE_ADDR']) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : '';
$this->load = false;
// Load limit check (if applicable)
if ($config['limit_load'] || $config['limit_search_load']) {
if (function_exists('sys_getloadavg') && ($load = sys_getloadavg()) || ($load = explode(' ', @file_get_contents('/proc/loadavg')))) {
$this->load = array_slice($load, 0, 1);
$this->load = floatval($this->load[0]);
} else {
set_config('limit_load', '0');
set_config('limit_search_load', '0');
}
}
// Is session_id is set or session_id is set and matches the url param if required
if (!empty($this->session_id) && (!defined('NEED_SID') || isset($_GET['sid']) && $this->session_id === $_GET['sid'])) {
$sql = 'SELECT u.*, s.*
FROM ' . SESSIONS_TABLE . ' s, ' . USERS_TABLE . " u\n\t\t\t\tWHERE s.session_id = '" . $db->sql_escape($this->session_id) . "'\n\t\t\t\t\tAND u.user_id = s.session_user_id";
$result = $db->sql_query($sql);
$this->data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
// Did the session exist in the DB?
if (isset($this->data['user_id'])) {
// Validate IP length according to admin ... enforces an IP
// check on bots if admin requires this
// $quadcheck = ($config['ip_check_bot'] && $this->data['user_type'] & USER_BOT) ? 4 : $config['ip_check'];
if (strpos($this->ip, ':') !== false && strpos($this->data['session_ip'], ':') !== false) {
$s_ip = short_ipv6($this->data['session_ip'], $config['ip_check']);
$u_ip = short_ipv6($this->ip, $config['ip_check']);
} else {
$s_ip = implode('.', array_slice(explode('.', $this->data['session_ip']), 0, $config['ip_check']));
$u_ip = implode('.', array_slice(explode('.', $this->ip), 0, $config['ip_check']));
}
$s_browser = $config['browser_check'] ? trim(strtolower(substr($this->data['session_browser'], 0, 149))) : '';
$u_browser = $config['browser_check'] ? trim(strtolower(substr($this->browser, 0, 149))) : '';
$s_forwarded_for = $config['forwarded_for_check'] ? substr($this->data['session_forwarded_for'], 0, 254) : '';
$u_forwarded_for = $config['forwarded_for_check'] ? substr($this->forwarded_for, 0, 254) : '';
// referer checks
// The @ before $config['referer_validation'] supp
|
请发表评论