UCHome 网站首页index.php页面代码分析

<?php
02./*
03.    [UCenter Home] (C) 2007-2008 Comsenz Inc.
04.    $Id: index.php 2009-10-7 20:44:00
05.    @author ymaozi
06.    @copyright http://www.codedesign.cn
07.    @deprecated uchome源码交流QQ群:83400173
08.*/
09. 
10.include_once('./common.php'); //引入公共文件
11. 
12.//is_numeric();检测变量是否为数字
13.if(is_numeric($_SERVER['QUERY_STRING'])) {
14.    showmessage('enter_the_space', "space.php?uid=$_SERVER[QUERY_STRING]", 0);
15.}
01.//二级域名
02.if(!isset($_GET['do']) &amp;&amp; $_SCONFIG['allowdomain']) {
03.    $hostarr = explode('.', $_SERVER['HTTP_HOST']);
04.    $domainrootarr = explode('.', $_SCONFIG['domainroot']);
05.    if(count($hostarr) > 2 &amp;&amp; count($hostarr) > count($domainrootarr) &amp;&amp; $hostarr[0] != 'www' &amp;&amp; !isholddomain($hostarr[0])) {
06.        showmessage('enter_the_space', $_SCONFIG['siteallurl'].'space.php?domain='.$hostarr[0], 0);
07.    }
08.}
09. 
10.if($_SGLOBAL['supe_uid']) {
11.    //已登录,直接跳转个人首页
12.    showmessage('enter_the_space', 'space.php?do=home', 0);
13.}
14. 
15.if(empty($_SCONFIG['networkpublic'])) { //是否公开”随便看看“页面
16. 
17.    $cachefile = S_ROOT.'./data/cache_index.txt'; //获取首页缓存文件
18.    $cachetime = @filemtime($cachefile); //缓存文件创建时间
19. 
20.    $spacelist = array();   //空间数组
21.    if($_SGLOBAL['timestamp'] - $cachetime > 900) {  //如果当前时间减去文件创建时间大于900秒
22.        //20位热门用户
23.        $query = $_SGLOBAL['db']->query("SELECT s.*, sf.resideprovince, sf.residecity
24.            FROM ".tname('space')." s
25.            LEFT JOIN ".tname('spacefield')." sf ON sf.uid=s.uid
26.            ORDER BY s.friendnum DESC LIMIT 0,20"); //通过好友数排序,取前20名
27.        while ($value = $_SGLOBAL['db']->fetch_array($query)) {
28.            $spacelist[] = $value;
29.        }
30.        swritefile($cachefile, serialize($spacelist)); //将空间数组通过serialize()转换成字符串后存入到文件中,作为缓存文件
31.    } else {
32.        $spacelist = unserialize(sreadfile($cachefile));//通过unserialize();将已序列化的字符串,转换成数组
33.    }
34. 
35.    //应用
36.    //获取安装的应用数
37.    $myappcount = 0;
38.    $myapplist = array();
39.    if($_SCONFIG['my_status']) {
40.        $myappcount = $_SGLOBAL['db']->result($_SGLOBAL['db']->query("SELECT COUNT(*) FROM ".tname('myapp')." WHERE flag>='0'"), 0);
41.        if($myappcount) {
42.            $query = $_SGLOBAL['db']->query("SELECT appid,appname FROM ".tname('myapp')." WHERE flag>=0 ORDER BY flag DESC, displayorder LIMIT 0,7");
43.            while ($value = $_SGLOBAL['db']->fetch_array($query)) {
44.                $myapplist[] = $value;
45.            }
46.        }
47.    }
48. 
49.    //实名
50.    foreach ($spacelist as $key => $value) {
51.        realname_set($value['uid'], $value['username'], $value['name'], $value['namestatus']); //如果姓名存在则获取姓名,否则获取用户名
52.    }
53.    //获取实名
54.    realname_get();
55. 
56.    $_TPL['css'] = 'network';//设置文件的css
57.    include_once template("index"); //引入模板文件
58.} else {    //如果不公开"随便看看",则直接引入network.php文件
59.    include_once(S_ROOT.'./source/network.php');
60.}
61. 
62.?>

posted on 2010-01-26 16:42  14的路  阅读(1429)  评论(0编辑  收藏  举报

导航

友情链接:源码下载