author | Dan |
Tue, 23 Sep 2008 23:31:51 -0400 | |
changeset 51 | 7009a9cbd46f |
parent 50 | 1b4288399b1f |
child 64 | ee64bb096f56 |
permissions | -rw-r--r-- |
50
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
1 |
<?php |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
2 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
3 |
/** |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
4 |
* Greyhound - real web management for Amarok |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
5 |
* Copyright (C) 2008 Dan Fuhry |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
6 |
* |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
7 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
8 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
9 |
* |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
11 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
12 |
*/ |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
13 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
14 |
// rebooting doesn't work at this point |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
15 |
define('REBOOT_SUPPORT', false); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
16 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
17 |
function greyhound_config($httpd, $socket) |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
18 |
{ |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
19 |
global $use_auth; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
20 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
21 |
// validate the session |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
22 |
if ( !session_check() ) |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
23 |
{ |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
24 |
$httpd->header('HTTP/1.1 307 Temporary Redirect'); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
25 |
$httpd->header('Location: /login'); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
26 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
27 |
return; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
28 |
} |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
29 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
30 |
$tried = false; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
31 |
$success = false; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
32 |
$needpass = false; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
33 |
$error = false; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
34 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
35 |
// if a config password is set, make sure it matches. |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
36 |
$authed = false; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
37 |
if ( empty($GLOBALS['configpass']) ) |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
38 |
{ |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
39 |
$authed = true; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
40 |
} |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
41 |
else |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
42 |
{ |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
43 |
$needpass = true; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
44 |
if ( isset($_POST['configpass']) && sha1($_POST['configpass']) === $GLOBALS['configpass'] ) |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
45 |
{ |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
46 |
$authed = true; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
47 |
$tried = true; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
48 |
} |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
49 |
else if ( isset($_POST['configpass']) ) |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
50 |
{ |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
51 |
$error = 'You didn\'t enter the right configuration password, so the changes weren\'t saved.'; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
52 |
$tried = true; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
53 |
} |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
54 |
} |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
55 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
56 |
if ( $authed && isset($_POST['submit']) ) |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
57 |
{ |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
58 |
$need_reboot = ( isset($_POST['public']) !== $GLOBALS['public'] || |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
59 |
isset($_POST['allow_fork']) !== $GLOBALS['allow_fork']); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
60 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
61 |
// compile the new config file |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
62 |
$public = ( isset($_POST['public']) ) ? 'true' : 'false'; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
63 |
$allowcontrol = ( isset($_POST['allowcontrol']) ) ? 'true' : 'false'; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
64 |
$allow_fork = ( isset($_POST['allow_fork']) ) ? 'true' : 'false'; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
65 |
$use_auth = ( isset($_POST['use_auth']) ) ? 'true' : 'false'; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
66 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
67 |
// for auth_data, we're going to merge the data from POST with the current auth_data array. |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
68 |
$auth_data = $GLOBALS['auth_data']; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
69 |
$auth_changed = false; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
70 |
foreach ( $auth_data as $user => $pass ) |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
71 |
{ |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
72 |
if ( !in_array($user, $_POST['users']) ) |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
73 |
{ |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
74 |
$auth_changed = true; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
75 |
unset($auth_data[$user]); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
76 |
} |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
77 |
} |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
78 |
if ( isset($_POST['users_add']) ) |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
79 |
{ |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
80 |
foreach ( $_POST['users_add'] as $user => $pass ) |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
81 |
{ |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
82 |
$auth_changed = true; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
83 |
$auth_data[$user] = $pass; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
84 |
} |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
85 |
} |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
86 |
$auth_data = var_export_string($auth_data); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
87 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
88 |
$new_configpass = ( is_string($_POST['newconfigpass']) && $_POST['newconfigpass'] != '____________________' ) ? sha1($_POST['newconfigpass']) : $GLOBALS['configpass']; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
89 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
90 |
$config_file = <<<EOF |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
91 |
<?php |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
92 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
93 |
// |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
94 |
// GREYHOUND CONFIGURATION |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
95 |
// |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
96 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
97 |
// Listen on all interfaces. If this is false, it will only listen on |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
98 |
// 127.0.0.1 (the loopback interface) |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
99 |
\$GLOBALS['public'] = $public; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
100 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
101 |
// Allow control of playback. By default this is turned on but if you |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
102 |
// set this to false, it will only display the playlist. |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
103 |
\$GLOBALS['allowcontrol'] = $allowcontrol; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
104 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
105 |
// The default theme. This should be a name of a directory in ./themes. |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
106 |
\$GLOBALS['theme'] = 'grey'; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
107 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
108 |
// Allow forking when an HTTP request is received. This has advantages |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
109 |
// and disadvantages. If this experimental option is enabled, it will |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
110 |
// result in faster responses and load times but more memory usage. |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
111 |
\$GLOBALS['allow_fork'] = $allow_fork; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
112 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
113 |
// set to true to enable authentication |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
114 |
// this uses cookies, so make sure they're enabled in your browser |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
115 |
\$GLOBALS['use_auth'] = $use_auth; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
116 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
117 |
// valid users and passwords |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
118 |
\$GLOBALS['auth_data'] = $auth_data; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
119 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
120 |
// password for site configuration |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
121 |
\$GLOBALS['configpass'] = '$new_configpass'; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
122 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
123 |
EOF; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
124 |
$error = 'Couldn\'t write to the config file (./greyhound-config.php).'; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
125 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
126 |
$fp = @fopen('./greyhound-config.php', 'w'); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
127 |
if ( $fp ) |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
128 |
{ |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
129 |
fwrite($fp, $config_file); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
130 |
fclose($fp); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
131 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
132 |
$passblurb = $auth_changed ? "\n<small>If you changed your own password, you've been logged out so you'll need to log back in again.</small>" : ''; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
133 |
if ( REBOOT_SUPPORT ) |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
134 |
{ |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
135 |
$rebootblurb = $need_reboot ? "\n<small>Since you changed some core configuration values, the Greyhound server has been restarted.</small>\n<small>If Greyhound doesn't respond, wait 20 seconds and then restart it using Amarok's script manager.</small>" : ''; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
136 |
} |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
137 |
else |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
138 |
{ |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
139 |
$rebootblurb = $need_reboot ? "\n<small>Please restart Greyhound using Amarok's script manager for public IP and multithreading options to take effect.</small>" : ''; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
140 |
} |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
141 |
$success = "Configuration changes successful.{$passblurb}{$rebootblurb}"; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
142 |
$httpd->threader->ipc_send(array('action' => 'reloadconfig', 'propagate' => true)); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
143 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
144 |
if ( $need_reboot && REBOOT_SUPPORT ) |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
145 |
{ |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
146 |
$addr = $GLOBALS['public'] ? '0.0.0.0' : '127.0.0.1'; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
147 |
$fork = $GLOBALS['allow_fork']; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
148 |
$httpd->reboot($addr, null, $fork); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
149 |
} |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
150 |
} |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
151 |
} |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
152 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
153 |
global $theme; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
154 |
$iphone = ( ( strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') || |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
155 |
strpos($_SERVER['HTTP_USER_AGENT'], 'iPod') || |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
156 |
strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') || |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
157 |
isset($_GET['m']) ) |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
158 |
&& !isset($_GET['f']) |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
159 |
); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
160 |
$theme_id = ( $iphone ) ? 'iphone' : $theme; |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
161 |
$smarty = load_theme($theme_id); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
162 |
|
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
163 |
$smarty->assign('theme', $theme_id); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
164 |
$smarty->assign('greyhound_version', GREY_VERSION); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
165 |
$smarty->assign('tried', $tried); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
166 |
$smarty->assign('success', $success); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
167 |
$smarty->assign('needpass', $needpass); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
168 |
$smarty->assign('use_auth', $use_auth); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
169 |
$smarty->assign('public', $GLOBALS['public']); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
170 |
$smarty->assign('allowcontrol', $GLOBALS['allowcontrol']); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
171 |
$smarty->assign('allow_fork', $GLOBALS['allow_fork']); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
172 |
$smarty->assign('use_auth', $GLOBALS['use_auth']); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
173 |
$smarty->assign('users', $GLOBALS['auth_data']); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
174 |
$smarty->assign('error', $error); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
175 |
$smarty->display('config.tpl'); |
1b4288399b1f
Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading)
Dan
parents:
diff
changeset
|
176 |
} |