index.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. # Allow overloading of series requests for certain functions
  10. if (preg_match('/^\*\*\*/', $_REQUEST['series'])) {
  11. require_authentication();
  12. # Force refresh of the series list
  13. if (preg_match('/refresh/i', $_REQUEST['series'])) {
  14. set_time_limit(0);
  15. global $TV_PATH;
  16. allSeriesSeasons($TV_PATH, false);
  17. }
  18. # Always redirect to the main page
  19. global $MAIN_PAGE;
  20. header('Location: ' . $MAIN_PAGE);
  21. exit();
  22. }
  23. # Set the safe series name
  24. $series = cleanSeries($_REQUEST['series']);
  25. }
  26. # Did the user request an update?
  27. if ($series !== false && isset($_POST['Save'])) {
  28. require_authentication();
  29. # Grab the current settings for comparison
  30. $series_last = readFlags($series);
  31. $seasons_last = findSeasons($series);
  32. # Save series and season data
  33. saveFlags($series, $_POST, $series_last, $seasons_last);
  34. saveSeasons($series, $_POST, $series_last, $seasons_last);
  35. }
  36. # Did the user add a season?
  37. if ($series !== false && isset($_POST['AddSeason'])) {
  38. require_authentication();
  39. # Add a season folder
  40. $season = intval($_POST['season_add']);
  41. addSeason($series, $season);
  42. }
  43. # Did the user delete a season?
  44. if ($series !== false) {
  45. $season = false;
  46. foreach (array_keys($_POST) as $key) {
  47. if (preg_match('/season_del_(\d+)/', $key, $matches)) {
  48. $season = intval($matches[1]);
  49. last;
  50. }
  51. }
  52. if ($season !== false) {
  53. require_authentication();
  54. # Remove a season folder (if empty)
  55. delSeason($series, $season);
  56. }
  57. }
  58. # Did the user add a series?
  59. if ($series === false && isset($_POST['series_add'])) {
  60. require_authentication();
  61. # Add a series folder
  62. $series = addSeries($_POST['series_add']);
  63. }
  64. #=========================================================================================
  65. printHeader('UberZach TV');
  66. if ($series === false) {
  67. printAllSeries();
  68. } else {
  69. printSeries($series);
  70. }
  71. printFooter();
  72. ?>