Zeile 322 | Zeile 322 |
---|
/** * Turn a unix timestamp in to a "friendly" date/time format for the user. *
|
/** * Turn a unix timestamp in to a "friendly" date/time format for the user. *
|
* @param string $format A date format according to PHP's date structure.
| * @param string $format A date format (either relative, normal or PHP's date() structure).
|
* @param int $stamp The unix timestamp the date should be generated for. * @param int|string $offset The offset in hours that should be applied to times. (timezones) Or an empty string to determine that automatically * @param int $ty Whether or not to use today/yesterday formatting.
| * @param int $stamp The unix timestamp the date should be generated for. * @param int|string $offset The offset in hours that should be applied to times. (timezones) Or an empty string to determine that automatically * @param int $ty Whether or not to use today/yesterday formatting.
|
Zeile 380 | Zeile 380 |
---|
}
$todaysdate = $yesterdaysdate = '';
|
}
$todaysdate = $yesterdaysdate = '';
|
if($ty && ($format == $mybb->settings['dateformat'] || $format == 'relative'))
| if($ty && ($format == $mybb->settings['dateformat'] || $format == 'relative' || $format == 'normal'))
|
{ $_stamp = TIME_NOW; if($adodb == true)
| { $_stamp = TIME_NOW; if($adodb == true)
|
Zeile 400 | Zeile 400 |
---|
if($format == 'relative') { // Relative formats both date and time
|
if($format == 'relative') { // Relative formats both date and time
|
| $real_date = $real_time = ''; if($adodb == true) { $real_date = adodb_date($mybb->settings['dateformat'], $stamp + ($offset * 3600)); $real_time = $mybb->settings['datetimesep']; $real_time .= adodb_date($mybb->settings['timeformat'], $stamp + ($offset * 3600)); } else { $real_date = gmdate($mybb->settings['dateformat'], $stamp + ($offset * 3600)); $real_time = $mybb->settings['datetimesep']; $real_time .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600)); }
|
if($ty != 2 && abs(TIME_NOW - $stamp) < 3600) { $diff = TIME_NOW - $stamp;
| if($ty != 2 && abs(TIME_NOW - $stamp) < 3600) { $diff = TIME_NOW - $stamp;
|
Zeile 411 | Zeile 425 |
---|
$relative['suffix'] = ''; $relative['prefix'] = $lang->rel_in; }
|
$relative['suffix'] = ''; $relative['prefix'] = $lang->rel_in; }
|
|
|
$relative['minute'] = floor($diff / 60);
if($relative['minute'] <= 1)
|
$relative['minute'] = floor($diff / 60);
if($relative['minute'] <= 1)
|
{
| {
|
$relative['minute'] = 1; $relative['plural'] = $lang->rel_minutes_single;
|
$relative['minute'] = 1; $relative['plural'] = $lang->rel_minutes_single;
|
}
| }
|
if($diff <= 60) { // Less than a minute $relative['prefix'] = $lang->rel_less_than; }
|
if($diff <= 60) { // Less than a minute $relative['prefix'] = $lang->rel_less_than; }
|
$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['minute'], $relative['plural'], $relative['suffix']);
| $date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['minute'], $relative['plural'], $relative['suffix'], $real_date, $real_time);
|
} elseif($ty != 2 && abs(TIME_NOW - $stamp) < 43200) { $diff = TIME_NOW - $stamp; $relative = array('prefix' => '', 'hour' => 0, 'plural' => $lang->rel_hours_plural, 'suffix' => $lang->rel_ago);
|
} elseif($ty != 2 && abs(TIME_NOW - $stamp) < 43200) { $diff = TIME_NOW - $stamp; $relative = array('prefix' => '', 'hour' => 0, 'plural' => $lang->rel_hours_plural, 'suffix' => $lang->rel_ago);
|
|
|
if($diff < 0) { $diff = abs($diff); $relative['suffix'] = ''; $relative['prefix'] = $lang->rel_in;
|
if($diff < 0) { $diff = abs($diff); $relative['suffix'] = ''; $relative['prefix'] = $lang->rel_in;
|
}
$relative['hour'] = floor($diff / 3600);
| }
$relative['hour'] = floor($diff / 3600);
|
if($relative['hour'] <= 1) { $relative['hour'] = 1; $relative['plural'] = $lang->rel_hours_single;
|
if($relative['hour'] <= 1) { $relative['hour'] = 1; $relative['plural'] = $lang->rel_hours_single;
|
}
$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['hour'], $relative['plural'], $relative['suffix']); }
| }
$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['hour'], $relative['plural'], $relative['suffix'], $real_date, $real_time); }
|
else { if($ty) { if($todaysdate == $date) {
|
else { if($ty) { if($todaysdate == $date) {
|
$date = $lang->today;
| $date = $lang->sprintf($lang->today_rel, $real_date);
|
} else if($yesterdaysdate == $date) {
|
} else if($yesterdaysdate == $date) {
|
$date = $lang->yesterday;
| $date = $lang->sprintf($lang->yesterday_rel, $real_date);
|
} }
| } }
|
Zeile 473 | Zeile 487 |
---|
{ $date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600)); }
|
{ $date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600)); }
|
| } } elseif($format == 'normal') { // Normal format both date and time if($ty != 2) { if($todaysdate == $date) { $date = $lang->today; } else if($yesterdaysdate == $date) { $date = $lang->yesterday; } }
$date .= $mybb->settings['datetimesep']; if($adodb == true) { $date .= adodb_date($mybb->settings['timeformat'], $stamp + ($offset * 3600)); } else { $date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600));
|
} } else
| } } else
|
Zeile 499 | Zeile 538 |
---|
$date = gmdate($format, $stamp + ($offset * 3600)); } }
|
$date = gmdate($format, $stamp + ($offset * 3600)); } }
|
}
| }
|
if(is_object($plugins)) {
| if(is_object($plugins)) {
|
Zeile 531 | Zeile 570 |
---|
// Does our object not exist? Create it if(!is_object($mail))
|
// Does our object not exist? Create it if(!is_object($mail))
|
{
| {
|
require_once MYBB_ROOT."inc/class_mailhandler.php";
if($mybb->settings['mail_handler'] == 'smtp')
| require_once MYBB_ROOT."inc/class_mailhandler.php";
if($mybb->settings['mail_handler'] == 'smtp')
|
Zeile 561 | Zeile 600 |
---|
if($mybb->settings['mail_parameters'] != '') { $mail->additional_parameters = $mybb->settings['mail_parameters'];
|
if($mybb->settings['mail_parameters'] != '') { $mail->additional_parameters = $mybb->settings['mail_parameters'];
|
} }
| } }
|
// Build and send $mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email); return $mail->send();
| // Build and send $mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email); return $mail->send();
|
Zeile 627 | Zeile 666 |
---|
* * @param int $fid The forum id to get the parent list for. * @return string The comma-separated parent list.
|
* * @param int $fid The forum id to get the parent list for. * @return string The comma-separated parent list.
|
*/
| */
|
function get_parent_list($fid) { global $forum_cache;
| function get_parent_list($fid) { global $forum_cache;
|
Zeile 658 | Zeile 697 |
---|
* @return string The query string generated */ function build_parent_list($fid, $column="fid", $joiner="OR", $parentlist="")
|
* @return string The query string generated */ function build_parent_list($fid, $column="fid", $joiner="OR", $parentlist="")
|
{
| {
|
if(!$parentlist)
|
if(!$parentlist)
|
{
| {
|
$parentlist = get_parent_list($fid);
|
$parentlist = get_parent_list($fid);
|
}
| }
|
$parentsexploded = explode(",", $parentlist); $builtlist = "("; $sep = '';
|
$parentsexploded = explode(",", $parentlist); $builtlist = "("; $sep = '';
|
|
|
foreach($parentsexploded as $key => $val) { $builtlist .= "$sep$column='$val'"; $sep = " $joiner ";
|
foreach($parentsexploded as $key => $val) { $builtlist .= "$sep$column='$val'"; $sep = " $joiner ";
|
}
$builtlist .= ")";
| }
$builtlist .= ")";
|
return $builtlist; }
| return $builtlist; }
|
Zeile 688 | Zeile 727 |
---|
function cache_forums($force=false) { global $forum_cache, $cache;
|
function cache_forums($force=false) { global $forum_cache, $cache;
|
|
|
if($force == true) { $forum_cache = $cache->read("forums", 1);
| if($force == true) { $forum_cache = $cache->read("forums", 1);
|
Zeile 719 | Zeile 758 |
---|
$forums = array(); if(!is_array($forums_by_parent))
|
$forums = array(); if(!is_array($forums_by_parent))
|
{
| {
|
$forum_cache = cache_forums(); foreach($forum_cache as $forum) {
| $forum_cache = cache_forums(); foreach($forum_cache as $forum) {
|
Zeile 728 | Zeile 767 |
---|
$forums_by_parent[$forum['pid']][$forum['fid']] = $forum; } }
|
$forums_by_parent[$forum['pid']][$forum['fid']] = $forum; } }
|
}
| }
|
if(!is_array($forums_by_parent[$fid]))
|
if(!is_array($forums_by_parent[$fid]))
|
{
| {
|
return $forums; }
foreach($forums_by_parent[$fid] as $forum)
|
return $forums; }
foreach($forums_by_parent[$fid] as $forum)
|
{
| {
|
$forums[] = $forum['fid']; $children = get_child_list($forum['fid']); if(is_array($children))
| $forums[] = $forum['fid']; $children = get_child_list($forum['fid']); if(is_array($children))
|
Zeile 782 | Zeile 821 |
---|
eval("\$errorpage = \"".$templates->get("error")."\";"); output_page($errorpage);
|
eval("\$errorpage = \"".$templates->get("error")."\";"); output_page($errorpage);
|
exit; }
/**
| exit; }
/**
|
* Produce an error message for displaying inline on a page * * @param array $errors Array of errors to be shown
| * Produce an error message for displaying inline on a page * * @param array $errors Array of errors to be shown
|
Zeile 801 | Zeile 840 |
---|
if(!$title) { $title = $lang->please_correct_errors;
|
if(!$title) { $title = $lang->please_correct_errors;
|
}
| }
|
if(!is_array($errors)) { $errors = array($errors);
| if(!is_array($errors)) { $errors = array($errors);
|
Zeile 882 | Zeile 921 |
---|
switch($mybb->settings['username_method']) { case 0:
|
switch($mybb->settings['username_method']) { case 0:
|
$lang_username = $lang->username;
| $lang_username = $lang->username;
|
break; case 1: $lang_username = $lang->username1;
| break; case 1: $lang_username = $lang->username1;
|
Zeile 913 | Zeile 952 |
---|
global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;
$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);
|
global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;
$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);
|
|
|
$plugins->run_hooks("redirect", $redirect_args);
if($mybb->get_input('ajax', MyBB::INPUT_INT))
| $plugins->run_hooks("redirect", $redirect_args);
if($mybb->get_input('ajax', MyBB::INPUT_INT))
|
Zeile 966 | Zeile 1005 |
---|
run_shutdown();
|
run_shutdown();
|
if(!my_validate_url($url, true))
| if(!my_validate_url($url, true, true))
|
{ header("Location: {$mybb->settings['bburl']}/{$url}"); }
| { header("Location: {$mybb->settings['bburl']}/{$url}"); }
|
Zeile 1179 | Zeile 1218 |
---|
if($uid != $mybb->user['uid']) { // We've already cached permissions for this user, return them.
|
if($uid != $mybb->user['uid']) { // We've already cached permissions for this user, return them.
|
if($user_cache[$uid]['permissions'])
| if(!empty($user_cache[$uid]['permissions']))
|
{ return $user_cache[$uid]['permissions']; }
// This user was not already cached, fetch their user information.
|
{ return $user_cache[$uid]['permissions']; }
// This user was not already cached, fetch their user information.
|
if(!$user_cache[$uid])
| if(empty($user_cache[$uid]))
|
{ $user_cache[$uid] = get_user($uid); }
| { $user_cache[$uid] = get_user($uid); }
|
Zeile 1422 | Zeile 1461 |
---|
if(empty($level_permissions)) { $level_permissions = $groupscache[$gid];
|
if(empty($level_permissions)) { $level_permissions = $groupscache[$gid];
|
}
foreach($level_permissions as $permission => $access) {
| }
foreach($level_permissions as $permission => $access) {
|
if(empty($current_permissions[$permission]) || $access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no")) { $current_permissions[$permission] = $access;
| if(empty($current_permissions[$permission]) || $access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no")) { $current_permissions[$permission] = $access;
|
Zeile 3011 | Zeile 3050 |
---|
*/ function format_name($username, $usergroup, $displaygroup=0) {
|
*/ function format_name($username, $usergroup, $displaygroup=0) {
|
global $groupscache, $cache;
| global $groupscache, $cache, $plugins;
|
|
|
if(!is_array($groupscache))
| static $formattednames = array();
if(!isset($formattednames[$username]))
|
{
|
{
|
$groupscache = $cache->read("usergroups"); }
if($displaygroup != 0) { $usergroup = $displaygroup; }
| if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups"); }
if($displaygroup != 0) { $usergroup = $displaygroup; }
$format = "{username}";
if(isset($groupscache[$usergroup])) { $ugroup = $groupscache[$usergroup];
if(strpos($ugroup['namestyle'], "{username}") !== false) { $format = $ugroup['namestyle']; } }
$format = stripslashes($format);
$parameters = compact('username', 'usergroup', 'displaygroup', 'format');
$parameters = $plugins->run_hooks('format_name', $parameters);
|
|
|
$ugroup = $groupscache[$usergroup]; $format = $ugroup['namestyle']; $userin = substr_count($format, "{username}");
| $format = $parameters['format'];
|
|
|
if($userin == 0) { $format = "{username}";
| $formattednames[$username] = str_replace("{username}", $username, $format);
|
}
|
}
|
$format = stripslashes($format);
return str_replace("{username}", $username, $format);
| return $formattednames[$username];
|
}
/**
| }
/**
|
Zeile 3781 | Zeile 3836 |
---|
{ $pid = (int)$data['pid']; unset($data['pid']);
|
{ $pid = (int)$data['pid']; unset($data['pid']);
|
| }
$tids = array(); if(isset($data['tids'])) { $tids = (array)$data['tids']; unset($data['tids']);
|
}
// Any remaining extra data - we my_serialize and insert in to its own column
| }
// Any remaining extra data - we my_serialize and insert in to its own column
|
Zeile 3799 | Zeile 3861 |
---|
"data" => $db->escape_string($data), "ipaddress" => $db->escape_binary($session->packedip) );
|
"data" => $db->escape_string($data), "ipaddress" => $db->escape_binary($session->packedip) );
|
$db->insert_query("moderatorlog", $sql_array);
| if($tids) { $multiple_sql_array = array();
foreach($tids as $tid) { $sql_array['tid'] = (int)$tid; $multiple_sql_array[] = $sql_array; }
$db->insert_query_multiple("moderatorlog", $multiple_sql_array); } else { $db->insert_query("moderatorlog", $sql_array); }
|
}
/**
| }
/**
|
Zeile 3817 | Zeile 3895 |
---|
if($reputation < 0) { $reputation_class = "reputation_negative";
|
if($reputation < 0) { $reputation_class = "reputation_negative";
|
}
| }
|
elseif($reputation > 0)
|
elseif($reputation > 0)
|
{
| {
|
$reputation_class = "reputation_positive";
|
$reputation_class = "reputation_positive";
|
}
| }
|
else { $reputation_class = "reputation_neutral";
|
else { $reputation_class = "reputation_neutral";
|
}
$reputation = my_number_format($reputation);
| }
$reputation = my_number_format($reputation);
|
if($uid != 0)
|
if($uid != 0)
|
{
| {
|
eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted_link")."\";"); } else
| eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted_link")."\";"); } else
|
Zeile 3839 | Zeile 3917 |
---|
}
return $display_reputation;
|
}
return $display_reputation;
|
}
| }
|
/** * Fetch a color coded version of a warning level (based on it's percentage)
| /** * Fetch a color coded version of a warning level (based on it's percentage)
|
Zeile 3850 | Zeile 3928 |
---|
function get_colored_warning_level($level) { global $templates;
|
function get_colored_warning_level($level) { global $templates;
|
|
|
$warning_class = ''; if($level >= 80)
|
$warning_class = ''; if($level >= 80)
|
{
| {
|
$warning_class = "high_warning";
|
$warning_class = "high_warning";
|
}
| }
|
else if($level >= 50) { $warning_class = "moderate_warning"; } else if($level >= 25)
|
else if($level >= 50) { $warning_class = "moderate_warning"; } else if($level >= 25)
|
{
| {
|
$warning_class = "low_warning";
|
$warning_class = "low_warning";
|
}
| }
|
else { $warning_class = "normal_warning"; }
|
else { $warning_class = "normal_warning"; }
|
|
|
eval("\$level = \"".$templates->get("postbit_warninglevel_formatted")."\";"); return $level;
|
eval("\$level = \"".$templates->get("postbit_warninglevel_formatted")."\";"); return $level;
|
}
| }
|
/** * Fetch the IP address of the current user. *
| /** * Fetch the IP address of the current user. *
|
Zeile 3895 | Zeile 3973 |
---|
elseif(isset($_SERVER['HTTP_X_REAL_IP'])) { $addresses = explode(',', strtolower($_SERVER['HTTP_X_REAL_IP']));
|
elseif(isset($_SERVER['HTTP_X_REAL_IP'])) { $addresses = explode(',', strtolower($_SERVER['HTTP_X_REAL_IP']));
|
}
| }
|
if(is_array($addresses)) {
| if(is_array($addresses)) {
|
Zeile 3928 | Zeile 4006 |
---|
return $ip; }
|
return $ip; }
|
|
|
/** * Fetch the friendly size (GB, MB, KB, B) for a specified file size. *
| /** * Fetch the friendly size (GB, MB, KB, B) for a specified file size. *
|
Zeile 3961 | Zeile 4039 |
---|
} // Petabyte (1024 Terabytes) elseif($size >= 1125899906842624)
|
} // Petabyte (1024 Terabytes) elseif($size >= 1125899906842624)
|
{
| {
|
$size = my_number_format(round(($size / 1125899906842624), 2))." ".$lang->size_pb; } // Terabyte (1024 Gigabytes)
| $size = my_number_format(round(($size / 1125899906842624), 2))." ".$lang->size_pb; } // Terabyte (1024 Gigabytes)
|
Zeile 4138 | Zeile 4216 |
---|
if($forum['password'] != "") { if($mybb->cookies['forumpass'][$forum['fid']] !== md5($mybb->user['uid'].$forum['password']))
|
if($forum['password'] != "") { if($mybb->cookies['forumpass'][$forum['fid']] !== md5($mybb->user['uid'].$forum['password']))
|
{
| {
|
$pwverified = 0; }
| $pwverified = 0; }
|
Zeile 4315 | Zeile 4393 |
---|
{ // Set up link to forum in breadcrumb. if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')
|
{ // Set up link to forum in breadcrumb. if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')
|
{
| {
|
$navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html"; } else
| $navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html"; } else
|
Zeile 4492 | Zeile 4570 |
---|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_usage}</span></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Limit:</span></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_limit}</span></td>\n";
|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_usage}</span></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Limit:</span></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_limit}</span></td>\n";
|
echo "</tr>\n";
echo "</table>\n";
| echo "</tr>\n";
echo "</table>\n";
|
echo "<h2>Database Connections (".count($db->connections)." Total) </h2>\n"; echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
| echo "<h2>Database Connections (".count($db->connections)." Total) </h2>\n"; echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
|
Zeile 4503 | Zeile 4581 |
---|
echo "</tr>\n"; echo "</table>\n"; echo "<br />\n";
|
echo "</tr>\n"; echo "</table>\n"; echo "<br />\n";
|
|
|
echo "<h2>Database Queries (".$db->query_count." Total) </h2>\n"; echo $db->explain;
|
echo "<h2>Database Queries (".$db->query_count." Total) </h2>\n"; echo $db->explain;
|
|
|
if($cache->call_count > 0) { echo "<h2>Cache Calls (".$cache->call_count." Total, ".$call_time.") </h2>\n"; echo $cache->cache_debug; }
|
if($cache->call_count > 0) { echo "<h2>Cache Calls (".$cache->call_count." Total, ".$call_time.") </h2>\n"; echo $cache->cache_debug; }
|
|
|
echo "<h2>Template Statistics</h2>\n";
if(count($templates->cache) > 0)
|
echo "<h2>Template Statistics</h2>\n";
if(count($templates->cache) > 0)
|
{ echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
| { echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
|
echo "<tr>\n"; echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n"; echo "</tr>\n";
| echo "<tr>\n"; echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n"; echo "</tr>\n";
|
Zeile 4642 | Zeile 4720 |
---|
$lang_minutes = $lang->minutes_short; $lang_second = $lang->second_short; $lang_seconds = $lang->seconds_short;
|
$lang_minutes = $lang->minutes_short; $lang_second = $lang->second_short; $lang_seconds = $lang->seconds_short;
|
}
| }
|
else { $lang_year = " ".$lang->year;
| else { $lang_year = " ".$lang->year;
|
Zeile 4675 | Zeile 4753 |
---|
$stamp %= $msecs; $seconds = $stamp;
|
$stamp %= $msecs; $seconds = $stamp;
|
if($years == 1)
| // Prevent gross over accuracy ($options parameter will override these) if($years > 0)
|
{
|
{
|
$nicetime['years'] = "1".$lang_year;
| $options = array_merge(array( 'days' => false, 'hours' => false, 'minutes' => false, 'seconds' => false ), $options);
|
}
|
}
|
else if($years > 1)
| elseif($months > 0)
|
{
|
{
|
$nicetime['years'] = $years.$lang_years;
| $options = array_merge(array( 'hours' => false, 'minutes' => false, 'seconds' => false ), $options);
|
}
|
}
|
if($months == 1) { $nicetime['months'] = "1".$lang_month;
| elseif($weeks > 0) { $options = array_merge(array( 'minutes' => false, 'seconds' => false ), $options); } elseif($days > 0) { $options = array_merge(array( 'seconds' => false ), $options); }
if(!isset($options['years']) || $options['years'] !== false) { if($years == 1) { $nicetime['years'] = "1".$lang_year; } else if($years > 1) { $nicetime['years'] = $years.$lang_years; } }
if(!isset($options['months']) || $options['months'] !== false) { if($months == 1) { $nicetime['months'] = "1".$lang_month; } else if($months > 1) { $nicetime['months'] = $months.$lang_months; }
|
}
|
}
|
else if($months > 1)
| if(!isset($options['weeks']) || $options['weeks'] !== false)
|
{
|
{
|
$nicetime['months'] = $months.$lang_months;
| if($weeks == 1) { $nicetime['weeks'] = "1".$lang_week; } else if($weeks > 1) { $nicetime['weeks'] = $weeks.$lang_weeks; }
|
}
|
}
|
if($weeks == 1) { $nicetime['weeks'] = "1".$lang_week; } else if($weeks > 1) { $nicetime['weeks'] = $weeks.$lang_weeks; }
if($days == 1)
| if(!isset($options['days']) || $options['days'] !== false)
|
{
|
{
|
$nicetime['days'] = "1".$lang_day; } else if($days > 1) { $nicetime['days'] = $days.$lang_days;
| if($days == 1) { $nicetime['days'] = "1".$lang_day; } else if($days > 1) { $nicetime['days'] = $days.$lang_days; }
|
}
if(!isset($options['hours']) || $options['hours'] !== false)
| }
if(!isset($options['hours']) || $options['hours'] !== false)
|
Zeile 5669 | Zeile 5791 |
---|
function unhtmlentities($string) { // Replace numeric entities
|
function unhtmlentities($string) { // Replace numeric entities
|
$string = preg_replace_callback('~&#x([0-9a-f]+);~i', create_function('$matches', 'return unichr(hexdec($matches[1]));'), $string); $string = preg_replace_callback('~&#([0-9]+);~', create_function('$matches', 'return unichr($matches[1]);'), $string);
| $string = preg_replace_callback('~&#x([0-9a-f]+);~i', 'unichr_callback1', $string); $string = preg_replace_callback('~&#([0-9]+);~', 'unichr_callback2', $string);
|
// Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES);
| // Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES);
|
Zeile 5710 | Zeile 5832 |
---|
{ return false; }
|
{ return false; }
|
| }
/** * Returns any ascii to it's character (utf-8 safe). * * @param array $matches Matches. * @return string|bool The characterized ascii. False on failure */ function unichr_callback1($matches) { return unichr(hexdec($matches[1])); }
/** * Returns any ascii to it's character (utf-8 safe). * * @param array $matches Matches. * @return string|bool The characterized ascii. False on failure */ function unichr_callback2($matches) { return unichr($matches[1]);
|
}
/**
| }
/**
|
Zeile 5783 | Zeile 5927 |
---|
if(!$username && $uid == 0) { // Return Guest phrase for no UID, no guest nickname
|
if(!$username && $uid == 0) { // Return Guest phrase for no UID, no guest nickname
|
return $lang->guest;
| return htmlspecialchars_uni($lang->guest);
|
} elseif($uid == 0) {
| } elseif($uid == 0) {
|
Zeile 5901 | Zeile 6045 |
---|
function get_event_link($eid) { $link = str_replace("{eid}", $eid, EVENT_URL);
|
function get_event_link($eid) { $link = str_replace("{eid}", $eid, EVENT_URL);
|
return htmlspecialchars_uni($link); }
| return htmlspecialchars_uni($link); }
|
/** * Build the link to a specified date on the calendar
| /** * Build the link to a specified date on the calendar
|
Zeile 6185 | Zeile 6329 |
---|
foreach($forum_cache as $fid1 => $forum1) { if(my_strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false && !in_array($fid1, $inactive))
|
foreach($forum_cache as $fid1 => $forum1) { if(my_strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false && !in_array($fid1, $inactive))
|
{
| {
|
$inactive[] = $fid1; } }
| $inactive[] = $fid1; } }
|
Zeile 6299 | Zeile 6443 |
---|
*/ function validate_email_format($email) {
|
*/ function validate_email_format($email) {
|
if(strpos($email, ' ') !== false) { return false; } // Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^\?=\/]+@[a-zA-Z0-9-]+\.([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,}$/si", $email);
| return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
|
}
/**
| }
/**
|
Zeile 6313 | Zeile 6452 |
---|
* @param string $email The email to check. * @param int $uid User ID of the user (updating only) * @return boolean True when in use, false when not.
|
* @param string $email The email to check. * @param int $uid User ID of the user (updating only) * @return boolean True when in use, false when not.
|
*/
| */
|
function email_already_in_use($email, $uid=0) { global $db;
| function email_already_in_use($email, $uid=0) { global $db;
|
Zeile 6328 | Zeile 6467 |
---|
if($db->fetch_field($query, "emails") > 0) { return true;
|
if($db->fetch_field($query, "emails") > 0) { return true;
|
}
| }
|
return false; }
| return false; }
|
Zeile 6341 | Zeile 6480 |
---|
{ global $db, $mybb;
|
{ global $db, $mybb;
|
if(!file_exists(MYBB_ROOT."inc/settings.php")) { $mode = "x"; } else { $mode = "w"; }
$options = array( "order_by" => "title", "order_dir" => "ASC" ); $query = $db->simple_select("settings", "value, name", "", $options);
| $query = $db->simple_select("settings", "value, name", "", array( 'order_by' => 'title', 'order_dir' => 'ASC', ));
|
|
|
$settings = null;
| $settings = '';
|
while($setting = $db->fetch_array($query)) { $mybb->settings[$setting['name']] = $setting['value'];
| while($setting = $db->fetch_array($query)) { $mybb->settings[$setting['name']] = $setting['value'];
|
Zeile 6365 | Zeile 6494 |
---|
}
$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n";
|
}
$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n";
|
$file = @fopen(MYBB_ROOT."inc/settings.php", $mode); @fwrite($file, $settings); @fclose($file);
| file_put_contents(MYBB_ROOT.'inc/settings.php', $settings, LOCK_EX);
|
$GLOBALS['settings'] = &$mybb->settings; }
|
$GLOBALS['settings'] = &$mybb->settings; }
|
|
|
/** * Build a PREG compatible array of search highlight terms to replace in posts. *
| /** * Build a PREG compatible array of search highlight terms to replace in posts. *
|
Zeile 6388 | Zeile 6516 |
---|
}
if(is_array($terms))
|
}
if(is_array($terms))
|
{
| {
|
$terms = implode(' ', $terms); }
| $terms = implode(' ', $terms); }
|
Zeile 6412 | Zeile 6540 |
---|
{ $phrase = htmlspecialchars_uni($phrase); if($phrase != "")
|
{ $phrase = htmlspecialchars_uni($phrase); if($phrase != "")
|
{
| {
|
if($inquote) { $words[] = trim($phrase);
| if($inquote) { $words[] = trim($phrase);
|
Zeile 6435 | Zeile 6563 |
---|
} } $inquote = !$inquote;
|
} } $inquote = !$inquote;
|
}
| }
|
} // Otherwise just a simple search query with no phrases else
| } // Otherwise just a simple search query with no phrases else
|
Zeile 6458 | Zeile 6586 |
---|
if(!is_array($words)) { return false;
|
if(!is_array($words)) { return false;
|
}
| }
|
// Sort the word array by length. Largest terms go first and work their way down to the smallest term. // This resolves problems like "test tes" where "tes" will be highlighted first, then "test" can't be highlighted because of the changed html
|
// Sort the word array by length. Largest terms go first and work their way down to the smallest term. // This resolves problems like "test tes" where "tes" will be highlighted first, then "test" can't be highlighted because of the changed html
|
usort($words, create_function('$a,$b', 'return strlen($b) - strlen($a);'));
| usort($words, 'build_highlight_array_sort');
|
// Loop through our words to build the PREG compatible strings foreach($words as $word)
| // Loop through our words to build the PREG compatible strings foreach($words as $word)
|
Zeile 6484 | Zeile 6612 |
---|
}
return $highlight_cache;
|
}
return $highlight_cache;
|
| }
/** * Sort the word array by length. Largest terms go first and work their way down to the smallest term. * * @param string $a First word. * @param string $b Second word. * @return integer Result of comparison function. */ function build_highlight_array_sort($a, $b) { return strlen($b) - strlen($a);
|
}
/**
| }
/**
|
Zeile 7583 | Zeile 7723 |
---|
array('::', '(int)"$1"?"$1":"0$1"'), $r); return $r;
|
array('::', '(int)"$1"?"$1":"0$1"'), $r); return $r;
|
}
| }
|
return false; } }
| return false; } }
|
Zeile 7647 | Zeile 7787 |
---|
// Invalid IP address return false; }
|
// Invalid IP address return false; }
|
}
| }
|
/** * Taken from: https://github.com/NewEraCracker/php_work/blob/master/ipRangeCalculate.php
| /** * Taken from: https://github.com/NewEraCracker/php_work/blob/master/ipRangeCalculate.php
|
Zeile 7663 | Zeile 7803 |
---|
// IP bits (lots of 0's and 1's) $ip_bits = ''; for($i = 0; $i < $ip_pack_size; $i = $i+1)
|
// IP bits (lots of 0's and 1's) $ip_bits = ''; for($i = 0; $i < $ip_pack_size; $i = $i+1)
|
{
| {
|
$bit = decbin(ord($ip_pack[$i])); $bit = str_pad($bit, 8, '0', STR_PAD_LEFT); $ip_bits .= $bit; }
|
$bit = decbin(ord($ip_pack[$i])); $bit = str_pad($bit, 8, '0', STR_PAD_LEFT); $ip_bits .= $bit; }
|
|
|
// Significative bits (from the ip range) $ip_bits = substr($ip_bits, 0, $ip_range);
| // Significative bits (from the ip range) $ip_bits = substr($ip_bits, 0, $ip_range);
|
Zeile 7678 | Zeile 7818 |
---|
// Lower IP $ip_lower_pack = '';
|
// Lower IP $ip_lower_pack = '';
|
for($i=0; $i < $ip_bits_size; $i=$i+8) {
| for($i=0; $i < $ip_bits_size; $i=$i+8) {
|
$chr = substr($ip_lower_bits, $i, 8); $chr = chr(bindec($chr)); $ip_lower_pack .= $chr;
|
$chr = substr($ip_lower_bits, $i, 8); $chr = chr(bindec($chr)); $ip_lower_pack .= $chr;
|
}
| }
|
// Higher IP $ip_higher_pack = '';
| // Higher IP $ip_higher_pack = '';
|
Zeile 7695 | Zeile 7835 |
---|
}
return array($ip_lower_pack, $ip_higher_pack);
|
}
return array($ip_lower_pack, $ip_higher_pack);
|
}
| }
|
// Just on IP address else {
| // Just on IP address else {
|
Zeile 7711 | Zeile 7851 |
---|
function get_execution_time() { static $time_start;
|
function get_execution_time() { static $time_start;
|
|
|
$time = microtime(true);
| $time = microtime(true);
|
Zeile 7773 | Zeile 7913 |
---|
if(is_dir($path."/".$file)) { verify_files($path."/".$file, ($count+1));
|
if(is_dir($path."/".$file)) { verify_files($path."/".$file, ($count+1));
|
continue; }
| continue; }
|
// We only need the last part of the path (from the MyBB directory to the file. i.e. inc/functions.php) $file_path = ".".str_replace(substr(MYBB_ROOT, 0, -1), "", $path)."/".$file;
| // We only need the last part of the path (from the MyBB directory to the file. i.e. inc/functions.php) $file_path = ".".str_replace(substr(MYBB_ROOT, 0, -1), "", $path)."/".$file;
|
Zeile 7784 | Zeile 7924 |
---|
{ $filename = $path."/".$file; $handle = fopen($filename, "rb");
|
{ $filename = $path."/".$file; $handle = fopen($filename, "rb");
|
$contents = '';
| $hashingContext = hash_init('sha512');
|
while(!feof($handle)) {
|
while(!feof($handle)) {
|
$contents .= fread($handle, 8192);
| hash_update($hashingContext, fread($handle, 8192));
|
} fclose($handle);
|
} fclose($handle);
|
$md5 = md5($contents);
| $checksum = hash_final($hashingContext);
|
// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes)
|
// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes)
|
if(!in_array($md5, $checksums[$file_path]))
| if(!in_array($checksum, $checksums[$file_path]))
|
{ $bad_verify_files[] = array("status" => "changed", "path" => $file_path); }
| { $bad_verify_files[] = array("status" => "changed", "path" => $file_path); }
|
Zeile 7842 | Zeile 7982 |
---|
else { return "+$int";
|
else { return "+$int";
|
}
| }
|
}
/**
| }
/**
|
Zeile 7869 | Zeile 8009 |
---|
{ $output = @fread($handle, $bytes); @fclose($handle);
|
{ $output = @fread($handle, $bytes); @fclose($handle);
|
} } else { return $output; }
| } } else { return $output; }
|
if(strlen($output) < $bytes) {
| if(strlen($output) < $bytes) {
|
Zeile 7890 | Zeile 8030 |
---|
}
$output = @mcrypt_create_iv($bytes, $source);
|
}
$output = @mcrypt_create_iv($bytes, $source);
|
}
| }
|
} else {
| } else {
|
Zeile 7906 | Zeile 8046 |
---|
{ $output = openssl_random_pseudo_bytes($bytes, $crypto_strong); if ($crypto_strong == false)
|
{ $output = openssl_random_pseudo_bytes($bytes, $crypto_strong); if ($crypto_strong == false)
|
{
| {
|
$output = null; } }
| $output = null; } }
|
Zeile 7953 | Zeile 8093 |
---|
$output = substr($output, 0, ($bytes * 2));
$output = pack('H*', $output);
|
$output = substr($output, 0, ($bytes * 2));
$output = pack('H*', $output);
|
return $output;
| return $output;
|
} else {
| } else {
|
Zeile 7970 | Zeile 8110 |
---|
function secure_seed_rng() { $bytes = PHP_INT_SIZE;
|
function secure_seed_rng() { $bytes = PHP_INT_SIZE;
|
|
|
do {
| do {
|
Zeile 8224 | Zeile 8364 |
---|
{ // Valid UTF-8 sequence? if(!preg_match('##u', $input))
|
{ // Valid UTF-8 sequence? if(!preg_match('##u', $input))
|
{
| {
|
$string = ''; $len = strlen($input); for($i = 0; $i < $len; $i++)
| $string = ''; $len = strlen($input); for($i = 0; $i < $len; $i++)
|
Zeile 8238 | Zeile 8378 |
---|
{ $string .= '?'; continue;
|
{ $string .= '?'; continue;
|
} else {
| } else {
|
return false; } }
| return false; } }
|
Zeile 8304 | Zeile 8444 |
---|
} } $input = $string;
|
} } $input = $string;
|
}
| }
|
if($return) { if($allow_mb4)
| if($return) { if($allow_mb4)
|
Zeile 8352 | Zeile 8492 |
---|
}
if(isset($pm['language']))
|
}
if(isset($pm['language']))
|
{
| {
|
if($pm['language'] != $mybb->user['language'] && $lang->language_exists($pm['language']))
|
if($pm['language'] != $mybb->user['language'] && $lang->language_exists($pm['language']))
|
{
| {
|
// Load user language $lang->set_language($pm['language']); $lang->load($pm['language_file']);
|
// Load user language $lang->set_language($pm['language']); $lang->load($pm['language_file']);
|
|
|
$revert = true; }
| $revert = true; }
|
Zeile 8368 | Zeile 8508 |
---|
{ $lang_string = $lang->{$pm[$key][0]}; $num_args = count($pm[$key]);
|
{ $lang_string = $lang->{$pm[$key][0]}; $num_args = count($pm[$key]);
|
|
|
for($i = 1; $i < $num_args; $i++) { $lang_string = str_replace('{'.$i.'}', $pm[$key][$i], $lang_string);
| for($i = 1; $i < $num_args; $i++) { $lang_string = str_replace('{'.$i.'}', $pm[$key][$i], $lang_string);
|
Zeile 8449 | Zeile 8589 |
---|
"readreceipt" => 0 );
|
"readreceipt" => 0 );
|
$pm['saveasdraft'] = 0;
| $pm['saveasdraft'] = 0;
|
// Admin override $pmhandler->admin_override = (int)$admin_override;
| // Admin override $pmhandler->admin_override = (int)$admin_override;
|
Zeile 8464 | Zeile 8604 |
---|
return false; }
|
return false; }
|
|
|
/** * Log a user spam block from StopForumSpam (or other spam service providers...) *
| /** * Log a user spam block from StopForumSpam (or other spam service providers...) *
|
Zeile 8479 | Zeile 8619 |
---|
global $db, $session;
if(!is_array($data))
|
global $db, $session;
if(!is_array($data))
|
{
| {
|
$data = array($data); }
| $data = array($data); }
|
Zeile 8511 | Zeile 8651 |
---|
* @return bool Whether the file was copied successfully. */ function copy_file_to_cdn($file_path = '', &$uploaded_path = null)
|
* @return bool Whether the file was copied successfully. */ function copy_file_to_cdn($file_path = '', &$uploaded_path = null)
|
{
| {
|
global $mybb, $plugins;
|
global $mybb, $plugins;
|
$success = false;
$file_path = (string)$file_path;
| $success = false;
|
|
|
$real_file_path = realpath($file_path);
| $file_path = (string)$file_path;
$real_file_path = realpath($file_path);
|
$file_dir_path = dirname($real_file_path); $file_dir_path = str_replace(MYBB_ROOT, '', $file_dir_path); $file_dir_path = ltrim($file_dir_path, './\\');
|
$file_dir_path = dirname($real_file_path); $file_dir_path = str_replace(MYBB_ROOT, '', $file_dir_path); $file_dir_path = ltrim($file_dir_path, './\\');
|
|
|
$file_name = basename($real_file_path);
if(file_exists($file_path))
|
$file_name = basename($real_file_path);
if(file_exists($file_path))
|
{
| {
|
if($mybb->settings['usecdn'] && !empty($mybb->settings['cdnpath'])) { $cdn_path = rtrim($mybb->settings['cdnpath'], '/\\');
| if($mybb->settings['usecdn'] && !empty($mybb->settings['cdnpath'])) { $cdn_path = rtrim($mybb->settings['cdnpath'], '/\\');
|
Zeile 8535 | Zeile 8675 |
---|
if(substr($file_dir_path, 0, my_strlen(MYBB_ROOT)) == MYBB_ROOT) { $file_dir_path = str_replace(MYBB_ROOT, '', $file_dir_path);
|
if(substr($file_dir_path, 0, my_strlen(MYBB_ROOT)) == MYBB_ROOT) { $file_dir_path = str_replace(MYBB_ROOT, '', $file_dir_path);
|
}
| }
|
$cdn_upload_path = $cdn_path . DIRECTORY_SEPARATOR . $file_dir_path;
if(!($dir_exists = is_dir($cdn_upload_path))) { $dir_exists = @mkdir($cdn_upload_path, 0777, true);
|
$cdn_upload_path = $cdn_path . DIRECTORY_SEPARATOR . $file_dir_path;
if(!($dir_exists = is_dir($cdn_upload_path))) { $dir_exists = @mkdir($cdn_upload_path, 0777, true);
|
}
| }
|
if($dir_exists) { if(($cdn_upload_path = realpath($cdn_upload_path)) !== false) { $success = @copy($file_path, $cdn_upload_path.DIRECTORY_SEPARATOR.$file_name);
|
if($dir_exists) { if(($cdn_upload_path = realpath($cdn_upload_path)) !== false) { $success = @copy($file_path, $cdn_upload_path.DIRECTORY_SEPARATOR.$file_name);
|
|
|
if($success) { $uploaded_path = $cdn_upload_path;
| if($success) { $uploaded_path = $cdn_upload_path;
|
Zeile 8559 | Zeile 8699 |
---|
}
if(is_object($plugins))
|
}
if(is_object($plugins))
|
{
| {
|
$hook_args = array( 'file_path' => &$file_path, 'real_file_path' => &$real_file_path,
| $hook_args = array( 'file_path' => &$file_path, 'real_file_path' => &$real_file_path,
|
Zeile 8567 | Zeile 8707 |
---|
'uploaded_path' => &$uploaded_path, 'success' => &$success, );
|
'uploaded_path' => &$uploaded_path, 'success' => &$success, );
|
|
|
$plugins->run_hooks('copy_file_to_cdn_end', $hook_args); } }
|
$plugins->run_hooks('copy_file_to_cdn_end', $hook_args); } }
|
|
|
return $success;
|
return $success;
|
}
/**
| }
/**
|
* Validate an url
|
* Validate an url
|
*
| *
|
* @param string $url The url to validate. * @param bool $relative_path Whether or not the url could be a relative path.
|
* @param string $url The url to validate. * @param bool $relative_path Whether or not the url could be a relative path.
|
| * @param bool $allow_local Whether or not the url could be pointing to local networks.
|
* * @return bool Whether this is a valid url. */
|
* * @return bool Whether this is a valid url. */
|
function my_validate_url($url, $relative_path=false)
| function my_validate_url($url, $relative_path=false, $allow_local=false)
|
{
|
{
|
if($relative_path && my_substr($url, 0, 1) == '/' || preg_match('_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$_iuS', $url))
| if($allow_local) { $regex = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:localhost|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?))(?::\d{2,5})?(?:[/?#]\S*)?$_iuS'; } else { $regex = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$_iuS'; }
if($relative_path && my_substr($url, 0, 1) == '/' || preg_match($regex, $url))
|
{ return true; }
|
{ return true; }
|
| |
return false;
|
return false;
|
}
/**
| }
/**
|
* Strip html tags from string, also removes <script> and <style> contents.
|
* Strip html tags from string, also removes <script> and <style> contents.
|
*
| *
|
* @param string $string String to stripe * @param string $allowable_tags Allowed html tags
|
* @param string $string String to stripe * @param string $allowable_tags Allowed html tags
|
*
| *
|
* @return string Striped string */ function my_strip_tags($string, $allowable_tags = '')
| * @return string Striped string */ function my_strip_tags($string, $allowable_tags = '')
|
Zeile 8611 | Zeile 8760 |
---|
); $string = preg_replace($pattern, '', $string); return strip_tags($string, $allowable_tags);
|
); $string = preg_replace($pattern, '', $string); return strip_tags($string, $allowable_tags);
|
| }
/** * Escapes a RFC 4180-compliant CSV string. * Based on https://github.com/Automattic/camptix/blob/f80725094440bf09861383b8f11e96c177c45789/camptix.php#L2867 * * @param string $string The string to be escaped * @param boolean $escape_active_content Whether or not to escape active content trigger characters * @return string The escaped string */ function my_escape_csv($string, $escape_active_content=true) { if($escape_active_content) { $active_content_triggers = array('=', '+', '-', '@'); $delimiters = array(',', ';', ':', '|', '^', "\n", "\t", " ");
$first_character = mb_substr($string, 0, 1);
if( in_array($first_character, $active_content_triggers, true) || in_array($first_character, $delimiters, true) ) { $string = "'".$string; }
foreach($delimiters as $delimiter) { foreach($active_content_triggers as $trigger) { $string = str_replace($delimiter.$trigger, $delimiter."'".$trigger, $string); } } }
$string = str_replace('"', '""', $string);
return $string;
|
}
| }
|