diff --git a/common.php b/common.php
index 9dd51601b..81d9debbf 100644
--- a/common.php
+++ b/common.php
@@ -257,7 +257,7 @@ function file_write ($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $repla
{
$bytes_written = false;
- if ($max_size && filesize($file) >= $max_size)
+ if (file_exists($file) && $max_size && filesize($file) >= $max_size)
{
$old_name = $file; $ext = '';
if (preg_match('#^(.+)(\.[^\\/]+)$#', $file, $matches))
diff --git a/library/includes/cron/cron_init.php b/library/includes/cron/cron_init.php
index 227b31260..8c7398796 100644
--- a/library/includes/cron/cron_init.php
+++ b/library/includes/cron/cron_init.php
@@ -30,7 +30,7 @@ function cron_get_file_lock ()
function cron_track_running ($mode)
{
- 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());
if ($mode == 'start')
{
diff --git a/library/includes/functions.php b/library/includes/functions.php
index b269e926b..e03e4d8bc 100644
--- a/library/includes/functions.php
+++ b/library/includes/functions.php
@@ -2029,7 +2029,7 @@ function get_topic_icon ($topic, $is_unread = null)
$folder = $images['folder_locked'];
$folder_new = $images['folder_locked_new'];
}
- else if ($topic['tracker_status'])
+ else if (isset($topic['tracker_status']))
{
$folder = ($t_hot) ? $images['folder_dl_hot'] : $images['folder_dl'];
$folder_new = ($t_hot) ? $images['folder_dl_hot_new'] : $images['folder_dl_new'];
diff --git a/library/includes/init_bb.php b/library/includes/init_bb.php
index e7c5d2cef..dc1521927 100644
--- a/library/includes/init_bb.php
+++ b/library/includes/init_bb.php
@@ -496,10 +496,14 @@ function cron_touch_lock_file ($lock_file)
function cron_enable_board ()
{
- rename(BB_DISABLED, BB_ENABLED);
+ if (file_exists(BB_DISABLED)) {
+ rename(BB_DISABLED, BB_ENABLED);
+ }
}
function cron_disable_board ()
{
- rename(BB_ENABLED, BB_DISABLED);
+ if (file_exists(BB_ENABLED)) {
+ rename(BB_ENABLED, BB_DISABLED);
+ }
}
\ No newline at end of file
diff --git a/library/includes/torrent_show_dl_list.php b/library/includes/torrent_show_dl_list.php
index c17946adf..458172e01 100644
--- a/library/includes/torrent_show_dl_list.php
+++ b/library/includes/torrent_show_dl_list.php
@@ -2,6 +2,9 @@
if (!defined('BB_ROOT')) die(basename(__FILE__));
+/** @var \TorrentPier\Di $di */
+$di = \TorrentPier\Di::getInstance();
+
$show_canceled_in_count_mode = false;
$title_date_format = 'Y-m-d';
$dl_list_sql_limit = 300; // DL-List overall limit
@@ -12,15 +15,15 @@ $dl_users_div_style_overflow = "padding: 6px; height: $dl_users_overflow_div_he
$template->assign_vars(array('DL_BUTTONS' => false));
-$count_mode = ($bb_cfg['bt_dl_list_only_count'] && !($_GET['dl'] === 'names'));
+$count_mode = ($bb_cfg['bt_dl_list_only_count'] && !($di->request->get('dl') === 'names'));
-$dl_topic = ($t_data['tracker_status'] && !($bb_cfg['bt_dl_list_only_1st_page'] && $start));
-$show_dl_list = ($dl_topic && ($bb_cfg['bt_show_dl_list'] || ($bb_cfg['allow_dl_list_names_mode'] && $_GET['dl'] === 'names')));
+$dl_topic = (isset($t_data['tracker_status']) && !($bb_cfg['bt_dl_list_only_1st_page'] && $start));
+$show_dl_list = ($dl_topic && ($bb_cfg['bt_show_dl_list'] || ($bb_cfg['allow_dl_list_names_mode'] && $di->request->get('dl') === 'names')));
$show_dl_buttons = ($dl_topic && $bb_cfg['bt_show_dl_list_buttons']);
// link to clear DL-List
$template->assign_vars(array('S_DL_DELETE' => false));
-if ($is_auth['auth_mod'] && $t_data['tracker_status'])
+if ($is_auth['auth_mod'] && isset($t_data['tracker_status']))
{
$s_dl_delete = "'. $lang['DL_LIST_DEL'] .'';
$template->assign_vars(array('S_DL_DELETE' => $s_dl_delete));
diff --git a/library/language/en/main.php b/library/language/en/main.php
index 26b16fe69..7b0473e61 100644
--- a/library/language/en/main.php
+++ b/library/language/en/main.php
@@ -2333,8 +2333,8 @@ $lang['BOARD_DISABLE_EXPL'] = 'disable board when this job is run';
$lang['RUN_COUNTER'] = 'Run counter';
$lang['JOB_REMOVED'] = 'The problem has been removed successfully';
-$lang['SCRIPT_DUPLICATE'] = 'Script '. $_POST['cron_script'] .' already exists!';
-$lang['TITLE_DUPLICATE'] = 'Task Name '. $_POST['cron_title'] .' already exists!';
+$lang['SCRIPT_DUPLICATE'] = 'Script $_POST["cron_script"] already exists!';
+$lang['TITLE_DUPLICATE'] = 'Task Name $_POST["cron_title"] already exists!';
$lang['CLICK_RETURN_JOBS_ADDED'] = '%sReturn to the addition problem%s';
$lang['CLICK_RETURN_JOBS'] = '%sBack to the Task Scheduler%s';
diff --git a/library/language/ru/main.php b/library/language/ru/main.php
index c670fdcfd..088576a38 100644
--- a/library/language/ru/main.php
+++ b/library/language/ru/main.php
@@ -2333,8 +2333,8 @@ $lang['BOARD_DISABLE_EXPL'] = 'отключать форум, когда зад
$lang['RUN_COUNTER'] = 'Кол-во запусков';
$lang['JOB_REMOVED'] = 'Задача была успешно удалена';
-$lang['SCRIPT_DUPLICATE'] = 'Скрипт '. $_POST['cron_script'] .' уже существует!';
-$lang['TITLE_DUPLICATE'] = 'Название задачи '. $_POST['cron_title'] .' уже существует!';
+$lang['SCRIPT_DUPLICATE'] = 'Скрипт $_POST["cron_script"] уже существует!';
+$lang['TITLE_DUPLICATE'] = 'Название задачи $_POST["cron_title"] уже существует!';
$lang['CLICK_RETURN_JOBS_ADDED'] = '%sВернуться к добавлению задачи%s';
$lang['CLICK_RETURN_JOBS'] = '%sВернуться к планировщику задач%s';
diff --git a/library/language/uk/main.php b/library/language/uk/main.php
index 77ee1547a..926224fae 100644
--- a/library/language/uk/main.php
+++ b/library/language/uk/main.php
@@ -2333,8 +2333,8 @@ $lang['BOARD_DISABLE_EXPL'] = 'відключати форум, коли зав
$lang['RUN_COUNTER'] = 'Кількість запусків';
$lang['JOB_REMOVED'] = 'Завдання було успішно видалено';
-$lang['SCRIPT_DUPLICATE'] = 'Скрипт '. $_POST['cron_script'] .' вже існує!';
-$lang['TITLE_DUPLICATE'] = 'Назва завдання '. $_POST['cron_title'] .' вже існує!';
+$lang['SCRIPT_DUPLICATE'] = 'Скрипт $_POST["cron_script"] вже існує!';
+$lang['TITLE_DUPLICATE'] = 'Назва завдання $_POST["cron_title"] вже існує!';
$lang['CLICK_RETURN_JOBS_ADDED'] = '%sПовернутися до додавання задачі%s';
$lang['CLICK_RETURN_JOBS'] = '%sПовернутися до планувальника завдань%s';
diff --git a/posting.php b/posting.php
index e947e779d..0c9b80dbf 100644
--- a/posting.php
+++ b/posting.php
@@ -3,6 +3,10 @@
define('BB_SCRIPT', 'posting');
define('BB_ROOT', './');
require(BB_ROOT ."common.php");
+
+/** @var \TorrentPier\Di $di */
+$di = \TorrentPier\Di::getInstance();
+
require(INC_DIR .'bbcode.php');
require(INC_DIR .'functions_post.php');
@@ -11,13 +15,13 @@ $user->session_start();
$page_cfg['load_tpl_vars'] = ['post_icons'];
-$submit = (bool) $_REQUEST['post'];
-$preview = (bool) $_REQUEST['preview'];
-$delete = (bool) $_REQUEST['delete'];
+$submit = $di->request->request->has('post');
+$preview = $di->request->request->has('preview');
+$delete = $di->request->request->has('delete');
-$forum_id = (int) $_REQUEST[POST_FORUM_URL];
-$topic_id = (int) $_REQUEST[POST_TOPIC_URL];
-$post_id = (int) $_REQUEST[POST_POST_URL];
+$forum_id = $di->request->request->getInt(POST_FORUM_URL);
+$topic_id = $di->request->request->getInt(POST_TOPIC_URL);
+$post_id = $di->request->request->getInt(POST_POST_URL);
$mode = (string) $_REQUEST['mode'];
@@ -26,7 +30,7 @@ $confirm = isset($_POST['confirm']);
$orig_word = $replacement_word = [];
// Set topic type
-$topic_type = ($_POST['topictype']) ? (int) $_POST['topictype'] : POST_NORMAL;
+$topic_type = $di->request->request->getInt('topictype', POST_NORMAL);
$topic_type = in_array($topic_type, [POST_NORMAL, POST_STICKY, POST_ANNOUNCE]) ? $topic_type : POST_NORMAL;
$selected_rg = $switch_rg_sig = $switch_poster_rg_sig = 0;
diff --git a/search.php b/search.php
index 3278b2ea4..389052a9f 100644
--- a/search.php
+++ b/search.php
@@ -819,7 +819,7 @@ else
'ATTACH' => $topic['attach_ext_id'],
'STATUS' => $topic['topic_status'],
'TYPE' => $topic['topic_type'],
- 'DL' => $topic['tracker_status'],
+ 'DL' => isset($topic['tracker_status']) ? $topic['tracker_status'] : null,
'POLL' => $topic['topic_vote'],
'DL_CLASS' => isset($topic['dl_status']) ? $dl_link_css[$topic['dl_status']] : '',
diff --git a/styleguide.php b/styleguide.php
index 951a010a2..7bcb54184 100644
--- a/styleguide.php
+++ b/styleguide.php
@@ -9,6 +9,11 @@ $di = \TorrentPier\Di::getInstance();
/** @var \TorrentPier\Db\Adapter $db */
$db = $di->db;
+///** @var \Symfony\Component\HttpFoundation\Request $request */
+//$request = $di->request;
+//$request->request->has()
+
+
//$id = $db->insert(BB_USERS, [
// 'username' => 'user_' . rand(1, 50)
//]);
diff --git a/viewforum.php b/viewforum.php
index dbbd4775f..db4639720 100644
--- a/viewforum.php
+++ b/viewforum.php
@@ -4,6 +4,9 @@ define('BB_SCRIPT', 'forum');
define('BB_ROOT', './');
require(BB_ROOT . 'common.php');
+/** @var \TorrentPier\Di $di */
+$di = \TorrentPier\Di::getInstance();
+
$page_cfg['include_bbcode_js'] = true;
$show_last_topic = true;
@@ -231,7 +234,8 @@ $select_tpp = '';
if ($is_auth['auth_mod'])
{
- if ($req_tpp = abs(intval($_REQUEST['tpp'])) AND in_array($req_tpp, $bb_cfg['allowed_topics_per_page']))
+
+ if ($req_tpp = $di->request->query->getInt('tpp') AND in_array($req_tpp, $bb_cfg['allowed_topics_per_page']))
{
$topics_per_page = $req_tpp;
}
@@ -260,7 +264,7 @@ $sel_previous_days = array(
if (!empty($_REQUEST['topicdays']))
{
- if ($req_topic_days = abs(intval($_REQUEST['topicdays'])) AND isset($sel_previous_days[$req_topic_days]))
+ if ($req_topic_days = $di->request->query->getInt('topicdays') AND isset($sel_previous_days[$req_topic_days]))
{
$sql = "
SELECT COUNT(*) AS forum_topics
@@ -485,7 +489,7 @@ foreach ($topic_rowset as $topic)
'ATTACH' => $topic['attach_ext_id'],
'STATUS' => $topic['topic_status'],
'TYPE' => $topic['topic_type'],
- 'DL' => ($topic['tracker_status'] && !$forum_data['allow_reg_tracker']),
+ 'DL' => (isset($topic['tracker_status']) && !$forum_data['allow_reg_tracker']),
'POLL' => $topic['topic_vote'],
'DL_CLASS' => isset($topic['dl_status']) ? $dl_link_css[$topic['dl_status']] : '',
diff --git a/viewtopic.php b/viewtopic.php
index de9f76963..a627011bf 100644
--- a/viewtopic.php
+++ b/viewtopic.php
@@ -3,6 +3,10 @@
define('BB_SCRIPT', 'topic');
define('BB_ROOT', './');
require(BB_ROOT .'common.php');
+
+/** @var \TorrentPier\Di $di */
+$di = \TorrentPier\Di::getInstance();
+
require(INC_DIR .'bbcode.php');
$datastore->enqueue(array(
@@ -29,7 +33,7 @@ $select_ppp = '';
if ($userdata['session_admin'])
{
- if ($req_ppp = abs(intval($_REQUEST['ppp'])) AND in_array($req_ppp, $bb_cfg['allowed_posts_per_page']))
+ if ($req_ppp = $di->request->query->getInt('ppp') AND in_array($req_ppp, $bb_cfg['allowed_posts_per_page']))
{
$posts_per_page = $req_ppp;
}