Small bit of code cleanup.

This commit is contained in:
Floorb 2021-07-17 18:29:36 -04:00
parent 8f940d718d
commit 3b9d09ef7b
32 changed files with 98 additions and 163 deletions

View file

@ -65,4 +65,3 @@ require('ssp.pastes.php');
echo json_encode( echo json_encode(
SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns, $columns2) SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns, $columns2)
); );
?>

View file

@ -1,9 +1,7 @@
<?php <?php
session_start(); session_start();
if (isset($_SESSION['login'])) { if (!isset($_SESSION['login'])) {
// Do nothing
} else {
header("Location: ."); header("Location: .");
exit(); exit();
} }
@ -65,4 +63,3 @@ require('ssp.reports.php');
echo json_encode( echo json_encode(
SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns, $columns2) SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns, $columns2)
); );
?>

View file

@ -54,4 +54,4 @@ if ($_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") {
header("Location: http://ponepaste.org/SVOtaKqJZh4nT9Z"); header("Location: http://ponepaste.org/SVOtaKqJZh4nT9Z");
die(); die();
} }
?>

View file

@ -14,9 +14,7 @@
*/ */
session_start(); session_start();
if (isset($_SESSION['login'])) { if (!isset($_SESSION['login'])) {
// Do nothing
} else {
header("Location: ."); header("Location: .");
exit(); exit();
} }
@ -57,9 +55,7 @@ while ($row = mysqli_fetch_array($result)) {
} }
if ($last_ip == $ip) { if ($last_ip == $ip) {
if ($last_date == $date) { if ($last_date != $date) {
} else {
$query = "INSERT INTO admin_history (last_date,ip) VALUES ('$date','$ip')"; $query = "INSERT INTO admin_history (last_date,ip) VALUES ('$date','$ip')";
mysqli_query($con, $query); mysqli_query($con, $query);
} }
@ -192,8 +188,7 @@ if ($last_ip == $ip) {
$fname = explode('.php', $files1[$loop]); $fname = explode('.php', $files1[$loop]);
$fname = $fname[0]; $fname = $fname[0];
$ffname = $files1[$loop]; $ffname = $files1[$loop];
if ($ffname == "index.php") {/* we don't want index.php showing */ if ($ffname != "index.php") {
} else {
echo '<option value="' . $ffname . '">' . $fname . '</option>'; echo '<option value="' . $ffname . '">' . $fname . '</option>';
} }
} }

View file

@ -14,9 +14,7 @@
*/ */
session_start(); session_start();
if (isset($_SESSION['login'])) { if (!isset($_SESSION['login'])) {
// Do nothing
} else {
header("Location: ."); header("Location: .");
exit(); exit();
} }
@ -57,9 +55,7 @@ while ($row = mysqli_fetch_array($result)) {
} }
if ($last_ip == $ip) { if ($last_ip == $ip) {
if ($last_date == $date) { if ($last_date != $date) {
} else {
$query = "INSERT INTO admin_history (last_date,ip) VALUES ('$date','$ip')"; $query = "INSERT INTO admin_history (last_date,ip) VALUES ('$date','$ip')";
mysqli_query($con, $query); mysqli_query($con, $query);
} }
@ -97,7 +93,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' || isset($_GET['banip'])) {
} }
} }
if (isset($_GET{'delete'})) { if (isset($_GET['delete'])) {
$delete = htmlentities(Trim($_GET['delete'])); $delete = htmlentities(Trim($_GET['delete']));
$query = "DELETE FROM ban_user WHERE id=$delete"; $query = "DELETE FROM ban_user WHERE id=$delete";
$result = mysqli_query($con, $query); $result = mysqli_query($con, $query);
@ -237,8 +233,8 @@ if (isset($_GET{'delete'})) {
$rec_count = Trim($row[0]); $rec_count = Trim($row[0]);
if (isset($_GET{'page'})) { // Current page if (isset($_GET['page'])) { // Current page
$page = $_GET{'page'} + 1; $page = $_GET['page'] + 1;
$offset = $rec_limit * $page; $offset = $rec_limit * $page;
} else { } else {
// Show first set of results // Show first set of results

View file

@ -14,4 +14,4 @@
------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------
</pre><div style="display:none"></body> */ </pre><div style="display:none"></body> */
include "assets/posteddata.php"; ?> include "assets/posteddata.php";

View file

@ -18,28 +18,27 @@ require_once('common.php');
updateAdminHistory($conn); updateAdminHistory($conn);
if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST{'editme'})) { if (isset($_POST['editme'])) {
$edit_me_id = htmlentities(Trim($_POST['editme'])); $edit_me_id = htmlentities(Trim($_POST['editme']));
$page_name = Trim($_POST['page_name']); $page_name = Trim($_POST['page_name']);
$page_title = Trim($_POST['page_title']); $page_title = Trim($_POST['page_title']);
$page_content = $_POST['data']; $page_content = $_POST['data'];
$query = "UPDATE pages SET last_date='$date', page_name='$page_name', page_title='$page_title', page_content='$page_content' WHERE id='$edit_me_id'"; $query = "UPDATE pages SET last_date='$date', page_name='$page_name', page_title='$page_title', page_content='$page_content' WHERE id='$edit_me_id'";
mysqli_query($con, $query);
} else { } else {
$page_name = Trim($_POST['page_name']); $page_name = Trim($_POST['page_name']);
$page_title = Trim($_POST['page_title']); $page_title = Trim($_POST['page_title']);
$page_content = $_POST['data']; $page_content = $_POST['data'];
$query = "INSERT INTO pages (last_date,page_name,page_title,page_content) VALUES ('$date','$page_name','$page_title','$page_content')"; $query = "INSERT INTO pages (last_date,page_name,page_title,page_content) VALUES ('$date','$page_name','$page_title','$page_content')";
mysqli_query($con, $query);
} }
mysqli_query($con, $query);
$page_name = ""; $page_name = "";
$page_title = ""; $page_title = "";
$page_content = ""; $page_content = "";
} }
if (isset($_GET{'edit'})) { if (isset($_GET['edit'])) {
$page_id = trim($_GET['edit']); $page_id = trim($_GET['edit']);
$sql = "SELECT * FROM pages where id='$page_id'"; $sql = "SELECT * FROM pages where id='$page_id'";
@ -120,7 +119,7 @@ if (isset($_GET{'edit'})) {
</div> </div>
<br/> <br/>
<?php <?php
if (isset($_GET{'edit'})) { if (isset($_GET['edit'])) {
echo '<input type="hidden" value=' . $_GET['edit'] . 'id="editme" name="editme" />'; echo '<input type="hidden" value=' . $_GET['edit'] . 'id="editme" name="editme" />';
} }
?> ?>
@ -151,7 +150,7 @@ if (isset($_GET{'edit'})) {
<th>Delete</th> <th>Delete</th>
<?php <?php
if (isset($_GET{'delete'})) { if (isset($_GET['delete'])) {
$delete = htmlentities(Trim($_GET['delete'])); $delete = htmlentities(Trim($_GET['delete']));
$query = "DELETE FROM pages WHERE id=$delete"; $query = "DELETE FROM pages WHERE id=$delete";
$result = mysqli_query($con, $query); $result = mysqli_query($con, $query);

View file

@ -395,4 +395,3 @@ class SSP {
} }
} }
?>

View file

@ -395,4 +395,3 @@ class SSP {
} }
} }
?>

View file

@ -399,4 +399,3 @@ if ($_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") {
header("Location: http://ponepaste.org/SVOtaKqJZh4nT9Z"); header("Location: http://ponepaste.org/SVOtaKqJZh4nT9Z");
die(); die();
} }
?>

View file

@ -14,9 +14,7 @@
*/ */
session_start(); session_start();
if (isset($_SESSION['login'])) { if (!isset($_SESSION['login'])) {
// Do nothing
} else {
header("Location: ."); header("Location: .");
exit(); exit();
} }

View file

@ -43,4 +43,3 @@ require('ssp.pastes.php');
echo json_encode( echo json_encode(
SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns, $columns2) SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns, $columns2)
); );
?>

View file

@ -281,8 +281,7 @@ class SSP {
} catch (PDOException $e) { } catch (PDOException $e) {
self::fatal("An SQL error occurred: " . $e->getMessage()); self::fatal("An SQL error occurred: " . $e->getMessage());
} }
$result = $stmt->fetchAll(); return $stmt->fetchAll();
return $result;
} }
static function Ssql_exec($db, $bindings, $sql = null) { static function Ssql_exec($db, $bindings, $sql = null) {
@ -389,4 +388,3 @@ class SSP {
} }
} }
?>

View file

@ -308,8 +308,7 @@ class SSP {
} catch (PDOException $e) { } catch (PDOException $e) {
self::fatal("An SQL error occurred: " . $e->getMessage()); self::fatal("An SQL error occurred: " . $e->getMessage());
} }
$result = $stmt->fetchAll(); return $stmt->fetchAll();
return $result;
} }
static function Ssql_exec($db, $bindings, $sql = null) { static function Ssql_exec($db, $bindings, $sql = null) {
@ -341,7 +340,7 @@ class SSP {
$result[$loop]['id'] = $arr['id']; $result[$loop]['id'] = $arr['id'];
$result[$loop]['member'] = $arr['member']; $result[$loop]['member'] = $arr['member'];
$result[$loop]['tagsys'] = sandwitch($arr['tagsys']); $result[$loop]['tagsys'] = sandwitch($arr['tagsys']);
$date_time = strtotime(isset($arr['date']) ? $arr['date'] : '0'); $date_time = strtotime($arr['date'] ?? '0');
$result[$loop]['date'] = date("d F Y", $date_time); $result[$loop]['date'] = date("d F Y", $date_time);
$myid = $arr['id']; $myid = $arr['id'];
$mytitle = $arr['title']; $mytitle = $arr['title'];

View file

@ -33,4 +33,3 @@ $p_title = $lang['archive']; // "Pastes Archive";
require_once('theme/' . $default_theme . '/header.php'); require_once('theme/' . $default_theme . '/header.php');
require_once('theme/' . $default_theme . '/archive.php'); require_once('theme/' . $default_theme . '/archive.php');
require_once('theme/' . $default_theme . '/footer.php'); require_once('theme/' . $default_theme . '/footer.php');
?>

View file

@ -29,4 +29,3 @@ $p_title = $lang['archive']; // "Pastes Archive";
require_once('theme/' . $default_theme . '/header.php'); require_once('theme/' . $default_theme . '/header.php');
require_once('theme/' . $default_theme . '/event.php'); require_once('theme/' . $default_theme . '/event.php');
require_once('theme/' . $default_theme . '/footer.php'); require_once('theme/' . $default_theme . '/footer.php');
?>

View file

@ -1,5 +1,9 @@
<?php <?php
function captcha($color, $mode, $mul, $allowed) {
use JetBrains\PhpStorm\ArrayShape;
#[ArrayShape(['code' => "mixed|string", 'image_src' => "string"])]
function captcha($color, $mode, $mul, $allowed) : array {
$bg_path = dirname(__FILE__) . '/captchabg/'; $bg_path = dirname(__FILE__) . '/captchabg/';
$font_path = dirname(__FILE__) . '/fonts/'; $font_path = dirname(__FILE__) . '/fonts/';
@ -100,10 +104,10 @@ function captcha($color, $mode, $mul, $allowed) {
$_SESSION['_CAPTCHA']['config'] = serialize($captcha_config); $_SESSION['_CAPTCHA']['config'] = serialize($captcha_config);
return array( return [
'code' => $captcha_config['code'], 'code' => $captcha_config['code'],
'image_src' => $image_src 'image_src' => $image_src
); ];
} }

View file

@ -68,14 +68,13 @@ function updatePageViews(PDO $conn) : void {
$last_date = $last_page_view['date']; $last_date = $last_page_view['date'];
if ($last_date == $date) { if ($last_date == $date) {
if (str_contains($data_ip, $ip)) { $last_tpage = intval($last_page_view['tpage']) + 1;
$last_tpage = intval($last_page_view['tpage']) + 1;
if (str_contains($data_ip, $ip)) {
// IP already exists, Update view count // IP already exists, Update view count
$statement = $conn->prepare("UPDATE page_view SET tpage = ? WHERE id = ?"); $statement = $conn->prepare("UPDATE page_view SET tpage = ? WHERE id = ?");
$statement->execute([$last_tpage, $last_page_view['id']]); $statement->execute([$last_tpage, $last_page_view['id']]);
} else { } else {
$last_tpage = intval($last_page_view['tpage']) + 1;
$last_tvisit = intval($last_page_view['tvisit']) + 1; $last_tvisit = intval($last_page_view['tvisit']) + 1;
// Update both tpage and tvisit. // Update both tpage and tvisit.

View file

@ -13,19 +13,6 @@
* GNU General Public License in GPL.txt for more details. * GNU General Public License in GPL.txt for more details.
*/ */
function timer() {
static $start;
if (is_null($start)) {
$start = microtime(true);
} else {
$diff = round((microtime(true) - $start), 4);
$start = null;
return $diff;
}
}
function getUserFavs(PDO $conn, string $user_id) : array { function getUserFavs(PDO $conn, string $user_id) : array {
$query = $conn->prepare( $query = $conn->prepare(
"SELECT pins.f_time, pastes.id, pastes.title, pastes.created_at, pastes.tagsys "SELECT pins.f_time, pastes.id, pastes.title, pastes.created_at, pastes.tagsys
@ -100,21 +87,16 @@ function linkify($value, $protocols = array('http', 'mail'), array $attributes =
// Extract text links for each protocol // Extract text links for each protocol
foreach ((array)$protocols as $protocol) { foreach ((array)$protocols as $protocol) {
switch ($protocol) { $value = match ($protocol) {
case 'http': 'http', 'https' => preg_replace_callback('~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i', function ($match) use ($protocol, &$links, $attr) {
case 'https': if ($match[1]) $protocol = $match[1];
$value = preg_replace_callback('~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i', function ($match) use ($protocol, &$links, $attr) { $link = $match[2] ?: $match[3];
if ($match[1]) $protocol = $match[1]; return '<' . array_push($links, "<a $attr href=\"$protocol://$link\">$protocol://$link</a>") . '>';
$link = $match[2] ?: $match[3]; }, $value),
return '<' . array_push($links, "<a $attr href=\"$protocol://$link\">$protocol://$link</a>") . '>'; default => preg_replace_callback('~' . preg_quote($protocol, '~') . '://([^\s<]+?)(?<![\.,:])~i', function ($match) use ($protocol, &$links, $attr) {
}, $value); return '<' . array_push($links, "<a $attr href=\"$protocol://{$match[1]}\">$protocol://{$match[1]}</a>") . '>';
break; }, $value),
default: };
$value = preg_replace_callback('~' . preg_quote($protocol, '~') . '://([^\s<]+?)(?<![\.,:])~i', function ($match) use ($protocol, &$links, $attr) {
return '<' . array_push($links, "<a $attr href=\"$protocol://{$match[1]}\">$protocol://{$match[1]}</a>") . '>';
}, $value);
break;
}
} }
// Insert all link // Insert all link
@ -213,7 +195,7 @@ function getRecent($conn, $count) {
} }
function getRecentadmin($conn, $count = 5) { function getRecentadmin($conn, $count = 5) {
$query = $conn->prepare('SELECT id, ip title, date, now_time, views, member FROM pastes ORDER BY id DESC LIMIT 0, ?'); $query = $conn->prepare('SELECT id, ip, title, date, now_time, views, member FROM pastes ORDER BY id DESC LIMIT 0, ?');
$query->execute([$count]); $query->execute([$count]);
return $query->fetchAll(); return $query->fetchAll();
@ -255,8 +237,8 @@ LIMIT 0 , ?");
function getUserPastes(PDO $conn, $user_id) : array { function getUserPastes(PDO $conn, $user_id) : array {
$query = $conn->prepare( $query = $conn->prepare(
"SELECT id, title, visible,code,created_at,tagsys,user_id from pastes WHERE user_id= ? "SELECT id, title, visible, code, created_at, tagsys, user_id, views from pastes WHERE user_id = ?
ORDER by pastes.id DESC"); ORDER by pastes.id DESC");
$query->execute([$user_id]); $query->execute([$user_id]);
return $query->fetchAll(); return $query->fetchAll();
} }
@ -350,8 +332,7 @@ function conTime($secs) {
$ret[] = 'ago'; $ret[] = 'ago';
$val = join(' ', $ret); $val = join(' ', $ret);
if (str_conntains($val, "week")) { if (!str_conntains($val, "week")) {
} else {
$val = str_replace("and", "", $val); $val = str_replace("and", "", $val);
} }
if (Trim($val) == "ago") { if (Trim($val) == "ago") {
@ -404,7 +385,7 @@ function truncatetag($input, $maxWords, $maxChars) {
$truncated1[] = $fragment; $truncated1[] = $fragment;
} }
$result = implode($truncated1, ' '); $result = implode(' ', $truncated1);
return $result . ($input == $result ? '' : '...'); return $result . ($input == $result ? '' : '...');
} }
@ -414,11 +395,9 @@ function doDownload($paste_id, $p_title, $p_member, $p_conntent, $p_code) {
if ($p_code) { if ($p_code) {
// Figure out extensions. // Figure out extensions.
$ext = "txt"; $ext = "txt";
switch ($p_code) { $ext = match ($p_code) {
default: default => 'txt',
$ext = 'txt'; };
break;
}
// Download // Download
$p_title = stripslashes($p_title); $p_title = stripslashes($p_title);

View file

@ -1,7 +1,7 @@
<?php <?php
// Turn off all error reporting - uh no? // Turn off all error reporting - uh no?
//error_reporting(0); //error_reporting(0);
?>
<?php <?php
/** /**
* GeSHi - Generic Syntax Highlighter * GeSHi - Generic Syntax Highlighter
@ -864,7 +864,7 @@ class GeSHi {
* @since 1.0.0 * @since 1.0.0
*/ */
public function enable_classes($flag = true) { public function enable_classes($flag = true) {
$this->use_classes = ($flag) ? true : false; $this->use_classes = (bool)$flag;
} }
/** /**
@ -1011,7 +1011,7 @@ class GeSHi {
* @since 1.0.0 * @since 1.0.0
*/ */
public function set_keyword_group_highlighting($key, $flag = true) { public function set_keyword_group_highlighting($key, $flag = true) {
$this->lexic_permissions['KEYWORDS'][$key] = ($flag) ? true : false; $this->lexic_permissions['KEYWORDS'][$key] = (bool)$flag;
} }
/** /**
@ -1051,7 +1051,7 @@ class GeSHi {
* @since 1.0.0 * @since 1.0.0
*/ */
public function set_comments_highlighting($key, $flag = true) { public function set_comments_highlighting($key, $flag = true) {
$this->lexic_permissions['COMMENTS'][$key] = ($flag) ? true : false; $this->lexic_permissions['COMMENTS'][$key] = (bool)$flag;
} }
/** /**
@ -1080,7 +1080,7 @@ class GeSHi {
* @since 1.0.0 * @since 1.0.0
*/ */
public function set_escape_characters_highlighting($flag = true) { public function set_escape_characters_highlighting($flag = true) {
$this->lexic_permissions['ESCAPE_CHAR'] = ($flag) ? true : false; $this->lexic_permissions['ESCAPE_CHAR'] = (bool)$flag;
} }
/** /**
@ -1116,7 +1116,7 @@ class GeSHi {
* @deprecated In favour of set_symbols_highlighting * @deprecated In favour of set_symbols_highlighting
*/ */
public function set_brackets_highlighting($flag) { public function set_brackets_highlighting($flag) {
$this->lexic_permissions['BRACKETS'] = ($flag) ? true : false; $this->lexic_permissions['BRACKETS'] = (bool)$flag;
} }
/** /**
@ -1152,7 +1152,7 @@ class GeSHi {
*/ */
public function set_symbols_highlighting($flag) { public function set_symbols_highlighting($flag) {
// Update lexic permissions for this symbol group // Update lexic permissions for this symbol group
$this->lexic_permissions['SYMBOLS'] = ($flag) ? true : false; $this->lexic_permissions['SYMBOLS'] = (bool)$flag;
// For backward compatibility // For backward compatibility
$this->set_brackets_highlighting($flag); $this->set_brackets_highlighting($flag);
@ -1184,7 +1184,7 @@ class GeSHi {
* @since 1.0.0 * @since 1.0.0
*/ */
public function set_strings_highlighting($flag) { public function set_strings_highlighting($flag) {
$this->lexic_permissions['STRINGS'] = ($flag) ? true : false; $this->lexic_permissions['STRINGS'] = (bool)$flag;
} }
/** /**
@ -1233,7 +1233,7 @@ class GeSHi {
* @since 1.0.0 * @since 1.0.0
*/ */
public function set_numbers_highlighting($flag) { public function set_numbers_highlighting($flag) {
$this->lexic_permissions['NUMBERS'] = ($flag) ? true : false; $this->lexic_permissions['NUMBERS'] = (bool)$flag;
} }
/** /**
@ -1264,7 +1264,7 @@ class GeSHi {
* @since 1.0.0 * @since 1.0.0
*/ */
public function set_methods_highlighting($flag) { public function set_methods_highlighting($flag) {
$this->lexic_permissions['METHODS'] = ($flag) ? true : false; $this->lexic_permissions['METHODS'] = (bool)$flag;
} }
/** /**
@ -1295,7 +1295,7 @@ class GeSHi {
* @since 1.0.0 * @since 1.0.0
*/ */
public function set_regexps_highlighting($key, $flag) { public function set_regexps_highlighting($key, $flag) {
$this->lexic_permissions['REGEXPS'][$key] = ($flag) ? true : false; $this->lexic_permissions['REGEXPS'][$key] = (bool)$flag;
} }
/** /**
@ -1306,7 +1306,7 @@ class GeSHi {
* @since 1.0.0 * @since 1.0.0
*/ */
public function set_case_sensitivity($key, $case) { public function set_case_sensitivity($key, $case) {
$this->language_data['CASE_SENSITIVE'][$key] = ($case) ? true : false; $this->language_data['CASE_SENSITIVE'][$key] = (bool)$case;
} }
/** /**
@ -1406,7 +1406,7 @@ class GeSHi {
* @todo Rewrite with array traversal * @todo Rewrite with array traversal
*/ */
public function enable_highlighting($flag = true) { public function enable_highlighting($flag = true) {
$flag = $flag ? true : false; $flag = (bool)$flag;
foreach ($this->lexic_permissions as $key => $value) { foreach ($this->lexic_permissions as $key => $value) {
if (is_array($value)) { if (is_array($value)) {
foreach ($value as $k => $v) { foreach ($value as $k => $v) {
@ -1781,7 +1781,7 @@ class GeSHi {
* @since 1.0.2 * @since 1.0.2
*/ */
public function enable_important_blocks($flag) { public function enable_important_blocks($flag) {
$this->enable_important_blocks = ($flag) ? true : false; $this->enable_important_blocks = (bool)$flag;
} }
/** /**
@ -1791,7 +1791,7 @@ class GeSHi {
* @since 1.0.2 * @since 1.0.2
*/ */
public function enable_ids($flag = true) { public function enable_ids($flag = true) {
$this->add_ids = ($flag) ? true : false; $this->add_ids = (bool)$flag;
} }
/** /**
@ -3192,14 +3192,11 @@ class GeSHi {
* @since 1.0.0 * @since 1.0.0
*/ */
protected function change_case($instr) { protected function change_case($instr) {
switch ($this->language_data['CASE_KEYWORDS']) { return match ($this->language_data['CASE_KEYWORDS']) {
case GESHI_CAPS_UPPER: GESHI_CAPS_UPPER => strtoupper($instr),
return strtoupper($instr); GESHI_CAPS_LOWER => strtolower($instr),
case GESHI_CAPS_LOWER: default => $instr,
return strtolower($instr); };
default:
return $instr;
}
} }
/** /**
@ -3445,8 +3442,7 @@ class GeSHi {
foreach (array_keys($this->language_data['KEYWORDS']) as $k) { foreach (array_keys($this->language_data['KEYWORDS']) as $k) {
if (!$this->use_classes) { if (!$this->use_classes) {
$attributes = ' style="' . $attributes = ' style="' .
(isset($this->language_data['STYLES']['KEYWORDS'][$k]) ? ($this->language_data['STYLES']['KEYWORDS'][$k] ?? "") . '"';
$this->language_data['STYLES']['KEYWORDS'][$k] : "") . '"';
} else { } else {
$attributes = ' class="kw' . $k . '"'; $attributes = ' class="kw' . $k . '"';
} }
@ -4126,7 +4122,7 @@ class GeSHi {
$footer = $this->footer_content; $footer = $this->footer_content;
if ($footer) { if ($footer) {
if ($this->header_type == GESHI_HEADER_PRE) { if ($this->header_type == GESHI_HEADER_PRE) {
$footer = str_replace("\n", '', $footer);; $footer = str_replace("\n", '', $footer);
} }
$footer = $this->replace_keywords($footer); $footer = $this->replace_keywords($footer);
@ -4377,20 +4373,12 @@ class GeSHi {
// or the appropriate key is given. // or the appropriate key is given.
foreach ($this->link_styles as $key => $style) { foreach ($this->link_styles as $key => $style) {
if ($style != '') { if ($style != '') {
switch ($key) { $stylesheet .= match ($key) {
case GESHI_LINK: GESHI_LINK => "{$selector}a:link {{$style}}\n",
$stylesheet .= "{$selector}a:link {{$style}}\n"; GESHI_HOVER => "{$selector}a:hover {{$style}}\n",
break; GESHI_ACTIVE => "{$selector}a:active {{$style}}\n",
case GESHI_HOVER: GESHI_VISITED => "{$selector}a:visited {{$style}}\n",
$stylesheet .= "{$selector}a:hover {{$style}}\n"; };
break;
case GESHI_ACTIVE:
$stylesheet .= "{$selector}a:active {{$style}}\n";
break;
case GESHI_VISITED:
$stylesheet .= "{$selector}a:visited {{$style}}\n";
break;
}
} }
} }

View file

@ -236,4 +236,3 @@ OutPut:
require_once('theme/' . $default_theme . '/header.php'); require_once('theme/' . $default_theme . '/header.php');
require_once('theme/' . $default_theme . '/main.php'); require_once('theme/' . $default_theme . '/main.php');
require_once('theme/' . $default_theme . '/footer.php'); require_once('theme/' . $default_theme . '/footer.php');
?>

View file

@ -117,4 +117,4 @@ $lang['profile-total-pri'] = "Total private pastes:";
$lang['profile-total-views'] = "Total views of all your pastes:"; $lang['profile-total-views'] = "Total views of all your pastes:";
$lang['embed-hosted-by'] = "hosted by"; $lang['embed-hosted-by'] = "hosted by";
$lang['view-raw'] = "Покажи в необработен текст"; $lang['view-raw'] = "Покажи в необработен текст";
?>

View file

@ -118,4 +118,4 @@ $lang['profile-total-pri'] = "Numero de pastes privados:";
$lang['profile-total-views'] = "Numero de visualizações nos seus pastes:"; $lang['profile-total-views'] = "Numero de visualizações nos seus pastes:";
$lang['embed-hosted-by'] = "hospedado por"; $lang['embed-hosted-by'] = "hospedado por";
$lang['view-raw'] = "Ver texto bruto"; $lang['view-raw'] = "Ver texto bruto";
?>

View file

@ -119,4 +119,4 @@ $lang['profile-total-pri'] = "Total private Pastes:";
$lang['profile-total-views'] = "Total Ansichten all deiner Pastes:"; $lang['profile-total-views'] = "Total Ansichten all deiner Pastes:";
$lang['embed-hosted-by'] = "gehostet von"; $lang['embed-hosted-by'] = "gehostet von";
$lang['view-raw'] = "Zeige Raw"; $lang['view-raw'] = "Zeige Raw";
?>

View file

@ -130,4 +130,4 @@ $lang['pastfavs-total'] = "Total Favorites of your pastes:";
$lang['yourfavs-total'] = "Total Favorites by you:"; $lang['yourfavs-total'] = "Total Favorites by you:";
$lang['embed-hosted-by'] = "hosted by"; $lang['embed-hosted-by'] = "hosted by";
$lang['view-raw'] = "View Raw"; $lang['view-raw'] = "View Raw";
?>

View file

@ -117,4 +117,4 @@ $lang ['perfil-total-pri'] = "Total de pegados privados:";
$lang ['profile-total-views'] = "Total de vistas de todos sus pegados:"; $lang ['profile-total-views'] = "Total de vistas de todos sus pegados:";
$lang ['embed-hosted-by'] = "alojado por"; $lang ['embed-hosted-by'] = "alojado por";
$lang ['view-raw'] = "Ver crudo"; $lang ['view-raw'] = "Ver crudo";
?>

View file

@ -119,4 +119,3 @@ $lang['profile-total-views'] = "Nombre total de vues :";
$lang['embed-hosted-by'] = "hébergé par"; $lang['embed-hosted-by'] = "hébergé par";
$lang['view-raw'] = "Voir les données brutes"; $lang['view-raw'] = "Voir les données brutes";
?>

View file

@ -119,4 +119,4 @@ $lang['profile-total-pri'] = "Prywatne wklejki:";
$lang['profile-total-views'] = "Wyświetlenia wszystkich wklejek:"; $lang['profile-total-views'] = "Wyświetlenia wszystkich wklejek:";
$lang['embed-hosted-by'] = "przechowywane na"; $lang['embed-hosted-by'] = "przechowywane na";
$lang['view-raw'] = "Surowy plik"; $lang['view-raw'] = "Surowy plik";
?>

View file

@ -5,4 +5,3 @@
$lang = array(); $lang = array();
?>

View file

@ -75,8 +75,7 @@
?> ?>
</div> </div>
<?php } <?php }
if ($privatesite == "on") { // Remove sidebar if site is private if ($privatesite != "on") {
} else {
require_once('theme/' . $default_theme . '/sidebar.php'); require_once('theme/' . $default_theme . '/sidebar.php');
} }
?> ?>

View file

@ -69,8 +69,7 @@
<?php } else { ?> <?php } else { ?>
<?php } <?php }
if (isset($privatesite) && $privatesite == "on") { // Remove 'recent pastes' if site is private if (!isset($privatesite) || $privatesite != "on") { ?>
} else { ?>
<div class="notification is-warning"> <div class="notification is-warning">
<strong id="headline">Entries Deadline</strong> <strong id="headline">Entries Deadline</strong>
<div id="countdown"> <div id="countdown">
@ -217,8 +216,9 @@
<!-- End Panel --> <!-- End Panel -->
<?php } <?php }
if ($privatesite == "on") { // Remove sidebar if site is private if ($privatesite != "on") {
return;
} elseif (isset($site_ads)) { } elseif (isset($site_ads)) {
echo $site_ads['ads_2']; echo $site_ads['ads_2'];
} }// Remove sidebar if site is private
?> ?>

View file

@ -174,28 +174,22 @@ $protocol = paste_protocol();
<?php <?php
foreach ($profile_pastes as $row) { foreach ($profile_pastes as $row) {
$title = Trim($row['title']); $title = Trim($row['title']);
$p_id = Trim($row['id']); $p_id = $row['id'];
$p_code = Trim($row['code']); $p_code = Trim($row['code']);
$p_date = new DateTime($row['created_at']); $p_date = new DateTime($row['created_at']);
$p_dateui = $p_date->format("d F Y"); $p_dateui = $p_date->format("d F Y");
$p_views = Trim($row['views']); $p_views = Trim($row['views']);
$p_visible = Trim($row['visible']); $p_visible = intval($row['visible']);
$p_tags = Trim($row['tagsys']); $p_tags = Trim($row['tagsys']);
$tagArray = explode(',', $p_tags); $tagArray = explode(',', $p_tags);
$tagArray = array_filter($tagArray); $tagArray = array_filter($tagArray);
switch ($p_visible) { $p_visible = match ($p_visible) {
case 0: 0 => $lang['public'],
$p_visible = $lang['public']; 1 => $lang['unlisted'],
break; 2 => $lang['private']
case 1: };
$p_visible = $lang['unlisted'];
break;
case 2:
$p_visible = $lang['private'];
break;
}
$p_link = ($mod_rewrite == '1') ? "$p_id" : "paste.php?id=$p_id"; $p_link = ($mod_rewrite == '1') ? "$p_id" : "paste.php?id=$p_id";
$p_delete_link = ($mod_rewrite == '1') ? "user.php?del&user=$profile_username&id=$p_id" : "user.php?del&user=$profile_username&id=$p_id"; $p_delete_link = ($mod_rewrite == '1') ? "user.php?del&user=$profile_username&id=$p_id" : "user.php?del&user=$profile_username&id=$p_id";
$p_tag_link = ($mod_rewrite == '1') ? "user.php?user=$profile_username&q=$p_tags" : "user.php?user=$profile_username&q=$tags"; $p_tag_link = ($mod_rewrite == '1') ? "user.php?user=$profile_username&q=$p_tags" : "user.php?user=$profile_username&q=$tags";
@ -206,7 +200,7 @@ $protocol = paste_protocol();
if ($row['visible'] == 0) { if ($row['visible'] == 0) {
echo '<tr> echo '<tr>
<td> <td>
<a href="' . $protocol . $baseurl . '/' . $p_link . '" title="' . $title . '">' . ($title) . '</a> <a href="' . urlForPaste($p_id) . '" title="' . $title . '">' . ($title) . '</a>
</td> </td>
<td data-sort="' . $p_date->format('U') . '" class="td-center"> <td data-sort="' . $p_date->format('U') . '" class="td-center">
<span>' . $p_dateui . '</span> <span>' . $p_dateui . '</span>
@ -218,10 +212,10 @@ $protocol = paste_protocol();
if (strlen($p_tags) > 0) { if (strlen($p_tags) > 0) {
foreach ($tagArray as $key => $tags) { foreach ($tagArray as $key => $tags) {
echo '<a href="' . $protocol . $baseurl . '/user.php?user=' . $profile_username . '&q=' . $tags . '"><span class="tag is-info">' . trim($tags) . '</span></a>'; echo '<a href="' . $protocol . $baseurl . '/user.php?user=' . $profile_username . '&q=' . $tags . '"><span class="tag is-info">' . trim($tags) . '</span></a>';
}; }
} else { } else {
echo ' <span class="tag is-warning">No tags</span>'; echo ' <span class="tag is-warning">No tags</span>';
}; }
echo '</td> echo '</td>
@ -305,10 +299,10 @@ $protocol = paste_protocol();
if (strlen($f_tags) > 0) { if (strlen($f_tags) > 0) {
foreach ($ftagArray as $key => $ftags) { foreach ($ftagArray as $key => $ftags) {
echo '<span class="tag is-info">' . trim($ftags) . '</span>'; echo '<span class="tag is-info">' . trim($ftags) . '</span>';
}; }
} else { } else {
echo ' <span class="tag is-warning">No tags</span>'; echo ' <span class="tag is-warning">No tags</span>';
}; }
echo '</td> echo '</td>