uiconfig.php
author Dan
Tue, 26 May 2009 15:26:22 -0400
changeset 71 8663af0e27c7
parent 64 ee64bb096f56
child 78 08f8a72b1f7b
permissions -rw-r--r--
A little more work on reboot support. Still not enabled, but should work eventually.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
  {
71
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    58
    $tried = true;
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
    59
    $need_reboot = ( isset($_POST['public']) !== $GLOBALS['public'] ||
71
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    60
                     isset($_POST['ipv6']) !== $GLOBALS['enable_ipv6'] ||
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
    61
                     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
    62
    
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
    // 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
    64
    $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
    65
    $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
    66
    $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
    67
    $use_auth = ( isset($_POST['use_auth']) ) ? 'true' : 'false';
71
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    68
    $ipv6_settings = ( isset($_POST['ipv6']) ) ? '$GLOBALS[\'enable_ipv4\'] = false;
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    69
$GLOBALS[\'enable_ipv6\'] = true;' : '$GLOBALS[\'enable_ipv4\'] = true;
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    70
$GLOBALS[\'enable_ipv6\'] = false;';
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    71
    $GLOBALS['enable_ipv6'] = isset($_POST['ipv6']);
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
    72
    
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
    // 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
    74
    $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
    75
    $auth_changed = false;
71
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    76
    if ( isset($_POST['users']) )
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
    77
    {
71
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    78
      foreach ( $auth_data as $user => $pass )
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
    79
      {
71
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    80
        if ( !in_array($user, $_POST['users']) )
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    81
        {
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    82
          $auth_changed = true;
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    83
          unset($auth_data[$user]);
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    84
        }
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    85
      }
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    86
    }
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    87
    else
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    88
    {
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    89
      if ( !empty($auth_data) )
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    90
      {
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    91
        $auth_data = array();
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
    92
        $auth_changed = true;
71
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
    93
      } 
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
    94
    }
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
    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
    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
      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
    98
      {
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
        $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
   100
        $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
   101
      }
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
    }
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
    $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
   104
    
71
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   105
    $new_configpass = ( isset($_POST['newconfigpass']) && is_string($_POST['newconfigpass']) && $_POST['newconfigpass'] != '____________________' ) ? sha1($_POST['newconfigpass']) : $GLOBALS['configpass'];
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   106
    if ( isset($_POST['newconfigpass']) && $_POST['newconfigpass'] === true )
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   107
      $new_configpass = '';
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   108
    
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   109
    $needpass = ( $new_configpass != '' );
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
   110
    
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
    $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
   112
<?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
   113
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
//
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
// 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
   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
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
// 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
   119
// 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
   120
\$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
   121
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
// 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
   123
// 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
   124
\$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
   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
// 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
   127
\$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
   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
// 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
   130
// 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
   131
// 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
   132
\$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
   133
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
// 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
   135
// 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
   136
\$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
   137
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
// 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
   139
\$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
   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
// 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
   142
\$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
   143
71
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   144
// IPv4 and IPv6
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   145
$ipv6_settings
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   146
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
   147
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
   148
    $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
   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
    $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
   151
    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
   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
      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
   154
      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
   155
      
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
      $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
   157
      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
   158
      {
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
        $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
   160
      }
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
      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
   162
      {
71
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   163
        $rebootblurb = $need_reboot ? "\n<small>Please restart Greyhound using Amarok's script manager for public IP, multithreading, and IPv6 options to take effect.</small>" : '';
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
   164
      }
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
      $success = "Configuration changes successful.{$passblurb}{$rebootblurb}";
71
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   166
      if ( $httpd->threader->is_child() )
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   167
      {
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   168
        $httpd->threader->ipc_send(array('action' => 'reloadconfig', 'propagate' => true));
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   169
      }
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   170
      else
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   171
      {
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   172
        grey_reload_config();
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   173
      }
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
   174
      
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
      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
   176
      {
71
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   177
        if ( $GLOBALS['enable_ipv6'] )
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   178
        {
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   179
          $addr = isset($_POST['public']) ? '::' : '::1';
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   180
        }
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   181
        else
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   182
        {
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   183
          $addr = isset($_POST['public']) ? '0.0.0.0' : '127.0.0.1';
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   184
        }
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   185
        $fork = isset($_POST['allow_fork']);
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
   186
        $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
   187
      }
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
   188
    }
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
   189
  }
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
   190
  
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
   191
  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
   192
  $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
   193
       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
   194
       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
   195
       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
   196
       && !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
   197
       );
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
   198
  $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
   199
  $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
   200
  
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
   201
  $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
   202
  $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
   203
  $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
   204
  $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
   205
  $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
   206
  $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
   207
  $smarty->assign('public', $GLOBALS['public']);
71
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   208
  $smarty->assign('ipv6', $GLOBALS['enable_ipv6']);
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
   209
  $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
   210
  $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
   211
  $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
   212
  $smarty->assign('users', $GLOBALS['auth_data']);
71
8663af0e27c7 A little more work on reboot support. Still not enabled, but should work eventually.
Dan
parents: 64
diff changeset
   213
  $smarty->assign('reboot_support', REBOOT_SUPPORT);
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
   214
  $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
   215
  $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
   216
}