index.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 series?
  7. $series = false;
  8. if (isset($_REQUEST['series'])) {
  9. # This is not a great filter, but it should make the string safe for use as a quoted path
  10. $series = preg_replace('/[\0\n\r]/', '', $_REQUEST['series']);
  11. $series = basename($series);
  12. }
  13. # Did the user request an update?
  14. if ($series !== 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. $series_last = readFlags($series);
  19. $seasons_last = findSeasons($series);
  20. # Save series and season data
  21. saveFlags($series, $_POST, $series_last, $seasons_last);
  22. saveSeasons($series, $_POST, $series_last, $seasons_last);
  23. } else {
  24. echo '<h4 style="color: red;">Cannot save: User not authenticated</h4>';
  25. }
  26. }
  27. # Did the user add a season?
  28. if ($series !== false && isset($_POST['AddSeason'])) {
  29. # Require auth (or for the time being, specific IP addresses)
  30. if (preg_match('/^(?:172\.19\.[17]\.|2602:3f:e50d:76|74\.93\.97\.65)/', $_SERVER['REMOTE_ADDR'])) {
  31. # Add a season folder
  32. $new_season = intval($_POST['season_new']);
  33. addSeason($series, $new_season);
  34. } else {
  35. echo '<h4 style="color: red;">Cannot save: User not authenticated</h4>';
  36. }
  37. }
  38. #=========================================================================================
  39. # Generic XHTML 1.1 header
  40. print <<<ENDOLA
  41. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  42. "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  43. <html xmlns="http://www.w3.org/1999/xhtml">
  44. <head>
  45. <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
  46. <title>UberZach TV</title>
  47. </head>
  48. <body>
  49. ENDOLA;
  50. if ($series === false) {
  51. printAllSeries();
  52. } else {
  53. printSeries($series);
  54. }
  55. # Generic XHTML 1.1 footer
  56. print <<<ENDOLA
  57. </body>
  58. </html>
  59. ENDOLA;
  60. ?>