index.php 2.1 KB

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