X-Git-Url: https://git.p6c8.net/jirafeau_project.git/blobdiff_plain/43ad1d1e823742663afc773d7aab1ca07a54da02..913fb0f876f2170bd537b5eaa4648315b7d59a46:/script.php?ds=inline
diff --git a/script.php b/script.php
index 3e6668e..9da9221 100644
--- a/script.php
+++ b/script.php
@@ -22,10 +22,8 @@
* If you don't want this feature, you can simply delete this file from your
* web directory.
*/
-
define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/');
-require (JIRAFEAU_ROOT . 'lib/config.original.php');
require (JIRAFEAU_ROOT . 'lib/settings.php');
require (JIRAFEAU_ROOT . 'lib/functions.php');
require (JIRAFEAU_ROOT . 'lib/lang.php');
@@ -55,7 +53,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET" && count ($_GET) == 0)
Scripting interface
This interface permits to script your uploads and downloads.
See source code of this interface to get available calls :)
- Alternatively, go to this page to download a bash script.
+ You may download a preconfigured Bash Script to easily send to and get files from the API via command line.
#!/bin/bash
-# This script has been auto-generated by Jirafeau but you can still edit
-# options below.
+# This script has been auto-generated by Jirafeau but you can still edit options below.
-# Config
-proxy='' # ex: proxy='proxysever.test.com:3128' or set JIRAFEAU_PROXY global variable
-url='' # or set JIRAFEAU_URL ex: url='http://mysite/jirafeau/script.php'
-time='none' # minute, hour, day, week, month, year or none. Or set JIRAFEAU_TIME.
-one_time='' # ex: one_time="1" or set JIRAFEAU_ONE_TIME.
-curl='' # curl path to download or set JIRAFEAU_CURL_PATH.
-# End of config
+# Config begin
+proxy='' # Or set JIRAFEAU_PROXY.
+url='' # Or set JIRAFEAU_URL.
+time='' # Or set JIRAFEAU_TIME.
+one_time='' # Or set JIRAFEAU_ONE_TIME.
+curl='' # Or set JIRAFEAU_CURL_PATH.
+# Config end
if [ -n "$JIRAFEAU_PROXY" ]; then
proxy="$JIRAFEAU_PROXY"
@@ -289,17 +289,22 @@ if [ -z "$curl" ]; then
fi
if [ -z "$2" ]; then
- echo "man:"
- echo " $0 send PATH [PASSWORD]"
+ echo "Jirafeau Bash Script "
+ echo "--------------------------"
+ echo "Usage:"
+ echo " $0 OPTIONS"
+ echo
+ echo "Options:"
+ echo " $0 send FILE [PASSWORD]"
echo " $0 get URL [PASSWORD]"
echo " $0 delete URL"
- echo ""
+ echo
echo "Global variables to export:"
- echo " JIRAFEAU_PROXY : example: proxysever.test.com:3128"
- echo " JIRAFEAU_URL : example: http://mysite/jirafeau/script.php"
- echo " JIRAFEAU_TIME : minute, hour, day, week, year, month or none"
- echo " JIRAFEAU_ONE_TIME : set anything or set empty"
- echo " JIRAFEAU_CURL : path to your curl binary"
+ echo " JIRAFEAU_PROXY: Domain and port of proxy server, eg. »proxysever.example.com:3128«"
+ echo " JIRAFEAU_URL : URI to Jirafeau installation with trailing slash, eg. »https://example.com/jirafeau/«"
+ echo " JIRAFEAU_TIME : expiration time, eg. »minute«, »hour«, »day«, »week«, »month«, »quarter«, »year« or »none«"
+ echo " JIRAFEAU_ONE_TIME : self-destroy after first download, eg. »1« to enable or »« (empty) to disable"
+ echo " JIRAFEAU_CURL : alternative path to curl binary"
exit 0
fi
@@ -319,6 +324,9 @@ if [ -n "$3" ]; then
options="$options -F key=$password"
fi
+apipage='script.php'
+downloadpage='f.php'
+
if [ "$1" == "send" ]; then
if [ ! -f "$2" ]; then
echo "File \"$2\" does not exists."
@@ -329,7 +337,7 @@ if [ "$1" == "send" ]; then
res=$($curl -X POST --http1.0 $proxy $options \
-F "time=$time" \
-F "file=@$2" \
- $url)
+ $url$apipage)
if [[ "$res" == Error* ]]; then
echo "Error while uploading."
@@ -350,12 +358,20 @@ if [ "$1" == "send" ]; then
fi
cnt=$(( cnt + 1 ))
done)
- echo "Download link:"
- echo "${url}?h=$code"
- echo "Direct download link:"
- echo "${url}?h=$code&d=1"
+
+ echo
+ echo "Download page:"
+ echo " ${url}${downloadpage}?h=$code"
+ echo "Direct download:"
+ echo " ${url}${downloadpage}?h=$code&d=1"
echo "Delete link:"
- echo "${url}?h=$code&d=$del_code"
+ echo " ${url}${downloadpage}?h=$code&d=$del_code"
+ echo
+ echo "Download via API:"
+ echo " ${0} get ${url}${apipage}?h=$code [PASSWORD}"
+ echo "Delete via API:"
+ echo " ${0} delete ${url}${downloadpage}?h=$code&d=$del_code"
+
elif [ "$1" == "get" ]; then
if [ -z "$password" ]; then
$curl $proxy -OJ "$2"
@@ -504,6 +520,9 @@ elseif (isset ($_GET['init_async']))
case 'month':
$time += JIRAFEAU_MONTH;
break;
+ case 'quarter':
+ $time += JIRAFEAU_QUARTER;
+ break;
case 'year':
$time += JIRAFEAU_YEAR;
break;