From d40920583b61e300dcff6edfbcc6a3815289f523 Mon Sep 17 00:00:00 2001 From: RaJiska Date: Mon, 23 Oct 2017 11:19:25 +0200 Subject: [PATCH] Small Tweaks / Fixes, Cron Clean, Unnecessary Files Removal, README --- README.md | 20 + classes/Paste.php | 5 +- cron/clean.php | 8 + cron/cron.php | 2 +- lib/geshi/contrib/aliased.php | 134 -- lib/geshi/contrib/cssgen.php | 465 ---- lib/geshi/contrib/cssgen2.php | 59 - lib/geshi/contrib/example.php | 210 -- lib/geshi/contrib/langwiz.php | 1156 ---------- lib/geshi/docs/geshi-doc.html | 4077 --------------------------------- pages/paste.php | 4 +- resources/js/beyondpaste.js | 2 - 12 files changed, 35 insertions(+), 6107 deletions(-) create mode 100644 README.md create mode 100644 cron/clean.php delete mode 100644 lib/geshi/contrib/aliased.php delete mode 100644 lib/geshi/contrib/cssgen.php delete mode 100644 lib/geshi/contrib/cssgen2.php delete mode 100644 lib/geshi/contrib/example.php delete mode 100644 lib/geshi/contrib/langwiz.php delete mode 100644 lib/geshi/docs/geshi-doc.html diff --git a/README.md b/README.md new file mode 100644 index 0000000..5aa2176 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# BeyondPaste +Simple self hosted Pastebin-like tool allowing you to have the pastes uploaded on your own server. +Running on PHP7, it is using Bootstrap 4 for its frontend, Geshi for the syntax highlighting. + +# Features +* Paste upload +* Syntax Highlighting +* Unlisted Pastes +* One Time Read Paste +* Paste auto remove + +# Screenshots +**Paste creation** +![alt text](https://i.gyazo.com/c6270e7c1068d4bbb463e10c2940a382.png) +--------------------- +**Paste View** +![alt text](https://i.gyazo.com/abedef0e0aca81f07894fd0e7802fec0.png) + +# Credits +Design inspired by **Popoliito's** securePaste project. \ No newline at end of file diff --git a/classes/Paste.php b/classes/Paste.php index b8c87b2..da708b2 100644 --- a/classes/Paste.php +++ b/classes/Paste.php @@ -264,6 +264,7 @@ public function getPasteLink() private function expirationToTimestamp(&$expiration) { + $time = time(); $timeToAdd = 0; switch ($expiration) @@ -289,9 +290,11 @@ private function expirationToTimestamp(&$expiration) case '1y': $timeToAdd = (12 * 30 * 24 * 60 * 60); break; + case 'never': + $timeToAdd = -($time); } - return (time() + $timeToAdd); + return ($time + $timeToAdd); } /* Getters / Setters */ diff --git a/cron/clean.php b/cron/clean.php new file mode 100644 index 0000000..8ee3603 --- /dev/null +++ b/cron/clean.php @@ -0,0 +1,8 @@ +query("DELETE FROM `paste` WHERE deleted = '1';"); \ No newline at end of file diff --git a/cron/cron.php b/cron/cron.php index 3de4082..9a469a2 100644 --- a/cron/cron.php +++ b/cron/cron.php @@ -5,4 +5,4 @@ require_once "../classes/Database.php"; $current_epoch = time(); -$stmt = $Database->query("UPDATE `paste` SET deleted = '1' WHERE $current_epoch >= expiration_epoch;"); \ No newline at end of file +$stmt = $Database->query("UPDATE `paste` SET deleted = '1' WHERE expiration_epoch != 0 && $current_epoch >= expiration_epoch;"); \ No newline at end of file diff --git a/lib/geshi/contrib/aliased.php b/lib/geshi/contrib/aliased.php deleted file mode 100644 index fb8c4fb..0000000 --- a/lib/geshi/contrib/aliased.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @version $Id$ - */ - -// Your config here -define("SOURCE_ROOT", "/var/www/your/source/root/"); - -if (file_exists(__DIR__ . '/../vendor/autoload.php')) { - //composer install - require __DIR__ . '/../vendor/autoload.php'; -} else if (file_exists(__DIR__ . '/../src/geshi.php')) { - //git checkout - require __DIR__ . '/../src/geshi.php'; -} else { - // Assume you've put geshi in the include_path already - require_once("geshi.php"); -} - -if (!isset($_SERVER['PATH_INFO'])) { - die("No file name given.\n"); -} - -// Get path info -$path = SOURCE_ROOT . $_SERVER['PATH_INFO']; - -// Check for dickheads trying to use '../' to get to sensitive areas -$base_path_len = strlen(SOURCE_ROOT); -$real_path = realpath($path); -if(strncmp($real_path, SOURCE_ROOT, $base_path_len)) { - exit("Access outside acceptable path."); -} - -// Check file exists -if(!file_exists($path)) { - exit("File not found ($path)."); -} - -// Prepare GeSHi instance -$geshi = new GeSHi(); -$geshi->set_language('text'); -$geshi->load_from_file($path); -$geshi->set_header_type(GESHI_HEADER_PRE); -$geshi->enable_classes(); -$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 10); -$geshi->set_overall_style('color: #000066; border: 1px solid #d0d0d0; background-color: #f0f0f0;', true); -$geshi->set_line_style('font: normal normal 95% \'Courier New\', Courier, monospace; color: #003030;', 'font-weight: bold; color: #006060;', true); -$geshi->set_code_style('color: #000020;', 'color: #000020;'); -$geshi->set_link_styles(GESHI_LINK, 'color: #000060;'); -$geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;'); -$geshi->set_header_content('Source code viewer - ' . $path . ' - ' . $geshi->get_language_name()); -$geshi->set_header_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;'); -$geshi->set_footer_content('Parsed in