# HG changeset patch # User Dan # Date 1206544220 14400 # Node ID b5db2345c3970b1a45833aa6b9727131a2c907ad # Parent b3fcc21e557f76c951d15fd8b68c9235d9480051 Added PHP feature check to prevent script from throwing unneeded exceptions on unsupported PHP configurations diff -r b3fcc21e557f -r b5db2345c397 functions.php --- a/functions.php Wed Mar 26 10:24:20 2008 -0400 +++ b/functions.php Wed Mar 26 11:10:20 2008 -0400 @@ -44,6 +44,18 @@ } /** + * Print a stylized warning message, compatible with Linux consoles + * @param string message message + */ + +function warning($msg) +{ + $h = @fopen('php://stderr', 'w'); + fwrite($h, "\x1B[33;1m[Greyhound] \x1B[0m\x1B[33mWarning:\x1B[0m $msg\n"); + fclose($h); +} + +/** * Performs an action with DCOP. * @param string DCOP component, e.g. player, playlist, playlistbrowser, ... * @param string Action to perform, e.g. stop, play, ... diff -r b3fcc21e557f -r b5db2345c397 greyhound.php --- a/greyhound.php Wed Mar 26 10:24:20 2008 -0400 +++ b/greyhound.php Wed Mar 26 11:10:20 2008 -0400 @@ -85,6 +85,11 @@ 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 diff -r b3fcc21e557f -r b5db2345c397 scripts/ajax.js --- a/scripts/ajax.js Wed Mar 26 10:24:20 2008 -0400 +++ b/scripts/ajax.js Wed Mar 26 11:10:20 2008 -0400 @@ -293,6 +293,10 @@ { var count_seconds = time % 60; var count_minutes = ( time - count_seconds ) / 60; + if ( isNaN(count_seconds) ) + count_seconds = 0; + if ( isNaN(count_minutes) ) + count_minutes = 0; return fill_zeroes(count_minutes) + ':' + fill_zeroes(count_seconds); } @@ -335,13 +339,16 @@ $(booby).rmClass(match[2]); } } + // recalculate list of rows that should pulse var tdlist_new = document.getElementsByClassName('current', 'tr'); if ( pulsar_current == 0 && tdlist_new == pulsar_tdlist ) { return true; } + // reset everything to 0 pulsar_tdlist = tdlist_new; pulsar_current = 0; + pulsar_direction = 1; for ( var i = 0; i < pulsar_tdlist.length; i++ ) { var td = pulsar_reset[i]; @@ -361,6 +368,10 @@ var pulsar_advance = function() { + // this should be as optimized as possible, it should use a precalculated + // list of elements to pulse and whatnot... heck even right now it's not + // really as optimized as it should be due to the logic, but a lot of it's + // kinda more or less necessary. if ( !is_playing ) return true; if ( pulsar_current + pulsar_direction == 10 ) diff -r b3fcc21e557f -r b5db2345c397 webserver.php --- a/webserver.php Wed Mar 26 10:24:20 2008 -0400 +++ b/webserver.php Wed Mar 26 11:10:20 2008 -0400 @@ -105,6 +105,12 @@ @set_time_limit(0); @ini_set('memory_limit', '256M'); + // do we have socket functions? + if ( !function_exists('socket_create') ) + { + burnout('System does not support socket functions. Please rebuild your PHP or install an appropriate extension.'); + } + $this->sock = socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp')); if ( !$this->sock ) throw new Exception('Could not create socket');