# HG changeset patch
# User Dan
# Date 1218858540 14400
# Node ID 3b817b961984d4fef22539caf044cc20892f9d37
# Parent 3b4aef1efff6270a5144de1693174a5bb33789c3# Parent 48004643a8a52a747dea289f7279d56c426d7bb7
Merging changes from nighthawk; added support for dumb terminals
diff -r 3b4aef1efff6 -r 3b817b961984 functions.php
--- a/functions.php Fri Aug 15 23:31:37 2008 -0400
+++ b/functions.php Fri Aug 15 23:49:00 2008 -0400
@@ -24,23 +24,39 @@
function burnout($msg)
{
+ global $use_colors;
$h = @fopen('php://stderr', 'w');
- fwrite($h, "\x1B[31;1m[Greyhound] fatal: \x1B[37;1m");
- fwrite($h, "$msg\x1B[0m\n");
+ if ( $use_colors )
+ {
+ fwrite($h, "\x1B[31;1m[Greyhound] fatal: \x1B[37;1m");
+ fwrite($h, "$msg\x1B[0m\n");
+ }
+ else
+ {
+ fwrite($h, "[Greyhound] fatal: $msg\n");
+ }
fclose($h);
exit(1);
}
/**
- * Print a stylized status message, compatible with Linux consoles
+ * Print a stylized status message, compatible with Linux consoles. Falls back to no control characters if on unsupported terminal.
* @param string Status message
*/
function status($msg)
{
+ global $use_colors;
$h = @fopen('php://stderr', 'w');
$label = ( defined('HTTPD_WS_CHILD') ) ? 'Child ' . substr(strval(getmypid()), -3) : 'Greyhound';
- fwrite($h, "\x1B[32;1m[$label] \x1B[32;0m$msg\x1B[0m\n");
+ if ( $use_colors )
+ {
+ fwrite($h, "\x1B[32;1m[$label] \x1B[32;0m$msg\x1B[0m\n");
+ }
+ else
+ {
+ fwrite($h, "[$label] $msg\n");
+ }
fclose($h);
}
@@ -51,8 +67,16 @@
function warning($msg)
{
+ global $use_colors;
$h = @fopen('php://stderr', 'w');
- fwrite($h, "\x1B[33;1m[Greyhound] \x1B[0m\x1B[33mWarning:\x1B[0m $msg\n");
+ if ( $use_colors )
+ {
+ fwrite($h, "\x1B[33;1m[Greyhound] \x1B[0m\x1B[33mWarning:\x1B[0m $msg\n");
+ }
+ else
+ {
+ fwrite($h, "[Greyhound] Warning: $msg\n");
+ }
fclose($h);
}
diff -r 3b4aef1efff6 -r 3b817b961984 greyhound.php
--- a/greyhound.php Fri Aug 15 23:31:37 2008 -0400
+++ b/greyhound.php Fri Aug 15 23:49:00 2008 -0400
@@ -37,7 +37,7 @@
// set this to false, it will only display the playlist.
$allowcontrol = true;
// The default theme. This should be a name of a directory in ./themes.
-$theme = 'funkymonkey';
+$theme = 'grey';
// Allow forking when an HTTP request is received. This has advantages
// and disadvantages. If this experimental option is enabled, it will
// result in faster responses and load times but more memory usage.
@@ -64,6 +64,9 @@
// create directories
@mkdir('./compiled');
+// what kind of terminal do we have?
+$use_colors = ( @in_array(@$_SERVER['TERM'], array('linux', 'xterm', 'vt100')) ) ? true : false;
+
// start up...
status('Starting Greyhound Web Control v0.1a3');
@@ -85,6 +88,18 @@
exit(0);
}
+status('doing PHP capabilities check');
+if ( !function_exists('pcntl_signal') )
+{
+ warning('System does not support POSIX functions. Termination signals will result in unclean shutdown.');
+}
+
+if ( !function_exists('simplexml_load_file') )
+{
+ warning('Can\'t find support for SimpleXML, which is needed to parse the Amarok playlist file.');
+ burnout('SimpleXML required to continue. You may have an outdated version of PHP; most versions of PHP 5 have SimpleXML built-in. Check your distribution\'s documentation to find out how to enable PHP\'s SimpleXML support.');
+}
+
status('initializing playlist');
// init playlist object
@@ -99,11 +114,6 @@
try
{
status('starting PhpHttpd');
- status('doing PHP capabilities check');
- if ( !function_exists('pcntl_signal') )
- {
- warning('System does not support POSIX functions. Termination signals will result in unclean shutdown.');
- }
$httpd = new WebServer($ip, $port);
// setup handlers
@@ -143,6 +153,10 @@
}
catch( Exception $e )
{
+ if ( strstr(strval($e), "Could not bind") )
+ {
+ burnout("Could not bind to the port $ip:$port. Is Greyhound already running? Sometimes browsers don't close off their connections until Greyhound has been dead for about a minute, so try starting Greyhound again in roughly 60 seconds. If that doesn't work, type \"killall -9 php\" at a terminal and try starting Greyhound again in 60 seconds.");
+ }
burnout("Exception caught while running webserver:\n$e");
}
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/ajax.gif
Binary file themes/grey/images/ajax.gif has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/amarok.gif
Binary file themes/grey/images/amarok.gif has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/next.png
Binary file themes/grey/images/next.png has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/pause.png
Binary file themes/grey/images/pause.png has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/play.png
Binary file themes/grey/images/play.png has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/playbar-shadow.gif
Binary file themes/grey/images/playbar-shadow.gif has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/playbar.gif
Binary file themes/grey/images/playbar.gif has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/playhead.png
Binary file themes/grey/images/playhead.png has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/position-empty.png
Binary file themes/grey/images/position-empty.png has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/position-full.png
Binary file themes/grey/images/position-full.png has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/prev.png
Binary file themes/grey/images/prev.png has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/src/playbar-shadow.xcf
Binary file themes/grey/images/src/playbar-shadow.xcf has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/src/playbar.xcf
Binary file themes/grey/images/src/playbar.xcf has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/src/playhead.xcf
Binary file themes/grey/images/src/playhead.xcf has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/src/position-empty.xcf
Binary file themes/grey/images/src/position-empty.xcf has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/src/position-full.xcf
Binary file themes/grey/images/src/position-full.xcf has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/stop.png
Binary file themes/grey/images/stop.png has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/images/volume.png
Binary file themes/grey/images/volume.png has changed
diff -r 3b4aef1efff6 -r 3b817b961984 themes/grey/playlist.tpl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/grey/playlist.tpl Fri Aug 15 23:49:00 2008 -0400
@@ -0,0 +1,92 @@
+{**
+ * Template file for default Funky Monkey theme
+ * Web control interface script for Amarok
+ * Written by Dan Fuhry - 2008
+ *
+ * This script is in the public domain. Use it for good, not evil.
+ *}
+
+
+
+