Advertisement
BillEvansAtMariposa

20160613-01

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