Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee4ac8a429 | ||
|
|
5c6fdef0b6 | ||
|
|
16c3e42635 | ||
|
|
fbc8445b73 | ||
|
|
cd72ee3124 | ||
|
|
6f3789bfdc | ||
|
|
5b1653ca11 |
4
.hgtags
Normal file
4
.hgtags
Normal file
@@ -0,0 +1,4 @@
|
||||
b66e758d981314bfd9de6dbfe0385785908a884c v1.0.0
|
||||
4db108cffb1f05d2c42ff71e22d6c2330b4f45ad v1.1.0
|
||||
0a90758f5df3d039490b57fad1091af22fb47524 v2.0.0
|
||||
6db9ff3d18c27c2f7c08ed4104d6cbc05ca8bf86 v2.1.0
|
||||
55
README.md
55
README.md
@@ -1,9 +1,11 @@
|
||||
## Paste. ##
|
||||
|
||||
This is pastebin replacement. It does not use ads, it is opensource it is relatively small.
|
||||
This is pastebin replacement. It does not use ads, it is opensource, it is relatively small.
|
||||
And it has minimal pastebin API stub, at least pastebinit can paste to it with minimal config changes.
|
||||
Besides pastebinit there are 2 cli clients available on main page of this app.
|
||||
|
||||
And as a bonus this app can short links too! But it either shorts links **or** stores paste, not both at same time.
|
||||
|
||||
### How do I get set up? ###
|
||||
|
||||
This paste utilizes PDO SQLite driver, well, at least for now :) and mbstrings.
|
||||
@@ -11,7 +13,11 @@ Tested php versions are 5.6.30 and 7.0.12. Paste uses **paste/paste.sqlite** fil
|
||||
|
||||
Tested on apache/fcgid (windows) for dev and nginx/php-fpm for prod.
|
||||
|
||||
Default installation assumes that paste runs as / app on site, but you can change it (BASEURL) in index.php.
|
||||
Default installation assumes that paste runs as / app on site, but you can change it (BASEURL) in app.ini.
|
||||
|
||||
#### Settings for paste mode ####
|
||||
|
||||
edit app.ini and set correct address, base url, db path, application type (type = paste)
|
||||
|
||||
Nginx config snippet:
|
||||
```
|
||||
@@ -43,7 +49,39 @@ location / {
|
||||
}
|
||||
```
|
||||
|
||||
Database initialises automatically :)
|
||||
Database initializes automatically :)
|
||||
|
||||
#### Settings for link shortener mode ####
|
||||
|
||||
edit app.ini and set correct address, base url, db path, application type (type = short)
|
||||
|
||||
Nginx config snippet:
|
||||
```
|
||||
# limit links size to ~ 50k
|
||||
client_max_body_size 64k;
|
||||
|
||||
rewrite "^/([a-z|A-Z]*)$" /index.php?$1;
|
||||
|
||||
location / {
|
||||
root /var/www/htdocs/empty;
|
||||
|
||||
index index.php;
|
||||
location ~ \.php$ {
|
||||
if ($request_method !~ ^(GET|HEAD|POST)$ ) {
|
||||
return 499;
|
||||
}
|
||||
|
||||
root /var/www/htdocs;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
|
||||
fastcgi_index index.php;
|
||||
include fastcgi.conf;
|
||||
fastcgi_pass php;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Database initializes automatically :)
|
||||
|
||||
### Contribution guidelines ###
|
||||
|
||||
@@ -52,7 +90,7 @@ Clean code, preferably with comments for some quirky places.
|
||||
### PasteBinIt configuration ###
|
||||
|
||||
default pastebin site, __~/.pastebinit.xml__:
|
||||
```
|
||||
```xml
|
||||
<pastebinit>
|
||||
<pastebin>http://your.site</pastebin>
|
||||
<author>Stephane Graber</author>
|
||||
@@ -61,7 +99,7 @@ default pastebin site, __~/.pastebinit.xml__:
|
||||
</pastebinit>
|
||||
```
|
||||
and how to work with it __~/.pastebinit.d/your.site.conf__:
|
||||
```
|
||||
```ini
|
||||
[pastebin]
|
||||
basename = your.site
|
||||
regexp = http://((([a-zA-Z0-9\-_\.]*)(your\.site)))
|
||||
@@ -116,3 +154,10 @@ diff -ruN pastebin.com.conf your.site.conf
|
||||
+page = /
|
||||
regexp = (.*)
|
||||
```
|
||||
|
||||
### TODO ###
|
||||
|
||||
* Make one app that shorten links, stores paste, stores pictures (yes! image hosting).
|
||||
* Configurable features (not everyone wants all features enabled).
|
||||
* Before implementing picture storage, there should be made authorization.
|
||||
* Sane and clear API.
|
||||
|
||||
14
app.ini
Normal file
14
app.ini
Normal file
@@ -0,0 +1,14 @@
|
||||
[app]
|
||||
; either "paste" or "short"
|
||||
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 for paste and /logo.png for link shortener
|
||||
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 = data/db.sqlite
|
||||
397
index.php
397
index.php
@@ -1,16 +1,59 @@
|
||||
<?php
|
||||
define ('BASEURL', "/"); # must end with '/'
|
||||
define ('KEY_MIN', 3);
|
||||
define ('KEY_MAX', 9);
|
||||
define ('DBPATH', 'paste/paste.sqlite');
|
||||
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) {
|
||||
header('Content-Language: en, ru');
|
||||
header('Pragma: no-cache');
|
||||
header('Cache-Control: no-cache');
|
||||
interface iPaste {
|
||||
public function showindex($text);
|
||||
public function eclient();
|
||||
public function dclient();
|
||||
public function query_db($q);
|
||||
public function store_data($paste);
|
||||
}
|
||||
|
||||
class paste implements iPaste {
|
||||
public function __construct () {
|
||||
if (! file_exists('app.ini')) {
|
||||
print "app.ini not found, unable to run application\n";
|
||||
}
|
||||
|
||||
$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_MAX', 9);
|
||||
define ('APP_TYPE', $config["type"]);
|
||||
unset ($config);
|
||||
|
||||
if (! file_exists(dirname(DBPATH))) {
|
||||
mkdir(dirname(DBPATH), 0777, true);
|
||||
}
|
||||
|
||||
$dbh = new PDO("sqlite:" . DBPATH);
|
||||
|
||||
$r = $dbh->exec(
|
||||
"CREATE TABLE IF NOT EXISTS paste (
|
||||
id TEXT PRIMARY KEY,
|
||||
paste TEXT,
|
||||
time INTEGER,
|
||||
etime INTEGER
|
||||
)"
|
||||
);
|
||||
|
||||
if ($r === false) {
|
||||
$e = $r->errorInfo();
|
||||
self::showindex($e[2]);
|
||||
}
|
||||
|
||||
$dbh = null;
|
||||
}
|
||||
|
||||
public function showindex ($text) {
|
||||
header('Content-Language: en, ru');
|
||||
header('Pragma: no-cache');
|
||||
header('Cache-Control: no-cache');
|
||||
|
||||
if (APP_TYPE == 'paste') {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
@@ -25,14 +68,15 @@ function showindex($text) {
|
||||
height: 70vh;
|
||||
}
|
||||
</style>
|
||||
<title>Paste.</title>
|
||||
<title>Slack paste.</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Paste</h3>
|
||||
<h3>Slack Paste</h3>
|
||||
<form method="post" action="<?php print APP_ADDRESS; ?>" enctype="multipart/form-data">
|
||||
<textarea name="exs" id="textbox" autofocus></textarea><br />
|
||||
<input type="submit" value="Post it!" style="font-size:115%;" /> for
|
||||
<select name="etime" style="font-size: 85%; text-align:left;">
|
||||
<input type="submit" value="Post it!" style="font-size:115%;" />
|
||||
for
|
||||
<select name="etime" style="font-size:115%; text-align:left;">
|
||||
<option value="1" style="font-size: 85%; text-align:left;">1 Hour</option>
|
||||
<option value="2" style="font-size: 85%; text-align:left;">12 Hours</option>
|
||||
<option value="3" style="font-size: 85%; text-align:left;">1 day</option>
|
||||
@@ -46,9 +90,9 @@ function showindex($text) {
|
||||
</select>
|
||||
</form>
|
||||
<?php
|
||||
if ($text != '') {
|
||||
printf (" <p><table align=\"center\" frame=\"void\" border=\"0\"><td>%s</td></table></p>\n", $text);
|
||||
}
|
||||
if ($text != '') {
|
||||
printf (" <p><table align=\"center\" frame=\"void\" border=\"0\"><td>%s</td></table></p>\n", $text);
|
||||
}
|
||||
?>
|
||||
<p style="font-size: small;">
|
||||
Console client can be found here: <a href="<?php print APP_ADDRESS; ?>e"><?php print APP_ADDRESS; ?>e</a> thanks <a href="http://sprunge.us">sprunge.us</a> for their client :)<br/>
|
||||
@@ -59,12 +103,60 @@ function showindex($text) {
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
} elseif (APP_TYPE == 'short') {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<style>
|
||||
* {
|
||||
margin: 10px;
|
||||
text-align: center;
|
||||
font-size: 14pt;
|
||||
}
|
||||
html, body {
|
||||
background-color: #adc0fc; text-align: center;
|
||||
}
|
||||
</style>
|
||||
<title>Link Shortener</title>
|
||||
</head>
|
||||
<body>
|
||||
<img src="<?php print CDN_ADDRESS; ?>logo.png" />
|
||||
|
||||
function eclient() {
|
||||
header('Content-Language: en, ru');
|
||||
header('Content-Type: text/plain');
|
||||
header('Content-Disposition: attachment; filename="e"');
|
||||
<form method="post" action="<?php print APP_ADDRESS; ?>">
|
||||
Shorten this link:<br />
|
||||
<input type="text" maxlength="768" name="exs" style="font-size: 110%; width:45%;" autofocus/></br />
|
||||
<input type="submit" value="Submit" style="font-size: 85%;" />
|
||||
for
|
||||
<select name="etime" style="font-size: 85%; text-align:left;">
|
||||
<option value="1" style="font-size: 85%; text-align:left;">1 Hour</option>
|
||||
<option value="2" style="font-size: 85%; text-align:left;">12 Hours</option>
|
||||
<option value="3" style="font-size: 85%; text-align:left;">1 day</option>
|
||||
<option value="4" style="font-size: 85%; text-align:left;">1 week</option>
|
||||
<option value="5" style="font-size: 85%; text-align:left;">1 Month</option>
|
||||
<option value="6" style="font-size: 85%; text-align:left;">3 Months</option>
|
||||
<option value="7" selected style="font-size: 85%; text-align:left;">6 Months</option>
|
||||
<option value="8" style="font-size: 85%; text-align:left;">1 Year</option>
|
||||
<option value="9" style="font-size: 85%; text-align:left;">2 Years</option>
|
||||
<option value="10" style="font-size: 85%; text-align:left;">3 Years</option>
|
||||
</select>
|
||||
</form>
|
||||
<?php
|
||||
if ($text != '') {
|
||||
printf (" <table style=\"margin: 0px auto;\"><td>%s</td></table>\n", $text);
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
public function eclient () {
|
||||
header('Content-Language: en, ru');
|
||||
header('Content-Type: text/plain');
|
||||
header('Content-Disposition: attachment; filename="e"');
|
||||
?>
|
||||
#!/bin/bash
|
||||
|
||||
@@ -76,7 +168,7 @@ description() {
|
||||
cat << HERE
|
||||
|
||||
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
|
||||
$0 filename.txt
|
||||
@@ -127,13 +219,13 @@ else
|
||||
done | curl -F "exs=<-" <?php print SITE_ADDRESS; ?>
|
||||
fi
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
function dclient() {
|
||||
header('Content-Language: en, ru');
|
||||
header('Content-Type: text/plain');
|
||||
header('Content-Disposition: attachment; filename="d";');
|
||||
public function dclient () {
|
||||
header('Content-Language: en, ru');
|
||||
header('Content-Type: text/plain');
|
||||
header('Content-Disposition: attachment; filename="d";');
|
||||
?>
|
||||
#!/usr/bin/env bash
|
||||
|
||||
@@ -149,99 +241,70 @@ fi
|
||||
exit 0
|
||||
';
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
function gen_id() {
|
||||
$urllen = rand (KEY_MIN, KEY_MAX);
|
||||
$string = '';
|
||||
$a = Array(); $a = array_merge(range('A', 'Z'), range('a', 'z'));
|
||||
|
||||
for($i = 0; $i < $urllen; $i++){
|
||||
$string .= $a[rand (0, count($a) - 1)];
|
||||
}
|
||||
|
||||
return($string);
|
||||
}
|
||||
|
||||
function init_db() {
|
||||
# we init db, eh? drop db file and re-create it!
|
||||
if (file_exists(DBPATH)) { unlink(DBPATH); }
|
||||
if (! file_exists(dirname(DBPATH))) { mkdir(dirname(DBPATH), 0777, true); }
|
||||
|
||||
$dbh = new PDO("sqlite:" . DBPATH);
|
||||
|
||||
$r = $dbh->exec(
|
||||
"CREATE TABLE IF NOT EXISTS paste (
|
||||
id TEXT PRIMARY KEY,
|
||||
paste TEXT,
|
||||
time INTEGER,
|
||||
etime INTEGER
|
||||
)"
|
||||
);
|
||||
|
||||
if($r === false) {
|
||||
$e = $r->errorInfo();
|
||||
showindex($e[2]);
|
||||
}
|
||||
|
||||
$dbh = null;
|
||||
}
|
||||
|
||||
function query_db($id) {
|
||||
if (! file_exists(DBPATH)) {
|
||||
init_db();
|
||||
return false;
|
||||
}
|
||||
|
||||
$dbh = new PDO("sqlite:" . DBPATH);
|
||||
$sth = $dbh->query("SELECT paste FROM paste WHERE id='$id'");
|
||||
|
||||
if ($sth === false) {
|
||||
$e = $r->errorInfo();
|
||||
showindex($e[2]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sth->setFetchMode(PDO::FETCH_ASSOC);
|
||||
$data = $sth->fetch();
|
||||
$dbh = null;
|
||||
protected function gen_id () {
|
||||
$urllen = rand (KEY_MIN, KEY_MAX);
|
||||
$string = '';
|
||||
$a = Array(); $a = array_merge(range('A', 'Z'), range('a', 'z'));
|
||||
|
||||
if ($data === false) {
|
||||
return($data);
|
||||
} else {
|
||||
if (isset($data['etime']) and ($data['etime'] < time())){
|
||||
return false;
|
||||
for ($i = 0; $i < $urllen; $i++) {
|
||||
$string .= $a[rand (0, count($a) - 1)];
|
||||
}
|
||||
|
||||
$data = $data['paste'];
|
||||
return($data); # false if no data or no key in db
|
||||
return($string);
|
||||
}
|
||||
}
|
||||
|
||||
function store_data($paste) {
|
||||
if (! file_exists(DBPATH)) { init_db(); }
|
||||
$dbh = new PDO("sqlite:" . DBPATH);
|
||||
$q = 0;
|
||||
public function query_db ($q) {
|
||||
$dbh = new PDO("sqlite:" . DBPATH);
|
||||
$sth = $dbh->query("SELECT paste FROM paste WHERE id='$q'");
|
||||
|
||||
do {
|
||||
if ($q > 100) { # assume key-value space depleted if we try more than 100 times
|
||||
$q = false;
|
||||
break;
|
||||
if ($sth === false) {
|
||||
$e = $r->errorInfo();
|
||||
self::showindex($e[2]);
|
||||
exit;
|
||||
}
|
||||
$id = gen_id();
|
||||
$q++;
|
||||
} while (! $dbh->query("SELECT id FROM paste WHERE id='$id'"));
|
||||
|
||||
if($q === false) {
|
||||
return('Storage depleted.');
|
||||
$sth->setFetchMode(PDO::FETCH_ASSOC);
|
||||
$data = $sth->fetch();
|
||||
$dbh = null;
|
||||
|
||||
if ($data === false) {
|
||||
return($data);
|
||||
} else {
|
||||
if (isset($data['etime']) and ($data['etime'] < time())){
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = $data['paste'];
|
||||
return($data); # false if no data or no key in db
|
||||
}
|
||||
}
|
||||
|
||||
$ctime = time();
|
||||
$etime = $ctime + 14515200;
|
||||
public function store_data ($paste) {
|
||||
$dbh = new PDO("sqlite:" . DBPATH);
|
||||
$q = 0;
|
||||
|
||||
if(isset($_POST['etime'])) {
|
||||
switch ($_POST['etime']) {
|
||||
do {
|
||||
if ($q > 100) { # assume key-value space depleted if we try more than 100 times
|
||||
$q = false;
|
||||
break;
|
||||
}
|
||||
|
||||
$id = self::gen_id();
|
||||
$q++;
|
||||
} while (! $dbh->query("SELECT id FROM paste WHERE id='$id'"));
|
||||
|
||||
if ($q === false) {
|
||||
return('Storage depleted.');
|
||||
}
|
||||
|
||||
$ctime = time();
|
||||
$etime = $ctime + 14515200;
|
||||
|
||||
if (isset($_POST['etime'])) {
|
||||
switch ($_POST['etime']) {
|
||||
case '1': # 1 hour
|
||||
$etime = $ctime + 3600;
|
||||
break;
|
||||
@@ -285,63 +348,111 @@ function store_data($paste) {
|
||||
case '13': # forever
|
||||
$etime = "null";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$sth = $dbh->prepare("INSERT INTO paste VALUES('$id', '$paste', $ctime, $etime)");
|
||||
$sth->execute();
|
||||
|
||||
if ($sth === false) {
|
||||
$e = $sth->errorInfo();
|
||||
self::showindex($e[2]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$dbh = null;
|
||||
return($id);
|
||||
}
|
||||
|
||||
$sth = $dbh->prepare("INSERT INTO paste VALUES('$id', '$paste', $ctime, $etime)");
|
||||
$sth->execute();
|
||||
|
||||
if ($sth === false) {
|
||||
$e = $sth->errorInfo();
|
||||
showindex($e[2]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$dbh = null;
|
||||
return($id);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* MAIN STARTS HERE
|
||||
*/
|
||||
|
||||
$text = '';
|
||||
$p = new paste;
|
||||
|
||||
if (($_SERVER['REQUEST_METHOD'] === 'GET') or ($_SERVER['REQUEST_METHOD'] === 'HEAD')) {
|
||||
# substr returns empty string (boolean false) on error
|
||||
$str = $_SERVER['REQUEST_URI']; $str = substr($str, mb_strlen(BASEURL, 'UTF-8'));
|
||||
|
||||
if ($str == 'e') {
|
||||
eclient();
|
||||
exit;
|
||||
} elseif ($str == 'd') {
|
||||
dclient();
|
||||
exit;
|
||||
}
|
||||
if (APP_TYPE == 'paste') {
|
||||
if ($str == 'e') {
|
||||
$p->eclient();
|
||||
exit;
|
||||
} elseif ($str == 'd') {
|
||||
$p->dclient();
|
||||
exit;
|
||||
}
|
||||
|
||||
# pastebin returns raw pate when paste' key prepended with /raw/, let's handle it
|
||||
if (preg_match('/^raw\//', $str) == 1) {
|
||||
$str = substr($str, mb_strlen('raw/', 'UTF-8'));
|
||||
# pastebin returns raw paste when paste' key prepended with /raw/, let's handle it
|
||||
if (preg_match('/^raw\//', $str) == 1) {
|
||||
$str = substr($str, mb_strlen('raw/', 'UTF-8'));
|
||||
}
|
||||
}
|
||||
|
||||
if ((mb_strlen($str, 'UTF-8') >= KEY_MIN) and ((mb_strlen($str, 'UTF-8') <= KEY_MAX))) {
|
||||
if (preg_match('/^[a-z|A-Z]+$/', $str) == 1) {
|
||||
$response = query_db($str);
|
||||
$response = $p->query_db($str);
|
||||
|
||||
if ($response === false) {
|
||||
$text = 'No such paste.';
|
||||
} else {
|
||||
header('Content-Type: text/plain');
|
||||
print base64_decode($response);
|
||||
exit;
|
||||
$response = base64_decode($response);
|
||||
|
||||
if (APP_TYPE == 'paste') {
|
||||
header('Content-Type: text/plain');
|
||||
print $response;
|
||||
exit;
|
||||
} elseif (APP_TYPE == 'short') {
|
||||
header( "Location: " . $response, true, 301 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (isset($_POST['exs']) and ($_POST['exs'] != '')) {
|
||||
$text = APP_ADDRESS . store_data(base64_encode($_POST['exs']));
|
||||
} elseif (isset($_POST['api_option'])){ # some pastebin API compatibility stuff
|
||||
if (APP_TYPE == 'short') {
|
||||
# I don't like loops :)
|
||||
if ((preg_match('/^https?\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^s?ftps?\:/', $_POST['exs']) == 1) or
|
||||
# Looks like shorten links other than http(s) or ftp is not good idea at all, but we CAN do this too.
|
||||
(preg_match('/^ldaps?\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^ircs?\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^xmpp\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^mailto\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^rtmp\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^rtsp\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^rtp\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^soutcast\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^icecast\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^magnet\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^ed2k\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^ssh\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^svn\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^hg\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^git\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^smb\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^ipp\:/', $_POST['exs']) == 1) or
|
||||
(preg_match('/^chrome\:/', $_POST['exs']) == 1) or # i'm doubt if this really working, but anyway
|
||||
(preg_match('/^vivaldi\:/', $_POST['exs']) == 1) or # i'm doubt if this really working, but anyway
|
||||
(preg_match('/^opera\:/', $_POST['exs']) == 1) or # i'm doubt if this really working, but anyway
|
||||
(preg_match('/^about\:/', $_POST['exs']) == 1) or # i'm doubt if this really working, but anyway
|
||||
(preg_match('/^skype\:/', $_POST['exs']) == 1)) {
|
||||
$text = APP_ADDRESS . $p->store_data(base64_encode($_POST['exs']));
|
||||
} else {
|
||||
$text = 'Unable to short your link.';
|
||||
}
|
||||
} elseif (APP_TYPE == 'paste') {
|
||||
$text = APP_ADDRESS . $p->store_data(base64_encode($_POST['exs']));
|
||||
}
|
||||
} elseif ((APP_TYPE == 'paste') and (isset($_POST['api_option']))) { # some pastebin API compatibility stuff
|
||||
if ($_POST['api_option'] == 'paste') {
|
||||
if ((isset($_POST['api_paste_code'])) and ($_POST['api_paste_code'] != '')) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
print mb_convert_encoding(APP_ADDRESS . store_data(base64_encode($_POST['api_paste_code'])), 'UTF-8', 'auto');
|
||||
print mb_convert_encoding(APP_ADDRESS . $p->store_data(base64_encode($_POST['api_paste_code'])), 'UTF-8', 'auto');
|
||||
exit;
|
||||
}
|
||||
} elseif ($_POST['api_option'] == 'show_paste') {
|
||||
@@ -350,7 +461,7 @@ if (($_SERVER['REQUEST_METHOD'] === 'GET') or ($_SERVER['REQUEST_METHOD'] === 'H
|
||||
|
||||
if ((mb_strlen($str, 'UTF-8') >= KEY_MIN) and ((mb_strlen($str, 'UTF-8') <= KEY_MAX))) {
|
||||
if (preg_match('/^[a-z|A-Z]+$/', $str) == 1) {
|
||||
$response = query_db($str);
|
||||
$response = $p->query_db($str);
|
||||
|
||||
if ($response === false) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
@@ -366,9 +477,11 @@ if (($_SERVER['REQUEST_METHOD'] === 'GET') or ($_SERVER['REQUEST_METHOD'] === 'H
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# ???
|
||||
}
|
||||
|
||||
showindex($text);
|
||||
$p->showindex($text);
|
||||
|
||||
/*
|
||||
* END OF MAIN
|
||||
*/
|
||||
?>
|
||||
Reference in New Issue
Block a user