Declare type of arguments
This commit is contained in:
parent
20de03396f
commit
0186fa70ee
|
@ -316,7 +316,7 @@ else if (isset($_GET['edit_forum']))
|
|||
<option value="0"><?php echo $lang_subforums['No parent forum'] ?></option>
|
||||
<?php
|
||||
// MOD subforums - Visman
|
||||
function sf_select_view($id, $cur_forum, $space = '')
|
||||
function sf_select_view(int $id, $cur_forum, $space = '')
|
||||
{
|
||||
global $sf_array_tree, $sf_array_asc;
|
||||
|
||||
|
@ -513,7 +513,7 @@ if (!empty($sf_array_tree[0])) // MOD subforums - Visman
|
|||
$cur_index = 4;
|
||||
|
||||
// MOD subforum - Visman
|
||||
function sf_list_view($id, $space = '')
|
||||
function sf_list_view(int $id, $space = '')
|
||||
{
|
||||
global $sf_array_tree, $cur_index, $lang_admin_common, $lang_admin_forums;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ require PUN_ROOT.'include/common.php';
|
|||
require PUN_ROOT.'include/common_admin.php';
|
||||
|
||||
|
||||
function sva_gf($key)
|
||||
function sva_gf(string $key)
|
||||
{
|
||||
return $_POST['form'][$key] ?? '';
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class flux_addon_manager
|
|||
$d->close();
|
||||
}
|
||||
|
||||
function bind($hook, $callback)
|
||||
function bind(string $hook, $callback)
|
||||
{
|
||||
if (!isset($this->hooks[$hook]))
|
||||
$this->hooks[$hook] = array();
|
||||
|
@ -53,7 +53,7 @@ class flux_addon_manager
|
|||
$this->hooks[$hook][] = $callback;
|
||||
}
|
||||
|
||||
function hook($name)
|
||||
function hook(string $name)
|
||||
{
|
||||
if (!$this->loaded)
|
||||
$this->load();
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2011-2015 Visman (mio.visman@yandex.ru)
|
||||
* Copyright (C) 2011-2023 Visman (mio.visman@yandex.ru)
|
||||
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
|
||||
*/
|
||||
|
||||
|
||||
if (!defined('PUN')) exit;
|
||||
|
||||
|
||||
function ua_isbot($ua, $ual)
|
||||
function ua_isbot(string $ua, string $ual)
|
||||
{
|
||||
if (!trim($ua))
|
||||
return false;
|
||||
|
|
|
@ -233,7 +233,7 @@ function generate_admins_cache()
|
|||
//
|
||||
// Safely write out a cache file.
|
||||
//
|
||||
function fluxbb_write_cache_file($file, $content)
|
||||
function fluxbb_write_cache_file(string $file, string $content)
|
||||
{
|
||||
$fh = @fopen(FORUM_CACHE_DIR.$file, 'wb');
|
||||
if (!$fh)
|
||||
|
@ -377,7 +377,7 @@ function generate_subforums_cache($group_id = false)
|
|||
//
|
||||
// Invalidate updated php files that are cached by an opcache
|
||||
//
|
||||
function fluxbb_invalidate_cached_file($file)
|
||||
function fluxbb_invalidate_cached_file(string $file)
|
||||
{
|
||||
if (function_exists('opcache_invalidate'))
|
||||
opcache_invalidate($file, true);
|
||||
|
|
|
@ -18,7 +18,7 @@ if (!defined('FORUM_EOL'))
|
|||
//
|
||||
// Validate an email address
|
||||
//
|
||||
function is_valid_email($email)
|
||||
function is_valid_email(string $email)
|
||||
{
|
||||
if (strlen($email) > 80)
|
||||
return false;
|
||||
|
@ -30,7 +30,7 @@ function is_valid_email($email)
|
|||
//
|
||||
// Check if $email is banned
|
||||
//
|
||||
function is_banned_email($email, $id = false)
|
||||
function is_banned_email(string $email, $id = false)
|
||||
{
|
||||
global $pun_bans;
|
||||
|
||||
|
@ -66,7 +66,7 @@ function is_banned_email($email, $id = false)
|
|||
//
|
||||
// Only encode with base64, if there is at least one unicode character in the string
|
||||
//
|
||||
function encode_mail_text($str)
|
||||
function encode_mail_text(string $str)
|
||||
{
|
||||
if (preg_match('%[^\x20-\x7F]%', $str)) {
|
||||
return '=?UTF-8?B?' . base64_encode($str) . '?=';
|
||||
|
@ -79,7 +79,7 @@ function encode_mail_text($str)
|
|||
//
|
||||
// Make a post email safe
|
||||
//
|
||||
function bbcode2email($text, $wrap_length = 72, $language = null)
|
||||
function bbcode2email(string $text, $wrap_length = 72, $language = null)
|
||||
{
|
||||
static $base_url;
|
||||
static $wrotes = array();
|
||||
|
@ -245,7 +245,7 @@ function bbcode2email($text, $wrap_length = 72, $language = null)
|
|||
//
|
||||
// Wrapper for PHP's mail()
|
||||
//
|
||||
function pun_mail($to, $subject, $message, $reply_to_email = '', $reply_to_name = '')
|
||||
function pun_mail(string $to, string $subject, string $message, $reply_to_email = '', $reply_to_name = '')
|
||||
{
|
||||
global $pun_config, $lang_common;
|
||||
|
||||
|
@ -310,7 +310,7 @@ function server_parse($socket, $expected_response)
|
|||
// This function was originally a part of the phpBB Group forum software phpBB2 (http://www.phpbb.com)
|
||||
// They deserve all the credit for writing it. I made small modifications for it to suit PunBB and its coding standards.
|
||||
//
|
||||
function smtp_mail($to, $subject, $message, $headers = '')
|
||||
function smtp_mail(string $to, string $subject, string $message, $headers = '')
|
||||
{
|
||||
global $pun_config;
|
||||
static $local_host;
|
||||
|
|
|
@ -134,7 +134,7 @@ function check_cookie(&$pun_user)
|
|||
//
|
||||
// Converts the CDATA end sequence ]]> into ]]>
|
||||
//
|
||||
function escape_cdata($str)
|
||||
function escape_cdata(string $str)
|
||||
{
|
||||
return str_replace(']]>', ']]>', $str);
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ function escape_cdata($str)
|
|||
// $user can be either a user ID (integer) or a username (string)
|
||||
// $password can be either a plaintext password or a password hash including salt ($password_is_hash must be set accordingly)
|
||||
//
|
||||
function authenticate_user($user, $password, $password_is_hash = false)
|
||||
function authenticate_user($user, string $password, $password_is_hash = false)
|
||||
{
|
||||
global $db, $pun_user;
|
||||
|
||||
|
@ -157,7 +157,7 @@ function authenticate_user($user, $password, $password_is_hash = false)
|
|||
isset($pun_user['id'])
|
||||
&& $pun_user['id'] > 1
|
||||
&& (
|
||||
($password_is_hash && true === hash_equals((string) $password, $pun_user['password']))
|
||||
($password_is_hash && true === hash_equals($password, $pun_user['password']))
|
||||
|| (! $password_is_hash && false !== forum_password_verify($password, $pun_user))
|
||||
)
|
||||
) {
|
||||
|
@ -325,7 +325,7 @@ function set_default_user()
|
|||
//
|
||||
// SHA1 HMAC with PHP 4 fallback
|
||||
//
|
||||
function forum_hmac($data, $key, $raw_output = false)
|
||||
function forum_hmac(string $data, string $key, $raw_output = false)
|
||||
{
|
||||
return hash_hmac('sha1', $data, $key, $raw_output);
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ function forum_hmac($data, $key, $raw_output = false)
|
|||
// Set a cookie, FluxBB style!
|
||||
// Wrapper for forum_setcookie
|
||||
//
|
||||
function pun_setcookie($user_id, $password_hash, $expire)
|
||||
function pun_setcookie(int $user_id, string $password_hash, int $expire)
|
||||
{
|
||||
global $cookie_name, $cookie_seed;
|
||||
|
||||
|
@ -346,7 +346,7 @@ function pun_setcookie($user_id, $password_hash, $expire)
|
|||
//
|
||||
// Set a cookie, FluxBB style!
|
||||
//
|
||||
function forum_setcookie($name, $value, $expire)
|
||||
function forum_setcookie(string $name, string $value, int $expire)
|
||||
{
|
||||
global $cookie_path, $cookie_domain, $cookie_secure, $pun_config, $cookie_samesite;
|
||||
|
||||
|
@ -456,7 +456,7 @@ function check_bans()
|
|||
//
|
||||
// Check username
|
||||
//
|
||||
function check_username($username, $exclude_id = null)
|
||||
function check_username(string $username, $exclude_id = null)
|
||||
{
|
||||
global $db, $pun_config, $errors, $lang_prof_reg, $lang_register, $lang_common;
|
||||
|
||||
|
@ -611,7 +611,7 @@ function generate_profile_menu($page = '')
|
|||
//
|
||||
// Outputs markup to display a user's avatar
|
||||
//
|
||||
function generate_avatar_markup($user_id)
|
||||
function generate_avatar_markup(int $user_id)
|
||||
{
|
||||
global $pun_config;
|
||||
|
||||
|
@ -720,7 +720,7 @@ function get_tracked_topics()
|
|||
//
|
||||
// Shortcut method for executing all callbacks registered with the addon manager for the given hook
|
||||
//
|
||||
function flux_hook($name)
|
||||
function flux_hook(string $name)
|
||||
{
|
||||
global $flux_addons;
|
||||
|
||||
|
@ -878,7 +878,7 @@ function forum_clear_cache()
|
|||
//
|
||||
// Replace censored words in $text
|
||||
//
|
||||
function censor_words($text)
|
||||
function censor_words(string $text)
|
||||
{
|
||||
global $db;
|
||||
static $search_for, $replace_with;
|
||||
|
@ -959,7 +959,7 @@ function get_title($user)
|
|||
//
|
||||
// Generate a string with numbered links (for multipage scripts)
|
||||
//
|
||||
function paginate($num_pages, $cur_page, $link)
|
||||
function paginate(int $num_pages, int $cur_page, string $link)
|
||||
{
|
||||
global $lang_common;
|
||||
|
||||
|
@ -1032,7 +1032,7 @@ function paginate($num_pages, $cur_page, $link)
|
|||
//
|
||||
// Display a message
|
||||
//
|
||||
function message($message, $no_back_link = false, $http_status = null)
|
||||
function message(string $message, $no_back_link = false, $http_status = null)
|
||||
{
|
||||
global $db, $lang_common, $pun_config, $pun_start, $tpl_main, $pun_user, $page_js;
|
||||
|
||||
|
@ -1125,7 +1125,7 @@ function forum_number_format($number, $decimals = 0)
|
|||
//
|
||||
// Generate a random key of length $len
|
||||
//
|
||||
function random_key($len, $readable = false, $hash = false)
|
||||
function random_key(int $len, $readable = false, $hash = false)
|
||||
{
|
||||
$key = '';
|
||||
|
||||
|
@ -1164,7 +1164,7 @@ function confirm_message($error_msg = false)
|
|||
}
|
||||
|
||||
|
||||
function confirm_referrer($script, $error_msg = false, $use_ip = true)
|
||||
function confirm_referrer(string $script, $error_msg = false, $use_ip = true)
|
||||
{
|
||||
$hash = $_POST['csrf_hash'] ?? ($_GET['csrf_hash'] ?? null);
|
||||
|
||||
|
@ -1178,7 +1178,7 @@ function csrf_hash($script = false, $use_ip = true, $user = false)
|
|||
global $pun_config, $pun_user;
|
||||
static $arr = array();
|
||||
|
||||
$script = $script ? $script : basename($_SERVER['SCRIPT_NAME']);
|
||||
$script = $script ?: basename($_SERVER['SCRIPT_NAME']);
|
||||
$ip = $use_ip ? get_remote_address() : '';
|
||||
$user = is_array($user) ? $user : $pun_user;
|
||||
|
||||
|
@ -1195,7 +1195,7 @@ function csrf_hash($script = false, $use_ip = true, $user = false)
|
|||
//
|
||||
// Validate the given redirect URL, use the fallback otherwise
|
||||
//
|
||||
function validate_redirect($redirect_url, $fallback_url)
|
||||
function validate_redirect(string $redirect_url, string $fallback_url)
|
||||
{
|
||||
$referrer = parse_url(strtolower($redirect_url));
|
||||
|
||||
|
@ -1232,7 +1232,7 @@ function validate_redirect($redirect_url, $fallback_url)
|
|||
// Generate a random password of length $len
|
||||
// Compatibility wrapper for random_key
|
||||
//
|
||||
function random_pass($len)
|
||||
function random_pass(int $len)
|
||||
{
|
||||
return random_key($len, true);
|
||||
}
|
||||
|
@ -1241,7 +1241,7 @@ function random_pass($len)
|
|||
//
|
||||
// Compute a hash of $str
|
||||
//
|
||||
function pun_hash($str)
|
||||
function pun_hash(string $str)
|
||||
{
|
||||
global $salt1;
|
||||
|
||||
|
@ -1324,7 +1324,7 @@ function pun_htmlspecialchars_decode($str)
|
|||
//
|
||||
// A wrapper for mb_strlen for compatibility
|
||||
//
|
||||
function pun_strlen($str)
|
||||
function pun_strlen(string $str)
|
||||
{
|
||||
return mb_strlen($str);
|
||||
}
|
||||
|
@ -1333,7 +1333,7 @@ function pun_strlen($str)
|
|||
//
|
||||
// Convert \r\n and \r to \n
|
||||
//
|
||||
function pun_linebreaks($str)
|
||||
function pun_linebreaks(string $str)
|
||||
{
|
||||
return str_replace(array("\r\n", "\r"), "\n", $str);
|
||||
}
|
||||
|
@ -1361,7 +1361,7 @@ function pun_trim($str, $charlist = false)
|
|||
//
|
||||
// Checks if a string is in all uppercase
|
||||
//
|
||||
function is_all_uppercase($string)
|
||||
function is_all_uppercase(string $string)
|
||||
{
|
||||
return mb_strtoupper($string) === $string && mb_strtolower($string) !== $string;
|
||||
}
|
||||
|
@ -1370,7 +1370,7 @@ function is_all_uppercase($string)
|
|||
//
|
||||
// strcmp() for UTF-8 - Visman
|
||||
//
|
||||
function pun_strcasecmp($strX, $strY)
|
||||
function pun_strcasecmp(string $strX, string $strY)
|
||||
{
|
||||
return strcmp(mb_strtolower($strX), mb_strtolower($strY));
|
||||
}
|
||||
|
@ -1514,7 +1514,7 @@ function maintenance_message()
|
|||
//
|
||||
// Display $message and redirect user to $destination_url
|
||||
//
|
||||
function redirect($destination_url, $message)
|
||||
function redirect(string $destination_url, string $message)
|
||||
{
|
||||
global $db, $pun_config, $lang_common, $pun_user;
|
||||
|
||||
|
@ -1647,7 +1647,7 @@ function redirect($destination_url, $message)
|
|||
//
|
||||
// Display a simple error message
|
||||
//
|
||||
function error($message, $file = null, $line = null, $db_error = false)
|
||||
function error(string $message, $file = null, $line = null, $db_error = false)
|
||||
{
|
||||
global $pun_config, $lang_common;
|
||||
|
||||
|
@ -1909,7 +1909,7 @@ function generate_stopwords_cache_id()
|
|||
//
|
||||
// Split text into chunks ($inside contains all text inside $start and $end, and $outside contains all text outside)
|
||||
//
|
||||
function split_text($text, $start, $end, $retab = true)
|
||||
function split_text(string $text, $start, $end, $retab = true)
|
||||
{
|
||||
global $pun_config;
|
||||
|
||||
|
@ -1937,7 +1937,7 @@ function split_text($text, $start, $end, $retab = true)
|
|||
// Extract blocks from a text with a starting and ending string
|
||||
// This function always matches the most outer block so nesting is possible
|
||||
//
|
||||
function extract_blocks($text, $start, $end, $retab = true)
|
||||
function extract_blocks(string $text, $start, $end, $retab = true)
|
||||
{
|
||||
global $pun_config;
|
||||
|
||||
|
@ -2018,7 +2018,7 @@ function extract_blocks($text, $start, $end, $retab = true)
|
|||
// [fragment] => fragone
|
||||
// [url] => http://www.jmrware.com:80/articles?height=10&width=75#fragone
|
||||
// )
|
||||
function url_valid($url)
|
||||
function url_valid(string $url)
|
||||
{
|
||||
if (strpos($url, 'www.') === 0) $url = 'http://'. $url;
|
||||
if (strpos($url, 'ftp.') === 0) $url = 'ftp://'. $url;
|
||||
|
@ -2105,7 +2105,7 @@ function url_valid($url)
|
|||
//
|
||||
// This function also works on Windows Server where ACLs seem to be ignored.
|
||||
//
|
||||
function forum_is_writable($path)
|
||||
function forum_is_writable(string $path)
|
||||
{
|
||||
if (is_dir($path))
|
||||
{
|
||||
|
@ -2260,7 +2260,7 @@ function witt_query($var = NULL)
|
|||
//
|
||||
// MOD Subforums
|
||||
//
|
||||
function sf_crumbs($id)
|
||||
function sf_crumbs(int $id)
|
||||
{
|
||||
global $sf_array_desc;
|
||||
|
||||
|
@ -2278,7 +2278,7 @@ function sf_crumbs($id)
|
|||
//
|
||||
// Checks the password on the user's data array
|
||||
//
|
||||
function forum_password_verify($password, $user)
|
||||
function forum_password_verify(string $password, $user)
|
||||
{
|
||||
global $salt1;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ if (!isset($smilies))
|
|||
//
|
||||
// Make sure all BBCodes are lower case and do a little cleanup
|
||||
//
|
||||
function preparse_bbcode($text, &$errors, $is_signature = false)
|
||||
function preparse_bbcode(string $text, &$errors, $is_signature = false)
|
||||
{
|
||||
global $pun_config, $lang_common, $lang_post, $re_list;
|
||||
|
||||
|
@ -150,7 +150,7 @@ function preparse_bbcode($text, &$errors, $is_signature = false)
|
|||
//
|
||||
// Strip empty bbcode tags from some text
|
||||
//
|
||||
function strip_empty_bbcode($text)
|
||||
function strip_empty_bbcode(string $text)
|
||||
{
|
||||
// If the message contains a code tag we have to split it up (empty tags within [code][/code] are fine)
|
||||
if (strpos($text, '[code]') !== false && strpos($text, '[/code]') !== false)
|
||||
|
@ -194,7 +194,7 @@ function strip_empty_bbcode($text)
|
|||
//
|
||||
// Check the structure of bbcode tags and fix simple mistakes where possible
|
||||
//
|
||||
function preparse_tags($text, &$errors, $is_signature = false)
|
||||
function preparse_tags(string $text, &$errors, $is_signature = false)
|
||||
{
|
||||
global $lang_common, $pun_config, $pun_user;
|
||||
|
||||
|
@ -630,7 +630,7 @@ function preparse_tags($text, &$errors, $is_signature = false)
|
|||
//
|
||||
// Preparse the contents of [list] bbcode
|
||||
//
|
||||
function preparse_list_tag($content, $type = '*')
|
||||
function preparse_list_tag(string $content, $type = '*')
|
||||
{
|
||||
global $lang_common, $re_list;
|
||||
|
||||
|
@ -658,7 +658,7 @@ function preparse_list_tag($content, $type = '*')
|
|||
//
|
||||
// Truncate URL if longer than 55 characters (add http:// or ftp:// if missing)
|
||||
//
|
||||
function handle_url_tag($url, $link = '', $bbcode = false)
|
||||
function handle_url_tag(string $url, $link = '', $bbcode = false)
|
||||
{
|
||||
global $pun_config, $pun_user, $page_js;
|
||||
|
||||
|
@ -714,7 +714,7 @@ function handle_url_tag($url, $link = '', $bbcode = false)
|
|||
//
|
||||
// Turns an URL from the [img] tag into an <img> tag or a <a href...> tag
|
||||
//
|
||||
function handle_img_tag($url, $is_signature = false, $alt = null, $float = '')
|
||||
function handle_img_tag(string $url, $is_signature = false, $alt = null, $float = '')
|
||||
{
|
||||
global $lang_common, $pun_user;
|
||||
|
||||
|
@ -734,7 +734,7 @@ function handle_img_tag($url, $is_signature = false, $alt = null, $float = '')
|
|||
//
|
||||
// Email bbcode replace to <a href="mailto:... - Visman
|
||||
//
|
||||
function handle_email_tag($mail, $body = null)
|
||||
function handle_email_tag(string $mail, $body = null)
|
||||
{
|
||||
if (null === $body)
|
||||
$body = $mail;
|
||||
|
@ -747,7 +747,7 @@ function handle_email_tag($mail, $body = null)
|
|||
//
|
||||
// Parse the contents of [list] bbcode
|
||||
//
|
||||
function handle_list_tag($content, $type = '*')
|
||||
function handle_list_tag(string $content, $type = '*')
|
||||
{
|
||||
global $re_list;
|
||||
|
||||
|
@ -775,7 +775,7 @@ function handle_list_tag($content, $type = '*')
|
|||
//
|
||||
// ф-ия показывающая сколько прошло времени - Visman
|
||||
//
|
||||
function handle_time_tag($after_time)
|
||||
function handle_time_tag(string $after_time)
|
||||
{
|
||||
global $lang_common;
|
||||
|
||||
|
@ -803,7 +803,7 @@ function handle_time_tag($after_time)
|
|||
//
|
||||
// Convert BBCodes to their HTML equivalent
|
||||
//
|
||||
function do_bbcode($text, $is_signature = false)
|
||||
function do_bbcode(string $text, $is_signature = false)
|
||||
{
|
||||
global $lang_common, $pun_user, $pun_config, $re_list;
|
||||
|
||||
|
@ -930,7 +930,7 @@ function do_bbcode($text, $is_signature = false)
|
|||
//
|
||||
// Make hyperlinks clickable
|
||||
//
|
||||
function do_clickable($text)
|
||||
function do_clickable(string $text)
|
||||
{
|
||||
$text = ' '.$text;
|
||||
$text = preg_replace_callback('%(?<=[\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|imgr|imgl)\])%ui', function ($matches) { return stripslashes($matches[1].$matches[2].$matches[3].$matches[4]).handle_url_tag($matches[5]."://".$matches[6], $matches[5]."://".$matches[6], true).stripslashes($matches[4].forum_array_key($matches, 10).forum_array_key($matches, 11).forum_array_key($matches, 12)); }, $text);
|
||||
|
@ -952,7 +952,7 @@ function forum_array_key($arr, $key)
|
|||
//
|
||||
// Convert a series of smilies to images
|
||||
//
|
||||
function do_smilies($text)
|
||||
function do_smilies(string $text)
|
||||
{
|
||||
global $smilies;
|
||||
static $base;
|
||||
|
@ -976,7 +976,7 @@ function do_smilies($text)
|
|||
//
|
||||
// Parse message text
|
||||
//
|
||||
function parse_message($text, $hide_smilies)
|
||||
function parse_message(string $text, $hide_smilies)
|
||||
{
|
||||
global $pun_config, $lang_common, $pun_user;
|
||||
|
||||
|
@ -1033,7 +1033,7 @@ function parse_message($text, $hide_smilies)
|
|||
//
|
||||
// Clean up paragraphs and line breaks
|
||||
//
|
||||
function clean_paragraphs($text)
|
||||
function clean_paragraphs(string $text)
|
||||
{
|
||||
// Add paragraph tag around post, but make sure there are no empty paragraphs
|
||||
|
||||
|
@ -1059,7 +1059,7 @@ function clean_paragraphs($text)
|
|||
//
|
||||
// Parse signature text
|
||||
//
|
||||
function parse_signature($text)
|
||||
function parse_signature(string $text)
|
||||
{
|
||||
global $pun_config, $lang_common, $pun_user;
|
||||
|
||||
|
@ -1087,7 +1087,7 @@ function parse_signature($text)
|
|||
//
|
||||
// Обработчик для текста, но не для кода html тегов - Visman
|
||||
//
|
||||
function sva_do_for_only_text($text, $do_smilies)
|
||||
function sva_do_for_only_text(string $text, $do_smilies)
|
||||
{
|
||||
if (! $do_smilies || '' === $text)
|
||||
return $text;
|
||||
|
|
|
@ -167,12 +167,12 @@ function pmsn_user_delete(int $user, $mflag, $topics = array())
|
|||
pmsn_user_update($user_up[$i]);
|
||||
}
|
||||
|
||||
function pmsn_get_var($name, $default = null)
|
||||
function pmsn_get_var(string $name, $default = null)
|
||||
{
|
||||
return $_POST[$name] ?? ($_GET[$name] ?? $default);
|
||||
}
|
||||
|
||||
function pmsn_csrf_token($key)
|
||||
function pmsn_csrf_token(string $key)
|
||||
{
|
||||
global $pun_config, $pun_user;
|
||||
static $arr = array();
|
||||
|
|
|
@ -16,7 +16,7 @@ else
|
|||
require PUN_ROOT.'lang/English/poll.php';
|
||||
|
||||
// вывод сообщений *************************************************************
|
||||
function poll_mess($mess, $ques = '', $vote = '')
|
||||
function poll_mess(string $mess, $ques = '', $vote = '')
|
||||
{
|
||||
global $lang_poll;
|
||||
|
||||
|
@ -31,7 +31,7 @@ function poll_mess($mess, $ques = '', $vote = '')
|
|||
}
|
||||
|
||||
// получение данных из формы ***************************************************
|
||||
function poll_post($var, $default = null)
|
||||
function poll_post(string $var, $default = null)
|
||||
{
|
||||
return isset($_POST[$var]) ? $_POST[$var] : $default;
|
||||
}
|
||||
|
@ -142,13 +142,13 @@ function poll_form_post($tid)
|
|||
}
|
||||
|
||||
// форма редактирования ********************************************************
|
||||
function poll_form_edit($tid)
|
||||
function poll_form_edit(int $tid)
|
||||
{
|
||||
poll_form($tid);
|
||||
}
|
||||
|
||||
// данные по опросу ************************************************************
|
||||
function poll_topic($tid)
|
||||
function poll_topic(int $tid)
|
||||
{
|
||||
global $cur_post, $cur_topic;
|
||||
|
||||
|
@ -169,7 +169,7 @@ function poll_topic($tid)
|
|||
}
|
||||
|
||||
// форма ввода/редактирования **************************************************
|
||||
function poll_form($tid)
|
||||
function poll_form(int $tid)
|
||||
{
|
||||
global $cur_index, $lang_poll, $pun_config, $tpl_main;
|
||||
|
||||
|
@ -346,7 +346,7 @@ function ForQues(num,t){if(num > max_ques){return false}var div=document.getElem
|
|||
}
|
||||
|
||||
// проверяем правильность ******************************************************
|
||||
function poll_form_validate($tid, &$errors)
|
||||
function poll_form_validate(int $tid, &$errors)
|
||||
{
|
||||
global $lang_poll, $pun_config;
|
||||
|
||||
|
@ -401,14 +401,14 @@ function poll_form_validate($tid, &$errors)
|
|||
}
|
||||
|
||||
// удаление кэша опроса ********************************************************
|
||||
function poll_cache_delete($tid)
|
||||
function poll_cache_delete(int $tid)
|
||||
{
|
||||
if (file_exists(FORUM_CACHE_DIR.'polls/'.$tid.'.php'))
|
||||
@unlink(FORUM_CACHE_DIR.'polls/'.$tid.'.php');
|
||||
}
|
||||
|
||||
// удаление опроса *************************************************************
|
||||
function poll_delete($tid, $flag = false)
|
||||
function poll_delete(int $tid, $flag = false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
|
@ -421,7 +421,7 @@ function poll_delete($tid, $flag = false)
|
|||
}
|
||||
|
||||
// сохраняем опрос *************************************************************
|
||||
function poll_save($tid)
|
||||
function poll_save(int $tid)
|
||||
{
|
||||
global $db, $pun_config;
|
||||
|
||||
|
@ -505,7 +505,7 @@ function poll_save($tid)
|
|||
}
|
||||
|
||||
// результат голосования в теме ************************************************
|
||||
function poll_display_topic($tid, $uid, $p = 0, $f = false)
|
||||
function poll_display_topic(int $tid, int $uid, $p = 0, $f = false)
|
||||
{
|
||||
global $pun_config;
|
||||
static $info = null;
|
||||
|
@ -524,7 +524,7 @@ function poll_display_topic($tid, $uid, $p = 0, $f = false)
|
|||
}
|
||||
|
||||
// превью в посте **************************************************************
|
||||
function poll_display_post($tid, $uid)
|
||||
function poll_display_post(int $tid, int $uid)
|
||||
{
|
||||
global $pun_config;
|
||||
|
||||
|
@ -592,7 +592,7 @@ function poll_display_post($tid, $uid)
|
|||
}
|
||||
|
||||
// отображаем результат голосования ********************************************
|
||||
function poll_display($tid, $uid, $info, $top, $prev = false)
|
||||
function poll_display(int $tid, int $uid, $info, $top, $prev = false)
|
||||
{
|
||||
|
||||
global $db, $lang_poll, $pun_config, $lang_common;
|
||||
|
@ -731,7 +731,7 @@ function poll_display($tid, $uid, $info, $top, $prev = false)
|
|||
}
|
||||
|
||||
// голосуем ********************************************************************
|
||||
function poll_vote($tid, $uid)
|
||||
function poll_vote(int $tid, int $uid)
|
||||
{
|
||||
global $db;
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ function split_words_clear_link_minor($arr)
|
|||
}
|
||||
|
||||
|
||||
function split_words_clear_link($url)
|
||||
function split_words_clear_link(string $url)
|
||||
{
|
||||
$text = '';
|
||||
$arr = parse_url($url);
|
||||
|
@ -101,7 +101,7 @@ function split_words_clear_link($url)
|
|||
// "Cleans up" a text string and returns an array of unique words
|
||||
// This function depends on the current locale setting
|
||||
//
|
||||
function split_words($text, $idx)
|
||||
function split_words(string $text, $idx)
|
||||
{
|
||||
// Remove BBCode
|
||||
$text = preg_replace('%\[/?(b|u|s|ins|del|em|i|h|colou?r|quote|code|img|url|email|list|topic|post|forum|user|imgr|imgl|hr|size|after|spoiler|right|center|justify|mono)(?:\=[^\]]*)?\]%', ' ', $text);
|
||||
|
@ -158,7 +158,7 @@ function split_words($text, $idx)
|
|||
//
|
||||
// Checks if a word is a valid searchable word
|
||||
//
|
||||
function validate_search_word($word, $idx)
|
||||
function validate_search_word(string $word, $idx)
|
||||
{
|
||||
static $stopwords;
|
||||
|
||||
|
@ -201,7 +201,7 @@ function validate_search_word($word, $idx)
|
|||
//
|
||||
// Check a given word is a search keyword.
|
||||
//
|
||||
function is_keyword($word)
|
||||
function is_keyword(string $word)
|
||||
{
|
||||
return $word == 'and' || $word == 'or' || $word == 'not';
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ function is_keyword($word)
|
|||
//
|
||||
// Check if a given word is CJK or Hangul.
|
||||
//
|
||||
function is_cjk($word)
|
||||
function is_cjk(string $word)
|
||||
{
|
||||
return preg_match('%^'.PUN_CJK_HANGUL_REGEX.'+$%u', $word) ? true : false;
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ function is_cjk($word)
|
|||
//
|
||||
// Strip [img] [url] and [email] out of the message so we don't index their contents
|
||||
//
|
||||
function strip_bbcode($text)
|
||||
function strip_bbcode(string $text)
|
||||
{
|
||||
static $patterns;
|
||||
|
||||
|
@ -242,7 +242,7 @@ function strip_bbcode($text)
|
|||
//
|
||||
// Updates the search index with the contents of $post_id (and $subject)
|
||||
//
|
||||
function update_search_index($mode, int $post_id, $message, $subject = null)
|
||||
function update_search_index($mode, int $post_id, string $message, $subject = null)
|
||||
{
|
||||
global $db_type, $db;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ if (!defined('PUN'))
|
|||
exit;
|
||||
|
||||
|
||||
function security_lang($val, $isset = false)
|
||||
function security_lang(string $val, $isset = false)
|
||||
{
|
||||
static $lang_sec;
|
||||
|
||||
|
@ -31,7 +31,7 @@ function security_lang($val, $isset = false)
|
|||
}
|
||||
|
||||
|
||||
function security_encode_for_js($s)
|
||||
function security_encode_for_js(string $s)
|
||||
{
|
||||
global $pun_config, $page_js;
|
||||
|
||||
|
@ -69,7 +69,7 @@ function security_show_random_value($val)
|
|||
}
|
||||
|
||||
|
||||
function security_random_name($s)
|
||||
function security_random_name(string $s)
|
||||
{
|
||||
global $pun_config;
|
||||
static $s1_ar, $sar;
|
||||
|
|
|
@ -191,12 +191,12 @@ class upfClass
|
|||
}
|
||||
}
|
||||
|
||||
public function inBlackList($ext)
|
||||
public function inBlackList(string $ext)
|
||||
{
|
||||
return isset($this->blackList[strtolower($ext)]);
|
||||
}
|
||||
|
||||
public function dirSize($dir)
|
||||
public function dirSize(string $dir)
|
||||
{
|
||||
if ($this->isBadLink($dir)) {
|
||||
return false;
|
||||
|
@ -283,7 +283,7 @@ class upfClass
|
|||
*
|
||||
* @return false|array
|
||||
*/
|
||||
public function imageExt($path)
|
||||
public function imageExt(string $path)
|
||||
{
|
||||
if ($this->isBadLink($path)) {
|
||||
return false;
|
||||
|
@ -317,7 +317,7 @@ class upfClass
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function filterName($name)
|
||||
protected function filterName(string $name)
|
||||
{
|
||||
$new = false;
|
||||
if (function_exists('transliterator_transliterate')) {
|
||||
|
@ -377,7 +377,7 @@ class upfClass
|
|||
protected $fileIsUp;
|
||||
protected $image;
|
||||
|
||||
public function loadFile($path, $basename = null)
|
||||
public function loadFile(string $path, $basename = null)
|
||||
{
|
||||
$this->filePath = null;
|
||||
$this->fileName = null;
|
||||
|
@ -523,12 +523,12 @@ class upfClass
|
|||
];
|
||||
}
|
||||
|
||||
public function saveFile($path, $overwrite = false)
|
||||
public function saveFile(string $path, $overwrite = false)
|
||||
{
|
||||
return $this->save($path, $overwrite, false);
|
||||
}
|
||||
|
||||
public function saveImage($path, $overwrite = false)
|
||||
public function saveImage(string $path, $overwrite = false)
|
||||
{
|
||||
if (empty($this->image)) {
|
||||
$this->error = 'No image';
|
||||
|
@ -538,7 +538,7 @@ class upfClass
|
|||
return $this->save($path, $overwrite, true);
|
||||
}
|
||||
|
||||
protected function save($path, $overwrite, $isImage)
|
||||
protected function save(string $path, $overwrite, $isImage)
|
||||
{
|
||||
if ($this->isBadLink($path)) {
|
||||
return false;
|
||||
|
@ -646,7 +646,7 @@ class upfClass
|
|||
];
|
||||
}
|
||||
|
||||
public function resizeImage($width, $height = null)
|
||||
public function resizeImage(int $width, $height = null)
|
||||
{
|
||||
if (empty($this->image)) {
|
||||
$this->error = 'No image';
|
||||
|
@ -778,7 +778,7 @@ class upfClass
|
|||
$this->destroyImage();
|
||||
}
|
||||
|
||||
protected function hidePath($str, $path = null)
|
||||
protected function hidePath(string $str, $path = null)
|
||||
{
|
||||
$search = [];
|
||||
if (null !== $this->filePath) {
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
|
||||
*/
|
||||
|
||||
function ua_get_filename($name, $folder)
|
||||
function ua_get_filename(string $name, string $folder)
|
||||
{
|
||||
$name = preg_replace('%[^\w]%', '', strtolower($name));
|
||||
return get_base_url(true).'/img/user_agent/'.$folder.'/'.$name.'.png';
|
||||
}
|
||||
|
||||
function ua_search_for_item($items, $usrag)
|
||||
function ua_search_for_item($items, string $usrag)
|
||||
{
|
||||
foreach ($items as $item)
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ function ua_search_for_item($items, $usrag)
|
|||
return 'Unknown';
|
||||
}
|
||||
|
||||
function get_useragent_names($usrag)
|
||||
function get_useragent_names(string $usrag)
|
||||
{
|
||||
$browser_img = $browser_version = '';
|
||||
|
||||
|
@ -132,7 +132,7 @@ function get_useragent_names($usrag)
|
|||
return $result;
|
||||
}
|
||||
|
||||
function get_useragent_icons($usrag)
|
||||
function get_useragent_icons(string $usrag)
|
||||
{
|
||||
global $pun_user;
|
||||
static $uac = array();
|
||||
|
|
Loading…
Reference in New Issue