Modified the thing so you can easily paste and new index
This commit is contained in:
parent
3f3d173e5d
commit
d041a216f7
4 changed files with 73 additions and 28 deletions
|
@ -14,35 +14,15 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with lainsafe. If not, see <https://www.gnu.org/licenses/>.
|
# along with lainsafe. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
my $disk_size = `df -h | awk 'NR==2 {print \$2; exit}'`;
|
|
||||||
my $disk_usage = `df -h | awk 'NR==2 {print \$3; exit}'`;
|
|
||||||
my $disk_free = `df -h | awk 'NR==2 {print \$4; exit}'`;
|
|
||||||
my $disk_percentage = `df -h | awk 'NR==2 {print \$5; exit}'`;
|
|
||||||
|
|
||||||
if ($ENV{REQUEST_METHOD} eq "POST") {
|
if ($ENV{REQUEST_METHOD} eq "POST") {
|
||||||
do "./upload.cgi";
|
do "./upload.cgi";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $SITE_URL = $ENV{REMOTE_ADDR};
|
||||||
|
|
||||||
print "Content-type: text/html\n\n";
|
print "Content-type: text/html\n\n";
|
||||||
print "<!DOCTYPE html>
|
|
||||||
<html lang=\"en\">
|
|
||||||
<head>
|
|
||||||
<title>lainsafe</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<h1>lainsafe</h1>
|
open(my $fh, "<index.html");
|
||||||
|
|
||||||
<img src='https://lainchan.org/static/lain_is_cute_datass_small.png'
|
print while <$fh>;
|
||||||
width=200 alt='cool lain' />
|
|
||||||
<form ENCTYPE='multipart/form-data' method='post' action='upload.cgi'>
|
|
||||||
<input type='file' name='file' size='30'>
|
|
||||||
<input type='submit' value='upload'>
|
|
||||||
</form>
|
|
||||||
<a href='https://github.com/dimethyltriptamine/lainsafe'>star me</a>
|
|
||||||
<h2>Terminal usage</h2>
|
|
||||||
<p>I recommend using clainsafecli to upload files to lainsafe, however, there is more than one way to do it.</p>
|
|
||||||
<code>curl -F 'file=@1605388889.png' $ENV{HTTP_HOST}$ENV{REQUEST_URI}</code><br/>
|
|
||||||
</body>
|
|
||||||
</html>";
|
|
||||||
|
|
38
http/index.css
Normal file
38
http/index.css
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
p {
|
||||||
|
color: white;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* p code {display: block;} */
|
||||||
|
|
||||||
|
code {
|
||||||
|
background: #4e4e4e;
|
||||||
|
font-family: monospace;
|
||||||
|
color: #e3e3e3;
|
||||||
|
margin: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body, input, select, textarea {
|
||||||
|
color: #333;
|
||||||
|
font-size: 10pt;
|
||||||
|
line-height: 1.65em;
|
||||||
|
letter-spacing: -0.015em;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background:#040304;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2 {
|
||||||
|
color: #e3e3e3;
|
||||||
|
}
|
||||||
|
.left {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 30px;
|
||||||
|
border-left-color: #333;
|
||||||
|
border-left-width: 2px;
|
||||||
|
border-left-style: solid;
|
||||||
|
padding: 10px;
|
||||||
|
|
||||||
|
}
|
27
http/index.html
Normal file
27
http/index.html
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>lainsafe</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="index.css"/>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>lainsafe</h1>
|
||||||
|
<h2>shitless file upload, pastebin and url shorter</h2>
|
||||||
|
<img src="https://www.lainchan.org/static/lain_is_cute_datass_small.png"/>
|
||||||
|
<h2>USAGE</h2>
|
||||||
|
<p>POST a file:</p>
|
||||||
|
<code>curl -F 'file=@yourfile.png' $SITE_URL</code>
|
||||||
|
<p>Shorten URL:</p>
|
||||||
|
<code>curl -F 'url=https://example.org' $SITE_URL</code>
|
||||||
|
<p>Post your text directly</p>
|
||||||
|
<code>curl -F 'file=@-' $SITE_URL</code>
|
||||||
|
<div class="left">
|
||||||
|
<h2>Or just upload a file here</h2>
|
||||||
|
<form ENCTYPE='multipart/form-data' method='post' action='upload.cgi'>
|
||||||
|
<input type='file' name='file' size='30'/>
|
||||||
|
<input type='submit' value='upload'/>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
use CGI;
|
use CGI;
|
||||||
use CGI::Carp qw(fatalsToBrowser);
|
use CGI::Carp qw(fatalsToBrowser);
|
||||||
use Time::HiRes qw(gettimeofday);
|
|
||||||
my $q = CGI->new;
|
my $q = CGI->new;
|
||||||
|
|
||||||
my $filename = $q->param('file');
|
my $filename = $q->param('file');
|
||||||
|
@ -74,8 +74,8 @@ if ($filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if($filename eq "-") {
|
if ($filename eq "-") {
|
||||||
$filename .= ".txt"; # for pastes
|
$filename .= ".txt"; # for pastes
|
||||||
}
|
}
|
||||||
if ($allowed_extension) {
|
if ($allowed_extension) {
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ if ($filename) {
|
||||||
|
|
||||||
close FILE;
|
close FILE;
|
||||||
$filename =~ s/ /%20/g;
|
$filename =~ s/ /%20/g;
|
||||||
print $prot. "://" . $ENV{HTTP_HOST} . "/$upload_dir$dirname/$filename";
|
print $prot. "://" . $ENV{HTTP_HOST} . "/$upload_dir$dirname/$filename" . "\n";
|
||||||
} else {
|
} else {
|
||||||
print "The file extension .$extension is not allowed in this instance.";
|
print "The file extension .$extension is not allowed in this instance.";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue