mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 22:33:55 -07:00
PHPDoc and some reformat fixes.
This commit is contained in:
parent
21f9ef22fc
commit
79ea41b3f4
49 changed files with 2510 additions and 1049 deletions
|
@ -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>')
|
'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;
|
$sql = "SELECT * FROM " . BB_CONFIG;
|
||||||
if (!$result = DB()->sql_query($sql)) {
|
if (!$result = DB()->sql_query($sql)) {
|
||||||
bb_die('Could not query config information in admin_board');
|
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];
|
$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 (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]));
|
$new[$config_name] = serialize(str_replace(',', '.', $new[$config_name]));
|
||||||
}
|
}
|
||||||
bb_update_config(array($config_name => $new[$config_name]));
|
bb_update_config(array($config_name => $new[$config_name]));
|
||||||
|
|
|
@ -14,9 +14,11 @@ require(INC_DIR . 'functions_admin_torrent.php');
|
||||||
$submit = isset($_POST['submit']);
|
$submit = isset($_POST['submit']);
|
||||||
$confirm = isset($_POST['confirm']);
|
$confirm = isset($_POST['confirm']);
|
||||||
|
|
||||||
$cfg = array();
|
$cfg = [];
|
||||||
|
|
||||||
// All config names with default values
|
/**
|
||||||
|
* All config names with default values
|
||||||
|
*/
|
||||||
$default_cfg_str = array(
|
$default_cfg_str = array(
|
||||||
'bt_announce_url' => 'http://demo.torrentpier.me/bt/',
|
'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
|
'self_moderated' => 0, // Users can move theirs topic to another forum
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get config
|
/**
|
||||||
|
* Get config
|
||||||
|
*/
|
||||||
$cfg = bb_get_config(BB_CONFIG, true, false);
|
$cfg = bb_get_config(BB_CONFIG, true, false);
|
||||||
|
|
||||||
// Submit new config
|
/**
|
||||||
|
* Submit new config
|
||||||
|
*/
|
||||||
if ($submit && $confirm) {
|
if ($submit && $confirm) {
|
||||||
foreach ($db_fields_bool as $field_name => $field_def_val) {
|
foreach ($db_fields_bool as $field_name => $field_def_val) {
|
||||||
update_table_bool(BB_FORUMS, 'forum_id', $field_name, $field_def_val);
|
update_table_bool(BB_FORUMS, 'forum_id', $field_name, $field_def_val);
|
||||||
|
|
|
@ -20,7 +20,9 @@ require(INC_DIR . 'functions_admin_torrent.php');
|
||||||
$submit = isset($_POST['submit']);
|
$submit = isset($_POST['submit']);
|
||||||
$confirmed = isset($_POST['confirm']);
|
$confirmed = isset($_POST['confirm']);
|
||||||
|
|
||||||
// All config names with default values
|
/**
|
||||||
|
* All config names with default values
|
||||||
|
*/
|
||||||
$default_cfg_str = array(
|
$default_cfg_str = array(
|
||||||
'off_reason' => 'Tracker is disabled',
|
'off_reason' => 'Tracker is disabled',
|
||||||
'browser_redirect_url' => 'http://demo.torrentpier.me/',
|
'browser_redirect_url' => 'http://demo.torrentpier.me/',
|
||||||
|
@ -46,7 +48,9 @@ $default_cfg_num = array(
|
||||||
'limit_leech_ips' => 0,
|
'limit_leech_ips' => 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set template vars
|
/**
|
||||||
|
* Set template vars
|
||||||
|
*/
|
||||||
set_tpl_vars($default_cfg_str, $tr_cfg);
|
set_tpl_vars($default_cfg_str, $tr_cfg);
|
||||||
set_tpl_vars_lang($default_cfg_str);
|
set_tpl_vars_lang($default_cfg_str);
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,9 @@ if (isset($_POST['add_name'])) {
|
||||||
bb_die($message);
|
bb_die($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/**
|
||||||
// Grab the current list of disallowed usernames...
|
* Grab the current list of disallowed usernames
|
||||||
//
|
*/
|
||||||
$sql = "SELECT * FROM " . BB_DISALLOW;
|
$sql = "SELECT * FROM " . BB_DISALLOW;
|
||||||
$result = DB()->sql_query($sql);
|
$result = DB()->sql_query($sql);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
|
@ -55,10 +55,9 @@ if (!$result) {
|
||||||
|
|
||||||
$disallowed = DB()->sql_fetchrowset($result);
|
$disallowed = DB()->sql_fetchrowset($result);
|
||||||
|
|
||||||
//
|
/**
|
||||||
// Ok now generate the info for the template, which will be put out no matter
|
* Now generate the info for the template, which will be put out no matter what mode we are in
|
||||||
// what mode we are in.
|
*/
|
||||||
//
|
|
||||||
$disallow_select = '<select name="disallowed_id">';
|
$disallow_select = '<select name="disallowed_id">';
|
||||||
|
|
||||||
if (count($disallowed) <= 0) {
|
if (count($disallowed) <= 0) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ if (!empty($setmodules)) {
|
||||||
}
|
}
|
||||||
require('./pagestart.php');
|
require('./pagestart.php');
|
||||||
|
|
||||||
$forum_auth_fields = array(
|
$forum_auth_fields = [
|
||||||
'auth_view',
|
'auth_view',
|
||||||
'auth_read',
|
'auth_read',
|
||||||
'auth_reply',
|
'auth_reply',
|
||||||
|
@ -19,27 +19,20 @@ $forum_auth_fields = array(
|
||||||
'auth_post',
|
'auth_post',
|
||||||
'auth_sticky',
|
'auth_sticky',
|
||||||
'auth_announce',
|
'auth_announce',
|
||||||
);
|
];
|
||||||
|
|
||||||
// View Read Reply Edit Delete Vote Poll PostAttach DownAttach PostTopic Sticky Announce
|
// View Read Reply Edit Delete Vote Poll PostAttach DownAttach PostTopic Sticky Announce
|
||||||
$simple_auth_ary = array(
|
$simple_auth_ary = [
|
||||||
/* Public */
|
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
|
||||||
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
|
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
|
||||||
/* Reg */
|
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]
|
||||||
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
|
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
|
||||||
/* Reg [Hid] */
|
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]
|
||||||
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]
|
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
|
||||||
/* Priv */
|
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]
|
||||||
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_types = array(
|
$simple_auth_types = [
|
||||||
$lang['PUBLIC'],
|
$lang['PUBLIC'],
|
||||||
$lang['REGISTERED'],
|
$lang['REGISTERED'],
|
||||||
$lang['REGISTERED'] . ' [' . $lang['HIDDEN'] . ']',
|
$lang['REGISTERED'] . ' [' . $lang['HIDDEN'] . ']',
|
||||||
|
@ -47,15 +40,15 @@ $simple_auth_types = array(
|
||||||
$lang['PRIVATE'] . ' [' . $lang['HIDDEN'] . ']',
|
$lang['PRIVATE'] . ' [' . $lang['HIDDEN'] . ']',
|
||||||
$lang['MODERATORS'],
|
$lang['MODERATORS'],
|
||||||
$lang['MODERATORS'] . ' [' . $lang['HIDDEN'] . ']',
|
$lang['MODERATORS'] . ' [' . $lang['HIDDEN'] . ']',
|
||||||
);
|
];
|
||||||
|
|
||||||
$field_names = array();
|
$field_names = [];
|
||||||
foreach ($forum_auth_fields as $auth_type) {
|
foreach ($forum_auth_fields as $auth_type) {
|
||||||
$field_names[$auth_type] = $lang[strtoupper($auth_type)];
|
$field_names[$auth_type] = $lang[strtoupper($auth_type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
$forum_auth_levels = array('ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN');
|
$forum_auth_levels = ['ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN'];
|
||||||
$forum_auth_const = array(AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_ADMIN);
|
$forum_auth_const = [AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_ADMIN];
|
||||||
|
|
||||||
if ($_REQUEST[POST_FORUM_URL]) {
|
if ($_REQUEST[POST_FORUM_URL]) {
|
||||||
$forum_id = (int)$_REQUEST[POST_FORUM_URL];
|
$forum_id = (int)$_REQUEST[POST_FORUM_URL];
|
||||||
|
@ -71,9 +64,9 @@ if (isset($_GET['adv'])) {
|
||||||
unset($adv);
|
unset($adv);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/**
|
||||||
// Start program proper
|
* Start program proper
|
||||||
//
|
*/
|
||||||
if (isset($_POST['submit'])) {
|
if (isset($_POST['submit'])) {
|
||||||
$sql = '';
|
$sql = '';
|
||||||
|
|
||||||
|
@ -116,13 +109,11 @@ if (isset($_POST['submit'])) {
|
||||||
|
|
||||||
$datastore->update('cat_forums');
|
$datastore->update('cat_forums');
|
||||||
bb_die($lang['FORUM_AUTH_UPDATED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_FORUMAUTH'], '<a href="' . "admin_forumauth.php" . '">', "</a>"));
|
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
|
* Get required information
|
||||||
// no id was specified or just the requsted if it
|
*/
|
||||||
// was
|
|
||||||
//
|
|
||||||
$forum_rows = DB()->fetch_rowset("SELECT * FROM " . BB_FORUMS . " $forum_sql");
|
$forum_rows = DB()->fetch_rowset("SELECT * FROM " . BB_FORUMS . " $forum_sql");
|
||||||
|
|
||||||
if (empty($forum_id)) {
|
if (empty($forum_id)) {
|
||||||
|
@ -179,10 +170,7 @@ if (empty($forum_id)) {
|
||||||
|
|
||||||
$s_column_span++;
|
$s_column_span++;
|
||||||
} else {
|
} else {
|
||||||
//
|
// Output values of individual fields
|
||||||
// Output values of individual
|
|
||||||
// fields
|
|
||||||
//
|
|
||||||
for ($j = 0; $j < count($forum_auth_fields); $j++) {
|
for ($j = 0; $j < count($forum_auth_fields); $j++) {
|
||||||
$custom_auth[$j] = ' <select name="' . $forum_auth_fields[$j] . '">';
|
$custom_auth[$j] = ' <select name="' . $forum_auth_fields[$j] . '">';
|
||||||
|
|
||||||
|
|
|
@ -7,24 +7,17 @@ if (!empty($setmodules)) {
|
||||||
require('./pagestart.php');
|
require('./pagestart.php');
|
||||||
|
|
||||||
// View Read Post Reply Edit Delete Sticky Announce Vote Poll PostAttach Download
|
// View Read Post Reply Edit Delete Sticky Announce Vote Poll PostAttach Download
|
||||||
$simple_auth_ary = array(
|
$simple_auth_ary = [
|
||||||
/* Public */
|
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
|
||||||
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
|
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
|
||||||
/* Reg */
|
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]
|
||||||
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
|
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
|
||||||
/* Reg [Hid] */
|
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]
|
||||||
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]
|
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
|
||||||
/* Priv */
|
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]
|
||||||
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_types = array(
|
$simple_auth_types = [
|
||||||
$lang['PUBLIC'],
|
$lang['PUBLIC'],
|
||||||
$lang['REGISTERED'],
|
$lang['REGISTERED'],
|
||||||
$lang['REGISTERED'] . ' [' . $lang['HIDDEN'] . ']',
|
$lang['REGISTERED'] . ' [' . $lang['HIDDEN'] . ']',
|
||||||
|
@ -32,9 +25,9 @@ $simple_auth_types = array(
|
||||||
$lang['PRIVATE'] . ' [' . $lang['HIDDEN'] . ']',
|
$lang['PRIVATE'] . ' [' . $lang['HIDDEN'] . ']',
|
||||||
$lang['MODERATORS'],
|
$lang['MODERATORS'],
|
||||||
$lang['MODERATORS'] . ' [' . $lang['HIDDEN'] . ']',
|
$lang['MODERATORS'] . ' [' . $lang['HIDDEN'] . ']',
|
||||||
);
|
];
|
||||||
|
|
||||||
$forum_auth_fields = array(
|
$forum_auth_fields = [
|
||||||
'auth_view',
|
'auth_view',
|
||||||
'auth_read',
|
'auth_read',
|
||||||
'auth_reply',
|
'auth_reply',
|
||||||
|
@ -47,15 +40,15 @@ $forum_auth_fields = array(
|
||||||
'auth_post',
|
'auth_post',
|
||||||
'auth_sticky',
|
'auth_sticky',
|
||||||
'auth_announce',
|
'auth_announce',
|
||||||
);
|
];
|
||||||
|
|
||||||
$field_names = array();
|
$field_names = [];
|
||||||
foreach ($forum_auth_fields as $auth_type) {
|
foreach ($forum_auth_fields as $auth_type) {
|
||||||
$field_names[$auth_type] = $lang[strtoupper($auth_type)];
|
$field_names[$auth_type] = $lang[strtoupper($auth_type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
$forum_auth_levels = array('ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN');
|
$forum_auth_levels = ['ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN'];
|
||||||
$forum_auth_const = array(AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_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])) {
|
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]);
|
$forum_id = (isset($_POST[POST_FORUM_URL])) ? intval($_POST[POST_FORUM_URL]) : intval($_GET[POST_FORUM_URL]);
|
||||||
|
|
|
@ -18,7 +18,7 @@ array_deep($_POST, 'trim');
|
||||||
|
|
||||||
$s = '';
|
$s = '';
|
||||||
|
|
||||||
$default_forum_auth = array(
|
$default_forum_auth = [
|
||||||
'auth_view' => AUTH_ALL,
|
'auth_view' => AUTH_ALL,
|
||||||
'auth_read' => AUTH_ALL,
|
'auth_read' => AUTH_ALL,
|
||||||
'auth_post' => AUTH_REG,
|
'auth_post' => AUTH_REG,
|
||||||
|
@ -31,7 +31,7 @@ $default_forum_auth = array(
|
||||||
'auth_pollcreate' => AUTH_REG,
|
'auth_pollcreate' => AUTH_REG,
|
||||||
'auth_attachments' => AUTH_REG,
|
'auth_attachments' => AUTH_REG,
|
||||||
'auth_download' => AUTH_REG,
|
'auth_download' => AUTH_REG,
|
||||||
);
|
];
|
||||||
|
|
||||||
$mode = ($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : '';
|
$mode = ($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : '';
|
||||||
|
|
||||||
|
@ -766,7 +766,11 @@ if (!$mode || $show_main_page) {
|
||||||
|
|
||||||
print_page('admin_forums.tpl', 'admin');
|
print_page('admin_forums.tpl', 'admin');
|
||||||
|
|
||||||
// Functions
|
/**
|
||||||
|
* @param $mode
|
||||||
|
* @param $id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
function get_info($mode, $id)
|
function get_info($mode, $id)
|
||||||
{
|
{
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
|
@ -806,6 +810,12 @@ function get_info($mode, $id)
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $mode
|
||||||
|
* @param $id
|
||||||
|
* @param $select
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function get_list($mode, $id, $select)
|
function get_list($mode, $id, $select)
|
||||||
{
|
{
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
|
@ -851,6 +861,10 @@ function get_list($mode, $id, $select)
|
||||||
return ($catlist);
|
return ($catlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $mode
|
||||||
|
* @param int $cat
|
||||||
|
*/
|
||||||
function renumber_order($mode, $cat = 0)
|
function renumber_order($mode, $cat = 0)
|
||||||
{
|
{
|
||||||
switch ($mode) {
|
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)
|
function get_cat_forums($cat_id = false)
|
||||||
{
|
{
|
||||||
$forums = array();
|
$forums = array();
|
||||||
|
@ -928,6 +946,10 @@ function get_cat_forums($cat_id = false)
|
||||||
return $forums;
|
return $forums;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $forum_id
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function get_sf_count($forum_id)
|
function get_sf_count($forum_id)
|
||||||
{
|
{
|
||||||
global $cat_forums;
|
global $cat_forums;
|
||||||
|
@ -945,6 +967,11 @@ function get_sf_count($forum_id)
|
||||||
return $sf_count;
|
return $sf_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $forums
|
||||||
|
* @param $curr_forum_order
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
function get_prev_root_forum_id($forums, $curr_forum_order)
|
function get_prev_root_forum_id($forums, $curr_forum_order)
|
||||||
{
|
{
|
||||||
$i = $curr_forum_order - 10;
|
$i = $curr_forum_order - 10;
|
||||||
|
@ -959,6 +986,11 @@ function get_prev_root_forum_id($forums, $curr_forum_order)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $forums
|
||||||
|
* @param $curr_forum_order
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
function get_next_root_forum_id($forums, $curr_forum_order)
|
function get_next_root_forum_id($forums, $curr_forum_order)
|
||||||
{
|
{
|
||||||
$i = $curr_forum_order + 10;
|
$i = $curr_forum_order + 10;
|
||||||
|
@ -974,6 +1006,9 @@ function get_next_root_forum_id($forums, $curr_forum_order)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function get_orphan_sf()
|
function get_orphan_sf()
|
||||||
{
|
{
|
||||||
global $cat_forums;
|
global $cat_forums;
|
||||||
|
@ -996,6 +1031,11 @@ function get_orphan_sf()
|
||||||
return implode(',', $bad_sf_ary);
|
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)
|
function fix_orphan_sf($orphan_sf_sql = '', $show_mess = false)
|
||||||
{
|
{
|
||||||
global $lang;
|
global $lang;
|
||||||
|
@ -1028,6 +1068,12 @@ function fix_orphan_sf($orphan_sf_sql = '', $show_mess = false)
|
||||||
return $done_mess;
|
return $done_mess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $mode
|
||||||
|
* @param int $exclude
|
||||||
|
* @param int $select
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function sf_get_list($mode, $exclude = 0, $select = 0)
|
function sf_get_list($mode, $exclude = 0, $select = 0)
|
||||||
{
|
{
|
||||||
global $cat_forums, $forum_parent;
|
global $cat_forums, $forum_parent;
|
||||||
|
@ -1052,6 +1098,10 @@ function sf_get_list($mode, $exclude = 0, $select = 0)
|
||||||
return $opt;
|
return $opt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $forum_id
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
function get_forum_data($forum_id)
|
function get_forum_data($forum_id)
|
||||||
{
|
{
|
||||||
global $cat_forums;
|
global $cat_forums;
|
||||||
|
@ -1067,6 +1117,10 @@ function get_forum_data($forum_id)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $cat_id
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function get_max_forum_order($cat_id)
|
function get_max_forum_order($cat_id)
|
||||||
{
|
{
|
||||||
$row = DB()->fetch_row("
|
$row = DB()->fetch_row("
|
||||||
|
@ -1078,6 +1132,12 @@ function get_max_forum_order($cat_id)
|
||||||
return intval($row['max_forum_order']);
|
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)
|
function check_name_dup($mode, $name, $die_on_error = true)
|
||||||
{
|
{
|
||||||
$name_sql = DB()->escape($name);
|
$name_sql = DB()->escape($name);
|
||||||
|
|
|
@ -25,7 +25,7 @@ if (!empty($_POST['edit']) || !empty($_POST['new'])) {
|
||||||
'release_group' => $row['release_group'],
|
'release_group' => $row['release_group'],
|
||||||
);
|
);
|
||||||
$mode = 'editgroup';
|
$mode = 'editgroup';
|
||||||
$template->assign_block_vars('group_edit', array());
|
$template->assign_block_vars('group_edit', []);
|
||||||
} elseif (!empty($_POST['new'])) {
|
} elseif (!empty($_POST['new'])) {
|
||||||
$group_info = array(
|
$group_info = array(
|
||||||
'group_name' => '',
|
'group_name' => '',
|
||||||
|
|
|
@ -15,7 +15,7 @@ $subject = (string)trim(request_var('subject', ''));
|
||||||
$message = (string)request_var('message', '');
|
$message = (string)request_var('message', '');
|
||||||
$group_id = (int)request_var(POST_GROUPS_URL, 0);
|
$group_id = (int)request_var(POST_GROUPS_URL, 0);
|
||||||
|
|
||||||
$errors = $user_id_sql = array();
|
$errors = $user_id_sql = [];
|
||||||
|
|
||||||
if (isset($_POST['submit'])) {
|
if (isset($_POST['submit'])) {
|
||||||
if (!$subject) {
|
if (!$subject) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ if (!IS_ADMIN) {
|
||||||
bb_die($lang['NOT_AUTHORISED']);
|
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;
|
$peers_in_last_sec_limit = 300;
|
||||||
|
|
||||||
$announce_interval = intval($di->config->get('announce_interval'));
|
$announce_interval = intval($di->config->get('announce_interval'));
|
||||||
|
|
|
@ -170,9 +170,6 @@ function msg_die($msg)
|
||||||
die($output);
|
die($output);
|
||||||
}
|
}
|
||||||
|
|
||||||
# $agent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '-';
|
|
||||||
# bb_log("$agent | ". str_compact($peer_id) ."\n", 'agent');
|
|
||||||
|
|
||||||
// Start announcer
|
// Start announcer
|
||||||
define('TR_ROOT', './');
|
define('TR_ROOT', './');
|
||||||
require(TR_ROOT . 'includes/init_tr.php');
|
require(TR_ROOT . 'includes/init_tr.php');
|
||||||
|
|
|
@ -83,6 +83,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
* @param $cfg_values
|
||||||
|
* @return sql_db
|
||||||
*/
|
*/
|
||||||
public function sql_db($cfg_values)
|
public function sql_db($cfg_values)
|
||||||
{
|
{
|
||||||
|
@ -173,6 +175,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base query method
|
* Base query method
|
||||||
|
* @param $query
|
||||||
|
* @return null|resource
|
||||||
*/
|
*/
|
||||||
public function sql_query($query)
|
public function sql_query($query)
|
||||||
{
|
{
|
||||||
|
@ -197,6 +201,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute query WRAPPER (with error handling)
|
* Execute query WRAPPER (with error handling)
|
||||||
|
* @param $query
|
||||||
|
* @return null|resource
|
||||||
*/
|
*/
|
||||||
public function query($query)
|
public function query($query)
|
||||||
{
|
{
|
||||||
|
@ -209,6 +215,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return number of rows
|
* Return number of rows
|
||||||
|
* @param bool $result
|
||||||
|
* @return bool|int
|
||||||
*/
|
*/
|
||||||
public function num_rows($result = false)
|
public function num_rows($result = false)
|
||||||
{
|
{
|
||||||
|
@ -231,6 +239,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch current row
|
* Fetch current row
|
||||||
|
* @param $result
|
||||||
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
public function sql_fetchrow($result)
|
public function sql_fetchrow($result)
|
||||||
{
|
{
|
||||||
|
@ -239,6 +249,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alias of sql_fetchrow()
|
* Alias of sql_fetchrow()
|
||||||
|
* @param $result
|
||||||
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
public function fetch_next($result)
|
public function fetch_next($result)
|
||||||
{
|
{
|
||||||
|
@ -247,6 +259,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch row WRAPPER (with error handling)
|
* Fetch row WRAPPER (with error handling)
|
||||||
|
* @param $query
|
||||||
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
public function fetch_row($query)
|
public function fetch_row($query)
|
||||||
{
|
{
|
||||||
|
@ -259,6 +273,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch all rows
|
* Fetch all rows
|
||||||
|
* @param $result
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function sql_fetchrowset($result)
|
public function sql_fetchrowset($result)
|
||||||
{
|
{
|
||||||
|
@ -273,6 +289,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch all rows WRAPPER (with error handling)
|
* Fetch all rows WRAPPER (with error handling)
|
||||||
|
* @param $query
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function fetch_rowset($query)
|
public function fetch_rowset($query)
|
||||||
{
|
{
|
||||||
|
@ -285,6 +303,9 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Escape string used in sql query
|
* Escape string used in sql query
|
||||||
|
* @param $v
|
||||||
|
* @param bool $check_type
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escape($v, $check_type = false)
|
public function escape($v, $check_type = false)
|
||||||
{
|
{
|
||||||
|
@ -371,6 +392,7 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store debug info
|
* Store debug info
|
||||||
|
* @param $mode
|
||||||
*/
|
*/
|
||||||
public function debug($mode)
|
public function debug($mode)
|
||||||
{
|
{
|
||||||
|
@ -405,6 +427,7 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trigger error
|
* Trigger error
|
||||||
|
* @param string $msg
|
||||||
*/
|
*/
|
||||||
public function trigger_error($msg = '')
|
public function trigger_error($msg = '')
|
||||||
{
|
{
|
||||||
|
|
|
@ -131,6 +131,8 @@ $DBS = new DBS([
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: @deprecated
|
* TODO: @deprecated
|
||||||
|
* @param string $db_alias
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function DB($db_alias = 'db')
|
function DB($db_alias = 'db')
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,10 @@ if (($file_contents = @file_get_contents($file_path)) === false) {
|
||||||
// Построение списка
|
// Построение списка
|
||||||
$tor_filelist = build_tor_filelist($file_contents);
|
$tor_filelist = build_tor_filelist($file_contents);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $file_contents
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function build_tor_filelist($file_contents)
|
function build_tor_filelist($file_contents)
|
||||||
{
|
{
|
||||||
global $lang;
|
global $lang;
|
||||||
|
@ -41,6 +45,9 @@ function build_tor_filelist($file_contents)
|
||||||
return $torrent->get_filelist();
|
return $torrent->get_filelist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class torrent
|
||||||
|
*/
|
||||||
class torrent
|
class torrent
|
||||||
{
|
{
|
||||||
public $tor_decoded = array();
|
public $tor_decoded = array();
|
||||||
|
@ -49,11 +56,19 @@ class torrent
|
||||||
public $root_dir = '';
|
public $root_dir = '';
|
||||||
public $files_html = '';
|
public $files_html = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* torrent constructor.
|
||||||
|
* @param $decoded_file_contents
|
||||||
|
* @return torrent
|
||||||
|
*/
|
||||||
public function torrent($decoded_file_contents)
|
public function torrent($decoded_file_contents)
|
||||||
{
|
{
|
||||||
$this->tor_decoded = $decoded_file_contents;
|
$this->tor_decoded = $decoded_file_contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function get_filelist()
|
public function get_filelist()
|
||||||
{
|
{
|
||||||
$this->build_filelist_array();
|
$this->build_filelist_array();
|
||||||
|
@ -70,6 +85,9 @@ class torrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Torrent file list builder
|
||||||
|
*/
|
||||||
public function build_filelist_array()
|
public function build_filelist_array()
|
||||||
{
|
{
|
||||||
$info = $this->tor_decoded['info'];
|
$info = $this->tor_decoded['info'];
|
||||||
|
@ -131,6 +149,11 @@ class torrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
* @param $length
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function build_file_item($name, $length)
|
public function build_file_item($name, $length)
|
||||||
{
|
{
|
||||||
global $images, $lang;
|
global $images, $lang;
|
||||||
|
@ -148,6 +171,9 @@ class torrent
|
||||||
return "$name <i>$length</i> $magnet_name $magnet_ext";
|
return "$name <i>$length</i> $magnet_name $magnet_ext";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function build_filelist_html()
|
public function build_filelist_html()
|
||||||
{
|
{
|
||||||
global $html;
|
global $html;
|
||||||
|
@ -155,6 +181,10 @@ class torrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $dirname
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
function clean_tor_dirname($dirname)
|
function clean_tor_dirname($dirname)
|
||||||
{
|
{
|
||||||
return str_replace(array('[', ']', '<', '>', "'"), array('[', ']', '<', '>', '''), $dirname);
|
return str_replace(array('[', ']', '<', '>', "'"), array('[', ']', '<', '>', '''), $dirname);
|
||||||
|
|
|
@ -13,6 +13,9 @@ $page_cfg['include_bbcode_js'] = true;
|
||||||
//
|
//
|
||||||
// BBCode templates
|
// BBCode templates
|
||||||
//
|
//
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
function get_bbcode_tpl()
|
function get_bbcode_tpl()
|
||||||
{
|
{
|
||||||
$bbcode_tpl = array();
|
$bbcode_tpl = array();
|
||||||
|
@ -79,6 +82,10 @@ HTML;
|
||||||
return $bbcode_tpl;
|
return $bbcode_tpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $text
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
function bbcode_tpl_compact($text)
|
function bbcode_tpl_compact($text)
|
||||||
{
|
{
|
||||||
$text = str_compact($text);
|
$text = str_compact($text);
|
||||||
|
@ -87,6 +94,10 @@ function bbcode_tpl_compact($text)
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare a posted message for entry into the database
|
// prepare a posted message for entry into the database
|
||||||
|
/**
|
||||||
|
* @param $message
|
||||||
|
* @return mixed|string
|
||||||
|
*/
|
||||||
function prepare_message($message)
|
function prepare_message($message)
|
||||||
{
|
{
|
||||||
$message = bbcode::clean_up($message);
|
$message = bbcode::clean_up($message);
|
||||||
|
@ -96,6 +107,9 @@ function prepare_message($message)
|
||||||
|
|
||||||
// Fill smiley templates (or just the variables) with smileys
|
// Fill smiley templates (or just the variables) with smileys
|
||||||
// Either in a window or inline
|
// Either in a window or inline
|
||||||
|
/**
|
||||||
|
* @param $mode
|
||||||
|
*/
|
||||||
function generate_smilies($mode)
|
function generate_smilies($mode)
|
||||||
{
|
{
|
||||||
global $template, $lang, $datastore;
|
global $template, $lang, $datastore;
|
||||||
|
@ -314,6 +328,10 @@ function strip_bbcode($message, $stripquotes = true, $fast_and_dirty = false, $s
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $text
|
||||||
|
* @return mixed|string
|
||||||
|
*/
|
||||||
function extract_search_words($text)
|
function extract_search_words($text)
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
@ -365,6 +383,10 @@ function extract_search_words($text)
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $text
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
function replace_synonyms($text)
|
function replace_synonyms($text)
|
||||||
{
|
{
|
||||||
static $syn_match = null, $syn_replace = null;
|
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;
|
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)
|
function add_search_words($post_id, $post_message, $topic_title = '', $only_return_words = false)
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
@ -401,6 +430,9 @@ function add_search_words($post_id, $post_message, $topic_title = '', $only_retu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class bbcode
|
||||||
|
*/
|
||||||
class bbcode
|
class bbcode
|
||||||
{
|
{
|
||||||
public $tpl = array(); // шаблоны для замены тегов
|
public $tpl = array(); // шаблоны для замены тегов
|
||||||
|
@ -813,6 +845,10 @@ class bbcode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $text
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function bbcode2html($text)
|
function bbcode2html($text)
|
||||||
{
|
{
|
||||||
global $bbcode;
|
global $bbcode;
|
||||||
|
@ -829,6 +865,9 @@ function bbcode2html($text)
|
||||||
return $bbcode->bbcode2html($text);
|
return $bbcode->bbcode2html($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class words_rate
|
||||||
|
*/
|
||||||
class words_rate
|
class words_rate
|
||||||
{
|
{
|
||||||
public $dbg_mode = false;
|
public $dbg_mode = false;
|
||||||
|
@ -903,6 +942,10 @@ class words_rate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $text
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function get_words_rate($text)
|
function get_words_rate($text)
|
||||||
{
|
{
|
||||||
static $wr = null;
|
static $wr = null;
|
||||||
|
@ -912,6 +955,10 @@ function get_words_rate($text)
|
||||||
return $wr->get_words_rate($text);
|
return $wr->get_words_rate($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $str
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
function hide_passkey($str)
|
function hide_passkey($str)
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @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);
|
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)
|
function get_parsed_post($postrow, $mode = 'full', $return_chars = 600)
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
@ -942,6 +995,9 @@ function get_parsed_post($postrow, $mode = 'full', $return_chars = 600)
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $postrow
|
||||||
|
*/
|
||||||
function update_post_html($postrow)
|
function update_post_html($postrow)
|
||||||
{
|
{
|
||||||
DB()->query("DELETE FROM " . BB_POSTS_HTML . " WHERE post_id = " . (int)$postrow['post_id'] . " LIMIT 1");
|
DB()->query("DELETE FROM " . BB_POSTS_HTML . " WHERE post_id = " . (int)$postrow['post_id'] . " LIMIT 1");
|
||||||
|
|
|
@ -13,6 +13,11 @@ class emailer
|
||||||
public $tpl_msg = array();
|
public $tpl_msg = array();
|
||||||
public $vars = array();
|
public $vars = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* emailer constructor.
|
||||||
|
* @param $use_smtp
|
||||||
|
* @return emailer
|
||||||
|
*/
|
||||||
public function emailer($use_smtp/*$tpl_name, $sbj, $to_address*/)
|
public function emailer($use_smtp/*$tpl_name, $sbj, $to_address*/)
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
@ -24,6 +29,9 @@ class emailer
|
||||||
$this->use_smtp = $use_smtp;
|
$this->use_smtp = $use_smtp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Установка стандартных замен в письмах
|
||||||
|
*/
|
||||||
public function set_default_vars()
|
public function set_default_vars()
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
@ -37,6 +45,9 @@ class emailer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resets all the data (address, template file, etc etc to default
|
// Resets all the data (address, template file, etc etc to default
|
||||||
|
/**
|
||||||
|
* Сброс
|
||||||
|
*/
|
||||||
public function reset()
|
public function reset()
|
||||||
{
|
{
|
||||||
$this->addresses = array();
|
$this->addresses = array();
|
||||||
|
@ -45,43 +56,69 @@ class emailer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets an email address to send to
|
// Sets an email address to send to
|
||||||
|
/**
|
||||||
|
* @param $address
|
||||||
|
*/
|
||||||
public function email_address($address)
|
public function email_address($address)
|
||||||
{
|
{
|
||||||
$this->addresses['to'] = trim($address);
|
$this->addresses['to'] = trim($address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $address
|
||||||
|
*/
|
||||||
public function cc($address)
|
public function cc($address)
|
||||||
{
|
{
|
||||||
$this->addresses['cc'][] = trim($address);
|
$this->addresses['cc'][] = trim($address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $address
|
||||||
|
*/
|
||||||
public function bcc($address)
|
public function bcc($address)
|
||||||
{
|
{
|
||||||
$this->addresses['bcc'][] = trim($address);
|
$this->addresses['bcc'][] = trim($address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $address
|
||||||
|
*/
|
||||||
public function replyto($address)
|
public function replyto($address)
|
||||||
{
|
{
|
||||||
$this->reply_to = trim($address);
|
$this->reply_to = trim($address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $address
|
||||||
|
*/
|
||||||
public function from($address)
|
public function from($address)
|
||||||
{
|
{
|
||||||
$this->from = trim($address);
|
$this->from = trim($address);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up subject for mail
|
// set up subject for mail
|
||||||
|
/**
|
||||||
|
* @param string $subject
|
||||||
|
*/
|
||||||
public function set_subject($subject = '')
|
public function set_subject($subject = '')
|
||||||
{
|
{
|
||||||
$this->subject = trim(preg_replace('#[\n\r]+#s', '', $subject));
|
$this->subject = trim(preg_replace('#[\n\r]+#s', '', $subject));
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up extra mail headers
|
// set up extra mail headers
|
||||||
|
/**
|
||||||
|
* @param $headers
|
||||||
|
*/
|
||||||
public function extra_headers($headers)
|
public function extra_headers($headers)
|
||||||
{
|
{
|
||||||
$this->extra_headers .= trim($headers) . "\n";
|
$this->extra_headers .= trim($headers) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $template_file
|
||||||
|
* @param string $template_lang
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function use_template($template_file, $template_lang = '')
|
public function use_template($template_file, $template_lang = '')
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
@ -120,12 +157,19 @@ class emailer
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign variables
|
// assign variables
|
||||||
|
/**
|
||||||
|
* @param $vars
|
||||||
|
*/
|
||||||
public function assign_vars($vars)
|
public function assign_vars($vars)
|
||||||
{
|
{
|
||||||
$this->vars = array_merge($this->vars, $vars);
|
$this->vars = array_merge($this->vars, $vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the mail out to the recipients set previously in var $this->address
|
// 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')
|
public function send($email_format = 'text')
|
||||||
{
|
{
|
||||||
global $userdata;
|
global $userdata;
|
||||||
|
@ -208,6 +252,10 @@ class emailer
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $str
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function encode($str)
|
public function encode($str)
|
||||||
{
|
{
|
||||||
if ($this->encoding == '') {
|
if ($this->encoding == '') {
|
||||||
|
|
|
@ -13,11 +13,17 @@ class sitemap
|
||||||
public $priority = '0.6';
|
public $priority = '0.6';
|
||||||
public $cat_priority = '0.7';
|
public $cat_priority = '0.7';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sitemap constructor.
|
||||||
|
*/
|
||||||
public function sitemap()
|
public function sitemap()
|
||||||
{
|
{
|
||||||
$this->home = make_url();
|
$this->home = make_url();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function build_map()
|
public function build_map()
|
||||||
{
|
{
|
||||||
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
|
$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;
|
return $map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $count
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function build_index($count)
|
public function build_index($count)
|
||||||
{
|
{
|
||||||
$lm = date('c');
|
$lm = date('c');
|
||||||
|
@ -43,6 +53,9 @@ class sitemap
|
||||||
return $map;
|
return $map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function build_stat()
|
public function build_stat()
|
||||||
{
|
{
|
||||||
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
|
$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;
|
return $map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $n
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function build_map_topic($n)
|
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";
|
$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 $map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function get_forum()
|
public function get_forum()
|
||||||
{
|
{
|
||||||
global $datastore;
|
global $datastore;
|
||||||
|
@ -92,6 +112,10 @@ class sitemap
|
||||||
return $xml;
|
return $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $page
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function get_topic($page = false)
|
public function get_topic($page = false)
|
||||||
{
|
{
|
||||||
global $datastore;
|
global $datastore;
|
||||||
|
@ -136,6 +160,9 @@ class sitemap
|
||||||
return $xml;
|
return $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function get_static()
|
public function get_static()
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
@ -161,6 +188,11 @@ class sitemap
|
||||||
return $xml;
|
return $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $loc
|
||||||
|
* @param $lm
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function get_xml($loc, $lm)
|
public function get_xml($loc, $lm)
|
||||||
{
|
{
|
||||||
$xml = "\t<url>\n";
|
$xml = "\t<url>\n";
|
||||||
|
@ -172,6 +204,11 @@ class sitemap
|
||||||
return $xml;
|
return $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $url
|
||||||
|
* @param $map
|
||||||
|
* @return bool|mixed|string
|
||||||
|
*/
|
||||||
public function send_url($url, $map)
|
public function send_url($url, $map)
|
||||||
{
|
{
|
||||||
$data = false;
|
$data = false;
|
||||||
|
@ -195,6 +232,9 @@ class sitemap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Создание карты сайта
|
||||||
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$row = DB()->fetch_row("SELECT COUNT(*) AS count FROM " . BB_TOPICS);
|
$row = DB()->fetch_row("SELECT COUNT(*) AS count FROM " . BB_TOPICS);
|
||||||
|
|
|
@ -16,6 +16,11 @@ class dbs
|
||||||
public $sql_inittime = 0;
|
public $sql_inittime = 0;
|
||||||
public $sql_timetotal = 0;
|
public $sql_timetotal = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dbs constructor.
|
||||||
|
* @param $cfg
|
||||||
|
* @return dbs
|
||||||
|
*/
|
||||||
public function DBS($cfg)
|
public function DBS($cfg)
|
||||||
{
|
{
|
||||||
$this->cfg = $cfg['db'];
|
$this->cfg = $cfg['db'];
|
||||||
|
@ -27,6 +32,10 @@ class dbs
|
||||||
}
|
}
|
||||||
|
|
||||||
// получение/инициализация класса для сервера $srv_name
|
// получение/инициализация класса для сервера $srv_name
|
||||||
|
/**
|
||||||
|
* @param string $srv_name_or_alias
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function get_db_obj($srv_name_or_alias = 'db1')
|
public function get_db_obj($srv_name_or_alias = 'db1')
|
||||||
{
|
{
|
||||||
$srv_name = $this->get_srv_name($srv_name_or_alias);
|
$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)
|
public function get_srv_name($name)
|
||||||
{
|
{
|
||||||
if (isset($this->alias[$name])) {
|
if (isset($this->alias[$name])) {
|
||||||
|
|
|
@ -39,6 +39,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
* @param $cfg_values
|
||||||
|
* @return sql_db
|
||||||
*/
|
*/
|
||||||
public function sql_db($cfg_values)
|
public function sql_db($cfg_values)
|
||||||
{
|
{
|
||||||
|
@ -127,6 +129,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base query method
|
* Base query method
|
||||||
|
* @param $query
|
||||||
|
* @return null|resource
|
||||||
*/
|
*/
|
||||||
public function sql_query($query)
|
public function sql_query($query)
|
||||||
{
|
{
|
||||||
|
@ -159,6 +163,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute query WRAPPER (with error handling)
|
* Execute query WRAPPER (with error handling)
|
||||||
|
* @param $query
|
||||||
|
* @return null|resource
|
||||||
*/
|
*/
|
||||||
public function query($query)
|
public function query($query)
|
||||||
{
|
{
|
||||||
|
@ -171,6 +177,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return number of rows
|
* Return number of rows
|
||||||
|
* @param bool $result
|
||||||
|
* @return bool|int
|
||||||
*/
|
*/
|
||||||
public function num_rows($result = false)
|
public function num_rows($result = false)
|
||||||
{
|
{
|
||||||
|
@ -193,6 +201,10 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch current field
|
* 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)
|
public function sql_fetchfield($field, $rownum = -1, $query_id = 0)
|
||||||
{
|
{
|
||||||
|
@ -223,6 +235,9 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch current row
|
* Fetch current row
|
||||||
|
* @param $result
|
||||||
|
* @param string $field_name
|
||||||
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
public function sql_fetchrow($result, $field_name = '')
|
public function sql_fetchrow($result, $field_name = '')
|
||||||
{
|
{
|
||||||
|
@ -237,6 +252,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alias of sql_fetchrow()
|
* Alias of sql_fetchrow()
|
||||||
|
* @param $result
|
||||||
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
public function fetch_next($result)
|
public function fetch_next($result)
|
||||||
{
|
{
|
||||||
|
@ -245,6 +262,9 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch row WRAPPER (with error handling)
|
* Fetch row WRAPPER (with error handling)
|
||||||
|
* @param $query
|
||||||
|
* @param string $field_name
|
||||||
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
public function fetch_row($query, $field_name = '')
|
public function fetch_row($query, $field_name = '')
|
||||||
{
|
{
|
||||||
|
@ -257,6 +277,9 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch all rows
|
* Fetch all rows
|
||||||
|
* @param $result
|
||||||
|
* @param string $field_name
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function sql_fetchrowset($result, $field_name = '')
|
public function sql_fetchrowset($result, $field_name = '')
|
||||||
{
|
{
|
||||||
|
@ -271,6 +294,9 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch all rows WRAPPER (with error handling)
|
* Fetch all rows WRAPPER (with error handling)
|
||||||
|
* @param $query
|
||||||
|
* @param string $field_name
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function fetch_rowset($query, $field_name = '')
|
public function fetch_rowset($query, $field_name = '')
|
||||||
{
|
{
|
||||||
|
@ -283,6 +309,9 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch all rows WRAPPER (with error handling)
|
* Fetch all rows WRAPPER (with error handling)
|
||||||
|
* @param $query
|
||||||
|
* @param string $field_name
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function fetch_all($query, $field_name = '')
|
public function fetch_all($query, $field_name = '')
|
||||||
{
|
{
|
||||||
|
@ -303,6 +332,7 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free sql result
|
* Free sql result
|
||||||
|
* @param bool $result
|
||||||
*/
|
*/
|
||||||
public function sql_freeresult($result = false)
|
public function sql_freeresult($result = false)
|
||||||
{
|
{
|
||||||
|
@ -315,6 +345,10 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Escape data used in sql query
|
* 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)
|
public function escape($v, $check_type = false, $dont_escape = false)
|
||||||
{
|
{
|
||||||
|
@ -343,6 +377,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Escape string
|
* Escape string
|
||||||
|
* @param $str
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escape_string($str)
|
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)
|
* 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
|
* 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)
|
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 "\n" . $query . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function get_empty_sql_array()
|
public function get_empty_sql_array()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
@ -426,6 +470,10 @@ class sql_db
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $sql_ary
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function build_sql($sql_ary)
|
public function build_sql($sql_ary)
|
||||||
{
|
{
|
||||||
$sql = '';
|
$sql = '';
|
||||||
|
@ -502,6 +550,7 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add shutdown query
|
* Add shutdown query
|
||||||
|
* @param $sql
|
||||||
*/
|
*/
|
||||||
public function add_shutdown_query($sql)
|
public function add_shutdown_query($sql)
|
||||||
{
|
{
|
||||||
|
@ -531,6 +580,9 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lock tables
|
* Lock tables
|
||||||
|
* @param $tables
|
||||||
|
* @param string $lock_type
|
||||||
|
* @return bool|null|resource
|
||||||
*/
|
*/
|
||||||
public function lock($tables, $lock_type = 'WRITE')
|
public function lock($tables, $lock_type = 'WRITE')
|
||||||
{
|
{
|
||||||
|
@ -564,6 +616,9 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain user level lock
|
* Obtain user level lock
|
||||||
|
* @param $name
|
||||||
|
* @param int $timeout
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function get_lock($name, $timeout = 0)
|
public function get_lock($name, $timeout = 0)
|
||||||
{
|
{
|
||||||
|
@ -580,6 +635,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain user level lock status
|
* Obtain user level lock status
|
||||||
|
* @param $name
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function release_lock($name)
|
public function release_lock($name)
|
||||||
{
|
{
|
||||||
|
@ -595,6 +652,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Release user level lock
|
* Release user level lock
|
||||||
|
* @param $name
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function is_free_lock($name)
|
public function is_free_lock($name)
|
||||||
{
|
{
|
||||||
|
@ -605,6 +664,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make per db unique lock name
|
* Make per db unique lock name
|
||||||
|
* @param $name
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_lock_name($name)
|
public function get_lock_name($name)
|
||||||
{
|
{
|
||||||
|
@ -647,6 +708,8 @@ class sql_db
|
||||||
/**
|
/**
|
||||||
* Set slow query marker for xx seconds
|
* Set slow query marker for xx seconds
|
||||||
* This will disable counting other queries as "slow" during this time
|
* 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)
|
public function expect_slow_query($ignoring_time = 60, $new_priority = 10)
|
||||||
{
|
{
|
||||||
|
@ -669,6 +732,7 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store debug info
|
* Store debug info
|
||||||
|
* @param $mode
|
||||||
*/
|
*/
|
||||||
public function debug($mode)
|
public function debug($mode)
|
||||||
{
|
{
|
||||||
|
@ -724,6 +788,7 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trigger error
|
* Trigger error
|
||||||
|
* @param string $msg
|
||||||
*/
|
*/
|
||||||
public function trigger_error($msg = 'DB Error')
|
public function trigger_error($msg = 'DB Error')
|
||||||
{
|
{
|
||||||
|
@ -741,6 +806,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find caller source
|
* Find caller source
|
||||||
|
* @param string $mode
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function debug_find_source($mode = '')
|
public function debug_find_source($mode = '')
|
||||||
{
|
{
|
||||||
|
@ -761,6 +828,8 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare for logging
|
* Prepare for logging
|
||||||
|
* @param int $queries_count
|
||||||
|
* @param string $log_file
|
||||||
*/
|
*/
|
||||||
public function log_next_query($queries_count = 1, $log_file = 'sql_queries')
|
public function log_next_query($queries_count = 1, $log_file = 'sql_queries')
|
||||||
{
|
{
|
||||||
|
@ -770,6 +839,7 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log query
|
* Log query
|
||||||
|
* @param string $log_file
|
||||||
*/
|
*/
|
||||||
public function log_query($log_file = 'sql_queries')
|
public function log_query($log_file = 'sql_queries')
|
||||||
{
|
{
|
||||||
|
@ -791,6 +861,7 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log slow query
|
* Log slow query
|
||||||
|
* @param string $log_file
|
||||||
*/
|
*/
|
||||||
public function log_slow_query($log_file = 'sql_slow_bb')
|
public function log_slow_query($log_file = 'sql_slow_bb')
|
||||||
{
|
{
|
||||||
|
@ -836,6 +907,10 @@ class sql_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Explain queries (based on code from phpBB3)
|
* 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 = '')
|
public function explain($mode, $html_table = '', $row = '')
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,6 +7,9 @@ if (!defined('BB_ROOT')) {
|
||||||
//
|
//
|
||||||
// Functions
|
// Functions
|
||||||
//
|
//
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
function cron_get_file_lock()
|
function cron_get_file_lock()
|
||||||
{
|
{
|
||||||
$lock_obtained = false;
|
$lock_obtained = false;
|
||||||
|
@ -25,6 +28,9 @@ function cron_get_file_lock()
|
||||||
return $lock_obtained;
|
return $lock_obtained;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $mode
|
||||||
|
*/
|
||||||
function cron_track_running($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());
|
defined('CRON_STARTMARK') or define('CRON_STARTMARK', TRIGGERS_DIR . 'cron_started_at_' . date('Y-m-d_H-i-s') . '_by_pid_' . getmypid());
|
||||||
|
|
|
@ -9,6 +9,11 @@ class datastore_apc extends datastore_common
|
||||||
public $engine = 'APC';
|
public $engine = 'APC';
|
||||||
public $prefix = null;
|
public $prefix = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* datastore_apc constructor.
|
||||||
|
* @param null $prefix
|
||||||
|
* @return datastore_apc
|
||||||
|
*/
|
||||||
public function datastore_apc($prefix = null)
|
public function datastore_apc($prefix = null)
|
||||||
{
|
{
|
||||||
if (!$this->is_installed()) {
|
if (!$this->is_installed()) {
|
||||||
|
@ -18,6 +23,11 @@ class datastore_apc extends datastore_common
|
||||||
$this->prefix = $prefix;
|
$this->prefix = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $title
|
||||||
|
* @param $var
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function store($title, $var)
|
public function store($title, $var)
|
||||||
{
|
{
|
||||||
$this->data[$title] = $var;
|
$this->data[$title] = $var;
|
||||||
|
@ -31,6 +41,9 @@ class datastore_apc extends datastore_common
|
||||||
return (bool)apc_store($this->prefix . $title, $var);
|
return (bool)apc_store($this->prefix . $title, $var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Очистка
|
||||||
|
*/
|
||||||
public function clean()
|
public function clean()
|
||||||
{
|
{
|
||||||
foreach ($this->known_items as $title => $script_name) {
|
foreach ($this->known_items as $title => $script_name) {
|
||||||
|
@ -44,6 +57,9 @@ class datastore_apc extends datastore_common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получение из кеша
|
||||||
|
*/
|
||||||
public function _fetch_from_store()
|
public function _fetch_from_store()
|
||||||
{
|
{
|
||||||
if (!$items = $this->queued_items) {
|
if (!$items = $this->queued_items) {
|
||||||
|
@ -62,6 +78,9 @@ class datastore_apc extends datastore_common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function is_installed()
|
public function is_installed()
|
||||||
{
|
{
|
||||||
return function_exists('apc_fetch');
|
return function_exists('apc_fetch');
|
||||||
|
|
|
@ -58,6 +58,10 @@ class datastore_common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $title
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function &get($title)
|
public function &get($title)
|
||||||
{
|
{
|
||||||
if (!isset($this->data[$title])) {
|
if (!isset($this->data[$title])) {
|
||||||
|
@ -67,10 +71,17 @@ class datastore_common
|
||||||
return $this->data[$title];
|
return $this->data[$title];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $item_name
|
||||||
|
* @param $item_data
|
||||||
|
*/
|
||||||
public function store($item_name, $item_data)
|
public function store($item_name, $item_data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $items
|
||||||
|
*/
|
||||||
public function rm($items)
|
public function rm($items)
|
||||||
{
|
{
|
||||||
foreach ((array)$items as $item) {
|
foreach ((array)$items as $item) {
|
||||||
|
@ -78,6 +89,9 @@ class datastore_common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $items
|
||||||
|
*/
|
||||||
public function update($items)
|
public function update($items)
|
||||||
{
|
{
|
||||||
if ($items == 'all') {
|
if ($items == 'all') {
|
||||||
|
@ -88,6 +102,9 @@ class datastore_common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получение
|
||||||
|
*/
|
||||||
public function _fetch()
|
public function _fetch()
|
||||||
{
|
{
|
||||||
$this->_fetch_from_store();
|
$this->_fetch_from_store();
|
||||||
|
@ -101,10 +118,16 @@ class datastore_common
|
||||||
$this->queued_items = array();
|
$this->queued_items = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получение из кеша
|
||||||
|
*/
|
||||||
public function _fetch_from_store()
|
public function _fetch_from_store()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $title
|
||||||
|
*/
|
||||||
public function _build_item($title)
|
public function _build_item($title)
|
||||||
{
|
{
|
||||||
if (!empty($this->known_items[$title])) {
|
if (!empty($this->known_items[$title])) {
|
||||||
|
@ -125,6 +148,10 @@ class datastore_common
|
||||||
public $dbg_enabled = false;
|
public $dbg_enabled = false;
|
||||||
public $cur_query = null;
|
public $cur_query = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $mode
|
||||||
|
* @param null $cur_query
|
||||||
|
*/
|
||||||
public function debug($mode, $cur_query = null)
|
public function debug($mode, $cur_query = null)
|
||||||
{
|
{
|
||||||
if (!$this->dbg_enabled) {
|
if (!$this->dbg_enabled) {
|
||||||
|
@ -150,6 +177,10 @@ class datastore_common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $mode
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function debug_find_source($mode = '')
|
public function debug_find_source($mode = '')
|
||||||
{
|
{
|
||||||
foreach (debug_backtrace() as $trace) {
|
foreach (debug_backtrace() as $trace) {
|
||||||
|
|
|
@ -10,6 +10,12 @@ class datastore_file extends datastore_common
|
||||||
public $prefix = null;
|
public $prefix = null;
|
||||||
public $engine = 'Filecache';
|
public $engine = 'Filecache';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* datastore_file constructor.
|
||||||
|
* @param $dir
|
||||||
|
* @param null $prefix
|
||||||
|
* @return datastore_file
|
||||||
|
*/
|
||||||
public function datastore_file($dir, $prefix = null)
|
public function datastore_file($dir, $prefix = null)
|
||||||
{
|
{
|
||||||
$this->prefix = $prefix;
|
$this->prefix = $prefix;
|
||||||
|
@ -17,6 +23,11 @@ class datastore_file extends datastore_common
|
||||||
$this->dbg_enabled = sql_dbg_enabled();
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $title
|
||||||
|
* @param $var
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function store($title, $var)
|
public function store($title, $var)
|
||||||
{
|
{
|
||||||
$this->cur_query = "cache->set('$title')";
|
$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);
|
return (bool)file_write($filecache, $filename, false, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Очистка
|
||||||
|
*/
|
||||||
public function clean()
|
public function clean()
|
||||||
{
|
{
|
||||||
$dir = $this->dir;
|
$dir = $this->dir;
|
||||||
|
@ -56,6 +70,9 @@ class datastore_file extends datastore_common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получение из кеша
|
||||||
|
*/
|
||||||
public function _fetch_from_store()
|
public function _fetch_from_store()
|
||||||
{
|
{
|
||||||
if (!$items = $this->queued_items) {
|
if (!$items = $this->queued_items) {
|
||||||
|
|
|
@ -12,6 +12,12 @@ class datastore_memcache extends datastore_common
|
||||||
public $engine = 'Memcache';
|
public $engine = 'Memcache';
|
||||||
public $prefix = null;
|
public $prefix = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* datastore_memcache constructor.
|
||||||
|
* @param $cfg
|
||||||
|
* @param null $prefix
|
||||||
|
* @return datastore_memcache
|
||||||
|
*/
|
||||||
public function datastore_memcache($cfg, $prefix = null)
|
public function datastore_memcache($cfg, $prefix = null)
|
||||||
{
|
{
|
||||||
if (!$this->is_installed()) {
|
if (!$this->is_installed()) {
|
||||||
|
@ -24,6 +30,9 @@ class datastore_memcache extends datastore_common
|
||||||
$this->dbg_enabled = sql_dbg_enabled();
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Подключение
|
||||||
|
*/
|
||||||
public function connect()
|
public function connect()
|
||||||
{
|
{
|
||||||
$connect_type = ($this->cfg['pconnect']) ? 'pconnect' : 'connect';
|
$connect_type = ($this->cfg['pconnect']) ? 'pconnect' : 'connect';
|
||||||
|
@ -47,6 +56,11 @@ class datastore_memcache extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $title
|
||||||
|
* @param $var
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function store($title, $var)
|
public function store($title, $var)
|
||||||
{
|
{
|
||||||
if (!$this->connected) {
|
if (!$this->connected) {
|
||||||
|
@ -63,6 +77,9 @@ class datastore_memcache extends datastore_common
|
||||||
return (bool)$this->memcache->set($this->prefix . $title, $var);
|
return (bool)$this->memcache->set($this->prefix . $title, $var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Очистка
|
||||||
|
*/
|
||||||
public function clean()
|
public function clean()
|
||||||
{
|
{
|
||||||
if (!$this->connected) {
|
if (!$this->connected) {
|
||||||
|
@ -79,6 +96,9 @@ class datastore_memcache extends datastore_common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получение из кеша
|
||||||
|
*/
|
||||||
public function _fetch_from_store()
|
public function _fetch_from_store()
|
||||||
{
|
{
|
||||||
if (!$items = $this->queued_items) {
|
if (!$items = $this->queued_items) {
|
||||||
|
@ -100,6 +120,9 @@ class datastore_memcache extends datastore_common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function is_installed()
|
public function is_installed()
|
||||||
{
|
{
|
||||||
return class_exists('Memcache');
|
return class_exists('Memcache');
|
||||||
|
|
|
@ -12,6 +12,12 @@ class datastore_redis extends datastore_common
|
||||||
public $connected = false;
|
public $connected = false;
|
||||||
public $engine = 'Redis';
|
public $engine = 'Redis';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* datastore_redis constructor.
|
||||||
|
* @param $cfg
|
||||||
|
* @param null $prefix
|
||||||
|
* @return datastore_redis
|
||||||
|
*/
|
||||||
public function datastore_redis($cfg, $prefix = null)
|
public function datastore_redis($cfg, $prefix = null)
|
||||||
{
|
{
|
||||||
if (!$this->is_installed()) {
|
if (!$this->is_installed()) {
|
||||||
|
@ -24,6 +30,9 @@ class datastore_redis extends datastore_common
|
||||||
$this->prefix = $prefix;
|
$this->prefix = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Подключение
|
||||||
|
*/
|
||||||
public function connect()
|
public function connect()
|
||||||
{
|
{
|
||||||
$this->cur_query = 'connect ' . $this->cfg['host'] . ':' . $this->cfg['port'];
|
$this->cur_query = 'connect ' . $this->cfg['host'] . ':' . $this->cfg['port'];
|
||||||
|
@ -41,6 +50,11 @@ class datastore_redis extends datastore_common
|
||||||
$this->cur_query = null;
|
$this->cur_query = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $title
|
||||||
|
* @param $var
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function store($title, $var)
|
public function store($title, $var)
|
||||||
{
|
{
|
||||||
if (!$this->connected) {
|
if (!$this->connected) {
|
||||||
|
@ -57,6 +71,9 @@ class datastore_redis extends datastore_common
|
||||||
return (bool)$this->redis->set($this->prefix . $title, serialize($var));
|
return (bool)$this->redis->set($this->prefix . $title, serialize($var));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Очистка
|
||||||
|
*/
|
||||||
public function clean()
|
public function clean()
|
||||||
{
|
{
|
||||||
if (!$this->connected) {
|
if (!$this->connected) {
|
||||||
|
@ -73,6 +90,9 @@ class datastore_redis extends datastore_common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получение из кеша
|
||||||
|
*/
|
||||||
public function _fetch_from_store()
|
public function _fetch_from_store()
|
||||||
{
|
{
|
||||||
if (!$items = $this->queued_items) {
|
if (!$items = $this->queued_items) {
|
||||||
|
@ -94,6 +114,9 @@ class datastore_redis extends datastore_common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function is_installed()
|
public function is_installed()
|
||||||
{
|
{
|
||||||
return class_exists('Redis');
|
return class_exists('Redis');
|
||||||
|
|
|
@ -22,6 +22,12 @@ class datastore_sqlite extends datastore_common
|
||||||
'log_name' => 'DATASTORE',
|
'log_name' => 'DATASTORE',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* datastore_sqlite constructor.
|
||||||
|
* @param $cfg
|
||||||
|
* @param null $prefix
|
||||||
|
* @return datastore_sqlite
|
||||||
|
*/
|
||||||
public function datastore_sqlite($cfg, $prefix = null)
|
public function datastore_sqlite($cfg, $prefix = null)
|
||||||
{
|
{
|
||||||
$this->cfg = array_merge($this->cfg, $cfg);
|
$this->cfg = array_merge($this->cfg, $cfg);
|
||||||
|
@ -29,6 +35,11 @@ class datastore_sqlite extends datastore_common
|
||||||
$this->prefix = $prefix;
|
$this->prefix = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $item_name
|
||||||
|
* @param $item_data
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function store($item_name, $item_data)
|
public function store($item_name, $item_data)
|
||||||
{
|
{
|
||||||
$this->data[$item_name] = $item_data;
|
$this->data[$item_name] = $item_data;
|
||||||
|
@ -41,11 +52,17 @@ class datastore_sqlite extends datastore_common
|
||||||
return (bool)$result;
|
return (bool)$result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Очистка
|
||||||
|
*/
|
||||||
public function clean()
|
public function clean()
|
||||||
{
|
{
|
||||||
$this->db->query("DELETE FROM " . $this->cfg['table_name']);
|
$this->db->query("DELETE FROM " . $this->cfg['table_name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получение из кеша
|
||||||
|
*/
|
||||||
public function _fetch_from_store()
|
public function _fetch_from_store()
|
||||||
{
|
{
|
||||||
if (!$items = $this->queued_items) {
|
if (!$items = $this->queued_items) {
|
||||||
|
|
|
@ -9,6 +9,11 @@ class datastore_xcache extends datastore_common
|
||||||
public $prefix = null;
|
public $prefix = null;
|
||||||
public $engine = 'XCache';
|
public $engine = 'XCache';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* datastore_xcache constructor.
|
||||||
|
* @param null $prefix
|
||||||
|
* @return datastore_xcache
|
||||||
|
*/
|
||||||
public function datastore_xcache($prefix = null)
|
public function datastore_xcache($prefix = null)
|
||||||
{
|
{
|
||||||
if (!$this->is_installed()) {
|
if (!$this->is_installed()) {
|
||||||
|
@ -19,6 +24,11 @@ class datastore_xcache extends datastore_common
|
||||||
$this->prefix = $prefix;
|
$this->prefix = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $title
|
||||||
|
* @param $var
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function store($title, $var)
|
public function store($title, $var)
|
||||||
{
|
{
|
||||||
$this->data[$title] = $var;
|
$this->data[$title] = $var;
|
||||||
|
@ -32,6 +42,9 @@ class datastore_xcache extends datastore_common
|
||||||
return (bool)xcache_set($this->prefix . $title, $var);
|
return (bool)xcache_set($this->prefix . $title, $var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Очистка
|
||||||
|
*/
|
||||||
public function clean()
|
public function clean()
|
||||||
{
|
{
|
||||||
foreach ($this->known_items as $title => $script_name) {
|
foreach ($this->known_items as $title => $script_name) {
|
||||||
|
@ -45,6 +58,9 @@ class datastore_xcache extends datastore_common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получение из кеша
|
||||||
|
*/
|
||||||
public function _fetch_from_store()
|
public function _fetch_from_store()
|
||||||
{
|
{
|
||||||
if (!$items = $this->queued_items) {
|
if (!$items = $this->queued_items) {
|
||||||
|
@ -63,6 +79,9 @@ class datastore_xcache extends datastore_common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function is_installed()
|
public function is_installed()
|
||||||
{
|
{
|
||||||
return function_exists('xcache_get');
|
return function_exists('xcache_get');
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -4,6 +4,9 @@ if (!defined('BB_ROOT')) {
|
||||||
die(basename(__FILE__));
|
die(basename(__FILE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Синхронизация всех форумов
|
||||||
|
*/
|
||||||
function sync_all_forums()
|
function sync_all_forums()
|
||||||
{
|
{
|
||||||
foreach (DB()->fetch_rowset("SELECT forum_id FROM " . BB_FORUMS) as $row) {
|
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)
|
function sync($type, $id)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
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)
|
function topic_delete($mode_or_topic_id, $forum_id = null, $prune_time = 0, $prune_all = false)
|
||||||
{
|
{
|
||||||
global $lang, $log_action;
|
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;
|
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)
|
function topic_move($topic_id, $to_forum_id, $from_forum_id = null, $leave_shadow = false, $insert_bot_msg = false)
|
||||||
{
|
{
|
||||||
global $log_action;
|
global $log_action;
|
||||||
|
@ -444,6 +466,12 @@ function topic_move($topic_id, $to_forum_id, $from_forum_id = null, $leave_shado
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $topic_id
|
||||||
|
* @param $mode
|
||||||
|
* @param null $forum_id
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
function topic_lock_unlock($topic_id, $mode, $forum_id = null)
|
function topic_lock_unlock($topic_id, $mode, $forum_id = null)
|
||||||
{
|
{
|
||||||
global $log_action;
|
global $log_action;
|
||||||
|
@ -490,6 +518,12 @@ function topic_lock_unlock($topic_id, $mode, $forum_id = null)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $topic_id
|
||||||
|
* @param $mode
|
||||||
|
* @param null $forum_id
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
function topic_stick_unstick($topic_id, $mode, $forum_id = null)
|
function topic_stick_unstick($topic_id, $mode, $forum_id = null)
|
||||||
{
|
{
|
||||||
if (!$topic_csv = get_id_csv($topic_id)) {
|
if (!$topic_csv = get_id_csv($topic_id)) {
|
||||||
|
@ -518,6 +552,12 @@ function topic_stick_unstick($topic_id, $mode, $forum_id = null)
|
||||||
}
|
}
|
||||||
|
|
||||||
// $exclude_first - в режиме удаления сообщений по списку исключать первое сообщение в теме
|
// $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)
|
function post_delete($mode_or_post_id, $user_id = null, $exclude_first = true)
|
||||||
{
|
{
|
||||||
global $log_action;
|
global $log_action;
|
||||||
|
@ -656,6 +696,11 @@ function post_delete($mode_or_post_id, $user_id = null, $exclude_first = true)
|
||||||
return $deleted_posts_count;
|
return $deleted_posts_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $user_id
|
||||||
|
* @param bool $delete_posts
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
function user_delete($user_id, $delete_posts = false)
|
function user_delete($user_id, $delete_posts = false)
|
||||||
{
|
{
|
||||||
global $log_action;
|
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)
|
function get_usernames_for_log($user_id)
|
||||||
{
|
{
|
||||||
$users_log_msg = array();
|
$users_log_msg = array();
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $jobs
|
||||||
|
*/
|
||||||
function run_jobs($jobs)
|
function run_jobs($jobs)
|
||||||
{
|
{
|
||||||
global $tr_cfg, $datastore;
|
global $tr_cfg, $datastore;
|
||||||
|
@ -46,12 +49,19 @@ function run_jobs($jobs)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $jobs
|
||||||
|
*/
|
||||||
function delete_jobs($jobs)
|
function delete_jobs($jobs)
|
||||||
{
|
{
|
||||||
DB()->query("DELETE FROM " . BB_CRON . " WHERE cron_id IN ($jobs)");
|
DB()->query("DELETE FROM " . BB_CRON . " WHERE cron_id IN ($jobs)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $jobs
|
||||||
|
* @param $cron_action
|
||||||
|
*/
|
||||||
function toggle_active($jobs, $cron_action)
|
function toggle_active($jobs, $cron_action)
|
||||||
{
|
{
|
||||||
$active = ($cron_action == 'disable') ? 0 : 1;
|
$active = ($cron_action == 'disable') ? 0 : 1;
|
||||||
|
@ -59,6 +69,10 @@ function toggle_active($jobs, $cron_action)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $cron_arr
|
||||||
|
* @return int|string
|
||||||
|
*/
|
||||||
function validate_cron_post($cron_arr)
|
function validate_cron_post($cron_arr)
|
||||||
{
|
{
|
||||||
$errors = 'Errors in: ';
|
$errors = 'Errors in: ';
|
||||||
|
@ -79,6 +93,9 @@ function validate_cron_post($cron_arr)
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $cron_arr
|
||||||
|
*/
|
||||||
function insert_cron_job($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'] . "' ");
|
$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')");
|
$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)
|
function update_cron_job($cron_arr)
|
||||||
{
|
{
|
||||||
$cron_id = $cron_arr['cron_id'];
|
$cron_id = $cron_arr['cron_id'];
|
||||||
|
|
|
@ -4,6 +4,12 @@ if (!defined('BB_ROOT')) {
|
||||||
die(basename(__FILE__));
|
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)
|
function update_table_bool($table_name, $key, $field_name, $field_def_val)
|
||||||
{
|
{
|
||||||
// Clear current status
|
// Clear current status
|
||||||
|
@ -37,6 +43,10 @@ function update_table_bool($table_name, $key, $field_name, $field_def_val)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $default_cfg
|
||||||
|
* @param $cfg
|
||||||
|
*/
|
||||||
function set_tpl_vars($default_cfg, $cfg)
|
function set_tpl_vars($default_cfg, $cfg)
|
||||||
{
|
{
|
||||||
global $template;
|
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)
|
function set_tpl_vars_bool($default_cfg, $cfg)
|
||||||
{
|
{
|
||||||
global $template, $lang;
|
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)
|
function set_tpl_vars_lang($default_cfg)
|
||||||
{
|
{
|
||||||
global $template, $lang;
|
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)
|
function update_config_table($table_name, $default_cfg, $cfg, $type)
|
||||||
{
|
{
|
||||||
foreach ($default_cfg as $config_name => $config_value) {
|
foreach ($default_cfg as $config_name => $config_value) {
|
||||||
|
|
|
@ -7,6 +7,11 @@ if (!defined('BB_ROOT')) {
|
||||||
// Максимум записей = 50
|
// Максимум записей = 50
|
||||||
// [Обновлено] - если дата изменения первого поста топика не старее недели (?) или в топике новые сообщения не старее недели (?)
|
// [Обновлено] - если дата изменения первого поста топика не старее недели (?) или в топике новые сообщения не старее недели (?)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $forum_id
|
||||||
|
* @param $forum_data
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
function update_forum_feed($forum_id, $forum_data)
|
function update_forum_feed($forum_id, $forum_data)
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @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)
|
function update_user_feed($user_id, $username)
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @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)
|
function create_atom($file_path, $mode, $id, $title, $topics)
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
|
|
@ -4,6 +4,9 @@ if (!defined('BB_ROOT')) {
|
||||||
die(basename(__FILE__));
|
die(basename(__FILE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function get_sql_log()
|
function get_sql_log()
|
||||||
{
|
{
|
||||||
global $DBS, $sphinx, $datastore;
|
global $DBS, $sphinx, $datastore;
|
||||||
|
@ -25,6 +28,11 @@ function get_sql_log()
|
||||||
return $log;
|
return $log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $db_obj
|
||||||
|
* @param $log_name
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function get_sql_log_html($db_obj, $log_name)
|
function get_sql_log_html($db_obj, $log_name)
|
||||||
{
|
{
|
||||||
$log = '';
|
$log = '';
|
||||||
|
|
|
@ -4,6 +4,9 @@ if (!defined('BB_ROOT')) {
|
||||||
die(basename(__FILE__));
|
die(basename(__FILE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $user_id
|
||||||
|
*/
|
||||||
function update_user_level($user_id)
|
function update_user_level($user_id)
|
||||||
{
|
{
|
||||||
global $datastore;
|
global $datastore;
|
||||||
|
@ -61,6 +64,9 @@ function update_user_level($user_id)
|
||||||
$datastore->update('moderators');
|
$datastore->update('moderators');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $group_id
|
||||||
|
*/
|
||||||
function delete_group($group_id)
|
function delete_group($group_id)
|
||||||
{
|
{
|
||||||
$group_id = (int)$group_id;
|
$group_id = (int)$group_id;
|
||||||
|
@ -78,6 +84,12 @@ function delete_group($group_id)
|
||||||
update_user_level('all');
|
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)
|
function add_user_into_group($group_id, $user_id, $user_pending = 0, $user_time = TIMENOW)
|
||||||
{
|
{
|
||||||
$args = DB()->build_array('INSERT', array(
|
$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)
|
function delete_user_group($group_id, $user_id)
|
||||||
{
|
{
|
||||||
DB()->query("
|
DB()->query("
|
||||||
|
@ -104,6 +120,10 @@ function delete_user_group($group_id, $user_id)
|
||||||
update_user_level($user_id);
|
update_user_level($user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $user_id
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function create_user_group($user_id)
|
function create_user_group($user_id)
|
||||||
{
|
{
|
||||||
DB()->query("INSERT INTO " . BB_GROUPS . " (group_single_user) VALUES (1)");
|
DB()->query("INSERT INTO " . BB_GROUPS . " (group_single_user) VALUES (1)");
|
||||||
|
@ -116,6 +136,10 @@ function create_user_group($user_id)
|
||||||
return $group_id;
|
return $group_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $group_id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
function get_group_data($group_id)
|
function get_group_data($group_id)
|
||||||
{
|
{
|
||||||
if ($group_id === 'all') {
|
if ($group_id === 'all') {
|
||||||
|
@ -139,6 +163,11 @@ function get_group_data($group_id)
|
||||||
return DB()->$method($sql);
|
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)
|
function delete_permissions($group_id = null, $user_id = null, $cat_id = null)
|
||||||
{
|
{
|
||||||
$group_id = get_id_csv($group_id);
|
$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)
|
function store_permissions($group_id, $auth_ary)
|
||||||
{
|
{
|
||||||
if (empty($auth_ary) || !is_array($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);
|
DB()->query("INSERT INTO " . BB_AUTH_ACCESS . $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $user_id
|
||||||
|
*/
|
||||||
function update_user_permissions($user_id = 'all')
|
function update_user_permissions($user_id = 'all')
|
||||||
{
|
{
|
||||||
if (is_array($user_id)) {
|
if (is_array($user_id)) {
|
||||||
|
@ -206,6 +242,9 @@ function update_user_permissions($user_id = 'all')
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Удаление битых групп пользователей
|
||||||
|
*/
|
||||||
function delete_orphan_usergroups()
|
function delete_orphan_usergroups()
|
||||||
{
|
{
|
||||||
// GROUP_SINGLE_USER without AUTH_ACCESS
|
// GROUP_SINGLE_USER without AUTH_ACCESS
|
||||||
|
|
|
@ -7,6 +7,14 @@ if (!defined('BB_ROOT')) {
|
||||||
//
|
//
|
||||||
// Prepare a message for posting
|
// 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)
|
function prepare_post(&$mode, &$post_data, &$error_msg, &$username, &$subject, &$message)
|
||||||
{
|
{
|
||||||
global $user, $userdata, $lang;
|
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
|
// 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)
|
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;
|
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
|
// 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)
|
function update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id)
|
||||||
{
|
{
|
||||||
$sign = ($mode == 'delete') ? '- 1' : '+ 1';
|
$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
|
// 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)
|
function delete_post($mode, $post_data, &$message, &$meta, $forum_id, $topic_id, $post_id)
|
||||||
{
|
{
|
||||||
global $lang;
|
global $lang;
|
||||||
|
@ -284,6 +326,14 @@ function delete_post($mode, $post_data, &$message, &$meta, $forum_id, $topic_id,
|
||||||
//
|
//
|
||||||
// Handle user notification on new post
|
// 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)
|
function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$notify_user)
|
||||||
{
|
{
|
||||||
global $lang, $userdata;
|
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 = '')
|
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;
|
global $userdata, $lang;
|
||||||
|
|
|
@ -5,6 +5,11 @@ if (!defined('BB_ROOT')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Languages
|
// Languages
|
||||||
|
/**
|
||||||
|
* @param $default_lang
|
||||||
|
* @param string $select_name
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function language_select($default_lang, $select_name = 'language')
|
function language_select($default_lang, $select_name = 'language')
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
@ -25,6 +30,11 @@ function language_select($default_lang, $select_name = 'language')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pick a timezone
|
// Pick a timezone
|
||||||
|
/**
|
||||||
|
* @param $default
|
||||||
|
* @param string $select_name
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function tz_select($default, $select_name = 'timezone')
|
function tz_select($default, $select_name = 'timezone')
|
||||||
{
|
{
|
||||||
global $sys_timezone, $lang;
|
global $sys_timezone, $lang;
|
||||||
|
@ -44,6 +54,11 @@ function tz_select($default, $select_name = 'timezone')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Templates
|
// Templates
|
||||||
|
/**
|
||||||
|
* @param $default_style
|
||||||
|
* @param string $select_name
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function templates_select($default_style, $select_name = 'tpl_name')
|
function templates_select($default_style, $select_name = 'tpl_name')
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
|
|
@ -4,6 +4,11 @@ if (!defined('BB_ROOT')) {
|
||||||
die(basename(__FILE__));
|
die(basename(__FILE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $forum_id
|
||||||
|
* @param $poster_id
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
function torrent_auth_check($forum_id, $poster_id)
|
function torrent_auth_check($forum_id, $poster_id)
|
||||||
{
|
{
|
||||||
global $lang, $userdata;
|
global $lang, $userdata;
|
||||||
|
@ -22,6 +27,10 @@ function torrent_auth_check($forum_id, $poster_id)
|
||||||
bb_die($lang['NOT_MODERATOR']);
|
bb_die($lang['NOT_MODERATOR']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $topic_id
|
||||||
|
* @param string $redirect_url
|
||||||
|
*/
|
||||||
function tracker_unregister($topic_id, $redirect_url = '')
|
function tracker_unregister($topic_id, $redirect_url = '')
|
||||||
{
|
{
|
||||||
global $lang, $log_action;
|
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)
|
function torrent_cp_close($topic_id, $forum_id)
|
||||||
{
|
{
|
||||||
global $log_action, $userdata;
|
global $log_action, $userdata;
|
||||||
|
@ -111,6 +124,13 @@ function torrent_cp_close($topic_id, $forum_id)
|
||||||
topic_lock_unlock($topic_id, 'lock');
|
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)
|
function tracker_register($topic_id, $mode = '', $tor_status = TOR_NOT_APPROVED, $reg_time = TIMENOW)
|
||||||
{
|
{
|
||||||
global $lang;
|
global $lang;
|
||||||
|
@ -231,6 +251,10 @@ function tracker_register($topic_id, $mode = '', $tor_status = TOR_NOT_APPROVED,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $topic_id
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
function delete_torrent($topic_id)
|
function delete_torrent($topic_id)
|
||||||
{
|
{
|
||||||
tracker_unregister($topic_id);
|
tracker_unregister($topic_id);
|
||||||
|
@ -239,6 +263,10 @@ function delete_torrent($topic_id)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $topic_id
|
||||||
|
* @param $tor_status
|
||||||
|
*/
|
||||||
function change_tor_status($topic_id, $tor_status)
|
function change_tor_status($topic_id, $tor_status)
|
||||||
{
|
{
|
||||||
global $userdata;
|
global $userdata;
|
||||||
|
@ -260,6 +288,10 @@ function change_tor_status($topic_id, $tor_status)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set gold / silver type for torrent
|
// Set gold / silver type for torrent
|
||||||
|
/**
|
||||||
|
* @param $topic_id
|
||||||
|
* @param $tor_status_gold
|
||||||
|
*/
|
||||||
function change_tor_type($topic_id, $tor_status_gold)
|
function change_tor_type($topic_id, $tor_status_gold)
|
||||||
{
|
{
|
||||||
global $lang;
|
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)
|
function send_torrent_with_passkey($t_data)
|
||||||
{
|
{
|
||||||
global $lang, $tr_cfg, $userdata;
|
global $lang, $tr_cfg, $userdata;
|
||||||
|
@ -453,6 +488,11 @@ function send_torrent_with_passkey($t_data)
|
||||||
bb_exit($output);
|
bb_exit($output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $user_id
|
||||||
|
* @param bool $force_generate
|
||||||
|
* @return bool|string
|
||||||
|
*/
|
||||||
function generate_passkey($user_id, $force_generate = false)
|
function generate_passkey($user_id, $force_generate = false)
|
||||||
{
|
{
|
||||||
global $lang;
|
global $lang;
|
||||||
|
@ -507,6 +547,10 @@ function generate_passkey($user_id, $force_generate = false)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $message
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
function torrent_error_exit($message)
|
function torrent_error_exit($message)
|
||||||
{
|
{
|
||||||
global $reg_mode, $return_message, $lang;
|
global $reg_mode, $return_message, $lang;
|
||||||
|
@ -527,16 +571,29 @@ function torrent_error_exit($message)
|
||||||
bb_die($msg . $message);
|
bb_die($msg . $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $topic_id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
function tracker_rm_torrent($topic_id)
|
function tracker_rm_torrent($topic_id)
|
||||||
{
|
{
|
||||||
return DB()->sql_query("DELETE FROM " . BB_BT_TRACKER . " WHERE topic_id = " . (int)$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)
|
function tracker_rm_user($user_id)
|
||||||
{
|
{
|
||||||
return DB()->sql_query("DELETE FROM " . BB_BT_TRACKER . " WHERE user_id = " . (int)$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)
|
function ocelot_update_tracker($action, $updates)
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
@ -558,6 +615,12 @@ function ocelot_update_tracker($action, $updates)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $get
|
||||||
|
* @param int $max_attempts
|
||||||
|
* @param bool $err
|
||||||
|
* @return bool|int
|
||||||
|
*/
|
||||||
function ocelot_send_request($get, $max_attempts = 1, &$err = false)
|
function ocelot_send_request($get, $max_attempts = 1, &$err = false)
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
@ -607,18 +670,31 @@ function ocelot_send_request($get, $max_attempts = 1, &$err = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// bdecode: based on OpenTracker
|
// bdecode: based on OpenTracker
|
||||||
|
/**
|
||||||
|
* @param $filename
|
||||||
|
* @return null|string
|
||||||
|
*/
|
||||||
function bdecode_file($filename)
|
function bdecode_file($filename)
|
||||||
{
|
{
|
||||||
$file_contents = file_get_contents($filename);
|
$file_contents = file_get_contents($filename);
|
||||||
return bdecode($file_contents);
|
return bdecode($file_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $str
|
||||||
|
* @return null|string
|
||||||
|
*/
|
||||||
function bdecode($str)
|
function bdecode($str)
|
||||||
{
|
{
|
||||||
$pos = 0;
|
$pos = 0;
|
||||||
return bdecode_r($str, $pos);
|
return bdecode_r($str, $pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $str
|
||||||
|
* @param $pos
|
||||||
|
* @return null|string
|
||||||
|
*/
|
||||||
function bdecode_r($str, &$pos)
|
function bdecode_r($str, &$pos)
|
||||||
{
|
{
|
||||||
$strlen = strlen($str);
|
$strlen = strlen($str);
|
||||||
|
|
|
@ -36,6 +36,12 @@ class upload_common
|
||||||
8 => 'tiff',
|
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)
|
public function init($cfg = array(), $post_params = array(), $uploaded_only = true)
|
||||||
{
|
{
|
||||||
global $lang;
|
global $lang;
|
||||||
|
@ -109,6 +115,11 @@ class upload_common
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $mode
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function store($mode = '', $params = array())
|
public function store($mode = '', $params = array())
|
||||||
{
|
{
|
||||||
if ($mode == 'avatar') {
|
if ($mode == 'avatar') {
|
||||||
|
@ -124,6 +135,10 @@ class upload_common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $file_path
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function _move($file_path)
|
public function _move($file_path)
|
||||||
{
|
{
|
||||||
$dir = dirname($file_path);
|
$dir = dirname($file_path);
|
||||||
|
|
|
@ -5,6 +5,11 @@ if (!defined('BB_ROOT')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// !!! $username должен быть предварительно обработан clean_username() !!!
|
// !!! $username должен быть предварительно обработан clean_username() !!!
|
||||||
|
/**
|
||||||
|
* @param $username
|
||||||
|
* @param bool $check_ban_and_taken
|
||||||
|
* @return bool|string
|
||||||
|
*/
|
||||||
function validate_username($username, $check_ban_and_taken = true)
|
function validate_username($username, $check_ban_and_taken = true)
|
||||||
{
|
{
|
||||||
global $user, $lang;
|
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
|
// 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)
|
function validate_email($email, $check_ban_and_taken = true)
|
||||||
{
|
{
|
||||||
global $lang, $userdata;
|
global $lang, $userdata;
|
||||||
|
|
|
@ -29,6 +29,10 @@ $user_ip = encode_ip($client_ip);
|
||||||
define('CLIENT_IP', $client_ip);
|
define('CLIENT_IP', $client_ip);
|
||||||
define('USER_IP', $user_ip);
|
define('USER_IP', $user_ip);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $contents
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function send_page($contents)
|
function send_page($contents)
|
||||||
{
|
{
|
||||||
return compress_output($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));
|
define('UA_GZIP_SUPPORTED', (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $contents
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function compress_output($contents)
|
function compress_output($contents)
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
@ -71,6 +79,13 @@ define('COOKIE_PERSIST', TIMENOW + 31536000);
|
||||||
|
|
||||||
define('COOKIE_MAX_TRACKS', 90);
|
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)
|
function bb_setcookie($name, $val, $lifetime = COOKIE_PERSIST, $httponly = false)
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
@ -276,7 +291,9 @@ $dl_status_css = [
|
||||||
DL_STATUS_CANCEL => 'dlCancel',
|
DL_STATUS_CANCEL => 'dlCancel',
|
||||||
];
|
];
|
||||||
|
|
||||||
// Functions
|
/**
|
||||||
|
* Отправка заголовков без кеша
|
||||||
|
*/
|
||||||
function send_no_cache_headers()
|
function send_no_cache_headers()
|
||||||
{
|
{
|
||||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||||
|
@ -286,6 +303,9 @@ function send_no_cache_headers()
|
||||||
header('Pragma: no-cache');
|
header('Pragma: no-cache');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $output
|
||||||
|
*/
|
||||||
function bb_exit($output = '')
|
function bb_exit($output = '')
|
||||||
{
|
{
|
||||||
if ($output) {
|
if ($output) {
|
||||||
|
@ -294,16 +314,33 @@ function bb_exit($output = '')
|
||||||
exit;
|
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')
|
function htmlCHR($txt, $double_encode = false, $quote_style = ENT_QUOTES, $charset = 'UTF-8')
|
||||||
{
|
{
|
||||||
return (string)htmlspecialchars($txt, $quote_style, $charset, $double_encode);
|
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')
|
function html_ent_decode($txt, $quote_style = ENT_QUOTES, $charset = 'UTF-8')
|
||||||
{
|
{
|
||||||
return (string)html_entity_decode($txt, $quote_style, $charset);
|
return (string)html_entity_decode($txt, $quote_style, $charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $path
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function make_url($path = '')
|
function make_url($path = '')
|
||||||
{
|
{
|
||||||
return FULL_URL . preg_replace('#^\/?(.*?)\/?$#', '\1', $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()
|
function cron_release_deadlock()
|
||||||
{
|
{
|
||||||
if (file_exists(CRON_RUNNING)) {
|
if (file_exists(CRON_RUNNING)) {
|
||||||
|
@ -386,17 +425,26 @@ function cron_release_deadlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Блокировка крона
|
||||||
|
*/
|
||||||
function cron_release_file_lock()
|
function cron_release_file_lock()
|
||||||
{
|
{
|
||||||
rename(CRON_RUNNING, CRON_ALLOWED);
|
rename(CRON_RUNNING, CRON_ALLOWED);
|
||||||
cron_touch_lock_file(CRON_ALLOWED);
|
cron_touch_lock_file(CRON_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $lock_file
|
||||||
|
*/
|
||||||
function cron_touch_lock_file($lock_file)
|
function cron_touch_lock_file($lock_file)
|
||||||
{
|
{
|
||||||
file_write(make_rand_str(20), $lock_file, 0, true, true);
|
file_write(make_rand_str(20), $lock_file, 0, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Включение форума (при блокировке крона)
|
||||||
|
*/
|
||||||
function cron_enable_board()
|
function cron_enable_board()
|
||||||
{
|
{
|
||||||
if (file_exists(BB_DISABLED)) {
|
if (file_exists(BB_DISABLED)) {
|
||||||
|
@ -404,6 +452,9 @@ function cron_enable_board()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Отключение форума (при блокировке крона)
|
||||||
|
*/
|
||||||
function cron_disable_board()
|
function cron_disable_board()
|
||||||
{
|
{
|
||||||
if (file_exists(BB_ENABLED)) {
|
if (file_exists(BB_ENABLED)) {
|
||||||
|
|
|
@ -735,11 +735,18 @@ class user_common
|
||||||
//
|
//
|
||||||
// userdata cache
|
// userdata cache
|
||||||
//
|
//
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
function ignore_cached_userdata()
|
function ignore_cached_userdata()
|
||||||
{
|
{
|
||||||
return (defined('IN_PM')) ? true : false;
|
return (defined('IN_PM')) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return bool|mixed|null
|
||||||
|
*/
|
||||||
function cache_get_userdata($id)
|
function cache_get_userdata($id)
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
@ -755,6 +762,11 @@ function cache_get_userdata($id)
|
||||||
return $cache->get($id);
|
return $cache->get($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $userdata
|
||||||
|
* @param bool $force
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
function cache_set_userdata($userdata, $force = false)
|
function cache_set_userdata($userdata, $force = false)
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @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'));
|
return $cache->set($id, $userdata, $di->config->get('session_update_intrv'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $userdata
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
function cache_rm_userdata($userdata)
|
function cache_rm_userdata($userdata)
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
@ -790,6 +806,9 @@ function cache_rm_userdata($userdata)
|
||||||
}
|
}
|
||||||
|
|
||||||
// $user_id - array(id1,id2,..) or (string) id
|
// $user_id - array(id1,id2,..) or (string) id
|
||||||
|
/**
|
||||||
|
* @param $user_id
|
||||||
|
*/
|
||||||
function cache_rm_user_sessions($user_id)
|
function cache_rm_user_sessions($user_id)
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
@ -809,11 +828,21 @@ function cache_rm_user_sessions($user_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $userdata
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
function cache_update_userdata($userdata)
|
function cache_update_userdata($userdata)
|
||||||
{
|
{
|
||||||
return cache_set_userdata($userdata, true);
|
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)
|
function db_update_userdata($userdata, $sql_ary, $data_already_escaped = true)
|
||||||
{
|
{
|
||||||
if (!$userdata) {
|
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
|
// $user_id - array(id1,id2,..) or (string) id
|
||||||
|
/**
|
||||||
|
* @param $user_id
|
||||||
|
*/
|
||||||
function delete_user_sessions($user_id)
|
function delete_user_sessions($user_id)
|
||||||
{
|
{
|
||||||
cache_rm_user_sessions($user_id);
|
cache_rm_user_sessions($user_id);
|
||||||
|
|
|
@ -6,6 +6,11 @@ if (!defined('BB_ROOT')) {
|
||||||
|
|
||||||
define('SMTP_INCLUDED', 1);
|
define('SMTP_INCLUDED', 1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $socket
|
||||||
|
* @param $response
|
||||||
|
* @param int $line
|
||||||
|
*/
|
||||||
function server_parse($socket, $response, $line = __LINE__)
|
function server_parse($socket, $response, $line = __LINE__)
|
||||||
{
|
{
|
||||||
$server_response = '';
|
$server_response = '';
|
||||||
|
@ -21,6 +26,13 @@ function server_parse($socket, $response, $line = __LINE__)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replacement or substitute for PHP's mail command
|
// 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 = '')
|
function smtpmail($mail_to, $subject, $message, $headers = '')
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
|
|
@ -92,6 +92,7 @@ class template
|
||||||
* Constructor. Installs XS mod on first run or updates it and sets the root dir.
|
* Constructor. Installs XS mod on first run or updates it and sets the root dir.
|
||||||
*
|
*
|
||||||
* @param string $root
|
* @param string $root
|
||||||
|
* @return template
|
||||||
*/
|
*/
|
||||||
public function Template($root = '.')
|
public function Template($root = '.')
|
||||||
{
|
{
|
||||||
|
@ -531,6 +532,11 @@ class template
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $filename
|
||||||
|
* @param $code
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function compile_code($filename, $code)
|
public function compile_code($filename, $code)
|
||||||
{
|
{
|
||||||
// Load code from file
|
// Load code from file
|
||||||
|
@ -818,6 +824,10 @@ class template
|
||||||
/*
|
/*
|
||||||
* Compile code between tags
|
* Compile code between tags
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* @param $code
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function _compile_text($code)
|
public function _compile_text($code)
|
||||||
{
|
{
|
||||||
if (strlen($code) < 3) {
|
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
|
// 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)
|
public function compile_tag_if($tag_args, $elseif)
|
||||||
{
|
{
|
||||||
/* Tokenize args for 'if' tag */
|
/* Tokenize args for 'if' tag */
|
||||||
|
@ -961,6 +976,11 @@ class template
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is from Smarty
|
// This is from Smarty
|
||||||
|
/**
|
||||||
|
* @param $is_arg
|
||||||
|
* @param $tokens
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function _parse_is_expr($is_arg, $tokens)
|
public function _parse_is_expr($is_arg, $tokens)
|
||||||
{
|
{
|
||||||
$expr_end = 0;
|
$expr_end = 0;
|
||||||
|
@ -1069,6 +1089,9 @@ class template
|
||||||
file_write($code, $filename, false, true, true);
|
file_write($code, $filename, false, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Запуск шаблонизатора
|
||||||
|
*/
|
||||||
public function xs_startup()
|
public function xs_startup()
|
||||||
{
|
{
|
||||||
/** @var \TorrentPier\Di $di */
|
/** @var \TorrentPier\Di $di */
|
||||||
|
@ -1088,6 +1111,10 @@ class template
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $var
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function lang_error($var)
|
public function lang_error($var)
|
||||||
{
|
{
|
||||||
trigger_error(basename($this->cur_tpl) . " : undefined language variable {L_{$var}}", E_USER_WARNING);
|
trigger_error(basename($this->cur_tpl) . " : undefined language variable {L_{$var}}", E_USER_WARNING);
|
||||||
|
|
|
@ -5,7 +5,6 @@ namespace TorrentPier\ServiceProviders;
|
||||||
use Pimple\Container;
|
use Pimple\Container;
|
||||||
use Pimple\ServiceProviderInterface;
|
use Pimple\ServiceProviderInterface;
|
||||||
use TorrentPier\Db\Adapter;
|
use TorrentPier\Db\Adapter;
|
||||||
use TorrentPier\Db\Connection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DbServiceProvider
|
* Class DbServiceProvider
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
// BBCode control
|
// BBCode control
|
||||||
function BBCode(obj)
|
function BBCode(obj) {
|
||||||
{
|
|
||||||
textarea = document.getElementById(obj);
|
textarea = document.getElementById(obj);
|
||||||
this.construct(textarea);
|
this.construct(textarea);
|
||||||
}
|
}
|
||||||
|
@ -24,17 +23,26 @@ BBCode.prototype = {
|
||||||
// Tag for quoting
|
// Tag for quoting
|
||||||
this.addTag(
|
this.addTag(
|
||||||
'_quoter',
|
'_quoter',
|
||||||
function() { return '[quote="'+th.quoter+'"][qpost='+th.qouted_pid+']' },
|
function () {
|
||||||
|
return '[quote="' + th.quoter + '"][qpost=' + th.qouted_pid + ']'
|
||||||
|
},
|
||||||
'[/quote]\n',
|
'[/quote]\n',
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
function() { th.collapseAfterInsert=true; return th._prepareMultiline(th.quoterText) }
|
function () {
|
||||||
|
th.collapseAfterInsert = true;
|
||||||
|
return th._prepareMultiline(th.quoterText)
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Init events
|
// Init events
|
||||||
var th = this;
|
var th = this;
|
||||||
addEvent(textarea, 'keydown', function(e) { return th.onKeyPress(e, window.HTMLElement? 'down' : 'press') });
|
addEvent(textarea, 'keydown', function (e) {
|
||||||
addEvent(textarea, 'keypress', function(e) { return th.onKeyPress(e, 'press') });
|
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
|
// Insert poster name or poster quotes to the text
|
||||||
|
@ -110,14 +118,18 @@ BBCode.prototype = {
|
||||||
t.value += text;
|
t.value += text;
|
||||||
}
|
}
|
||||||
// For IE
|
// For IE
|
||||||
setTimeout(function() { t.focus() }, 100);
|
setTimeout(function () {
|
||||||
|
t.focus()
|
||||||
|
}, 100);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Surround piece of textarea text with tags
|
// Surround piece of textarea text with tags
|
||||||
surround: function (open, close, fTrans) {
|
surround: function (open, close, fTrans) {
|
||||||
var t = this.textarea;
|
var t = this.textarea;
|
||||||
t.focus();
|
t.focus();
|
||||||
if (!fTrans) fTrans = function(t) { return t; };
|
if (!fTrans) fTrans = function (t) {
|
||||||
|
return t;
|
||||||
|
};
|
||||||
|
|
||||||
var rt = this.getSelection();
|
var rt = this.getSelection();
|
||||||
var text = rt[0];
|
var text = rt[0];
|
||||||
|
@ -238,14 +250,19 @@ BBCode.prototype = {
|
||||||
if (elt) {
|
if (elt) {
|
||||||
var th = this;
|
var th = this;
|
||||||
if (elt.type && elt.type.toUpperCase() == "BUTTON") {
|
if (elt.type && elt.type.toUpperCase() == "BUTTON") {
|
||||||
addEvent(elt, 'click', function() { th.insertTag(id); return false; });
|
addEvent(elt, 'click', function () {
|
||||||
|
th.insertTag(id);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (elt.tagName && elt.tagName.toUpperCase() == "SELECT") {
|
if (elt.tagName && elt.tagName.toUpperCase() == "SELECT") {
|
||||||
addEvent(elt, 'change', function() { th.insertTag(id); return false; });
|
addEvent(elt, 'change', function () {
|
||||||
|
th.insertTag(id);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
if (id && id.indexOf('_') != 0) return alert("addTag('" + id + "'): no such element in the form");
|
if (id && id.indexOf('_') != 0) return alert("addTag('" + id + "'): no such element in the form");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -294,8 +311,7 @@ function AddSelectedText(BBOpen, BBClose) {
|
||||||
document.post.message.focus()
|
document.post.message.focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
function InsertBBCode(BBcode)
|
function InsertBBCode(BBcode) {
|
||||||
{
|
|
||||||
AddSelectedText('[' + BBcode + ']', '[/' + BBcode + ']');
|
AddSelectedText('[' + BBcode + ']', '[/' + BBcode + ']');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,8 +319,7 @@ function storeCaret(textEl) {
|
||||||
if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
|
if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
function initPostBBCode(context)
|
function initPostBBCode(context) {
|
||||||
{
|
|
||||||
$('span.post-hr', context).html('<hr align="left" />');
|
$('span.post-hr', context).html('<hr align="left" />');
|
||||||
initCodes(context);
|
initCodes(context);
|
||||||
initQuotes(context);
|
initQuotes(context);
|
||||||
|
@ -314,16 +329,14 @@ function initPostBBCode(context)
|
||||||
initMedia(context);
|
initMedia(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
function initCodes(context)
|
function initCodes(context) {
|
||||||
{
|
|
||||||
$('div.c-body', context).each(function () {
|
$('div.c-body', context).each(function () {
|
||||||
var $c = $(this);
|
var $c = $(this);
|
||||||
$c.before('<div class="c-head"><b>' + bbl['code'] + ':</b></div>');
|
$c.before('<div class="c-head"><b>' + bbl['code'] + ':</b></div>');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initQuotes(context)
|
function initQuotes(context) {
|
||||||
{
|
|
||||||
$('div.q', context).each(function () {
|
$('div.q', context).each(function () {
|
||||||
var $q = $(this);
|
var $q = $(this);
|
||||||
var name = $(this).attr('head');
|
var name = $(this).attr('head');
|
||||||
|
@ -337,8 +350,7 @@ function initQuotes(context)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initPostImages(context)
|
function initPostImages(context) {
|
||||||
{
|
|
||||||
if (hidePostImg) return;
|
if (hidePostImg) return;
|
||||||
var $in_spoilers = $('div.sp-body var.postImg', context);
|
var $in_spoilers = $('div.sp-body var.postImg', context);
|
||||||
$('var.postImg', context).not($in_spoilers).each(function () {
|
$('var.postImg', context).not($in_spoilers).each(function () {
|
||||||
|
@ -347,7 +359,9 @@ function initPostImages(context)
|
||||||
var $img = $('<img src="' + src + '" class="' + $v.attr('class') + '" alt="pic" />');
|
var $img = $('<img src="' + src + '" class="' + $v.attr('class') + '" alt="pic" />');
|
||||||
$img = fixPostImage($img);
|
$img = fixPostImage($img);
|
||||||
var maxW = ($v.hasClass('postImgAligned')) ? postImgAligned_MaxWidth : postImg_MaxWidth;
|
var maxW = ($v.hasClass('postImgAligned')) ? postImgAligned_MaxWidth : postImg_MaxWidth;
|
||||||
$img.bind('click', function(){ return imgFit(this, maxW); });
|
$img.bind('click', function () {
|
||||||
|
return imgFit(this, maxW);
|
||||||
|
});
|
||||||
if (user.opt_js.i_aft_l) {
|
if (user.opt_js.i_aft_l) {
|
||||||
$('#preload').append($img);
|
$('#preload').append($img);
|
||||||
var loading_icon = '<a href="' + src + '" target="_blank"><img src="' + bb_url + 'styles/images/pic_loading.gif" alt="" /></a>';
|
var loading_icon = '<a href="' + src + '" target="_blank"><img src="' + bb_url + 'styles/images/pic_loading.gif" alt="" /></a>';
|
||||||
|
@ -361,7 +375,9 @@ function initPostImages(context)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$img.one('load', function(){ imgFit(this, maxW) });
|
$img.one('load', function () {
|
||||||
|
imgFit(this, maxW)
|
||||||
|
});
|
||||||
$v.empty().append($img);
|
$v.empty().append($img);
|
||||||
if ($.browser.msie) {
|
if ($.browser.msie) {
|
||||||
$v.after('<wbr>');
|
$v.after('<wbr>');
|
||||||
|
@ -370,8 +386,7 @@ function initPostImages(context)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initSpoilers(context)
|
function initSpoilers(context) {
|
||||||
{
|
|
||||||
$('div.sp-body', context).each(function () {
|
$('div.sp-body', context).each(function () {
|
||||||
var $sp_body = $(this);
|
var $sp_body = $(this);
|
||||||
var name = $.trim(this.title) || '' + bbl['spoiler_head'] + '';
|
var name = $.trim(this.title) || '' + bbl['spoiler_head'] + '';
|
||||||
|
@ -390,7 +405,9 @@ function initSpoilers(context)
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.shiftKey = false;
|
e.shiftKey = false;
|
||||||
var fold = $(this).hasClass('unfolded');
|
var fold = $(this).hasClass('unfolded');
|
||||||
$('div.sp-head', $($sp_body.parents('td')[0])).filter( function(){ return $(this).hasClass('unfolded') ? fold : !fold } ).click();
|
$('div.sp-head', $($sp_body.parents('td')[0])).filter(function () {
|
||||||
|
return $(this).hasClass('unfolded') ? fold : !fold
|
||||||
|
}).click();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$(this).toggleClass('unfolded');
|
$(this).toggleClass('unfolded');
|
||||||
|
@ -400,26 +417,26 @@ function initSpoilers(context)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initExternalLinks(context)
|
function initExternalLinks(context) {
|
||||||
{
|
|
||||||
var context = context || 'body';
|
var context = context || 'body';
|
||||||
if (ExternalLinks_InNewWindow) {
|
if (ExternalLinks_InNewWindow) {
|
||||||
$("a.postLink:not([href*='" + window.location.hostname + "/'])", context).attr({target: '_blank'});
|
$("a.postLink:not([href*='" + window.location.hostname + "/'])", context).attr({target: '_blank'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function fixPostImage ($img)
|
function fixPostImage($img) {
|
||||||
{
|
|
||||||
var banned_image_hosts = /imagebanana|hidebehind/i;
|
var banned_image_hosts = /imagebanana|hidebehind/i;
|
||||||
var src = $img[0].src;
|
var src = $img[0].src;
|
||||||
if (src.match(banned_image_hosts)) {
|
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']+"" });
|
$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;
|
return $img;
|
||||||
}
|
}
|
||||||
|
|
||||||
function initMedia(context)
|
function initMedia(context) {
|
||||||
{
|
|
||||||
var apostLink = $('a.postLink', context);
|
var apostLink = $('a.postLink', context);
|
||||||
for (var i = 0; i < apostLink.length; i++) {
|
for (var i = 0; i < apostLink.length; i++) {
|
||||||
var link = apostLink[i];
|
var link = apostLink[i];
|
||||||
|
@ -449,5 +466,7 @@ function initMedia(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('div.post_wrap, div.signature').each(function(){ initPostBBCode( $(this) ) });
|
$('div.post_wrap, div.signature').each(function () {
|
||||||
|
initPostBBCode($(this))
|
||||||
|
});
|
||||||
});
|
});
|
|
@ -133,7 +133,7 @@ function refresh_username(selected_username)
|
||||||
opener.document.forms['post'].{INPUT_NAME}.value = selected_username;
|
opener.document.forms['post'].{INPUT_NAME}.value = selected_username;
|
||||||
opener.focus();
|
opener.focus();
|
||||||
window.close();
|
window.close();
|
||||||
};
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form method="post" name="search" action="{SEARCH_ACTION}">
|
<form method="post" name="search" action="{SEARCH_ACTION}">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue