index.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?
  2. # Include the TV functions
  3. require_once 'includes/main.php';
  4. # Send our headers early
  5. header('Content-type: text/html; charset=utf-8');
  6. # Did the user request a specific show?
  7. $show = false;
  8. if (isset($_REQUEST['show'])) {
  9. # This is not a great filter, but it should make the string safe for use as a quoted path
  10. $show = preg_replace('/[\0\n\r]/', '', $_REQUEST['show']);
  11. $show = basename($show);
  12. }
  13. # Did the user request an update?
  14. if ($show !== false && isset($_POST['Save'])) {
  15. # Require auth (or for the time being, specific IP addresses)
  16. if (preg_match('/^(?:172\.19\.[17]\.|2602:3f:e50d:76|74\.93\.97\.65)/', $_SERVER['REMOTE_ADDR'])) {
  17. # Grab the current settings for comparison
  18. global $TV_PATH;
  19. $series_path = $TV_PATH . '/'. $show;
  20. $series_last = readFlags($series_path);
  21. $seasons_last = findSeasons($series_path);
  22. # Save series and season data
  23. saveFlags($series_path, $_POST, $series_last, $seasons_last);
  24. saveSeasons($series_path, $_POST, $series_last, $seasons_last);
  25. } else {
  26. echo '<h4 style="color: red;">Cannot save: User not authenticated</h4>';
  27. }
  28. }
  29. #=========================================================================================
  30. # Generic XHTML 1.1 header
  31. print <<<ENDOLA
  32. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  33. "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  34. <html xmlns="http://www.w3.org/1999/xhtml">
  35. <head>
  36. <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
  37. <title>UberZach TV</title>
  38. </head>
  39. <body>
  40. ENDOLA;
  41. if ($show === false) {
  42. printAllShows();
  43. } else {
  44. printShow($show);
  45. }
  46. # Generic XHTML 1.1 footer
  47. print <<<ENDOLA
  48. </body>
  49. </html>
  50. ENDOLA;
  51. ?>