]> Joshua Wise's Git repositories - patchfork.git/blob - player/login.php
Update URL for LyricWiki. NOTE: LyricWiki now only returns 1/7 of the song lyrics...
[patchfork.git] / player / login.php
1 <?php
2 /* 
3     Pitchfork Music Player Daemon Client
4     Copyright (C) 2007  Roger Bystrøm
5
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; version 2 of the License.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19         $error = false;
20         $no_require_login = "true";
21         require_once("../inc/base.php");
22         if(isset($_POST['password'])) {
23                 $pass = get_config("login_pass");
24                 if(substr($pass,0, 4)=="sha:") {
25                         if(check_hash($pass, trim($_POST['password']))) {
26                                 $_SESSION['logged_in'] = true;
27                                 header("Location: index.php");
28                                 exit(); 
29                         }
30                         $error = "Login failed";
31                 }
32                 else if($pass==trim($_POST['password'])) {
33                         $_SESSION['logged_in'] = true;
34                         header("Location: index.php");
35                         exit(); 
36                 }
37                 else {
38                         $error = "Login failed";
39                 }
40         }
41         else if(isset($_GET['logout'])) {
42                 session_destroy();
43                 header("Location: login.php");
44                 exit();
45         }
46 ?>
47 <html>
48 <head>
49 <title>Pitchfork login</title>
50 <meta name="robots" content="noindex,nofollow" />
51 <style type="text/css"> 
52         body {
53                 text-align: center;
54         }
55         h1 {
56                 font-size: 18px; 
57         }
58         div.container {
59                 display:        block;
60                 overflow:       visible;
61                 padding:        10px 25px 10px 25px;
62                 width:          500px;
63                 margin:         0 auto;
64                 border:         1px solid #B0BDEC; 
65                 background-color: #DEE7F7; 
66         }
67         p.error {
68                 border:         1px solid #a20000;
69                 background-color: #ffcccc;
70                 padding: 5px;
71         }
72 </style>
73 </head>
74 <body onload="document.getElementById('password').focus();">
75 <div class='container'>
76 <h1>Pitchfork login</h1>
77 <?php
78         if($error) {
79                 echo "<p class='error'>$error</p>";
80         }
81         if(isset($_SESSION['logged_in'])&&$_SESSION['logged_in']) {
82                 echo "<p>Already logged in. <a href='login.php?logout'>Log out?</a></p>\n";
83         }
84 ?>
85         <form method="post" action="login.php">
86                 Password: <input type='password' id="password" name='password' />
87                 <input type='submit' name='submit' value='Log in'/>
88         </form>
89 </div>
90 </body>
91 </html>
This page took 0.031148 seconds and 4 git commands to generate.