diff -r 5f35ebc4f9bb -r 3ba432f8390b greyhound.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/greyhound.php Sun Mar 23 23:17:06 2008 -0400 @@ -0,0 +1,87 @@ +#!/usr/bin/env php +template_dir = "./themes/$theme"; +$smarty->compile_dir = "./themes/$theme/compiled"; +$smarty->cache_dir = "./cache"; +$smarty->config_dir = "./config"; + +status('doing home directory detection'); + +// get home directory + +if ( !isset($_ENV['HOME']) ) +{ + burnout('Could not get your home directory'); +} + +$homedir =& $_ENV['HOME']; + +status('initializing playlist'); + +// init playlist object +$playlist = array(); +rebuild_playlist(); + +// startup webserver +$ip = ( $public ) ? '0.0.0.0' : '127.0.0.1'; +$port = 7447; + +try +{ + status('starting PhpHttpd'); + $httpd = new WebServer($ip, $port); + + // setup handlers + status('initializing handlers'); + $httpd->add_handler('index', 'function', 'amarok_playlist'); + $httpd->add_handler('action.json', 'function', 'ajax_request_handler'); + $httpd->add_handler('scripts', 'dir', './scripts'); + $httpd->add_handler('favicon.ico', 'file', './amarok_icon.ico'); + $httpd->add_handler('apple-touch-icon.png', 'file', './apple-touch-icon.png'); + $httpd->add_handler("themes/$theme", 'dir', "./themes/$theme"); + $httpd->allow_dir_list = true; + $httpd->default_document = 'index'; + + status("Entering main server loop - ^C to interrupt, listening on port $port"); + $httpd->serve(); +} +catch( Exception $e ) +{ + burnout("Exception caught while running webserver:\n$e"); +} +