mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
Some reported bugfixes (#1275)
* Some reported bugfixes * Updated * Update common.php * Update BBCode.php
This commit is contained in:
parent
13bf41e776
commit
e8a90b025c
5 changed files with 29 additions and 31 deletions
|
@ -190,11 +190,11 @@ function file_write($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $replac
|
|||
$bytes_written = false;
|
||||
clearstatcache();
|
||||
|
||||
if (($max_size && file_exists($file) && is_file($file)) && filesize($file) >= $max_size) {
|
||||
if (is_file($file) && ($max_size && filesize($file) >= $max_size)) {
|
||||
$file_parts = pathinfo($file);
|
||||
$new_name = ($file_parts['dirname'] . '/' . $file_parts['filename'] . '_[old]_' . date('Y-m-d_H-i-s_') . getmypid() . '.' . $file_parts['extension']);
|
||||
clearstatcache();
|
||||
if (!file_exists($new_name) && !is_file($new_name)) {
|
||||
if (!is_file($new_name)) {
|
||||
rename($file, $new_name);
|
||||
}
|
||||
}
|
||||
|
@ -269,6 +269,7 @@ function str_compact($str)
|
|||
*
|
||||
* @param int $length
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
function make_rand_str(int $length = 10): string
|
||||
{
|
||||
|
|
|
@ -16,13 +16,13 @@ namespace TorrentPier\Legacy;
|
|||
class BBCode
|
||||
{
|
||||
/** @var array $tpl Replacements for some code elements */
|
||||
public $tpl = [];
|
||||
public array $tpl = [];
|
||||
|
||||
/** @var array $smilies Replacements for smilies */
|
||||
public $smilies;
|
||||
|
||||
/** @var array $tidy_cfg Tidy preprocessor configuration */
|
||||
public $tidy_cfg = [
|
||||
public array $tidy_cfg = [
|
||||
'drop-empty-paras' => false,
|
||||
'fix-uri' => false,
|
||||
'force-output' => true,
|
||||
|
@ -42,7 +42,7 @@ class BBCode
|
|||
];
|
||||
|
||||
/** @var array $block_tags Define some elements as block-processed */
|
||||
public $block_tags = [
|
||||
public array $block_tags = [
|
||||
'align',
|
||||
'br',
|
||||
'clear',
|
||||
|
@ -142,7 +142,7 @@ class BBCode
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function bbcode2html($text): string
|
||||
public function bbcode2html(string $text): string
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
|
@ -166,7 +166,7 @@ class BBCode
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
private function parse($text): string
|
||||
private function parse(string $text): string
|
||||
{
|
||||
// Tag parse
|
||||
if (!str_contains($text, '[')) {
|
||||
|
@ -205,23 +205,22 @@ class BBCode
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function clean_up($text): string
|
||||
public static function clean_up(string $text): string
|
||||
{
|
||||
$text = trim($text);
|
||||
$text = str_replace("\r", '', $text);
|
||||
$text = preg_replace('#[ \t]+$#m', '', $text);
|
||||
$text = preg_replace('#\n{3,}#', "\n\n", $text);
|
||||
return $text;
|
||||
return preg_replace('#\n{3,}#', "\n\n", $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to [code]
|
||||
*
|
||||
* @param string $m
|
||||
* @param array $m
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function code_callback($m): string
|
||||
private function code_callback(array $m): string
|
||||
{
|
||||
$code = trim($m[2]);
|
||||
$code = str_replace(' ', ' ', $code);
|
||||
|
@ -234,11 +233,11 @@ class BBCode
|
|||
/**
|
||||
* Callback to [url]
|
||||
*
|
||||
* @param string $m
|
||||
* @param array $m
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function url_callback($m): string
|
||||
private function url_callback(array $m): string
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
|
@ -261,11 +260,11 @@ class BBCode
|
|||
/**
|
||||
* Callback to escape titles in block elements
|
||||
*
|
||||
* @param string $m
|
||||
* @param array $m
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function escape_titles_callback($m): string
|
||||
private function escape_titles_callback(array $m): string
|
||||
{
|
||||
$title = substr($m[3], 0, 250);
|
||||
$title = str_replace(['[', ']', ':', ')', '"'], ['[', ']', ':', ')', '"'], $title);
|
||||
|
@ -281,7 +280,7 @@ class BBCode
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
private function make_clickable($text): string
|
||||
private function make_clickable(string $text): string
|
||||
{
|
||||
$url_regexp = "#
|
||||
(?<![\"'=])
|
||||
|
@ -311,11 +310,11 @@ class BBCode
|
|||
/**
|
||||
* Callback to make URL clickable
|
||||
*
|
||||
* @param string $m
|
||||
* @param array $m
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function make_url_clickable_callback($m): string
|
||||
private function make_url_clickable_callback(array $m): string
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
|
@ -339,9 +338,9 @@ class BBCode
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
private function smilies_pass($text): string
|
||||
private function smilies_pass(string $text): string
|
||||
{
|
||||
global $bb_cfg, $datastore;
|
||||
global $datastore;
|
||||
|
||||
if (null === $this->smilies) {
|
||||
$this->smilies = $datastore->get('smile_replacements');
|
||||
|
@ -364,11 +363,10 @@ class BBCode
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
private function new_line2html($text): string
|
||||
private function new_line2html(string $text): string
|
||||
{
|
||||
$text = preg_replace('#\n{2,}#', '<span class="post-br"><br /></span>', $text);
|
||||
$text = str_replace("\n", '<br />', $text);
|
||||
return $text;
|
||||
return str_replace("\n", '<br />', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -378,9 +376,8 @@ class BBCode
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
private function tidy($text): string
|
||||
private function tidy(string $text): string
|
||||
{
|
||||
$text = tidy_repair_string($text, $this->tidy_cfg, 'utf8');
|
||||
return $text;
|
||||
return tidy_repair_string($text, $this->tidy_cfg, 'utf8');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,12 +219,12 @@ class User
|
|||
|
||||
// Initial ban check
|
||||
if ($banInfo = getBanInfo((int)$this->id)) {
|
||||
$this->session_end();
|
||||
if (!empty($banInfo['ban_reason'])) {
|
||||
bb_die($lang['YOU_BEEN_BANNED'] . '<br><br>' . $banInfo['ban_reason']);
|
||||
bb_die($lang['YOU_BEEN_BANNED'] . '<br><br>' . $lang['REASON'] . ': ' . '<b>' . $banInfo['ban_reason'] . '</b>');
|
||||
} else {
|
||||
bb_die($lang['YOU_BEEN_BANNED']);
|
||||
}
|
||||
$this->session_end();
|
||||
}
|
||||
|
||||
return $this->data;
|
||||
|
|
|
@ -939,7 +939,7 @@ class SqlDb
|
|||
$msg[] = 'PID : ' . sprintf('%05d', getmypid());
|
||||
$msg[] = 'Request : ' . trim(print_r($_REQUEST, true)) . str_repeat('_', 78) . LOG_LF;
|
||||
$msg[] = '';
|
||||
bb_log($msg, IN_TRACKER ? SQL_TR_LOG_NAME : SQL_BB_LOG_NAME);
|
||||
bb_log($msg, (defined('IN_TRACKER') ? SQL_TR_LOG_NAME : SQL_BB_LOG_NAME));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<td class="row2"><input type="text" size="3" maxlength="4" name="img_link_width" value="{IMAGE_LINK_WIDTH}" class="post" /> x <input type="text" size="3" maxlength="4" name="img_link_height" value="{IMAGE_LINK_HEIGHT}" class="post" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="catBottom" colspan="2">{S_HIDDEN_FIELDS}<input type="submit" name="submit" value="{L_SUBMIT}" class="mainoption" /> <input type="reset" value="{L_RESET}" class="liteoption" /> <input type="submit" name="search_imagick" value="{L_IMAGE_SEARCH_IMAGICK}" class="liteoption" /> <input type="submit" name="cat_settings" value="{L_TEST_SETTINGS}" class="liteoption" /></td>
|
||||
<td class="catBottom" colspan="2">{S_HIDDEN_FIELDS}<input type="submit" name="submit" value="{L_SUBMIT}" class="mainoption" /> <input type="reset" value="{L_RESET}" class="liteoption" /> <input type="submit" name="cat_settings" value="{L_TEST_SETTINGS}" class="liteoption" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue