-
Notifications
You must be signed in to change notification settings - Fork 264
/
Show.php
executable file
·52 lines (47 loc) · 1.64 KB
/
Show.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
// +----------------------------------------------------------------------
// | [RhaPHP System] Copyright (c) 2017 http://www.rhaphp.com/
// +----------------------------------------------------------------------
// | [RhaPHP] 并不是自由软件,你可免费使用,未经许可不能去掉RhaPHP相关版权
// +----------------------------------------------------------------------
// | Author: Geeson <qimengkeji@vip.qq.com>
// +----------------------------------------------------------------------
namespace app\mp\controller;
class Show
{
/**
* @param string $url
*/
public function image($url = '')
{
if (strpos($url, 'http') === false || strpos($url, 'http') != 0) {
exit('非法协议');
}
$url = urldecode($url);
if (!empty($Arr = explode('wx_fmt=', $url))) {
if (empty($Arr[0])) {
exit('非法资源');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
$file = curl_exec($ch);
curl_close($ch);
$types = array(
'gif' => 'image/gif',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'png' => 'image/png',
);
if (isset($Arr[1]) && key_exists($Arr[1], $types)) {
$type = $types[$Arr[1]];
} else {
$type = 'image/jpeg';
}
header("Content-type: " . $type);
echo $file;
exit();
}
}
}