robots.awk 985 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #
  2. # Copyright (C) 2005, 2006 Stephen Jungels
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful, but
  10. # WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # General Public License for more details.
  13. #
  14. # See COPYING for the full text of the license.
  15. BEGIN {
  16. ok = 1;
  17. check = 0;
  18. }
  19. /^User-agent:/ {
  20. check = 0;
  21. }
  22. /^User-agent: \* *(#.*)?$/ {
  23. check = 1;
  24. }
  25. /^User-agent: Plait *(#.*)?$/ {
  26. check = 1;
  27. }
  28. /^Disallow: ?\/ *(#.*)?$/ {
  29. if (check==1) ok = 0;
  30. }
  31. /^Disallow: ?\/directory/ {
  32. if (check==1) ok = 0;
  33. }
  34. /^Allow: ?\/directory/ {
  35. if (check==1) ok = 1;
  36. }
  37. END {
  38. if (ok==1)
  39. print("OK");
  40. else
  41. print("NOT OK");
  42. }