array('somearg', 'otherarg'), * key => val * otherkey => val * third => val * fourth => val */ if(isset($_SERVER['argv'][2])) { $args = array_slice($_SERVER['argv'],2); $_GET = array(); foreach($args as $arg) { if(strpos($arg,'=') == false) { $_GET['args'][] = $arg; } else { $newItems = array(); parse_str( (substr($arg,0,2) == '--') ? substr($arg,2) : $arg, $newItems ); $_GET = array_merge($_GET, $newItems); } } $_REQUEST = $_GET; } /** * Include Sapphire's core code */ require_once("core/Core.php"); global $databaseConfig; // We don't have a session in cli-script, but this prevents errors $_SESSION = null; // Connect to database require_once("core/model/DB.php"); DB::connect($databaseConfig); // Get the request URL from the querystring arguments $url = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : null; if(!$url) { echo 'Please specify an argument to cli-script.php/sake. For more information, visit http://doc.silverstripe.org/doku.php?id=sake'; die(); } $_SERVER['REQUEST_URI'] = BASE_URL . '/' . $url; // Direct away - this is the "main" function, that hands control to the apporopriate controller Director::direct($url); ?>