From 79ea41b3f49661fbd6e0cea94c67938c3b17207a Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Mon, 3 Oct 2016 23:56:46 +0300 Subject: [PATCH] PHPDoc and some reformat fixes. --- admin/admin_board.php | 12 +- admin/admin_bt_forum_cfg.php | 14 +- admin/admin_bt_tracker_cfg.php | 8 +- admin/admin_disallow.php | 13 +- admin/admin_forumauth.php | 60 +- admin/admin_forumauth_list.php | 39 +- admin/admin_forums.php | 66 +- admin/admin_groups.php | 2 +- admin/admin_mass_email.php | 2 +- admin/stats/tracker.php | 2 +- bt/announce.php | 3 - bt/includes/init_tr.php | 23 + common.php | 2 + library/ajax/view_torrent.php | 30 + library/includes/bbcode.php | 56 ++ library/includes/classes/emailer.php | 48 + library/includes/classes/sitemap.php | 40 + library/includes/core/dbs.php | 13 + library/includes/core/mysql.php | 75 ++ library/includes/cron/cron_init.php | 6 + library/includes/datastore/apc.php | 19 + library/includes/datastore/common.php | 31 + library/includes/datastore/file.php | 17 + library/includes/datastore/memcache.php | 23 + library/includes/datastore/redis.php | 23 + library/includes/datastore/sqlite.php | 17 + library/includes/datastore/xcache.php | 19 + library/includes/functions.php | 494 +++++++++++ library/includes/functions_admin.php | 49 ++ library/includes/functions_admin_cron.php | 20 + library/includes/functions_admin_torrent.php | 23 + library/includes/functions_atom.php | 18 + library/includes/functions_dev.php | 8 + library/includes/functions_group.php | 39 + library/includes/functions_post.php | 61 ++ library/includes/functions_selects.php | 15 + library/includes/functions_torrent.php | 76 ++ library/includes/functions_upload.php | 15 + library/includes/functions_validate.php | 10 + library/includes/init_bb.php | 55 +- library/includes/sessions.php | 32 + library/includes/smtp.php | 12 + library/includes/template.php | 27 + src/ServiceProviders/DbServiceProvider.php | 1 - styles/js/bbcode.js | 813 ++++++++--------- styles/js/main.js | 880 +++++++++---------- styles/templates/default/search.tpl | 4 +- styles/templates/default/tpl_config.php | 242 ++--- styles/templates/default/tracker.tpl | 2 +- 49 files changed, 2510 insertions(+), 1049 deletions(-) diff --git a/admin/admin_board.php b/admin/admin_board.php index 680ccc544..d1d67a4f1 100644 --- a/admin/admin_board.php +++ b/admin/admin_board.php @@ -17,9 +17,9 @@ $return_links = array( 'config_mods' => '

' . sprintf($lang['CLICK_RETURN_CONFIG_MODS'], '', '') ); -// -// Pull all config data -// +/** + * Pull all config data + */ $sql = "SELECT * FROM " . BB_CONFIG; if (!$result = DB()->sql_query($sql)) { bb_die('Could not query config information in admin_board'); @@ -32,7 +32,11 @@ if (!$result = DB()->sql_query($sql)) { $new[$config_name] = isset($_POST[$config_name]) ? $_POST[$config_name] : $default_config[$config_name]; if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) { - if ($config_name == 'seed_bonus_points' || $config_name == 'seed_bonus_release' || $config_name == 'bonus_upload' || $config_name == 'bonus_upload_price') { + if ($config_name == 'seed_bonus_points' || + $config_name == 'seed_bonus_release' || + $config_name == 'bonus_upload' || + $config_name == 'bonus_upload_price' + ) { $new[$config_name] = serialize(str_replace(',', '.', $new[$config_name])); } bb_update_config(array($config_name => $new[$config_name])); diff --git a/admin/admin_bt_forum_cfg.php b/admin/admin_bt_forum_cfg.php index 40e1143be..d2913976d 100644 --- a/admin/admin_bt_forum_cfg.php +++ b/admin/admin_bt_forum_cfg.php @@ -14,9 +14,11 @@ require(INC_DIR . 'functions_admin_torrent.php'); $submit = isset($_POST['submit']); $confirm = isset($_POST['confirm']); -$cfg = array(); +$cfg = []; -// All config names with default values +/** + * All config names with default values + */ $default_cfg_str = array( 'bt_announce_url' => 'http://demo.torrentpier.me/bt/', ); @@ -57,10 +59,14 @@ $db_fields_bool = array( 'self_moderated' => 0, // Users can move theirs topic to another forum ); -// Get config +/** + * Get config + */ $cfg = bb_get_config(BB_CONFIG, true, false); -// Submit new config +/** + * Submit new config + */ if ($submit && $confirm) { foreach ($db_fields_bool as $field_name => $field_def_val) { update_table_bool(BB_FORUMS, 'forum_id', $field_name, $field_def_val); diff --git a/admin/admin_bt_tracker_cfg.php b/admin/admin_bt_tracker_cfg.php index e1b5d7814..fe3363579 100644 --- a/admin/admin_bt_tracker_cfg.php +++ b/admin/admin_bt_tracker_cfg.php @@ -20,7 +20,9 @@ require(INC_DIR . 'functions_admin_torrent.php'); $submit = isset($_POST['submit']); $confirmed = isset($_POST['confirm']); -// All config names with default values +/** + * All config names with default values + */ $default_cfg_str = array( 'off_reason' => 'Tracker is disabled', 'browser_redirect_url' => 'http://demo.torrentpier.me/', @@ -46,7 +48,9 @@ $default_cfg_num = array( 'limit_leech_ips' => 0, ); -// Set template vars +/** + * Set template vars + */ set_tpl_vars($default_cfg_str, $tr_cfg); set_tpl_vars_lang($default_cfg_str); diff --git a/admin/admin_disallow.php b/admin/admin_disallow.php index 12fd931a0..1e6926c31 100644 --- a/admin/admin_disallow.php +++ b/admin/admin_disallow.php @@ -44,9 +44,9 @@ if (isset($_POST['add_name'])) { bb_die($message); } -// -// Grab the current list of disallowed usernames... -// +/** + * Grab the current list of disallowed usernames + */ $sql = "SELECT * FROM " . BB_DISALLOW; $result = DB()->sql_query($sql); if (!$result) { @@ -55,10 +55,9 @@ if (!$result) { $disallowed = DB()->sql_fetchrowset($result); -// -// Ok now generate the info for the template, which will be put out no matter -// what mode we are in. -// +/** + * Now generate the info for the template, which will be put out no matter what mode we are in + */ $disallow_select = ''; diff --git a/admin/admin_forumauth_list.php b/admin/admin_forumauth_list.php index aa7c2c37e..732dc6f2a 100644 --- a/admin/admin_forumauth_list.php +++ b/admin/admin_forumauth_list.php @@ -7,24 +7,17 @@ if (!empty($setmodules)) { require('./pagestart.php'); // View Read Post Reply Edit Delete Sticky Announce Vote Poll PostAttach Download -$simple_auth_ary = array( - /* Public */ - 0 => array(AUTH_ALL, AUTH_ALL, AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_ALL), // Public - /* Reg */ - 1 => array(AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG), // Registered - /* Reg [Hid] */ - 2 => array(AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG), // Registered [Hidden] - /* Priv */ - 3 => array(AUTH_REG, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_MOD, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL), // Private - /* Priv [Hid] */ - 4 => array(AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_MOD, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL), // Private [Hidden] - /* MOD */ - 5 => array(AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD), // Moderators - /* MOD [Hid] */ - 6 => array(AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD), // Moderators [Hidden] -); +$simple_auth_ary = [ + 0 => [AUTH_ALL, AUTH_ALL, AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_ALL], // Public + 1 => [AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG], // Registered + 2 => [AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG], // Registered [Hidden] + 3 => [AUTH_REG, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_MOD, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL], // Private + 4 => [AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_MOD, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL], // Private [Hidden] + 5 => [AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD], // Moderators + 6 => [AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD], // Moderators [Hidden] +]; -$simple_auth_types = array( +$simple_auth_types = [ $lang['PUBLIC'], $lang['REGISTERED'], $lang['REGISTERED'] . ' [' . $lang['HIDDEN'] . ']', @@ -32,9 +25,9 @@ $simple_auth_types = array( $lang['PRIVATE'] . ' [' . $lang['HIDDEN'] . ']', $lang['MODERATORS'], $lang['MODERATORS'] . ' [' . $lang['HIDDEN'] . ']', -); +]; -$forum_auth_fields = array( +$forum_auth_fields = [ 'auth_view', 'auth_read', 'auth_reply', @@ -47,15 +40,15 @@ $forum_auth_fields = array( 'auth_post', 'auth_sticky', 'auth_announce', -); +]; -$field_names = array(); +$field_names = []; foreach ($forum_auth_fields as $auth_type) { $field_names[$auth_type] = $lang[strtoupper($auth_type)]; } -$forum_auth_levels = array('ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN'); -$forum_auth_const = array(AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_ADMIN); +$forum_auth_levels = ['ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN']; +$forum_auth_const = [AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_ADMIN]; if (isset($_GET[POST_FORUM_URL]) || isset($_POST[POST_FORUM_URL])) { $forum_id = (isset($_POST[POST_FORUM_URL])) ? intval($_POST[POST_FORUM_URL]) : intval($_GET[POST_FORUM_URL]); diff --git a/admin/admin_forums.php b/admin/admin_forums.php index 3fbc061a7..c8a629209 100644 --- a/admin/admin_forums.php +++ b/admin/admin_forums.php @@ -18,7 +18,7 @@ array_deep($_POST, 'trim'); $s = ''; -$default_forum_auth = array( +$default_forum_auth = [ 'auth_view' => AUTH_ALL, 'auth_read' => AUTH_ALL, 'auth_post' => AUTH_REG, @@ -31,7 +31,7 @@ $default_forum_auth = array( 'auth_pollcreate' => AUTH_REG, 'auth_attachments' => AUTH_REG, 'auth_download' => AUTH_REG, -); +]; $mode = ($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : ''; @@ -766,7 +766,11 @@ if (!$mode || $show_main_page) { print_page('admin_forums.tpl', 'admin'); -// Functions +/** + * @param $mode + * @param $id + * @return mixed + */ function get_info($mode, $id) { switch ($mode) { @@ -806,6 +810,12 @@ function get_info($mode, $id) return $return; } +/** + * @param $mode + * @param $id + * @param $select + * @return string + */ function get_list($mode, $id, $select) { switch ($mode) { @@ -851,6 +861,10 @@ function get_list($mode, $id, $select) return ($catlist); } +/** + * @param $mode + * @param int $cat + */ function renumber_order($mode, $cat = 0) { switch ($mode) { @@ -898,6 +912,10 @@ function renumber_order($mode, $cat = 0) } } +/** + * @param bool $cat_id + * @return array + */ function get_cat_forums($cat_id = false) { $forums = array(); @@ -928,6 +946,10 @@ function get_cat_forums($cat_id = false) return $forums; } +/** + * @param $forum_id + * @return int + */ function get_sf_count($forum_id) { global $cat_forums; @@ -945,6 +967,11 @@ function get_sf_count($forum_id) return $sf_count; } +/** + * @param $forums + * @param $curr_forum_order + * @return bool + */ function get_prev_root_forum_id($forums, $curr_forum_order) { $i = $curr_forum_order - 10; @@ -959,6 +986,11 @@ function get_prev_root_forum_id($forums, $curr_forum_order) return false; } +/** + * @param $forums + * @param $curr_forum_order + * @return bool + */ function get_next_root_forum_id($forums, $curr_forum_order) { $i = $curr_forum_order + 10; @@ -974,6 +1006,9 @@ function get_next_root_forum_id($forums, $curr_forum_order) return false; } +/** + * @return string + */ function get_orphan_sf() { global $cat_forums; @@ -996,6 +1031,11 @@ function get_orphan_sf() return implode(',', $bad_sf_ary); } +/** + * @param string $orphan_sf_sql + * @param bool $show_mess + * @return string + */ function fix_orphan_sf($orphan_sf_sql = '', $show_mess = false) { global $lang; @@ -1028,6 +1068,12 @@ function fix_orphan_sf($orphan_sf_sql = '', $show_mess = false) return $done_mess; } +/** + * @param $mode + * @param int $exclude + * @param int $select + * @return string + */ function sf_get_list($mode, $exclude = 0, $select = 0) { global $cat_forums, $forum_parent; @@ -1052,6 +1098,10 @@ function sf_get_list($mode, $exclude = 0, $select = 0) return $opt; } +/** + * @param $forum_id + * @return bool + */ function get_forum_data($forum_id) { global $cat_forums; @@ -1067,6 +1117,10 @@ function get_forum_data($forum_id) return false; } +/** + * @param $cat_id + * @return int + */ function get_max_forum_order($cat_id) { $row = DB()->fetch_row(" @@ -1078,6 +1132,12 @@ function get_max_forum_order($cat_id) return intval($row['max_forum_order']); } +/** + * @param $mode + * @param $name + * @param bool $die_on_error + * @return mixed + */ function check_name_dup($mode, $name, $die_on_error = true) { $name_sql = DB()->escape($name); diff --git a/admin/admin_groups.php b/admin/admin_groups.php index c6af183eb..4f608a98e 100644 --- a/admin/admin_groups.php +++ b/admin/admin_groups.php @@ -25,7 +25,7 @@ if (!empty($_POST['edit']) || !empty($_POST['new'])) { 'release_group' => $row['release_group'], ); $mode = 'editgroup'; - $template->assign_block_vars('group_edit', array()); + $template->assign_block_vars('group_edit', []); } elseif (!empty($_POST['new'])) { $group_info = array( 'group_name' => '', diff --git a/admin/admin_mass_email.php b/admin/admin_mass_email.php index 2b490d956..a29ae12f4 100644 --- a/admin/admin_mass_email.php +++ b/admin/admin_mass_email.php @@ -15,7 +15,7 @@ $subject = (string)trim(request_var('subject', '')); $message = (string)request_var('message', ''); $group_id = (int)request_var(POST_GROUPS_URL, 0); -$errors = $user_id_sql = array(); +$errors = $user_id_sql = []; if (isset($_POST['submit'])) { if (!$subject) { diff --git a/admin/stats/tracker.php b/admin/stats/tracker.php index 98d2d9e30..0691fe113 100644 --- a/admin/stats/tracker.php +++ b/admin/stats/tracker.php @@ -13,7 +13,7 @@ if (!IS_ADMIN) { bb_die($lang['NOT_AUTHORISED']); } -$peers_in_last_minutes = array(30, 15, 5, 1); +$peers_in_last_minutes = [30, 15, 5, 1]; $peers_in_last_sec_limit = 300; $announce_interval = intval($di->config->get('announce_interval')); diff --git a/bt/announce.php b/bt/announce.php index a7385fc32..c5890d38a 100644 --- a/bt/announce.php +++ b/bt/announce.php @@ -170,9 +170,6 @@ function msg_die($msg) die($output); } -# $agent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '-'; -# bb_log("$agent | ". str_compact($peer_id) ."\n", 'agent'); - // Start announcer define('TR_ROOT', './'); require(TR_ROOT . 'includes/init_tr.php'); diff --git a/bt/includes/init_tr.php b/bt/includes/init_tr.php index 40c9ad298..21c14b197 100644 --- a/bt/includes/init_tr.php +++ b/bt/includes/init_tr.php @@ -83,6 +83,8 @@ class sql_db /** * Constructor + * @param $cfg_values + * @return sql_db */ public function sql_db($cfg_values) { @@ -173,6 +175,8 @@ class sql_db /** * Base query method + * @param $query + * @return null|resource */ public function sql_query($query) { @@ -197,6 +201,8 @@ class sql_db /** * Execute query WRAPPER (with error handling) + * @param $query + * @return null|resource */ public function query($query) { @@ -209,6 +215,8 @@ class sql_db /** * Return number of rows + * @param bool $result + * @return bool|int */ public function num_rows($result = false) { @@ -231,6 +239,8 @@ class sql_db /** * Fetch current row + * @param $result + * @return array|bool */ public function sql_fetchrow($result) { @@ -239,6 +249,8 @@ class sql_db /** * Alias of sql_fetchrow() + * @param $result + * @return array|bool */ public function fetch_next($result) { @@ -247,6 +259,8 @@ class sql_db /** * Fetch row WRAPPER (with error handling) + * @param $query + * @return array|bool */ public function fetch_row($query) { @@ -259,6 +273,8 @@ class sql_db /** * Fetch all rows + * @param $result + * @return array */ public function sql_fetchrowset($result) { @@ -273,6 +289,8 @@ class sql_db /** * Fetch all rows WRAPPER (with error handling) + * @param $query + * @return array */ public function fetch_rowset($query) { @@ -285,6 +303,9 @@ class sql_db /** * Escape string used in sql query + * @param $v + * @param bool $check_type + * @return string */ public function escape($v, $check_type = false) { @@ -371,6 +392,7 @@ class sql_db /** * Store debug info + * @param $mode */ public function debug($mode) { @@ -405,6 +427,7 @@ class sql_db /** * Trigger error + * @param string $msg */ public function trigger_error($msg = '') { diff --git a/common.php b/common.php index adf3cffd1..0cb010332 100644 --- a/common.php +++ b/common.php @@ -131,6 +131,8 @@ $DBS = new DBS([ /** * TODO: @deprecated + * @param string $db_alias + * @return mixed */ function DB($db_alias = 'db') { diff --git a/library/ajax/view_torrent.php b/library/ajax/view_torrent.php index c4176a78c..3c665145c 100644 --- a/library/ajax/view_torrent.php +++ b/library/ajax/view_torrent.php @@ -28,6 +28,10 @@ if (($file_contents = @file_get_contents($file_path)) === false) { // Построение списка $tor_filelist = build_tor_filelist($file_contents); +/** + * @param $file_contents + * @return string + */ function build_tor_filelist($file_contents) { global $lang; @@ -41,6 +45,9 @@ function build_tor_filelist($file_contents) return $torrent->get_filelist(); } +/** + * Class torrent + */ class torrent { public $tor_decoded = array(); @@ -49,11 +56,19 @@ class torrent public $root_dir = ''; public $files_html = ''; + /** + * torrent constructor. + * @param $decoded_file_contents + * @return torrent + */ public function torrent($decoded_file_contents) { $this->tor_decoded = $decoded_file_contents; } + /** + * @return string + */ public function get_filelist() { $this->build_filelist_array(); @@ -70,6 +85,9 @@ class torrent } } + /** + * Torrent file list builder + */ public function build_filelist_array() { $info = $this->tor_decoded['info']; @@ -131,6 +149,11 @@ class torrent } } + /** + * @param $name + * @param $length + * @return string + */ public function build_file_item($name, $length) { global $images, $lang; @@ -148,6 +171,9 @@ class torrent return "$name $length $magnet_name $magnet_ext"; } + /** + * @return string + */ public function build_filelist_html() { global $html; @@ -155,6 +181,10 @@ class torrent } } +/** + * @param $dirname + * @return mixed + */ function clean_tor_dirname($dirname) { return str_replace(array('[', ']', '<', '>', "'"), array('[', ']', '<', '>', '''), $dirname); diff --git a/library/includes/bbcode.php b/library/includes/bbcode.php index 731cf9efe..28b579aae 100644 --- a/library/includes/bbcode.php +++ b/library/includes/bbcode.php @@ -13,6 +13,9 @@ $page_cfg['include_bbcode_js'] = true; // // BBCode templates // +/** + * @return array + */ function get_bbcode_tpl() { $bbcode_tpl = array(); @@ -79,6 +82,10 @@ HTML; return $bbcode_tpl; } +/** + * @param $text + * @return mixed + */ function bbcode_tpl_compact($text) { $text = str_compact($text); @@ -87,6 +94,10 @@ function bbcode_tpl_compact($text) } // prepare a posted message for entry into the database +/** + * @param $message + * @return mixed|string + */ function prepare_message($message) { $message = bbcode::clean_up($message); @@ -96,6 +107,9 @@ function prepare_message($message) // Fill smiley templates (or just the variables) with smileys // Either in a window or inline +/** + * @param $mode + */ function generate_smilies($mode) { global $template, $lang, $datastore; @@ -314,6 +328,10 @@ function strip_bbcode($message, $stripquotes = true, $fast_and_dirty = false, $s return $message; } +/** + * @param $text + * @return mixed|string + */ function extract_search_words($text) { /** @var \TorrentPier\Di $di */ @@ -365,6 +383,10 @@ function extract_search_words($text) return $text; } +/** + * @param $text + * @return mixed + */ function replace_synonyms($text) { static $syn_match = null, $syn_replace = null; @@ -382,6 +404,13 @@ function replace_synonyms($text) return ($syn_match && $syn_replace) ? str_replace($syn_match, $syn_replace, $text) : $text; } +/** + * @param $post_id + * @param $post_message + * @param string $topic_title + * @param bool $only_return_words + * @return string + */ function add_search_words($post_id, $post_message, $topic_title = '', $only_return_words = false) { /** @var \TorrentPier\Di $di */ @@ -401,6 +430,9 @@ function add_search_words($post_id, $post_message, $topic_title = '', $only_retu } } +/** + * Class bbcode + */ class bbcode { public $tpl = array(); // шаблоны для замены тегов @@ -813,6 +845,10 @@ class bbcode } } +/** + * @param $text + * @return string + */ function bbcode2html($text) { global $bbcode; @@ -829,6 +865,9 @@ function bbcode2html($text) return $bbcode->bbcode2html($text); } +/** + * Class words_rate + */ class words_rate { public $dbg_mode = false; @@ -903,6 +942,10 @@ class words_rate } } +/** + * @param $text + * @return int + */ function get_words_rate($text) { static $wr = null; @@ -912,6 +955,10 @@ function get_words_rate($text) return $wr->get_words_rate($text); } +/** + * @param $str + * @return mixed + */ function hide_passkey($str) { /** @var \TorrentPier\Di $di */ @@ -920,6 +967,12 @@ function hide_passkey($str) return preg_replace("#\?{$di->config->get('passkey_key')}=[a-zA-Z0-9]{" . BT_AUTH_KEY_LENGTH . "}#", "?{$di->config->get('passkey_key')}=passkey", $str); } +/** + * @param $postrow + * @param string $mode + * @param int $return_chars + * @return string + */ function get_parsed_post($postrow, $mode = 'full', $return_chars = 600) { /** @var \TorrentPier\Di $di */ @@ -942,6 +995,9 @@ function get_parsed_post($postrow, $mode = 'full', $return_chars = 600) return $message; } +/** + * @param $postrow + */ function update_post_html($postrow) { DB()->query("DELETE FROM " . BB_POSTS_HTML . " WHERE post_id = " . (int)$postrow['post_id'] . " LIMIT 1"); diff --git a/library/includes/classes/emailer.php b/library/includes/classes/emailer.php index 0b5707e86..9fa85292d 100644 --- a/library/includes/classes/emailer.php +++ b/library/includes/classes/emailer.php @@ -13,6 +13,11 @@ class emailer public $tpl_msg = array(); public $vars = array(); + /** + * emailer constructor. + * @param $use_smtp + * @return emailer + */ public function emailer($use_smtp/*$tpl_name, $sbj, $to_address*/) { /** @var \TorrentPier\Di $di */ @@ -24,6 +29,9 @@ class emailer $this->use_smtp = $use_smtp; } + /** + * Установка стандартных замен в письмах + */ public function set_default_vars() { /** @var \TorrentPier\Di $di */ @@ -37,6 +45,9 @@ class emailer } // Resets all the data (address, template file, etc etc to default + /** + * Сброс + */ public function reset() { $this->addresses = array(); @@ -45,43 +56,69 @@ class emailer } // Sets an email address to send to + /** + * @param $address + */ public function email_address($address) { $this->addresses['to'] = trim($address); } + /** + * @param $address + */ public function cc($address) { $this->addresses['cc'][] = trim($address); } + /** + * @param $address + */ public function bcc($address) { $this->addresses['bcc'][] = trim($address); } + /** + * @param $address + */ public function replyto($address) { $this->reply_to = trim($address); } + /** + * @param $address + */ public function from($address) { $this->from = trim($address); } // set up subject for mail + /** + * @param string $subject + */ public function set_subject($subject = '') { $this->subject = trim(preg_replace('#[\n\r]+#s', '', $subject)); } // set up extra mail headers + /** + * @param $headers + */ public function extra_headers($headers) { $this->extra_headers .= trim($headers) . "\n"; } + /** + * @param $template_file + * @param string $template_lang + * @return bool + */ public function use_template($template_file, $template_lang = '') { /** @var \TorrentPier\Di $di */ @@ -120,12 +157,19 @@ class emailer } // assign variables + /** + * @param $vars + */ public function assign_vars($vars) { $this->vars = array_merge($this->vars, $vars); } // Send the mail out to the recipients set previously in var $this->address + /** + * @param string $email_format + * @return bool + */ public function send($email_format = 'text') { global $userdata; @@ -208,6 +252,10 @@ class emailer return true; } + /** + * @param $str + * @return string + */ public function encode($str) { if ($this->encoding == '') { diff --git a/library/includes/classes/sitemap.php b/library/includes/classes/sitemap.php index 6b1463a8f..069955ad4 100644 --- a/library/includes/classes/sitemap.php +++ b/library/includes/classes/sitemap.php @@ -13,11 +13,17 @@ class sitemap public $priority = '0.6'; public $cat_priority = '0.7'; + /** + * sitemap constructor. + */ public function sitemap() { $this->home = make_url(); } + /** + * @return string + */ public function build_map() { $map = "\n\n"; @@ -29,6 +35,10 @@ class sitemap return $map; } + /** + * @param $count + * @return string + */ public function build_index($count) { $lm = date('c'); @@ -43,6 +53,9 @@ class sitemap return $map; } + /** + * @return string + */ public function build_stat() { $map = "\n\n"; @@ -53,6 +66,10 @@ class sitemap return $map; } + /** + * @param $n + * @return string + */ public function build_map_topic($n) { $map = "\n\n"; @@ -62,6 +79,9 @@ class sitemap return $map; } + /** + * @return string + */ public function get_forum() { global $datastore; @@ -92,6 +112,10 @@ class sitemap return $xml; } + /** + * @param bool $page + * @return string + */ public function get_topic($page = false) { global $datastore; @@ -136,6 +160,9 @@ class sitemap return $xml; } + /** + * @return string + */ public function get_static() { /** @var \TorrentPier\Di $di */ @@ -161,6 +188,11 @@ class sitemap return $xml; } + /** + * @param $loc + * @param $lm + * @return string + */ public function get_xml($loc, $lm) { $xml = "\t\n"; @@ -172,6 +204,11 @@ class sitemap return $xml; } + /** + * @param $url + * @param $map + * @return bool|mixed|string + */ public function send_url($url, $map) { $data = false; @@ -195,6 +232,9 @@ class sitemap } } + /** + * Создание карты сайта + */ public function create() { $row = DB()->fetch_row("SELECT COUNT(*) AS count FROM " . BB_TOPICS); diff --git a/library/includes/core/dbs.php b/library/includes/core/dbs.php index 06f4874eb..6199cb316 100644 --- a/library/includes/core/dbs.php +++ b/library/includes/core/dbs.php @@ -16,6 +16,11 @@ class dbs public $sql_inittime = 0; public $sql_timetotal = 0; + /** + * dbs constructor. + * @param $cfg + * @return dbs + */ public function DBS($cfg) { $this->cfg = $cfg['db']; @@ -27,6 +32,10 @@ class dbs } // получение/инициализация класса для сервера $srv_name + /** + * @param string $srv_name_or_alias + * @return mixed + */ public function get_db_obj($srv_name_or_alias = 'db1') { $srv_name = $this->get_srv_name($srv_name_or_alias); @@ -39,6 +48,10 @@ class dbs } // определение имени сервера + /** + * @param $name + * @return mixed|string + */ public function get_srv_name($name) { if (isset($this->alias[$name])) { diff --git a/library/includes/core/mysql.php b/library/includes/core/mysql.php index d9fbe1fa0..0eda2efdc 100644 --- a/library/includes/core/mysql.php +++ b/library/includes/core/mysql.php @@ -39,6 +39,8 @@ class sql_db /** * Constructor + * @param $cfg_values + * @return sql_db */ public function sql_db($cfg_values) { @@ -127,6 +129,8 @@ class sql_db /** * Base query method + * @param $query + * @return null|resource */ public function sql_query($query) { @@ -159,6 +163,8 @@ class sql_db /** * Execute query WRAPPER (with error handling) + * @param $query + * @return null|resource */ public function query($query) { @@ -171,6 +177,8 @@ class sql_db /** * Return number of rows + * @param bool $result + * @return bool|int */ public function num_rows($result = false) { @@ -193,6 +201,10 @@ class sql_db /** * Fetch current field + * @param $field + * @param int $rownum + * @param int $query_id + * @return bool|string */ public function sql_fetchfield($field, $rownum = -1, $query_id = 0) { @@ -223,6 +235,9 @@ class sql_db /** * Fetch current row + * @param $result + * @param string $field_name + * @return array|bool */ public function sql_fetchrow($result, $field_name = '') { @@ -237,6 +252,8 @@ class sql_db /** * Alias of sql_fetchrow() + * @param $result + * @return array|bool */ public function fetch_next($result) { @@ -245,6 +262,9 @@ class sql_db /** * Fetch row WRAPPER (with error handling) + * @param $query + * @param string $field_name + * @return array|bool */ public function fetch_row($query, $field_name = '') { @@ -257,6 +277,9 @@ class sql_db /** * Fetch all rows + * @param $result + * @param string $field_name + * @return array */ public function sql_fetchrowset($result, $field_name = '') { @@ -271,6 +294,9 @@ class sql_db /** * Fetch all rows WRAPPER (with error handling) + * @param $query + * @param string $field_name + * @return array */ public function fetch_rowset($query, $field_name = '') { @@ -283,6 +309,9 @@ class sql_db /** * Fetch all rows WRAPPER (with error handling) + * @param $query + * @param string $field_name + * @return array */ public function fetch_all($query, $field_name = '') { @@ -303,6 +332,7 @@ class sql_db /** * Free sql result + * @param bool $result */ public function sql_freeresult($result = false) { @@ -315,6 +345,10 @@ class sql_db /** * Escape data used in sql query + * @param $v + * @param bool $check_type + * @param bool $dont_escape + * @return string */ public function escape($v, $check_type = false, $dont_escape = false) { @@ -343,6 +377,8 @@ class sql_db /** * Escape string + * @param $str + * @return string */ public function escape_string($str) { @@ -357,6 +393,11 @@ class sql_db * Build SQL statement from array (based on same method from phpBB3, idea from Ikonboard) * * Possible $query_type values: INSERT, INSERT_SELECT, MULTI_INSERT, UPDATE, SELECT + * @param $query_type + * @param $input_ary + * @param bool $data_already_escaped + * @param bool $check_data_type_in_escape + * @return string */ public function build_array($query_type, $input_ary, $data_already_escaped = false, $check_data_type_in_escape = true) { @@ -410,6 +451,9 @@ class sql_db return "\n" . $query . "\n"; } + /** + * @return array + */ public function get_empty_sql_array() { return array( @@ -426,6 +470,10 @@ class sql_db ); } + /** + * @param $sql_ary + * @return string + */ public function build_sql($sql_ary) { $sql = ''; @@ -502,6 +550,7 @@ class sql_db /** * Add shutdown query + * @param $sql */ public function add_shutdown_query($sql) { @@ -531,6 +580,9 @@ class sql_db /** * Lock tables + * @param $tables + * @param string $lock_type + * @return bool|null|resource */ public function lock($tables, $lock_type = 'WRITE') { @@ -564,6 +616,9 @@ class sql_db /** * Obtain user level lock + * @param $name + * @param int $timeout + * @return mixed */ public function get_lock($name, $timeout = 0) { @@ -580,6 +635,8 @@ class sql_db /** * Obtain user level lock status + * @param $name + * @return mixed */ public function release_lock($name) { @@ -595,6 +652,8 @@ class sql_db /** * Release user level lock + * @param $name + * @return mixed */ public function is_free_lock($name) { @@ -605,6 +664,8 @@ class sql_db /** * Make per db unique lock name + * @param $name + * @return string */ public function get_lock_name($name) { @@ -647,6 +708,8 @@ class sql_db /** * Set slow query marker for xx seconds * This will disable counting other queries as "slow" during this time + * @param int $ignoring_time + * @param int $new_priority */ public function expect_slow_query($ignoring_time = 60, $new_priority = 10) { @@ -669,6 +732,7 @@ class sql_db /** * Store debug info + * @param $mode */ public function debug($mode) { @@ -724,6 +788,7 @@ class sql_db /** * Trigger error + * @param string $msg */ public function trigger_error($msg = 'DB Error') { @@ -741,6 +806,8 @@ class sql_db /** * Find caller source + * @param string $mode + * @return string */ public function debug_find_source($mode = '') { @@ -761,6 +828,8 @@ class sql_db /** * Prepare for logging + * @param int $queries_count + * @param string $log_file */ public function log_next_query($queries_count = 1, $log_file = 'sql_queries') { @@ -770,6 +839,7 @@ class sql_db /** * Log query + * @param string $log_file */ public function log_query($log_file = 'sql_queries') { @@ -791,6 +861,7 @@ class sql_db /** * Log slow query + * @param string $log_file */ public function log_slow_query($log_file = 'sql_slow_bb') { @@ -836,6 +907,10 @@ class sql_db /** * Explain queries (based on code from phpBB3) + * @param $mode + * @param string $html_table + * @param string $row + * @return bool|string */ public function explain($mode, $html_table = '', $row = '') { diff --git a/library/includes/cron/cron_init.php b/library/includes/cron/cron_init.php index 4d7a22e69..4554bc21c 100644 --- a/library/includes/cron/cron_init.php +++ b/library/includes/cron/cron_init.php @@ -7,6 +7,9 @@ if (!defined('BB_ROOT')) { // // Functions // +/** + * @return bool + */ function cron_get_file_lock() { $lock_obtained = false; @@ -25,6 +28,9 @@ function cron_get_file_lock() return $lock_obtained; } +/** + * @param $mode + */ function cron_track_running($mode) { defined('CRON_STARTMARK') or define('CRON_STARTMARK', TRIGGERS_DIR . 'cron_started_at_' . date('Y-m-d_H-i-s') . '_by_pid_' . getmypid()); diff --git a/library/includes/datastore/apc.php b/library/includes/datastore/apc.php index 09162562e..6637e44c3 100644 --- a/library/includes/datastore/apc.php +++ b/library/includes/datastore/apc.php @@ -9,6 +9,11 @@ class datastore_apc extends datastore_common public $engine = 'APC'; public $prefix = null; + /** + * datastore_apc constructor. + * @param null $prefix + * @return datastore_apc + */ public function datastore_apc($prefix = null) { if (!$this->is_installed()) { @@ -18,6 +23,11 @@ class datastore_apc extends datastore_common $this->prefix = $prefix; } + /** + * @param $title + * @param $var + * @return bool + */ public function store($title, $var) { $this->data[$title] = $var; @@ -31,6 +41,9 @@ class datastore_apc extends datastore_common return (bool)apc_store($this->prefix . $title, $var); } + /** + * Очистка + */ public function clean() { foreach ($this->known_items as $title => $script_name) { @@ -44,6 +57,9 @@ class datastore_apc extends datastore_common } } + /** + * Получение из кеша + */ public function _fetch_from_store() { if (!$items = $this->queued_items) { @@ -62,6 +78,9 @@ class datastore_apc extends datastore_common } } + /** + * @return bool + */ public function is_installed() { return function_exists('apc_fetch'); diff --git a/library/includes/datastore/common.php b/library/includes/datastore/common.php index b2ba1456a..30f4e74ee 100644 --- a/library/includes/datastore/common.php +++ b/library/includes/datastore/common.php @@ -58,6 +58,10 @@ class datastore_common } } + /** + * @param $title + * @return mixed + */ public function &get($title) { if (!isset($this->data[$title])) { @@ -67,10 +71,17 @@ class datastore_common return $this->data[$title]; } + /** + * @param $item_name + * @param $item_data + */ public function store($item_name, $item_data) { } + /** + * @param $items + */ public function rm($items) { foreach ((array)$items as $item) { @@ -78,6 +89,9 @@ class datastore_common } } + /** + * @param $items + */ public function update($items) { if ($items == 'all') { @@ -88,6 +102,9 @@ class datastore_common } } + /** + * Получение + */ public function _fetch() { $this->_fetch_from_store(); @@ -101,10 +118,16 @@ class datastore_common $this->queued_items = array(); } + /** + * Получение из кеша + */ public function _fetch_from_store() { } + /** + * @param $title + */ public function _build_item($title) { if (!empty($this->known_items[$title])) { @@ -125,6 +148,10 @@ class datastore_common public $dbg_enabled = false; public $cur_query = null; + /** + * @param $mode + * @param null $cur_query + */ public function debug($mode, $cur_query = null) { if (!$this->dbg_enabled) { @@ -150,6 +177,10 @@ class datastore_common } } + /** + * @param string $mode + * @return string + */ public function debug_find_source($mode = '') { foreach (debug_backtrace() as $trace) { diff --git a/library/includes/datastore/file.php b/library/includes/datastore/file.php index d14fd53a4..34f3322c0 100644 --- a/library/includes/datastore/file.php +++ b/library/includes/datastore/file.php @@ -10,6 +10,12 @@ class datastore_file extends datastore_common public $prefix = null; public $engine = 'Filecache'; + /** + * datastore_file constructor. + * @param $dir + * @param null $prefix + * @return datastore_file + */ public function datastore_file($dir, $prefix = null) { $this->prefix = $prefix; @@ -17,6 +23,11 @@ class datastore_file extends datastore_common $this->dbg_enabled = sql_dbg_enabled(); } + /** + * @param $title + * @param $var + * @return bool + */ public function store($title, $var) { $this->cur_query = "cache->set('$title')"; @@ -38,6 +49,9 @@ class datastore_file extends datastore_common return (bool)file_write($filecache, $filename, false, true, true); } + /** + * Очистка + */ public function clean() { $dir = $this->dir; @@ -56,6 +70,9 @@ class datastore_file extends datastore_common } } + /** + * Получение из кеша + */ public function _fetch_from_store() { if (!$items = $this->queued_items) { diff --git a/library/includes/datastore/memcache.php b/library/includes/datastore/memcache.php index b3b2a05cb..ea19403dd 100644 --- a/library/includes/datastore/memcache.php +++ b/library/includes/datastore/memcache.php @@ -12,6 +12,12 @@ class datastore_memcache extends datastore_common public $engine = 'Memcache'; public $prefix = null; + /** + * datastore_memcache constructor. + * @param $cfg + * @param null $prefix + * @return datastore_memcache + */ public function datastore_memcache($cfg, $prefix = null) { if (!$this->is_installed()) { @@ -24,6 +30,9 @@ class datastore_memcache extends datastore_common $this->dbg_enabled = sql_dbg_enabled(); } + /** + * Подключение + */ public function connect() { $connect_type = ($this->cfg['pconnect']) ? 'pconnect' : 'connect'; @@ -47,6 +56,11 @@ class datastore_memcache extends datastore_common $this->cur_query = null; } + /** + * @param $title + * @param $var + * @return bool + */ public function store($title, $var) { if (!$this->connected) { @@ -63,6 +77,9 @@ class datastore_memcache extends datastore_common return (bool)$this->memcache->set($this->prefix . $title, $var); } + /** + * Очистка + */ public function clean() { if (!$this->connected) { @@ -79,6 +96,9 @@ class datastore_memcache extends datastore_common } } + /** + * Получение из кеша + */ public function _fetch_from_store() { if (!$items = $this->queued_items) { @@ -100,6 +120,9 @@ class datastore_memcache extends datastore_common } } + /** + * @return bool + */ public function is_installed() { return class_exists('Memcache'); diff --git a/library/includes/datastore/redis.php b/library/includes/datastore/redis.php index e90827cc4..6373013fe 100644 --- a/library/includes/datastore/redis.php +++ b/library/includes/datastore/redis.php @@ -12,6 +12,12 @@ class datastore_redis extends datastore_common public $connected = false; public $engine = 'Redis'; + /** + * datastore_redis constructor. + * @param $cfg + * @param null $prefix + * @return datastore_redis + */ public function datastore_redis($cfg, $prefix = null) { if (!$this->is_installed()) { @@ -24,6 +30,9 @@ class datastore_redis extends datastore_common $this->prefix = $prefix; } + /** + * Подключение + */ public function connect() { $this->cur_query = 'connect ' . $this->cfg['host'] . ':' . $this->cfg['port']; @@ -41,6 +50,11 @@ class datastore_redis extends datastore_common $this->cur_query = null; } + /** + * @param $title + * @param $var + * @return bool + */ public function store($title, $var) { if (!$this->connected) { @@ -57,6 +71,9 @@ class datastore_redis extends datastore_common return (bool)$this->redis->set($this->prefix . $title, serialize($var)); } + /** + * Очистка + */ public function clean() { if (!$this->connected) { @@ -73,6 +90,9 @@ class datastore_redis extends datastore_common } } + /** + * Получение из кеша + */ public function _fetch_from_store() { if (!$items = $this->queued_items) { @@ -94,6 +114,9 @@ class datastore_redis extends datastore_common } } + /** + * @return bool + */ public function is_installed() { return class_exists('Redis'); diff --git a/library/includes/datastore/sqlite.php b/library/includes/datastore/sqlite.php index 9595755be..682b83ad5 100644 --- a/library/includes/datastore/sqlite.php +++ b/library/includes/datastore/sqlite.php @@ -22,6 +22,12 @@ class datastore_sqlite extends datastore_common 'log_name' => 'DATASTORE', ); + /** + * datastore_sqlite constructor. + * @param $cfg + * @param null $prefix + * @return datastore_sqlite + */ public function datastore_sqlite($cfg, $prefix = null) { $this->cfg = array_merge($this->cfg, $cfg); @@ -29,6 +35,11 @@ class datastore_sqlite extends datastore_common $this->prefix = $prefix; } + /** + * @param $item_name + * @param $item_data + * @return bool + */ public function store($item_name, $item_data) { $this->data[$item_name] = $item_data; @@ -41,11 +52,17 @@ class datastore_sqlite extends datastore_common return (bool)$result; } + /** + * Очистка + */ public function clean() { $this->db->query("DELETE FROM " . $this->cfg['table_name']); } + /** + * Получение из кеша + */ public function _fetch_from_store() { if (!$items = $this->queued_items) { diff --git a/library/includes/datastore/xcache.php b/library/includes/datastore/xcache.php index b1a0a37e2..e31fbb32c 100644 --- a/library/includes/datastore/xcache.php +++ b/library/includes/datastore/xcache.php @@ -9,6 +9,11 @@ class datastore_xcache extends datastore_common public $prefix = null; public $engine = 'XCache'; + /** + * datastore_xcache constructor. + * @param null $prefix + * @return datastore_xcache + */ public function datastore_xcache($prefix = null) { if (!$this->is_installed()) { @@ -19,6 +24,11 @@ class datastore_xcache extends datastore_common $this->prefix = $prefix; } + /** + * @param $title + * @param $var + * @return bool + */ public function store($title, $var) { $this->data[$title] = $var; @@ -32,6 +42,9 @@ class datastore_xcache extends datastore_common return (bool)xcache_set($this->prefix . $title, $var); } + /** + * Очистка + */ public function clean() { foreach ($this->known_items as $title => $script_name) { @@ -45,6 +58,9 @@ class datastore_xcache extends datastore_common } } + /** + * Получение из кеша + */ public function _fetch_from_store() { if (!$items = $this->queued_items) { @@ -63,6 +79,9 @@ class datastore_xcache extends datastore_common } } + /** + * @return bool + */ public function is_installed() { return function_exists('xcache_get'); diff --git a/library/includes/functions.php b/library/includes/functions.php index 3dab50e90..4cd03ff05 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -4,6 +4,14 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } +/** + * @param $id + * @param $ext_id + * @param $base_path + * @param $first_div + * @param $sec_div + * @return string + */ function get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div) { /** @var \TorrentPier\Di $di */ @@ -14,6 +22,14 @@ function get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div) return ($base_path ? "$base_path/" : '') . floor($id / $first_div) . '/' . ($id % $sec_div) . '/' . $id . ($ext ? ".$ext" : ''); } +/** + * @param $id + * @param $ext_id + * @param null $base_path + * @param int $first_div + * @param int $sec_div + * @return string + */ function get_avatar_path($id, $ext_id, $base_path = null, $first_div = 10000, $sec_div = 100) { /** @var \TorrentPier\Di $di */ @@ -24,6 +40,14 @@ function get_avatar_path($id, $ext_id, $base_path = null, $first_div = 10000, $s return get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div); } +/** + * @param $id + * @param string $ext_id + * @param null $base_path + * @param int $first_div + * @param int $sec_div + * @return string + */ function get_attach_path($id, $ext_id = '', $base_path = null, $first_div = 10000, $sec_div = 100) { /** @var \TorrentPier\Di $di */ @@ -34,18 +58,32 @@ function get_attach_path($id, $ext_id = '', $base_path = null, $first_div = 1000 return get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div); } +/** + * @param $user_id + * @param $avatar_ext_id + * @return bool + */ function delete_avatar($user_id, $avatar_ext_id) { $avatar_file = ($avatar_ext_id) ? get_avatar_path($user_id, $avatar_ext_id) : ''; return ($avatar_file && file_exists($avatar_file)) ? unlink($avatar_file) : false; } +/** + * @param $topic_id + * @param $attach_ext_id + * @return bool + */ function delete_attach($topic_id, $attach_ext_id) { $attach_file = ($attach_ext_id) ? get_attach_path($topic_id, $attach_ext_id) : ''; return ($attach_file && file_exists($attach_file)) ? unlink($attach_file) : false; } +/** + * @param $type + * @return array|bool|mixed + */ function get_tracks($type) { $c_name = ''; @@ -67,6 +105,12 @@ function get_tracks($type) return ($tracks) ? $tracks : array(); } +/** + * @param $cookie_name + * @param $tracking_ary + * @param null $tracks + * @param int $val + */ function set_tracks($cookie_name, &$tracking_ary, $tracks = null, $val = TIMENOW) { global $tracking_topics, $tracking_forums, $user; @@ -108,6 +152,11 @@ function set_tracks($cookie_name, &$tracking_ary, $tracks = null, $val = TIMENOW } } +/** + * @param int $topic_id + * @param int $forum_id + * @return mixed + */ function get_last_read($topic_id = 0, $forum_id = 0) { global $tracking_topics, $tracking_forums, $user; @@ -117,6 +166,12 @@ function get_last_read($topic_id = 0, $forum_id = 0) return max($t, $f, $user->data['user_lastvisit']); } +/** + * @param $ref + * @param int $topic_id + * @param int $forum_id + * @return bool + */ function is_unread($ref, $topic_id = 0, $forum_id = 0) { return (!IS_GUEST && $ref > get_last_read($topic_id, $forum_id)); @@ -192,6 +247,10 @@ $bf['user_opt'] = array( 'user_retracker' => 15, // Добавлять ретрекер к скачиваемым торрентам ); +/** + * @param $bit_num + * @return int + */ function bit2dec($bit_num) { if (is_array($bit_num)) { @@ -204,6 +263,11 @@ function bit2dec($bit_num) return (1 << $bit_num); } +/** + * @param $bf_array_name + * @param $key + * @return int + */ function bf_bit2dec($bf_array_name, $key) { global $bf; @@ -213,11 +277,23 @@ function bf_bit2dec($bf_array_name, $key) return (1 << $bf[$bf_array_name][$key]); } +/** + * @param $int + * @param $bf_array_name + * @param $key + * @return int + */ function bf($int, $bf_array_name, $key) { return (bf_bit2dec($bf_array_name, $key) & (int)$int); } +/** + * @param $int + * @param $bit_num + * @param $on + * @return int + */ function setbit(&$int, $bit_num, $on) { return ($on) ? $int |= (1 << $bit_num) : $int &= ~(1 << $bit_num); @@ -251,6 +327,14 @@ function setbit(&$int, $bit_num, $on) forum auth levels, this will prevent the auth function having to do its own lookup */ +/** + * @param $type + * @param $forum_id + * @param $ug_data + * @param array $f_access + * @param int $group_perm + * @return array|mixed + */ function auth($type, $forum_id, $ug_data, $f_access = array(), $group_perm = UG_PERM_BOTH) { global $lang, $bf, $datastore; @@ -408,6 +492,14 @@ function auth($type, $forum_id, $ug_data, $f_access = array(), $group_perm = UG_ return ($forum_id == AUTH_LIST_ALL) ? $auth : $auth[$forum_id]; } +/** + * @param $bf_ary + * @param $bf_key + * @param $perm_ary + * @param $perm_key + * @param bool $is_admin + * @return bool|int + */ function auth_check($bf_ary, $bf_key, $perm_ary, $perm_key, $is_admin = false) { if ($is_admin) { @@ -433,6 +525,9 @@ class Date_Delta public $format = ''; // Creates new object. + /** + * Date_Delta constructor. + */ public function Date_Delta() { global $lang; @@ -442,6 +537,12 @@ class Date_Delta } // Makes the spellable phrase. + /** + * @param $first + * @param $last + * @param string $from + * @return bool|string + */ public function spellDelta($first, $last, $from = 'auto') { if ($last < $first) { @@ -490,6 +591,11 @@ class Date_Delta } // returns the associative array with date deltas. + /** + * @param $first + * @param $last + * @return bool + */ public function getDelta($first, $last) { if ($last < $first) { @@ -534,6 +640,11 @@ class Date_Delta } // Returns the length (in days) of the specified month. + /** + * @param $year + * @param $mon + * @return int + */ public function monthLength($year, $mon) { $l = 28; @@ -544,11 +655,24 @@ class Date_Delta } } +/** + * @param $timestamp_1 + * @param int $timestamp_2 + * @param string $granularity + * @return mixed + */ function delta_time($timestamp_1, $timestamp_2 = TIMENOW, $granularity = 'auto') { return $GLOBALS['DeltaTime']->spellDelta($timestamp_1, $timestamp_2, $granularity); } +/** + * @param $select + * @param null $selected + * @param string $return_as + * @param string $first_opt + * @return array|string + */ function get_select($select, $selected = null, $return_as = 'html', $first_opt = '»» Выбрать ') { $select_ary = array(); @@ -583,6 +707,15 @@ class html_common public $max_length = HTML_SELECT_MAX_LENGTH; public $selected = array(); + /** + * @param $name + * @param $params + * @param null $selected + * @param int $max_length + * @param null $multiple_size + * @param string $js + * @return string + */ public function build_select($name, $params, $selected = null, $max_length = HTML_SELECT_MAX_LENGTH, $multiple_size = null, $js = '') { if (empty($params)) { @@ -611,6 +744,9 @@ class html_common return "\n\n"; } + /** + * @param $params + */ public function _build_select_rec($params) { foreach ($params as $opt_name => $opt_val) { @@ -641,6 +777,12 @@ class html_common } } + /** + * @param $array + * @param string $ul + * @param string $li + * @return string + */ public function array2html($array, $ul = 'ul', $li = 'li') { $this->out = ''; @@ -648,6 +790,11 @@ class html_common return "<$ul class=\"tree-root\">{$this->out}"; } + /** + * @param $array + * @param $ul + * @param $li + */ public function _array2html_rec($array, $ul, $li) { foreach ($array as $k => $v) { @@ -662,6 +809,16 @@ class html_common } // all arguments should be already htmlspecialchar()d (if needed) + /** + * @param $name + * @param $title + * @param bool $checked + * @param bool $disabled + * @param null $class + * @param null $id + * @param int $value + * @return string + */ public function build_checkbox($name, $title, $checked = false, $disabled = false, $class = null, $id = null, $value = 1) { $name = ' name="' . $name . '" '; @@ -675,18 +832,43 @@ class html_common } } +/** + * @param $name + * @param $params + * @param null $selected + * @param int $max_length + * @param null $multiple_size + * @param string $js + * @return string + */ function build_select($name, $params, $selected = null, $max_length = HTML_SELECT_MAX_LENGTH, $multiple_size = null, $js = '') { global $html; return $html->build_select($name, $params, $selected, $max_length, $multiple_size, $js); } +/** + * @param $name + * @param $title + * @param bool $checked + * @param bool $disabled + * @param null $class + * @param null $id + * @param int $value + * @return string + */ function build_checkbox($name, $title, $checked = false, $disabled = false, $class = null, $id = null, $value = 1) { global $html; return $html->build_checkbox($name, $title, $checked, $disabled, $class, $id, $value); } +/** + * @param $str + * @param bool $double + * @param bool $single + * @return mixed + */ function replace_quote($str, $double = true, $single = true) { if ($double) { @@ -760,6 +942,13 @@ function declension($int, $expressions, $format = '%1$s %2$s') } // http://forum.dklab.ru/php/advises/UrlreplaceargChangesValueOfParameterInUrl.html +/** + * @param $url + * @param $arg + * @param $value + * @param string $amp + * @return string + */ function url_arg($url, $arg, $value, $amp = '&') { $arg = preg_quote($arg, '/'); @@ -832,6 +1021,11 @@ function humn_size($size, $rounder = null, $min = null, $space = ' ') return round($size, $rounder) . $space . $ext; } +/** + * @param $ip + * @param string $port + * @return bool|string + */ function bt_show_ip($ip, $port = '') { /** @var \TorrentPier\Di $di */ @@ -846,6 +1040,10 @@ function bt_show_ip($ip, $port = '') } } +/** + * @param $port + * @return bool + */ function bt_show_port($port) { /** @var \TorrentPier\Di $di */ @@ -858,12 +1056,23 @@ function bt_show_port($port) } } +/** + * @param $ip + * @return string + */ function decode_ip_xx($ip) { $h = explode('.', chunk_split($ip, 2, '.')); return hexdec($h[0]) . '.' . hexdec($h[1]) . '.' . hexdec($h[2]) . '.xx'; } +/** + * @param $key + * @param $val + * @param int $default + * @param int $on + * @param int $off + */ function checkbox_get_val(&$key, &$val, $default = 1, $on = 1, $off = 0) { global $previous_settings, $search_id; @@ -879,6 +1088,13 @@ function checkbox_get_val(&$key, &$val, $default = 1, $on = 1, $off = 0) } } +/** + * @param $key + * @param $val + * @param $options_ary + * @param $default + * @param bool $num + */ function select_get_val($key, &$val, $options_ary, $default, $num = true) { global $previous_settings; @@ -998,6 +1214,10 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false) return $var; } +/** + * @param $user_id + * @return array|bool + */ function get_username($user_id) { if (empty($user_id)) { @@ -1015,6 +1235,10 @@ function get_username($user_id) } } +/** + * @param $username + * @return bool + */ function get_user_id($username) { if (empty($username)) { @@ -1024,6 +1248,12 @@ function get_user_id($username) return $row['user_id']; } +/** + * @param $text + * @param $max_length + * @param string $space + * @return mixed|string + */ function str_short($text, $max_length, $space = ' ') { if ($max_length && mb_strlen($text, 'UTF-8') > $max_length) { @@ -1042,11 +1272,20 @@ function str_short($text, $max_length, $space = ' ') return $text; } +/** + * @param $text + * @param int $max_word_length + * @return mixed + */ function wbr($text, $max_word_length = HTML_WBR_LENGTH) { return preg_replace("/([\w\->;:.,~!?(){}@#$%^*\/\\\\]{" . $max_word_length . "})/ui", '$1', $text); } +/** + * @param $user_id + * @return mixed|null + */ function get_bt_userdata($user_id) { /** @var \TorrentPier\Di $di */ @@ -1072,6 +1311,10 @@ function get_bt_userdata($user_id) return $btu; } +/** + * @param $btu + * @return float|null + */ function get_bt_ratio($btu) { return @@ -1080,6 +1323,9 @@ function get_bt_ratio($btu) : null; } +/** + * @param $user_id + */ function show_bt_userdata($user_id) { global $lang, $template; @@ -1115,6 +1361,12 @@ function show_bt_userdata($user_id) )); } +/** + * @param $table + * @param bool $from_db + * @param bool $update_cache + * @return array|mixed|null + */ function bb_get_config($table, $from_db = false, $update_cache = true) { /** @var \TorrentPier\Di $di */ @@ -1140,6 +1392,10 @@ function bb_get_config($table, $from_db = false, $update_cache = true) return $cfg; } +/** + * @param $params + * @param string $table + */ function bb_update_config($params, $table = BB_CONFIG) { $updates = array(); @@ -1157,6 +1413,10 @@ function bb_update_config($params, $table = BB_CONFIG) bb_get_config($table, true, true); } +/** + * @param $mode + * @return bool + */ function get_db_stat($mode) { switch ($mode) { @@ -1198,6 +1458,10 @@ function get_db_stat($mode) return false; } +/** + * @param $username + * @return mixed|string + */ function clean_username($username) { $username = mb_substr(htmlspecialchars(str_replace("\'", "'", trim($username))), 0, 25, 'UTF-8'); @@ -1207,6 +1471,11 @@ function clean_username($username) return $username; } +/** + * @param $str + * @param bool $charlist + * @return string + */ function bb_ltrim($str, $charlist = false) { if ($charlist === false) { @@ -1218,6 +1487,11 @@ function bb_ltrim($str, $charlist = false) return $str; } +/** + * @param $str + * @param bool $charlist + * @return string + */ function bb_rtrim($str, $charlist = false) { if ($charlist === false) { @@ -1230,6 +1504,12 @@ function bb_rtrim($str, $charlist = false) } // Get Userdata, $u can be username or user_id. If $force_name is true, the username will be forced. +/** + * @param $u + * @param bool $force_name + * @param bool $allow_guest + * @return array|bool|mixed|null + */ function get_userdata($u, $force_name = false, $allow_guest = false) { /** @var \TorrentPier\Di $di */ @@ -1276,6 +1556,9 @@ function get_userdata($u, $force_name = false, $allow_guest = false) return $u_data; } +/** + * @param int $selected + */ function make_jumpbox($selected = 0) { global $datastore, $template; @@ -1291,6 +1574,16 @@ function make_jumpbox($selected = 0) } // $mode: array(not_auth_forum1,not_auth_forum2,..) or (string) 'mode' +/** + * @param string $mode + * @param string $name + * @param null $selected + * @param int $max_length + * @param null $multiple_size + * @param string $js + * @param null $all_forums_option + * @return string + */ function get_forum_select($mode = 'guest', $name = POST_FORUM_URL, $selected = null, $max_length = HTML_SELECT_MAX_LENGTH, $multiple_size = null, $js = '', $all_forums_option = null) { global $lang, $datastore; @@ -1354,6 +1647,9 @@ function get_forum_select($mode = 'guest', $name = POST_FORUM_URL, $selected = n return build_select($name, $select, $selected, $max_length, $multiple_size, $js); } +/** + * @return array + */ function setup_style() { global $template, $userdata; @@ -1393,6 +1689,12 @@ function setup_style() } // Create date / time with format and friendly date +/** + * @param $gmepoch + * @param bool $format + * @param bool $friendly_date + * @return false|string + */ function bb_date($gmepoch, $format = false, $friendly_date = true) { global $lang, $userdata; @@ -1446,6 +1748,10 @@ function bb_date($gmepoch, $format = false, $friendly_date = true) return ($di->config->get('translate_dates')) ? strtr(strtoupper($date), $lang['DATETIME']) : $date; } +/** + * @param $date + * @return bool|mixed + */ function birthday_age($date) { /** @var \TorrentPier\Di $di */ @@ -1464,6 +1770,14 @@ function birthday_age($date) // Pagination routine, generates // page number sequence // +/** + * @param $base_url + * @param $num_items + * @param $per_page + * @param $start_item + * @param bool $add_prevnext_text + * @return mixed|string + */ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = true) { global $lang, $template; @@ -1566,6 +1880,11 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add // calling script, note that the vars are passed as references this just makes it easier // to return both sets of arrays // +/** + * @param $orig_word + * @param $replacement_word + * @return bool + */ function obtain_word_list(&$orig_word, &$replacement_word) { /** @var \TorrentPier\Di $di */ @@ -1596,6 +1915,9 @@ function obtain_word_list(&$orig_word, &$replacement_word) return true; } +/** + * @param $msg_text + */ function bb_die($msg_text) { global $ajax, $lang, $template, $theme, $user; @@ -1653,6 +1975,9 @@ function bb_die($msg_text) exit; } +/** + * @param $txt + */ function bb_simple_die($txt) { /** @var \TorrentPier\Di $di */ @@ -1666,16 +1991,27 @@ function bb_simple_die($txt) die($txt); } +/** + * @param $path + * @return string + */ function bb_realpath($path) { return (!function_exists('realpath') || !realpath(INC_DIR . 'functions.php')) ? $path : realpath($path); } +/** + * @param string $url + */ function login_redirect($url = '') { redirect(LOGIN_URL . '?redirect=' . (($url) ? $url : (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/'))); } +/** + * @param $url + * @param int $time + */ function meta_refresh($url, $time = 5) { global $template; @@ -1683,6 +2019,9 @@ function meta_refresh($url, $time = 5) $template->assign_var('META', ''); } +/** + * @param $url + */ function redirect($url) { /** @var \TorrentPier\Di $di */ @@ -1716,6 +2055,12 @@ function redirect($url) } // build a list of the sortable fields or return field name +/** + * @param int $selected_row + * @param string $action + * @param string $list + * @return string + */ function get_forum_display_sort_option($selected_row = 0, $action = 'list', $list = 'sort') { global $lang; @@ -1753,6 +2098,9 @@ function get_forum_display_sort_option($selected_row = 0, $action = 'list', $lis return $res; } +/** + * @param $topics_csv + */ function clear_dl_list($topics_csv) { DB()->query("DELETE FROM " . BB_BT_DLSTATUS . " WHERE topic_id IN($topics_csv)"); @@ -1760,6 +2108,10 @@ function clear_dl_list($topics_csv) } // $ids - array(id1,id2,..) or (string) id +/** + * @param $ids + * @return string + */ function get_id_csv($ids) { $ids = array_values((array)$ids); @@ -1768,6 +2120,10 @@ function get_id_csv($ids) } // $ids - array(id1,id2,..) or (string) id1,id2,.. +/** + * @param $ids + * @return array + */ function get_id_ary($ids) { $ids = is_string($ids) ? explode(',', $ids) : array_values((array)$ids); @@ -1775,6 +2131,10 @@ function get_id_ary($ids) return (array)$ids; } +/** + * @param $topic_id + * @return mixed + */ function get_topic_title($topic_id) { $row = DB()->fetch_row(" @@ -1783,11 +2143,19 @@ function get_topic_title($topic_id) return $row['topic_title']; } +/** + * @param $forum_id + * @return mixed + */ function forum_exists($forum_id) { return DB()->fetch_row("SELECT forum_id FROM " . BB_FORUMS . " WHERE forum_id = $forum_id LIMIT 1"); } +/** + * @param $cat_id + * @return mixed + */ function cat_exists($cat_id) { return DB()->fetch_row("SELECT cat_id FROM " . BB_CATEGORIES . " WHERE cat_id = $cat_id LIMIT 1"); @@ -1820,6 +2188,9 @@ class log_action public $log_type_select = []; public $log_disabled = false; + /** + * + */ public function init() { global $lang; @@ -1829,6 +2200,10 @@ class log_action } } + /** + * @param $type_name + * @param array $args + */ public function mod($type_name, $args = array()) { global $userdata; @@ -1874,12 +2249,21 @@ class log_action DB()->query("INSERT INTO " . BB_LOG . " $sql_args"); } + /** + * @param $type_name + * @param array $args + */ public function admin($type_name, $args = array()) { $this->mod($type_name, $args); } } +/** + * @param $topic + * @param null $is_unread + * @return mixed + */ function get_topic_icon($topic, $is_unread = null) { global $images; @@ -1916,6 +2300,12 @@ function get_topic_icon($topic, $is_unread = null) return $folder_image; } +/** + * @param $url + * @param $replies + * @param $per_page + * @return string + */ function build_topic_pagination($url, $replies, $per_page) { $pg = ''; @@ -1943,6 +2333,10 @@ function build_topic_pagination($url, $replies, $per_page) // // Poll // +/** + * @param $topic_id + * @return array|bool|mixed + */ function get_poll_data_items_js($topic_id) { /** @var \TorrentPier\Di $di */ @@ -1981,6 +2375,10 @@ function get_poll_data_items_js($topic_id) return is_array($topic_id) ? $items : $items[$topic_id]; } +/** + * @param $t_data + * @return bool + */ function poll_is_active($t_data) { /** @var \TorrentPier\Di $di */ @@ -1989,6 +2387,9 @@ function poll_is_active($t_data) return ($t_data['topic_vote'] == 1 && $t_data['topic_time'] > TIMENOW - $di->config->get('poll_max_days') * 86400); } +/** + * @param $tpl_vars + */ function print_confirmation($tpl_vars) { global $template, $lang; @@ -2042,6 +2443,11 @@ function print_page($args, $type = '', $mode = '') } } +/** + * @param $str + * @param bool $replace_underscore + * @return mixed|string + */ function clean_title($str, $replace_underscore = false) { $str = ($replace_underscore) ? str_replace('_', ' ', $str) : $str; @@ -2049,6 +2455,13 @@ function clean_title($str, $replace_underscore = false) return $str; } +/** + * @param $text + * @param bool $ltrim_star + * @param bool $remove_stopwords + * @param bool $die_if_empty + * @return mixed|string + */ function clean_text_match($text, $ltrim_star = true, $remove_stopwords = false, $die_if_empty = false) { global $lang; @@ -2088,6 +2501,9 @@ function clean_text_match($text, $ltrim_star = true, $remove_stopwords = false, return $text_match_sql; } +/** + * + */ function init_sphinx() { global $sphinx; @@ -2104,6 +2520,11 @@ function init_sphinx() } } +/** + * @param $err_type + * @param $err_msg + * @param string $query + */ function log_sphinx_error($err_type, $err_msg, $query = '') { $ignore_err_txt = array( @@ -2116,6 +2537,10 @@ function log_sphinx_error($err_type, $err_msg, $query = '') } } +/** + * @param $search + * @return array + */ function get_title_match_topics($search) { global $sphinx, $userdata, $lang; @@ -2178,16 +2603,28 @@ function get_title_match_topics($search) } // для более корректного поиска по словам содержащим одиночную кавычку +/** + * @param $txt + * @return mixed + */ function encode_text_match($txt) { return str_replace("'", ''', $txt); } +/** + * @param $txt + * @return mixed + */ function decode_text_match($txt) { return str_replace(''', "'", $txt); } +/** + * @param $text + * @return mixed + */ function remove_stopwords($text) { static $stopwords = null; @@ -2200,11 +2637,21 @@ function remove_stopwords($text) return ($stopwords) ? str_replace($stopwords, ' ', $text) : $text; } +/** + * @param $str + * @return string + */ function pad_with_space($str) { return ($str) ? " $str " : $str; } +/** + * @param $infohash + * @param $auth_key + * @param $logged_in + * @return string + */ function create_magnet($infohash, $auth_key, $logged_in) { global $images; @@ -2221,6 +2668,11 @@ function create_magnet($infohash, $auth_key, $logged_in) } } +/** + * @param null $forum_id + * @param null $topic_id + * @param null $group_id + */ function set_die_append_msg($forum_id = null, $topic_id = null, $group_id = null) { global $lang, $template; @@ -2233,6 +2685,9 @@ function set_die_append_msg($forum_id = null, $topic_id = null, $group_id = null $template->assign_var('BB_DIE_APPEND_MSG', $msg); } +/** + * @param $pr_uid + */ function set_pr_die_append_msg($pr_uid) { global $lang, $template; @@ -2246,6 +2701,12 @@ function set_pr_die_append_msg($pr_uid) '); } +/** + * @param $user_id + * @param $subject + * @param $message + * @param int $poster_id + */ function send_pm($user_id, $subject, $message, $poster_id = BOT_UID) { global $userdata; @@ -2269,6 +2730,10 @@ function send_pm($user_id, $subject, $message, $poster_id = BOT_UID) DB()->query("UPDATE " . BB_USERS . " SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . TIMENOW . ", user_newest_pm_id = $pm_id WHERE user_id = $user_id"); } +/** + * @param $data + * @return string + */ function profile_url($data) { global $lang, $datastore; @@ -2310,6 +2775,15 @@ function profile_url($data) return $profile; } +/** + * @param $user_id + * @param $ext_id + * @param bool $allow_avatar + * @param bool $size + * @param string $height + * @param string $width + * @return string + */ function get_avatar($user_id, $ext_id, $allow_avatar = true, $size = true, $height = '', $width = '') { /** @var \TorrentPier\Di $di */ @@ -2335,6 +2809,10 @@ function get_avatar($user_id, $ext_id, $allow_avatar = true, $size = true, $heig return $user_avatar; } +/** + * @param $gender + * @return string + */ function gender_image($gender) { global $lang, $images; @@ -2362,6 +2840,10 @@ function gender_image($gender) return $user_gender; } +/** + * @param $type + * @return string + */ function is_gold($type) { global $lang, $tr_cfg; @@ -2386,6 +2868,10 @@ function is_gold($type) return $is_gold; } +/** + * @param $type + * @param $id + */ function update_atom($type, $id) { require_once(INC_DIR . 'functions_atom.php'); @@ -2402,6 +2888,9 @@ function update_atom($type, $id) } } +/** + * @param $hash + */ function hash_search($hash) { global $lang; @@ -2421,6 +2910,11 @@ function hash_search($hash) } } +/** + * @param $mode + * @param string $callback + * @return bool|string + */ function bb_captcha($mode, $callback = '') { global $lang; diff --git a/library/includes/functions_admin.php b/library/includes/functions_admin.php index 88fdfa702..ff1d96162 100644 --- a/library/includes/functions_admin.php +++ b/library/includes/functions_admin.php @@ -4,6 +4,9 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } +/** + * Синхронизация всех форумов + */ function sync_all_forums() { foreach (DB()->fetch_rowset("SELECT forum_id FROM " . BB_FORUMS) as $row) { @@ -11,6 +14,10 @@ function sync_all_forums() } } +/** + * @param $type + * @param $id + */ function sync($type, $id) { switch ($type) { @@ -182,6 +189,13 @@ function sync($type, $id) } } +/** + * @param $mode_or_topic_id + * @param null $forum_id + * @param int $prune_time + * @param bool $prune_all + * @return mixed + */ function topic_delete($mode_or_topic_id, $forum_id = null, $prune_time = 0, $prune_all = false) { global $lang, $log_action; @@ -354,6 +368,14 @@ function topic_delete($mode_or_topic_id, $forum_id = null, $prune_time = 0, $pru return $deleted_topics_count; } +/** + * @param $topic_id + * @param $to_forum_id + * @param null $from_forum_id + * @param bool $leave_shadow + * @param bool $insert_bot_msg + * @return bool + */ function topic_move($topic_id, $to_forum_id, $from_forum_id = null, $leave_shadow = false, $insert_bot_msg = false) { global $log_action; @@ -444,6 +466,12 @@ function topic_move($topic_id, $to_forum_id, $from_forum_id = null, $leave_shado return true; } +/** + * @param $topic_id + * @param $mode + * @param null $forum_id + * @return bool + */ function topic_lock_unlock($topic_id, $mode, $forum_id = null) { global $log_action; @@ -490,6 +518,12 @@ function topic_lock_unlock($topic_id, $mode, $forum_id = null) return true; } +/** + * @param $topic_id + * @param $mode + * @param null $forum_id + * @return bool + */ function topic_stick_unstick($topic_id, $mode, $forum_id = null) { if (!$topic_csv = get_id_csv($topic_id)) { @@ -518,6 +552,12 @@ function topic_stick_unstick($topic_id, $mode, $forum_id = null) } // $exclude_first - в режиме удаления сообщений по списку исключать первое сообщение в теме +/** + * @param $mode_or_post_id + * @param null $user_id + * @param bool $exclude_first + * @return mixed + */ function post_delete($mode_or_post_id, $user_id = null, $exclude_first = true) { global $log_action; @@ -656,6 +696,11 @@ function post_delete($mode_or_post_id, $user_id = null, $exclude_first = true) return $deleted_posts_count; } +/** + * @param $user_id + * @param bool $delete_posts + * @return bool + */ function user_delete($user_id, $delete_posts = false) { global $log_action; @@ -746,6 +791,10 @@ function user_delete($user_id, $delete_posts = false) } } +/** + * @param $user_id + * @return string + */ function get_usernames_for_log($user_id) { $users_log_msg = array(); diff --git a/library/includes/functions_admin_cron.php b/library/includes/functions_admin_cron.php index 281c3ca7b..5fd89bba8 100644 --- a/library/includes/functions_admin_cron.php +++ b/library/includes/functions_admin_cron.php @@ -1,5 +1,8 @@ query("DELETE FROM " . BB_CRON . " WHERE cron_id IN ($jobs)"); return; } +/** + * @param $jobs + * @param $cron_action + */ function toggle_active($jobs, $cron_action) { $active = ($cron_action == 'disable') ? 0 : 1; @@ -59,6 +69,10 @@ function toggle_active($jobs, $cron_action) return; } +/** + * @param $cron_arr + * @return int|string + */ function validate_cron_post($cron_arr) { $errors = 'Errors in: '; @@ -79,6 +93,9 @@ function validate_cron_post($cron_arr) return $result; } +/** + * @param $cron_arr + */ function insert_cron_job($cron_arr) { $row = DB()->fetch_row("SELECT cron_title, cron_script FROM " . BB_CRON . " WHERE cron_title = '" . $_POST['cron_title'] . "' or cron_script = '" . $_POST['cron_script'] . "' "); @@ -117,6 +134,9 @@ function insert_cron_job($cron_arr) $cron_active, '$cron_title', '$cron_script', '$schedule', '$run_day', '$run_time', '$run_order', '$last_run', '$next_run', '$run_interval', $log_enabled, '$log_file', $log_sql_queries, $disable_board, '$run_counter')"); } +/** + * @param $cron_arr + */ function update_cron_job($cron_arr) { $cron_id = $cron_arr['cron_id']; diff --git a/library/includes/functions_admin_torrent.php b/library/includes/functions_admin_torrent.php index 7d645ffb2..b6ff501ac 100644 --- a/library/includes/functions_admin_torrent.php +++ b/library/includes/functions_admin_torrent.php @@ -4,6 +4,12 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } +/** + * @param $table_name + * @param $key + * @param $field_name + * @param $field_def_val + */ function update_table_bool($table_name, $key, $field_name, $field_def_val) { // Clear current status @@ -37,6 +43,10 @@ function update_table_bool($table_name, $key, $field_name, $field_def_val) return; } +/** + * @param $default_cfg + * @param $cfg + */ function set_tpl_vars($default_cfg, $cfg) { global $template; @@ -46,6 +56,10 @@ function set_tpl_vars($default_cfg, $cfg) } } +/** + * @param $default_cfg + * @param $cfg + */ function set_tpl_vars_bool($default_cfg, $cfg) { global $template, $lang; @@ -64,6 +78,9 @@ function set_tpl_vars_bool($default_cfg, $cfg) } } +/** + * @param $default_cfg + */ function set_tpl_vars_lang($default_cfg) { global $template, $lang; @@ -77,6 +94,12 @@ function set_tpl_vars_lang($default_cfg) } } +/** + * @param $table_name + * @param $default_cfg + * @param $cfg + * @param $type + */ function update_config_table($table_name, $default_cfg, $cfg, $type) { foreach ($default_cfg as $config_name => $config_value) { diff --git a/library/includes/functions_atom.php b/library/includes/functions_atom.php index f4107a94b..ab8717a55 100644 --- a/library/includes/functions_atom.php +++ b/library/includes/functions_atom.php @@ -7,6 +7,11 @@ if (!defined('BB_ROOT')) { // Максимум записей = 50 // [Обновлено] - если дата изменения первого поста топика не старее недели (?) или в топике новые сообщения не старее недели (?) +/** + * @param $forum_id + * @param $forum_data + * @return bool + */ function update_forum_feed($forum_id, $forum_data) { /** @var \TorrentPier\Di $di */ @@ -81,6 +86,11 @@ function update_forum_feed($forum_id, $forum_data) } } +/** + * @param $user_id + * @param $username + * @return bool + */ function update_user_feed($user_id, $username) { /** @var \TorrentPier\Di $di */ @@ -129,6 +139,14 @@ function update_user_feed($user_id, $username) } } +/** + * @param $file_path + * @param $mode + * @param $id + * @param $title + * @param $topics + * @return bool + */ function create_atom($file_path, $mode, $id, $title, $topics) { /** @var \TorrentPier\Di $di */ diff --git a/library/includes/functions_dev.php b/library/includes/functions_dev.php index 6a81ca183..456efec79 100644 --- a/library/includes/functions_dev.php +++ b/library/includes/functions_dev.php @@ -4,6 +4,9 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } +/** + * @return string + */ function get_sql_log() { global $DBS, $sphinx, $datastore; @@ -25,6 +28,11 @@ function get_sql_log() return $log; } +/** + * @param $db_obj + * @param $log_name + * @return string + */ function get_sql_log_html($db_obj, $log_name) { $log = ''; diff --git a/library/includes/functions_group.php b/library/includes/functions_group.php index 16240a5a4..85718364e 100644 --- a/library/includes/functions_group.php +++ b/library/includes/functions_group.php @@ -4,6 +4,9 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } +/** + * @param $user_id + */ function update_user_level($user_id) { global $datastore; @@ -61,6 +64,9 @@ function update_user_level($user_id) $datastore->update('moderators'); } +/** + * @param $group_id + */ function delete_group($group_id) { $group_id = (int)$group_id; @@ -78,6 +84,12 @@ function delete_group($group_id) update_user_level('all'); } +/** + * @param $group_id + * @param $user_id + * @param int $user_pending + * @param int $user_time + */ function add_user_into_group($group_id, $user_id, $user_pending = 0, $user_time = TIMENOW) { $args = DB()->build_array('INSERT', array( @@ -93,6 +105,10 @@ function add_user_into_group($group_id, $user_id, $user_pending = 0, $user_time } } +/** + * @param $group_id + * @param $user_id + */ function delete_user_group($group_id, $user_id) { DB()->query(" @@ -104,6 +120,10 @@ function delete_user_group($group_id, $user_id) update_user_level($user_id); } +/** + * @param $user_id + * @return int + */ function create_user_group($user_id) { DB()->query("INSERT INTO " . BB_GROUPS . " (group_single_user) VALUES (1)"); @@ -116,6 +136,10 @@ function create_user_group($user_id) return $group_id; } +/** + * @param $group_id + * @return mixed + */ function get_group_data($group_id) { if ($group_id === 'all') { @@ -139,6 +163,11 @@ function get_group_data($group_id) return DB()->$method($sql); } +/** + * @param null $group_id + * @param null $user_id + * @param null $cat_id + */ function delete_permissions($group_id = null, $user_id = null, $cat_id = null) { $group_id = get_id_csv($group_id); @@ -157,6 +186,10 @@ function delete_permissions($group_id = null, $user_id = null, $cat_id = null) } } +/** + * @param $group_id + * @param $auth_ary + */ function store_permissions($group_id, $auth_ary) { if (empty($auth_ary) || !is_array($auth_ary)) { @@ -177,6 +210,9 @@ function store_permissions($group_id, $auth_ary) DB()->query("INSERT INTO " . BB_AUTH_ACCESS . $values); } +/** + * @param string $user_id + */ function update_user_permissions($user_id = 'all') { if (is_array($user_id)) { @@ -206,6 +242,9 @@ function update_user_permissions($user_id = 'all') "); } +/** + * Удаление битых групп пользователей + */ function delete_orphan_usergroups() { // GROUP_SINGLE_USER without AUTH_ACCESS diff --git a/library/includes/functions_post.php b/library/includes/functions_post.php index 9b9013c1a..4a1b0ed9b 100644 --- a/library/includes/functions_post.php +++ b/library/includes/functions_post.php @@ -7,6 +7,14 @@ if (!defined('BB_ROOT')) { // // Prepare a message for posting // +/** + * @param $mode + * @param $post_data + * @param $error_msg + * @param $username + * @param $subject + * @param $message + */ function prepare_post(&$mode, &$post_data, &$error_msg, &$username, &$subject, &$message) { global $user, $userdata, $lang; @@ -59,6 +67,23 @@ function prepare_post(&$mode, &$post_data, &$error_msg, &$username, &$subject, & // // Post a new topic/reply or edit existing post/poll // +/** + * @param $mode + * @param $post_data + * @param $message + * @param $meta + * @param $forum_id + * @param $topic_id + * @param $post_id + * @param $topic_type + * @param $post_username + * @param $post_subject + * @param $post_message + * @param $update_post_time + * @param $poster_rg_id + * @param $attach_rg_sig + * @return mixed + */ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$topic_type, $post_username, $post_subject, $post_message, $update_post_time, $poster_rg_id, $attach_rg_sig) { global $userdata, $post_info, $is_auth, $lang, $datastore; @@ -196,6 +221,14 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_ // // Update post stats and details // +/** + * @param $mode + * @param $post_data + * @param $forum_id + * @param $topic_id + * @param $post_id + * @param $user_id + */ function update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id) { $sign = ($mode == 'delete') ? '- 1' : '+ 1'; @@ -271,6 +304,15 @@ function update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $u // // Delete a post // +/** + * @param $mode + * @param $post_data + * @param $message + * @param $meta + * @param $forum_id + * @param $topic_id + * @param $post_id + */ function delete_post($mode, $post_data, &$message, &$meta, $forum_id, $topic_id, $post_id) { global $lang; @@ -284,6 +326,14 @@ function delete_post($mode, $post_data, &$message, &$meta, $forum_id, $topic_id, // // Handle user notification on new post // +/** + * @param $mode + * @param $post_data + * @param $topic_title + * @param $forum_id + * @param $topic_id + * @param $notify_user + */ function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$notify_user) { global $lang, $userdata; @@ -373,6 +423,17 @@ function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topi } } +/** + * @param $mode + * @param $topic_id + * @param string $forum_id + * @param string $old_forum_id + * @param string $new_topic_id + * @param string $new_topic_title + * @param string $old_topic_id + * @param string $message + * @param string $poster_id + */ function insert_post($mode, $topic_id, $forum_id = '', $old_forum_id = '', $new_topic_id = '', $new_topic_title = '', $old_topic_id = '', $message = '', $poster_id = '') { global $userdata, $lang; diff --git a/library/includes/functions_selects.php b/library/includes/functions_selects.php index efcf01aac..609aaac57 100644 --- a/library/includes/functions_selects.php +++ b/library/includes/functions_selects.php @@ -5,6 +5,11 @@ if (!defined('BB_ROOT')) { } // Languages +/** + * @param $default_lang + * @param string $select_name + * @return string + */ function language_select($default_lang, $select_name = 'language') { /** @var \TorrentPier\Di $di */ @@ -25,6 +30,11 @@ function language_select($default_lang, $select_name = 'language') } // Pick a timezone +/** + * @param $default + * @param string $select_name + * @return string + */ function tz_select($default, $select_name = 'timezone') { global $sys_timezone, $lang; @@ -44,6 +54,11 @@ function tz_select($default, $select_name = 'timezone') } // Templates +/** + * @param $default_style + * @param string $select_name + * @return string + */ function templates_select($default_style, $select_name = 'tpl_name') { /** @var \TorrentPier\Di $di */ diff --git a/library/includes/functions_torrent.php b/library/includes/functions_torrent.php index 599b64c1c..ee04e06d5 100644 --- a/library/includes/functions_torrent.php +++ b/library/includes/functions_torrent.php @@ -4,6 +4,11 @@ if (!defined('BB_ROOT')) { die(basename(__FILE__)); } +/** + * @param $forum_id + * @param $poster_id + * @return bool + */ function torrent_auth_check($forum_id, $poster_id) { global $lang, $userdata; @@ -22,6 +27,10 @@ function torrent_auth_check($forum_id, $poster_id) bb_die($lang['NOT_MODERATOR']); } +/** + * @param $topic_id + * @param string $redirect_url + */ function tracker_unregister($topic_id, $redirect_url = '') { global $lang, $log_action; @@ -85,6 +94,10 @@ function tracker_unregister($topic_id, $redirect_url = '') } } +/** + * @param $topic_id + * @param $forum_id + */ function torrent_cp_close($topic_id, $forum_id) { global $log_action, $userdata; @@ -111,6 +124,13 @@ function torrent_cp_close($topic_id, $forum_id) topic_lock_unlock($topic_id, 'lock'); } +/** + * @param $topic_id + * @param string $mode + * @param int $tor_status + * @param int $reg_time + * @return bool|mixed|string + */ function tracker_register($topic_id, $mode = '', $tor_status = TOR_NOT_APPROVED, $reg_time = TIMENOW) { global $lang; @@ -231,6 +251,10 @@ function tracker_register($topic_id, $mode = '', $tor_status = TOR_NOT_APPROVED, return true; } +/** + * @param $topic_id + * @return bool + */ function delete_torrent($topic_id) { tracker_unregister($topic_id); @@ -239,6 +263,10 @@ function delete_torrent($topic_id) return true; } +/** + * @param $topic_id + * @param $tor_status + */ function change_tor_status($topic_id, $tor_status) { global $userdata; @@ -260,6 +288,10 @@ function change_tor_status($topic_id, $tor_status) } // Set gold / silver type for torrent +/** + * @param $topic_id + * @param $tor_status_gold + */ function change_tor_type($topic_id, $tor_status_gold) { global $lang; @@ -285,6 +317,9 @@ function change_tor_type($topic_id, $tor_status_gold) } } +/** + * @param $t_data + */ function send_torrent_with_passkey($t_data) { global $lang, $tr_cfg, $userdata; @@ -453,6 +488,11 @@ function send_torrent_with_passkey($t_data) bb_exit($output); } +/** + * @param $user_id + * @param bool $force_generate + * @return bool|string + */ function generate_passkey($user_id, $force_generate = false) { global $lang; @@ -507,6 +547,10 @@ function generate_passkey($user_id, $force_generate = false) return false; } +/** + * @param $message + * @return mixed + */ function torrent_error_exit($message) { global $reg_mode, $return_message, $lang; @@ -527,16 +571,29 @@ function torrent_error_exit($message) bb_die($msg . $message); } +/** + * @param $topic_id + * @return mixed + */ function tracker_rm_torrent($topic_id) { return DB()->sql_query("DELETE FROM " . BB_BT_TRACKER . " WHERE topic_id = " . (int)$topic_id); } +/** + * @param $user_id + * @return mixed + */ function tracker_rm_user($user_id) { return DB()->sql_query("DELETE FROM " . BB_BT_TRACKER . " WHERE user_id = " . (int)$user_id); } +/** + * @param $action + * @param $updates + * @return bool + */ function ocelot_update_tracker($action, $updates) { /** @var \TorrentPier\Di $di */ @@ -558,6 +615,12 @@ function ocelot_update_tracker($action, $updates) return true; } +/** + * @param $get + * @param int $max_attempts + * @param bool $err + * @return bool|int + */ function ocelot_send_request($get, $max_attempts = 1, &$err = false) { /** @var \TorrentPier\Di $di */ @@ -607,18 +670,31 @@ function ocelot_send_request($get, $max_attempts = 1, &$err = false) } // bdecode: based on OpenTracker +/** + * @param $filename + * @return null|string + */ function bdecode_file($filename) { $file_contents = file_get_contents($filename); return bdecode($file_contents); } +/** + * @param $str + * @return null|string + */ function bdecode($str) { $pos = 0; return bdecode_r($str, $pos); } +/** + * @param $str + * @param $pos + * @return null|string + */ function bdecode_r($str, &$pos) { $strlen = strlen($str); diff --git a/library/includes/functions_upload.php b/library/includes/functions_upload.php index b0c3a5b2f..40b0018a6 100644 --- a/library/includes/functions_upload.php +++ b/library/includes/functions_upload.php @@ -36,6 +36,12 @@ class upload_common 8 => 'tiff', ); + /** + * @param array $cfg + * @param array $post_params + * @param bool $uploaded_only + * @return bool + */ public function init($cfg = array(), $post_params = array(), $uploaded_only = true) { global $lang; @@ -109,6 +115,11 @@ class upload_common return true; } + /** + * @param string $mode + * @param array $params + * @return bool + */ public function store($mode = '', $params = array()) { if ($mode == 'avatar') { @@ -124,6 +135,10 @@ class upload_common } } + /** + * @param $file_path + * @return bool + */ public function _move($file_path) { $dir = dirname($file_path); diff --git a/library/includes/functions_validate.php b/library/includes/functions_validate.php index 0e0a1f83e..1cb279a3e 100644 --- a/library/includes/functions_validate.php +++ b/library/includes/functions_validate.php @@ -5,6 +5,11 @@ if (!defined('BB_ROOT')) { } // !!! $username должен быть предварительно обработан clean_username() !!! +/** + * @param $username + * @param bool $check_ban_and_taken + * @return bool|string + */ function validate_username($username, $check_ban_and_taken = true) { global $user, $lang; @@ -59,6 +64,11 @@ function validate_username($username, $check_ban_and_taken = true) } // Check to see if email address is banned or already present in the DB +/** + * @param $email + * @param bool $check_ban_and_taken + * @return bool|string + */ function validate_email($email, $check_ban_and_taken = true) { global $lang, $userdata; diff --git a/library/includes/init_bb.php b/library/includes/init_bb.php index 2b23be4c4..802d1c045 100644 --- a/library/includes/init_bb.php +++ b/library/includes/init_bb.php @@ -29,6 +29,10 @@ $user_ip = encode_ip($client_ip); define('CLIENT_IP', $client_ip); define('USER_IP', $user_ip); +/** + * @param $contents + * @return string + */ function send_page($contents) { return compress_output($contents); @@ -36,6 +40,10 @@ function send_page($contents) define('UA_GZIP_SUPPORTED', (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false)); +/** + * @param $contents + * @return string + */ function compress_output($contents) { /** @var \TorrentPier\Di $di */ @@ -71,6 +79,13 @@ define('COOKIE_PERSIST', TIMENOW + 31536000); define('COOKIE_MAX_TRACKS', 90); +/** + * @param $name + * @param $val + * @param int $lifetime + * @param bool $httponly + * @return bool + */ function bb_setcookie($name, $val, $lifetime = COOKIE_PERSIST, $httponly = false) { /** @var \TorrentPier\Di $di */ @@ -276,7 +291,9 @@ $dl_status_css = [ DL_STATUS_CANCEL => 'dlCancel', ]; -// Functions +/** + * Отправка заголовков без кеша + */ function send_no_cache_headers() { header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); @@ -286,6 +303,9 @@ function send_no_cache_headers() header('Pragma: no-cache'); } +/** + * @param string $output + */ function bb_exit($output = '') { if ($output) { @@ -294,16 +314,33 @@ function bb_exit($output = '') exit; } +/** + * @param $txt + * @param bool $double_encode + * @param int $quote_style + * @param string $charset + * @return string + */ function htmlCHR($txt, $double_encode = false, $quote_style = ENT_QUOTES, $charset = 'UTF-8') { return (string)htmlspecialchars($txt, $quote_style, $charset, $double_encode); } +/** + * @param $txt + * @param int $quote_style + * @param string $charset + * @return string + */ function html_ent_decode($txt, $quote_style = ENT_QUOTES, $charset = 'UTF-8') { return (string)html_entity_decode($txt, $quote_style, $charset); } +/** + * @param string $path + * @return string + */ function make_url($path = '') { return FULL_URL . preg_replace('#^\/?(.*?)\/?$#', '\1', $path); @@ -375,7 +412,9 @@ if (($di->config->get('board_disable') || file_exists(BB_DISABLED)) && !defined( } } -// Cron functions +/** + * Снятие блокировки крона + */ function cron_release_deadlock() { if (file_exists(CRON_RUNNING)) { @@ -386,17 +425,26 @@ function cron_release_deadlock() } } +/** + * Блокировка крона + */ function cron_release_file_lock() { rename(CRON_RUNNING, CRON_ALLOWED); cron_touch_lock_file(CRON_ALLOWED); } +/** + * @param $lock_file + */ function cron_touch_lock_file($lock_file) { file_write(make_rand_str(20), $lock_file, 0, true, true); } +/** + * Включение форума (при блокировке крона) + */ function cron_enable_board() { if (file_exists(BB_DISABLED)) { @@ -404,6 +452,9 @@ function cron_enable_board() } } +/** + * Отключение форума (при блокировке крона) + */ function cron_disable_board() { if (file_exists(BB_ENABLED)) { diff --git a/library/includes/sessions.php b/library/includes/sessions.php index b3c96d02c..dcf6ceea4 100644 --- a/library/includes/sessions.php +++ b/library/includes/sessions.php @@ -735,11 +735,18 @@ class user_common // // userdata cache // +/** + * @return bool + */ function ignore_cached_userdata() { return (defined('IN_PM')) ? true : false; } +/** + * @param $id + * @return bool|mixed|null + */ function cache_get_userdata($id) { /** @var \TorrentPier\Di $di */ @@ -755,6 +762,11 @@ function cache_get_userdata($id) return $cache->get($id); } +/** + * @param $userdata + * @param bool $force + * @return bool + */ function cache_set_userdata($userdata, $force = false) { /** @var \TorrentPier\Di $di */ @@ -772,6 +784,10 @@ function cache_set_userdata($userdata, $force = false) return $cache->set($id, $userdata, $di->config->get('session_update_intrv')); } +/** + * @param $userdata + * @return bool + */ function cache_rm_userdata($userdata) { /** @var \TorrentPier\Di $di */ @@ -790,6 +806,9 @@ function cache_rm_userdata($userdata) } // $user_id - array(id1,id2,..) or (string) id +/** + * @param $user_id + */ function cache_rm_user_sessions($user_id) { /** @var \TorrentPier\Di $di */ @@ -809,11 +828,21 @@ function cache_rm_user_sessions($user_id) } } +/** + * @param $userdata + * @return bool + */ function cache_update_userdata($userdata) { return cache_set_userdata($userdata, true); } +/** + * @param $userdata + * @param $sql_ary + * @param bool $data_already_escaped + * @return bool + */ function db_update_userdata($userdata, $sql_ary, $data_already_escaped = true) { if (!$userdata) { @@ -831,6 +860,9 @@ function db_update_userdata($userdata, $sql_ary, $data_already_escaped = true) } // $user_id - array(id1,id2,..) or (string) id +/** + * @param $user_id + */ function delete_user_sessions($user_id) { cache_rm_user_sessions($user_id); diff --git a/library/includes/smtp.php b/library/includes/smtp.php index 2cb10c454..0f4cc07e3 100644 --- a/library/includes/smtp.php +++ b/library/includes/smtp.php @@ -6,6 +6,11 @@ if (!defined('BB_ROOT')) { define('SMTP_INCLUDED', 1); +/** + * @param $socket + * @param $response + * @param int $line + */ function server_parse($socket, $response, $line = __LINE__) { $server_response = ''; @@ -21,6 +26,13 @@ function server_parse($socket, $response, $line = __LINE__) } // Replacement or substitute for PHP's mail command +/** + * @param $mail_to + * @param $subject + * @param $message + * @param string $headers + * @return bool + */ function smtpmail($mail_to, $subject, $message, $headers = '') { /** @var \TorrentPier\Di $di */ diff --git a/library/includes/template.php b/library/includes/template.php index 64990a784..a7ca87934 100644 --- a/library/includes/template.php +++ b/library/includes/template.php @@ -92,6 +92,7 @@ class template * Constructor. Installs XS mod on first run or updates it and sets the root dir. * * @param string $root + * @return template */ public function Template($root = '.') { @@ -531,6 +532,11 @@ class template } } + /** + * @param $filename + * @param $code + * @return string + */ public function compile_code($filename, $code) { // Load code from file @@ -818,6 +824,10 @@ class template /* * Compile code between tags */ + /** + * @param $code + * @return mixed + */ public function _compile_text($code) { if (strlen($code) < 3) { @@ -850,6 +860,11 @@ class template // // Compile IF tags - much of this is from Smarty with some adaptions for our block level methods // + /** + * @param $tag_args + * @param $elseif + * @return string + */ public function compile_tag_if($tag_args, $elseif) { /* Tokenize args for 'if' tag */ @@ -961,6 +976,11 @@ class template } // This is from Smarty + /** + * @param $is_arg + * @param $tokens + * @return mixed + */ public function _parse_is_expr($is_arg, $tokens) { $expr_end = 0; @@ -1069,6 +1089,9 @@ class template file_write($code, $filename, false, true, true); } + /** + * Запуск шаблонизатора + */ public function xs_startup() { /** @var \TorrentPier\Di $di */ @@ -1088,6 +1111,10 @@ class template } } + /** + * @param $var + * @return string + */ public function lang_error($var) { trigger_error(basename($this->cur_tpl) . " : undefined language variable {L_{$var}}", E_USER_WARNING); diff --git a/src/ServiceProviders/DbServiceProvider.php b/src/ServiceProviders/DbServiceProvider.php index 44593263f..51341d920 100644 --- a/src/ServiceProviders/DbServiceProvider.php +++ b/src/ServiceProviders/DbServiceProvider.php @@ -5,7 +5,6 @@ namespace TorrentPier\ServiceProviders; use Pimple\Container; use Pimple\ServiceProviderInterface; use TorrentPier\Db\Adapter; -use TorrentPier\Db\Connection; /** * Class DbServiceProvider diff --git a/styles/js/bbcode.js b/styles/js/bbcode.js index 35c9bd840..7828ec7e1 100644 --- a/styles/js/bbcode.js +++ b/styles/js/bbcode.js @@ -1,453 +1,472 @@ // BBCode control -function BBCode(obj) -{ - textarea = document.getElementById(obj); - this.construct(textarea); +function BBCode(obj) { + textarea = document.getElementById(obj); + this.construct(textarea); } BBCode.prototype = { - VK_TAB: 9, - VK_ENTER: 13, - VK_PAGE_UP: 33, - BRK_OP: '[', - BRK_CL: ']', - textarea: null, - stext: '', - quoter: null, - qouted_pid: null, - collapseAfterInsert: false, - replaceOnInsert: false, + VK_TAB: 9, + VK_ENTER: 13, + VK_PAGE_UP: 33, + BRK_OP: '[', + BRK_CL: ']', + textarea: null, + stext: '', + quoter: null, + qouted_pid: null, + collapseAfterInsert: false, + replaceOnInsert: false, - // Create new BBCode control - construct: function(textarea) { - this.textarea = textarea; - this.tags = {}; - // Tag for quoting - this.addTag( - '_quoter', - function() { return '[quote="'+th.quoter+'"][qpost='+th.qouted_pid+']' }, - '[/quote]\n', - null, - null, - function() { th.collapseAfterInsert=true; return th._prepareMultiline(th.quoterText) } - ); + // Create new BBCode control + construct: function (textarea) { + this.textarea = textarea; + this.tags = {}; + // Tag for quoting + this.addTag( + '_quoter', + function () { + return '[quote="' + th.quoter + '"][qpost=' + th.qouted_pid + ']' + }, + '[/quote]\n', + null, + null, + function () { + th.collapseAfterInsert = true; + return th._prepareMultiline(th.quoterText) + } + ); - // Init events - var th = this; - addEvent(textarea, 'keydown', function(e) { return th.onKeyPress(e, window.HTMLElement? 'down' : 'press') }); - addEvent(textarea, 'keypress', function(e) { return th.onKeyPress(e, 'press') }); - }, + // Init events + var th = this; + addEvent(textarea, 'keydown', function (e) { + return th.onKeyPress(e, window.HTMLElement ? 'down' : 'press') + }); + addEvent(textarea, 'keypress', function (e) { + return th.onKeyPress(e, 'press') + }); + }, - // Insert poster name or poster quotes to the text - onclickPoster: function(name, post_id) { - var sel = this.getSelection()[0]; - if (sel) { - this.quoter = name; - this.qouted_pid = post_id; - this.quoterText = sel; - this.insertTag('_quoter'); - } else { - this.insertAtCursor("[b]" + name + '[/b], '); - } - return false; - }, + // Insert poster name or poster quotes to the text + onclickPoster: function (name, post_id) { + var sel = this.getSelection()[0]; + if (sel) { + this.quoter = name; + this.qouted_pid = post_id; + this.quoterText = sel; + this.insertTag('_quoter'); + } else { + this.insertAtCursor("[b]" + name + '[/b], '); + } + return false; + }, - // Quote selected text - onclickQuoteSel: function() { - var sel = this.getSelection()[0]; - if (sel) { - this.insertAtCursor('[quote]' + sel + '[/quote]\n'); - } - else { - alert('Вы не выбрали текст'); - } - return false; - }, + // Quote selected text + onclickQuoteSel: function () { + var sel = this.getSelection()[0]; + if (sel) { + this.insertAtCursor('[quote]' + sel + '[/quote]\n'); + } + else { + alert('Вы не выбрали текст'); + } + return false; + }, - // Quote selected text - emoticon: function(em) { - if (em) { - this.insertAtCursor(' ' + em + ' '); - } - else { - return false; - } - return false; - }, + // Quote selected text + emoticon: function (em) { + if (em) { + this.insertAtCursor(' ' + em + ' '); + } + else { + return false; + } + return false; + }, - // Return current selection and range (if exists) - getSelection: function() { - var w = window; - var text = '', range; - if (w.getSelection) { - text = w.getSelection(); - } else { - return [null, null]; - } - if (text == '') text = this.stext; - text = ""+text; - text = text.replace("/^\s+|\s+$/g", ""); - return [text, range]; - }, + // Return current selection and range (if exists) + getSelection: function () { + var w = window; + var text = '', range; + if (w.getSelection) { + text = w.getSelection(); + } else { + return [null, null]; + } + if (text == '') text = this.stext; + text = "" + text; + text = text.replace("/^\s+|\s+$/g", ""); + return [text, range]; + }, - // Insert string at cursor position of textarea - insertAtCursor: function(text) { - // Focus is placed to textarea - var t = this.textarea; - t.focus(); - // Insert the string - if (document.selection && document.selection.createRange) { - var r = document.selection.createRange(); - if (!this.replaceOnInsert) r.collapse(); - r.text = text; - } else if (t.setSelectionRange) { - var start = this.replaceOnInsert? t.selectionStart : t.selectionEnd; - var end = t.selectionEnd; - var sel1 = t.value.substr(0, start); - var sel2 = t.value.substr(end); - t.value = sel1 + text + sel2; - t.setSelectionRange(start+text.length, start+text.length); - } else{ - t.value += text; - } - // For IE - setTimeout(function() { t.focus() }, 100); - }, + // Insert string at cursor position of textarea + insertAtCursor: function (text) { + // Focus is placed to textarea + var t = this.textarea; + t.focus(); + // Insert the string + if (document.selection && document.selection.createRange) { + var r = document.selection.createRange(); + if (!this.replaceOnInsert) r.collapse(); + r.text = text; + } else if (t.setSelectionRange) { + var start = this.replaceOnInsert ? t.selectionStart : t.selectionEnd; + var end = t.selectionEnd; + var sel1 = t.value.substr(0, start); + var sel2 = t.value.substr(end); + t.value = sel1 + text + sel2; + t.setSelectionRange(start + text.length, start + text.length); + } else { + t.value += text; + } + // For IE + setTimeout(function () { + t.focus() + }, 100); + }, - // Surround piece of textarea text with tags - surround: function(open, close, fTrans) { - var t = this.textarea; - t.focus(); - if (!fTrans) fTrans = function(t) { return t; }; + // Surround piece of textarea text with tags + surround: function (open, close, fTrans) { + var t = this.textarea; + t.focus(); + if (!fTrans) fTrans = function (t) { + return t; + }; - var rt = this.getSelection(); - var text = rt[0]; - var range = rt[1]; - if (text == null) return false; + var rt = this.getSelection(); + var text = rt[0]; + var range = rt[1]; + if (text == null) return false; - var notEmpty = text != null && text != ''; + var notEmpty = text != null && text != ''; - // Surround - if (range) { - var notEmpty = text != null && text != ''; - var newText = open + fTrans(text) + (close? close : ''); - range.text = newText; - range.collapse(); - if (text != '') { - // Correction for stupid IE: \r for moveStart is 0 character - var delta = 0; - for (var i=0; i= 0) text = "\n" + text + "\n"; - return text; - } + _prepareMultiline: function (text) { + text = text.replace(/\s+$/, ''); + text = text.replace(/^([ \t]*\r?\n)+/, ''); + if (text.indexOf("\n") >= 0) text = "\n" + text + "\n"; + return text; + } }; // Emulation of innerText for Mozilla. if (window.HTMLElement && window.HTMLElement.prototype.__defineSetter__) { - HTMLElement.prototype.__defineSetter__("innerText", function (sText) { - this.innerHTML = sText.replace(/\&/g, "&").replace(//g, ">"); - }); - HTMLElement.prototype.__defineGetter__("innerText", function () { - var r = this.ownerDocument.createRange(); - r.selectNodeContents(this); - return r.toString(); - }); + HTMLElement.prototype.__defineSetter__("innerText", function (sText) { + this.innerHTML = sText.replace(/\&/g, "&").replace(//g, ">"); + }); + HTMLElement.prototype.__defineGetter__("innerText", function () { + var r = this.ownerDocument.createRange(); + r.selectNodeContents(this); + return r.toString(); + }); } function AddSelectedText(BBOpen, BBClose) { - if (document.post.message.caretPos) document.post.message.caretPos.text = BBOpen + document.post.message.caretPos.text + BBClose; - else document.post.message.value += BBOpen + BBClose; - document.post.message.focus() + if (document.post.message.caretPos) document.post.message.caretPos.text = BBOpen + document.post.message.caretPos.text + BBClose; + else document.post.message.value += BBOpen + BBClose; + document.post.message.focus() } -function InsertBBCode(BBcode) -{ - AddSelectedText('[' + BBcode + ']','[/' + BBcode + ']'); +function InsertBBCode(BBcode) { + AddSelectedText('[' + BBcode + ']', '[/' + BBcode + ']'); } function storeCaret(textEl) { - if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate(); + if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate(); } -function initPostBBCode(context) -{ - $('span.post-hr', context).html('
'); - initCodes(context); - initQuotes(context); - initExternalLinks(context); - initPostImages(context); - initSpoilers(context); - initMedia(context); +function initPostBBCode(context) { + $('span.post-hr', context).html('
'); + initCodes(context); + initQuotes(context); + initExternalLinks(context); + initPostImages(context); + initSpoilers(context); + initMedia(context); } -function initCodes(context) -{ - $('div.c-body', context).each(function(){ - var $c = $(this); - $c.before('
'+bbl['code']+':
'); - }); +function initCodes(context) { + $('div.c-body', context).each(function () { + var $c = $(this); + $c.before('
' + bbl['code'] + ':
'); + }); } -function initQuotes(context) -{ - $('div.q', context).each(function(){ - var $q = $(this); - var name = $(this).attr('head'); - var q_title = (name ? ''+name+' '+bbl['wrote']+':' : ''+bbl['quote']+''); - if ( quoted_pid = $q.children('u.q-post:first').text() ) { - var on_this_page = $('#post_'+quoted_pid).length; - var href = (on_this_page) ? '#'+ quoted_pid : './viewtopic.php?p='+ quoted_pid +'#'+ quoted_pid; - q_title += ' '; - } - $q.before('
'+ q_title +'
'); - }); +function initQuotes(context) { + $('div.q', context).each(function () { + var $q = $(this); + var name = $(this).attr('head'); + var q_title = (name ? '' + name + ' ' + bbl['wrote'] + ':' : '' + bbl['quote'] + ''); + if (quoted_pid = $q.children('u.q-post:first').text()) { + var on_this_page = $('#post_' + quoted_pid).length; + var href = (on_this_page) ? '#' + quoted_pid : './viewtopic.php?p=' + quoted_pid + '#' + quoted_pid; + q_title += ' '; + } + $q.before('
' + q_title + '
'); + }); } -function initPostImages(context) -{ - if (hidePostImg) return; - var $in_spoilers = $('div.sp-body var.postImg', context); - $('var.postImg', context).not($in_spoilers).each(function(){ - var $v = $(this); - var src = $v.attr('title'); - var $img = $('pic'); - $img = fixPostImage($img); - var maxW = ($v.hasClass('postImgAligned')) ? postImgAligned_MaxWidth : postImg_MaxWidth; - $img.bind('click', function(){ return imgFit(this, maxW); }); - if (user.opt_js.i_aft_l) { - $('#preload').append($img); - var loading_icon = ''; - $v.html(loading_icon); - if ($.browser.msie) { - $v.after(''); - } - $img.one('load', function(){ - imgFit(this, maxW); - $v.empty().append(this); - }); - } - else { - $img.one('load', function(){ imgFit(this, maxW) }); - $v.empty().append($img); - if ($.browser.msie) { - $v.after(''); - } - } - }); +function initPostImages(context) { + if (hidePostImg) return; + var $in_spoilers = $('div.sp-body var.postImg', context); + $('var.postImg', context).not($in_spoilers).each(function () { + var $v = $(this); + var src = $v.attr('title'); + var $img = $('pic'); + $img = fixPostImage($img); + var maxW = ($v.hasClass('postImgAligned')) ? postImgAligned_MaxWidth : postImg_MaxWidth; + $img.bind('click', function () { + return imgFit(this, maxW); + }); + if (user.opt_js.i_aft_l) { + $('#preload').append($img); + var loading_icon = ''; + $v.html(loading_icon); + if ($.browser.msie) { + $v.after(''); + } + $img.one('load', function () { + imgFit(this, maxW); + $v.empty().append(this); + }); + } + else { + $img.one('load', function () { + imgFit(this, maxW) + }); + $v.empty().append($img); + if ($.browser.msie) { + $v.after(''); + } + } + }); } -function initSpoilers(context) -{ - $('div.sp-body', context).each(function(){ - var $sp_body = $(this); - var name = $.trim(this.title) || ''+bbl['spoiler_head']+''; - this.title = ''; - var $sp_head = $('
'+ name +'
'); - $sp_head.insertBefore($sp_body).click(function(e){ - if (!$sp_body.hasClass('inited')) { - initPostImages($sp_body); - var $sp_fold_btn = $('
['+bbl['spoiler_close']+']
').click(function(){ - $.scrollTo($sp_head, { duration:200, axis:'y', offset:-200 }); - $sp_head.click().animate({opacity: 0.1}, 500).animate({opacity: 1}, 700); - }); - $sp_body.prepend('
').append('
').append($sp_fold_btn).addClass('inited'); - } - if (e.shiftKey) { - e.stopPropagation(); - e.shiftKey = false; - var fold = $(this).hasClass('unfolded'); - $('div.sp-head', $($sp_body.parents('td')[0])).filter( function(){ return $(this).hasClass('unfolded') ? fold : !fold } ).click(); - } - else { - $(this).toggleClass('unfolded'); - $sp_body.slideToggle('fast'); - } - }); - }); +function initSpoilers(context) { + $('div.sp-body', context).each(function () { + var $sp_body = $(this); + var name = $.trim(this.title) || '' + bbl['spoiler_head'] + ''; + this.title = ''; + var $sp_head = $('
' + name + '
'); + $sp_head.insertBefore($sp_body).click(function (e) { + if (!$sp_body.hasClass('inited')) { + initPostImages($sp_body); + var $sp_fold_btn = $('
[' + bbl['spoiler_close'] + ']
').click(function () { + $.scrollTo($sp_head, {duration: 200, axis: 'y', offset: -200}); + $sp_head.click().animate({opacity: 0.1}, 500).animate({opacity: 1}, 700); + }); + $sp_body.prepend('
').append('
').append($sp_fold_btn).addClass('inited'); + } + if (e.shiftKey) { + e.stopPropagation(); + e.shiftKey = false; + var fold = $(this).hasClass('unfolded'); + $('div.sp-head', $($sp_body.parents('td')[0])).filter(function () { + return $(this).hasClass('unfolded') ? fold : !fold + }).click(); + } + else { + $(this).toggleClass('unfolded'); + $sp_body.slideToggle('fast'); + } + }); + }); } -function initExternalLinks(context) -{ - var context = context || 'body'; - if (ExternalLinks_InNewWindow) { - $("a.postLink:not([href*='"+ window.location.hostname +"/'])", context).attr({ target: '_blank' }); - } +function initExternalLinks(context) { + var context = context || 'body'; + if (ExternalLinks_InNewWindow) { + $("a.postLink:not([href*='" + window.location.hostname + "/'])", context).attr({target: '_blank'}); + } } -function fixPostImage ($img) -{ - var banned_image_hosts = /imagebanana|hidebehind/i; - var src = $img[0].src; - if (src.match(banned_image_hosts)) { - $img.wrap('').attr({ src: ""+bb_url+"styles/images/smiles/tr_oops.gif", title: ""+bbl['scr_rules']+"" }); - } - return $img; +function fixPostImage($img) { + var banned_image_hosts = /imagebanana|hidebehind/i; + var src = $img[0].src; + if (src.match(banned_image_hosts)) { + $img.wrap('').attr({ + src: "" + bb_url + "styles/images/smiles/tr_oops.gif", + title: "" + bbl['scr_rules'] + "" + }); + } + return $img; } -function initMedia(context) -{ - var apostLink = $('a.postLink', context); - for (var i = 0; i < apostLink.length; i++) { - var link = apostLink[i]; - if (typeof link.href != 'string') { - continue; - } - if (/^http(?:s|):\/\/www.youtube.com\/watch\?(.*)?(&?v=([a-z0-9\-_]+))(.*)?|http:\/\/youtu.be\/.+/i.test(link.href)) { - var a = document.createElement('span'); - a.className = 'YTLink'; - a.innerHTML = ''; - window.addEvent(a, 'click', function (e) { - var vhref = e.target.nextSibling.href.replace(/^http(?:s|):\/\/www.youtube.com\/watch\?(.*)?(&?v=([a-z0-9\-_]+))(.*)?|http:\/\/youtu.be\//ig, "http://www.youtube.com/embed/$3"); - var text = e.target.nextSibling.innerText != "" ? e.target.nextSibling.innerText : e.target.nextSibling.href; - $('#Panel_youtube').remove(); - ypanel('youtube', { - title: '' + text + '', - resizing: 0, - width: 862, - height: 550, - content: '' - }); - }); - link.parentNode.insertBefore(a, link); - a.appendChild(link); - } - } +function initMedia(context) { + var apostLink = $('a.postLink', context); + for (var i = 0; i < apostLink.length; i++) { + var link = apostLink[i]; + if (typeof link.href != 'string') { + continue; + } + if (/^http(?:s|):\/\/www.youtube.com\/watch\?(.*)?(&?v=([a-z0-9\-_]+))(.*)?|http:\/\/youtu.be\/.+/i.test(link.href)) { + var a = document.createElement('span'); + a.className = 'YTLink'; + a.innerHTML = ''; + window.addEvent(a, 'click', function (e) { + var vhref = e.target.nextSibling.href.replace(/^http(?:s|):\/\/www.youtube.com\/watch\?(.*)?(&?v=([a-z0-9\-_]+))(.*)?|http:\/\/youtu.be\//ig, "http://www.youtube.com/embed/$3"); + var text = e.target.nextSibling.innerText != "" ? e.target.nextSibling.innerText : e.target.nextSibling.href; + $('#Panel_youtube').remove(); + ypanel('youtube', { + title: '' + text + '', + resizing: 0, + width: 862, + height: 550, + content: '' + }); + }); + link.parentNode.insertBefore(a, link); + a.appendChild(link); + } + } } -$(document).ready(function(){ - $('div.post_wrap, div.signature').each(function(){ initPostBBCode( $(this) ) }); -}); \ No newline at end of file +$(document).ready(function () { + $('div.post_wrap, div.signature').each(function () { + initPostBBCode($(this)) + }); +}); diff --git a/styles/js/main.js b/styles/js/main.js index 243832fa6..5ed9224a9 100644 --- a/styles/js/main.js +++ b/styles/js/main.js @@ -1,98 +1,98 @@ function $p() { - var elements = []; - for (var i = 0; i < arguments.length; i++) { - var element = arguments[i]; - if (typeof element == 'string') - element = document.getElementById(element); - if (arguments.length == 1) - return element; - elements.push(element); - } - return elements; + var elements = []; + for (var i = 0; i < arguments.length; i++) { + var element = arguments[i]; + if (typeof element == 'string') + element = document.getElementById(element); + if (arguments.length == 1) + return element; + elements.push(element); + } + return elements; } function addEvent(obj, type, fn) { - if (obj.addEventListener) { - obj.addEventListener(type, fn, false); - EventCache.add(obj, type, fn); - } - else if (obj.attachEvent) { - obj["e" + type + fn] = fn; - obj[type + fn] = function () { - obj["e" + type + fn](window.event); - }; - obj.attachEvent("on" + type, obj[type + fn]); - EventCache.add(obj, type, fn); - } - else { - obj["on" + type] = obj["e" + type + fn]; - } + if (obj.addEventListener) { + obj.addEventListener(type, fn, false); + EventCache.add(obj, type, fn); + } + else if (obj.attachEvent) { + obj["e" + type + fn] = fn; + obj[type + fn] = function () { + obj["e" + type + fn](window.event); + }; + obj.attachEvent("on" + type, obj[type + fn]); + EventCache.add(obj, type, fn); + } + else { + obj["on" + type] = obj["e" + type + fn]; + } } var EventCache = function () { - var listEvents = []; - return { - listEvents: listEvents, - add: function (node, sEventName, fHandler) { - listEvents.push(arguments); - }, - flush: function () { - var i, item; - for (i = listEvents.length - 1; i >= 0; i = i - 1) { - item = listEvents[i]; - if (item[0].removeEventListener) { - item[0].removeEventListener(item[1], item[2], item[3]); - } - if (item[1].substring(0, 2) != "on") { - item[1] = "on" + item[1]; - } - if (item[0].detachEvent) { - item[0].detachEvent(item[1], item[2]); - } - item[0][item[1]] = null; - } - } - }; + var listEvents = []; + return { + listEvents: listEvents, + add: function (node, sEventName, fHandler) { + listEvents.push(arguments); + }, + flush: function () { + var i, item; + for (i = listEvents.length - 1; i >= 0; i = i - 1) { + item = listEvents[i]; + if (item[0].removeEventListener) { + item[0].removeEventListener(item[1], item[2], item[3]); + } + if (item[1].substring(0, 2) != "on") { + item[1] = "on" + item[1]; + } + if (item[0].detachEvent) { + item[0].detachEvent(item[1], item[2]); + } + item[0][item[1]] = null; + } + } + }; }(); if (document.all) { - addEvent(window, 'unload', EventCache.flush); + addEvent(window, 'unload', EventCache.flush); } function imgFit(img, maxW) { - img.title = 'Размеры изображения: ' + img.width + ' x ' + img.height; - if (typeof(img.naturalHeight) == 'undefined') { - img.naturalHeight = img.height; - img.naturalWidth = img.width; - } - if (img.width > maxW) { - img.height = Math.round((maxW / img.width) * img.height); - img.width = maxW; - img.title = 'Нажмите на изображение, чтобы посмотреть его в полный размер'; - img.style.cursor = 'move'; - return false; - } - else if (img.width == maxW && img.width < img.naturalWidth) { - img.height = img.naturalHeight; - img.width = img.naturalWidth; - img.title = 'Размеры изображения: ' + img.naturalWidth + ' x ' + img.naturalHeight; - return false; - } - else { - return true; - } + img.title = 'Размеры изображения: ' + img.width + ' x ' + img.height; + if (typeof(img.naturalHeight) == 'undefined') { + img.naturalHeight = img.height; + img.naturalWidth = img.width; + } + if (img.width > maxW) { + img.height = Math.round((maxW / img.width) * img.height); + img.width = maxW; + img.title = 'Нажмите на изображение, чтобы посмотреть его в полный размер'; + img.style.cursor = 'move'; + return false; + } + else if (img.width == maxW && img.width < img.naturalWidth) { + img.height = img.naturalHeight; + img.width = img.naturalWidth; + img.title = 'Размеры изображения: ' + img.naturalWidth + ' x ' + img.naturalHeight; + return false; + } + else { + return true; + } } function toggle_block(id) { - var el = document.getElementById(id); - el.style.display = (el.style.display == 'none') ? '' : 'none'; + var el = document.getElementById(id); + el.style.display = (el.style.display == 'none') ? '' : 'none'; } function toggle_disabled(id, val) { - document.getElementById(id).disabled = (val) ? 0 : 1; + document.getElementById(id).disabled = (val) ? 0 : 1; } function rand(min, max) { - return min + Math.floor((max - min + 1) * Math.random()); + return min + Math.floor((max - min + 1) * Math.random()); } // Cookie functions @@ -107,21 +107,21 @@ function rand(min, max) { * secure transmission */ function setCookie(name, value, days, path, domain, secure) { - if (days != 'SESSION') { - var date = new Date(); - days = days || 365; - date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); - var expires = date.toGMTString(); - } else { - var expires = ''; - } + if (days != 'SESSION') { + var date = new Date(); + days = days || 365; + date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); + var expires = date.toGMTString(); + } else { + var expires = ''; + } - document.cookie = - name + '=' + encodeURI(value) - + ((expires) ? '; expires=' + expires : '') - + ((path) ? '; path=' + path : ((cookiePath) ? '; path=' + cookiePath : '')) - + ((domain) ? '; domain=' + domain : ((cookieDomain) ? '; domain=' + cookieDomain : '')) - + ((secure) ? '; secure' : ((cookieSecure) ? '; secure' : '')); + document.cookie = + name + '=' + encodeURI(value) + + ((expires) ? '; expires=' + expires : '') + + ((path) ? '; path=' + path : ((cookiePath) ? '; path=' + cookiePath : '')) + + ((domain) ? '; domain=' + domain : ((cookieDomain) ? '; domain=' + cookieDomain : '')) + + ((secure) ? '; secure' : ((cookieSecure) ? '; secure' : '')); } /** @@ -129,8 +129,8 @@ function setCookie(name, value, days, path, domain, secure) { * or null if cookie does not exist. */ function getCookie(name) { - var c, RE = new RegExp('(^|;)\\s*' + name + '\\s*=\\s*([^\\s;]+)', 'g'); - return (c = RE.exec(document.cookie)) ? c[2] : null; + var c, RE = new RegExp('(^|;)\\s*' + name + '\\s*=\\s*([^\\s;]+)', 'g'); + return (c = RE.exec(document.cookie)) ? c[2] : null; } /** @@ -139,341 +139,341 @@ function getCookie(name) { * [domain] domain of the cookie (must be same as domain used to create cookie) */ function deleteCookie(name, path, domain) { - setCookie(name, '', -1, path, domain); + setCookie(name, '', -1, path, domain); } // Menus var Menu = { - hideSpeed: 'fast', - offsetCorrection_X: -4, - offsetCorrection_Y: 2, + hideSpeed: 'fast', + offsetCorrection_X: -4, + offsetCorrection_Y: 2, - activeMenuId: null, // currently opened menu (from previous click) - clickedMenuId: null, // menu to show up - $root: null, // root element for menu with "href = '#clickedMenuId'" - $menu: null, // clicked menu - positioningType: null, // reserved - outsideClickWatch: false, // prevent multiple $(document).click binding + activeMenuId: null, // currently opened menu (from previous click) + clickedMenuId: null, // menu to show up + $root: null, // root element for menu with "href = '#clickedMenuId'" + $menu: null, // clicked menu + positioningType: null, // reserved + outsideClickWatch: false, // prevent multiple $(document).click binding - clicked: function ($root) { - $root.blur(); - this.clickedMenuId = this.getMenuId($root); - this.$menu = $(this.clickedMenuId); - this.$root = $root; - this.toggle(); - }, + clicked: function ($root) { + $root.blur(); + this.clickedMenuId = this.getMenuId($root); + this.$menu = $(this.clickedMenuId); + this.$root = $root; + this.toggle(); + }, - hovered: function ($root) { - if (this.activeMenuId && this.activeMenuId !== this.getMenuId($root)) { - this.clicked($root); - } - }, + hovered: function ($root) { + if (this.activeMenuId && this.activeMenuId !== this.getMenuId($root)) { + this.clicked($root); + } + }, - unhovered: function ($root) { - }, + unhovered: function ($root) { + }, - getMenuId: function ($el) { - var href = $el.attr('href'); - return href.substr(href.indexOf('#')); - }, + getMenuId: function ($el) { + var href = $el.attr('href'); + return href.substr(href.indexOf('#')); + }, - setLocation: function () { - var CSS = this.$root.offset(); - CSS.top += this.$root.height() + this.offsetCorrection_Y; - var curTop = parseInt(CSS.top); - var tCorner = $(document).scrollTop() + $(window).height() - 20; - var maxVisibleTop = Math.min(curTop, Math.max(0, tCorner - this.$menu.height())); - if (curTop != maxVisibleTop) { - CSS.top = maxVisibleTop; - } - CSS.left += this.offsetCorrection_X; - var curLeft = parseInt(CSS.left); - var rCorner = $(document).scrollLeft() + $(window).width() - 6; - var maxVisibleLeft = Math.min(curLeft, Math.max(0, rCorner - this.$menu.width())); - if (curLeft != maxVisibleLeft) { - CSS.left = maxVisibleLeft; - } - this.$menu.css(CSS); - }, + setLocation: function () { + var CSS = this.$root.offset(); + CSS.top += this.$root.height() + this.offsetCorrection_Y; + var curTop = parseInt(CSS.top); + var tCorner = $(document).scrollTop() + $(window).height() - 20; + var maxVisibleTop = Math.min(curTop, Math.max(0, tCorner - this.$menu.height())); + if (curTop != maxVisibleTop) { + CSS.top = maxVisibleTop; + } + CSS.left += this.offsetCorrection_X; + var curLeft = parseInt(CSS.left); + var rCorner = $(document).scrollLeft() + $(window).width() - 6; + var maxVisibleLeft = Math.min(curLeft, Math.max(0, rCorner - this.$menu.width())); + if (curLeft != maxVisibleLeft) { + CSS.left = maxVisibleLeft; + } + this.$menu.css(CSS); + }, - fixLocation: function () { - var $menu = this.$menu; - var curLeft = parseInt($menu.css('left')); - var rCorner = $(document).scrollLeft() + $(window).width() - 6; - var maxVisibleLeft = Math.min(curLeft, Math.max(0, rCorner - $menu.width())); - if (curLeft != maxVisibleLeft) { - $menu.css('left', maxVisibleLeft); - } - var curTop = parseInt($menu.css('top')); - var tCorner = $(document).scrollTop() + $(window).height() - 20; - var maxVisibleTop = Math.min(curTop, Math.max(0, tCorner - $menu.height())); - if (curTop != maxVisibleTop) { - $menu.css('top', maxVisibleTop); - } - }, + fixLocation: function () { + var $menu = this.$menu; + var curLeft = parseInt($menu.css('left')); + var rCorner = $(document).scrollLeft() + $(window).width() - 6; + var maxVisibleLeft = Math.min(curLeft, Math.max(0, rCorner - $menu.width())); + if (curLeft != maxVisibleLeft) { + $menu.css('left', maxVisibleLeft); + } + var curTop = parseInt($menu.css('top')); + var tCorner = $(document).scrollTop() + $(window).height() - 20; + var maxVisibleTop = Math.min(curTop, Math.max(0, tCorner - $menu.height())); + if (curTop != maxVisibleTop) { + $menu.css('top', maxVisibleTop); + } + }, - toggle: function () { - if (this.activeMenuId && this.activeMenuId !== this.clickedMenuId) { - $(this.activeMenuId).hide(this.hideSpeed); - } - // toggle clicked menu - if (this.$menu.is(':visible')) { - this.$menu.hide(this.hideSpeed); - this.activeMenuId = null; - } else { - this.showClickedMenu(); - if (!this.outsideClickWatch) { - $(document).one('mousedown', function (e) { - Menu.hideClickWatcher(e); - }); - this.outsideClickWatch = true; - } - } - }, + toggle: function () { + if (this.activeMenuId && this.activeMenuId !== this.clickedMenuId) { + $(this.activeMenuId).hide(this.hideSpeed); + } + // toggle clicked menu + if (this.$menu.is(':visible')) { + this.$menu.hide(this.hideSpeed); + this.activeMenuId = null; + } else { + this.showClickedMenu(); + if (!this.outsideClickWatch) { + $(document).one('mousedown', function (e) { + Menu.hideClickWatcher(e); + }); + this.outsideClickWatch = true; + } + } + }, - showClickedMenu: function () { - this.setLocation(); - this.$menu.css({display: 'block'}); - // this.fixLocation(); - this.activeMenuId = this.clickedMenuId; - }, + showClickedMenu: function () { + this.setLocation(); + this.$menu.css({display: 'block'}); + // this.fixLocation(); + this.activeMenuId = this.clickedMenuId; + }, - // hide if clicked outside of menu - hideClickWatcher: function (e) { - this.outsideClickWatch = false; - this.hide(e); - }, + // hide if clicked outside of menu + hideClickWatcher: function (e) { + this.outsideClickWatch = false; + this.hide(e); + }, - hide: function (e) { - if (this.$menu) { - this.$menu.hide(this.hideSpeed); - } - this.activeMenuId = this.clickedMenuId = this.$menu = null; - } + hide: function (e) { + if (this.$menu) { + this.$menu.hide(this.hideSpeed); + } + this.activeMenuId = this.clickedMenuId = this.$menu = null; + } }; $(document).ready(function () { - // Menus - $('body').append($('div.menu-sub')); - $('a.menu-root') - .click( - function (e) { - e.preventDefault(); - Menu.clicked($(this)); - return false; - }) - .hover( - function () { - Menu.hovered($(this)); - return false; - }, - function () { - Menu.unhovered($(this)); - return false; - } - ) - ; - $('div.menu-sub') - .mousedown(function (e) { - e.stopPropagation(); - }) - .find('a') - .click(function (e) { - Menu.hide(e); - }) - ; - // Input hints - $('input') - .filter('.hint').one('focus', function () { - $(this).val('').removeClass('hint'); - }) - .end() - .filter('.error').one('focus', function () { - $(this).removeClass('error'); - }) - ; + // Menus + $('body').append($('div.menu-sub')); + $('a.menu-root') + .click( + function (e) { + e.preventDefault(); + Menu.clicked($(this)); + return false; + }) + .hover( + function () { + Menu.hovered($(this)); + return false; + }, + function () { + Menu.unhovered($(this)); + return false; + } + ) + ; + $('div.menu-sub') + .mousedown(function (e) { + e.stopPropagation(); + }) + .find('a') + .click(function (e) { + Menu.hide(e); + }) + ; + // Input hints + $('input') + .filter('.hint').one('focus', function () { + $(this).val('').removeClass('hint'); + }) + .end() + .filter('.error').one('focus', function () { + $(this).removeClass('error'); + }) + ; }); // // Ajax // function Ajax(handlerURL, requestType, dataType) { - this.url = handlerURL; - this.type = requestType; - this.dataType = dataType; - this.errors = {}; + this.url = handlerURL; + this.type = requestType; + this.dataType = dataType; + this.errors = {}; } Ajax.prototype = { - init: {}, // init functions (run before submit, after triggering ajax event) - callback: {}, // callback functions (response handlers) - state: {}, // current action state - request: {}, // request data - params: {}, // action params, format: ajax.params[ElementID] = { param: "val" ... } - form_token: '', + init: {}, // init functions (run before submit, after triggering ajax event) + callback: {}, // callback functions (response handlers) + state: {}, // current action state + request: {}, // request data + params: {}, // action params, format: ajax.params[ElementID] = { param: "val" ... } + form_token: '', - exec: function (request) { - this.request[request.action] = request; - request['form_token'] = this.form_token; - $.ajax({ - url: this.url, - type: this.type, - dataType: this.dataType, - data: request, - success: ajax.success, - error: ajax.error - }); - }, + exec: function (request) { + this.request[request.action] = request; + request['form_token'] = this.form_token; + $.ajax({ + url: this.url, + type: this.type, + dataType: this.dataType, + data: request, + success: ajax.success, + error: ajax.error + }); + }, - success: function (response) { - var action = response.action; - // raw_output normally might contain only error messages (if php.ini.display_errors == 1) - if (response.raw_output) { - $('body').prepend(response.raw_output); - } - if (response.sql_log) { - $('#sqlLog').prepend(response.sql_log + '
'); - fixSqlLog(); - } - if (response.update_ids) { - for (id in response.update_ids) { - $('#' + id).html(response.update_ids[id]); - } - } - if (response.prompt_password) { - var user_password = prompt('Для доступа к данной функции, пожалуйста, введите свой пароль', ''); - if (user_password) { - var req = ajax.request[action]; - req.user_password = user_password; - ajax.exec(req); - } - else { - ajax.clearActionState(action); - ajax.showErrorMsg('Введен неверный пароль'); - } - } - else if (response.prompt_confirm) { - if (window.confirm(response.confirm_msg)) { - var req = ajax.request[action]; - req.confirmed = 1; - ajax.exec(req); - } - else { - ajax.clearActionState(action); - } - } - else if (response.error_code) { - ajax.showErrorMsg(response.error_msg); - $('.loading-1').removeClass('loading-1').html('error'); - } - else { - ajax.callback[action](response); - ajax.clearActionState(action); - } - }, + success: function (response) { + var action = response.action; + // raw_output normally might contain only error messages (if php.ini.display_errors == 1) + if (response.raw_output) { + $('body').prepend(response.raw_output); + } + if (response.sql_log) { + $('#sqlLog').prepend(response.sql_log + '
'); + fixSqlLog(); + } + if (response.update_ids) { + for (id in response.update_ids) { + $('#' + id).html(response.update_ids[id]); + } + } + if (response.prompt_password) { + var user_password = prompt('Для доступа к данной функции, пожалуйста, введите свой пароль', ''); + if (user_password) { + var req = ajax.request[action]; + req.user_password = user_password; + ajax.exec(req); + } + else { + ajax.clearActionState(action); + ajax.showErrorMsg('Введен неверный пароль'); + } + } + else if (response.prompt_confirm) { + if (window.confirm(response.confirm_msg)) { + var req = ajax.request[action]; + req.confirmed = 1; + ajax.exec(req); + } + else { + ajax.clearActionState(action); + } + } + else if (response.error_code) { + ajax.showErrorMsg(response.error_msg); + $('.loading-1').removeClass('loading-1').html('error'); + } + else { + ajax.callback[action](response); + ajax.clearActionState(action); + } + }, - error: function (xml, desc) { - }, + error: function (xml, desc) { + }, - clearActionState: function (action) { - ajax.state[action] = ajax.request[action] = ''; - }, + clearActionState: function (action) { + ajax.state[action] = ajax.request[action] = ''; + }, - showErrorMsg: function (msg) { - alert(msg); - }, + showErrorMsg: function (msg) { + alert(msg); + }, - callInitFn: function (event) { - event.stopPropagation(); - var params = ajax.params[$(this).attr('id')]; - var action = params.action; - if (ajax.state[action] == 'readyToSubmit' || ajax.state[action] == 'error') { - return false; - } else { - ajax.state[action] = 'readyToSubmit'; - } - ajax.init[action](params); - }, + callInitFn: function (event) { + event.stopPropagation(); + var params = ajax.params[$(this).attr('id')]; + var action = params.action; + if (ajax.state[action] == 'readyToSubmit' || ajax.state[action] == 'error') { + return false; + } else { + ajax.state[action] = 'readyToSubmit'; + } + ajax.init[action](params); + }, - setStatusBoxPosition: function ($el) { - var newTop = $(document).scrollTop(); - var rCorner = $(document).scrollLeft() + $(window).width() - 8; - var newLeft = Math.max(0, rCorner - $el.width()); - $el.css({top: newTop, left: newLeft}); - }, + setStatusBoxPosition: function ($el) { + var newTop = $(document).scrollTop(); + var rCorner = $(document).scrollLeft() + $(window).width() - 8; + var newLeft = Math.max(0, rCorner - $el.width()); + $el.css({top: newTop, left: newLeft}); + }, - makeEditable: function (rootElementId, editableType) { - var $root = $('#' + rootElementId); - var $editable = $('.editable', $root); - var inputsHtml = $('#editable-tpl-' + editableType).html(); - $editable.hide().after(inputsHtml); - var $inputs = $('.editable-inputs', $root); - if (editableType == 'input' || editableType == 'textarea') { - $('.editable-value', $inputs).val($.trim($editable.text())); - } - $('input.editable-submit', $inputs).click(function () { - var params = ajax.params[rootElementId]; - var $val = $('.editable-value', '#' + rootElementId); - params.value = ($val.size() == 1) ? $val.val() : $val.filter(':checked').val(); - params.submit = true; - ajax.init[params.action](params); - }); - $('input.editable-cancel', $inputs).click(function () { - ajax.restoreEditable(rootElementId); - }); - $inputs.show().find('.editable-value').focus(); - $root.removeClass('editable-container'); - }, + makeEditable: function (rootElementId, editableType) { + var $root = $('#' + rootElementId); + var $editable = $('.editable', $root); + var inputsHtml = $('#editable-tpl-' + editableType).html(); + $editable.hide().after(inputsHtml); + var $inputs = $('.editable-inputs', $root); + if (editableType == 'input' || editableType == 'textarea') { + $('.editable-value', $inputs).val($.trim($editable.text())); + } + $('input.editable-submit', $inputs).click(function () { + var params = ajax.params[rootElementId]; + var $val = $('.editable-value', '#' + rootElementId); + params.value = ($val.size() == 1) ? $val.val() : $val.filter(':checked').val(); + params.submit = true; + ajax.init[params.action](params); + }); + $('input.editable-cancel', $inputs).click(function () { + ajax.restoreEditable(rootElementId); + }); + $inputs.show().find('.editable-value').focus(); + $root.removeClass('editable-container'); + }, - restoreEditable: function (rootElementId, newValue) { - var $root = $('#' + rootElementId); - var $editable = $('.editable', $root); - $('.editable-inputs', $root).remove(); - if (newValue) { - $editable.text(newValue); - } - $editable.show(); - ajax.clearActionState(ajax.params[rootElementId].action); - ajax.params[rootElementId].submit = false; - $root.addClass('editable-container'); - } + restoreEditable: function (rootElementId, newValue) { + var $root = $('#' + rootElementId); + var $editable = $('.editable', $root); + $('.editable-inputs', $root).remove(); + if (newValue) { + $editable.text(newValue); + } + $editable.show(); + ajax.clearActionState(ajax.params[rootElementId].action); + ajax.params[rootElementId].submit = false; + $root.addClass('editable-container'); + } }; $(document).ready(function () { - // Setup ajax-loading box - $("#ajax-loading").ajaxStart(function () { - $("#ajax-error").hide(); - $(this).show(); - ajax.setStatusBoxPosition($(this)); - }); - $("#ajax-loading").ajaxStop(function () { - $(this).hide(); - }); + // Setup ajax-loading box + $("#ajax-loading").ajaxStart(function () { + $("#ajax-error").hide(); + $(this).show(); + ajax.setStatusBoxPosition($(this)); + }); + $("#ajax-loading").ajaxStop(function () { + $(this).hide(); + }); - // Setup ajax-error box - $("#ajax-error").ajaxError(function (req, xml) { - var status = xml.status; - var text = xml.statusText; - if (status == 200) { - status = ''; - text = 'неверный формат данных'; - } - $(this).html( - "Ошибка в: " + ajax.url + "
" + status + " " + text + "" - ).show(); - ajax.setStatusBoxPosition($(this)); - }); + // Setup ajax-error box + $("#ajax-error").ajaxError(function (req, xml) { + var status = xml.status; + var text = xml.statusText; + if (status == 200) { + status = ''; + text = 'неверный формат данных'; + } + $(this).html( + "Ошибка в: " + ajax.url + "
" + status + " " + text + "" + ).show(); + ajax.setStatusBoxPosition($(this)); + }); - // Bind ajax events - $('var.ajax-params').each(function () { - var params = $.evalJSON($(this).html()); - params.event = params.event || 'dblclick'; - ajax.params[params.id] = params; - $("#" + params.id).bind(params.event, ajax.callInitFn); - if (params.event == 'click' || params.event == 'dblclick') { - $("#" + params.id).addClass('editable-container'); - } - }); + // Bind ajax events + $('var.ajax-params').each(function () { + var params = $.evalJSON($(this).html()); + params.event = params.event || 'dblclick'; + ajax.params[params.id] = params; + $("#" + params.id).bind(params.event, ajax.callInitFn); + if (params.event == 'click' || params.event == 'dblclick') { + $("#" + params.id).addClass('editable-container'); + } + }); }); /** @@ -481,75 +481,75 @@ $(document).ready(function () { **/ var array_for_rand_pass = ["a", "A", "b", "B", "c", "C", "d", "D", "e", "E", "f", "F", "g", "G", "h", "H", "i", "I", "j", "J", "k", "K", "l", "L", "m", "M", "n", "N", "o", "O", "p", "P", "q", "Q", "r", "R", "s", "S", "t", "T", "u", "U", "v", "V", "w", "W", "x", "X", "y", "Y", "z", "Z", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; var array_rand = function (array) { - var array_length = array.length; - var result = Math.random() * array_length; - return Math.floor(result); + var array_length = array.length; + var result = Math.random() * array_length; + return Math.floor(result); }; var autocomplete = function (noCenter) { - var string_result = ""; // Empty string - for (var i = 1; i <= 8; i++) { - string_result += array_for_rand_pass[array_rand(array_for_rand_pass)]; - } + var string_result = ""; // Empty string + for (var i = 1; i <= 8; i++) { + string_result += array_for_rand_pass[array_rand(array_for_rand_pass)]; + } - var _popup_left = (Math.ceil(window.screen.availWidth / 2) - 150); - var _popup_top = (Math.ceil(window.screen.availHeight / 2) - 50); + var _popup_left = (Math.ceil(window.screen.availWidth / 2) - 150); + var _popup_top = (Math.ceil(window.screen.availHeight / 2) - 50); - if (!noCenter) { - $("div#autocomplete_popup").css({ - left: _popup_left + "px", - top: _popup_top + "px" - }).show(1000); - } else { - $("div#autocomplete_popup").show(1000); - } + if (!noCenter) { + $("div#autocomplete_popup").css({ + left: _popup_left + "px", + top: _popup_top + "px" + }).show(1000); + } else { + $("div#autocomplete_popup").show(1000); + } - $("[name='new_pass'],[name='cfm_pass'], div#autocomplete_popup input").each(function () { - $(this).val(string_result); - }); + $("[name='new_pass'],[name='cfm_pass'], div#autocomplete_popup input").each(function () { + $(this).val(string_result); + }); }; $(document).ready(function () { - $("span#autocomplete").click(function () { - autocomplete(); - }); + $("span#autocomplete").click(function () { + autocomplete(); + }); - // перемещение окна - var _X, _Y; - var _bMoveble = false; + // перемещение окна + var _X, _Y; + var _bMoveble = false; - $("div#autocomplete_popup div.title").mousedown(function (event) { - _bMoveble = true; - _X = event.clientX; - _Y = event.clientY; - }); + $("div#autocomplete_popup div.title").mousedown(function (event) { + _bMoveble = true; + _X = event.clientX; + _Y = event.clientY; + }); - $("div#autocomplete_popup div.title").mousemove(function (event) { - var jFrame = $("div#autocomplete_popup"); - var jFLeft = parseInt(jFrame.css("left")); - var jFTop = parseInt(jFrame.css("top")); + $("div#autocomplete_popup div.title").mousemove(function (event) { + var jFrame = $("div#autocomplete_popup"); + var jFLeft = parseInt(jFrame.css("left")); + var jFTop = parseInt(jFrame.css("top")); - if (_bMoveble) { - if (event.clientX < _X) { - jFrame.css("left", jFLeft - (_X - event.clientX) + "px"); - } else { - jFrame.css("left", (jFLeft + (event.clientX - _X)) + "px"); - } + if (_bMoveble) { + if (event.clientX < _X) { + jFrame.css("left", jFLeft - (_X - event.clientX) + "px"); + } else { + jFrame.css("left", (jFLeft + (event.clientX - _X)) + "px"); + } - if (event.clientY < _Y) { - jFrame.css("top", jFTop - (_Y - event.clientY) + "px"); - } else { - jFrame.css("top", (jFTop + (event.clientY - _Y)) + "px"); - } + if (event.clientY < _Y) { + jFrame.css("top", jFTop - (_Y - event.clientY) + "px"); + } else { + jFrame.css("top", (jFTop + (event.clientY - _Y)) + "px"); + } - _X = event.clientX; - _Y = event.clientY; - } - }); + _X = event.clientX; + _Y = event.clientY; + } + }); - $("div#autocomplete_popup div.title").mouseup(function () { - _bMoveble = false; - }).mouseout(function () { - _bMoveble = false; - }); -}); \ No newline at end of file + $("div#autocomplete_popup div.title").mouseup(function () { + _bMoveble = false; + }).mouseout(function () { + _bMoveble = false; + }); +}); diff --git a/styles/templates/default/search.tpl b/styles/templates/default/search.tpl index fa86e8d48..6ec02121f 100644 --- a/styles/templates/default/search.tpl +++ b/styles/templates/default/search.tpl @@ -133,7 +133,7 @@ function refresh_username(selected_username) opener.document.forms['post'].{INPUT_NAME}.value = selected_username; opener.focus(); window.close(); -}; +}
@@ -165,4 +165,4 @@ function refresh_username(selected_username)
- \ No newline at end of file + diff --git a/styles/templates/default/tpl_config.php b/styles/templates/default/tpl_config.php index 249392050..511558082 100644 --- a/styles/templates/default/tpl_config.php +++ b/styles/templates/default/tpl_config.php @@ -8,171 +8,171 @@ $di = \TorrentPier\Di::getInstance(); $width = $height = array(); $template_name = basename(dirname(__FILE__)); -$_img = BB_ROOT . 'styles/images/'; -$_main = BB_ROOT . 'styles/' . basename(TEMPLATES_DIR) . '/'. $template_name .'/images/'; -$_lang = $_main . 'lang/' . basename($di->config->get('default_lang')) .'/'; +$_img = BB_ROOT . 'styles/images/'; +$_main = BB_ROOT . 'styles/' . basename(TEMPLATES_DIR) . '/' . $template_name . '/images/'; +$_lang = $_main . 'lang/' . basename($di->config->get('default_lang')) . '/'; // post_buttons -$images['icon_quote'] = $_lang .'icon_quote.gif'; -$images['icon_edit'] = $_lang .'icon_edit.gif'; -$images['icon_search'] = $_lang .'icon_search.gif'; -$images['icon_profile'] = $_lang .'icon_profile.gif'; -$images['icon_pm'] = $_lang .'icon_pm.gif'; -$images['icon_email'] = $_lang .'icon_email.gif'; -$images['icon_delpost'] = $_main .'icon_delete.gif'; -$images['icon_ip'] = $_lang .'icon_ip.gif'; -$images['icon_mod'] = $_main .'icon_mod.gif'; -$images['icon_www'] = $_lang .'icon_www.gif'; -$images['icon_icq'] = $_lang .'icon_icq_add.gif'; +$images['icon_quote'] = $_lang . 'icon_quote.gif'; +$images['icon_edit'] = $_lang . 'icon_edit.gif'; +$images['icon_search'] = $_lang . 'icon_search.gif'; +$images['icon_profile'] = $_lang . 'icon_profile.gif'; +$images['icon_pm'] = $_lang . 'icon_pm.gif'; +$images['icon_email'] = $_lang . 'icon_email.gif'; +$images['icon_delpost'] = $_main . 'icon_delete.gif'; +$images['icon_ip'] = $_lang . 'icon_ip.gif'; +$images['icon_mod'] = $_main . 'icon_mod.gif'; +$images['icon_www'] = $_lang . 'icon_www.gif'; +$images['icon_icq'] = $_lang . 'icon_icq_add.gif'; -$images['icon_mc'] = $_lang .'icon_mc.gif'; -$images['icon_poll'] = $_lang .'icon_poll.gif'; +$images['icon_mc'] = $_lang . 'icon_mc.gif'; +$images['icon_poll'] = $_lang . 'icon_poll.gif'; -$images['icon_birthday'] = $_main .'icon_birthday.gif'; -$images['icon_male'] = $_main .'icon_male.gif'; -$images['icon_female'] = $_main .'icon_female.gif'; -$images['icon_nogender'] = $_main .'icon_nogender.gif'; +$images['icon_birthday'] = $_main . 'icon_birthday.gif'; +$images['icon_male'] = $_main . 'icon_male.gif'; +$images['icon_female'] = $_main . 'icon_female.gif'; +$images['icon_nogender'] = $_main . 'icon_nogender.gif'; // post_icons -$images['icon_minipost'] = $_main .'icon_minipost.gif'; -$images['icon_gotopost'] = $_main .'icon_minipost.gif'; -$images['icon_minipost_new'] = $_main .'icon_minipost_new.gif'; -$images['icon_latest_reply'] = $_main .'icon_latest_reply.gif'; -$images['icon_newest_reply'] = $_main .'icon_newest_reply.gif'; +$images['icon_minipost'] = $_main . 'icon_minipost.gif'; +$images['icon_gotopost'] = $_main . 'icon_minipost.gif'; +$images['icon_minipost_new'] = $_main . 'icon_minipost_new.gif'; +$images['icon_latest_reply'] = $_main . 'icon_latest_reply.gif'; +$images['icon_newest_reply'] = $_main . 'icon_newest_reply.gif'; // forum_icons -$images['forum'] = $_main .'folder_big.gif'; -$images['forum_new'] = $_main .'folder_new_big.gif'; -$images['forum_locked'] = $_main .'folder_locked_big.gif'; +$images['forum'] = $_main . 'folder_big.gif'; +$images['forum_new'] = $_main . 'folder_new_big.gif'; +$images['forum_locked'] = $_main . 'folder_locked_big.gif'; // topic_icons -$images['folder'] = $_main .'folder.gif'; -$images['folder_new'] = $_main .'folder_new.gif'; -$images['folder_hot'] = $_main .'folder_hot.gif'; -$images['folder_hot_new'] = $_main .'folder_new_hot.gif'; -$images['folder_locked'] = $_main .'folder_lock.gif'; -$images['folder_locked_new'] = $_main .'folder_lock_new.gif'; -$images['folder_sticky'] = $_main .'folder_sticky.gif'; -$images['folder_sticky_new'] = $_main .'folder_sticky_new.gif'; -$images['folder_announce'] = $_main .'folder_announce.gif'; -$images['folder_announce_new'] = $_main .'folder_announce_new.gif'; -$images['folder_dl'] = $_main .'folder_dl.gif'; -$images['folder_dl_new'] = $_main .'folder_dl_new.gif'; -$images['folder_dl_hot'] = $_main .'folder_dl_hot.gif'; -$images['folder_dl_hot_new'] = $_main .'folder_dl_hot_new.gif'; +$images['folder'] = $_main . 'folder.gif'; +$images['folder_new'] = $_main . 'folder_new.gif'; +$images['folder_hot'] = $_main . 'folder_hot.gif'; +$images['folder_hot_new'] = $_main . 'folder_new_hot.gif'; +$images['folder_locked'] = $_main . 'folder_lock.gif'; +$images['folder_locked_new'] = $_main . 'folder_lock_new.gif'; +$images['folder_sticky'] = $_main . 'folder_sticky.gif'; +$images['folder_sticky_new'] = $_main . 'folder_sticky_new.gif'; +$images['folder_announce'] = $_main . 'folder_announce.gif'; +$images['folder_announce_new'] = $_main . 'folder_announce_new.gif'; +$images['folder_dl'] = $_main . 'folder_dl.gif'; +$images['folder_dl_new'] = $_main . 'folder_dl_new.gif'; +$images['folder_dl_hot'] = $_main . 'folder_dl_hot.gif'; +$images['folder_dl_hot_new'] = $_main . 'folder_dl_hot_new.gif'; // attach_icons -$images['icon_clip'] = $_img .'icon_clip.gif'; -$images['icon_dn'] = $_img .'icon_dn.gif'; -$images['icon_magnet'] = $_img .'magnet.png'; -$images['icon_dc_magnet'] = $_img .'dc_magnet.png'; -$images['icon_dc_magnet_ext'] = $_img .'dc_magnet_ext.png'; +$images['icon_clip'] = $_img . 'icon_clip.gif'; +$images['icon_dn'] = $_img . 'icon_dn.gif'; +$images['icon_magnet'] = $_img . 'magnet.png'; +$images['icon_dc_magnet'] = $_img . 'dc_magnet.png'; +$images['icon_dc_magnet_ext'] = $_img . 'dc_magnet_ext.png'; // posting_icons -$images['post_new'] = $_lang .'post.gif'; -$images['post_locked'] = $_lang .'reply-locked.gif'; -$images['reply_new'] = $_lang .'reply.gif'; -$images['reply_locked'] = $_lang .'reply-locked.gif'; -$images['release_new'] = $_lang .'release.gif'; +$images['post_new'] = $_lang . 'post.gif'; +$images['post_locked'] = $_lang . 'reply-locked.gif'; +$images['reply_new'] = $_lang . 'reply.gif'; +$images['reply_locked'] = $_lang . 'reply-locked.gif'; +$images['release_new'] = $_lang . 'release.gif'; // pm_icons -$images['pm_inbox'] = $_main .'msg_inbox.gif'; -$images['pm_outbox'] = $_main .'msg_outbox.gif'; -$images['pm_savebox'] = $_main .'msg_savebox.gif'; -$images['pm_sentbox'] = $_main .'msg_sentbox.gif'; -$images['pm_readmsg'] = $_main .'folder.gif'; -$images['pm_unreadmsg'] = $_main .'folder_new.gif'; -$images['pm_replymsg'] = $_lang .'reply.gif'; -$images['pm_postmsg'] = $_lang .'msg_newpost.gif'; -$images['pm_quotemsg'] = $_lang .'icon_quote.gif'; -$images['pm_editmsg'] = $_lang .'icon_edit.gif'; -$images['pm_new_msg'] = ''; -$images['pm_no_new_msg'] = ''; +$images['pm_inbox'] = $_main . 'msg_inbox.gif'; +$images['pm_outbox'] = $_main . 'msg_outbox.gif'; +$images['pm_savebox'] = $_main . 'msg_savebox.gif'; +$images['pm_sentbox'] = $_main . 'msg_sentbox.gif'; +$images['pm_readmsg'] = $_main . 'folder.gif'; +$images['pm_unreadmsg'] = $_main . 'folder_new.gif'; +$images['pm_replymsg'] = $_lang . 'reply.gif'; +$images['pm_postmsg'] = $_lang . 'msg_newpost.gif'; +$images['pm_quotemsg'] = $_lang . 'icon_quote.gif'; +$images['pm_editmsg'] = $_lang . 'icon_edit.gif'; +$images['pm_new_msg'] = ''; +$images['pm_no_new_msg'] = ''; // topic_mod_icons will be replaced with SELECT later... -$images['topic_watch'] = ''; -$images['topic_un_watch'] = ''; -$images['topic_mod_lock'] = $_main .'topic_lock.gif'; -$images['topic_mod_unlock'] = $_main .'topic_unlock.gif'; -$images['topic_mod_split'] = $_main .'topic_split.gif'; -$images['topic_mod_move'] = $_main .'topic_move.gif'; -$images['topic_mod_delete'] = $_main .'topic_delete.gif'; -$images['topic_dl'] = $_main .'topic_dl.gif'; -$images['topic_normal'] = $_main .'topic_normal.gif'; +$images['topic_watch'] = ''; +$images['topic_un_watch'] = ''; +$images['topic_mod_lock'] = $_main . 'topic_lock.gif'; +$images['topic_mod_unlock'] = $_main . 'topic_unlock.gif'; +$images['topic_mod_split'] = $_main . 'topic_split.gif'; +$images['topic_mod_move'] = $_main . 'topic_move.gif'; +$images['topic_mod_delete'] = $_main . 'topic_delete.gif'; +$images['topic_dl'] = $_main . 'topic_dl.gif'; +$images['topic_normal'] = $_main . 'topic_normal.gif'; -$images['voting_graphic'][0] = $_main .'voting_bar.gif'; -$images['voting_graphic'][1] = $_main .'voting_bar.gif'; -$images['voting_graphic'][2] = $_main .'voting_bar.gif'; -$images['voting_graphic'][3] = $_main .'voting_bar.gif'; -$images['voting_graphic'][4] = $_main .'voting_bar.gif'; -$images['progress_bar'] = $_main .'progress_bar.gif'; -$images['progress_bar_full'] = $_main .'progress_bar_full.gif'; +$images['voting_graphic'][0] = $_main . 'voting_bar.gif'; +$images['voting_graphic'][1] = $_main . 'voting_bar.gif'; +$images['voting_graphic'][2] = $_main . 'voting_bar.gif'; +$images['voting_graphic'][3] = $_main . 'voting_bar.gif'; +$images['voting_graphic'][4] = $_main . 'voting_bar.gif'; +$images['progress_bar'] = $_main . 'progress_bar.gif'; +$images['progress_bar_full'] = $_main . 'progress_bar_full.gif'; $template->assign_vars(array( - 'IMG' => $_main, - 'TEXT_BUTTONS' => $di->config->get('text_buttons'), - 'POST_BTN_SPACER' => ($di->config->get('text_buttons')) ? ' ' : '', - 'TOPIC_ATTACH_ICON' => '', - 'OPEN_MENU_IMG_ALT' => '', + 'IMG' => $_main, + 'TEXT_BUTTONS' => $di->config->get('text_buttons'), + 'POST_BTN_SPACER' => ($di->config->get('text_buttons')) ? ' ' : '', + 'TOPIC_ATTACH_ICON' => '', + 'OPEN_MENU_IMG_ALT' => '', 'TOPIC_LEFT_COL_SPACER_WITDH' => $di->config->get('topic_left_column_witdh') - 8, // 8px padding - 'POST_IMG_WIDTH_DECR_JS' => $di->config->get('topic_left_column_witdh') + $di->config->get('post_img_width_decr'), - 'ATTACH_IMG_WIDTH_DECR_JS' => $di->config->get('topic_left_column_witdh') + $di->config->get('attach_img_width_decr'), - 'MAGNET_LINKS' => $di->config->get('magnet_links_enabled'), - 'FEED_IMG' => ''. $lang['ATOM_FEED'] .'', + 'POST_IMG_WIDTH_DECR_JS' => $di->config->get('topic_left_column_witdh') + $di->config->get('post_img_width_decr'), + 'ATTACH_IMG_WIDTH_DECR_JS' => $di->config->get('topic_left_column_witdh') + $di->config->get('attach_img_width_decr'), + 'MAGNET_LINKS' => $di->config->get('magnet_links_enabled'), + 'FEED_IMG' => '' . $lang['ATOM_FEED'] . '', )); // post_buttons if (!empty($page_cfg['load_tpl_vars']) && ($vars = array_flip($page_cfg['load_tpl_vars']))) { if (isset($vars['post_buttons'])) { $template->assign_vars(array( - 'QUOTE_IMG' => ($di->config->get('text_buttons')) ? $lang['REPLY_WITH_QUOTE_TXTB'] : ''.$lang['REPLY_WITH_QUOTE_TXTB'].'', - 'EDIT_POST_IMG' => ($di->config->get('text_buttons')) ? $lang['EDIT_DELETE_POST_TXTB'] : ''.$lang['EDIT_DELETE_POST_TXTB'].'', - 'DELETE_POST_IMG' => ($di->config->get('text_buttons')) ? $lang['DELETE_POST_TXTB'] : ''.$lang['DELETE_POST_TXTB'].'', - 'IP_POST_IMG' => ($di->config->get('text_buttons')) ? $lang['VIEW_IP_TXTB'] : ''.$lang['VIEW_IP_TXTB'].'', - 'MOD_POST_IMG' => ($di->config->get('text_buttons')) ? $lang['MODERATE_POST_TXTB'] : ''.$lang['MODERATE_POST_TXTB'].'', - 'MC_IMG' => ($di->config->get('text_buttons')) ? '['.$lang['COMMENT'].']' : '['.$lang['COMMENT'].']', - 'POLL_IMG' => ($di->config->get('text_buttons')) ? $lang['TOPIC_POLL'] : ''.$lang['TOPIC_POLL'] .'', + 'QUOTE_IMG' => ($di->config->get('text_buttons')) ? $lang['REPLY_WITH_QUOTE_TXTB'] : '' . $lang['REPLY_WITH_QUOTE_TXTB'] . '', + 'EDIT_POST_IMG' => ($di->config->get('text_buttons')) ? $lang['EDIT_DELETE_POST_TXTB'] : '' . $lang['EDIT_DELETE_POST_TXTB'] . '', + 'DELETE_POST_IMG' => ($di->config->get('text_buttons')) ? $lang['DELETE_POST_TXTB'] : '' . $lang['DELETE_POST_TXTB'] . '', + 'IP_POST_IMG' => ($di->config->get('text_buttons')) ? $lang['VIEW_IP_TXTB'] : '' . $lang['VIEW_IP_TXTB'] . '', + 'MOD_POST_IMG' => ($di->config->get('text_buttons')) ? $lang['MODERATE_POST_TXTB'] : '' . $lang['MODERATE_POST_TXTB'] . '', + 'MC_IMG' => ($di->config->get('text_buttons')) ? '[' . $lang['COMMENT'] . ']' : '[' . $lang['COMMENT'] . ']', + 'POLL_IMG' => ($di->config->get('text_buttons')) ? $lang['TOPIC_POLL'] : '' . $lang['TOPIC_POLL'] . '', - 'QUOTE_URL' => BB_ROOT . POSTING_URL . "?mode=quote&p=", - 'EDIT_POST_URL' => BB_ROOT . POSTING_URL . "?mode=editpost&p=", + 'QUOTE_URL' => BB_ROOT . POSTING_URL . "?mode=quote&p=", + 'EDIT_POST_URL' => BB_ROOT . POSTING_URL . "?mode=editpost&p=", 'DELETE_POST_URL' => BB_ROOT . POSTING_URL . "?mode=delete&p=", - 'IP_POST_URL' => BB_ROOT ."modcp.php?mode=ip&p=", + 'IP_POST_URL' => BB_ROOT . "modcp.php?mode=ip&p=", - 'PROFILE_IMG' => ($di->config->get('text_buttons')) ? $lang['READ_PROFILE_TXTB'] : ''. $lang['READ_PROFILE_TXTB'] .'', - 'PM_IMG' => ($di->config->get('text_buttons')) ? $lang['SEND_PM_TXTB'] : ''. $lang['SEND_PM_TXTB'] .'', - 'EMAIL_IMG' => ($di->config->get('text_buttons')) ? $lang['SEND_EMAIL_TXTB'] : ''. $lang['SEND_EMAIL_TXTB'] .'', - 'WWW_IMG' => ($di->config->get('text_buttons')) ? $lang['VISIT_WEBSITE_TXTB'] : ''.$lang['VISIT_WEBSITE_TXTB'].'', - 'ICQ_IMG' => ($di->config->get('text_buttons')) ? $lang['ICQ_TXTB'] : ''.$lang['ICQ_TXTB'].'', + 'PROFILE_IMG' => ($di->config->get('text_buttons')) ? $lang['READ_PROFILE_TXTB'] : '' . $lang['READ_PROFILE_TXTB'] . '', + 'PM_IMG' => ($di->config->get('text_buttons')) ? $lang['SEND_PM_TXTB'] : '' . $lang['SEND_PM_TXTB'] . '', + 'EMAIL_IMG' => ($di->config->get('text_buttons')) ? $lang['SEND_EMAIL_TXTB'] : '' . $lang['SEND_EMAIL_TXTB'] . '', + 'WWW_IMG' => ($di->config->get('text_buttons')) ? $lang['VISIT_WEBSITE_TXTB'] : '' . $lang['VISIT_WEBSITE_TXTB'] . '', + 'ICQ_IMG' => ($di->config->get('text_buttons')) ? $lang['ICQ_TXTB'] : '' . $lang['ICQ_TXTB'] . '', - 'EMAIL_URL' => BB_ROOT ."profile.php?mode=email&u=", - 'FORUM_URL' => BB_ROOT . FORUM_URL, - 'PM_URL' => BB_ROOT . PM_URL, - 'PROFILE_URL' => BB_ROOT . PROFILE_URL, + 'EMAIL_URL' => BB_ROOT . "profile.php?mode=email&u=", + 'FORUM_URL' => BB_ROOT . FORUM_URL, + 'PM_URL' => BB_ROOT . PM_URL, + 'PROFILE_URL' => BB_ROOT . PROFILE_URL, )); } if (isset($vars['post_icons'])) { $template->assign_vars(array( - 'MINIPOST_IMG' => ''.$lang['POST'].'', - 'ICON_GOTOPOST' => ''.$lang['GO'].'', - 'MINIPOST_IMG_NEW' => ''.$lang['NEW'].'', - 'ICON_LATEST_REPLY' => ''.$lang['LATEST'].'', - 'ICON_NEWEST_REPLY' => ''.$lang['NEWEST'].'', + 'MINIPOST_IMG' => '' . $lang['POST'] . '', + 'ICON_GOTOPOST' => '' . $lang['GO'] . '', + 'MINIPOST_IMG_NEW' => '' . $lang['NEW'] . '', + 'ICON_LATEST_REPLY' => '' . $lang['LATEST'] . '', + 'ICON_NEWEST_REPLY' => '' . $lang['NEWEST'] . '', )); } if (isset($vars['topic_icons'])) { $template->assign_vars(array( - 'MOVED' => TOPIC_MOVED, - 'ANNOUNCE' => POST_ANNOUNCE, - 'STICKY' => POST_STICKY, - 'LOCKED' => TOPIC_LOCKED, + 'MOVED' => TOPIC_MOVED, + 'ANNOUNCE' => POST_ANNOUNCE, + 'STICKY' => POST_STICKY, + 'LOCKED' => TOPIC_LOCKED, )); } if (isset($vars['pm_icons'])) { $template->assign_vars(array( - 'INBOX_IMG' => '', - 'OUTBOX_IMG' => '', - 'SENTBOX_IMG' => '', - 'SAVEBOX_IMG' => '', + 'INBOX_IMG' => '', + 'OUTBOX_IMG' => '', + 'SENTBOX_IMG' => '', + 'SAVEBOX_IMG' => '', )); } } diff --git a/styles/templates/default/tracker.tpl b/styles/templates/default/tracker.tpl index 4d9073ce6..7263f6cf4 100644 --- a/styles/templates/default/tracker.tpl +++ b/styles/templates/default/tracker.tpl @@ -522,4 +522,4 @@ function get_fs_link () } return false; } - \ No newline at end of file +