index.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. $series = cleanSeries($_REQUEST['series']);
  10. }
  11. # Did the user request an update?
  12. if ($series !== false && isset($_POST['Save'])) {
  13. # Require auth (or for the time being, specific IP addresses)
  14. if (preg_match('/^(?:172\.19\.[17]\.|2602:3f:e50d:76|74\.93\.97\.65)/', $_SERVER['REMOTE_ADDR'])) {
  15. # Grab the current settings for comparison
  16. $series_last = readFlags($series);
  17. $seasons_last = findSeasons($series);
  18. # Save series and season data
  19. saveFlags($series, $_POST, $series_last, $seasons_last);
  20. saveSeasons($series, $_POST, $series_last, $seasons_last);
  21. } else {
  22. echo '<h4 style="color: red;">Cannot save: User not authenticated</h4>';
  23. }
  24. }
  25. # Did the user add a season?
  26. if ($series !== false && isset($_POST['AddSeason'])) {
  27. # Require auth (or for the time being, specific IP addresses)
  28. if (preg_match('/^(?:172\.19\.[17]\.|2602:3f:e50d:76|74\.93\.97\.65)/', $_SERVER['REMOTE_ADDR'])) {
  29. # Add a season folder
  30. $season = intval($_POST['season_add']);
  31. addSeason($series, $season);
  32. } else {
  33. echo '<h4 style="color: red;">Cannot save: User not authenticated</h4>';
  34. }
  35. }
  36. # Did the user delete a season?
  37. if ($series !== false) {
  38. $season = false;
  39. foreach (array_keys($_POST) as $key) {
  40. if (preg_match('/season_del_(\d+)/', $key, $matches)) {
  41. $season = intval($matches[1]);
  42. last;
  43. }
  44. }
  45. if ($season !== false) {
  46. # Require auth (or for the time being, specific IP addresses)
  47. if (preg_match('/^(?:172\.19\.[17]\.|2602:3f:e50d:76|74\.93\.97\.65)/', $_SERVER['REMOTE_ADDR'])) {
  48. # Remove a season folder (if empty)
  49. delSeason($series, $season);
  50. } else {
  51. echo '<h4 style="color: red;">Cannot save: User not authenticated</h4>';
  52. }
  53. }
  54. }
  55. # Did the user add a series?
  56. if ($series === false && isset($_POST['series_add'])) {
  57. # Require auth (or for the time being, specific IP addresses)
  58. if (preg_match('/^(?:172\.19\.[17]\.|2602:3f:e50d:76|74\.93\.97\.65)/', $_SERVER['REMOTE_ADDR'])) {
  59. # Add a series folder
  60. $series = addSeries($_POST['series_add']);
  61. } else {
  62. echo '<h4 style="color: red;">Cannot save: User not authenticated</h4>';
  63. }
  64. }
  65. #=========================================================================================
  66. # Generic XHTML 1.1 header
  67. print <<<ENDOLA
  68. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  69. "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  70. <html xmlns="http://www.w3.org/1999/xhtml">
  71. <head>
  72. <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
  73. <title>UberZach TV</title>
  74. <!-- Default JQuery/JQuery-mobile docs -->
  75. <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
  76. <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  77. <!-- Provide # support in JQuery-mobile -->
  78. <script src="jquery.mobile-1.3.2.js"></script>
  79. <!-- Custom JQuery docs -->
  80. <script src="autodividers-linkbar.js"></script>
  81. <link rel="stylesheet" href="autodividers-linkbar.css">
  82. </head>
  83. <body>
  84. ENDOLA;
  85. if ($series === false) {
  86. printAllSeries();
  87. } else {
  88. printSeries($series);
  89. }
  90. # Generic XHTML 1.1 footer
  91. print <<<ENDOLA
  92. </body>
  93. </html>
  94. ENDOLA;
  95. ?>