/** * package serverを立ち上げる * * @param string $package_root パッケージ名 */ public static function handler($package_root = null) { if (empty($package_root) || Rhaco::path() == "") { $debug = debug_backtrace(); $first_action = array_pop($debug); if ($package_root === null) { $package_root = basename(dirname($first_action["file"])); } if (Rhaco::path() == "") { Rhaco::init($first_action["file"]); } } $base_dir = Rhaco::path(); $request = new Request(); $package_root_path = str_replace(".", "/", $package_root); $preg_quote = (empty($package_root_path) ? "" : preg_quote($package_root_path, "/") . "\\/") . "(.+)"; $tag = new Tag("rest"); if (preg_match("/^\\/state\\/" . $preg_quote . "\$/", $request->args(), $match)) { $tag->add(new Tag("package", $match[1])); if (self::parse_package($package_root_path, $base_dir, $match[1], $tgz_filename)) { $tag->add(new Tag("status", "success")); $tag->output(); } } else { if (preg_match("/^\\/download\\/" . $preg_quote . "\$/", $request->args(), $match)) { if (self::parse_package($package_root_path, $base_dir, $match[1], $tgz_filename)) { Http::attach(new File($tgz_filename)); } } } Http::status_header(403); $tag->add(new Tag("status", "fail")); $tag->output(); exit; }
/** * アプリケーションの環境設定を行う * * @param string $path * @param string $url * @param string $lib * @param string $work */ function application_settings($path, $url = null, $lib = null, $work = null) { Rhaco::init($path, $url, $lib, $work); }