【UCHome二次开发】全局变量



    UCHome定义了一些全局变量保存常用信息,了解这些变量存放的内容将大大方便我们的二次开发。

    以下依次罗列各全局变量所保存的内容



    以上个别全局变量在不同页面的值会有所不同,使用前最好先测试一下值是否存在。

    下面是用print_r函数打印出来的各全局变量信息,方便参考(为节省篇幅,删除了部分结构重复的数据):

    $_SC:系统全局配置

    $_SC: Array
    (
      [dbhost] => localhost
      [dbuser] => root
      [dbpw] => root
      [dbcharset] => utf8
      [pconnect] => 0
      [dbname] => uchome
      [tablepre] => uchome_
      [charset] => utf-8
      [gzipcompress] => 0
      [cookiepre] => uchome_
      [cookiedomain] =>
      [cookiepath] => /
      [attachdir] => ./attachment/
      [attachurl] => attachment/
      [siteurl] => http://localhost/uchome/
      [tplrefresh] => 0
      [founder] => 1
      [allowedittpl] => 0
    )

    返回文章头部

    $_SCONFIG:个人空间配置

    $_SCONFIG: Array
    (
      [sitename] => 我的空间
      [sitelogo] => image/logo.gif
      [template] => default
      [adminemail] => webmaster@localhost
      [onlinehold] => 1800
      [timeoffset] => 8
      [maxpage] => 50
      [starcredit] => 100
      [starlevelnum] => 5
      [cachemode] => database
      [cachegrade] => 0
      [allowcache] => 1
      [allowdomain] => 0
      [allowrewrite] => 0
      [allowwatermark] => 0
      [allowftp] => 0
      [holddomain] => www|*blog*|*space*|x
      [mtagminnum] => 5
      [feedday] => 15
      [feedmaxnum] => 50
      [feedfilternum] => 10
      [importnum] => 100
      [singlesent] => 50
      [groupnum] => 8
      [closeregister] => 0
      [closeinvite] => 0
      [close] => 0
      [networkpublic] => 1
      [networkpage] => 1
      [networkupdate] => 300
      [seccode_register] => 1
      [uc_tagrelated] => 1
      [manualmoderator] => 1
      [linkguide] => 1
      [showall] => 1
      [sendmailday] => 0
      [realname] => 0
      [namecheck] => 0
      [namechange] => 0
      [name_allowfriend] => 1
      [name_allowpoke] => 1
      [name_allowdoing] => 1
      [name_allowblog] => 1
      [name_allowalbum] => 1
      [name_allowthread] => 1
      [name_allowshare] => 1
      [name_allowcomment] => 1
      [name_allowpost] => 1
      [showallfriendnum] => 10
      [feedtargetblank] => 1
      [feedread] => 1
      [uc_tagrelatedtime] => 86400
      [privacy] => Array
        (
          [view] => Array
            (
              [index] => 0
              [profile] => 0
              [friend] => 0
              [wall] => 0
              [feed] => 0
              [doing] => 0
              [blog] => 0
              [album] => 0
              [share] => 0
              [mtag] => 0
            )
    
          [feed] => Array
            (
              [doing] => 1
              [blog] => 1
              [album] => 1
              [upload] => 1
              [share] => 1
              [thread] => 1
              [post] => 1
              [mtag] => 1
              [friend] => 1
              [comment] => 1
              [trace] => 1
            )
    
        )
    
      [cronnextrun] => 1254829800
      [my_status] => 0
      [sitekey] => 2a37854626AdS662
      [siteallurl] => http://localhost/uchome/
      [licensed] => 0
      [debuginfo] => 0
      [miibeian] =>
      [headercharset] => 0
      [avatarreal] => 0
      [uc_dir] =>
      [my_ip] =>
      [closereason] =>
      [feeddefaultfilter] => all
      [my_closecheckupdate] => 0
      [spacebarusername] =>
      [defaultfusername] =>
      [domainroot] =>
      [ftpurl] =>
      [login_action] => 1812d4b322672381d1dc7396a8a52ef7
      [register_action] => 0d7f87d7c19770cac7d20679586b362f
    )

    返回文章头部

    $_SCOOKIE:Cookie信息

    $_SCOOKIE: Array
    (
      [loginuser] => admin
      [checkpm] => 1
      [synfriend] => 1
      [sendmail] => 1
      [auth] => 61087Cgwu3hoB35cDmXGpe3juvbjJQC2e+wlWJ79GPejIYhB1j/d9VwyKGy8DPYcKQCHUYvYg+EBqJoQS5Vc
    )

    返回文章头部

    $_SGLOBAL:各类全局信息

    $_SGLOBAL: Array
    (
      [timestamp] => 1254829664
      [supe_starttime] => 1254829664.1719
      [db] => dbstuff Object
        (
          [querynum] => 3
          [link] => Resource id #7
          [charset] => utf8
        )
    
      [app] => Array
        (
          [1] => Array
            (
              [name] => 枫芸志
              [url] => http://localhost/bbs
              [type] => DISCUZ
              [open] => 1
              [icon] => discuz
            )
    
          [2] => Array
            (
              [name] => 个人家园
              [url] => http://localhost/uch
              [type] => UCHOME
              [open] => 0
              [icon] => uchome
            )
    
        )
    
      [userapp] => Array
        (
        )
    
      [ad] => Array
        (
        )
    
      [supe_uid] => 1
      [supe_username] => admin
      [inajax] => 0
      [ajaxmenuid] =>
      [refer] => http://localhost/uchome/space.php?do=mtag
      [session] => Array
        (
          [uid] => 1
          [username] => admin
          [password] => 8ae86ee69cba169f8691011ea3c5691f
          [lastactivity] => 1254829662
          [ip] => 127000000
        )
    
      [username] => admin
      [my_menu] => Array
        (
        )
    
      [my_userapp] => Array
        (
        )
    
      [my_menu_more] => 0
      [appmenu] => Array
        (
          [name] => 枫芸志
          [url] => http://localhost/bbs
          [type] => DISCUZ
          [open] => 1
          [icon] => discuz
        )
    
      [appmenus] => Array
        (
        )
    
      [member] => Array
        (
          [uid] => 1
          [sex] => 0
          [email] =>
          [emailcheck] => 0
          [qq] =>
          [msn] =>
          [birthyear] => 0
          [birthmonth] => 0
          [birthday] => 0
          [blood] =>
          [marry] => 0
          [birthprovince] =>
          [birthcity] =>
          [resideprovince] =>
          [residecity] =>
          [note] =>
          [spacenote] =>
          [authstr] =>
          [theme] =>
          [nocss] => 0
          [menunum] => 0
           =>
          [privacy] => Array
            (
              [view] => Array
                (
                  [index] => 0
                  [profile] => 0
                  [friend] => 0
                  [wall] => 0
                  [feed] => 0
                  [doing] => 0
                  [blog] => 0
                  [album] => 0
                  [share] => 0
                  [mtag] => 0
                )
    
              [feed] => Array
                (
                  [doing] => 1
                  [blog] => 1
                  [album] => 1
                  [upload] => 1
                  [share] => 1
                  [thread] => 1
                  [post] => 1
                  [mtag] => 1
                  [friend] => 1
                  [comment] => 1
                  [trace] => 1
                )
    
            )
    
          [friend] =>
          [feedfriend] =>
          [sendmail] =>
          [groupid] => 1
          [credit] => 0
          [username] => admin
          [name] =>
          [namestatus] => 0
          [domain] =>
          [viewnum] => 0
          [notenum] => 0
          [friendnum] => 0
          [dateline] => 1245599521
          [updatetime] => 0
          [lastsearch] => 0
          [lastpost] => 0
          [lastlogin] => 1254829560
          [lastsend] => 0
          [attachsize] => 0
          [addsize] => 0
          [flag] => 1
          [newpm] => 0
          [avatar] => 0
          [ip] => 127000000
          [mood] => 0
          [self] => 1
          [friends] => Array
            (
            )
    
        )
    
      [space_1_uid] => Array
        (
          [uid] => 1
          [sex] => 1
          [email] =>
          [emailcheck] => 0
          [qq] =>
          [msn] =>
          [birthyear] => 0
          [birthmonth] => 0
          [birthday] => 0
          [blood] =>
          [marry] => 0
          [birthprovince] =>
          [birthcity] =>
          [resideprovince] =>
          [residecity] =>
          [note] =>
          [spacenote] =>
          [authstr] =>
          [theme] => t10
          [nocss] => 0
          [menunum] => 0
           =>
          [privacy] => Array
            (
              [view] => Array
                (
                  [index] => 0
                  [profile] => 0
                  [friend] => 0
                  [wall] => 0
                  [feed] => 0
                  [doing] => 0
                  [blog] => 0
                  [album] => 0
                  [share] => 0
                  [mtag] => 0
                )
    
              [feed] => Array
                (
                  [doing] => 1
                  [blog] => 1
                  [album] => 1
                  [upload] => 1
                  [share] => 1
                  [thread] => 1
                  [post] => 1
                  [mtag] => 1
                  [friend] => 1
                  [comment] => 1
                  [trace] => 1
                )
    
            )
    
          [friend] =>
          [feedfriend] =>
          [sendmail] =>
          [groupid] => 1
          [credit] => 0
          [username] => admin
          [name] => 晴枫
          [namestatus] => 1
          [domain] =>
          [viewnum] => 0
          [notenum] => 0
          [friendnum] => 0
          [dateline] => 1245599521
          [updatetime] => 0
          [lastsearch] => 0
          [lastpost] => 0
          [lastlogin] => 1254831926
          [lastsend] => 0
          [attachsize] => 0
          [addsize] => 0
          [flag] => 1
          [newpm] => 0
          [avatar] => 0
          [ip] => 127000000
          [mood] => 0
          [self] => 1
          [friends] => Array
            (
            )
    
        )
    
      [profield] => Array
        (
          [1] => Array
            (
              [fieldid] => 1
              [title] => 自由联盟
              [note] =>
              [formtype] => text
              [inputnum] => 100
              [choice] =>
              [mtagminnum] => 0
              [manualmoderator] => 0
              [manualmember] => 1
              [displayorder] => 0
            )
    
          [2] => Array
            (
              [fieldid] => 2
              [title] => 地区联盟
              [note] =>
              [formtype] => text
              [inputnum] => 100
              [choice] =>
              [mtagminnum] => 0
              [manualmoderator] => 0
              [manualmember] => 1
              [displayorder] => 0
            )
    
        )
    
      [usergroup] => Array
        (
    
          [1] => Array
            (
              [gid] => 1
              [grouptitle] => 站点管理员
              [system] => -1
              [creditlower] => 0
              [maxfriendnum] => 0
              [maxattachsize] => 0
              [allowhtml] => 1
              [allowcomment] => 1
              [searchinterval] => 0
              [postinterval] => 0
              [allowblog] => 1
              [allowdoing] => 1
              [allowupload] => 1
              [allowshare] => 1
              [allowmtag] => 1
              [allowthread] => 1
              [allowpost] => 1
              [allowcss] => 1
              [allowpoke] => 1
              [allowfriend] => 1
              [allowtrace] => 1
              [edittrail] => 0
              [domainlength] => 1
              [closeignore] => 1
              [seccode] => 0
              [color] => red
              [icon] => image/group/admin.gif
              [manageconfig] => 1
              [managenetwork] => 1
              [manageprofilefield] => 1
              [manageprofield] => 1
              [manageusergroup] => 1
              [managefeed] => 1
              [manageshare] => 1
              [managedoing] => 1
              [manageblog] => 1
              [managetag] => 1
              [managetagtpl] => 0
              [managealbum] => 1
              [managecomment] => 1
              [managemtag] => 1
              [managethread] => 1
              [managespace] => 1
              [managecensor] => 1
              [managead] => 1
              [managesitefeed] => 1
              [managebackup] => 1
              [manageblock] => 1
              [managetemplate] => 1
              [managestat] => 1
              [managecache] => 1
              [managecredit] => 1
              [managecron] => 1
              [managename] => 1
              [manageapp] => 1
              [managetask] => 1
              [managereport] => 1
            )
    
          [5] => Array
            (
              [gid] => 5
              [grouptitle] => 普通会员
              [system] => 0
              [creditlower] => 0
              [maxfriendnum] => 100
              [maxattachsize] => 20971520
              [allowhtml] => 0
              [allowcomment] => 1
              [searchinterval] => 60
              [postinterval] => 60
              [allowblog] => 1
              [allowdoing] => 1
              [allowupload] => 1
              [allowshare] => 1
              [allowmtag] => 1
              [allowthread] => 1
              [allowpost] => 1
              [allowcss] => 0
              [allowpoke] => 1
              [allowfriend] => 1
              [allowtrace] => 1
              [edittrail] => 0
              [domainlength] => 0
              [closeignore] => 0
              [seccode] => 0
              [color] =>
              [icon] =>
              [manageconfig] => 0
              [managenetwork] => 0
              [manageprofilefield] => 0
              [manageprofield] => 0
              [manageusergroup] => 0
              [managefeed] => 0
              [manageshare] => 0
              [managedoing] => 0
              [manageblog] => 0
              [managetag] => 0
              [managetagtpl] => 0
              [managealbum] => 0
              [managecomment] => 0
              [managemtag] => 0
              [managethread] => 0
              [managespace] => 0
              [managecensor] => 0
              [managead] => 0
              [managesitefeed] => 0
              [managebackup] => 0
              [manageblock] => 0
              [managetemplate] => 0
              [managestat] => 0
              [managecache] => 0
              [managecredit] => 0
              [managecron] => 0
              [managename] => 0
              [manageapp] => 0
              [managetask] => 0
              [managereport] => 0
              [credithigher] => 99
            )
    
        )
    
    )

    返回文章头部

    $_SN:昵称信息

    $_SN: Array
    (
      [1] => 晴枫
    )

    返回文章头部

    举例:

    在UCHome上增加一个功能,希望某些群组类别下只允许有群组管理的人才能新建群组,其他人无法新建这些类别的群组。只需修改模板中的cp_mtag.htm文件,将如下代码:

    <div class="l_status">1. <strong>请选择一个群组分类</strong></div>
    <table><tr>
    <!--{eval $i=0;}-->
    <!--{loop $fields $value}-->
    <td><input type="radio" id="fieldid_$value[fieldid]" name="fieldid" value="$value[fieldid]" onclick="fieldselect(this.value)"><label for="fieldid_$value[fieldid]">$value[title]</label></td>
    <!--{if $i%3==2}--></tr><tr><!--{/if}-->
    <!--{eval $i++;}-->
    <!--{/loop}-->
    </tr></table>

    更改为:

    <div class="l_status">1. <strong>请选择一个群组分类</strong></div>
    <table><tr>
    <!--{eval $i=0;}-->
    <!--{loop $fields $value}-->
    
    <!--{eval if(!($_SGLOBAL['usergroup'][$_SGLOBAL['member']['groupid']]['manageprofield'])){ /*判断当前用户是否有群组管理权限*/}-->
    <!--{eval if(in_array($value[fieldid], array(1,4,5,6))) continue;/*过滤不允许普通用户创建的群组*/}-->
    <!--{eval } }-->
    
    <td><input type="radio" id="fieldid_$value[fieldid]" name="fieldid" value="$value[fieldid]" onclick="fieldselect(this.value)"><label for="fieldid_$value[fieldid]">$value[title]</label></td>
    <!--{if $i%3==2}--></tr><tr><!--{/if}-->
    <!--{eval $i++;}-->
    <!--{/loop}-->
    </tr></table>

    简单说明一下:$_SGLOBAL['member']['groupid']返回当前用户的用户组编号,$_SGLOBAL['usergroup'][用户组编号]['manageprofield']返回特定用户组是否有群组管理权限,结合起来判断当前用户是否有群组管理权限。

    效果就是当管理员登陆后,新建群组可选择所有分类。

    管理员新建群组界面

    管理员新建群组界面

    而普通会员登录后,新建群组只能选个别分类。

    普通会员新建群组界面

    普通会员新建群组界面

    返回文章头部

    以上为个人实践的总结,如有不对之处,敬请指出!



    本博客所有文章如无特别注明均为原创。
    复制或转载请以超链接形式注明转自枫芸志,原文地址《【UCHome二次开发】全局变量
    标签:
    分享:

已经有9 条评论抢在你前面了~

  1. 沙发
    啊啊 2014年3月2日 下午3:44

    博主,现在的uchome2.0里面的东西略微有点差别,有的东西和你说的有差别了

    [回复]

    晴枫

    晴枫 回复:

    @啊啊, 正常,我这个都是三四年前的东西了,必然是有变化的

    [回复]

  2. 板凳
    楼主好银 2012年3月7日 上午11:19

    讲的太好了,比自己分析快多了,哈哈谢谢。。

    [回复]

  3. 地板
    竹轩-> 2011年11月27日 上午11:06

    我也是正在研究这些东西,谢谢楼主,这么好的文章,我可要转载一下,为我自己学习学习,也为楼主宣传一下,再次表示感谢!

    [回复]

  4. 4楼
    php代码学习 2011年11月18日 下午3:01

    正在研究这些东西呢,雪中送炭啊……

    [回复]

  5. 5楼
    hi 2010年6月24日 下午2:16

    第二个图片和第一个重复了,应该是ga-2.png

    [回复]

    晴枫

    晴枫 回复:

    @hi, 是的,改过来了

    [回复]

  6. 6楼
    世界工厂1035 2010年3月31日 上午8:23

    必须顶,很好的东西,谢谢!

    [回复]

无觅相关文章插件,快速提升流量