/** * 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; }
/** * install serverを立ち上げる * * @param string $package_root パッケージ名 */ public static function handler() { $base_dir = Rhaco::path(); $request = new Request(); $tag = new Tag("rest"); if (preg_match("/^\\/state\\/(.+)\$/", $request->args(), $match)) { $tag->add(new Tag("package", $match[1])); if (self::parse_package($base_dir, $match[1], $tgz_filename)) { $tag->add(new Tag("status", "success")); $tag->output(); } } else { if (preg_match("/^\\/download\\/(.+)\$/", $request->args(), $match)) { if (self::parse_package($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; }
/** * リポジトリサーバの実行 */ public static function handler() { Log::disable_display(); $request = new Request("_inc_session_=false"); if (strpos($request->args(), "/check") === 0) { exit; } $repository = new Repository(); self::lib($repository); self::app($repository); Object::C(__CLASS__)->call_module("repository", $repository); foreach ($repository->names as $type) { if (preg_match("/^\\/" . $type . "\\/download\\/(.+)\$/", $request->args(), $match)) { if (self::is_tgz($type, $match[1], $filename)) { self::dl($filename); } } if (preg_match("/^\\/" . $type . "\\/state\\/(.+)\$/", $request->args(), $match)) { if (self::is_tgz($type, $match[1], $filename)) { exit; } } if (preg_match("/^\\/" . $type . "\\/list\$/", $request->args(), $match)) { print self::read_xml($type); exit; } if (preg_match("/^\\/" . $type . "\\/list\\/json\$/", $request->args(), $match)) { if (Tag::setof($tag, self::read_xml($type))) { Text::output_jsonp($tag, $request->in_vars("callback")); } } } Http::status_header(403); exit; }