foobar.cgi 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. my @files = split("\n", `find .`);
  5. my $last_mod = 0;
  6. my $f_mod = 0;
  7. foreach my $file ( @files ) {
  8. my $mod_time = `stat $file | grep Modify | awk '{print \$2" "\$3}'`;
  9. chomp $mod_time;
  10. my $c = $mod_time;
  11. $c =~ tr/-\://d;
  12. $c =~ tr/ //d;
  13. if ( $c > $last_mod ) {
  14. $last_mod = $c;
  15. $f_mod = $mod_time;
  16. }
  17. }
  18. sub colorize($) {
  19. my $string = shift;
  20. # For "colorizing" the page
  21. my @fade_in_c_arr = (
  22. 142,143,144,145,146,233,240,244,250,
  23. );
  24. my $fade_len = @fade_in_c_arr;
  25. my @input_char_arr = split("", $string);
  26. my @colored_char_ar;
  27. foreach my $char ( @input_char_arr ) {
  28. if ( $char eq "\n" || $char eq " " || $char eq '\\' || $char eq '/' ) {
  29. push(@colored_char_ar,$char);
  30. next;
  31. }
  32. my $c = $fade_in_c_arr[rand @fade_in_c_arr];
  33. push(@colored_char_ar, "\x1B[38;5;$c" . "m" . "$char" . "\x1B[0m");
  34. }
  35. my $c_string = join("",@colored_char_ar);
  36. return $c_string;
  37. }
  38. sub printer($$$) {
  39. my $string = shift;
  40. my $type = shift;
  41. my $rest = shift;
  42. if ( defined $ENV{'QUERY_STRING'} && $ENV{'QUERY_STRING'} eq "plain" ) {
  43. print("$type$string$rest\n");
  44. } else {
  45. my $c_string = colorize($string);
  46. print("$type$c_string$rest\n");
  47. }
  48. }
  49. my $HOME_PATH = "/";
  50. if ( defined $ENV{'QUERY_STRING'} && $ENV{'QUERY_STRING'} eq "plain" ) {
  51. $HOME_PATH = "/foobar.cgi?plain";
  52. }
  53. # GOPHERMAP GEN HERE
  54. if ( defined $ENV{'QUERY_STRING'} && $ENV{'QUERY_STRING'} eq "plain" ) {
  55. print("i CHATE.IO\n");
  56. } else {
  57. print("i ▄████▄ ██░ ██ ▄▄▄ ▄▄▄█████▓▓█████ ██▓ ▒█████\n");
  58. print("i▒██▀ ▀█ ▓██░ ██▒▒████▄ ▓ ██▒ ▓▒▓█ ▀ ▓██▒▒██▒ ██▒\n");
  59. print("i▒▓█ ▄ ▒██▀▀██░▒██ ▀█▄ ▒ ▓██░ ▒░▒███ ▒██▒▒██░ ██▒\n");
  60. print("i▒▓▓▄ ▄██▒░▓█ ░██ ░██▄▄▄▄██░ ▓██▓ ░ ▒▓█ ▄ ░██░▒██ ██░\n");
  61. print("i▒ ▓███▀ ░░▓█▒░██▓ ▓█ ▓██▒ ▒██▒ ░ ░▒████▒ ██▓ ░██░░ ████▓▒░\n");
  62. print("i░ ░▒ ▒ ░ ▒ ░░▒░▒ ▒▒ ▓▒█░ ▒ ░░ ░░ ▒░ ░ ▒▓▒ ░▓ ░ ▒░▒░▒░\n");
  63. print("i ░ ▒ ▒ ░▒░ ░ ▒ ▒▒ ░ ░ ░ ░ ░ ░▒ ▒ ░ ░ ▒ ▒░\n");
  64. print("i░ ░ ░░ ░ ░ ▒ ░ ░ ░ ▒ ░░ ░ ░ ▒\n");
  65. print("i░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░\n");
  66. print("i░ ░\n");
  67. print("i\n");
  68. }
  69. printer(" _.-^ Thanks for visiting The Chateau ^-._","i","");
  70. print("i\n");
  71. printer(" Last Modification: $f_mod UTC","i","");
  72. print("i\n");
  73. printer("About Me","0","\tblogs/about-me.org.txt\tchate.io\t70");
  74. printer("Ramblings and Phlog","1","\tblogs\tchate.io\t70");
  75. print("i --> All posts are .org mode formatted,\n");
  76. print("i so elpher users can use M-x org-mode\n");
  77. print("i for nicer formatting\n");
  78. print("i\n");
  79. printer("Warez","1","\t$HOME_PATH\tchate.io\t70");
  80. print("i --> http://ntfy.sh\n");
  81. print("i - Awesome and very easy to use PUT/POST\n");
  82. print("i based notification system\n");
  83. print("i\n");
  84. printer("Cool Places","i","");
  85. printer(" --> baud.baby","1","\t/\tbaud.baby");
  86. printer(" --> hngopher.com (HN Gopher Proxy)","1","\t/\thngopher.com");
  87. printer(" --> Linkerror","1","\t/\tgopher.linkerror.com");
  88. printer(" --> gopher.black","1","\t/\tgopher.black");
  89. printer(" --> tilde.club","1","\t/\ttilde.club");
  90. printer(" --> RPoD (1436.ninja)","1","\t/\t1436.ninja");
  91. printer(" --> gopherpedia (Wikipedia Gopher Proxy)","1","\t/\tgopherpedia.com");
  92. printer(" --> thelambdalab.xyz","1","\t/\tthelambdalab.xyz");
  93. print("i\n");
  94. printer("WhackyCGI","i","");
  95. print("i\n");
  96. printer("Script that generates this page","0","\t/foobar.txt\tchate.io\t70\n");
  97. print("i\n");
  98. print("1Plain\t/foobar.cgi?plain\tchate.io\t70\n");
  99. print("1Colorized\t/foobar.cgi\tchate.io\t70\n");
  100. print("iIf the site looks weird, use the Plain entry above\n");
  101. print("iThis gopher site expects a client that either supports or\n");
  102. print("ifilters ANSI escape sequences. I recommend:\n");
  103. print("i--> cgo\n");
  104. print("i--> phetch\n");
  105. print("i--> curl (use gopher://)\n");
  106. print("i--> Elpher (filters ANSI)\n");