foobar.cgi 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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\tchate.io\t70\n");
  56. } else {
  57. print("i ▄████▄ ██░ ██ ▄▄▄ ▄▄▄█████▓▓█████ ██▓ ▒█████\tchate.io\t70\n");
  58. print("i▒██▀ ▀█ ▓██░ ██▒▒████▄ ▓ ██▒ ▓▒▓█ ▀ ▓██▒▒██▒ ██▒\tchate.io\t70\n");
  59. print("i▒▓█ ▄ ▒██▀▀██░▒██ ▀█▄ ▒ ▓██░ ▒░▒███ ▒██▒▒██░ ██▒\tchate.io\t70\n");
  60. print("i▒▓▓▄ ▄██▒░▓█ ░██ ░██▄▄▄▄██░ ▓██▓ ░ ▒▓█ ▄ ░██░▒██ ██░\tchate.io\t70\n");
  61. print("i▒ ▓███▀ ░░▓█▒░██▓ ▓█ ▓██▒ ▒██▒ ░ ░▒████▒ ██▓ ░██░░ ████▓▒░\tchate.io\t70\n");
  62. print("i░ ░▒ ▒ ░ ▒ ░░▒░▒ ▒▒ ▓▒█░ ▒ ░░ ░░ ▒░ ░ ▒▓▒ ░▓ ░ ▒░▒░▒░\tchate.io\t70\n");
  63. print("i ░ ▒ ▒ ░▒░ ░ ▒ ▒▒ ░ ░ ░ ░ ░ ░▒ ▒ ░ ░ ▒ ▒░\tchate.io\t70\n");
  64. print("i░ ░ ░░ ░ ░ ▒ ░ ░ ░ ▒ ░░ ░ ░ ▒\tchate.io\t70\n");
  65. print("i░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░\tchate.io\t70\n");
  66. print("i░ ░\tchate.io\t70\n");
  67. print("i\tchate.io\t70\n");
  68. }
  69. printer(" _.-^ Thanks for visiting The Chateau ^-._","i","\tchate.io\t70");
  70. print("i\tchate.io\t70\n");
  71. printer(" Last Modification: $f_mod UTC","i","\tchate.io\t70");
  72. my $uniq_ips = `cat ./existing_ips | wc -l`;
  73. chomp $uniq_ips;
  74. printer(" Uniq Visitors since Jan 2022 : $uniq_ips","i","\tchate.io\t70");
  75. print("i\tchate.io\t70\n");
  76. printer("About Me","0","\tblogs/about-me.org.txt\tchate.io\t70");
  77. printer("Ramblings and Phlog","1","\t/blogs/blogs.cgi\tchate.io\t70");
  78. print("i --> All posts are .org mode formatted,\tchate.io\t70\n");
  79. print("i so elpher users can use M-x org-mode\tchate.io\t70\n");
  80. print("i for nicer formatting\tchate.io\t70\n");
  81. print("i\tchate.io\t70\n");
  82. printer("Warez","1","\t$HOME_PATH\tchate.io\t70");
  83. print("i --> http://ntfy.sh\tchate.io\t70\n");
  84. print("i - Awesome and very easy to use PUT/POST\tchate.io\t70\n");
  85. print("i based notification system\tchate.io\t70\n");
  86. print("i\tchate.io\t70\n");
  87. printer("Cool Places","i","\tchate.io\t70");
  88. printer(" --> baud.baby","1","\t/\tbaud.baby\t70");
  89. printer(" --> hngopher.com (HN Gopher Proxy)","1","\t/\thngopher.com\t70");
  90. printer(" --> Linkerror","1","\t/\tgopher.linkerror.com\t70");
  91. printer(" --> gopher.black","1","\t/\tgopher.black\t70");
  92. printer(" --> tilde.club","1","\t/\ttilde.club\t70");
  93. printer(" --> RPoD (1436.ninja)","1","\t/\t1436.ninja\t70");
  94. printer(" --> gopherpedia (Wikipedia Gopher Proxy)","1","\t/\tgopherpedia.com\t70");
  95. printer(" --> thelambdalab.xyz","1","\t/\tthelambdalab.xyz\t70");
  96. print("i\tchate.io\t70\n");
  97. printer("Git Proxy","1","\t/git/go_git.cgi\tchate.io\t70");
  98. print("i --> This takes you to a CGI script that will proxy\tchate.io\t70\n");
  99. print("i HTTP requests to my git server, so that you can\tchate.io\t70\n");
  100. print("i browse my git repos\tchate.io\t70\n");
  101. print("i --> Note: Some clients won't render certain file exts,\tchate.io\t70\n");
  102. print("i which may cause some repos to appear empty.\tchate.io\t70\n");
  103. print("i\tchate.io\t70\n");
  104. printer("Mastodon Proxy","0","\t/masto/go_mast.cgi\tchate.io\t70");
  105. print("i --> Proxy of what I'm posting on Mastodon\tchate.io\t70\n");
  106. print("i\tchate.io\t70\n");
  107. printer("Script that generates this page","0","\t/foobar.txt\tchate.io\t70");
  108. print("i\tchate.io\t70\n");
  109. print("1Plain\t/foobar.cgi?plain\tchate.io\t70\tchate.io\t70\n");
  110. print("1Colorized\t/\tchate.io\t70\tchate.io\t70\n");
  111. print("iIf the site looks weird, use the Plain entry above\tchate.io\t70\n");
  112. print("i --> Sometimes info lines are filtered in some clients\tchate.io\t70\n");
  113. print("i when using the ?plain query, I'm not sure why yet\tchate.io\t70\n");
  114. print("i\tchate.io\t70\n");
  115. print("iThis gopher site expects a client that either supports or\tchate.io\t70\n");
  116. print("ifilters ANSI escape sequences. I recommend:\tchate.io\t70\n");
  117. print("i--> cgo\tchate.io\t70\n");
  118. print("i--> phetch\tchate.io\t70\n");
  119. print("i--> lagrange\tchate.io\t70\n");
  120. print("i--> castor\tchate.io\t70\n");
  121. print("i--> curl (use gopher://)\tchate.io\t70\n");
  122. print("i--> Elpher (filters ANSI)\tchate.io\t70\n");