php开发一套随机调取全网壁纸内容

   php开发一套随机调取全网壁纸内容,核心代码如下

<?php
//ini_set("display_errors", "On");
//error_reporting(E_ALL | E_STRICT);
//if(!defined("a")) exit("Error 001");
//获取当前主域名
$domainurl="http://".$_SERVER['SERVER_NAME'];
$listnum = array('①','②','③','④','⑤','⑥','⑦','⑧','⑨','⑩');
$myurl = myurl();
if(isset($_GET['q'])){
	$q = hd_clearStr($_GET['q']);	
}
if(isset($_GET['p'])){
	$p=$_GET['p'];
	if($p>50){
	   $p=50;	
	}
	if(REWRITE==1 && strpos(URLRULE2,'{qe}')>-1 && strpos($myurl,'q=')<1&&  strpos($myurl,'more=1')<1){
		$q = qdecode($q);
        $q = htmlspecialchars($q);
	}
}else{
	$p=1;
	if(REWRITE==1 && strpos(URLRULE1,'{qe}')>-1 && strpos($myurl,'q=')<1&&  strpos($myurl,'more=1')<1){
		$q = qdecode($q);
        $q = htmlspecialchars($q);
	}
}
$s = urlencode($q);
?>
<!doctype html>
<html>
<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<link rel="canonical" href="<?php echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?>">
		<title><?php  echo $q; if($p!=1){echo '_第'.$p.'页';}?> - <?php echo $huoduan['sitename']?></title>
		<meta name="keywords" content="<?php echo $q.",在线".$q;?>下载" />
		<meta name="description" content="<?php echo $huoduan['sitename']."为您提供".$q."相关壁纸,包括".$q."最新壁纸下载,让你更好更全面的获取".$q."精美壁纸!";?>" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta name="robots" content="index,follow"/>
		<meta name="referrer" content="no-referrer" />
		<link rel="stylesheet" href="css/wallpaper.css">
		<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
</head>
<body>

<nav class="navbar navbar-expand-sm xben-nav  navbar-light fixed-top">
		<a class="navbar-brand xben-title" href="http://www.kaotop.com/bizhi/" >壁纸网</a>
		<button class="navbar-toggler xben-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
				<span class="navbar-toggler-icon"></span>
		</button>
		<div class="collapse navbar-collapse " id="collapsibleNavbar">
				<ul class="navbar-nav">
						<li class="nav-item">
								<a class="nav-link" href="javascript:void(0)"
									onclick="loadData('360new', true);changeTitle(this)">最新壁纸</a>
						</li>
						<li class="nav-item dropdown">
								<a class="nav-link dropdown-toggle" href="#" id="navbardrop" data-toggle="dropdown">
										分类壁纸
								</a>
								<div class="dropdown-menu xben-dropdown-menu" id="xbenTags">

								</div>
						</li>
						<li class="nav-item">
								<a class="nav-link" href="javascript:void(0)"
									onclick="loadData('bing', true);changeTitle(this)">必应美图</a>
						</li>
						<li class="nav-item">
								<a class="nav-link" href="javascript:void(0)" onclick="loadData('ciba', true);changeTitle(this);"
									title="金山词霸每日一句壁纸">每日英语</a>
						</li>
							<?php 
							$huoduan['hotkeytype']==1;
										$filename=randtxt();
										$diykey = file_get_contents(ROOT_PATH.'/data/sitemap/'.$filename);
										if(strpos($diykey,"\r\n")>-1){
											$diylist = explode("\r\n",$diykey);
										}else{
												$diylist = explode("\n",$diykey);
										}
										shuffle($diylist);
										if(is_array($diylist)){
											$count = count($diylist);
											if($count>10){
													$j = 3;
											}else{
													$j = $count;
											}
											for($i=0;$i<$j;$i++){
						    echo '<li class="nav-item">';
														echo '<a class="nav-link" href="'.huoduansourl($diylist[$i]).'">'.$diylist[$i].'</a>'; 
							echo "</li>";
												} 
										} 
						?>
			<li class="nav-item">
						<a class="nav-link"  href="http://www.kaotop.com/bizhi/sitemap/">壁纸大全</a>
						</li>

				</ul>

		</div>
</nav>
<div class="xben-container">

		<div class="jigsaw" id="walBox"></div>  <!-- id="walBox" -->

		<a id="toolBall" target="_blank" href="javascript:void(0);" class="uptoTop"></a>

		<div id="loadmore">壁纸加载中……</div>
	<div class="xben-full-img"><img
						src="http://cdn-ali-img-staticbz.shanhutech.cn/bizhi/staticwp/202003/9bd0be8ab5506a7902f36eb4da95ebc1--3977944025.jpg"/>
		<button class="horizontal-btn btn btn-primary">横屏显示</button>
</div>
</div>
<!-- jQuery文件 -->
<script src="https://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
<!--滚动加载插件-->
<script type="text/javascript" src="js/jquery.lazyload.min.js"></script>
<!--全屏滚动插件-->
<script type="text/javascript" src="js/jquery.onepage-scroll.min.js"></script>
<!--页面核心js文件-->
<script type="text/javascript" src="js/wallpaper.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
</body>

  接口代码:

   

<?php

$cid = getParam('cid', '360new');

switch($cid)
{
    case '360new':  // 360壁纸 新图片
        $start = getParam('start', 0);
        $count = getParam('count', 10);
		echojson (file_get_contents("http://wp.birdpaper.com.cn/intf/newestList?pageno={$start}&count={$count}"));
    break;
    case '360tags':
	   echojson (file_get_contents("http://wp.birdpaper.com.cn/intf/getCategory"));
	   
    break;
    
    case 'bing':
        $start = getParam('start', -1);
        $count = getParam('count', 8);
        echojson (file_get_contents("http://cn.bing.com/HPImageArchive.aspx?format=js&idx={$start}&n={$count}"));
    break;
	
	case '360search':
	    $content = getParam('content', '');
        $start = getParam('start', 0);
        $count = getParam('count', 10);
        echojson (file_get_contents("http://wp.birdpaper.com.cn/intf/search?content={$content}&pageno={$start}&count={$count}"));
    break;
    
    default:
        $start = getParam('start', 0);
        $count = getParam('count', 10);
	   echojson (file_get_contents("http://wp.birdpaper.com.cn/intf/GetListByCategory?cids={$cid}&pageno={$start}&count={$count}"));
        
}


/**
 * 获取GET或POST过来的参数
 * @param $key 键值
 * @param $default 默认值
 * @return 获取到的内容(没有则为默认值)
 */
function getParam($key,$default='')
{
    return trim($key && is_string($key) ? (isset($_POST[$key]) ? $_POST[$key] : (isset($_GET[$key]) ? $_GET[$key] : $default)) : $default);
}

/**
 * 输出一个json或jsonp格式的内容
 * @param $data 数组内容
 */
function echojson($data)    //json和jsonp通用
{
    // $callback = getParam('callback');
    // if($callback != "") //输出jsonp格式
    // {
    //     echo $callback."(".$data.")";
    // }
    // else
    // {
        echo $data;
    // }
}

  演示地址:http://www.kaotop.com/bizhi/

posted @ 2021-11-01 22:53  圆柱模板  阅读(198)  评论(0编辑  收藏  举报