Minor improvements (#982)

* Minor improvements

* Apply fixes from StyleCI (#981)

Co-authored-by: StyleCI Bot <bot@styleci.io>

---------

Co-authored-by: Yury Pikhtarev <exileum@icloud.com>
Co-authored-by: StyleCI Bot <bot@styleci.io>
This commit is contained in:
Roman Kelesidis 2023-10-22 21:29:09 +07:00 committed by GitHub
commit f02e902691
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 60 additions and 38 deletions

View file

@ -30,7 +30,7 @@ if (isset($_POST['bonus_id'])) {
$points = $price_row[$id];
if ($userdata['user_points'] < $points) {
meta_refresh('index.php', 5);
meta_refresh('index.php', 10);
$message = $lang['BONUS_NOT_SUCCES'] . '<br /><br /><a href="' . BONUS_URL . '">' . $lang['BONUS_RETURN'] . '</a><br /><br /><a href="' . PROFILE_URL . $userdata['user_id'] . '">' . $lang['RETURN_PROFILE'] . '</a><br /><br />' . sprintf($lang['CLICK_RETURN_INDEX'], '<a href="index.php">', '</a>');
@ -47,7 +47,7 @@ if (isset($_POST['bonus_id'])) {
");
\TorrentPier\Sessions::cache_rm_user_sessions($user_id);
meta_refresh(BONUS_URL, 5);
meta_refresh(BONUS_URL, 10);
$message = sprintf($lang['BONUS_SUCCES'], humn_size($upload_row[$id] * 1024 * 1024 * 1024));
$message .= '<br /><br /><a href="' . BONUS_URL . '">' . $lang['BONUS_RETURN'] . '</a><br /><br /><a href="' . PROFILE_URL . $userdata['user_id'] . '">' . $lang['RETURN_PROFILE'] . '</a><br /><br />' . sprintf($lang['CLICK_RETURN_INDEX'], '<a href="index.php">', '</a>');

View file

@ -95,7 +95,7 @@ if ($watch_count > 0) {
}
DB()->sql_freeresult($result);
} else {
meta_refresh('index.php', 3);
meta_refresh('index.php');
bb_die($lang['NO_WATCHED_TOPICS']);
}

View file

@ -87,10 +87,20 @@ class Common
}
}
public function debug_find_source($mode = '')
/**
* Find caller source
*
* @param string $mode
*
* @return string
*/
public function debug_find_source(string $mode = ''): string
{
if (!SQL_PREPEND_SRC_COMM) {
return 'src disabled';
}
foreach (debug_backtrace() as $trace) {
if ($trace['file'] !== __FILE__) {
if (!empty($trace['file']) && $trace['file'] !== __FILE__) {
switch ($mode) {
case 'file':
return $trace['file'];

View file

@ -52,8 +52,8 @@ class Sqlite extends Common
}
$this->db->shard($name);
$cached_items = [];
$this->prefix_len = \strlen($this->prefix);
$this->prefix_sql = SQLite3::escapeString($this->prefix);
$prefix_len = \strlen($this->prefix);
$prefix_sql = SQLite3::escapeString($this->prefix);
$name_ary = $name_sql = (array)$name;
array_deep($name_sql, 'SQLite3::escapeString');
@ -62,13 +62,13 @@ class Sqlite extends Common
$rowset = $this->db->fetch_rowset("
SELECT cache_name, cache_value
FROM " . $this->cfg['table_name'] . "
WHERE cache_name IN('$this->prefix_sql" . implode("','$this->prefix_sql", $name_sql) . "') AND cache_expire_time > " . TIMENOW . "
WHERE cache_name IN('$prefix_sql" . implode("','$prefix_sql", $name_sql) . "') AND cache_expire_time > " . TIMENOW . "
LIMIT " . \count($name_sql) . "
");
$this->db->debug('start', 'unserialize()');
foreach ($rowset as $row) {
$cached_items[substr($row['cache_name'], $this->prefix_len)] = unserialize($row['cache_value']);
$cached_items[substr($row['cache_name'], $prefix_len)] = unserialize($row['cache_value']);
}
$this->db->debug('stop');

View file

@ -16,6 +16,7 @@ namespace TorrentPier\Legacy\Common;
class Html
{
public $options = '';
public $out = '';
public $attr = [];
public $cur_attr;
public $max_length = HTML_SELECT_MAX_LENGTH;

View file

@ -161,10 +161,20 @@ class Common
}
}
public function debug_find_source($mode = '')
/**
* Find caller source
*
* @param string $mode
*
* @return string
*/
public function debug_find_source(string $mode = ''): string
{
if (!SQL_PREPEND_SRC_COMM) {
return 'src disabled';
}
foreach (debug_backtrace() as $trace) {
if ($trace['file'] !== __FILE__) {
if (!empty($trace['file']) && $trace['file'] !== __FILE__) {
switch ($mode) {
case 'file':
return $trace['file'];

View file

@ -128,9 +128,7 @@ class SqlDb
if (\is_array($query)) {
$query = $this->build_sql($query);
}
if (SQL_PREPEND_SRC_COMM) {
$query = '/* ' . $this->debug_find_source() . ' */ ' . $query;
}
$query = '/* ' . $this->debug_find_source() . ' */ ' . $query;
$this->cur_query = $query;
$this->debug('start');
@ -850,8 +848,11 @@ class SqlDb
*
* @return string
*/
public function debug_find_source($mode = '')
public function debug_find_source(string $mode = ''): string
{
if (!SQL_PREPEND_SRC_COMM) {
return 'src disabled';
}
foreach (debug_backtrace() as $trace) {
if (!empty($trace['file']) && $trace['file'] !== __FILE__) {
switch ($mode) {
@ -864,7 +865,7 @@ class SqlDb
}
}
}
return '';
return 'src not found';
}
/**

View file

@ -1,21 +1,21 @@
<table class="forumline">
<tr>
<th>{L_TERMS}</th>
</tr>
<!-- IF TERMS_HTML -->
<tr>
<td class="row1">
<div class="post_wrap">
{TERMS_HTML}
</div>
</td>
</tr>
<!-- ENDIF -->
<!-- IF IS_ADMIN -->
<tr>
<td class="row2">
{TERMS_EDIT}
</td>
</tr>
<!-- ENDIF -->
<tr>
<th>{L_TERMS}</th>
</tr>
<!-- IF TERMS_HTML -->
<tr>
<td class="row1">
<div class="post_wrap">
{TERMS_HTML}
</div>
</td>
</tr>
<!-- ENDIF -->
<!-- IF IS_ADMIN -->
<tr>
<td class="row1">
{TERMS_EDIT}
</td>
</tr>
<!-- ENDIF -->
</table>

View file

@ -165,11 +165,11 @@ ajax.callback.mod_action = function(data) {
</div>
<div class="floatR">
<input type="submit" name="delete" value="{L_DELETE}" />
<input type="submit" name="move" value="{L_MOVE}" />
<input type="submit" name="move" value="{L_MOVE}" />&nbsp;&middot;
<input type="submit" name="lock" value="{L_LOCK}" />
<input type="submit" name="unlock" value="{L_UNLOCK}" />
<input type="submit" name="unlock" value="{L_UNLOCK}" />&nbsp;&middot;
<input type="submit" name="post_pin" value="{L_POST_PIN}" />
<input type="submit" name="post_unpin" value="{L_POST_UNPIN}" />
<input type="submit" name="post_unpin" value="{L_POST_UNPIN}" />&nbsp;&middot;
<label><input id="in-new-window" type="checkbox" />{L_NEW_WINDOW}</label>
</div>
</form>