Advertisement
BillEvansAtMariposa

20160613-01

Jun 13th, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.58 KB | None | 0 0
  1. #!/usr/bin/env perl
  2.  
  3. # This code is provided without warranty of any kind. If you break it, you
  4. # get to keep the pieces.
  5. #
  6. # I ran it as /usr/local/www/apache24/cgi-bin/apachee24_ls.cgi, with the
  7. # following lines somewhere in httpd.conf (without the "#", of course):
  8. #
  9. # <Directory "/usr/local/www/apache24/cgi-bin">
  10. # AllowOverride None
  11. # Options None
  12. # Require all granted
  13. # </Directory>
  14. #
  15. # ScriptAlias /cgi-bin/ "/usr/local/www/apache24/cgi-bin/"
  16. #
  17. # DirectoryIndex index.cgi index.html /cgi-bin/apache24_ls.cgi
  18. #
  19. # [end of httpd.conf lines]
  20. #
  21. # This code has at least six limitations. (Thanks, Monty Python!)
  22. #
  23. # 1. It has been tested only with an apache configuration that's wide open. A
  24. # more security-conscious configuration may break this script.
  25. # 2. It has not been designed with security configurations in mind. You may
  26. # wish to improve it to make it more secure.
  27. # 3. Even laying aside security considerations, it was written with common
  28. # configuration assumptions in mind. I don't even know exactly what those
  29. # assumptions are, and you won't either until you actually run this script
  30. # in an environment where those assumptions don't hold.
  31. # 4. It doesn't take into account strange characters like percent sign and
  32. # space.
  33. # 5. You may wish to narrow the display by removing some of the displayed
  34. # information.
  35. # 6. It logs debugging info to /tmp/billylog. You may wish to make use of
  36. # this while debugging your own modifications, and/or remove this feature
  37. # entirely by searching for "billylog" in the script.
  38. # 7. I'm sure it has bugs.
  39. #
  40. # Bill Evans
  41. # wje@acm.org
  42.  
  43. use strict;
  44. use warnings FATAL=>"all";
  45.  
  46. #-----------------------------------------------------------------------------
  47.  
  48. sub billylog
  49. {
  50. my $out_string=shift;
  51.  
  52. my $phyle;
  53.  
  54. open($phyle,">>","/tmp/billylog");
  55.  
  56. print($phyle sprintf("%05d",$$)."$out_string\n");
  57.  
  58. close($phyle);
  59.  
  60. } # billylog()
  61.  
  62. #-----------------------------------------------------------------------------
  63.  
  64. sub spit
  65. {
  66. my $spittle=shift;
  67.  
  68. print $spittle;
  69.  
  70. $spittle=~s/\r?\n?$//;
  71.  
  72. billylog("\"$spittle\"")
  73. }
  74.  
  75. #-----------------------------------------------------------------------------
  76.  
  77. sub fix_spaces
  78. {
  79. my $in_string=shift;
  80.  
  81. $in_string=~s/ /\&nbsp\;/g;
  82.  
  83. return $in_string;
  84.  
  85. } # fix_spaces()
  86.  
  87. #-----------------------------------------------------------------------------
  88.  
  89. sub etc_passwd
  90. {
  91. my $identity=shift;
  92. my $flags =shift;
  93.  
  94. my $in_line;
  95. my $phyle;
  96.  
  97. my @array;
  98.  
  99. open($phyle,"<","/etc/passwd")
  100. or
  101. return "<FONT COLOR=gray>inaccessible</FONT>";
  102.  
  103. while($in_line=<$phyle>)
  104. {
  105. $in_line=~s/\r?\n?$//;
  106.  
  107. if($in_line=~/^\#/)
  108. {
  109. next; # <---------
  110. }
  111.  
  112. @array=split(/:/,$in_line);
  113.  
  114. if(0+$array[2] == $identity)
  115. {
  116. close($phyle);
  117.  
  118. return sanitize($array[0]);
  119. }
  120. }
  121.  
  122. close($phyle);
  123.  
  124. if(defined($flags))
  125. {
  126. return "<FONT COLOR=gray>no such user name</FONT>";
  127. }
  128. else
  129. {
  130. return sanitize($identity);
  131. }
  132.  
  133. } # etc_passwd()
  134.  
  135. #-----------------------------------------------------------------------------
  136.  
  137. sub etc_group
  138. {
  139. my $identity=shift;
  140. my $flags =shift;
  141.  
  142. my $in_line;
  143. my $phyle;
  144.  
  145. my @array;
  146.  
  147. open($phyle,"<","/etc/group")
  148. or
  149. return "<FONT COLOR=gray>inaccessible</FONT>";
  150.  
  151. while($in_line=<$phyle>)
  152. {
  153. $in_line=~s/\r?\n?$//;
  154.  
  155. if($in_line=~/^\#/)
  156. {
  157. next; # <---------
  158. }
  159.  
  160. @array=split(/:/,$in_line);
  161.  
  162. if(0+$array[2] == $identity)
  163. {
  164. close($phyle);
  165.  
  166. return sanitize($array[0]);
  167. }
  168. }
  169.  
  170. close($phyle);
  171.  
  172. if(defined($flags))
  173. {
  174. return "<FONT COLOR=gray>no such group name</FONT>";
  175. }
  176. else
  177. {
  178. return sanitize($identity);
  179. }
  180.  
  181. } # etc_group()
  182.  
  183. #-----------------------------------------------------------------------------
  184.  
  185. sub printable_time
  186. {
  187. my $the_time=shift;
  188.  
  189. my $sec;
  190. my $min;
  191. my $hour,
  192. my $mday,
  193. my $mon,
  194. my $year;
  195.  
  196. my @mlist=("Jan",
  197. "Feb",
  198. "Mar",
  199. "Apr",
  200. "May",
  201. "Jun",
  202. "Jul",
  203. "Aug",
  204. "Sep",
  205. "Oct",
  206. "Nov",
  207. "Dec"
  208. );
  209.  
  210. ($sec,
  211. $min,
  212. $hour,
  213. $mday,
  214. $mon,
  215. $year
  216. )=localtime($the_time);
  217.  
  218. return sprintf("%04d&nbsp;%s&nbsp;%2d&nbsp;%02d:%02d:%02d",
  219. $year+1900,
  220. $mlist[$mon],
  221. $mday,
  222. $hour,
  223. $min,
  224. $sec
  225. );
  226.  
  227. } # printable_time()
  228.  
  229. #-----------------------------------------------------------------------------
  230.  
  231. sub sanitize
  232. {
  233. my $in_string=shift;
  234.  
  235. if(!defined($in_string))
  236. {
  237. $in_string="<FONT COLOR=gray>undefined</FONT>";
  238. }
  239. else
  240. {
  241. $in_string=~s/\&/\&amp\;/g;
  242. $in_string=~s/\</\&lt\;/g;
  243. $in_string=~s/\>/\&gt\;/g;
  244.  
  245. if($in_string eq "")
  246. {
  247. return "&nbsp;";
  248. }
  249. }
  250.  
  251. return $in_string;
  252.  
  253. } # sanitize()
  254.  
  255. #-----------------------------------------------------------------------------
  256.  
  257. sub handler
  258. {
  259. my $home_directory;
  260. my $in_line;
  261. my $param_1dot;
  262. my $param_2dots;
  263. my $param_dir_1;
  264. my $param_dir_2;
  265. my $param_file_1;
  266. my $param_file_2;
  267. my $param_mode_switching;
  268. my $passwd_phyle;
  269. my $physical_filename;
  270. my $single_key;
  271. my $single_value;
  272. my $target_filename;
  273. my $test_mode;
  274. my $user_name;
  275.  
  276. my @arg_array;
  277. my @passwd_fields;
  278.  
  279. my %arg_hash;
  280.  
  281. billylog("=== \"".$ENV{"REQUEST_URI"}."\"");
  282.  
  283. $target_filename=$ENV{"REQUEST_URI"};
  284. $target_filename=~s/^(.*?)\?.*$/$1/;
  285. $target_filename=~s/\/+$//;
  286. $physical_filename=$target_filename;
  287.  
  288. if($physical_filename=~/^\/\~/)
  289. {
  290. $user_name=$physical_filename;
  291. $user_name=~s/^\/\~(.*?)\/.*$/$1/
  292. or
  293. $user_name=~s/^\/\~([^\/]*)$/$1/;
  294.  
  295. if(open($passwd_phyle,"<","/etc/passwd"))
  296. {
  297. while($in_line=<$passwd_phyle>)
  298. {
  299. $in_line=~s/\r?\n?$//;
  300.  
  301. if($in_line=~/^\#/)
  302. {
  303. next; # <---------
  304. }
  305.  
  306. @passwd_fields=split(/\:/,$in_line);
  307.  
  308. if(scalar(@passwd_fields)!=7)
  309. {
  310. next; # <---------
  311. }
  312.  
  313. if($passwd_fields[0] eq $user_name)
  314. {
  315. last; # <---------
  316. }
  317. }
  318.  
  319. close($passwd_phyle);
  320. }
  321.  
  322. if(defined($in_line))
  323. {
  324. $physical_filename=~s/^\/\~(.*?)\//$passwd_fields[5]\/public_html\//;
  325. $physical_filename=~s/^\/\~(.*?)$/$passwd_fields[5]\/public_html/;
  326. }
  327. }
  328.  
  329. if($ENV{"QUERY_STRING"})
  330. {
  331. @arg_array=split(/\&/,$ENV{'QUERY_STRING'});
  332. }
  333.  
  334. while(scalar(@arg_array))
  335. {
  336. $single_key =$arg_array[0];
  337. $single_value=$arg_array[0];
  338.  
  339. if($single_key=~/\=/)
  340. {
  341. $single_key =~s/^(.*?)\=(.*)$/$1/;
  342. $single_value=~s/^(.*?)\=(.*)$/$2/;
  343. }
  344. else
  345. {
  346. $single_value="";
  347. }
  348.  
  349. $arg_hash{$single_key}=$single_value;
  350.  
  351. shift(@arg_array);
  352. }
  353.  
  354. if(defined($arg_hash{"test"}))
  355. {
  356. $test_mode=1;
  357. }
  358. else
  359. {
  360. $test_mode=0;
  361. }
  362.  
  363. if($test_mode) { ###########################################################
  364.  
  365. spit("Content-Type: text/html\n");
  366. spit("\n");
  367. spit("<HTML><BODY>\n");
  368.  
  369. spit("<table border bgcolor=#FFFFC0>\r\n");
  370.  
  371. spit("<thead><td><tt>variable name</tt></td><td><tt>value</tt></td></thead>\r\n");
  372.  
  373. foreach $single_key (sort keys %ENV)
  374. {
  375. spit("<tr><td><tt>$single_key</tt></td><td><tt>\"".sanitize($ENV{$single_key})."\"</tt></td></tr>\r\n");
  376. }
  377.  
  378. spit("</table>\r\n");
  379.  
  380. spit("</BODY></HTML>\n");
  381.  
  382. return 0;
  383.  
  384. } # if(test_mode) ##########################################################
  385.  
  386. # The f parameter informs us, when we're generating a directory, whether the
  387. # directory will end up in a single frame; the lefthand frame; the righthand
  388. # frame; the righthand frame of a framework which we should provide, and put
  389. # the directory's parent in the lefthand frame; or the lefthand frame of a
  390. # frameset which we should provide, and put the specified document in the
  391. # righthand frame.
  392. #
  393. # Parameters are handled as follows.
  394. #
  395. # -- If there are no parameters:
  396. #
  397. # -- If the directory contains index.cgi or index.html, pump it out.
  398. # -- Otherwise, divide the document into two frames.
  399. #
  400. # -- The first frame should point to ..,f=l; NAME=l.
  401. # -- The second frame should point to .,f=r ; NAME=r.
  402. #
  403. # -- f=d&d=something (d stands for document)
  404. #
  405. # -- Divide the document into two frames.
  406. # -- The first frame should point to .,f=l; NAME=l.
  407. # -- The second frame should point to something; NAME=r.
  408. #
  409. # -- f=s (s stands for single)
  410. #
  411. # -- Display the directory in its current frame.
  412. #
  413. # -- The mode switching link should go to plain ".".
  414. # -- For .. and . and all other directories, the link should
  415. # include f=s.
  416. # -- For all other files, the link should be plain.
  417. #
  418. # -- f=l (l stands for lefthand)
  419. #
  420. # -- Display the directory in its current frame.
  421. #
  422. # -- The mode switching link should go to .?f=s; TARGET=_top.
  423. # -- For .. and . the links should be plain, TARGET=_top.
  424. # -- For other directories, the links should be f=r; TARGET=r.
  425. # -- For other files, the links should specify TARGET=r.
  426. #
  427. # -- f=r (r stands for righthand)
  428. #
  429. # -- Display the directory in its current frame.
  430. #
  431. # -- The mode switching link should go to .?f=s; TARGET=_top.
  432. # -- For .. the link should be plain, TARGET=_top
  433. # -- For . the link should go to .,f=r.
  434. # -- For other directories, the links should be plain, TARGET=_top.
  435. # -- For other files, the links should be .,f=d,d=destination,
  436. # TARGET=_top.
  437.  
  438. # Correct for any missing destination, just for bulletproofing.
  439.  
  440. if((defined($arg_hash{"f"})) &&
  441. ($arg_hash{"f"} eq "d")
  442. )
  443. {
  444. if((!defined($arg_hash{"d"})) ||
  445. ($arg_hash{"d"} eq "")
  446. )
  447. {
  448. delete($arg_hash{"d"});
  449. delete($arg_hash{"f"});
  450. }
  451. }
  452.  
  453. if((!defined($arg_hash{"f"})) ||
  454. ($arg_hash{"f"} eq "")
  455. )
  456. {
  457. spit("Content-Type: text/html\n");
  458. spit("\n");
  459.  
  460. spit("<HTML><FRAMESET COLS=\"50%,50%\">\n");
  461.  
  462. spit("<FRAME SRC=\"$target_filename/../?f=l\" NAME=l>\n");
  463. spit("<FRAME SRC=\"$target_filename/?f=r\" NAME=r>\n");
  464.  
  465. spit("</FRAMESET></HTML>\n");
  466.  
  467. return 0;
  468.  
  469. } # if there's no f parameter
  470. elsif($arg_hash{"f"} eq "d")
  471. {
  472. billylog("f is d");
  473.  
  474. spit("Content-Type: text/html");
  475. spit("\n");
  476.  
  477. spit("<HTML><FRAMESET COLS=\"50%,50%\">\n");
  478.  
  479. spit("<FRAME SRC=\"./?f=l\" NAME=l>\n");
  480. spit("<FRAME SRC=\"".$arg_hash{"d"}."/\" NAME=r>\n");
  481.  
  482. spit("</FRAMESET></HTML>\n");
  483.  
  484. return 0;
  485. }
  486. elsif($arg_hash{"f"} eq "s")
  487. {
  488. billylog("f is s");
  489. $param_mode_switching="<A HREF=\".\">";
  490. $param_2dots="<A HREF=\"$target_filename/..?f=s\">";
  491. $param_1dot="<A HREF=\"$target_filename?f=s\">";
  492. $param_dir_1="<A HREF=\"";
  493. $param_dir_2="?f=s\">";
  494. $param_file_1="<A HREF=\"";
  495. $param_file_2="\">";
  496. }
  497. elsif($arg_hash{"f"} eq "l")
  498. {
  499. billylog("f is l");
  500. $param_mode_switching="<A HREF=\".?f=s\" TARGET=_top>";
  501. $param_2dots="<A HREF=\"$target_filename/..\" TARGET=_top>";
  502. $param_1dot="<A HREF=\"$target_filename\" TARGET=_top>";
  503. $param_dir_1="<A HREF=\"";
  504. $param_dir_2="?f=r\" TARGET=r>";
  505. $param_file_1="<A HREF=\"";
  506. $param_file_2="\" TARGET=r>";
  507. }
  508. elsif($arg_hash{"f"} eq "r")
  509. {
  510. billylog("f is r");
  511. $param_mode_switching="<A HREF=\".?f=s\" TARGET=_top>";
  512. $param_2dots="<A HREF=\"$target_filename/..\" TARGET=_top>";
  513. $param_1dot="<A HREF=\"$target_filename?f=r\">";
  514. $param_dir_1="<A HREF=\"";
  515. $param_dir_2="\" TARGET=_top>";
  516. $param_file_1="<A HREF=\".?f=d&d=";
  517. $param_file_2="\" TARGET=_top>";
  518. }
  519. else
  520. {
  521. billylog("oops");
  522. spit("Content-Type: text/plain\n");
  523. spit("Status: 500 Internal Server Error\n");
  524. spit("\n");
  525.  
  526. return 0;
  527. }
  528.  
  529. {
  530. # Actually list the directory.
  531.  
  532. my $buffer;
  533. my $dear;
  534. my $entry;
  535. my $jndex;
  536. my $max_group_width;
  537. my $max_nlink_width;
  538. my $max_size_width;
  539. my $max_user_width;
  540. my $st_dev;
  541. my $st_ino;
  542. my $st_mode;
  543. my $st_nlink;
  544. my $st_uid;
  545. my $st_gid;
  546. my $st_rdev;
  547. my $st_size;
  548. my $st_atime;
  549. my $st_mtime;
  550. my $st_ctime;
  551. my $st_blksize;
  552. my $st_blocks;
  553.  
  554. my %filenames;
  555.  
  556. if(!opendir($dear,$physical_filename))
  557. {
  558. my $status=$!;
  559.  
  560. if($status==13)
  561. {
  562. spit("Content-Type: text/plain\n");
  563. spit("Status: 403 Forbidden\n");
  564. spit("\n");
  565. spit("403 Forbidden $target_filename\n");
  566.  
  567. return 0;
  568. }
  569. else
  570. {
  571. spit("Content-Type: text/plain\n");
  572. spit("Status: 404 Not Found\n");
  573. spit("\n");
  574. spit("404 Not Found $target_filename\n");
  575.  
  576. return 0;
  577. }
  578. }
  579.  
  580. spit("Content-Type: text/html\n");
  581. spit("\n");
  582.  
  583. spit("<HTML><BODY>\n");
  584.  
  585. spit
  586. ("<TT>".$param_mode_switching."Click here to switch modes.</A>\n");
  587.  
  588. spit("<P>ls -l <FONT COLOR=gray>--kinda</FONT> $target_filename<BR>");
  589.  
  590. while($entry=readdir($dear))
  591. {
  592. if($entry=~/^\./)
  593. {
  594. next;
  595. }
  596.  
  597. $filenames{$entry}="X";
  598. }
  599.  
  600. closedir($dear);
  601.  
  602. # Get widths of columns. Grr.
  603.  
  604. $max_nlink_width=1;
  605. $max_size_width =1;
  606. $max_user_width =0;
  607. $max_group_width=0;
  608.  
  609. foreach $entry (sort(keys(%filenames)))
  610. {
  611. ($st_dev,
  612. $st_ino,
  613. $st_mode,
  614. $st_nlink,
  615. $st_uid,
  616. $st_gid,
  617. $st_rdev,
  618. $st_size,
  619. $st_atime,
  620. $st_mtime,
  621. $st_ctime,
  622. $st_blksize,
  623. $st_blocks
  624. )=stat("$physical_filename/$entry");
  625.  
  626. if($max_nlink_width<length($st_nlink))
  627. {
  628. $max_nlink_width=length($st_nlink);
  629. }
  630.  
  631. if($max_size_width<length($st_size))
  632. {
  633. $max_size_width=length($st_size);
  634. }
  635.  
  636. if($max_user_width<length(etc_passwd($st_uid)))
  637. {
  638. $max_user_width=length(etc_passwd($st_uid));
  639. }
  640.  
  641. if($max_group_width<length(etc_group($st_gid)))
  642. {
  643. $max_group_width=length(etc_group($st_gid));
  644. }
  645. }
  646.  
  647. foreach $entry ("..",".",sort(keys(%filenames)))
  648. {
  649. spit("<BR><NOBR>");
  650.  
  651. if((!-r "$physical_filename/$entry") &&
  652. ($entry!~/^\./)
  653. )
  654. {
  655. spit("<FONT COLOR=gray>");
  656. }
  657. elsif($entry!~/^\./)
  658. {
  659. if(-d "$physical_filename/$entry")
  660. {
  661. spit($param_dir_1);
  662. }
  663. else
  664. {
  665. spit($param_file_1);
  666. }
  667.  
  668. for($jndex=0;
  669. $jndex<length($entry);
  670. $jndex++
  671. )
  672. {
  673. $buffer=substr($entry,$jndex,1);
  674.  
  675. if($buffer!~/[!&()+-;=\?-\[\]-_a-z~]/)
  676. {
  677. $buffer="%".unpack("H**",$buffer);
  678. $buffer=~tr/a-z/A-Z/;
  679. }
  680.  
  681. spit($buffer);
  682. }
  683.  
  684. if(-d "$physical_filename/$entry")
  685. {
  686. spit($param_dir_2);
  687. }
  688. else
  689. {
  690. spit($param_file_2);
  691. }
  692. }
  693.  
  694. if($entry=~/^\./) { spit("&nbsp;"); }
  695. elsif(-f "$physical_filename/$entry") { spit("-"); }
  696. elsif(-b "$physical_filename/$entry") { spit("b"); }
  697. elsif(-c "$physical_filename/$entry") { spit("c"); }
  698. elsif(-d "$physical_filename/$entry") { spit("d"); }
  699. elsif(-l "$physical_filename/$entry") { spit("l"); }
  700. elsif(-p "$physical_filename/$entry") { spit("p"); }
  701. elsif(-S "$physical_filename/$entry") { spit("s"); }
  702. else { spit("?"); }
  703.  
  704. if($entry!~/^\./)
  705. {
  706. ($st_dev,
  707. $st_ino,
  708. $st_mode,
  709. $st_nlink,
  710. $st_uid,
  711. $st_gid,
  712. $st_rdev,
  713. $st_size,
  714. $st_atime,
  715. $st_mtime,
  716. $st_ctime,
  717. $st_blksize,
  718. $st_blocks
  719. )=stat("$physical_filename/$entry");
  720. }
  721.  
  722. if($entry=~/^\./)
  723. {
  724. spit("&nbsp;");
  725. }
  726. else
  727. {
  728. if($st_mode & 0400)
  729. {
  730. spit("r");
  731. }
  732. else
  733. {
  734. spit("-");
  735. }
  736. }
  737.  
  738. if($entry=~/^\./)
  739. {
  740. spit("&nbsp;");
  741. }
  742. else
  743. {
  744. if($st_mode & 0200)
  745. {
  746. spit("w");
  747. }
  748. else
  749. {
  750. spit("-");
  751. }
  752. }
  753.  
  754. if($entry=~/^\./)
  755. {
  756. spit("&nbsp;");
  757. }
  758. else
  759. {
  760. if($st_mode & 04000)
  761. {
  762. if($st_mode & 0100)
  763. {
  764. spit("s");
  765. }
  766. else
  767. {
  768. spit("S");
  769. }
  770. }
  771. else
  772. {
  773. if($st_mode & 0100)
  774. {
  775. spit("x");
  776. }
  777. else
  778. {
  779. spit("-");
  780. }
  781. }
  782. }
  783.  
  784. if($entry=~/^\./)
  785. {
  786. spit("&nbsp;");
  787. }
  788. else
  789. {
  790. if($st_mode & 0040)
  791. {
  792. spit("r");
  793. }
  794. else
  795. {
  796. spit("-");
  797. }
  798. }
  799.  
  800. if($entry=~/^\./)
  801. {
  802. spit("&nbsp;");
  803. }
  804. else
  805. {
  806. if($st_mode & 0020)
  807. {
  808. spit("w");
  809. }
  810. else
  811. {
  812. spit("-");
  813. }
  814. }
  815.  
  816. if($entry=~/^\./)
  817. {
  818. spit("&nbsp;");
  819. }
  820. else
  821. {
  822. if($st_mode & 02000)
  823. {
  824. if($st_mode & 0010)
  825. {
  826. spit("s");
  827. }
  828. else
  829. {
  830. spit("S");
  831. }
  832. }
  833. else
  834. {
  835. if($st_mode & 0010)
  836. {
  837. spit("x");
  838. }
  839. else
  840. {
  841. spit("-");
  842. }
  843. }
  844. }
  845.  
  846. if($entry=~/^\./)
  847. {
  848. spit("&nbsp;");
  849. }
  850. else
  851. {
  852. if($st_mode & 0004)
  853. {
  854. spit("r");
  855. }
  856. else
  857. {
  858. spit("-");
  859. }
  860. }
  861.  
  862. if($entry=~/^\./)
  863. {
  864. spit("&nbsp;");
  865. }
  866. else
  867. {
  868. if($st_mode & 0002)
  869. {
  870. spit("w");
  871. }
  872. else
  873. {
  874. spit("-");
  875. }
  876. }
  877.  
  878. if($entry=~/^\./)
  879. {
  880. spit("&nbsp;");
  881. }
  882. else
  883. {
  884. if($st_mode & 01000)
  885. {
  886. if($st_mode & 0001)
  887. {
  888. spit("s");
  889. }
  890. else
  891. {
  892. spit("S");
  893. }
  894. }
  895. else
  896. {
  897. if($st_mode & 0001)
  898. {
  899. spit("x");
  900. }
  901. else
  902. {
  903. spit("-");
  904. }
  905. }
  906. }
  907.  
  908. spit("&nbsp;");
  909.  
  910. if($entry=~/^\./)
  911. {
  912. spit("&nbsp;" x $max_nlink_width);
  913. }
  914. else
  915. {
  916. spit(fix_spaces(sprintf("%".$max_nlink_width."d",$st_nlink)));
  917. }
  918.  
  919. spit("&nbsp;");
  920.  
  921. if($entry=~/^\./)
  922. {
  923. spit("&nbsp;" x $max_user_width);
  924. }
  925. else
  926. {
  927. spit(sprintf(("%-".$max_user_width."s"),etc_passwd($st_uid)));
  928. }
  929.  
  930. spit("&nbsp;");
  931.  
  932. if($entry=~/^\./)
  933. {
  934. spit("&nbsp;" x $max_group_width);
  935. }
  936. else
  937. {
  938. spit(sprintf(("%-".$max_group_width."s"),etc_group($st_gid)));
  939. }
  940.  
  941. spit("&nbsp;");
  942.  
  943. if($entry=~/^\./)
  944. {
  945. spit("&nbsp;" x $max_size_width);
  946. }
  947. else
  948. {
  949. spit(fix_spaces(sprintf("%".$max_size_width."d",$st_size)));
  950. }
  951.  
  952. spit("&nbsp;");
  953.  
  954. if($entry=~/^\./)
  955. {
  956. spit("&nbsp;" x 20);
  957. }
  958. else
  959. {
  960. spit(printable_time($st_mtime));
  961. }
  962.  
  963. spit("&nbsp;");
  964.  
  965. if($entry eq "..")
  966. {
  967. spit($param_2dots);
  968. }
  969.  
  970. if($entry eq ".")
  971. {
  972. spit($param_1dot);
  973. }
  974.  
  975. spit(sanitize($entry));
  976.  
  977. if((!-r "$physical_filename/$entry") &&
  978. ($entry!~/^\./)
  979. )
  980. {
  981. spit("</FONT>");
  982. }
  983. else
  984. {
  985. spit("</A>");
  986. }
  987.  
  988. spit("</NOBR>\n");
  989. }
  990.  
  991. spit("</TT>");
  992.  
  993. spit("</BODY></HTML>\n");
  994. }
  995.  
  996. return 0;
  997.  
  998. } # handler()
  999.  
  1000. handler();
  1001.  
  1002. #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement