Noise科学虫洞

反代Github和jsdelivr进行加速

2023-07-13T12:39:11.png

使用方法

在PHP安装“fileinfo”扩展,然后在网站目录新建一个名为gh.php的文件,将下面的代码复制粘贴进去。然后访问:你的域名/gh.php?url=你要代理的URL地址

代码

<button class="copy dark:text-white absolute top-0 right-0 p-2 text-xs" style="box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; outline: none !important; font-family: inherit; font-size: 0.75rem; font-weight: inherit; line-height: 1rem; color: inherit; margin: 0px; padding: 0.5rem; text-transform: none; appearance: button; background-color: transparent; background-image: none; cursor: pointer; position: absolute; top: 0px; right: 0px; border: 0px solid #e5e7eb;" data-clipboard-text="<?php
if (isset($_GET['url']) == false) {
    die("请将参数填写完整,在当前路径后加上?url=反代的链接");
}

$token = (string) rand(100, 99999);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_GET['url']);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
if (isset($_SERVER['HTTP_REFERER']) == true) {
    curl_setopt($ch, CURLOPT_REFERER, $_SERVER['HTTP_REFERER']);
}
$data_down = curl_exec($ch);
if ($data_down === FALSE) {
    die("代理时发生错误");
}
curl_close($ch);
file_put_contents($token, $data_down);

// 使用finfo扩展获取文件的MIME类型
$finfo = new finfo(FILEINFO_MIME);
$mime_type = $finfo->file($token);

header('Content-Type: ' . $mime_type);
unlink($token);
echo $data_down;
?>"></button><?php
if (isset($_GET['url']) == false) {
die("请将参数填写完整,在当前路径后加上?url=反代的链接");
}

$token = (string) rand(100, 99999);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_GET['url']);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
if (isset($_SERVER['HTTP_REFERER']) == true) {
curl_setopt($ch, CURLOPT_REFERER, $_SERVER['HTTP_REFERER']);
}
$data_down = curl_exec($ch);
if ($data_down === FALSE) {
die("代理时发生错误");
}
curl_close($ch);
file_put_contents($token, $data_down);

// 使用finfo扩展获取文件的MIME类型
$finfo = new finfo(FILEINFO_MIME);
$mime_type = $finfo->file($token);

header('Content-Type: ' . $mime_type);
unlink($token);
echo $data_down;
?>

2023-07-13T12:39:11.png

Thoughts? Leave a comment