]> Joshua Wise's Git repositories - patchfork.git/blame - player/login.php
Add support for view-only mode.
[patchfork.git] / player / login.php
CommitLineData
964dd0bc
JW
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");
f8fb3735 22 if(isset($_POST['password']) && $_POST['password'] != "") {
964dd0bc
JW
23 $pass = get_config("login_pass");
24 if(substr($pass,0, 4)=="sha:") {
25 if(check_hash($pass, trim($_POST['password']))) {
f8fb3735 26 $_SESSION['logged_in'] = "rw";
964dd0bc
JW
27 header("Location: index.php");
28 exit();
29 }
30 $error = "Login failed";
31 }
32 else if($pass==trim($_POST['password'])) {
f8fb3735 33 $_SESSION['logged_in'] = "rw";
964dd0bc
JW
34 header("Location: index.php");
35 exit();
36 }
f8fb3735
JW
37
38 $pass = get_config("ro_pass");
39 if(substr($pass,0, 4)=="sha:") {
40 if(check_hash($pass, trim($_POST['password']))) {
41 $_SESSION['logged_in'] = "ro";
42 header("Location: index.php");
43 exit();
44 }
964dd0bc
JW
45 $error = "Login failed";
46 }
f8fb3735
JW
47 else if($pass==trim($_POST['password'])) {
48 $_SESSION['logged_in'] = "ro";
49 header("Location: index.php");
50 exit();
51 }
52
53 $error = "Login failed";
964dd0bc
JW
54 }
55 else if(isset($_GET['logout'])) {
56 session_destroy();
57 header("Location: login.php");
58 exit();
59 }
60?>
61<html>
62<head>
63<title>Pitchfork login</title>
64<meta name="robots" content="noindex,nofollow" />
65<style type="text/css">
66 body {
67 text-align: center;
68 }
69 h1 {
70 font-size: 18px;
71 }
72 div.container {
73 display: block;
74 overflow: visible;
75 padding: 10px 25px 10px 25px;
76 width: 500px;
77 margin: 0 auto;
78 border: 1px solid #B0BDEC;
79 background-color: #DEE7F7;
80 }
81 p.error {
82 border: 1px solid #a20000;
83 background-color: #ffcccc;
84 padding: 5px;
85 }
86</style>
87</head>
88<body onload="document.getElementById('password').focus();">
89<div class='container'>
90<h1>Pitchfork login</h1>
91<?php
92 if($error) {
93 echo "<p class='error'>$error</p>";
94 }
95 if(isset($_SESSION['logged_in'])&&$_SESSION['logged_in']) {
96 echo "<p>Already logged in. <a href='login.php?logout'>Log out?</a></p>\n";
97 }
98?>
99 <form method="post" action="login.php">
100 Password: <input type='password' id="password" name='password' />
101 <input type='submit' name='submit' value='Log in'/>
102 </form>
103</div>
104</body>
105</html>
This page took 0.032894 seconds and 4 git commands to generate.