Skip to content
Browse files

Updating all the regular expressions to use % as a delimiter. Before …

…we had a combination of /, #, and %. #250
  • Loading branch information...
1 parent 2e83328 commit b1deb69b8239f54f14e8eb7cdebb1a8afd4f6369 @reines reines committed Jun 5, 2011
View
14 admin_bans.php
@@ -192,21 +192,21 @@
message($lang_admin_bans['Must enter message']);
else if (strtolower($ban_user) == 'guest')
message($lang_admin_bans['Cannot ban guest message']);
-
+
// Make sure we're not banning an admin or moderator
if (!empty($ban_user))
{
$result = $db->query('SELECT group_id FROM '.$db->prefix.'users WHERE username=\''.$db->escape($ban_user).'\' AND id>1') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result))
{
$group_id = $db->result($result);
-
+
if ($group_id == PUN_ADMIN)
message(sprintf($lang_admin_bans['User is admin message'], pun_htmlspecialchars($ban_user)));
-
+
$result = $db->query('SELECT g_moderator FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to fetch group info', __FILE__, __LINE__, $db->error());
$is_moderator_group = $db->result($result);
-
+
if ($is_moderator_group)
message(sprintf($lang_admin_bans['User is mod message'], pun_htmlspecialchars($ban_user)));
}
@@ -215,7 +215,7 @@
// Validate IP/IP range (it's overkill, I know)
if ($ban_ip != '')
{
- $ban_ip = preg_replace('/\s{2,}/S', ' ', $ban_ip);
+ $ban_ip = preg_replace('%\s{2,}%S', ' ', $ban_ip);
$addresses = explode(' ', $ban_ip);
$addresses = array_map('pun_trim', $addresses);
@@ -244,7 +244,7 @@
{
$octets[$c] = (strlen($octets[$c]) > 1) ? ltrim($octets[$c], "0") : $octets[$c];
- if ($c > 3 || preg_match('/[^0-9]/', $octets[$c]) || intval($octets[$c]) > 255)
+ if ($c > 3 || preg_match('%[^0-9]%', $octets[$c]) || intval($octets[$c]) > 255)
message($lang_admin_bans['Invalid IP message']);
}
@@ -259,7 +259,7 @@
require PUN_ROOT.'include/email.php';
if ($ban_email != '' && !is_valid_email($ban_email))
{
- if (!preg_match('/^[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/', $ban_email))
+ if (!preg_match('%^[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$%', $ban_email))
message($lang_admin_bans['Invalid e-mail message']);
}
View
2 admin_categories.php
@@ -138,7 +138,7 @@
if ($cur_cat['name'] == '')
message($lang_admin_categories['Must enter name message']);
- if ($cur_cat['order'] == '' || preg_match('/[^0-9]/', $cur_cat['order']))
+ if ($cur_cat['order'] == '' || preg_match('%[^0-9]%', $cur_cat['order']))
message($lang_admin_categories['Must enter integer message']);
$db->query('UPDATE '.$db->prefix.'categories SET cat_name=\''.$db->escape($cur_cat['name']).'\', disp_position='.$cur_cat['order'].' WHERE id='.intval($cat_id)) or error('Unable to update category', __FILE__, __LINE__, $db->error());
View
2 admin_forums.php
@@ -128,7 +128,7 @@
foreach ($_POST['position'] as $forum_id => $disp_position)
{
$disp_position = trim($disp_position);
- if ($disp_position == '' || preg_match('/[^0-9]/', $disp_position))
+ if ($disp_position == '' || preg_match('%[^0-9]%', $disp_position))
message($lang_admin_forums['Must be integer message']);
$db->query('UPDATE '.$db->prefix.'forums SET disp_position='.$disp_position.' WHERE id='.intval($forum_id)) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
View
2 admin_index.php
@@ -70,7 +70,7 @@
$load_averages = @explode(' ', $load_averages);
$server_load = isset($load_averages[2]) ? $load_averages[0].' '.$load_averages[1].' '.$load_averages[2] : $lang_admin_index['Not available'];
}
-else if (!in_array(PHP_OS, array('WINNT', 'WIN32')) && preg_match('/averages?: ([0-9\.]+),?\s+([0-9\.]+),?\s+([0-9\.]+)/i', @exec('uptime'), $load_averages))
+else if (!in_array(PHP_OS, array('WINNT', 'WIN32')) && preg_match('%averages?: ([0-9\.]+),?\s+([0-9\.]+),?\s+([0-9\.]+)%i', @exec('uptime'), $load_averages))
$server_load = $load_averages[1].' '.$load_averages[2].' '.$load_averages[3];
else
$server_load = $lang_admin_index['Not available'];
View
2 admin_loader.php
@@ -19,7 +19,7 @@
// The plugin to load should be supplied via GET
$plugin = isset($_GET['plugin']) ? $_GET['plugin'] : '';
-if (!preg_match('/^AM?P_(\w*?)\.php$/i', $plugin))
+if (!preg_match('%^AM?P_(\w*?)\.php$%i', $plugin))
message($lang_common['Bad request']);
// AP_ == Admins only, AMP_ == admins and moderators
View
2 admin_maintenance.php
@@ -173,7 +173,7 @@
}
$prune_days = trim($_POST['req_prune_days']);
- if ($prune_days == '' || preg_match('/[^0-9]/', $prune_days))
+ if ($prune_days == '' || preg_match('%[^0-9]%', $prune_days))
message($lang_admin_maintenance['Days must be integer message']);
$prune_date = time() - ($prune_days * 86400);
View
2 admin_options.php
@@ -118,7 +118,7 @@
message($lang_admin_options['Invalid webmaster e-mail message']);
if ($form['mailing_list'] != '')
- $form['mailing_list'] = strtolower(preg_replace('/\s/S', '', $form['mailing_list']));
+ $form['mailing_list'] = strtolower(preg_replace('%\s%S', '', $form['mailing_list']));
// Make sure avatars_dir doesn't end with a slash
if (substr($form['avatars_dir'], -1) == '/')
View
4 admin_ranks.php
@@ -31,7 +31,7 @@
if ($rank == '')
message($lang_admin_ranks['Must enter title message']);
- if ($min_posts == '' || preg_match('/[^0-9]/', $min_posts))
+ if ($min_posts == '' || preg_match('%[^0-9]%', $min_posts))
message($lang_admin_ranks['Must be integer message']);
// Make sure there isn't already a rank with the same min_posts value
@@ -64,7 +64,7 @@
if ($rank == '')
message($lang_admin_ranks['Must enter title message']);
- if ($min_posts == '' || preg_match('/[^0-9]/', $min_posts))
+ if ($min_posts == '' || preg_match('%[^0-9]%', $min_posts))
message($lang_admin_ranks['Must be integer message']);
// Make sure there isn't already a rank with the same min_posts value
View
100 admin_users.php
@@ -125,7 +125,7 @@
{
$ip = trim($_GET['show_users']);
- if (!@preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $ip) && !@preg_match('/^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/', $ip))
+ if (!@preg_match('%^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$%', $ip) && !@preg_match('%^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$%', $ip))
message($lang_admin_users['Bad IP message']);
// Fetch user count
@@ -260,26 +260,26 @@
message($lang_common['No permission']);
confirm_referrer('admin_users.php');
-
+
if (isset($_POST['users']))
{
$user_ids = is_array($_POST['users']) ? array_keys($_POST['users']) : explode(',', $_POST['users']);
$user_ids = array_map('intval', $user_ids);
-
+
// Delete invalid IDs
$user_ids = array_diff($user_ids, array(0, 1));
}
else
$user_ids = array();
-
+
if (empty($user_ids))
message($lang_admin_users['No users selected']);
-
+
// Are we trying to batch move any admins?
$result = $db->query('SELECT COUNT(*) FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).') AND group_id='.PUN_ADMIN) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
if ($db->result($result) > 0)
message($lang_admin_users['No move admins message']);
-
+
// Fetch all user groups
$all_groups = array();
$result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id NOT IN ('.PUN_GUEST.','.PUN_ADMIN.') ORDER BY g_title ASC') or error('Unable to fetch groups', __FILE__, __LINE__, $db->error());
@@ -289,22 +289,22 @@
if (isset($_POST['move_users_comply']))
{
$new_group = isset($_POST['new_group']) && isset($all_groups[$_POST['new_group']]) ? $_POST['new_group'] : message($lang_admin_users['Invalid group message']);
-
+
// Is the new group a moderator group?
$result = $db->query('SELECT g_moderator FROM '.$db->prefix.'groups WHERE g_id='.$new_group) or error('Unable to fetch group info', __FILE__, __LINE__, $db->error());
$new_group_mod = $db->result($result);
-
+
// Fetch user groups
$user_groups = array();
$result = $db->query('SELECT id, group_id FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).')') or error('Unable to fetch user groups', __FILE__, __LINE__, $db->error());
while ($cur_user = $db->fetch_assoc($result))
{
if (!isset($user_groups[$cur_user['group_id']]))
$user_groups[$cur_user['group_id']] = array();
-
+
$user_groups[$cur_user['group_id']][] = $cur_user['id'];
}
-
+
// Are any users moderators?
$group_ids = array_keys($user_groups);
$result = $db->query('SELECT g_id, g_moderator FROM '.$db->prefix.'groups WHERE g_id IN ('.implode(',', $group_ids).')') or error('Unable to fetch group moderators', __FILE__, __LINE__, $db->error());
@@ -313,33 +313,33 @@
if ($cur_group['g_moderator'] == '0')
unset($user_groups[$cur_group['g_id']]);
}
-
+
if (!empty($user_groups) && $new_group != PUN_ADMIN && $new_group_mod != '1')
{
// Fetch forum list and clean up their moderator list
$result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
while ($cur_forum = $db->fetch_assoc($result))
{
$cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array();
-
+
foreach ($user_groups as $group_users)
$cur_moderators = array_diff($cur_moderators, $group_users);
-
+
$cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL';
$db->query('UPDATE '.$db->prefix.'forums SET moderators='.$cur_moderators.' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
}
}
-
+
// Change user group
$db->query('UPDATE '.$db->prefix.'users SET group_id='.$new_group.' WHERE id IN ('.implode(',', $user_ids).')') or error('Unable to change user group', __FILE__, __LINE__, $db->error());
-
+
redirect('admin_users.php', $lang_admin_users['Users move redirect']);
}
$page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users'], $lang_admin_users['Move users']);
define('PUN_ACTIVE_PAGE', 'admin');
require PUN_ROOT.'header.php';
-
+
generate_admin_menu('users');
?>
@@ -386,21 +386,21 @@
message($lang_common['No permission']);
confirm_referrer('admin_users.php');
-
+
if (isset($_POST['users']))
{
$user_ids = is_array($_POST['users']) ? array_keys($_POST['users']) : explode(',', $_POST['users']);
$user_ids = array_map('intval', $user_ids);
-
+
// Delete invalid IDs
$user_ids = array_diff($user_ids, array(0, 1));
}
else
$user_ids = array();
-
+
if (empty($user_ids))
message($lang_admin_users['No users selected']);
-
+
// Are we trying to delete any admins?
$result = $db->query('SELECT COUNT(*) FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).') AND group_id='.PUN_ADMIN) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
if ($db->result($result) > 0)
@@ -415,10 +415,10 @@
{
if (!isset($user_groups[$cur_user['group_id']]))
$user_groups[$cur_user['group_id']] = array();
-
+
$user_groups[$cur_user['group_id']][] = $cur_user['id'];
}
-
+
// Are any users moderators?
$group_ids = array_keys($user_groups);
$result = $db->query('SELECT g_id, g_moderator FROM '.$db->prefix.'groups WHERE g_id IN ('.implode(',', $group_ids).')') or error('Unable to fetch group moderators', __FILE__, __LINE__, $db->error());
@@ -427,7 +427,7 @@
if ($cur_group['g_moderator'] == '0')
unset($user_groups[$cur_group['g_id']]);
}
-
+
// Fetch forum list and clean up their moderator list
$result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
while ($cur_forum = $db->fetch_assoc($result))
@@ -436,18 +436,18 @@
foreach ($user_groups as $group_users)
$cur_moderators = array_diff($cur_moderators, $group_users);
-
+
$cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL';
$db->query('UPDATE '.$db->prefix.'forums SET moderators='.$cur_moderators.' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
}
-
+
// Delete any subscriptions
$db->query('DELETE FROM '.$db->prefix.'topic_subscriptions WHERE user_id IN ('.implode(',', $user_ids).')') or error('Unable to delete topic subscriptions', __FILE__, __LINE__, $db->error());
$db->query('DELETE FROM '.$db->prefix.'forum_subscriptions WHERE user_id IN ('.implode(',', $user_ids).')') or error('Unable to delete forum subscriptions', __FILE__, __LINE__, $db->error());
-
+
// Remove them from the online list (if they happen to be logged in)
$db->query('DELETE FROM '.$db->prefix.'online WHERE user_id IN ('.implode(',', $user_ids).')') or error('Unable to remove users from online list', __FILE__, __LINE__, $db->error());
-
+
// Should we delete all posts made by these users?
if (isset($_POST['delete_posts']))
{
@@ -482,7 +482,7 @@
// Delete user avatars
foreach ($user_ids as $user_id)
delete_avatar($user_id);
-
+
// Regenerate the users info cache
if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
require PUN_ROOT.'include/cache.php';
@@ -495,7 +495,7 @@
$page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users'], $lang_admin_users['Delete users']);
define('PUN_ACTIVE_PAGE', 'admin');
require PUN_ROOT.'header.php';
-
+
generate_admin_menu('users');
?>
@@ -535,85 +535,85 @@
message($lang_common['No permission']);
confirm_referrer('admin_users.php');
-
+
if (isset($_POST['users']))
{
$user_ids = is_array($_POST['users']) ? array_keys($_POST['users']) : explode(',', $_POST['users']);
$user_ids = array_map('intval', $user_ids);
-
+
// Delete invalid IDs
$user_ids = array_diff($user_ids, array(0, 1));
}
else
$user_ids = array();
-
+
if (empty($user_ids))
message($lang_admin_users['No users selected']);
-
+
// Are we trying to ban any admins?
$result = $db->query('SELECT COUNT(*) FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).') AND group_id='.PUN_ADMIN) or error('Unable to fetch group info', __FILE__, __LINE__, $db->error());
if ($db->result($result) > 0)
message($lang_admin_users['No ban admins message']);
-
+
// Also, we cannot ban moderators
$result = $db->query('SELECT COUNT(*) FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON u.group_id=g.g_id WHERE g.g_moderator=1 AND u.id IN ('.implode(',', $user_ids).')') or error('Unable to fetch moderator group info', __FILE__, __LINE__, $db->error());
if ($db->result($result) > 0)
message($lang_admin_users['No ban mods message']);
-
+
if (isset($_POST['ban_users_comply']))
{
$ban_message = pun_trim($_POST['ban_message']);
$ban_expire = pun_trim($_POST['ban_expire']);
$ban_the_ip = isset($_POST['ban_the_ip']) ? intval($_POST['ban_the_ip']) : 0;
-
+
if ($ban_expire != '' && $ban_expire != 'Never')
{
$ban_expire = strtotime($ban_expire.' GMT');
-
+
if ($ban_expire == -1 || !$ban_expire)
message($lang_admin_users['Invalid date message'].' '.$lang_admin_users['Invalid date reasons']);
-
+
$diff = ($pun_user['timezone'] + $pun_user['dst']) * 3600;
$ban_expire -= $diff;
-
+
if ($ban_expire <= time())
message($lang_admin_users['Invalid date message'].' '.$lang_admin_users['Invalid date reasons']);
}
else
$ban_expire = 'NULL';
-
+
$ban_message = ($ban_message != '') ? '\''.$db->escape($ban_message).'\'' : 'NULL';
-
+
// Fetch user information
$user_info = array();
$result = $db->query('SELECT id, username, email, registration_ip FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).')') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
while ($cur_user = $db->fetch_assoc($result))
$user_info[$cur_user['id']] = array('username' => $cur_user['username'], 'email' => $cur_user['email'], 'ip' => $cur_user['registration_ip']);
-
+
// Overwrite the registration IP with one from the last post (if it exists)
if ($ban_the_ip != 0)
{
$result = $db->query('SELECT p.poster_id, p.poster_ip FROM '.$db->prefix.'posts AS p INNER JOIN (SELECT MAX(id) AS id FROM '.$db->prefix.'posts WHERE poster_id IN ('.implode(',', $user_ids).') GROUP BY poster_id) AS i ON p.id=i.id') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
while ($cur_address = $db->fetch_assoc($result))
$user_info[$cur_address['poster_id']]['ip'] = $cur_address['poster_ip'];
}
-
+
// And insert the bans!
foreach ($user_ids as $user_id)
{
$ban_username = '\''.$db->escape($user_info[$user_id]['username']).'\'';
$ban_email = '\''.$db->escape($user_info[$user_id]['email']).'\'';
$ban_ip = ($ban_the_ip != 0) ? '\''.$db->escape($user_info[$user_id]['ip']).'\'' : 'NULL';
-
+
$db->query('INSERT INTO '.$db->prefix.'bans (username, ip, email, message, expire, ban_creator) VALUES('.$ban_username.', '.$ban_ip.', '.$ban_email.', '.$ban_message.', '.$ban_expire.', '.$pun_user['id'].')') or error('Unable to add ban', __FILE__, __LINE__, $db->error());
}
-
+
// Regenerate the bans cache
if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
require PUN_ROOT.'include/cache.php';
-
+
generate_bans_cache();
-
+
redirect('admin_users.php', $lang_admin_users['Users banned redirect']);
}
@@ -696,7 +696,7 @@
$query_str[] = 'direction='.$direction;
$query_str[] = 'user_group='.$user_group;
- if (preg_match('/[^0-9]/', $posts_greater.$posts_less))
+ if (preg_match('%[^0-9]%', $posts_greater.$posts_less))
message($lang_admin_users['Non numeric message']);
// Try to convert date/time to timestamps
@@ -797,7 +797,7 @@
// Generate paging links
$paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'admin_users.php?find_user=&amp;'.implode('&amp;', $query_str));
-
+
// Some helper variables for permissions
$can_delete = $can_move = $pun_user['g_id'] == PUN_ADMIN;
$can_ban = $pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_moderator'] == '1' && $pun_user['g_mod_ban_users'] == '1');
@@ -867,7 +867,7 @@
<td class="tc5"><?php echo ($user_data['admin_note'] != '') ? pun_htmlspecialchars($user_data['admin_note']) : '&#160;' ?></td>
<td class="tcr"><?php echo $actions ?></td>
<?php if ($can_action): ?> <td class="tcmod"><input type="checkbox" name="users[<?php echo $user_data['id'] ?>]" value="1" /></td>
-<?php endif; ?>
+<?php endif; ?>
</tr>
<?php
View
14 db_update.php
@@ -277,8 +277,8 @@ function convert_to_utf8(&$str, $old_charset)
$str = html_entity_decode($str, ENT_QUOTES, 'UTF-8');
// Replace numeric entities
- $str = preg_replace_callback('/&#([0-9]+);/', 'utf8_callback_1', $str);
- $str = preg_replace_callback('/&#x([a-f0-9]+);/i', 'utf8_callback_2', $str);
+ $str = preg_replace_callback('%&#([0-9]+);%', 'utf8_callback_1', $str);
+ $str = preg_replace_callback('%&#x([a-f0-9]+);%i', 'utf8_callback_2', $str);
// Remove "bad" characters
$str = remove_bad_characters($str);
@@ -339,7 +339,7 @@ function alter_table_utf8($table)
$allow_null = ($cur_column['Null'] == 'YES');
$collate = (substr($cur_column['Collation'], -3) == 'bin') ? 'utf8_bin' : 'utf8_general_ci';
- $db->alter_field($table, $cur_column['Field'], preg_replace('/'.$type.'/i', $types[$type], $cur_column['Type']), $allow_null, $cur_column['Default'], null, true) or error('Unable to alter field to binary', __FILE__, __LINE__, $db->error());
+ $db->alter_field($table, $cur_column['Field'], preg_replace('%'.$type.'%i', $types[$type], $cur_column['Type']), $allow_null, $cur_column['Default'], null, true) or error('Unable to alter field to binary', __FILE__, __LINE__, $db->error());
$db->alter_field($table, $cur_column['Field'], $cur_column['Type'].' CHARACTER SET utf8 COLLATE '.$collate, $allow_null, $cur_column['Default'], null, true) or error('Unable to alter field to utf8', __FILE__, __LINE__, $db->error());
}
}
@@ -719,7 +719,7 @@ function convert_table_utf8($table, $callback, $old_charset, $key = null, $start
{
// Make an educated guess regarding base_url
$base_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'; // protocol
- $base_url .= preg_replace('/:(80|443)$/', '', $_SERVER['HTTP_HOST']); // host[:port]
+ $base_url .= preg_replace('%:(80|443)$%', '', $_SERVER['HTTP_HOST']); // host[:port]
$base_url .= str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])); // path
}
@@ -1458,14 +1458,14 @@ function _error_users($cur_user)
$errors[$id][] = $lang_update['Username too long error'];
else if (!strcasecmp($username, 'Guest'))
$errors[$id][] = $lang_update['Username Guest reserved error'];
- else if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $username) || preg_match('/((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))/', $username))
+ else if (preg_match('%[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}%', $username) || preg_match('%((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))%', $username))
$errors[$id][] = $lang_update['Username IP format error'];
else if ((strpos($username, '[') !== false || strpos($username, ']') !== false) && strpos($username, '\'') !== false && strpos($username, '"') !== false)
$errors[$id][] = $lang_update['Username bad characters error'];
- else if (preg_match('/(?:\[\/?(?:b|u|s|ins|del|em|i|h|colou?r|quote|code|img|url|email|list|\*)\]|\[(?:img|url|quote|list)=)/i', $username))
+ else if (preg_match('%(?:\[/?(?:b|u|s|ins|del|em|i|h|colou?r|quote|code|img|url|email|list|\*)\]|\[(?:img|url|quote|list)=)%i', $username))
$errors[$id][] = $lang_update['Username BBCode error'];
- $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE (UPPER(username)=UPPER(\''.$db->escape($username).'\') OR UPPER(username)=UPPER(\''.$db->escape(ucp_preg_replace('/[^\p{L}\p{N}]/u', '', $username)).'\')) AND id>1') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
+ $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE (UPPER(username)=UPPER(\''.$db->escape($username).'\') OR UPPER(username)=UPPER(\''.$db->escape(ucp_preg_replace('%[^\p{L}\p{N}]%u', '', $username)).'\')) AND id>1') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result))
{
View
4 header.php
@@ -41,7 +41,7 @@
$tpl_main = file_get_contents($tpl_file);
// START SUBST - <pun_include "*">
-preg_match_all('#<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">#', $tpl_main, $pun_includes, PREG_SET_ORDER);
+preg_match_all('%<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">%i', $tpl_main, $pun_includes, PREG_SET_ORDER);
foreach ($pun_includes as $cur_include)
{
@@ -212,7 +212,7 @@ function process_form(the_form)
// Are there any additional navlinks we should insert into the array before imploding it?
if ($pun_user['g_read_board'] == '1' && $pun_config['o_additional_navlinks'] != '')
{
- if (preg_match_all('#([0-9]+)\s*=\s*(.*?)\n#s', $pun_config['o_additional_navlinks']."\n", $extra_links))
+ if (preg_match_all('%([0-9]+)\s*=\s*(.*?)\n%s', $pun_config['o_additional_navlinks']."\n", $extra_links))
{
// Insert any additional links into the $links array (at the correct index)
$num_links = count($extra_links[1]);
View
2 include/cache.php
@@ -183,7 +183,7 @@ function generate_censoring_cache()
for ($i = 0; $i < $num_words; $i++)
{
list($search_for[$i], $replace_with[$i]) = $db->fetch_row($result);
- $search_for[$i] = '/(?<=[^\p{L}\p{N}])('.str_replace('\*', '[\p{L}\p{N}]*?', preg_quote($search_for[$i], '/')).')(?=[^\p{L}\p{N}])/iu';
+ $search_for[$i] = '%(?<=[^\p{L}\p{N}])('.str_replace('\*', '[\p{L}\p{N}]*?', preg_quote($search_for[$i], '%')).')(?=[^\p{L}\p{N}])%iu';
}
// Output censored words as PHP code
View
4 include/dblayer/mysql.php
@@ -24,7 +24,7 @@ class DBLayer
var $error_msg = 'Unknown';
var $datatype_transformations = array(
- '/^SERIAL$/' => 'INT(10) UNSIGNED AUTO_INCREMENT'
+ '%^SERIAL$%' => 'INT(10) UNSIGNED AUTO_INCREMENT'
);
@@ -204,7 +204,7 @@ function get_version()
return array(
'name' => 'MySQL Standard',
- 'version' => preg_replace('/^([^-]+).*$/', '\\1', $this->result($result))
+ 'version' => preg_replace('%^([^-]+).*$%', '\\1', $this->result($result))
);
}
View
4 include/dblayer/mysql_innodb.php
@@ -25,7 +25,7 @@ class DBLayer
var $error_msg = 'Unknown';
var $datatype_transformations = array(
- '/^SERIAL$/' => 'INT(10) UNSIGNED AUTO_INCREMENT'
+ '%^SERIAL$%' => 'INT(10) UNSIGNED AUTO_INCREMENT'
);
@@ -218,7 +218,7 @@ function get_version()
return array(
'name' => 'MySQL Standard (InnoDB)',
- 'version' => preg_replace('/^([^-]+).*$/', '\\1', $this->result($result))
+ 'version' => preg_replace('%^([^-]+).*$%', '\\1', $this->result($result))
);
}
View
4 include/dblayer/mysqli.php
@@ -24,7 +24,7 @@ class DBLayer
var $error_msg = 'Unknown';
var $datatype_transformations = array(
- '/^SERIAL$/' => 'INT(10) UNSIGNED AUTO_INCREMENT'
+ '%^SERIAL$%' => 'INT(10) UNSIGNED AUTO_INCREMENT'
);
@@ -211,7 +211,7 @@ function get_version()
return array(
'name' => 'MySQL Improved',
- 'version' => preg_replace('/^([^-]+).*$/', '\\1', $this->result($result))
+ 'version' => preg_replace('%^([^-]+).*$%', '\\1', $this->result($result))
);
}
View
4 include/dblayer/mysqli_innodb.php
@@ -25,7 +25,7 @@ class DBLayer
var $error_msg = 'Unknown';
var $datatype_transformations = array(
- '/^SERIAL$/' => 'INT(10) UNSIGNED AUTO_INCREMENT'
+ '%^SERIAL$%' => 'INT(10) UNSIGNED AUTO_INCREMENT'
);
@@ -224,7 +224,7 @@ function get_version()
return array(
'name' => 'MySQL Improved (InnoDB)',
- 'version' => preg_replace('/^([^-]+).*$/', '\\1', $this->result($result))
+ 'version' => preg_replace('%^([^-]+).*$%', '\\1', $this->result($result))
);
}
View
18 include/dblayer/pgsql.php
@@ -26,12 +26,12 @@ class DBLayer
var $error_msg = 'Unknown';
var $datatype_transformations = array(
- '/^(TINY|SMALL)INT( )?(\\([0-9]+\\))?( )?(UNSIGNED)?$/i' => 'SMALLINT',
- '/^(MEDIUM)?INT( )?(\\([0-9]+\\))?( )?(UNSIGNED)?$/i' => 'INTEGER',
- '/^BIGINT( )?(\\([0-9]+\\))?( )?(UNSIGNED)?$/i' => 'BIGINT',
- '/^(TINY|MEDIUM|LONG)?TEXT$/i' => 'TEXT',
- '/^DOUBLE( )?(\\([0-9,]+\\))?( )?(UNSIGNED)?$/i' => 'DOUBLE PRECISION',
- '/^FLOAT( )?(\\([0-9]+\\))?( )?(UNSIGNED)?$/i' => 'REAL'
+ '%^(TINY|SMALL)INT( )?(\\([0-9]+\\))?( )?(UNSIGNED)?$%i' => 'SMALLINT',
+ '%^(MEDIUM)?INT( )?(\\([0-9]+\\))?( )?(UNSIGNED)?$%i' => 'INTEGER',
+ '%^BIGINT( )?(\\([0-9]+\\))?( )?(UNSIGNED)?$%i' => 'BIGINT',
+ '%^(TINY|MEDIUM|LONG)?TEXT$%i' => 'TEXT',
+ '%^DOUBLE( )?(\\([0-9,]+\\))?( )?(UNSIGNED)?$%i' => 'DOUBLE PRECISION',
+ '%^FLOAT( )?(\\([0-9]+\\))?( )?(UNSIGNED)?$%i' => 'REAL'
);
@@ -100,7 +100,7 @@ function end_transaction()
function query($sql, $unbuffered = false) // $unbuffered is ignored since there is no pgsql_unbuffered_query()
{
if (strrpos($sql, 'LIMIT') !== false)
- $sql = preg_replace('#LIMIT ([0-9]+),([ 0-9]+)#', 'LIMIT \\2 OFFSET \\1', $sql);
+ $sql = preg_replace('%LIMIT ([0-9]+),([ 0-9]+)%', 'LIMIT \\2 OFFSET \\1', $sql);
if (defined('PUN_SHOW_QUERIES'))
$q_start = get_microtime();
@@ -173,7 +173,7 @@ function insert_id()
if ($query_id && $this->last_query_text[$query_id] != '')
{
- if (preg_match('/^INSERT INTO ([a-z0-9\_\-]+)/is', $this->last_query_text[$query_id], $table_name))
+ if (preg_match('%^INSERT INTO ([a-z0-9\_\-]+)%is', $this->last_query_text[$query_id], $table_name))
{
// Hack (don't ask)
if (substr($table_name[1], -6) == 'groups')
@@ -266,7 +266,7 @@ function get_version()
return array(
'name' => 'PostgreSQL',
- 'version' => preg_replace('/^[^0-9]+([^\s,-]+).*$/', '\\1', $this->result($result))
+ 'version' => preg_replace('%^[^0-9]+([^\s,-]+).*$%', '\\1', $this->result($result))
);
}
View
8 include/dblayer/sqlite.php
@@ -25,9 +25,9 @@ class DBLayer
var $error_msg = 'Unknown';
var $datatype_transformations = array(
- '/^SERIAL$/' => 'INTEGER',
- '/^(TINY|SMALL|MEDIUM|BIG)?INT( )?(\\([0-9]+\\))?( )?(UNSIGNED)?$/i' => 'INTEGER',
- '/^(TINY|MEDIUM|LONG)?TEXT$/i' => 'TEXT'
+ '%^SERIAL$%' => 'INTEGER',
+ '%^(TINY|SMALL|MEDIUM|BIG)?INT( )?(\\([0-9]+\\))?( )?(UNSIGNED)?$%i' => 'INTEGER',
+ '%^(TINY|MEDIUM|LONG)?TEXT$%i' => 'TEXT'
);
@@ -279,7 +279,7 @@ function field_exists($table_name, $field_name, $no_prefix = false)
if (!$this->num_rows($result))
return false;
- return preg_match('/[\r\n]'.preg_quote($field_name).' /', $this->result($result));
+ return preg_match('%[\r\n]'.preg_quote($field_name, '%').' %', $this->result($result));
}
View
14 include/email.php
@@ -20,7 +20,7 @@ function is_valid_email($email)
if (strlen($email) > 80)
return false;
- return preg_match('/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|("[^"]+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-zA-Z\d\-]+\.)+[a-zA-Z]{2,}))$/', $email);
+ return preg_match('%^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|("[^"]+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-zA-Z\d\-]+\.)+[a-zA-Z]{2,}))$%', $email);
}
@@ -67,12 +67,12 @@ function pun_mail($to, $subject, $message, $reply_to_email = '', $reply_to_name
$from_email = $pun_config['o_webmaster_email'];
// Do a little spring cleaning
- $to = pun_trim(preg_replace('#[\n\r]+#s', '', $to));
- $subject = pun_trim(preg_replace('#[\n\r]+#s', '', $subject));
- $from_email = pun_trim(preg_replace('#[\n\r:]+#s', '', $from_email));
- $from_name = pun_trim(preg_replace('#[\n\r:]+#s', '', str_replace('"', '', $from_name)));
- $reply_to_email = pun_trim(preg_replace('#[\n\r:]+#s', '', $reply_to_email));
- $reply_to_name = pun_trim(preg_replace('#[\n\r:]+#s', '', str_replace('"', '', $reply_to_name)));
+ $to = pun_trim(preg_replace('%[\n\r]+%s', '', $to));
+ $subject = pun_trim(preg_replace('%[\n\r]+%s', '', $subject));
+ $from_email = pun_trim(preg_replace('%[\n\r:]+%s', '', $from_email));
+ $from_name = pun_trim(preg_replace('%[\n\r:]+%s', '', str_replace('"', '', $from_name)));
+ $reply_to_email = pun_trim(preg_replace('%[\n\r:]+%s', '', $reply_to_email));
+ $reply_to_name = pun_trim(preg_replace('%[\n\r:]+%s', '', str_replace('"', '', $reply_to_name)));
// Set up some headers to take advantage of UTF-8
$from = '"'.encode_mail_text($from_name).'" <'.$from_email.'>';
View
18 include/functions.php
@@ -26,7 +26,7 @@ function check_cookie(&$pun_user)
$now = time();
// If the cookie is set and it matches the correct pattern, then read the values from it
- if (isset($_COOKIE[$cookie_name]) && preg_match('/^(\d+)\|([0-9a-fA-F]+)\|(\d+)\|([0-9a-fA-F]+)$/', $_COOKIE[$cookie_name], $matches))
+ if (isset($_COOKIE[$cookie_name]) && preg_match('%^(\d+)\|([0-9a-fA-F]+)\|(\d+)\|([0-9a-fA-F]+)$%', $_COOKIE[$cookie_name], $matches))
{
$cookie = array(
'user_id' => intval($matches[1]),
@@ -428,7 +428,7 @@ function check_username($username, $exclude_id = null)
global $db, $pun_config, $errors, $lang_prof_reg, $lang_register, $lang_common, $pun_bans;
// Convert multiple whitespace characters into one (to prevent people from registering with indistinguishable usernames)
- $username = preg_replace('#\s+#s', ' ', $username);
+ $username = preg_replace('%\s+%s', ' ', $username);
// Validate username
if (pun_strlen($username) < 2)
@@ -437,11 +437,11 @@ function check_username($username, $exclude_id = null)
$errors[] = $lang_prof_reg['Username too long'];
else if (!strcasecmp($username, 'Guest') || !strcasecmp($username, $lang_common['Guest']))
$errors[] = $lang_prof_reg['Username guest'];
- else if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $username) || preg_match('/((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))/', $username))
+ else if (preg_match('%[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}%', $username) || preg_match('%((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))%', $username))
$errors[] = $lang_prof_reg['Username IP'];
else if ((strpos($username, '[') !== false || strpos($username, ']') !== false) && strpos($username, '\'') !== false && strpos($username, '"') !== false)
$errors[] = $lang_prof_reg['Username reserved chars'];
- else if (preg_match('/(?:\[\/?(?:b|u|s|ins|del|em|i|h|colou?r|quote|code|img|url|email|list|\*|topic|post|forum|user)\]|\[(?:img|url|quote|list)=)/i', $username))
+ else if (preg_match('%(?:\[/?(?:b|u|s|ins|del|em|i|h|colou?r|quote|code|img|url|email|list|\*|topic|post|forum|user)\]|\[(?:img|url|quote|list)=)%i', $username))
$errors[] = $lang_prof_reg['Username BBCode'];
// Check username for any censored words
@@ -451,7 +451,7 @@ function check_username($username, $exclude_id = null)
// Check that the username (or a too similar username) is not already registered
$query = ($exclude_id) ? ' AND id!='.$exclude_id : '';
- $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE (UPPER(username)=UPPER(\''.$db->escape($username).'\') OR UPPER(username)=UPPER(\''.$db->escape(ucp_preg_replace('/[^\p{L}\p{N}]/u', '', $username)).'\')) AND id>1'.$query) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
+ $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE (UPPER(username)=UPPER(\''.$db->escape($username).'\') OR UPPER(username)=UPPER(\''.$db->escape(ucp_preg_replace('%[^\p{L}\p{N}]%u', '', $username)).'\')) AND id>1'.$query) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result))
{
@@ -1224,7 +1224,7 @@ function maintenance_message()
$tpl_maint = file_get_contents($tpl_file);
// START SUBST - <pun_include "*">
- preg_match_all('#<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">#', $tpl_maint, $pun_includes, PREG_SET_ORDER);
+ preg_match_all('%<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">%i', $tpl_maint, $pun_includes, PREG_SET_ORDER);
foreach ($pun_includes as $cur_include)
{
@@ -1314,7 +1314,7 @@ function redirect($destination_url, $message)
$destination_url = get_base_url(true).'/'.$destination_url;
// Do a little spring cleaning
- $destination_url = preg_replace('/([\r\n])|(%0[ad])|(;\s*data\s*:)/i', '', $destination_url);
+ $destination_url = preg_replace('%([\r\n])|(\%0[ad])|(;\s*data\s*:)%i', '', $destination_url);
// If the delay is 0 seconds, we might as well skip the redirect all together
if ($pun_config['o_redirect_delay'] == '0')
@@ -1343,7 +1343,7 @@ function redirect($destination_url, $message)
$tpl_redir = file_get_contents($tpl_file);
// START SUBST - <pun_include "*">
- preg_match_all('#<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">#', $tpl_redir, $pun_includes, PREG_SET_ORDER);
+ preg_match_all('%<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">%i', $tpl_redir, $pun_includes, PREG_SET_ORDER);
foreach ($pun_includes as $cur_include)
{
@@ -1627,7 +1627,7 @@ function remove_bad_characters($array)
$array = utf8_bad_strip($array);
// Remove control characters
- $array = preg_replace('/[\x{00}-\x{08}\x{0b}-\x{0c}\x{0e}-\x{1f}]/', '', $array);
+ $array = preg_replace('%[\x{00}-\x{08}\x{0b}-\x{0c}\x{0e}-\x{1f}]%', '', $array);
// Replace some "bad" characters
$array = str_replace(array_keys($bad_utf8_chars), array_values($bad_utf8_chars), $array);
View
72 include/parser.php
@@ -150,7 +150,7 @@ function strip_empty_bbcode($text, &$errors)
}
// Remove empty tags
- while (($new_text = preg_replace('/\[(b|u|s|ins|del|em|i|h|colou?r|quote|img|url|email|list|topic|post|forum|user)(?:\=[^\]]*)?\]\s*\[\/\1\]/', '', $text)) !== NULL)
+ while (($new_text = preg_replace('%\[(b|u|s|ins|del|em|i|h|colou?r|quote|img|url|email|list|topic|post|forum|user)(?:\=[^\]]*)?\]\s*\[/\1\]%', '', $text)) !== NULL)
{
if ($new_text != $text)
$text = $new_text;
@@ -174,7 +174,7 @@ function strip_empty_bbcode($text, &$errors)
}
// Remove empty code tags
- while (($new_text = preg_replace('/\[(code)\]\s*\[\/\1\]/', '', $text)) !== NULL)
+ while (($new_text = preg_replace('%\[(code)\]\s*\[/\1\]%', '', $text)) !== NULL)
{
if ($new_text != $text)
$text = $new_text;
@@ -229,7 +229,7 @@ function preparse_tags($text, &$errors, $is_signature = false)
// Tags we can automatically fix bad nesting
$tags_fix = array('quote', 'b', 'i', 'u', 's', 'ins', 'del', 'em', 'color', 'colour', 'url', 'email', 'h', 'topic', 'post', 'forum', 'user');
- $split_text = preg_split("/(\[[\*a-zA-Z0-9-\/]*?(?:=.*?)?\])/", $text, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
+ $split_text = preg_split('%(\[[\*a-zA-Z0-9-/]*?(?:=.*?)?\])%', $text, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
$open_tags = array('fluxbb-bbcode');
$open_args = array('');
@@ -259,7 +259,7 @@ function preparse_tags($text, &$errors, $is_signature = false)
if (in_array($open_tags[$opened_tag], $tags_inline) && strpos($current, "\n") !== false)
{
// Deal with new lines
- $split_current = preg_split("/(\n\n+)/", $current, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
+ $split_current = preg_split('%(\n\n+)%', $current, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
$current = '';
if (!pun_trim($split_current[0], "\n")) // The first part is a linebreak so we need to handle any open tags first
@@ -556,7 +556,7 @@ function preparse_tags($text, &$errors, $is_signature = false)
// Remove quotes from arguments for certain tags
if (strpos($current, '=') !== false && in_array($current_tag, $tags_quotes))
{
- $current = preg_replace('#\['.$current_tag.'=("|\'|)(.*?)\\1\]\s*#i', '['.$current_tag.'=$2]', $current);
+ $current = preg_replace('%\['.$current_tag.'=("|\'|)(.*?)\\1\]\s*%i', '['.$current_tag.'=$2]', $current);
}
if (in_array($current_tag, array_keys($tags_limit_bbcode)))
@@ -719,9 +719,9 @@ function do_bbcode($text, $is_signature = false)
if (strpos($text, '[quote') !== false)
{
- $text = preg_replace('#\[quote\]\s*#', '</p><div class="quotebox"><blockquote><div><p>', $text);
- $text = preg_replace('#\[quote=(&quot;|&\#039;|"|\'|)(.*?)\\1\]#se', '"</p><div class=\"quotebox\"><cite>".str_replace(array(\'[\', \'\\"\'), array(\'&#91;\', \'"\'), \'$2\')." ".$lang_common[\'wrote\']."</cite><blockquote><div><p>"', $text);
- $text = preg_replace('#\s*\[\/quote\]#S', '</p></div></blockquote></div><p>', $text);
+ $text = preg_replace('%\[quote\]\s*%', '</p><div class="quotebox"><blockquote><div><p>', $text);
+ $text = preg_replace('%\[quote=(&quot;|&\#039;|"|\'|)(.*?)\\1\]%se', '"</p><div class=\"quotebox\"><cite>".str_replace(array(\'[\', \'\\"\'), array(\'&#91;\', \'"\'), \'$2\')." ".$lang_common[\'wrote\']."</cite><blockquote><div><p>"', $text);
+ $text = preg_replace('%\s*\[\/quote\]%S', '</p></div></blockquote></div><p>', $text);
}
if (!$is_signature)
@@ -730,15 +730,15 @@ function do_bbcode($text, $is_signature = false)
$replace[] = 'handle_list_tag(\'$2\', \'$1\')';
}
- $pattern[] = '#\[b\](.*?)\[/b\]#ms';
- $pattern[] = '#\[i\](.*?)\[/i\]#ms';
- $pattern[] = '#\[u\](.*?)\[/u\]#ms';
- $pattern[] = '#\[s\](.*?)\[/s\]#ms';
- $pattern[] = '#\[del\](.*?)\[/del\]#ms';
- $pattern[] = '#\[ins\](.*?)\[/ins\]#ms';
- $pattern[] = '#\[em\](.*?)\[/em\]#ms';
- $pattern[] = '#\[colou?r=([a-zA-Z]{3,20}|\#[0-9a-fA-F]{6}|\#[0-9a-fA-F]{3})](.*?)\[/colou?r\]#ms';
- $pattern[] = '#\[h\](.*?)\[/h\]#ms';
+ $pattern[] = '%\[b\](.*?)\[/b\]%ms';
+ $pattern[] = '%\[i\](.*?)\[/i\]%ms';
+ $pattern[] = '%\[u\](.*?)\[/u\]%ms';
+ $pattern[] = '%\[s\](.*?)\[/s\]%ms';
+ $pattern[] = '%\[del\](.*?)\[/del\]%ms';
+ $pattern[] = '%\[ins\](.*?)\[/ins\]%ms';
+ $pattern[] = '%\[em\](.*?)\[/em\]%ms';
+ $pattern[] = '%\[colou?r=([a-zA-Z]{3,20}|\#[0-9a-fA-F]{6}|\#[0-9a-fA-F]{3})](.*?)\[/colou?r\]%ms';
+ $pattern[] = '%\[h\](.*?)\[/h\]%ms';
$replace[] = '<strong>$1</strong>';
$replace[] = '<em>$1</em>';
@@ -752,8 +752,8 @@ function do_bbcode($text, $is_signature = false)
if (($is_signature && $pun_config['p_sig_img_tag'] == '1') || (!$is_signature && $pun_config['p_message_img_tag'] == '1'))
{
- $pattern[] = '#\[img\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e';
- $pattern[] = '#\[img=([^\[]*?)\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e';
+ $pattern[] = '%\[img\]((ht|f)tps?://)([^\s<"]*?)\[/img\]%e';
+ $pattern[] = '%\[img=([^\[]*?)\]((ht|f)tps?://)([^\s<"]*?)\[/img\]%e';
if ($is_signature)
{
$replace[] = 'handle_img_tag(\'$1$3\', true)';
@@ -766,18 +766,18 @@ function do_bbcode($text, $is_signature = false)
}
}
- $pattern[] = '#\[url\]([^\[]*?)\[/url\]#e';
- $pattern[] = '#\[url=([^\[]+?)\](.*?)\[/url\]#e';
- $pattern[] = '#\[email\]([^\[]*?)\[/email\]#';
- $pattern[] = '#\[email=([^\[]+?)\](.*?)\[/email\]#';
- $pattern[] = '#\[topic\]([^\[]*?)\[/topic\]#e';
- $pattern[] = '#\[topic=([^\[]+?)\](.*?)\[/topic\]#e';
- $pattern[] = '#\[post\]([^\[]*?)\[/post\]#e';
- $pattern[] = '#\[post=([^\[]+?)\](.*?)\[/post\]#e';
- $pattern[] = '#\[forum\]([^\[]*?)\[/forum\]#e';
- $pattern[] = '#\[forum=([^\[]+?)\](.*?)\[/forum\]#e';
- $pattern[] = '#\[user\]([^\[]*?)\[/user\]#e';
- $pattern[] = '#\[user=([^\[]+?)\](.*?)\[/user\]#e';
+ $pattern[] = '%\[url\]([^\[]*?)\[/url\]%e';
+ $pattern[] = '%\[url=([^\[]+?)\](.*?)\[/url\]%e';
+ $pattern[] = '%\[email\]([^\[]*?)\[/email\]%';
+ $pattern[] = '%\[email=([^\[]+?)\](.*?)\[/email\]%';
+ $pattern[] = '%\[topic\]([^\[]*?)\[/topic\]%e';
+ $pattern[] = '%\[topic=([^\[]+?)\](.*?)\[/topic\]%e';
+ $pattern[] = '%\[post\]([^\[]*?)\[/post\]%e';
+ $pattern[] = '%\[post=([^\[]+?)\](.*?)\[/post\]%e';
+ $pattern[] = '%\[forum\]([^\[]*?)\[/forum\]%e';
+ $pattern[] = '%\[forum=([^\[]+?)\](.*?)\[/forum\]%e';
+ $pattern[] = '%\[user\]([^\[]*?)\[/user\]%e';
+ $pattern[] = '%\[user=([^\[]+?)\](.*?)\[/user\]%e';
$replace[] = 'handle_url_tag(\'$1\')';
$replace[] = 'handle_url_tag(\'$1\', \'$2\')';
@@ -806,8 +806,8 @@ function do_clickable($text)
{
$text = ' '.$text;
- $text = ucp_preg_replace('#(?<=[\s\]\)])(<)?(\[)?(\()?([\'"]?)(https?|ftp|news){1}://([\p{L}\p{N}\-]+\.([\p{L}\p{N}\-]+\.)*[\p{L}\p{N}]+(:[0-9]+)?(/[^\s\[]*[^\s.,?!\[;:-])?)\4(?(3)(\)))(?(2)(\]))(?(1)(>))(?![^\s]*\[/(?:url|img)\])#uie', 'stripslashes(\'$1$2$3$4\').handle_url_tag(\'$5://$6\', \'$5://$6\', true).stripslashes(\'$4$10$11$12\')', $text);
- $text = ucp_preg_replace('#(?<=[\s\]\)])(<)?(\[)?(\()?([\'"]?)(www|ftp)\.(([\p{L}\p{N}\-]+\.)*[\p{L}\p{N}]+(:[0-9]+)?(/[^\s\[]*[^\s.,?!\[;:-])?)\4(?(3)(\)))(?(2)(\]))(?(1)(>))(?![^\s]*\[/(?:url|img)\])#uie', 'stripslashes(\'$1$2$3$4\').handle_url_tag(\'$5.$6\', \'$5.$6\', true).stripslashes(\'$4$10$11$12\')', $text);
+ $text = ucp_preg_replace('%(?<=[\s\]\)])(<)?(\[)?(\()?([\'"]?)(https?|ftp|news){1}://([\p{L}\p{N}\-]+\.([\p{L}\p{N}\-]+\.)*[\p{L}\p{N}]+(:[0-9]+)?(/[^\s\[]*[^\s.,?!\[;:-])?)\4(?(3)(\)))(?(2)(\]))(?(1)(>))(?![^\s]*\[/(?:url|img)\])%uie', 'stripslashes(\'$1$2$3$4\').handle_url_tag(\'$5://$6\', \'$5://$6\', true).stripslashes(\'$4$10$11$12\')', $text);
+ $text = ucp_preg_replace('%(?<=[\s\]\)])(<)?(\[)?(\()?([\'"]?)(www|ftp)\.(([\p{L}\p{N}\-]+\.)*[\p{L}\p{N}]+(:[0-9]+)?(/[^\s\[]*[^\s.,?!\[;:-])?)\4(?(3)(\)))(?(2)(\]))(?(1)(>))(?![^\s]*\[/(?:url|img)\])%uie', 'stripslashes(\'$1$2$3$4\').handle_url_tag(\'$5.$6\', \'$5.$6\', true).stripslashes(\'$4$10$11$12\')', $text);
return substr($text, 1);
}
@@ -825,7 +825,7 @@ function do_smilies($text)
foreach ($smilies as $smiley_text => $smiley_img)
{
if (strpos($text, $smiley_text) !== false)
- $text = ucp_preg_replace('#(?<=[>\s])'.preg_quote($smiley_text, '#').'(?=[^\p{L}\p{N}])#um', '<img src="'.pun_htmlspecialchars(get_base_url(true).'/img/smilies/'.$smiley_img).'" width="15" height="15" alt="'.substr($smiley_img, 0, strrpos($smiley_img, '.')).'" />', $text);
+ $text = ucp_preg_replace('%(?<=[>\s])'.preg_quote($smiley_text, '%').'(?=[^\p{L}\p{N}])%um', '<img src="'.pun_htmlspecialchars(get_base_url(true).'/img/smilies/'.$smiley_img).'" width="15" height="15" alt="'.substr($smiley_img, 0, strrpos($smiley_img, '.')).'" />', $text);
}
return substr($text, 1, -1);
@@ -884,7 +884,7 @@ function parse_message($text, $hide_smilies)
}
// Add paragraph tag around post, but make sure there are no empty paragraphs
- $text = preg_replace('#<br />\s*?<br />((\s*<br />)*)#i', "</p>$1<p>", $text);
+ $text = preg_replace('%<br />\s*?<br />((\s*<br />)*)%i', "</p>$1<p>", $text);
$text = str_replace('<p><br />', '<p>', $text);
$text = str_replace('<p></p>', '', '<p>'.$text.'</p>');
@@ -918,7 +918,7 @@ function parse_signature($text)
$text = str_replace($pattern, $replace, $text);
// Add paragraph tag around post, but make sure there are no empty paragraphs
- $text = preg_replace('#<br />\s*?<br />((\s*<br />)*)#i', "</p>$1<p>", $text);
+ $text = preg_replace('%<br />\s*?<br />((\s*<br />)*)%i', "</p>$1<p>", $text);
$text = str_replace('<p><br />', '<p>', $text);
$text = str_replace('<p></p>', '', '<p>'.$text.'</p>');
View
10 include/search_idx.php
@@ -48,16 +48,16 @@
function split_words($text, $idx)
{
// Remove BBCode
- $text = preg_replace('/\[\/?(b|u|s|ins|del|em|i|h|colou?r|quote|code|img|url|email|list)(?:\=[^\]]*)?\]/', ' ', $text);
+ $text = preg_replace('%\[/?(b|u|s|ins|del|em|i|h|colou?r|quote|code|img|url|email|list)(?:\=[^\]]*)?\]%', ' ', $text);
// Remove any apostrophes or dashes which aren't part of words
- $text = substr(ucp_preg_replace('/((?<=[^\p{L}\p{N}])[\'\-]|[\'\-](?=[^\p{L}\p{N}]))/u', '', ' '.$text.' '), 1, -1);
+ $text = substr(ucp_preg_replace('%((?<=[^\p{L}\p{N}])[\'\-]|[\'\-](?=[^\p{L}\p{N}]))%u', '', ' '.$text.' '), 1, -1);
// Remove punctuation and symbols (actually anything that isn't a letter or number), allow apostrophes and dashes (and % * if we aren't indexing)
- $text = ucp_preg_replace('/(?![\'\-'.($idx ? '' : '%\*').'])[^\p{L}\p{N}]+/u', ' ', $text);
+ $text = ucp_preg_replace('%(?![\'\-'.($idx ? '' : '\%\*').'])[^\p{L}\p{N}]+%u', ' ', $text);
// Replace multiple whitespace or dashes
- $text = preg_replace('/(\s){2,}/u', '\1', $text);
+ $text = preg_replace('%(\s){2,}%u', '\1', $text);
// Fill an array with all the words
$words = array_unique(explode(' ', $text));
@@ -128,7 +128,7 @@ function is_keyword($word)
//
function is_cjk($word)
{
- return preg_match('/^'.PUN_CJK_HANGUL_REGEX.'+$/u', $word) ? true : false;
+ return preg_match('%^'.PUN_CJK_HANGUL_REGEX.'+$%u', $word) ? true : false;
}
View
8 install.php
@@ -131,7 +131,7 @@ function generate_config_file()
{
// Make an educated guess regarding base_url
$base_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'; // protocol
- $base_url .= preg_replace('/:(80|443)$/', '', $_SERVER['HTTP_HOST']); // host[:port]
+ $base_url .= preg_replace('%:(80|443)$%', '', $_SERVER['HTTP_HOST']); // host[:port]
$base_url .= str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])); // path
if (substr($base_url, -1) == '/')
@@ -174,11 +174,11 @@ function generate_config_file()
$alerts[] = $lang_install['Username 2'];
else if (!strcasecmp($username, 'Guest'))
$alerts[] = $lang_install['Username 3'];
- else if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $username) || preg_match('/((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))/', $username))
+ else if (preg_match('%[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}%', $username) || preg_match('%((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))%', $username))
$alerts[] = $lang_install['Username 4'];
else if ((strpos($username, '[') !== false || strpos($username, ']') !== false) && strpos($username, '\'') !== false && strpos($username, '"') !== false)
$alerts[] = $lang_install['Username 5'];
- else if (preg_match('/(?:\[\/?(?:b|u|i|h|colou?r|quote|code|img|url|email|list)\]|\[(?:code|quote|list)=)/i', $username))
+ else if (preg_match('%(?:\[/?(?:b|u|i|h|colou?r|quote|code|img|url|email|list)\]|\[(?:code|quote|list)=)%i', $username))
$alerts[] = $lang_install['Username 6'];
if (pun_strlen($password1) < 4)
@@ -581,7 +581,7 @@ function process_form(the_form)
$db = new DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, false);
// Validate prefix
- if (strlen($db_prefix) > 0 && (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $db_prefix) || strlen($db_prefix) > 40))
+ if (strlen($db_prefix) > 0 && (!preg_match('%^[a-zA-Z_][a-zA-Z0-9_]*$%', $db_prefix) || strlen($db_prefix) > 40))
error(sprintf($lang_install['Table prefix error'], $db->prefix));
// Do some DB type specific checks
View
2 login.php
@@ -251,7 +251,7 @@
if (!isset($valid['path']))
$valid['path'] = '';
- if ($referrer['host'] == $valid['host'] && preg_match('#^'.preg_quote($valid['path']).'/(.*?)\.php#i', $referrer['path']))
+ if ($referrer['host'] == $valid['host'] && preg_match('%^'.preg_quote($valid['path'], '%').'/(.*?)\.php%i', $referrer['path']))
$redirect_url = $_SERVER['HTTP_REFERER'];
}
View
2 misc.php
@@ -150,7 +150,7 @@
if (strpos($valid['host'], 'www.') === 0)
$valid['host'] = substr($valid['host'], 4);
- if ($referrer['host'] == $valid['host'] && preg_match('#^'.preg_quote($valid['path']).'/(.*?)\.php#i', $referrer['path']))
+ if ($referrer['host'] == $valid['host'] && preg_match('%^'.preg_quote($valid['path'], '%').'/(.*?)\.php%i', $referrer['path']))
$redirect_url = $_SERVER['HTTP_REFERER'];
}
View
12 moderate.php
@@ -18,7 +18,7 @@
message($lang_common['No permission']);
// Is get_host an IP address or a post ID?
- if (@preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $_GET['get_host']) || @preg_match('/^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/', $_GET['get_host']))
+ if (@preg_match('%^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$%', $_GET['get_host']) || @preg_match('%^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$%', $_GET['get_host']))
$ip = $_GET['get_host'];
else
{
@@ -86,7 +86,7 @@
{
confirm_referrer('moderate.php');
- if (@preg_match('/[^0-9,]/', $posts))
+ if (@preg_match('%[^0-9,]%', $posts))
message($lang_common['Bad request']);
// Verify that the post IDs are valid
@@ -153,7 +153,7 @@
{
confirm_referrer('moderate.php');
- if (@preg_match('/[^0-9,]/', $posts))
+ if (@preg_match('%[^0-9,]%', $posts))
message($lang_common['Bad request']);
$move_to_forum = isset($_POST['move_to_forum']) ? intval($_POST['move_to_forum']) : 0;
@@ -420,7 +420,7 @@
{
confirm_referrer('moderate.php');
- if (@preg_match('/[^0-9,]/', $_POST['topics']))
+ if (@preg_match('%[^0-9,]%', $_POST['topics']))
message($lang_common['Bad request']);
$topics = explode(',', $_POST['topics']);
@@ -548,7 +548,7 @@
{
confirm_referrer('moderate.php');
- if (@preg_match('/[^0-9,]/', $_POST['topics']))
+ if (@preg_match('%[^0-9,]%', $_POST['topics']))
message($lang_common['Bad request']);
$topics = explode(',', $_POST['topics']);
@@ -644,7 +644,7 @@
{
confirm_referrer('moderate.php');
- if (@preg_match('/[^0-9,]/', $topics))
+ if (@preg_match('%[^0-9,]%', $topics))
message($lang_common['Bad request']);
require PUN_ROOT.'include/search_idx.php';
View
2 profile.php
@@ -780,7 +780,7 @@
);
// If the ICQ UIN contains anything other than digits it's invalid
- if (preg_match('/[^0-9]/', $form['icq']))
+ if (preg_match('%[^0-9]%', $form['icq']))
message($lang_prof_reg['Bad ICQ']);
break;
View
2 register.php
@@ -131,7 +131,7 @@
// Make sure we got a valid language string
if (isset($_POST['language']))
{
- $language = preg_replace('#[\.\\\/]#', '', $_POST['language']);
+ $language = preg_replace('%[\.\\\/]%', '', $_POST['language']);
if (!file_exists(PUN_ROOT.'lang/'.$language.'/common.php'))
message($lang_common['Bad request']);
}
View
4 search.php
@@ -50,10 +50,10 @@
$keywords = (isset($_GET['keywords'])) ? utf8_strtolower(pun_trim($_GET['keywords'])) : null;
$author = (isset($_GET['author'])) ? utf8_strtolower(pun_trim($_GET['author'])) : null;
- if (preg_match('#^[\*%]+$#', $keywords) || (pun_strlen(str_replace(array('*', '%'), '', $keywords)) < PUN_SEARCH_MIN_WORD && !is_cjk($keywords)))
+ if (preg_match('%^[\*\%]+$%', $keywords) || (pun_strlen(str_replace(array('*', '%'), '', $keywords)) < PUN_SEARCH_MIN_WORD && !is_cjk($keywords)))
$keywords = '';
- if (preg_match('#^[\*%]+$#', $author) || pun_strlen(str_replace(array('*', '%'), '', $author)) < 2)
+ if (preg_match('%^[\*\%]+$%', $author) || pun_strlen(str_replace(array('*', '%'), '', $author)) < 2)
$author = '';
if (!$keywords && !$author)

0 comments on commit b1deb69

Please sign in to comment.
Something went wrong with that request. Please try again.