diff --git a/admin/common.php b/admin/common.php
index e62c62a..b88ed43 100644
--- a/admin/common.php
+++ b/admin/common.php
@@ -2,6 +2,12 @@
if (!defined('IN_ADMIN')) {
die();
}
+$db_opts = [
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, /* throw a fatal exception on database errors */
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, /* Fetch rows as an associative array (hash table) by default */
+ PDO::ATTR_EMULATE_PREPARES => false
+];
+
require_once('../includes/config.php');
diff --git a/admin/dashboard.php b/admin/dashboard.php
index 2f7fa07..c0960ac 100644
--- a/admin/dashboard.php
+++ b/admin/dashboard.php
@@ -292,15 +292,7 @@ for ($loop = 0; $loop <= 6; $loop++) {
- You have the latest version';
- } else {
- echo '
Your Paste installation is outdated. Get the latest version from SourceForge';
- }
- ?>
+
You have the latest version
diff --git a/admin/sitemap.php b/admin/sitemap.php
index b6c6cca..6879dc7 100644
--- a/admin/sitemap.php
+++ b/admin/sitemap.php
@@ -201,7 +201,7 @@ while ($row = mysqli_fetch_array($result)) {
$site_data = file_get_contents("../sitemap.xml");
$site_data = str_replace("", "", $site_data);
- if ($mod_rewrite == "1") {
+ if (PP_MOD_REWRITE) {
$server_name = $protocol . $_SERVER['SERVER_NAME'] . $levelup . "/" . $paste_id;
} else {
$server_name = $protocol . $_SERVER['SERVER_NAME'] . $levelup . "/paste.php?id=" . $paste_id;
diff --git a/includes/common.php b/includes/common.php
index a1b649b..ebb8bfb 100644
--- a/includes/common.php
+++ b/includes/common.php
@@ -10,9 +10,7 @@ require_once(__DIR__ . '/User.class.php');
/* View functions */
function urlForPaste($paste_id) : string {
- global $mod_rewrite;
-
- if ($mod_rewrite === '1') {
+ if (PP_MOD_REWRITE) {
return "/${paste_id}";
}
@@ -20,9 +18,7 @@ function urlForPaste($paste_id) : string {
}
function urlForMember(string $member_name) : string {
- global $mod_rewrite;
-
- if ($mod_rewrite === '1') {
+ if (PP_MOD_REWRITE) {
return '/user/' . urlencode($member_name);
}
diff --git a/includes/config.php b/includes/config.php
index 368d6bb..731a623 100644
--- a/includes/config.php
+++ b/includes/config.php
@@ -17,17 +17,15 @@ if (gethostname() === 'thunderlane') {
ini_set('display_errors', 1);
}
-$currentversion = 2.2;
-
-// Max paste size in MB. This value should always be below the value of
-// post_max_size in your PHP configuration settings (php.ini) or empty errors will occur.
-// The value we got on installation of Paste was: post_max_size = 128M
-// Otherwise, the maximum value that can be set is 4000 (4GB)
-$pastelimit = "1"; // 0.5 = 512 kilobytes, 1 = 1MB
+/* Maximum paste size in bytes */
+const PP_PASTE_LIMIT_BYTES = 1048576;
/* A long and random string used for additionally salting passwords. */
const PP_PASSWORD_PEPPER = 'd791b6c6-91f2-4e8f-ba80-74ea968e4931';
+/* Whether to use friendly URLs that require mod_rewrite */
+const PP_MOD_REWRITE = true;
+
$db_host = 'localhost';
$db_schema = 'p0nepast3s';
$db_user = 'P0nedbAcc0unt';
@@ -41,19 +39,12 @@ if (gethostname() === 'thunderlane') {
$db_pass = 'ponepaste';
}
-$db_opts = [
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, /* throw a fatal exception on database errors */
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, /* Fetch rows as an associative array (hash table) by default */
- PDO::ATTR_EMULATE_PREPARES => false
-];
+
// Secret key for paste encryption
//$sec_key = "8ac67343e7980b16b31e8311d4377bbb";
$sec_key = '';
-define('SECRET', md5($sec_key));
-// Set to 1 to enable Apache's mod_rewrite
-$mod_rewrite = "1";
// Available GeSHi formats
$geshiformats = [
diff --git a/includes/functions.php b/includes/functions.php
index ae701bc..ccb44b1 100644
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -437,7 +437,7 @@ function addToSitemap($paste_id, $priority, $changefreq, $mod_rewrite) {
// which protocol are we on
$protocol = paste_protocol();
- if ($mod_rewrite == "1") {
+ if (PP_MOD_REWRITE) {
$server_name = $protocol . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/" . $paste_id;
} else {
$server_name = $protocol . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/paste.php?id=" . $paste_id;
diff --git a/index.php b/index.php
index d8d23ad..7e6c637 100644
--- a/index.php
+++ b/index.php
@@ -91,7 +91,7 @@ function validatePasteFields() : string|null {
return $lang['notags'];
} elseif (strlen($_POST["title"]) > 70) { /* Paste title too long */
return $lang['titlelen'];
- } elseif (mb_strlen($_POST["paste_data"], '8bit') > 1024 * 1024 * $pastelimit) { /* Paste size too big */
+ } elseif (mb_strlen($_POST["paste_data"], '8bit') > PP_PASTE_LIMIT_BYTES) { /* Paste size too big */
return $lang['large_paste'];
}
diff --git a/langs/en.php b/langs/en.php
index 53dae62..d717e01 100644
--- a/langs/en.php
+++ b/langs/en.php
@@ -31,7 +31,7 @@ $lang['missing-input-secret'] = "The reCAPTCHA secret parameter is missing. Plea
$lang['missing-input-response'] = "The reCAPTCHA response parameter is invalid. Please try to complete the reCAPTCHA again.";
$lang['invalid-input-secret'] = "The reCAPTCHA secret parameter is invalid or malformed. Please double check your PASTE settings.";
$lang['empty_paste'] = "You cannot post an empty paste.";
-$lang['large_paste'] = "Your paste is too large. Max size is " . $pastelimit . "MB";
+$lang['large_paste'] = "Your paste is too large. Max size is " . PP_PASTE_LIMIT_BYTES . " bytes";
$lang['paste_db_error'] = "Unable to post to database.";
$lang['error'] = "Something went wrong.";
$lang['archive'] = "Pastes Archive";
diff --git a/paste.php b/paste.php
index 1294dc8..66d189d 100644
--- a/paste.php
+++ b/paste.php
@@ -199,26 +199,17 @@ if ($p_password == "NONE") {
// No password & diplay the paste
// Set download URL
- if ($mod_rewrite == '1') {
+ if (PP_MOD_REWRITE) {
$p_download = "download/$paste_id";
- } else {
- $p_download = "paste.php?download&id=$paste_id";
- }
-
- // Set raw URL
- if ($mod_rewrite == '1') {
$p_raw = "raw/$paste_id";
- } else {
- $p_raw = "paste.php?raw&id=$paste_id";
- }
-
- // Set embed URL
- if ($mod_rewrite == '1') {
$p_embed = "embed/$paste_id";
} else {
+ $p_download = "paste.php?download&id=$paste_id";
+ $p_raw = "paste.php?raw&id=$paste_id";
$p_embed = "paste.php?embed&id=$paste_id";
}
+
// View counter
if ($_SESSION['not_unique'] !== $paste_id) {
$_SESSION['not_unique'] = $paste_id;
diff --git a/theme/bulma/header.php b/theme/bulma/header.php
index 590e4c9..5b3d2e9 100644
--- a/theme/bulma/header.php
+++ b/theme/bulma/header.php
@@ -78,7 +78,7 @@ $start = $time;
@@ -125,7 +125,7 @@ $start = $time;
echo '