Add file upload/download features

This commit is contained in:
Retro_Guy 2021-05-13 02:24:54 -07:00
parent d834f7757d
commit db4b2b4e89
4 changed files with 183 additions and 7 deletions

View File

@ -5,13 +5,11 @@ echo '<h4><p align="left">Welcome to Rocksolid</p>';
echo '<p align="left">How to access and whats available</p></h4><br />'; echo '<p align="left">How to access and whats available</p></h4><br />';
echo '<font size="4em">'; echo '<font size="4em">';
echo '<b>def2:</b><br /><a href="http://def2.i2p">def2.i2p</a><br /><a href="http://kyue3hfjhqxj3df4hox46itdyz7euah457ldtg4d23evfggumxw4rkid.onion">kyue3hfjhqxj3df4hox46itdyz7euah457ldtg4d23evfggumxw4rkid.onion</a><br />';
echo '<b>def3:</b><br /><a href="http://def3.i2p">def3.i2p</a><br /><a href="http://sumconrfm6sbd24f6clau7ynwjvot54hmiidf62d6e3otktd4fyxupid.onion">sumconrfm6sbd24f6clau7ynwjvot54hmiidf62d6e3otktd4fyxupid.onion</a><br />';
echo '<b>def4:</b><br /><a href="http://def4.i2p">def4.i2p</a><br /><a href="http://q4pkyd4wt5s7bzcmjzmtq2htm3hfklylf3va3xt4gcwrp2zt6oeyseid.onion">q4pkyd4wt5s7bzcmjzmtq2htm3hfklylf3va3xt4gcwrp2zt6oeyseid.onion</a><br />';
echo '<br />';
echo '<b>Rocksolid Light:</b><br /><a href="http://rslight.i2p">rslight.i2p</a><br /><a href="http://fev4bgoasgxttqb3x3tukxxia6lwryteq6a2ramqb2gjiol3zbu6xaid.onion">fev4bgoasgxttqb3x3tukxxia6lwryteq6a2ramqb2gjiol3zbu6xaid.onion</a><br /><a href="https://news.novabbs.org">news.novabbs.org</a><br />'; echo '<b>Rocksolid Light:</b><br /><a href="http://rslight.i2p">rslight.i2p</a><br /><a href="http://fev4bgoasgxttqb3x3tukxxia6lwryteq6a2ramqb2gjiol3zbu6xaid.onion">fev4bgoasgxttqb3x3tukxxia6lwryteq6a2ramqb2gjiol3zbu6xaid.onion</a><br /><a href="https://news.novabbs.org">news.novabbs.org</a><br />';
echo '<b>retrobbs:</b><br /><a href="http://retrobbs.i2p">retrobbs.i2p</a><br /><a href="https://www.rocksolidbbs.com">www.rocksolidbbs.com</a><br />'; echo '<br />';
echo '<b>novabbs:</b><br /><a href="https://www.novabbs.com">www.novabbs.com</a><br />'; echo '<b>retroBBS:</b><br /><a href="http://retrobbs.i2p">retrobbs.i2p</a><br /><a href="http://retrobbs2.i2p">retrobbs2.i2p</a><br /><a href="https://www.rocksolidbbs.com">www.rocksolidbbs.com</a><br />';
echo '<br />';
echo '<b>novaBBS:</b><br /><a href="https://www.novabbs.com">www.novabbs.com</a><br />';
echo '<br />'; echo '<br />';
echo 'Newsreader Access:<br />'; echo 'Newsreader Access:<br />';
@ -19,7 +17,7 @@ echo 'v77lu6t26velvaddm4gibyzd5sogskuczp7vwoc4vxmukvvaucva.b32.i2p<br />';
echo 'zkcvkb5xprurx5dvpanhyivneuzah6k6xayxgxd4h2ekklxgoi2x5aad.onion:119<br />'; echo 'zkcvkb5xprurx5dvpanhyivneuzah6k6xayxgxd4h2ekklxgoi2x5aad.onion:119<br />';
echo 'news.novabbs.org:119 or 563<br />'; echo 'news.novabbs.org:119 or 563<br />';
echo '<br />'; echo '<br />';
echo 'Create NNTP Account: Use one of the <i>rslight</i> links above to create account.<br />'; echo 'Create NNTP Account: Use one of the <i>Rocksolid Light</i> links above to create account.<br />';
echo 'NNTP Peering also available in i2p/tor/clearnet<br />'; echo 'NNTP Peering also available in i2p/tor/clearnet<br />';
echo '<br />'; echo '<br />';
echo 'Rocksolid is also available from any usenet news provider carrying the rocksolid.* hierarchy<br />'; echo 'Rocksolid is also available from any usenet news provider carrying the rocksolid.* hierarchy<br />';

View File

@ -0,0 +1,111 @@
<?php
include "config.inc.php";
include "newsportal.php";
include $config_dir.'/admin.inc.php';
if(isset($_COOKIE['tzo'])) {
$offset=$_COOKIE['tzo'];
} else {
$offset=$CONFIG['timezone'];
}
if($_REQUEST['command'] == 'Show' && $_REQUEST['key'] == hash('md5', $admin['key'])) {
$getfilename = $spooldir.'/upload/'.$_REQUEST['showfile'];
$getfh = fopen($getfilename, "rb");
$getfile = fread($getfh, filesize($getfilename));
fclose($getfh);
header('Content-type: '.$_REQUEST[contenttype]);
header('Content-disposition: filename="'.$_REQUEST[showfilename].'"');
echo $getfile;
exit(0);
}
include "head.inc";
$directory = $spooldir.'/upload/';
$users = array();
if(is_dir($directory)) {
if($users_list = opendir($directory)) {
while(($user_dir = readdir($users_list)) !== false) {
if($user_dir == '.' || $user_dir == '..') {
continue;
}
$users[] = $user_dir;
}
closedir($user_dir);
}
}
sort($users);
$found = 0;
echo '<strong><small><a href="upload.php">Click here to upload to your directory</a>, or<br />';
if(count($users) > 0) {
echo "Select a user directory to browse</small></strong>";
echo '<form name="browse" method="post" action="files.php" enctype="multipart/form-data">';
echo '<input name="command" type="hidden" id="command" value="Browse" readonly="readonly">';
echo '<input type="hidden" name="key" value="'.hash('md5', $admin['key']).'">';
echo '<select name="listbox">';
foreach($users as $user) {
$num = count(scandir($spooldir.'/upload/'.$user.'/')) - 2;
if($user == $_POST['listbox']) {
echo '<option value="'.$user.'" selected="selected">'.$user.' ('.$num.' files)</option>';
$found = 1;
} else {
echo '<option value="'.$user.'">'.$user.' ('.$num.' files)</option>';
}
}
echo '</select>';
echo '<input type="submit" name="Submit" value="Browse">';
echo '</form>';
}
if($found == 1 && $_POST['key'] == hash('md5', $admin['key'])) {
display_user_files($_POST['listbox'], $offset, $admin);
}
function display_user_files($user, $offset, $admin) {
global $CONFIG, $spooldir, $text_header;
$directory = $spooldir.'/upload/'.$user.'/';
if(is_dir($directory)) {
$files = scandir($directory);
}
natcasesort($files);
echo '<table cellspacing="0" class="np_thread_table">';
echo '<tr class="np_thread_head"><td class="np_thread_head">Filename</td><td>File Type</td><td>Date</td></tr>';
$i=0;
foreach($files as $file) {
if($file == '.' || $file == '..') {
continue;
}
$lineclass="np_thread_line".(($i%2)+1);
$thisfile = $spooldir.'/upload/'.$user.'/'.$file;
// Use local timezone if possible
$ts = new DateTime(date("D, j M Y H:i T", filectime($thisfile)), new DateTimeZone('UTC'));
$ts->add(DateInterval::createFromDateString($offset.' minutes'));
if($offset != 0) {
$newdate = $ts->format('j M Y');
} else {
$newdate = $ts->format('j M Y T');
}
unset($ts);
echo '<tr class="'.$lineclass.'">';
$mime = mime_content_type($thisfile);
// Link
echo '<td class="'.$lineclass.'">';
echo '<form action="files.php" method="post" target="rslight_view">';
echo '<button class="np_button_link" type="submit">'.$file.'</button>';
echo '<input type="hidden" name="showfile" value="'.$user.'/'.$file.'"/>';
echo '<input type="hidden" name="showfilename" value="'.$file.'"/>';
echo '<input type="hidden" name="key" value="'.hash('md5', $admin['key']).'">';
echo '<input type="hidden" name="contenttype" value="'.$mime.'">';
echo '<input name="command" type="hidden" id="command" value="Show" readonly="readonly">';
echo '</form>';
echo '</td>';
// echo '<td class="'.$lineclass.'"><span class="np_thread_line_text">'.$file.'</span></td>';
echo '<td class="'.$lineclass.'"><span class="np_thread_line_text">'.$mime.'</span></td>';
echo '<td class="'.$lineclass.'"><span class="np_thread_line_text">'.$newdate.'</span></td>';
echo '</tr>';
$i++;
}
echo '</table>';
}
?>

View File

@ -0,0 +1,66 @@
<?php
include "config.inc.php";
include "newsportal.php";
include $config_dir.'/admin.inc.php';
if(isset($_POST['username'])) {
$name = $_POST['username'];
// Save name in cookie
if ($setcookies==true) {
setcookie("cookie_name",stripslashes($name),time()+(3600*24*90));
}
} else {
if ($setcookies) {
if ((isset($_COOKIE["cookie_name"])) && (!isset($name))) {
$name=$_COOKIE["cookie_name"];
} else {
$name = '';
}
}
}
include "head.inc";
if(isset($_FILES)) {
// Check auth here
if(isset($_POST['key']) && $_POST['key'] == hash('md5', $admin['key'])) {
if(check_bbs_auth($_POST['username'], $_POST['password'])) {
$userdir = '/var/spool/rslight/upload/'.strtolower($_POST[username]);
$upload_to = $userdir.'/'.$_FILES[photo][name];
if(is_file($upload_to)) {
echo $_FILES[photo][name].' already exists in your folder';
} else {
if(!is_dir($userdir)) {
mkdir($userdir);
}
$success = move_uploaded_file($_FILES[photo][tmp_name], $upload_to);
if ($success) {
echo 'Saved '.$_FILES[photo][name].' to your files folder';
} else {
echo 'There was an error saving '.$_FILES[photo][name];
}
}
} else {
echo 'Authentication Failed';
}
echo '<br /><br />';
}
}
echo '<table border="0" align="center" cellpadding="0" cellspacing="1">';
echo '<form name="form1" method="post" action="upload.php" enctype="multipart/form-data">';
echo '<tr><td><strong>Please Login to Upload<br />(max size=1MB)</strong></td></tr>';
echo '<tr><td>Username:</td><td><input name="username" type="text" id="username" value="'.$name.'"></td></tr>';
echo '<tr><td>Password:</td><td><input name="password" type="password" id="password"></td></tr>';
echo '<td><input name="command" type="hidden" id="command" value="Upload" readonly="readonly"></td>';
echo '<input type="hidden" name="key" value="'.hash('md5', $admin['key']).'">';
echo '<tr><td><input type="file" name="photo" id="fileSelect" value="fileSelect" accept="image/*,audio/*,text/*,application/*"></td>
';
echo '<td>&nbsp;</td>';
echo '<td><input type="submit" name="Submit" value="Upload"></td>';
echo '</tr>';
echo '</form>';
echo '<tr><td><a href="files.php">Go to Files</a></td></tr>';
echo '</table>';
echo '</body></html>';
?>

View File

@ -1,5 +1,6 @@
# These are the links at the top right of the site # These are the links at the top right of the site
# display name:url # display name:url
register:/common/newuser.php register:/common/newuser.php
files:/rocksolid/files.php
nodelist:/common/nodelist.php nodelist:/common/nodelist.php
faq:/common/faq.txt faq:/common/faq.txt