/** * 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; }
/** * 文字列からattachする * @param string $path * @param string $filename */ public function attach_text($src, $filename = null) { Http::attach(new File($filename, $src)); exit; }
/** * 文字列からattachする * @param string $path * @param string $filename */ protected final function attach_text($src, $filename = null) { Http::attach(new File($filename, $src)); exit; }
private static function dl($filename) { Object::C(__CLASS__)->call_module("repository_download", $filename); if (self::is_remote()) { Http::redirect($filename); } Http::attach(new File($filename)); }