index.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 -->
  75. <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  76. <!-- Provide # support in JQuery-mobile autodividers -->
  77. <!-- Must be loaded before JQuery-mobile -->
  78. <script>
  79. $( document ).on( "mobileinit", function() {
  80. $.mobile.listview.prototype.options.autodividersSelector = function( elt ) {
  81. var text = $.trim( elt.text() ) || null;
  82. if ( !text ) {
  83. return null;
  84. }
  85. if ( !isNaN(parseFloat(text)) ) {
  86. return "#";
  87. } else {
  88. text = text.slice( 0, 1 ).toUpperCase();
  89. return text;
  90. }
  91. };
  92. });
  93. </script>
  94. <!-- Default JQuery-mobile -->
  95. <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
  96. <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
  97. <!-- Custom code for the linkbar -->
  98. <script src="autodividers-linkbar.js"></script>
  99. <link rel="stylesheet" href="autodividers-linkbar.css">
  100. </head>
  101. <body>
  102. ENDOLA;
  103. if ($series === false) {
  104. printAllSeries();
  105. } else {
  106. printSeries($series);
  107. }
  108. # Generic XHTML 1.1 footer
  109. print <<<ENDOLA
  110. </body>
  111. </html>
  112. ENDOLA;
  113. ?>