# HG changeset patch # User Dan # Date 1222226778 14400 # Node ID 1b4288399b1fc4ab0512aed67e9743e6c0436fa3 # Parent d62212462f9bbb10d5e59a9355fb5686dc5c3945 Added graphical configuration, at this point only for the grey theme but others will follow soon. (This has been nearly done for two weeks or more but was on hold due to the bugs with multithreading) diff -r d62212462f9b -r 1b4288399b1f functions.php --- a/functions.php Tue Sep 23 23:26:15 2008 -0400 +++ b/functions.php Tue Sep 23 23:26:18 2008 -0400 @@ -221,6 +221,11 @@ { global $httpd; static $smarty = array(); + if ( $theme_id === '__free__' ) + { + $smarty = array(); + return false; + } if ( !isset($smarty[$theme_id]) ) { $smarty[$theme_id] = new Smarty(); @@ -233,3 +238,61 @@ } return $smarty[$theme_id]; } + +/** + * Implementation of the "which" command in native PHP. + * @param string command + * @return string path to executable, or false on failure + */ + +function which($executable) +{ + $path = ( isset($_ENV['PATH']) ) ? $_ENV['PATH'] : ( isset($_SERVER['PATH']) ? $_SERVER['PATH'] : false ); + if ( !$path ) + // couldn't get OS's PATH + return false; + + $win32 = ( PHP_OS == 'WINNT' || PHP_OS == 'WIN32' ); + $extensions = $win32 ? array('.exe', '.com', '.bat') : array(''); + $separator = $win32 ? ';' : ':'; + $paths = explode($separator, $path); + foreach ( $paths as $dir ) + { + foreach ( $extensions as $ext ) + { + $fullpath = "$dir/{$executable}{$ext}"; + if ( file_exists($fullpath) && is_executable($fullpath) ) + { + return $fullpath; + } + } + } + return false; +} + +/** + * Reload the config. + */ + +function grey_reload_config() +{ + global $httpd; + status('reloading the config'); + + if ( file_exists('./greyhound-config.php') ) + { + require('./greyhound-config.php'); + } + else + { + // ignore this, it allows using a different config file when a Mercurial repository + // exists in Greyhound's root directory (to allow the devs to have their own config + // separate from the default) + + if ( @is_dir(GREY_ROOT . '/.hg') ) + require(GREY_ROOT . '/config.dev.php'); + else + require(GREY_ROOT . '/config.php'); + } +} + diff -r d62212462f9b -r 1b4288399b1f scripts/config.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/config.js Tue Sep 23 23:26:18 2008 -0400 @@ -0,0 +1,157 @@ +var userlist = []; + +function register_user(username) +{ + userlist.push(username); +} + +function draw_user(ul, username) +{ + var inp = document.createElement('input'); + inp.type = 'hidden'; + inp.name = 'users[]'; + inp.value = username; + ul.parentNode.appendChild(inp); + var li = document.createElement('li'); + li.username = username; + li.userinput = inp; + var delbtn = document.createElement('a'); + delbtn.style.color = '#ff0000'; + delbtn.href = '#'; + delbtn.onclick = function() + { + delete_user(this); + return false; + } + delbtn.appendChild(document.createTextNode('[X]')); + li.appendChild(delbtn); + + li.appendChild(document.createTextNode(' ' + username)); + ul.appendChild(li); +} + +function draw_new_user(username, password) +{ + for ( var i = 0; i < userlist.length; i++ ) + { + if ( userlist[i] == username ) + { + alert('The username you entered is already in the list, please delete the current user and re-add it if you want to change the password.'); + return false; + } + } + + userlist.push(username); + + var ul = document.getElementById('userlist'); + + var inp = document.createElement('input'); + inp.type = 'hidden'; + inp.name = 'users_add[' + username + ']'; + inp.value = password; + ul.parentNode.appendChild(inp); + var li = document.createElement('li'); + li.username = username; + li.userinput = inp; + var delbtn = document.createElement('a'); + delbtn.style.color = '#ff0000'; + delbtn.href = '#'; + delbtn.onclick = function() + { + delete_user(this); + return false; + } + delbtn.appendChild(document.createTextNode('[X]')); + li.appendChild(delbtn); + + li.appendChild(document.createTextNode(' ' + username)); + ul.appendChild(li); + + return true; +} + +function userlist_init() +{ + var ul = document.getElementById('userlist'); + for ( var i = 0; i < userlist.length; i++ ) + { + draw_user(ul, userlist[i]); + } +} + +function delete_user(a) +{ + var li = a.parentNode; + var username = li.username; + li.parentNode.parentNode.removeChild(li.userinput); + li.parentNode.removeChild(li); + + for ( var i = 0; i < userlist.length; i++ ) + { + if ( userlist[i] == username ) + { + delete(userlist[i]); + break; + } + } +} + +function add_user_form() +{ + var ul = document.getElementById('userlist'); + + if ( ul.parentNode.getElementsByTagName('form').length > 0 ) + { + return false; + } + + var theform = document.createElement('form'); + theform.action = 'javascript:void(0);'; + theform.onsubmit = function() + { + if ( this.username.value == '' || this.password.value == '' ) + { + alert('Please enter a username and password.'); + return false; + } + if ( draw_new_user(this.username.value, this.password.value) ) + { + this.parentNode.removeChild(this); + } + else + { + this.username.focus(); + } + + return false; + } + + theform.appendChild(document.createTextNode('user: ')); + + var i_user = document.createElement('input'); + i_user.type = 'text'; + i_user.name = 'username'; + i_user.size = '12'; + theform.appendChild(i_user); + + theform.appendChild(document.createTextNode(' pass: ')); + + var i_pass = document.createElement('input'); + i_pass.type = 'password'; + i_pass.name = 'password'; + i_pass.size = '12'; + theform.appendChild(i_pass); + + theform.appendChild(document.createTextNode(' ')); + + var i_sub = document.createElement('input'); + i_sub.type = 'submit'; + i_sub.value = 'Add'; + theform.appendChild(i_sub); + + ul.parentNode.appendChild(theform); + + i_user.focus(); +} + +window.onload = userlist_init; diff -r d62212462f9b -r 1b4288399b1f themes/grey/config.tpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/themes/grey/config.tpl Tue Sep 23 23:26:18 2008 -0400 @@ -0,0 +1,194 @@ +{** + * Template file for default Funky Monkey theme + * Web control interface script for Amarok + * Written by Dan Fuhry - 2008 + * + * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + *} + + + +
+