* Moved and added settings to config file. See update.txt
* Better logging
* Updated client/webclient
+* Setting the correct mime type to responses for the browser. FF had a problem with images.
20231009 version 1.5 Fluorine
* Maintenance release. Updated requirements to current versions if possible
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
*
- * 2019 - 2023 https://://www.bananas-playground.net/projekt/selfpaste
+ * 2019 - 2025 https://://www.bananas-playground.net/projekt/selfpaste
*/
# Encoding and error reporting setting
$_create = true;
}
+# default values
$contentType = 'Content-type: text/html; charset=UTF-8';
$contentView = 'welcome';
$httpResponseCode = 200;
if(!empty($_short)) {
- $contentType = 'Content-type: text/plain; charset=UTF-8';
$contentView = 'view';
- $httpResponseCode = 404;
- $contentBody = 'File not found.';
-
- $_t = Summoner::b64sl_unpack_id($_short);
- $_t = (string)$_t;
- $_p = Summoner::forwardslashStringToPath($_t);
- $_requestFile = str_ends_with(SELFPASTE_UPLOAD_DIR,'/') ? SELFPASTE_UPLOAD_DIR : SELFPASTE_UPLOAD_DIR.'/';
- $_requestFile .= $_p;
- $_requestFile .= $_t;
- if(is_readable($_requestFile)) {
- $contentBody = $_requestFile;
- $httpResponseCode = 200;
- }
}
elseif ($_create === true) {
$contentView = 'created';
- $contentType = 'Content-type:application/json;charset=utf-8';
- $httpResponseCode = 400;
- $_message = 'Something went wrong.';
-
- $_file = $_FILES['pasty'];
-
- $_fileObj = new Mancubus();
- if($_fileObj->load($_FILES['pasty']) === true) {
- $_fileObj->setSaveFilename();
- $_fileObj->setShort();
- $_fileObj->setStoragePath();
- $_fileObj->setShortURL();
-
- $_do = $_fileObj->process();
- $_message = $_do['message'];
- if($_do['status'] === true) {
- $httpResponseCode = 200;
- if(defined('LOG_CREATION') && LOG_CREATION === true) {
- Summoner::createLog($_message." ".SELFPASTE_UPLOAD_SECRET[$_POST['dl']]);
- }
- }
- }
-
- $contentBody = array(
- 'message' => $_message,
- 'status' => $httpResponseCode
- );
}
-header('X-PROVIDED-BY: selfpaste');
-header($contentType);
-http_response_code($httpResponseCode);
+header('X-Provided-By: selfpaste');
if(file_exists('view/'.$contentView.'.inc.php')) {
require_once 'view/'.$contentView.'.inc.php';
}
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
*
- * 2019 - 2023 https://://www.bananas-playground.net/projekt/selfpaste
+ * 2019 - 2025 https://://www.bananas-playground.net/projekt/selfpaste
*/
-echo json_encode($contentBody)."\n";
+$contentType = 'Content-type:application/json;charset=utf-8';
+$httpResponseCode = 400;
+$_message = 'Something went wrong.';
+
+$_file = $_FILES['pasty'];
+
+$_fileObj = new Mancubus();
+if($_fileObj->load($_FILES['pasty']) === true) {
+ $_fileObj->setSaveFilename();
+ $_fileObj->setShort();
+ $_fileObj->setStoragePath();
+ $_fileObj->setShortURL();
+
+ $_do = $_fileObj->process();
+ $_message = $_do['message'];
+ if($_do['status'] === true) {
+ $httpResponseCode = 200;
+ if(defined('LOG_CREATION') && LOG_CREATION === true) {
+ Summoner::createLog($_message." ".SELFPASTE_UPLOAD_SECRET[$_POST['dl']]);
+ }
+ }
+}
+
+http_response_code($httpResponseCode);
+header('Content-type:application/json;charset=utf-8');
+echo json_encode(array(
+ 'message' => $_message,
+ 'status' => $httpResponseCode))."\n";
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
*
- * 2019 - 2023 https://://www.bananas-playground.net/projekt/selfpaste
+ * 2019 - 2025 https://://www.bananas-playground.net/projekt/selfpaste
*/
-if (file_exists($contentBody)) {
+
+$_t = Summoner::b64sl_unpack_id($_short);
+$_t = (string)$_t;
+$_p = Summoner::forwardslashStringToPath($_t);
+$_requestFile = str_ends_with(SELFPASTE_UPLOAD_DIR,'/') ? SELFPASTE_UPLOAD_DIR : SELFPASTE_UPLOAD_DIR.'/';
+$_requestFile .= $_p;
+$_requestFile .= $_t;
+if(is_readable($_requestFile)) {
+ $finfo = finfo_open(FILEINFO_MIME_TYPE);
+ $mime = finfo_file($finfo, $_requestFile);
+ finfo_close($finfo);
+
+ http_response_code(200);
+ header('Content-type: '.$mime);
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
- readfile($contentBody);
- exit;
-}
-else {
- echo $contentBody;
+ readfile($_requestFile);
+} else {
+ http_response_code(404);
+ header('Content-type: text/plain; charset=UTF-8');
+ $contentBody = 'File not found.';
}
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
*
- * 2019 - 2023 https://://www.bananas-playground.net/projekt/selfpaste
+ * 2019 - 2025 https://://www.bananas-playground.net/projekt/selfpaste
*/
+header('Content-type: text/html; charset=UTF-8');
?>
<!DOCTYPE HTML>
<html lang="en">