index.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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_authentication();
  14. # Grab the current settings for comparison
  15. $series_last = readFlags($series);
  16. $seasons_last = findSeasons($series);
  17. # Save series and season data
  18. saveFlags($series, $_POST, $series_last, $seasons_last);
  19. saveSeasons($series, $_POST, $series_last, $seasons_last);
  20. }
  21. # Did the user add a season?
  22. if ($series !== false && isset($_POST['AddSeason'])) {
  23. require_authentication();
  24. # Add a season folder
  25. $season = intval($_POST['season_add']);
  26. addSeason($series, $season);
  27. }
  28. # Did the user delete a season?
  29. if ($series !== false) {
  30. $season = false;
  31. foreach (array_keys($_POST) as $key) {
  32. if (preg_match('/season_del_(\d+)/', $key, $matches)) {
  33. $season = intval($matches[1]);
  34. last;
  35. }
  36. }
  37. if ($season !== false) {
  38. require_authentication();
  39. # Remove a season folder (if empty)
  40. delSeason($series, $season);
  41. }
  42. }
  43. # Did the user add a series?
  44. if ($series === false && isset($_POST['series_add'])) {
  45. require_authentication();
  46. # Add a series folder
  47. $series = addSeries($_POST['series_add']);
  48. }
  49. #=========================================================================================
  50. # Generic XHTML 1.1 header
  51. print <<<ENDOLA
  52. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  53. "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  54. <html xmlns="http://www.w3.org/1999/xhtml">
  55. <head>
  56. <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
  57. <title>UberZach TV</title>
  58. <!-- Default JQuery -->
  59. <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  60. <!-- Provide # support in JQuery-mobile autodividers -->
  61. <!-- Must be loaded before JQuery-mobile -->
  62. <script>
  63. $( document ).on( "mobileinit", function() {
  64. $.mobile.listview.prototype.options.autodividersSelector = function( elt ) {
  65. var text = $.trim( elt.text() ) || null;
  66. if ( !text ) {
  67. return null;
  68. }
  69. if ( !isNaN(parseFloat(text)) ) {
  70. return "#";
  71. } else {
  72. text = text.slice( 0, 1 ).toUpperCase();
  73. return text;
  74. }
  75. };
  76. });
  77. </script>
  78. <!-- Default JQuery-mobile -->
  79. <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
  80. <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
  81. <!-- Custom code for the linkbar -->
  82. <script src="autodividers-linkbar.js"></script>
  83. <link rel="stylesheet" href="autodividers-linkbar.css">
  84. </head>
  85. <body>
  86. ENDOLA;
  87. if ($series === false) {
  88. printAllSeries();
  89. } else {
  90. printSeries($series);
  91. }
  92. # Generic XHTML 1.1 footer
  93. print <<<ENDOLA
  94. </body>
  95. </html>
  96. ENDOLA;
  97. ?>