View previous topic :: View next topic |
Author |
Message |
pigeonburger -
Joined: 17 Sep 2020 Posts: 21
|
Posted: Thu Sep 17, 2020 6:34 am Post subject: How to prevent the last dir from being listed in this dir |
|
|
I've used Abyss WS X1 for a few weeks now, and have been working on a custom directory list.
It always lists the directories like this:
../ (takes you back to previous directory)
file1.mp4
file2.docx
file3.mp3
How can I get rid of the ../, that takes me back to the previous directory? Directories themselves don't have MIME types so what can I do to get rid of it? Is it even possible to do that?
Thanks in advance for any help. |
|
Back to top |
|
|
admin Site Admin
Joined: 03 Mar 2002 Posts: 1296
|
Posted: Sun Oct 04, 2020 4:36 pm Post subject: Re: How to prevent the last dir from being listed in this di |
|
|
pigeonburger,
In such cases, it is recommended to filter out the unwanted line by using a test in your SSI directives. Please get in touch with us by email for a faster exchange. _________________ Follow @abyssws on Twitter
Subscribe to our newsletter
_________________
Forum Administrator
Aprelium - https://aprelium.com |
|
Back to top |
|
|
pkSML -
Joined: 29 May 2006 Posts: 952 Location: Michigan, USA
|
Posted: Mon Oct 05, 2020 3:33 am Post subject: |
|
|
You can also use a script if you’ve set up a scripting language interpreter (e.g. PHP) in Abyss. _________________ Stephen
Need a LitlURL?
http://CodeBin.yi.org |
|
Back to top |
|
|
pigeonburger -
Joined: 17 Sep 2020 Posts: 21
|
Posted: Tue Jan 26, 2021 6:28 am Post subject: |
|
|
Well, I've improved A LOT since I posted this lol and I've come a long way with my programming and projects such as @editvideobot but I thought I'd come back and leave an answer for the sake of it!
(and yes @pkSML I did end up using a script haha, I didn't want to back then because I was basically a vegetable at this stuff)
The actual script I use has a lot of stuff to do with the Twitter API and extra styling and stuff, so I'll give the basic examples by just modifying the examples provided in the AbyssWS docs!
For PHP:
Code: |
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<TITLE>
Index of <?php echo $_POST['path']; ?>
</TITLE>
</HEAD>
<BODY>
<TABLE BORDER="0">
<TR>
<TD>Name</TD>
<TD>Size</TD>
<TD>Date</TD>
<TD>MIME Type</TD>
</TR>
<?php
/* Split and get the lines */
$lines = explode("\n", $_POST['files']);
/* For each line do... */
foreach ($lines as $line)
{
/* Split the line and get the file information */
list($name, $url, $size, $date, $mimetype) = explode("\t", $line);
if ($mimetype == ""){
}
else{
echo "<TR><TD><A HREF=\"$url\">" . htmlentities($name) .
"</A></TD><TD>$size</TD><TD>$date</TD><TD>$mimetype</TD></TR>";}
}
?>
</TABLE>
</BODY>
</HTML>
|
For Python 2 (just add parentheses the the print statements if you're using Python 3):
Code: |
import cgi, string, os
posted_data = cgi.FieldStorage()
# Write the CGI header
print "Content-Type: text/html; charset=utf-8"
print
print "<HTML><HEAD>"
print "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">"
print "<TITLE>Index of %s</TITLE></HEAD>" % posted_data["path"].value
print "<TABLE BORDER='0'><TR><TD>Name</TD><TD>Size</TD><TD>Date</TD><TD>MIME Type</TD></TR>"
# Split and get the lines
lines = (posted_data["files"].value).split("\n")
# for each line do...
for line in lines:
# Split the line and get the file information
(name, url, size, date, mimetype) = line.split("\t")
if (mimetype == ""):
pass
else:
print "<TR><TD><A HREF=\"%s\">%s</A></TD>" % ( url, cgi.escape(name) )
print "<TD>%d</TD><TD>%s</TD><TD>%s</TD></TR>" % (int(size), date, mimetype)
print "</TABLE></BODY></HTML>"
|
The tabs might need to be fixed properly (I just edited this code here using 4 spaces) but the idea is simple; skip over anything that has a blank MIME type (e.g. a directory) and only show the actual files! _________________ Pigeonburger
Twitter: @pigeonburger
Website (hosted by Abyss X2): https://pigeonburger.xyz |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|