随机图片API源码,获取本地存储图片非某浪的外链

图片是直接获取服务器本地子文件夹的图片
美女(2935张):https://nnns.cc/meinv.php
风景(3000张):https://nnns.cc/fengjing.php
动漫(2656张):https://nnns.cc/dongman.php
参数:type=302302跳转原图:https://nnns.cc/dongman.php?type=302
<?php
//img为图片的文件夹,可以自定义修改
$img_array = glob("img/*.{gif,jpg,png}",GLOB_BRACE);
//把下面的链接更换为自己的链接
$url = 'nnns.cc';
$img = array_rand($img_array);
$result['error']=0;
$result['result']=200;
$result['img']='http://'.$url.'/'.$img_array[$img];
$type=$_GET['type'];
switch ($type)
{
case '302':
header("Location:".$result['img']);
break;
default:
echo '<img alt="'.$result['img'].'" src="'.$result['img'].'" />';
break;
}
设置为网站图片背景
<style type=text/css>
body {background-image:url(https://nnns.cc/dongman.php?type=302);
background-repeat:repeat;
background-attachment:fixed;
background-position:50% 50%;
}
</style>