Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f3789bfdc | ||
|
|
5b1653ca11 |
15
app.ini
Normal file
15
app.ini
Normal file
@@ -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
|
||||||
22
index.php
22
index.php
@@ -1,11 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
define ('BASEURL', "/"); # must end with '/'
|
$config = parse_ini_file("app.ini");
|
||||||
|
define ('SITE_ADDRESS', $config["siteaddress"]);
|
||||||
|
define ('BASEURL', $config["baseurl"]);
|
||||||
|
define ('APP_ADDRESS', substr(SITE_ADDRESS, 0, -1) . BASEURL);
|
||||||
|
define ('CDN_ADDRESS', $config["cdnaddress"]);
|
||||||
|
define ('DBPATH', $config["dbpath"]);
|
||||||
define ('KEY_MIN', 3);
|
define ('KEY_MIN', 3);
|
||||||
define ('KEY_MAX', 9);
|
define ('KEY_MAX', 9);
|
||||||
define ('DBPATH', 'paste/paste.sqlite');
|
unset ($config);
|
||||||
define ('SITE_ADDRESS', 'http://127.0.0.1/');
|
|
||||||
define ('CDN_ADDRESS', 'http://127.0.0.1/');
|
|
||||||
define ('APP_ADDRESS', substr(SITE_ADDRESS, 0, -1) . BASEURL);
|
|
||||||
|
|
||||||
function showindex($text) {
|
function showindex($text) {
|
||||||
header('Content-Language: en, ru');
|
header('Content-Language: en, ru');
|
||||||
@@ -25,10 +27,10 @@ function showindex($text) {
|
|||||||
height: 70vh;
|
height: 70vh;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<title>Paste.</title>
|
<title>Slack paste.</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h3>Paste</h3>
|
<h3>Slack Paste</h3>
|
||||||
<form method="post" action="<?php print APP_ADDRESS; ?>" enctype="multipart/form-data">
|
<form method="post" action="<?php print APP_ADDRESS; ?>" enctype="multipart/form-data">
|
||||||
<textarea name="exs" id="textbox" autofocus></textarea><br />
|
<textarea name="exs" id="textbox" autofocus></textarea><br />
|
||||||
<input type="submit" value="Post it!" style="font-size:115%;" /> for
|
<input type="submit" value="Post it!" style="font-size:115%;" /> for
|
||||||
@@ -76,7 +78,7 @@ description() {
|
|||||||
cat << HERE
|
cat << HERE
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
Upload data and fetch URL from the pastebin <?php print SITE_ADDRESS; ?>
|
Upload data and fetch URL from the pastebin http://p.dafuq.ru/
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
$0 filename.txt
|
$0 filename.txt
|
||||||
@@ -188,14 +190,14 @@ function init_db() {
|
|||||||
$dbh = null;
|
$dbh = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function query_db($id) {
|
function query_db($q) {
|
||||||
if (! file_exists(DBPATH)) {
|
if (! file_exists(DBPATH)) {
|
||||||
init_db();
|
init_db();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dbh = new PDO("sqlite:" . DBPATH);
|
$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) {
|
if ($sth === false) {
|
||||||
$e = $r->errorInfo();
|
$e = $r->errorInfo();
|
||||||
|
|||||||
Reference in New Issue
Block a user