diff --git a/HostOption.php b/HostOption.php new file mode 100644 index 0000000..8f910f6 --- /dev/null +++ b/HostOption.php @@ -0,0 +1,12 @@ + array('Authorization: token TOKEN') + ); + public static function get(string $key) { + return array_key_exists($key, self::$values) ? self::$values[$key] : false; + } +} + +?> diff --git a/PatchBase.php b/PatchBase.php index 384e313..c34056a 100644 --- a/PatchBase.php +++ b/PatchBase.php @@ -1,5 +1,7 @@ array('user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:1.0) Gecko/20200101 Patchbot/1.0')); + if (HostOption::get($host)) + $opt['http'] += array('header' => HostOption::get($host)); $ctx = stream_context_create($opt); - if ($str = file_get_contents($url, false, $ctx)) { + if ($str = @file_get_contents($url, false, $ctx)) { $this->data = $str; if ($json) { if (!($this->data = json_decode($str, true)))