public static function start($base_path = null) { if (self::$initialized) { return; } /* project root ********************/ //define( 'PROJECT_DIR', dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR); define('PROJECT_DIR', $base_path); define('API_DIR', PROJECT_DIR . 'inc' . DIRECTORY_SEPARATOR); define('APP_DIR', PROJECT_DIR . 'app' . DIRECTORY_SEPARATOR); define('VENDOR_DIR', PROJECT_DIR . 'vendor'); define('SF_EVENT_DIR', VENDOR_DIR . DIRECTORY_SEPARATOR . 'sfEvent' . DIRECTORY_SEPARATOR); define('LOCAL_API_DIR', PROJECT_DIR . 'localinc' . DIRECTORY_SEPARATOR); $root = dirname(dirname(__FILE__)); set_include_path(API_DIR . PATH_SEPARATOR . APP_DIR . PATH_SEPARATOR . VENDOR_DIR . PATH_SEPARATOR . SF_EVENT_DIR . PATH_SEPARATOR . LOCAL_API_DIR . PATH_SEPARATOR . get_include_path()); include 'autoload.php'; // Start sessions $sessions = api_session::getInstance(); // Construct URL for Web home (root of current host) $hostname = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; $hostinfo = self::getHostConfig($hostname); $schema = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ? 'https' : 'http'; $reqHostPath = '/'; if ($hostname != '') { $reqHostPath = $schema . '://' . $hostname; if (is_null($hostinfo)) { $reqHostPath .= '/'; } else { $reqHostPath .= $hostinfo['path']; } } define('API_HOST', $schema . '://' . $hostname . '/'); define('API_WEBROOT', $reqHostPath); define('API_MOUNTPATH', $hostinfo['path']); require_once PROJECT_DIR . "config/commandmap.php"; if (!function_exists('e')) { /** * This function is dynamically redefinable. * @see $GLOBALS['_global_function_callback_e'] */ function e($args) { $args = func_get_args(); return call_user_func_array($GLOBALS['_global_function_callback_e'], $args); } if (!isset($GLOBALS['_global_function_callback_e'])) { $GLOBALS['_global_function_callback_e'] = NULL; } } if (!function_exists('__')) { /** * This function is dynamically redefinable. * @see $GLOBALS['_global_function_callback___'] */ function __($args) { $args = func_get_args(); return call_user_func_array($GLOBALS['_global_function_callback___'], $args); } if (!isset($GLOBALS['_global_function_callback___'])) { $GLOBALS['_global_function_callback___'] = NULL; } } if (!function_exists('t')) { /** * This function is dynamically redefinable. * @see $GLOBALS['_global_function_callback_t'] */ function t($args) { $args = func_get_args(); return call_user_func_array($GLOBALS['_global_function_callback_t'], $args); } if (!isset($GLOBALS['_global_function_callback_t'])) { $GLOBALS['_global_function_callback_t'] = NULL; } } if (!function_exists('url')) { /** * This function is dynamically redefinable. * @see $GLOBALS['_global_function_callback_url'] */ function url($args) { $args = func_get_args(); return call_user_func_array($GLOBALS['_global_function_callback_url'], $args); } if (!isset($GLOBALS['_global_function_callback_url'])) { $GLOBALS['_global_function_callback_url'] = NULL; } } self::$initialized = true; }