index.php 2.1 KB

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