$desktopFolder = 'desktop';
$mobileFolder = 'mobile';
function isMobileDevice() {
$user_agent = $_SERVER['HTTP_USER_AGENT'];
'android', 'iphone', 'ipad', 'ipod', 'blackberry', 'windows ce', 'opera mini',
'webos', 'symbian', 'windows phone', 'iemobile', 'mobile', 'palm', 'palmos',
'pocket', 'psp', 'series', 'playstation', 'nintendo', 'gameboy', 'macintosh'
foreach ($mobile_agents as $agent) {
if (stripos($user_agent, $agent) !== false) {
$imageFolder = isMobileDevice() ? $mobileFolder : $desktopFolder;
$imageFiles = glob($imageFolder . '/*.{jpg,jpeg,png,gif}', GLOB_BRACE);
if (count($imageFiles) > 0) {
$randomImage = $imageFiles[array_rand($imageFiles)];
$imageInfo = getimagesize($randomImage);
$mime = $imageInfo['mime'];
header('Content-Type: ' . $mime);
暂无评论