SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | session_start(); | |
| 3 | - | session_destroy(); |
| 3 | + | $_SESSION["userid"] = ""; // set these manually |
| 4 | $_SESSION["ind_admin"] = "1"; | |
| 5 | ||
| 6 | - | include_once "./password.php"; |
| 6 | + | |
| 7 | $sdb = "../sqlite/audiostreamer.db"; | |
| 8 | - | // AudioStreamer, www.audiostreamer.org |
| 8 | + | |
| 9 | - | // Copyright (C) <2013> <Lieven Rottiers> |
| 9 | + | |
| 10 | $error = ''; | |
| 11 | - | // This program is free software: you can redistribute it and/or modify |
| 11 | + | |
| 12 | - | // it under the terms of the GNU General Public License as published by |
| 12 | + | |
| 13 | - | // the Free Software Foundation, either version 3 of the License, or |
| 13 | + | |
| 14 | - | // (at your option) any later version. |
| 14 | + | |
| 15 | if (($new_version) && ($new_version != $version)) {
| |
| 16 | - | // This program is distributed in the hope that it will be useful, |
| 16 | + | |
| 17 | - | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | + | |
| 18 | - | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | + | |
| 19 | - | // GNU General Public License for more details. |
| 19 | + | |
| 20 | $new_version = ''; | |
| 21 | - | // You should have received a copy of the GNU General Public License |
| 21 | + | |
| 22 | - | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | + | |
| 23 | ||
| 24 | $username=""; | |
| 25 | - | //database connection and AudioStreamer version |
| 25 | + | |
| 26 | - | //also change this in audiostreamerlib.php |
| 26 | + | |
| 27 | foreach ($dbh->query($sql) as $row) {
| |
| 28 | $username = $row["name"]; | |
| 29 | $password = $row["password"]; | |
| 30 | $_SESSION["userid"] = $row["id"]; | |
| 31 | $_SESSION["ind_admin"] = $row["ind_admin"]; | |
| 32 | $_SESSION["ind_desktop"] = $row["ind_desktop"]; | |
| 33 | } | |
| 34 | ||
| 35 | ||
| 36 | //fetching current desktop | |
| 37 | $sql = "select a.id, b.folder from desktop a, theme b where a.ind_current = 1 and a.user='".$_SESSION["userid"]."' and a.theme = b.id"; | |
| 38 | foreach ($dbh->query($sql) as $row) {
| |
| 39 | $_SESSION["desktopid"] = $row["id"]; | |
| 40 | $_SESSION["desktopcss"] = './app/themes/'.$row["folder"].'/theme.css'; | |
| 41 | } | |
| 42 | //fetching setting parameters | |
| 43 | $sql = "select param, value from param"; | |
| 44 | - | if (!empty($_GET) || !empty($_POST)) {
|
| 44 | + | |
| 45 | - | if (!empty($_POST["username"])) {
|
| 45 | + | |
| 46 | - | $_SESSION["username"] = $_POST["username"]; |
| 46 | + | |
| 47 | - | } else if (!empty($_GET["username"])) {
|
| 47 | + | |
| 48 | - | $_SESSION["username"] = $_GET["username"]; |
| 48 | + | |
| 49 | - | } else {
|
| 49 | + | |
| 50 | - | $_SESSION["username"] = ''; |
| 50 | + | |
| 51 | - | } |
| 51 | + | |
| 52 | - | if (!empty($_POST["password"])) {
|
| 52 | + | |
| 53 | - | $_SESSION["password"] = $_POST["password"]; |
| 53 | + | |
| 54 | - | } else if (!empty($_GET["password"])) {
|
| 54 | + | |
| 55 | - | $_SESSION["password"] = $_GET["password"]; |
| 55 | + | |
| 56 | - | } else {
|
| 56 | + | |
| 57 | - | $_SESSION["password"] = ''; |
| 57 | + | |
| 58 | - | } |
| 58 | + | |
| 59 | - | // |
| 59 | + | |
| 60 | - | //check if working with the password file |
| 60 | + | |
| 61 | - | //and thus checking username and password |
| 61 | + | |
| 62 | - | // |
| 62 | + | |
| 63 | - | if (!empty($start_password)) {
|
| 63 | + | |
| 64 | - | $username = $start_username; |
| 64 | + | |
| 65 | - | $password = $start_password; |
| 65 | + | |
| 66 | - | $_SESSION["userid"] = ""; |
| 66 | + | |
| 67 | - | $_SESSION["ind_admin"] = "1"; |
| 67 | + | |
| 68 | - | } |
| 68 | + | |
| 69 | - | else {
|
| 69 | + | |
| 70 | ||
| 71 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| 72 | ||
| 73 | </head> | |
| 74 | <body> | |
| 75 | <div id="content"> | |
| 76 | <div id="login"> | |
| 77 | '; | |
| 78 | ||
| 79 | $output = $output.' | |
| 80 | - | } |
| 80 | + | |
| 81 | <form method=post action="login.php" id="formlogin"> | |
| 82 | - | if (empty($_SESSION["username"])) {
|
| 82 | + | |
| 83 | - | $error = 'User must be specified. Try again.'; |
| 83 | + | |
| 84 | - | session_destroy(); |
| 84 | + | |
| 85 | - | } |
| 85 | + | |
| 86 | - | else if (empty($_SESSION["password"])) {
|
| 86 | + | |
| 87 | - | $error = 'Password must be specified. Try again.'; |
| 87 | + | |
| 88 | - | session_destroy(); |
| 88 | + | |
| 89 | - | } |
| 89 | + | |
| 90 | - | else if ($_SESSION["username"]!=$username) {
|
| 90 | + | |
| 91 | - | $error = 'Wrong user. Login Failed. Try again.'; |
| 91 | + | |
| 92 | - | session_destroy(); |
| 92 | + | |
| 93 | - | } |
| 93 | + | |
| 94 | - | else if ($_SESSION["password"]!=$password) {
|
| 94 | + | |
| 95 | - | $error = 'Wrong password. Login Failed. Try again.'; |
| 95 | + | |
| 96 | - | session_destroy(); |
| 96 | + | |
| 97 | - | } |
| 97 | + | |
| 98 | - | else {
|
| 98 | + | |
| 99 | $output = $output.' | |
| 100 | </div> | |
| 101 | </div> | |
| 102 | </div> | |
| 103 | <script type="text/javascript"> | |
| 104 | $(document).ready(function(){
| |
| 105 | $("#formlogin").keyup(function(event){
| |
| 106 | if(event.keyCode == 13) {
| |
| 107 | //Enter keypress event. | |
| 108 | $("#formlogin").submit();
| |
| 109 | } | |
| 110 | - | header("Location: ./index.php");
|
| 110 | + | |
| 111 | - | header('Content-Length: 0');
|
| 111 | + | |
| 112 | - | exit; |
| 112 | + | |
| 113 | - | } |
| 113 | + | |
| 114 | </html> | |
| 115 | '; | |
| 116 | ||
| 117 | echo $output; |