index.pl 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env perl
  2. # CGI script for checking if a page is up.
  3. print "Content-Type: text/html\n\n";
  4. print "<!DOCTYPE html>";
  5. print "<html>";
  6. print "<head>";
  7. print "<title>";
  8. $URL="";
  9. if($ENV{QUERY_STRING} eq "") {
  10. print "Down For Everyone Or Just Me? - Thanks Microsoft";
  11. }
  12. else {
  13. $PARSINGCOMPLETE=false;
  14. @charlist=split(//, $ENV{QUERY_STRING});
  15. foreach $char (@charlist) {
  16. if($PARSINGCOMPLETE eq "true") {
  17. $URL .= $char;
  18. }
  19. if ($char eq "=") {
  20. $PARSINGCOMPLETE=true;
  21. }
  22. }
  23. $URL=`bash process-url.sh "$URL"`;
  24. print "Is ",$URL, " down for everyone or just me? - Thanks Microsoft";
  25. }
  26. print "</title>";
  27. print "</head>";
  28. print "<body>";
  29. if($ENV{QUERY_STRING} ne "")
  30. {
  31. if(`bash -c 'wget -q -O /dev/null '$URL' && echo -n Success'` ne "Success") {
  32. print "<h1>It's not just you!</h1>";
  33. print '<h2 style="font-weight: 400">', $URL, " seems down from here.</h2>";
  34. }
  35. else {
  36. print "<h1>It's just you.</h1>";
  37. print '<h2 style="font-weight: 400">', $URL, " seems up from here.</h2>"
  38. }
  39. }
  40. else {
  41. print '<form action="/" method="get">';
  42. print '<h2 style="font-weight: 400">', "Is ";
  43. print '<input type="text" name="url" />';
  44. print " down for everyone or just me? ", '<input type="submit" value="Check" />', "</h2></form>";
  45. }
  46. print "</body>";
  47. print "</html>"