From 6f3789bfdcbad7e5a73a3f681b6bf9a5ef20c4a2 Mon Sep 17 00:00:00 2001 From: eleksir Date: Sat, 18 Mar 2017 12:18:48 +0300 Subject: [PATCH] added ini-file support for application settings --- app.ini | 15 +++++++++++++++ index.php | 26 ++++++++++++++------------ 2 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 app.ini diff --git a/app.ini b/app.ini new file mode 100644 index 0000000..1593f62 --- /dev/null +++ b/app.ini @@ -0,0 +1,15 @@ +[app] +; either "paste" or "shortener" +; reserved for future releases, not used +type = paste +; relative path to application, as it seen in browser +; must end with '/' +baseurl = / +; if you decide to put images|css on separate domain, write it here +; or leave it same as siteaddress +; for now it is only /bg_logo.png +cdnaddress = http://127.0.0.1/ +; hostname where app lives, with http(s) prefix +siteaddress = http://127.0.0.1/ +; path, where db created|stored, if not exist, it will be created +dbpath = paste/paste.sqlite diff --git a/index.php b/index.php index cc4223a..0f86a15 100644 --- a/index.php +++ b/index.php @@ -1,11 +1,13 @@ - Paste. + Slack paste. -

Paste

+

Slack Paste


for @@ -76,7 +78,7 @@ description() { cat << HERE DESCRIPTION - Upload data and fetch URL from the pastebin + Upload data and fetch URL from the pastebin http://p.dafuq.ru/ USAGE $0 filename.txt @@ -188,14 +190,14 @@ function init_db() { $dbh = null; } -function query_db($id) { +function query_db($q) { if (! file_exists(DBPATH)) { init_db(); return false; } $dbh = new PDO("sqlite:" . DBPATH); - $sth = $dbh->query("SELECT paste FROM paste WHERE id='$id'"); + $sth = $dbh->query("SELECT paste FROM paste WHERE id='$q'"); if ($sth === false) { $e = $r->errorInfo();