]> 91.132.146.200 Git - selfpaste.git/commitdiff
adding a simple webclient.
authorBanana <mail@bananas-playground.net>
Mon, 18 May 2020 18:19:46 +0000 (20:19 +0200)
committerBanana <mail@bananas-playground.net>
Mon, 18 May 2020 18:19:46 +0000 (20:19 +0200)
TODO
client/webclient/.gitignore [new file with mode: 0644]
client/webclient/README [new file with mode: 0644]
client/webclient/index.php [new file with mode: 0644]
documentation/clients.txt
webroot/index.php

diff --git a/TODO b/TODO
index 32384d7d7e53d8d57c1a8e6ac3571fa3472744ea..b0f30d61ac82e552cd7c8d2b5526bfd289f7d150 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1 +1,2 @@
 + Option outputfile in c client not implemented
++ Small web interface to add files without client
diff --git a/client/webclient/.gitignore b/client/webclient/.gitignore
new file mode 100644 (file)
index 0000000..4f4773f
--- /dev/null
@@ -0,0 +1 @@
+config.php
diff --git a/client/webclient/README b/client/webclient/README
new file mode 100644 (file)
index 0000000..f8d4a19
--- /dev/null
@@ -0,0 +1,7 @@
+The webclient provides a simple web client to add pasties on the go when no client is available.
+It is a simple basic auth protected script which will then add the new pasty to your installation.
+
+To enable the webclient read the details in the index.php and config.default. file.
+Copy config.default.php to config.php and provide a username, password, secret and the selfpaste endpoint url.
+
+Upload it where you want it and go.
diff --git a/client/webclient/index.php b/client/webclient/index.php
new file mode 100644 (file)
index 0000000..beb4bdd
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+/**
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
+ *
+ * You should have received a copy of the
+ * COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+ * along with this program.  If not, see http://www.sun.com/cddl/cddl.html
+ *
+ * 2019 - 2020 https://://www.bananas-playground.net/projekt/selfpaste
+ */
+
+/**
+ * This is a simple web client which can be hosted whereevery you want.
+ * copy the config.default.php file to config.php and update its settings
+ */
+
+define('DEBUG',false);
+require_once 'config.php';
+
+# Encoding and error reporting setting
+mb_http_output('UTF-8');
+mb_internal_encoding('UTF-8');
+ini_set('error_reporting',-1); // E_ALL & E_STRICT
+
+# default time setting
+date_default_timezone_set('Europe/Berlin');
+
+# check request
+$_urlToParse = filter_var($_SERVER['QUERY_STRING'],FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
+if(!empty($_urlToParse)) {
+    if(preg_match('/[\p{C}\p{M}\p{Sc}\p{Sk}\p{So}\p{Zl}\p{Zp}]/u',$_urlToParse) === 1) {
+        die('Malformed request. Make sure you know what you are doing.');
+    }
+}
+ini_set('display_errors',false);
+if(DEBUG === true) {
+    ini_set('display_errors',true);
+}
+
+if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])
+    || $_SERVER['PHP_AUTH_USER'] !== FRONTEND_USERNAME || $_SERVER['PHP_AUTH_PW'] !== FRONTEND_PASSWORD
+) {
+    header('WWW-Authenticate: Basic realm="Skynet"');
+    header('HTTP/1.0 401 Unauthorized');
+    echo 'No Access...';
+    exit;
+}
+
+exit("dosmoe");
+if(isset($_POST['dl']) && !empty($_POST['dl'])
+    && isset($_FILES['pasty']) && !empty($_FILES['pasty'])
+    && isset(SELFPASTE_UPLOAD_SECRET[$_POST['dl']])) {
+    $_create = true;
+}
+
+?>
+<html>
+<head>
+    <title>selfpaste - add a new one</title>
+</head>
+<body>
+<form method="post" enctype="multipart/form-data" action="<?php echo THE_ENDPOINT; ?>">
+    <input type="hidden" name="dl" value="<?php echo THE_SECRET; ?>">
+    <p>
+        <textarea name="" cols="100" rows="10"></textarea>
+    </p>
+    <p><input type="file" name="pasty"></p>
+    <p><input type="submit" value="send" name="doSome"></p>
+</form>
+</body>
+</html>
+
index 90b01ccd3f79583805c8ebee7bef0ee1f7a52262..7bf24a6bf92bdbcb7cb51c6e33b7a4b59891b17d 100644 (file)
@@ -7,7 +7,7 @@ help for more information.
 
 Requirements to create a new client are:
 
-    - Talk to the selfpaste endpoint over HTTP(S)
+    - Talk to the selfpaste endpoint over HTTP(S) (your choice)
     - Make a POST with multipart/form-data
     - The post must have field pasty and field dl
     -- pasty=File to upload
index ff0ae72405ae9f8b9abd1d202c2c19efd5724206..2f252e7378d2e4ae89fe0a60d8e4bceef956f085 100644 (file)
@@ -124,4 +124,4 @@ else {
     error_log('Content body file missing. '.var_export($_SERVER,true),3,ERROR_LOG_FILE);
     http_response_code(400);
     die('Well, something went wrong...');
-}
\ No newline at end of file
+}