From 6f40bebfc2dd88787525cfe5e5280a2fd1b2f992 Mon Sep 17 00:00:00 2001 From: Floorb <132411956+Neetpone@users.noreply.github.com> Date: Sun, 22 Aug 2021 21:45:26 -0400 Subject: [PATCH] New page template system kinda. --- archive.php | 5 +- composer.json | 3 +- discover.php | 6 +- event.php | 7 +- includes/ViewBag.class.php | 34 +++ includes/captcha.php | 25 ++- includes/common.php | 13 +- includes/config.php | 11 +- includes/functions.php | 13 +- index.php | 6 +- login.php | 7 +- pages.php | 6 +- paste.php | 12 +- profile.php | 7 +- rules.php | 6 +- theme/bulma/common.php | 439 +++++++++++++++++++++++++++++++++++++ theme/bulma/event.php | 2 +- theme/bulma/main.php | 18 +- theme/bulma/view.php | 12 +- user.php | 5 +- 20 files changed, 532 insertions(+), 105 deletions(-) create mode 100644 includes/ViewBag.class.php create mode 100644 theme/bulma/common.php diff --git a/archive.php b/archive.php index deb8c91..7205e2d 100644 --- a/archive.php +++ b/archive.php @@ -30,6 +30,5 @@ updatePageViews($conn); $p_title = $lang['archive']; // "Pastes Archive"; // Theme -require_once('theme/' . $default_theme . '/header.php'); -require_once('theme/' . $default_theme . '/archive.php'); -require_once('theme/' . $default_theme . '/footer.php'); +$page_template = 'archive'; +require_once('theme/' . $default_theme . '/common.php'); diff --git a/composer.json b/composer.json index c387c14..595d01b 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,7 @@ "scrivo/highlight.php": "v9.18.1.7", "ext-pdo": "*", "ext-openssl": "*", - "erusev/parsedown": "^1.7" + "erusev/parsedown": "^1.7", + "ext-gd": "*" } } diff --git a/discover.php b/discover.php index 0e9c5c7..c20cce8 100644 --- a/discover.php +++ b/discover.php @@ -99,6 +99,6 @@ $random_pastes = array_map('transformPasteRow', getRandomPastes($conn, 10)); // Theme $p_title = $lang['archive']; // "Pastes Archive"; -require_once('theme/' . $default_theme . '/header.php'); -require_once('theme/' . $default_theme . '/discover.php'); -require_once('theme/' . $default_theme . '/footer.php'); +$page_template = 'discover'; +require_once('theme/' . $default_theme . '/common.php'); + diff --git a/event.php b/event.php index 3fa02b0..c9d904f 100644 --- a/event.php +++ b/event.php @@ -20,12 +20,9 @@ require_once('includes/functions.php'); // UTF-8 header('Content-Type: text/html; charset=utf-8'); -$date = date('jS F Y'); -$ip = $_SERVER['REMOTE_ADDR']; $p_title = $lang['archive']; // "Pastes Archive"; // Theme -require_once('theme/' . $default_theme . '/header.php'); -require_once('theme/' . $default_theme . '/event.php'); -require_once('theme/' . $default_theme . '/footer.php'); +$page_template = 'event'; +require_once('theme/' . $default_theme . '/common.php'); \ No newline at end of file diff --git a/includes/ViewBag.class.php b/includes/ViewBag.class.php new file mode 100644 index 0000000..e4f4d6e --- /dev/null +++ b/includes/ViewBag.class.php @@ -0,0 +1,34 @@ +> 0x10); - $rgb_array['g'] = 0xFF & ($color_val >> 0x8); - $rgb_array['b'] = 0xFF & $color_val; + return [ + 'r' => 0xFF & ($color_val >> 0x10), + 'g' => 0xFF & ($color_val >> 0x8), + 'b' => 0xFF & $color_val + ]; } elseif (strlen($hex_str) == 3) { - $rgb_array['r'] = hexdec(str_repeat(substr($hex_str, 0, 1), 2)); - $rgb_array['g'] = hexdec(str_repeat(substr($hex_str, 1, 1), 2)); - $rgb_array['b'] = hexdec(str_repeat(substr($hex_str, 2, 1), 2)); - } else { - return false; + return [ + 'r' => hexdec(str_repeat(substr($hex_str, 0, 1), 2)), + 'g' => hexdec(str_repeat(substr($hex_str, 1, 1), 2)), + 'b' => hexdec(str_repeat(substr($hex_str, 2, 1), 2)) + ]; } - return $return_string ? implode($separator, $rgb_array) : $rgb_array; + + return null; } } diff --git a/includes/common.php b/includes/common.php index a5b1993..4af5570 100644 --- a/includes/common.php +++ b/includes/common.php @@ -7,6 +7,7 @@ require_once(__DIR__ . '/config.php'); require_once(__DIR__ . '/functions.php'); require_once(__DIR__ . '/DatabaseHandle.class.php'); require_once(__DIR__ . '/User.class.php'); +require_once(__DIR__ . '/ViewBag.class.php'); /* View functions */ function urlForPaste($paste_id) : string { @@ -98,11 +99,10 @@ $conn = new DatabaseHandle("mysql:host=$db_host;dbname=$db_schema;charset=utf8mb // Setup site info $site_info = getSiteInfo(); +$global_site_info = $site_info['site_info']; $row = $site_info['site_info']; $title = Trim($row['title']); -$des = Trim($row['description']); $baseurl = Trim($row['baseurl']); -$keyword = Trim($row['keywords']); $site_name = Trim($row['site_name']); $email = Trim($row['email']); $ga = Trim($row['google_analytics']); @@ -125,9 +125,6 @@ if ($site_permissions) { $disableguest = 'off'; } -$privatesite = $siteprivate; -$noguests = $disableguest; - // CAPTCHA configuration $captcha_config = $site_info['captcha']; $captcha_enabled = (bool)$captcha_config['enabled']; @@ -151,10 +148,8 @@ $total_unique_views = getSiteTotal_unique_views($conn); $current_user = User::current($conn); -if ($current_user) { - $noguests = "off"; -} - /* Security headers */ header('X-Frame-Options: SAMEORIGIN'); header('X-Content-Type-Options: nosniff'); + +//ob_start(); diff --git a/includes/config.php b/includes/config.php index ed66d85..340bee8 100644 --- a/includes/config.php +++ b/includes/config.php @@ -45,21 +45,12 @@ if (gethostname() === 'thunderlane') { const PP_ENCRYPTION_ALGO = 'AES-256-CBC'; const PP_ENCRYPTION_KEY = ''; - -// Available GeSHi formats -$geshiformats = [ +const PP_HIGHLIGHT_FORMATS = [ 'green' => 'Green Text', 'text' => 'Plain Text', 'pastedown' => 'pastedown', 'pastedown_old' => 'pastedown old' ]; -// Popular formats that are listed first. -$popular_formats = [ - 'green', - 'text', - 'pastedown', - 'pastedown_old' -]; // Cookie - I want a cookie, can I have one? diff --git a/includes/functions.php b/includes/functions.php index f7f471e..829bb80 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -232,9 +232,9 @@ function doDownload($paste_id, $p_title, $p_member, $p_conntent, $p_code) { return $stats; } -function embedView($paste_id, $p_title, $p_conntent, $p_code, $title, $baseurl, $ges_style, $lang) { +function embedView($paste_id, $p_title, $content, $p_code, $title, $baseurl, $lang) { $stats = false; - if ($p_conntent) { + if ($content) { // Build the output $output = "