-yyyymmdd version x.x Neon
+yyyymmdd version 1.x Neon
+* Moved and added settings to config file. See update.txt
+* Better logging
+* Updated client/webclient
20231009 version 1.5 Fluorine
* Maintenance release. Updated requirements to current versions if possible
* this is the config file for the webclient
*/
+const DEBUG = false;
+const TIMEZONE = 'Europe/Berlin';
+
/* please provide a unique username for this installation */
const FRONTEND_USERNAME = 'some';
/* please provide a unique password for this installation */
* copy the config.default.php file to config.php and update its settings
*/
-const DEBUG = false;
-require_once 'config.php';
-
# Encoding and error reporting setting
mb_http_output('UTF-8');
mb_internal_encoding('UTF-8');
error_reporting(-1); // E_ALL & E_STRICT
+require_once 'config.php';
+
# default time setting
-date_default_timezone_set('Europe/Berlin');
+date_default_timezone_set(TIMEZONE);
# check request
$_urlToParse = filter_var($_SERVER['QUERY_STRING'],FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW);
}
}
ini_set('display_errors',false);
-if(DEBUG === true) {
+if(DEBUG) {
ini_set('display_errors',true);
}
$ret = $do;
}
else {
- error_log(var_export(curl_error($ch),true),3,'./sp-webclient.log');
+ error_log(var_export(curl_error($ch),true),3,'./selfpaste-webclient.log');
}
curl_close($ch);
For more information about some config settings read the separate documentation
file for this setting.
-Folder logs and pasties need t be writeable by webserver process / owner
+Folder logs and pasties need to be writeable by webserver process / owner
-Change date_default_timezone_set in index.php if your timezone is
+Change TIMEZONE in config.php if your timezone is
different to Europe/Berlin
- update your config.php
- make sure of any special update steps listed below.
+## x.x Neon
+Moved and added settings to config file. See config.default.php
+Make sure to add (with default values):
+const DEBUG = false;
+const TIMEZONE = 'Europe/Berlin';
+const PATH_ABSOLUTE = '/path/to/your/installation/';
+const PATH_SYSTEMOUT = PATH_ABSOLUTE.'/logs';
+const ERROR_LOG_FILE = PATH_SYSTEMOUT.'/selfpaste-error.log';
+const CREATE_LOG = PATH_SYSTEMOUT.'/selfpaste-create.log';
+
+Logfilenames changed. Existing create.log and error.log can be removed.
+
+
## 1.5 Fluorine
New syntax in config file. Switched from define() to const syntax.
This change apply also to the included webclient
* 2019 - 2023 https://://www.bananas-playground.net/projekt/selfpaste
*/
+# debug setting
+const DEBUG = false;
+
+# timezone settings
+const TIMEZONE = 'Europe/Berlin';
+
+# path settings
+const PATH_ABSOLUTE = '/www/htdocs/';
+const PATH_SYSTEMOUT = PATH_ABSOLUTE.'/logs';
+const ERROR_LOG_FILE = PATH_SYSTEMOUT.'/selfpaste-error.log';
+const CREATE_LOG = PATH_SYSTEMOUT.'/selfpaste-create.log';
+
# this is your installation secret. Could be anything.
# Think of it as a key. Change it often to avoid any abuse.
# The description will be used in the log files
* 2019 - 2023 https://://www.bananas-playground.net/projekt/selfpaste
*/
-# global debug setting
-const DEBUG = false;
-
# Encoding and error reporting setting
mb_http_output('UTF-8');
mb_internal_encoding('UTF-8');
error_reporting(-1); // E_ALL & E_STRICT
+# config file
+require_once 'config.php';
+
# default time setting
-date_default_timezone_set('Europe/Berlin');
+date_default_timezone_set(TIMEZONE);
# check request
$_urlToParse = filter_var($_SERVER['QUERY_STRING'],FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW);
}
}
-const ERROR_LOG_FILE = './logs/error.log';
-const CREATE_LOG = './logs/create.log';
-
# error reporting
ini_set('log_errors',true);
if(DEBUG) {
# static helper class
require_once 'lib/summoner.class.php';
-# config file
-require_once 'config.php';
+
# upload / file handling
require_once 'lib/mancubus.class.php';
if($_do['status'] === true) {
$httpResponseCode = 200;
if(defined('LOG_CREATION') && LOG_CREATION === true) {
- error_log(date("c")." ".$_message." ".SELFPASTE_UPLOAD_SECRET[$_POST['dl']]."\n",3,CREATE_LOG);
+ Summoner::createLog($_message." ".SELFPASTE_UPLOAD_SECRET[$_POST['dl']]);
}
}
}
require_once 'view/'.$contentView.'.inc.php';
}
else {
- error_log('Content body file missing. '.var_export($_SERVER,true),3,ERROR_LOG_FILE);
+ Summoner::syslog('Content body file missing. '.Summoner::cleanForLog($_SERVER));
http_response_code(400);
die('Well, something went wrong...');
}
*/
private string $_short;
- private $_saveFilename;
- private $_storagePath;
- private $_shortURL;
+ private string $_saveFilename;
+ private string $_storagePath;
+ private string $_shortURL;
/**
* Mancubus constructor.
}
return $ret;
}
+
+ /**
+ * Make the input more safe for logging
+ *
+ * @param mixed $input The array/string to be made more safe
+ * @return string
+ */
+ static function cleanForLog(mixed $input): mixed {
+ $input = var_export($input, true);
+ $input = preg_replace( "/[\t\n\r]/", " ", $input);
+ return addcslashes($input, "\000..\037\177..\377\\");
+ }
+
+ /**
+ * error_log with a dedicated destination
+ * Uses LOGFILE const
+ *
+ * @param string $msg The string to be written to the log
+ */
+ static function sysLog(string $msg): void {
+ error_log(date("c")." ".$msg."\n", 3, ERROR_LOG_FILE);
+ }
+
+ /**
+ * error_log with a dedicated destination
+ * Uses CREATE_LOG const
+ *
+ * @param string $msg
+ * @return void
+ */
+ static function createLog(string $msg): void {
+ error_log(date("c")." ".$msg."\n", 3, CREATE_LOG);
+ }
}