PNA.fi koodi

food.cgi 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env perl
  2. # Copyright 2010 Timo Siiranen.
  3. # Public Domain
  4. #
  5. # Copyright 2018 Toni Fadjukoff. All Rights Reserved.
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. use strict;
  19. print "Content-Type: text/html; charset=iso-8859-1\n\n";
  20. print '<?xml version="1.0" encoding="iso-8859-1"?>
  21. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  22. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fi" lang="fi">
  23. <head>
  24. <title>Ruokalistat</title>
  25. </head>
  26. <body>';
  27. my $min_refresh_secs = 60*5;
  28. my @st = stat("/var/www/pna/1.html");
  29. if ($st[9] > time-$min_refresh_secs) {
  30. print "<p>Ruokalistaa on jo päivitetty alle 5min sitten.</p>";
  31. } elsif (system("cd /var/www/pna && ./food.py") == 0) {
  32. print "<p>Ruokalista päivitetty.</p>";
  33. } else {
  34. print "<p>Virhe päivittäessä ruokalistaa.</p>";
  35. }
  36. print "\n<p><a href=\"/\">Takaisin</a></p>\n</body></html>\n";