<?php
//读取文本
$var = $_GET['type'];
if ($var == 'mobile') {
  $text = 'mobile';
} else {
  $text = 'pc';
}
//这里可以分开PC端和手机端的图片获取

$str = explode("\n", file_get_contents('imgs.log'));
$k = rand(0,count($str));
$imgs = str_re($str[$k]);
$url = 'yoururl'.'/'.$imgs.'.jpg';
//这里填你的图片链接地址，其中随机的是img部分

//解析结果
$result=array("code"=>"200","imgurl"=>"$url");
 
//Type Choose参数代码
$type=$_GET['return'];
switch ($type)
{   
    
//Json格式解析
case 'json':
$imageInfo = getimagesize($url);  
$result['width']="$imageInfo[0]";  
$result['height']="$imageInfo[1]";  
header('Content-type:text/json');
echo json_encode($result);  
break;
//IMG
default:
header("Location:".$result['imgurl']);
break;
}
function str_re($str){
  $str = str_replace(' ', "", $str);
  $str = str_replace("\n", "", $str);
  $str = str_replace("\t", "", $str);
  $str = str_replace("\r", "", $str);
  return $str;
}
?>