PHPDoc and some reformat fixes.

This commit is contained in:
Yuriy Pikhtarev 2016-10-03 23:56:46 +03:00
commit 79ea41b3f4
No known key found for this signature in database
GPG key ID: 3A9B5A757B48ECC6
49 changed files with 2510 additions and 1049 deletions

View file

@ -17,9 +17,9 @@ $return_links = array(
'config_mods' => '<br /><br />' . sprintf($lang['CLICK_RETURN_CONFIG_MODS'], '<a href="admin_board.php?mode=config_mods">', '</a>')
);
//
// 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]));

View file

@ -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);

View file

@ -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);

View file

@ -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 = '<select name="disallowed_id">';
if (count($disallowed) <= 0) {

View file

@ -6,7 +6,7 @@ if (!empty($setmodules)) {
}
require('./pagestart.php');
$forum_auth_fields = array(
$forum_auth_fields = [
'auth_view',
'auth_read',
'auth_reply',
@ -19,27 +19,20 @@ $forum_auth_fields = array(
'auth_post',
'auth_sticky',
'auth_announce',
);
];
// View Read Reply Edit Delete Vote Poll PostAttach DownAttach PostTopic Sticky Announce
$simple_auth_ary = array(
/* Public */
0 => array(AUTH_ALL, AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_ALL, AUTH_ALL, AUTH_MOD, AUTH_MOD), // Public
/* Reg */
1 => array(AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD), // Registered
/* Reg [Hid] */
2 => array(AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD), // Registered [Hidden]
/* Priv */
3 => array(AUTH_REG, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_MOD), // Private
/* Priv [Hid] */
4 => array(AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_MOD), // 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_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_ALL, AUTH_ALL, AUTH_MOD, AUTH_MOD], // Public
1 => [AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD], // Registered
2 => [AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD], // Registered [Hidden]
3 => [AUTH_REG, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_MOD], // Private
4 => [AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_MOD], // 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'] . ']',
@ -47,15 +40,15 @@ $simple_auth_types = array(
$lang['PRIVATE'] . ' [' . $lang['HIDDEN'] . ']',
$lang['MODERATORS'],
$lang['MODERATORS'] . ' [' . $lang['HIDDEN'] . ']',
);
];
$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 ($_REQUEST[POST_FORUM_URL]) {
$forum_id = (int)$_REQUEST[POST_FORUM_URL];
@ -71,9 +64,9 @@ if (isset($_GET['adv'])) {
unset($adv);
}
//
// Start program proper
//
/**
* Start program proper
*/
if (isset($_POST['submit'])) {
$sql = '';
@ -116,13 +109,11 @@ if (isset($_POST['submit'])) {
$datastore->update('cat_forums');
bb_die($lang['FORUM_AUTH_UPDATED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_FORUMAUTH'], '<a href="' . "admin_forumauth.php" . '">', "</a>"));
} // End of submit
}
//
// Get required information, either all forums if
// no id was specified or just the requsted if it
// was
//
/**
* Get required information
*/
$forum_rows = DB()->fetch_rowset("SELECT * FROM " . BB_FORUMS . " $forum_sql");
if (empty($forum_id)) {
@ -179,10 +170,7 @@ if (empty($forum_id)) {
$s_column_span++;
} else {
//
// Output values of individual
// fields
//
// Output values of individual fields
for ($j = 0; $j < count($forum_auth_fields); $j++) {
$custom_auth[$j] = '&nbsp;<select name="' . $forum_auth_fields[$j] . '">';

View file

@ -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]);

View file

@ -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);

View file

@ -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' => '',

View file

@ -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) {

View file

@ -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'));

View file

@ -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');

View file

@ -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 = '')
{

View file

@ -131,6 +131,8 @@ $DBS = new DBS([
/**
* TODO: @deprecated
* @param string $db_alias
* @return mixed
*/
function DB($db_alias = 'db')
{

View file

@ -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 <i>$length</i> $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('&#91;', '&#93;', '&lt;', '&gt;', '&#039;'), $dirname);

View file

@ -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");

View file

@ -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 == '') {

View file

@ -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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
@ -53,6 +66,10 @@ class sitemap
return $map;
}
/**
* @param $n
* @return string
*/
public function build_map_topic($n)
{
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\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<url>\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);

View file

@ -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])) {

View file

@ -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 = '')
{

View file

@ -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());

View file

@ -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');

View file

@ -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) {

View file

@ -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) {

View file

@ -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');

View file

@ -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');

View file

@ -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) {

View file

@ -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');

File diff suppressed because it is too large Load diff

View file

@ -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();

View file

@ -1,5 +1,8 @@
<?php
/**
* @param $jobs
*/
function run_jobs($jobs)
{
global $tr_cfg, $datastore;
@ -46,12 +49,19 @@ function run_jobs($jobs)
return;
}
/**
* @param $jobs
*/
function delete_jobs($jobs)
{
DB()->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'];

View file

@ -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) {

View file

@ -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 */

View file

@ -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 = '';

View file

@ -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

View file

@ -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;

View file

@ -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 */

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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)) {

View file

@ -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);

View file

@ -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 */

View file

@ -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);

View file

@ -5,7 +5,6 @@ namespace TorrentPier\ServiceProviders;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use TorrentPier\Db\Adapter;
use TorrentPier\Db\Connection;
/**
* Class DbServiceProvider

View file

@ -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<newText.length; i++) if (newText.charAt(i)=='\r') delta++;
range.moveStart("character", -close.length-text.length-open.length+delta);
range.moveEnd("character", -0);
} else {
range.moveEnd("character", -close.length);
}
if (!this.collapseAfterInsert) range.select();
} else if (t.setSelectionRange) {
var start = t.selectionStart;
var end = t.selectionEnd;
var top = t.scrollTop;
var sel1 = t.value.substr(0, start);
var sel2 = t.value.substr(end);
var sel = fTrans(t.value.substr(start, end-start));
var inner = open + sel + close;
t.value = sel1 + inner + sel2;
if (sel != '') {
t.setSelectionRange(start, start+inner.length);
notEmpty = true;
} else {
t.setSelectionRange(start+open.length, start+open.length);
notEmpty = false;
}
t.scrollTop = top;
if (this.collapseAfterInsert) t.setSelectionRange(start+inner.length, start+inner.length);
} else {
t.value += open + text + close;
}
this.collapseAfterInsert = false;
return notEmpty;
},
// 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 < newText.length; i++) if (newText.charAt(i) == '\r') delta++;
range.moveStart("character", -close.length - text.length - open.length + delta);
range.moveEnd("character", -0);
} else {
range.moveEnd("character", -close.length);
}
if (!this.collapseAfterInsert) range.select();
} else if (t.setSelectionRange) {
var start = t.selectionStart;
var end = t.selectionEnd;
var top = t.scrollTop;
var sel1 = t.value.substr(0, start);
var sel2 = t.value.substr(end);
var sel = fTrans(t.value.substr(start, end - start));
var inner = open + sel + close;
t.value = sel1 + inner + sel2;
if (sel != '') {
t.setSelectionRange(start, start + inner.length);
notEmpty = true;
} else {
t.setSelectionRange(start + open.length, start + open.length);
notEmpty = false;
}
t.scrollTop = top;
if (this.collapseAfterInsert) t.setSelectionRange(start + inner.length, start + inner.length);
} else {
t.value += open + text + close;
}
this.collapseAfterInsert = false;
return notEmpty;
},
// Internal function for cross-browser event cancellation.
_cancelEvent: function(e) {
if (e.preventDefault) e.preventDefault();
if (e.stopPropagation) e.stopPropagation();
return e.returnValue = false;
},
// Internal function for cross-browser event cancellation.
_cancelEvent: function (e) {
if (e.preventDefault) e.preventDefault();
if (e.stopPropagation) e.stopPropagation();
return e.returnValue = false;
},
// Available key combinations and these interpretaions for BB are
// TAB - Insert TAB char
// CTRL-TAB - Next form field (usual TAB)
// ALT-ENTER - Preview
// CTRL-ENTER - Submit
onKeyPress: function(e, type) {
// Try to match all the hot keys.
var key = String.fromCharCode(e.keyCode? e.keyCode : e.charCode);
for (var id in this.tags) {
var tag = this.tags[id];
// Pressed control key?
if (tag.ctrlKey && !e[tag.ctrlKey+"Key"]) continue;
// Pressed needed key?
if (!tag.key || key.toUpperCase() != tag.key.toUpperCase()) continue;
// Insert
if (e.type == "keydown") this.insertTag(id);
// Reset event
return this._cancelEvent(e);
}
// Available key combinations and these interpretaions for BB are
// TAB - Insert TAB char
// CTRL-TAB - Next form field (usual TAB)
// ALT-ENTER - Preview
// CTRL-ENTER - Submit
onKeyPress: function (e, type) {
// Try to match all the hot keys.
var key = String.fromCharCode(e.keyCode ? e.keyCode : e.charCode);
for (var id in this.tags) {
var tag = this.tags[id];
// Pressed control key?
if (tag.ctrlKey && !e[tag.ctrlKey + "Key"]) continue;
// Pressed needed key?
if (!tag.key || key.toUpperCase() != tag.key.toUpperCase()) continue;
// Insert
if (e.type == "keydown") this.insertTag(id);
// Reset event
return this._cancelEvent(e);
}
// Tab
if (type == 'press' && e.keyCode == this.VK_TAB && !e.shiftKey && !e.ctrlKey && !e.altKey) {
this.insertAtCursor('[tab]');
return this._cancelEvent(e);
}
// Tab
if (type == 'press' && e.keyCode == this.VK_TAB && !e.shiftKey && !e.ctrlKey && !e.altKey) {
this.insertAtCursor('[tab]');
return this._cancelEvent(e);
}
// Ctrl+Tab
if (e.keyCode == this.VK_TAB && !e.shiftKey && e.ctrlKey && !e.altKey) {
this.textarea.form.post.focus();
return this._cancelEvent(e);
}
// Ctrl+Tab
if (e.keyCode == this.VK_TAB && !e.shiftKey && e.ctrlKey && !e.altKey) {
this.textarea.form.post.focus();
return this._cancelEvent(e);
}
// Hot keys
var form = this.textarea.form;
var submitter = null;
if (e.keyCode == this.VK_ENTER &&!e.shiftKey && !e.ctrlKey && e.altKey)
submitter = form.preview;
if (e.keyCode == this.VK_ENTER && !e.shiftKey && e.ctrlKey && !e.altKey)
submitter = form.post;
if (submitter) {
submitter.click();
return this._cancelEvent(e);
}
// Hot keys
var form = this.textarea.form;
var submitter = null;
if (e.keyCode == this.VK_ENTER && !e.shiftKey && !e.ctrlKey && e.altKey)
submitter = form.preview;
if (e.keyCode == this.VK_ENTER && !e.shiftKey && e.ctrlKey && !e.altKey)
submitter = form.post;
if (submitter) {
submitter.click();
return this._cancelEvent(e);
}
return true;
},
return true;
},
// Adds a BB tag to the list
addTag: function(id, open, close, key, ctrlKey, multiline) {
if (!ctrlKey) ctrlKey = "ctrl";
var tag = {};
tag.id = id;
tag.open = open;
tag.close = close;
tag.key = key;
tag.ctrlKey = ctrlKey;
tag.multiline = multiline;
tag.elt = this.textarea.form[id];
this.tags[id] = tag;
// Setup events
var elt = tag.elt;
if (elt) {
var th = this;
if (elt.type && elt.type.toUpperCase()=="BUTTON") {
addEvent(elt, 'click', function() { th.insertTag(id); return false; });
}
if (elt.tagName && elt.tagName.toUpperCase()=="SELECT") {
addEvent(elt, 'change', function() { th.insertTag(id); return false; });
}
}
else
{
if (id && id.indexOf('_') != 0) return alert("addTag('"+id+"'): no such element in the form");
}
},
// Adds a BB tag to the list
addTag: function (id, open, close, key, ctrlKey, multiline) {
if (!ctrlKey) ctrlKey = "ctrl";
var tag = {};
tag.id = id;
tag.open = open;
tag.close = close;
tag.key = key;
tag.ctrlKey = ctrlKey;
tag.multiline = multiline;
tag.elt = this.textarea.form[id];
this.tags[id] = tag;
// Setup events
var elt = tag.elt;
if (elt) {
var th = this;
if (elt.type && elt.type.toUpperCase() == "BUTTON") {
addEvent(elt, 'click', function () {
th.insertTag(id);
return false;
});
}
if (elt.tagName && elt.tagName.toUpperCase() == "SELECT") {
addEvent(elt, 'change', function () {
th.insertTag(id);
return false;
});
}
}
else {
if (id && id.indexOf('_') != 0) return alert("addTag('" + id + "'): no such element in the form");
}
},
// Inserts the tag with specified ID
insertTag: function(id) {
// Find tag
var tag = this.tags[id];
if (!tag) return alert("Unknown tag ID: "+id);
// Inserts the tag with specified ID
insertTag: function (id) {
// Find tag
var tag = this.tags[id];
if (!tag) return alert("Unknown tag ID: " + id);
// Open tag is generated by callback?
var op = tag.open;
if (typeof(tag.open) == "function") op = tag.open(tag.elt);
var cl = tag.close!=null? tag.close : "/"+op;
// Open tag is generated by callback?
var op = tag.open;
if (typeof(tag.open) == "function") op = tag.open(tag.elt);
var cl = tag.close != null ? tag.close : "/" + op;
// Use "[" if needed
if (op.charAt(0) != this.BRK_OP) op = this.BRK_OP+op+this.BRK_CL;
if (cl && cl.charAt(0) != this.BRK_OP) cl = this.BRK_OP+cl+this.BRK_CL;
// Use "[" if needed
if (op.charAt(0) != this.BRK_OP) op = this.BRK_OP + op + this.BRK_CL;
if (cl && cl.charAt(0) != this.BRK_OP) cl = this.BRK_OP + cl + this.BRK_CL;
this.surround(op, cl, !tag.multiline? null : tag.multiline===true? this._prepareMultiline : tag.multiline);
},
this.surround(op, cl, !tag.multiline ? null : tag.multiline === true ? this._prepareMultiline : tag.multiline);
},
_prepareMultiline: function(text) {
text = text.replace(/\s+$/, '');
text = text.replace(/^([ \t]*\r?\n)+/, '');
if (text.indexOf("\n") >= 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, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
});
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, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
});
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('<hr align="left" />');
initCodes(context);
initQuotes(context);
initExternalLinks(context);
initPostImages(context);
initSpoilers(context);
initMedia(context);
function initPostBBCode(context) {
$('span.post-hr', context).html('<hr align="left" />');
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('<div class="c-head"><b>'+bbl['code']+':</b></div>');
});
function initCodes(context) {
$('div.c-body', context).each(function () {
var $c = $(this);
$c.before('<div class="c-head"><b>' + bbl['code'] + ':</b></div>');
});
}
function initQuotes(context)
{
$('div.q', context).each(function(){
var $q = $(this);
var name = $(this).attr('head');
var q_title = (name ? '<b>'+name+'</b> '+bbl['wrote']+':' : '<b>'+bbl['quote']+'</b>');
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 += ' <a href="'+ href +'" title="'+bbl['quoted_post']+'"><img src="'+bb_url+'styles/templates/default/images/icon_latest_reply.gif" class="icon2" alt="" /></a>';
}
$q.before('<div class="q-head">'+ q_title +'</div>');
});
function initQuotes(context) {
$('div.q', context).each(function () {
var $q = $(this);
var name = $(this).attr('head');
var q_title = (name ? '<b>' + name + '</b> ' + bbl['wrote'] + ':' : '<b>' + bbl['quote'] + '</b>');
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 += ' <a href="' + href + '" title="' + bbl['quoted_post'] + '"><img src="' + bb_url + 'styles/templates/default/images/icon_latest_reply.gif" class="icon2" alt="" /></a>';
}
$q.before('<div class="q-head">' + q_title + '</div>');
});
}
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 = $('<img src="'+ src +'" class="'+ $v.attr('class') +'" alt="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 = '<a href="'+ src +'" target="_blank"><img src="'+bb_url+'styles/images/pic_loading.gif" alt="" /></a>';
$v.html(loading_icon);
if ($.browser.msie) {
$v.after('<wbr>');
}
$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('<wbr>');
}
}
});
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 = $('<img src="' + src + '" class="' + $v.attr('class') + '" alt="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 = '<a href="' + src + '" target="_blank"><img src="' + bb_url + 'styles/images/pic_loading.gif" alt="" /></a>';
$v.html(loading_icon);
if ($.browser.msie) {
$v.after('<wbr>');
}
$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('<wbr>');
}
}
});
}
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 = $('<div class="sp-head folded clickable">'+ name +'</div>');
$sp_head.insertBefore($sp_body).click(function(e){
if (!$sp_body.hasClass('inited')) {
initPostImages($sp_body);
var $sp_fold_btn = $('<div class="sp-fold clickable">['+bbl['spoiler_close']+']</div>').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('<div class="clear"></div>').append('<div class="clear"></div>').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 = $('<div class="sp-head folded clickable">' + name + '</div>');
$sp_head.insertBefore($sp_body).click(function (e) {
if (!$sp_body.hasClass('inited')) {
initPostImages($sp_body);
var $sp_fold_btn = $('<div class="sp-fold clickable">[' + bbl['spoiler_close'] + ']</div>').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('<div class="clear"></div>').append('<div class="clear"></div>').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('<a href="'+ this.src +'" target="_blank"></a>').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('<a href="' + this.src + '" target="_blank"></a>').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 = '<span title="'+bbl['play_on']+'" class="YTLinkButton">&#9658;</span>';
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: '<b>' + text + '</b>',
resizing: 0,
width: 862,
height: 550,
content: '<iframe width="853" height="493" frameborder="0" allowfullscreen="" src="' + vhref + '?wmode=opaque"></iframe>'
});
});
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 = '<span title="' + bbl['play_on'] + '" class="YTLinkButton">&#9658;</span>';
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: '<b>' + text + '</b>',
resizing: 0,
width: 862,
height: 550,
content: '<iframe width="853" height="493" frameborder="0" allowfullscreen="" src="' + vhref + '?wmode=opaque"></iframe>'
});
});
link.parentNode.insertBefore(a, link);
a.appendChild(link);
}
}
}
$(document).ready(function(){
$('div.post_wrap, div.signature').each(function(){ initPostBBCode( $(this) ) });
$(document).ready(function () {
$('div.post_wrap, div.signature').each(function () {
initPostBBCode($(this))
});
});

View file

@ -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 + '<hr />');
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 + '<hr />');
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(
"Ошибка в: <i>" + ajax.url + "</i><br /><b>" + status + " " + text + "</b>"
).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(
"Ошибка в: <i>" + ajax.url + "</i><br /><b>" + status + " " + text + "</b>"
).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;
});
$("div#autocomplete_popup div.title").mouseup(function () {
_bMoveble = false;
}).mouseout(function () {
_bMoveble = false;
});
});

View file

@ -133,7 +133,7 @@ function refresh_username(selected_username)
opener.document.forms['post'].{INPUT_NAME}.value = selected_username;
opener.focus();
window.close();
};
}
</script>
<form method="post" name="search" action="{SEARCH_ACTION}">

View file

@ -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')) ? '&nbsp;' : '',
'TOPIC_ATTACH_ICON' => '<img src="'. $_img .'icon_clip.gif" alt="" />',
'OPEN_MENU_IMG_ALT' => '<img src="'. $_main .'menu_open_1.gif" class="menu-alt1" alt="" />',
'IMG' => $_main,
'TEXT_BUTTONS' => $di->config->get('text_buttons'),
'POST_BTN_SPACER' => ($di->config->get('text_buttons')) ? '&nbsp;' : '',
'TOPIC_ATTACH_ICON' => '<img src="' . $_img . 'icon_clip.gif" alt="" />',
'OPEN_MENU_IMG_ALT' => '<img src="' . $_main . 'menu_open_1.gif" class="menu-alt1" 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' => '<img src="'. $_main .'feed.png" class="feed-small" alt="'. $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' => '<img src="' . $_main . 'feed.png" class="feed-small" alt="' . $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'] : '<img src="'. $images['icon_quote'] .'" alt="'.$lang['REPLY_WITH_QUOTE_TXTB'].'" title="'. $lang['REPLY_WITH_QUOTE'] .'" />',
'EDIT_POST_IMG' => ($di->config->get('text_buttons')) ? $lang['EDIT_DELETE_POST_TXTB'] : '<img src="'. $images['icon_edit'] .'" alt="'.$lang['EDIT_DELETE_POST_TXTB'].'" title="'. $lang['EDIT_POST'] .'" />',
'DELETE_POST_IMG' => ($di->config->get('text_buttons')) ? $lang['DELETE_POST_TXTB'] : '<img src="'. $images['icon_delpost'] .'" alt="'.$lang['DELETE_POST_TXTB'].'" title="'. $lang['DELETE_POST'] .'" />',
'IP_POST_IMG' => ($di->config->get('text_buttons')) ? $lang['VIEW_IP_TXTB'] : '<img src="'. $images['icon_ip'] .'" alt="'.$lang['VIEW_IP_TXTB'].'" title="'. $lang['VIEW_IP'] .'" />',
'MOD_POST_IMG' => ($di->config->get('text_buttons')) ? $lang['MODERATE_POST_TXTB'] : '<img src="'. $images['icon_mod'] .'" alt="'.$lang['MODERATE_POST_TXTB'].'" title="'. $lang['MODERATE_POST'] .'" />',
'MC_IMG' => ($di->config->get('text_buttons')) ? '['.$lang['COMMENT'].']' : '<img src="'. $images['icon_mc'] .'" alt="['.$lang['COMMENT'].']" title="'.$lang['COMMENT'].'" />',
'POLL_IMG' => ($di->config->get('text_buttons')) ? $lang['TOPIC_POLL'] : '<img src="'. $images['icon_poll'] .'" alt="'.$lang['TOPIC_POLL'] .'" title="'. $lang['ADD_POLL'] .'" />',
'QUOTE_IMG' => ($di->config->get('text_buttons')) ? $lang['REPLY_WITH_QUOTE_TXTB'] : '<img src="' . $images['icon_quote'] . '" alt="' . $lang['REPLY_WITH_QUOTE_TXTB'] . '" title="' . $lang['REPLY_WITH_QUOTE'] . '" />',
'EDIT_POST_IMG' => ($di->config->get('text_buttons')) ? $lang['EDIT_DELETE_POST_TXTB'] : '<img src="' . $images['icon_edit'] . '" alt="' . $lang['EDIT_DELETE_POST_TXTB'] . '" title="' . $lang['EDIT_POST'] . '" />',
'DELETE_POST_IMG' => ($di->config->get('text_buttons')) ? $lang['DELETE_POST_TXTB'] : '<img src="' . $images['icon_delpost'] . '" alt="' . $lang['DELETE_POST_TXTB'] . '" title="' . $lang['DELETE_POST'] . '" />',
'IP_POST_IMG' => ($di->config->get('text_buttons')) ? $lang['VIEW_IP_TXTB'] : '<img src="' . $images['icon_ip'] . '" alt="' . $lang['VIEW_IP_TXTB'] . '" title="' . $lang['VIEW_IP'] . '" />',
'MOD_POST_IMG' => ($di->config->get('text_buttons')) ? $lang['MODERATE_POST_TXTB'] : '<img src="' . $images['icon_mod'] . '" alt="' . $lang['MODERATE_POST_TXTB'] . '" title="' . $lang['MODERATE_POST'] . '" />',
'MC_IMG' => ($di->config->get('text_buttons')) ? '[' . $lang['COMMENT'] . ']' : '<img src="' . $images['icon_mc'] . '" alt="[' . $lang['COMMENT'] . ']" title="' . $lang['COMMENT'] . '" />',
'POLL_IMG' => ($di->config->get('text_buttons')) ? $lang['TOPIC_POLL'] : '<img src="' . $images['icon_poll'] . '" alt="' . $lang['TOPIC_POLL'] . '" title="' . $lang['ADD_POLL'] . '" />',
'QUOTE_URL' => BB_ROOT . POSTING_URL . "?mode=quote&amp;p=",
'EDIT_POST_URL' => BB_ROOT . POSTING_URL . "?mode=editpost&amp;p=",
'QUOTE_URL' => BB_ROOT . POSTING_URL . "?mode=quote&amp;p=",
'EDIT_POST_URL' => BB_ROOT . POSTING_URL . "?mode=editpost&amp;p=",
'DELETE_POST_URL' => BB_ROOT . POSTING_URL . "?mode=delete&amp;p=",
'IP_POST_URL' => BB_ROOT ."modcp.php?mode=ip&amp;p=",
'IP_POST_URL' => BB_ROOT . "modcp.php?mode=ip&amp;p=",
'PROFILE_IMG' => ($di->config->get('text_buttons')) ? $lang['READ_PROFILE_TXTB'] : '<img src="'. $images['icon_profile'] .'" alt="'. $lang['READ_PROFILE_TXTB'] .'" title="'. $lang['READ_PROFILE'] .'" />',
'PM_IMG' => ($di->config->get('text_buttons')) ? $lang['SEND_PM_TXTB'] : '<img src="'. $images['icon_pm'] .'" alt="'. $lang['SEND_PM_TXTB'] .'" title="'. $lang['SEND_PRIVATE_MESSAGE'] .'" />',
'EMAIL_IMG' => ($di->config->get('text_buttons')) ? $lang['SEND_EMAIL_TXTB'] : '<img src="'. $images['icon_email'] .'" alt="'. $lang['SEND_EMAIL_TXTB'] .'" title="'. $lang['SEND_EMAIL'] .'" />',
'WWW_IMG' => ($di->config->get('text_buttons')) ? $lang['VISIT_WEBSITE_TXTB'] : '<img src="'. $images['icon_www'] .'" alt="'.$lang['VISIT_WEBSITE_TXTB'].'" title="'. $lang['VISIT_WEBSITE'] .'" />',
'ICQ_IMG' => ($di->config->get('text_buttons')) ? $lang['ICQ_TXTB'] : '<img src="'. $images['icon_icq'] .'" alt="'.$lang['ICQ_TXTB'].'" title="'. $lang['ICQ'] .'" />',
'PROFILE_IMG' => ($di->config->get('text_buttons')) ? $lang['READ_PROFILE_TXTB'] : '<img src="' . $images['icon_profile'] . '" alt="' . $lang['READ_PROFILE_TXTB'] . '" title="' . $lang['READ_PROFILE'] . '" />',
'PM_IMG' => ($di->config->get('text_buttons')) ? $lang['SEND_PM_TXTB'] : '<img src="' . $images['icon_pm'] . '" alt="' . $lang['SEND_PM_TXTB'] . '" title="' . $lang['SEND_PRIVATE_MESSAGE'] . '" />',
'EMAIL_IMG' => ($di->config->get('text_buttons')) ? $lang['SEND_EMAIL_TXTB'] : '<img src="' . $images['icon_email'] . '" alt="' . $lang['SEND_EMAIL_TXTB'] . '" title="' . $lang['SEND_EMAIL'] . '" />',
'WWW_IMG' => ($di->config->get('text_buttons')) ? $lang['VISIT_WEBSITE_TXTB'] : '<img src="' . $images['icon_www'] . '" alt="' . $lang['VISIT_WEBSITE_TXTB'] . '" title="' . $lang['VISIT_WEBSITE'] . '" />',
'ICQ_IMG' => ($di->config->get('text_buttons')) ? $lang['ICQ_TXTB'] : '<img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ_TXTB'] . '" title="' . $lang['ICQ'] . '" />',
'EMAIL_URL' => BB_ROOT ."profile.php?mode=email&amp;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&amp;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' => '<img src="'. $images['icon_minipost'] .'" class="icon1" alt="'.$lang['POST'].'" />',
'ICON_GOTOPOST' => '<img src="'. $images['icon_gotopost'] .'" class="icon1" alt="'.$lang['GO'].'" title="'. $lang['GOTO_PAGE'] .'" />',
'MINIPOST_IMG_NEW' => '<img src="'. $images['icon_minipost_new'] .'" class="icon1" alt="'.$lang['NEW'].'" />',
'ICON_LATEST_REPLY' => '<img src="'. $images['icon_latest_reply'] .'" class="icon2" alt="'.$lang['LATEST'].'" title="'. $lang['VIEW_LATEST_POST'] .'" />',
'ICON_NEWEST_REPLY' => '<img src="'. $images['icon_newest_reply'] .'" class="icon2" alt="'.$lang['NEWEST'].'" title="'. $lang['VIEW_NEWEST_POST'] .'" />',
'MINIPOST_IMG' => '<img src="' . $images['icon_minipost'] . '" class="icon1" alt="' . $lang['POST'] . '" />',
'ICON_GOTOPOST' => '<img src="' . $images['icon_gotopost'] . '" class="icon1" alt="' . $lang['GO'] . '" title="' . $lang['GOTO_PAGE'] . '" />',
'MINIPOST_IMG_NEW' => '<img src="' . $images['icon_minipost_new'] . '" class="icon1" alt="' . $lang['NEW'] . '" />',
'ICON_LATEST_REPLY' => '<img src="' . $images['icon_latest_reply'] . '" class="icon2" alt="' . $lang['LATEST'] . '" title="' . $lang['VIEW_LATEST_POST'] . '" />',
'ICON_NEWEST_REPLY' => '<img src="' . $images['icon_newest_reply'] . '" class="icon2" alt="' . $lang['NEWEST'] . '" title="' . $lang['VIEW_NEWEST_POST'] . '" />',
));
}
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' => '<img src="'. $images['pm_inbox'] .'" class="pm_box_icon" alt="" />',
'OUTBOX_IMG' => '<img src="'. $images['pm_outbox'] .'" class="pm_box_icon" alt="" />',
'SENTBOX_IMG' => '<img src="'. $images['pm_sentbox'] .'" class="pm_box_icon" alt="" />',
'SAVEBOX_IMG' => '<img src="'. $images['pm_savebox'] .'" class="pm_box_icon" alt="" />',
'INBOX_IMG' => '<img src="' . $images['pm_inbox'] . '" class="pm_box_icon" alt="" />',
'OUTBOX_IMG' => '<img src="' . $images['pm_outbox'] . '" class="pm_box_icon" alt="" />',
'SENTBOX_IMG' => '<img src="' . $images['pm_sentbox'] . '" class="pm_box_icon" alt="" />',
'SAVEBOX_IMG' => '<img src="' . $images['pm_savebox'] . '" class="pm_box_icon" alt="" />',
));
}
}