yun
走过山时山不说话,路过海时海不说话
图片强制外链源码

access_time
brush 30个字
whatshot 50 ℃

图片强制外链referer源码,调用方法:

name.php?pic=图片url

源码:保存为php上传到网站目录,调用即可

<?php
header("Content-Type:image/jpeg");
@$picurl = $_GET['pic'];
echo getnepianImg($picurl);
function getnepianImg($url){
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data=curl_exec($ch);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, '20');
return $data;
curl_close($ch);}

=====================================================

<?php

$url=empty($_GET['url'])?'':trim(urldecode($_GET['url']));
if(empty($url))die('?url=');
$new_name = new_name($url);
if(file_exists($new_name)){header('location:'.$new_name);return;}
$type = get_type($url);
header('Content-type: image/'.$type);
$content = file_get_contents($url);
//file_put_contents($new_name,$content);
echo $content;

function new_name($url){

$url = strtr($url,array(':'=>'','//'=>'','/'=>'_'));
return 'uploads/cache/'.$url;

}
function get_type($url){

$type=substr(strrchr($url,"."),1);
if(in_array($type,array('png','gif','bmp','webp','jpg')))return $type;
return 'jpeg';

}
?>

=======================================================================

<?php 

$url = $_GET["url"];
//$url = str_replace("http:/","http://",$url);
$dir = pathinfo($url);
$host = $dir['dirname'];
$refer = $host.'/';
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_REFERER, $refer);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//Activation can modify the page
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
header("Content-type: image/jpeg");//Code to support jpeg, need to modify to support other image formats
print( $data );

?>

#如无特别声明,该文章均为 yun 原创,转载请遵循 署名-非商业性使用 4.0 国际(CC BY-NC 4.0) 协议,即转载请注明文章来源。
#最后编辑时间为: 2022 年 03 月 20 日


account_circle
email
explore


关于 DreamCat

主题名称:DreamCat | 版本:X1.9-20210218

主题开发:HanFengA7 | TeddyNight | Dev-Leo | CornWorld | WBStudio | 学神之女

Designed by HanFengA7 Power by Typecho

Copyright © 2015-2021 by LychApe All rights reserved!

加我的QQ
加我的微博
加我的支付宝
加我的微信
加我的QQ
加我的微博
加我的支付宝
加我的微信