login.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. # Process logout
  7. if (isset($_REQUEST['logout'])) {
  8. logout();
  9. }
  10. # Process login
  11. if (isset($_POST['username']) && isset($_POST['password'])) {
  12. login($_POST['username'], $_POST['password']);
  13. }
  14. # Redirect if we're already authenticated
  15. if (authenticated()) {
  16. login_redirect();
  17. }
  18. #=========================================================================================
  19. # Generic XHTML 1.1 header
  20. print <<<ENDOLA
  21. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  22. "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  23. <html xmlns="http://www.w3.org/1999/xhtml">
  24. <head>
  25. <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
  26. <title>UberZach TV - Login</title>
  27. <!-- Default JQuery -->
  28. <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  29. <!-- Provide # support in JQuery-mobile autodividers -->
  30. <!-- Must be loaded before JQuery-mobile -->
  31. <script>
  32. $( document ).on( "mobileinit", function() {
  33. $.mobile.listview.prototype.options.autodividersSelector = function( elt ) {
  34. var text = $.trim( elt.text() ) || null;
  35. if ( !text ) {
  36. return null;
  37. }
  38. if ( !isNaN(parseFloat(text)) ) {
  39. return "#";
  40. } else {
  41. text = text.slice( 0, 1 ).toUpperCase();
  42. return text;
  43. }
  44. };
  45. });
  46. </script>
  47. <!-- Default JQuery-mobile -->
  48. <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
  49. <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
  50. <!-- Custom code for the linkbar -->
  51. <script src="autodividers-linkbar.js"></script>
  52. <link rel="stylesheet" href="autodividers-linkbar.css">
  53. </head>
  54. <body>
  55. ENDOLA;
  56. $url = $_SERVER['PHP_SELF'];
  57. if (isset($_GET['dest'])) {
  58. $url .= '?dest=' . urlencode($_GET['dest']);
  59. }
  60. print <<<ENDOLA
  61. <div style="width: 50%; margin-left: auto; margin-right: auto;">
  62. <form action="${url}" method="post" data-ajax="false">
  63. <p>
  64. <label>Username: <input type="text" name="username" /></label><br/>
  65. <label>Password: <input type="password" name="password" /></label><br/>
  66. </p>
  67. <p><input type="submit" name="login" value="Login" /></p>
  68. </form>
  69. </div>
  70. ENDOLA;
  71. # Generic XHTML 1.1 footer
  72. print <<<ENDOLA
  73. </body>
  74. </html>
  75. ENDOLA;
  76. ?>