2 Commits

Author SHA1 Message Date
eleksir
5c6fdef0b6 * Changed EOL to UNIX type
* Refactor code to respect OOP coding style, now we have interface and class here!
2017-03-26 01:43:27 +03:00
eleksir
16c3e42635 Added tag v2.0.0 for changeset 0a90758f5df3 2017-03-18 16:15:31 +03:00
2 changed files with 488 additions and 478 deletions

View File

@@ -1,2 +1,3 @@
b66e758d981314bfd9de6dbfe0385785908a884c v1.0.0 b66e758d981314bfd9de6dbfe0385785908a884c v1.0.0
4db108cffb1f05d2c42ff71e22d6c2330b4f45ad v1.1.0 4db108cffb1f05d2c42ff71e22d6c2330b4f45ad v1.1.0
0a90758f5df3d039490b57fad1091af22fb47524 v2.0.0

965
index.php
View File

@@ -1,478 +1,487 @@
<?php <?php
$config = parse_ini_file("app.ini");
interface iPaste {
define ('SITE_ADDRESS', $config["siteaddress"]); public function showindex($text);
define ('BASEURL', $config["baseurl"]); public function eclient();
define ('APP_ADDRESS', substr(SITE_ADDRESS, 0, -1) . BASEURL); public function dclient();
define ('CDN_ADDRESS', $config["cdnaddress"]); public function query_db($q);
define ('DBPATH', $config["dbpath"]); public function store_data($paste);
define ('KEY_MIN', 3); }
define ('KEY_MAX', 9);
define ('APP_TYPE', $config["type"]); class paste implements iPaste {
public function __construct () {
unset ($config); if (! file_exists('app.ini')) {
print "app.ini not found, unable to run application\n";
function showindex($text) { }
header('Content-Language: en, ru');
header('Pragma: no-cache'); $config = parse_ini_file("app.ini");
header('Cache-Control: no-cache'); define ('SITE_ADDRESS', $config["siteaddress"]);
define ('BASEURL', $config["baseurl"]);
if (APP_TYPE == 'paste') { define ('APP_ADDRESS', substr(SITE_ADDRESS, 0, -1) . BASEURL);
?> define ('CDN_ADDRESS', $config["cdnaddress"]);
<!DOCTYPE html> define ('DBPATH', $config["dbpath"]);
<html lang="ru"> define ('KEY_MIN', 3);
<head> define ('KEY_MAX', 9);
<style> define ('APP_TYPE', $config["type"]);
body { background-color: #adc0fc; text-align: center; } unset ($config);
textarea {
background-image: url("<?php print CDN_ADDRESS; ?>bg_logo.png"); if (! file_exists(dirname(DBPATH))) {
background-repeat: no-repeat; mkdir(dirname(DBPATH), 0777, true);
background-position: center center; }
width: 90%;
height: 70vh; $dbh = new PDO("sqlite:" . DBPATH);
}
</style> $r = $dbh->exec(
<title>Slack paste.</title> "CREATE TABLE IF NOT EXISTS paste (
</head> id TEXT PRIMARY KEY,
<body> paste TEXT,
<h3>Slack Paste</h3> time INTEGER,
<form method="post" action="<?php print APP_ADDRESS; ?>" enctype="multipart/form-data"> etime INTEGER
<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:115%; text-align:left;"> if ($r === false) {
<option value="1" style="font-size: 85%; text-align:left;">1 Hour</option> $e = $r->errorInfo();
<option value="2" style="font-size: 85%; text-align:left;">12 Hours</option> self::showindex($e[2]);
<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> $dbh = null;
<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> public function showindex ($text) {
<option value="9" style="font-size: 85%; text-align:left;">2 Years</option> header('Content-Language: en, ru');
<option value="10" style="font-size: 85%; text-align:left;">3 Years</option> header('Pragma: no-cache');
</select> header('Cache-Control: no-cache');
</form>
<?php if (APP_TYPE == 'paste') {
if ($text != '') { ?>
printf (" <p><table align=\"center\" frame=\"void\" border=\"0\"><td>%s</td></table></p>\n", $text); <!DOCTYPE html>
} <html lang="ru">
?> <head>
<p style="font-size: small;"> <style>
Console client can be found here: <a href="<?php print APP_ADDRESS; ?>e"><?php print APP_ADDRESS; ?>e</a>&nbsp; &nbsp; thanks <a href="http://sprunge.us">sprunge.us</a> for their client :)<br/> body { background-color: #adc0fc; text-align: center; }
More minimalist console client can be found here: <a href="<?php print APP_ADDRESS; ?>d"><?php print APP_ADDRESS; ?>d</a><br/> textarea {
<br/> background-image: url("<?php print CDN_ADDRESS; ?>bg_logo.png");
2015 background-repeat: no-repeat;
</p> background-position: center center;
</body> width: 90%;
</html> height: 70vh;
<?php }
} elseif (APP_TYPE == 'short') { </style>
?> <title>Slack paste.</title>
<!DOCTYPE html> </head>
<html lang="ru"> <body>
<head> <h3>Slack Paste</h3>
<meta charset="UTF-8" /> <form method="post" action="<?php print APP_ADDRESS; ?>" enctype="multipart/form-data">
<style> <textarea name="exs" id="textbox" autofocus></textarea><br />
* { <input type="submit" value="Post it!" style="font-size:115%;" />
margin: 10px; for
text-align: center; <select name="etime" style="font-size:115%; text-align:left;">
font-size: 14pt; <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>
html, body { <option value="3" style="font-size: 85%; text-align:left;">1 day</option>
background-color: #adc0fc; text-align: center; <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>
</style> <option value="6" style="font-size: 85%; text-align:left;">3 Months</option>
<title>Link Shortener</title> <option value="7" selected style="font-size: 85%; text-align:left;">6 Months</option>
</head> <option value="8" style="font-size: 85%; text-align:left;">1 Year</option>
<body> <option value="9" style="font-size: 85%; text-align:left;">2 Years</option>
<img src="<?php print CDN_ADDRESS; ?>logo.png" /> <option value="10" style="font-size: 85%; text-align:left;">3 Years</option>
</select>
<form method="post" action="<?php print APP_ADDRESS; ?>"> </form>
Shorten this link:<br /> <?php
<input type="text" maxlength="768" name="exs" style="font-size: 110%; width:45%;" autofocus/></br /> if ($text != '') {
<input type="submit" value="Submit" style="font-size: 85%;" /> printf (" <p><table align=\"center\" frame=\"void\" border=\"0\"><td>%s</td></table></p>\n", $text);
for }
<select name="etime" style="font-size: 85%; text-align:left;"> ?>
<option value="1" style="font-size: 85%; text-align:left;">1 Hour</option> <p style="font-size: small;">
<option value="2" style="font-size: 85%; text-align:left;">12 Hours</option> Console client can be found here: <a href="<?php print APP_ADDRESS; ?>e"><?php print APP_ADDRESS; ?>e</a>&nbsp; &nbsp; thanks <a href="http://sprunge.us">sprunge.us</a> for their client :)<br/>
<option value="3" style="font-size: 85%; text-align:left;">1 day</option> More minimalist console client can be found here: <a href="<?php print APP_ADDRESS; ?>d"><?php print APP_ADDRESS; ?>d</a><br/>
<option value="4" style="font-size: 85%; text-align:left;">1 week</option> <br/>
<option value="5" style="font-size: 85%; text-align:left;">1 Month</option> 2015
<option value="6" style="font-size: 85%; text-align:left;">3 Months</option> </p>
<option value="7" selected style="font-size: 85%; text-align:left;">6 Months</option> </body>
<option value="8" style="font-size: 85%; text-align:left;">1 Year</option> </html>
<option value="9" style="font-size: 85%; text-align:left;">2 Years</option> <?php
<option value="10" style="font-size: 85%; text-align:left;">3 Years</option> } elseif (APP_TYPE == 'short') {
</select> ?>
</form> <!DOCTYPE html>
<?php <html lang="ru">
if ($text != '') { <head>
printf (" <table style=\"margin: 0px auto;\"><td>%s</td></table>\n", $text); <meta charset="UTF-8" />
} <style>
?> * {
</body> margin: 10px;
</html> text-align: center;
<?php font-size: 14pt;
} }
} html, body {
background-color: #adc0fc; text-align: center;
function eclient() { }
header('Content-Language: en, ru'); </style>
header('Content-Type: text/plain'); <title>Link Shortener</title>
header('Content-Disposition: attachment; filename="e"'); </head>
?> <body>
#!/bin/bash <img src="<?php print CDN_ADDRESS; ?>logo.png" />
usage() { <form method="post" action="<?php print APP_ADDRESS; ?>">
description | fmt -s >&2 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%;" />
description() { for
cat << HERE <select name="etime" style="font-size: 85%; text-align:left;">
<option value="1" style="font-size: 85%; text-align:left;">1 Hour</option>
DESCRIPTION <option value="2" style="font-size: 85%; text-align:left;">12 Hours</option>
Upload data and fetch URL from the pastebin http://p.dafuq.ru/ <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>
USAGE <option value="5" style="font-size: 85%; text-align:left;">1 Month</option>
$0 filename.txt <option value="6" style="font-size: 85%; text-align:left;">3 Months</option>
$0 text string <option value="7" selected style="font-size: 85%; text-align:left;">6 Months</option>
$0 < filename.txt <option value="8" style="font-size: 85%; text-align:left;">1 Year</option>
piped_data | $0 <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>
NOTES </select>
-------------------------------------------------------------------------- </form>
* INPUT METHODS * <?php
$0 can accept piped data, STDIN redirection [<filename.txt], text strings following the command as arguments, or filenames as arguments. Only one of these methods can be used at a time, so please see the note on precedence. Also, note that using a pipe or STDIN redirection will treat tabs as spaces, or disregard them entirely (if they appear at the beginning of a line). So I suggest using a filename as an argument if tabs are important either to the function or readability of the code. if ($text != '') {
printf (" <table style=\"margin: 0px auto;\"><td>%s</td></table>\n", $text);
* PRECEDENCE * }
STDIN redirection has precedence, then piped input, then a filename as an argument, and finally text strings as an arguments. ?>
</body>
EXAMPLE: </html>
echo piped | "$0" arguments.txt < stdin_redirection.txt <?php
}
In this example, the contents of file_as_stdin_redirection.txt would be uploaded. Both the piped_text and the file_as_argument.txt are ignored. If there is piped input and arguments, the arguments will be ignored, and the piped input uploaded. }
* FILENAMES * public function eclient () {
If a filename is misspelled or doesn\'t have the necessary path description, it will NOT generate an error, but will instead treat it as a text string and upload it. header('Content-Language: en, ru');
-------------------------------------------------------------------------- header('Content-Type: text/plain');
header('Content-Disposition: attachment; filename="e"');
HERE ?>
exit #!/bin/bash
}
usage() {
if [ -t 0 ]; then description | fmt -s >&2
echo Running interactively, checking for arguments... >&2 }
if [ "$*" ]; then
echo Arguments present... >&2 description() {
if [ -f "$*" ]; then cat << HERE
echo Uploading the contents of "$*"... >&2
cat "$*" DESCRIPTION
else Upload data and fetch URL from the pastebin http://p.dafuq.ru/
echo Uploading the text: \""$*"\"... >&2
echo "$*" USAGE
fi | curl -F "exs=<-" <?php print SITE_ADDRESS; ?> $0 filename.txt
else $0 text string
echo No arguments found, printing USAGE and exiting. >&2 $0 < filename.txt
usage piped_data | $0
fi
else NOTES
echo Using input from a pipe or STDIN redirection... >&2 --------------------------------------------------------------------------
while read -r line ; do * INPUT METHODS *
echo $line $0 can accept piped data, STDIN redirection [<filename.txt], text strings following the command as arguments, or filenames as arguments. Only one of these methods can be used at a time, so please see the note on precedence. Also, note that using a pipe or STDIN redirection will treat tabs as spaces, or disregard them entirely (if they appear at the beginning of a line). So I suggest using a filename as an argument if tabs are important either to the function or readability of the code.
done | curl -F "exs=<-" <?php print SITE_ADDRESS; ?>
fi * PRECEDENCE *
<?php STDIN redirection has precedence, then piped input, then a filename as an argument, and finally text strings as an arguments.
exit;
} EXAMPLE:
echo piped | "$0" arguments.txt < stdin_redirection.txt
function dclient() {
header('Content-Language: en, ru'); In this example, the contents of file_as_stdin_redirection.txt would be uploaded. Both the piped_text and the file_as_argument.txt are ignored. If there is piped input and arguments, the arguments will be ignored, and the piped input uploaded.
header('Content-Type: text/plain');
header('Content-Disposition: attachment; filename="d";'); * FILENAMES *
?> If a filename is misspelled or doesn\'t have the necessary path description, it will NOT generate an error, but will instead treat it as a text string and upload it.
#!/usr/bin/env bash --------------------------------------------------------------------------
if [[ "$1" == "--help" ]]; then HERE
echo "Usage: $0 < file" exit
echo " echo foo | $0" }
elif [[ -f "$1" ]]; then
curl -F "exs=<-" "<?php print SITE_ADDRESS; ?>" <"$1" if [ -t 0 ]; then
else echo Running interactively, checking for arguments... >&2
curl -F "exs=<-" "<?php print SITE_ADDRESS; ?>" if [ "$*" ]; then
fi echo Arguments present... >&2
if [ -f "$*" ]; then
exit 0 echo Uploading the contents of "$*"... >&2
'; cat "$*"
<?php else
exit; echo Uploading the text: \""$*"\"... >&2
} echo "$*"
fi | curl -F "exs=<-" <?php print SITE_ADDRESS; ?>
function gen_id() { else
$urllen = rand (KEY_MIN, KEY_MAX); echo No arguments found, printing USAGE and exiting. >&2
$string = ''; usage
$a = Array(); $a = array_merge(range('A', 'Z'), range('a', 'z')); fi
else
for($i = 0; $i < $urllen; $i++){ echo Using input from a pipe or STDIN redirection... >&2
$string .= $a[rand (0, count($a) - 1)]; while read -r line ; do
} echo $line
done | curl -F "exs=<-" <?php print SITE_ADDRESS; ?>
return($string); fi
} <?php
exit;
function init_db() { }
# we init db, eh? drop db file and re-create it!
if (file_exists(DBPATH)) { unlink(DBPATH); } public function dclient () {
if (! file_exists(dirname(DBPATH))) { mkdir(dirname(DBPATH), 0777, true); } header('Content-Language: en, ru');
header('Content-Type: text/plain');
$dbh = new PDO("sqlite:" . DBPATH); header('Content-Disposition: attachment; filename="d";');
?>
$r = $dbh->exec( #!/usr/bin/env bash
"CREATE TABLE IF NOT EXISTS paste (
id TEXT PRIMARY KEY, if [[ "$1" == "--help" ]]; then
paste TEXT, echo "Usage: $0 < file"
time INTEGER, echo " echo foo | $0"
etime INTEGER elif [[ -f "$1" ]]; then
)" curl -F "exs=<-" "<?php print SITE_ADDRESS; ?>" <"$1"
); else
curl -F "exs=<-" "<?php print SITE_ADDRESS; ?>"
if($r === false) { fi
$e = $r->errorInfo();
showindex($e[2]); exit 0
} ';
<?php
$dbh = null; exit;
} }
function query_db($q) { protected function gen_id () {
if (! file_exists(DBPATH)) { $urllen = rand (KEY_MIN, KEY_MAX);
init_db(); $string = '';
return false; $a = Array(); $a = array_merge(range('A', 'Z'), range('a', 'z'));
}
for ($i = 0; $i < $urllen; $i++) {
$dbh = new PDO("sqlite:" . DBPATH); $string .= $a[rand (0, count($a) - 1)];
$sth = $dbh->query("SELECT paste FROM paste WHERE id='$q'"); }
if ($sth === false) { return($string);
$e = $r->errorInfo(); }
showindex($e[2]);
exit; public function query_db ($q) {
} $dbh = new PDO("sqlite:" . DBPATH);
$sth = $dbh->query("SELECT paste FROM paste WHERE id='$q'");
$sth->setFetchMode(PDO::FETCH_ASSOC);
$data = $sth->fetch(); if ($sth === false) {
$dbh = null; $e = $r->errorInfo();
self::showindex($e[2]);
if ($data === false) { exit;
return($data); }
} else {
if (isset($data['etime']) and ($data['etime'] < time())){ $sth->setFetchMode(PDO::FETCH_ASSOC);
return false; $data = $sth->fetch();
} $dbh = null;
$data = $data['paste']; if ($data === false) {
return($data); # false if no data or no key in db return($data);
} } else {
} if (isset($data['etime']) and ($data['etime'] < time())){
return false;
function store_data($paste) { }
if (! file_exists(DBPATH)) { init_db(); }
$dbh = new PDO("sqlite:" . DBPATH); $data = $data['paste'];
$q = 0; return($data); # false if no data or no key in db
}
do { }
if ($q > 100) { # assume key-value space depleted if we try more than 100 times
$q = false; public function store_data ($paste) {
break; $dbh = new PDO("sqlite:" . DBPATH);
} $q = 0;
$id = gen_id();
$q++; do {
} while (! $dbh->query("SELECT id FROM paste WHERE id='$id'")); if ($q > 100) { # assume key-value space depleted if we try more than 100 times
$q = false;
if($q === false) { break;
return('Storage depleted.'); }
}
$id = self::gen_id();
$ctime = time(); $q++;
$etime = $ctime + 14515200; } while (! $dbh->query("SELECT id FROM paste WHERE id='$id'"));
if(isset($_POST['etime'])) { if ($q === false) {
switch ($_POST['etime']) { return('Storage depleted.');
case '1': # 1 hour }
$etime = $ctime + 3600;
break; $ctime = time();
$etime = $ctime + 14515200;
case '2': # 12 hours
$etime = $ctime + 43200; if (isset($_POST['etime'])) {
break; switch ($_POST['etime']) {
case '1': # 1 hour
case '3': # 1 day $etime = $ctime + 3600;
$etime = $ctime + 86400; break;
break;
case '2': # 12 hours
case '4': # 1 week $etime = $ctime + 43200;
$etime = $ctime + 604800; break;
break;
case '3': # 1 day
case '5': # 1 month $etime = $ctime + 86400;
$etime = $ctime + 2419200; break;
break;
case '4': # 1 week
case '6': # 3 months $etime = $ctime + 604800;
$etime = $ctime + 7257600; break;
break;
case '5': # 1 month
case '7': # 6 months $etime = $ctime + 2419200;
$etime = $ctime + 14515200; break;
break;
case '6': # 3 months
case '8': # 1 year $etime = $ctime + 7257600;
$etime = $ctime + 29030400; break;
break;
case '7': # 6 months
case '9': # 2 years $etime = $ctime + 14515200;
$etime = $ctime + 58060800; break;
break;
case '8': # 1 year
case '10': # 3 years $etime = $ctime + 29030400;
$etime = $ctime + 87091200; break;
break;
case '9': # 2 years
case '13': # forever $etime = $ctime + 58060800;
$etime = "null"; break;
break;
} case '10': # 3 years
} $etime = $ctime + 87091200;
break;
$sth = $dbh->prepare("INSERT INTO paste VALUES('$id', '$paste', $ctime, $etime)");
$sth->execute(); case '13': # forever
$etime = "null";
if ($sth === false) { break;
$e = $sth->errorInfo(); }
showindex($e[2]); }
exit;
} $sth = $dbh->prepare("INSERT INTO paste VALUES('$id', '$paste', $ctime, $etime)");
$sth->execute();
$dbh = null;
return($id); if ($sth === false) {
} $e = $sth->errorInfo();
self::showindex($e[2]);
exit;
/* }
* MAIN STARTS HERE
*/ $dbh = null;
return($id);
$text = ''; }
}
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')); /*
* MAIN STARTS HERE
if (APP_TYPE == 'paste') { */
if ($str == 'e') {
eclient(); $text = '';
exit; $p = new paste;
} elseif ($str == 'd') {
dclient(); if (($_SERVER['REQUEST_METHOD'] === 'GET') or ($_SERVER['REQUEST_METHOD'] === 'HEAD')) {
exit; # substr returns empty string (boolean false) on error
} $str = $_SERVER['REQUEST_URI']; $str = substr($str, mb_strlen(BASEURL, 'UTF-8'));
# pastebin returns raw paste when paste' key prepended with /raw/, let's handle it if (APP_TYPE == 'paste') {
if (preg_match('/^raw\//', $str) == 1) { if ($str == 'e') {
$str = substr($str, mb_strlen('raw/', 'UTF-8')); $p->eclient();
} exit;
} } elseif ($str == 'd') {
$p->dclient();
if ((mb_strlen($str, 'UTF-8') >= KEY_MIN) and ((mb_strlen($str, 'UTF-8') <= KEY_MAX))) { exit;
if (preg_match('/^[a-z|A-Z]+$/', $str) == 1) { }
$response = query_db($str);
# pastebin returns raw paste when paste' key prepended with /raw/, let's handle it
if ($response === false) { if (preg_match('/^raw\//', $str) == 1) {
$text = 'No such paste.'; $str = substr($str, mb_strlen('raw/', 'UTF-8'));
} else { }
$response = base64_decode($response); }
if (APP_TYPE == 'paste') { if ((mb_strlen($str, 'UTF-8') >= KEY_MIN) and ((mb_strlen($str, 'UTF-8') <= KEY_MAX))) {
header('Content-Type: text/plain'); if (preg_match('/^[a-z|A-Z]+$/', $str) == 1) {
print $response; $response = $p->query_db($str);
exit;
} elseif (APP_TYPE == 'short') { if ($response === false) {
header( "Location: " . $response, true, 301 ); $text = 'No such paste.';
} } else {
} $response = base64_decode($response);
}
} if (APP_TYPE == 'paste') {
header('Content-Type: text/plain');
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { print $response;
if (isset($_POST['exs']) and ($_POST['exs'] != '')) { exit;
if (APP_TYPE == 'short') { } elseif (APP_TYPE == 'short') {
# I don't like loops :) header( "Location: " . $response, true, 301 );
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 } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
(preg_match('/^mailto\:/', $_POST['exs']) == 1) or if (isset($_POST['exs']) and ($_POST['exs'] != '')) {
(preg_match('/^rtmp\:/', $_POST['exs']) == 1) or if (APP_TYPE == 'short') {
(preg_match('/^rtsp\:/', $_POST['exs']) == 1) or # I don't like loops :)
(preg_match('/^rtp\:/', $_POST['exs']) == 1) or if ((preg_match('/^https?\:/', $_POST['exs']) == 1) or
(preg_match('/^soutcast\:/', $_POST['exs']) == 1) or (preg_match('/^s?ftps?\:/', $_POST['exs']) == 1) or
(preg_match('/^icecast\:/', $_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('/^magnet\:/', $_POST['exs']) == 1) or (preg_match('/^ldaps?\:/', $_POST['exs']) == 1) or
(preg_match('/^ed2k\:/', $_POST['exs']) == 1) or (preg_match('/^ircs?\:/', $_POST['exs']) == 1) or
(preg_match('/^ssh\:/', $_POST['exs']) == 1) or (preg_match('/^xmpp\:/', $_POST['exs']) == 1) or
(preg_match('/^svn\:/', $_POST['exs']) == 1) or (preg_match('/^mailto\:/', $_POST['exs']) == 1) or
(preg_match('/^hg\:/', $_POST['exs']) == 1) or (preg_match('/^rtmp\:/', $_POST['exs']) == 1) or
(preg_match('/^git\:/', $_POST['exs']) == 1) or (preg_match('/^rtsp\:/', $_POST['exs']) == 1) or
(preg_match('/^smb\:/', $_POST['exs']) == 1) or (preg_match('/^rtp\:/', $_POST['exs']) == 1) or
(preg_match('/^ipp\:/', $_POST['exs']) == 1) or (preg_match('/^soutcast\:/', $_POST['exs']) == 1) or
(preg_match('/^chrome\:/', $_POST['exs']) == 1) or # i'm doubt if this really working, but anyway (preg_match('/^icecast\:/', $_POST['exs']) == 1) or
(preg_match('/^vivaldi\:/', $_POST['exs']) == 1) or # i'm doubt if this really working, but anyway (preg_match('/^magnet\:/', $_POST['exs']) == 1) or
(preg_match('/^opera\:/', $_POST['exs']) == 1) or # i'm doubt if this really working, but anyway (preg_match('/^ed2k\:/', $_POST['exs']) == 1) or
(preg_match('/^about\:/', $_POST['exs']) == 1) or # i'm doubt if this really working, but anyway (preg_match('/^ssh\:/', $_POST['exs']) == 1) or
(preg_match('/^skype\:/', $_POST['exs']) == 1)) { (preg_match('/^svn\:/', $_POST['exs']) == 1) or
$text = APP_ADDRESS . store_data(base64_encode($_POST['exs'])); (preg_match('/^hg\:/', $_POST['exs']) == 1) or
} else { (preg_match('/^git\:/', $_POST['exs']) == 1) or
$text = 'Unable to short your link.'; (preg_match('/^smb\:/', $_POST['exs']) == 1) or
} (preg_match('/^ipp\:/', $_POST['exs']) == 1) or
} elseif (APP_TYPE == 'paste') { (preg_match('/^chrome\:/', $_POST['exs']) == 1) or # i'm doubt if this really working, but anyway
$text = APP_ADDRESS . store_data(base64_encode($_POST['exs'])); (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
} elseif ((APP_TYPE == 'paste') and (isset($_POST['api_option']))) { # some pastebin API compatibility stuff (preg_match('/^about\:/', $_POST['exs']) == 1) or # i'm doubt if this really working, but anyway
if ($_POST['api_option'] == 'paste') { (preg_match('/^skype\:/', $_POST['exs']) == 1)) {
if ((isset($_POST['api_paste_code'])) and ($_POST['api_paste_code'] != '')) { $text = APP_ADDRESS . $p->store_data(base64_encode($_POST['exs']));
header('Content-Type: text/plain; charset=utf-8'); } else {
print mb_convert_encoding(APP_ADDRESS . store_data(base64_encode($_POST['api_paste_code'])), 'UTF-8', 'auto'); $text = 'Unable to short your link.';
exit; }
} } elseif (APP_TYPE == 'paste') {
} elseif ($_POST['api_option'] == 'show_paste') { $text = APP_ADDRESS . $p->store_data(base64_encode($_POST['exs']));
if (isset($_POST['api_paste_key'])) { }
$str = $_POST['api_paste_key']; } elseif ((APP_TYPE == 'paste') and (isset($_POST['api_option']))) { # some pastebin API compatibility stuff
if ($_POST['api_option'] == 'paste') {
if ((mb_strlen($str, 'UTF-8') >= KEY_MIN) and ((mb_strlen($str, 'UTF-8') <= KEY_MAX))) { if ((isset($_POST['api_paste_code'])) and ($_POST['api_paste_code'] != '')) {
if (preg_match('/^[a-z|A-Z]+$/', $str) == 1) { header('Content-Type: text/plain; charset=utf-8');
$response = query_db($str); print mb_convert_encoding(APP_ADDRESS . $p->store_data(base64_encode($_POST['api_paste_code'])), 'UTF-8', 'auto');
exit;
if ($response === false) { }
header('Content-Type: text/plain; charset=utf-8'); } elseif ($_POST['api_option'] == 'show_paste') {
print "Bad API request, invalid permission to view this paste or invalid api_paste_key"; if (isset($_POST['api_paste_key'])) {
exit; $str = $_POST['api_paste_key'];
} else {
header('Content-Type: text/plain'); if ((mb_strlen($str, 'UTF-8') >= KEY_MIN) and ((mb_strlen($str, 'UTF-8') <= KEY_MAX))) {
print base64_decode($response); if (preg_match('/^[a-z|A-Z]+$/', $str) == 1) {
exit; $response = $p->query_db($str);
}
} if ($response === false) {
} header('Content-Type: text/plain; charset=utf-8');
} print "Bad API request, invalid permission to view this paste or invalid api_paste_key";
} exit;
} } else {
} header('Content-Type: text/plain');
print base64_decode($response);
showindex($text); exit;
}
/* }
* END OF MAIN }
*/ }
?> }
}
}
$p->showindex($text);
/*
* END OF MAIN
*/
?>