Home  >  Article  >  php教程  >  UCenter Home Secondary Development Guide

UCenter Home Secondary Development Guide

高洛峰
高洛峰Original
2016-12-30 16:48:051312browse

Preface
This article will focus on the core theme of secondary development of UCH, focusing on the codes of various implementations. The auxiliary part will briefly explain how to carry out secondary development for UCH. UCH will be open sourced in a while, and I will write a detailed analysis of the UCH mechanism when the time comes.

By the way, this document was written about two weeks ago, but I haven’t had time to compile and publish it. Today I heard that UCH will be open sourced in the near future. Publishing it by then will not be of much help to everyone, so I decided not to organize it anymore. Although some of the instructions in the article are not detailed yet, they have been basically written.

Data call
The data call here is to use the built-in data call of UCenter Home. There is "data call" management in the "Advanced Application" in the background. The following codes are added in the template and then called data.
1. In-site data call

<!--{template data/blocktpl/1}-->

2. Off-site JS call

<script language="javascript" type="text/javascript" src="http://www.ccvita.com/js.php?id=1"></script>

Use of block
This block data call is different from the previous data call, from the data source and In terms of generation, it is basically similar.

5b2f0dcd058b9c25b97941c66ed3e33f
d0344d12c01721c8e09588b1eebacbbf
aa07253b7fe2b06dadd8ac0f43b37233
c09275a3ebf4c746aaf69196ebc0e4d694dec625a1bf66ba49af977bd767dd51$value[subject]5db79b134e9f6b82c0b36e0489ee08ed2952eb9283174fe1eb953f1628102785

Use of eval
Reasonable use of the eval syntax in the Ucenter Home template syntax will reduce secondary development in certain programs difficulty. For example:
1. Execute PHP statements in the template through eval syntax

c31609c265ebfad9d57c0821ab5f5a8a
000350f7c1fc7c16b84a20823825cd2d3916d31b972043b8ac3a73ea5da849cc8e99a69fbe029cd4e2b854e244eab143Latest log demo128dba7a3a77be0113eb0bea6ea0a5d05db79b134e9f6b82c0b36e0489ee08ed';}-->

2. Introduce an external PHP file through eval syntax
Introduce external files

5f69a7cc7db87a5a2462746d07885460
4f9b8aec85c154dda49cdfa0cd02fa06

Note: You can do anything you want by introducing external files into the template.

Direct external file
Extension of do.php
1. First, add a new allowed method in the do.php file
That is, in

$acs = array ('login', 'comment', 'wall', 'register', 'lostpasswd', 'swfupload', 'inputpwd',
'sns', 'viewspace', 'relatekw', 'ajax', 'seccode ');

add

$acs[] = 'demo';

2. Then, create a new do_demo.php file in the source directory, and the calling address is do .php?ac=demo
Although the files released by UCH are encrypted information, we can obtain valuable information for UCH secondary development from its open source files.
For example, the /source/cron directory and the source/class_mysql.php file are all open source. We can find out some information that is very useful for secondary development of UCH, such as how to perform SQL queries. Through analysis, We can write the following file.

< ?php
!defined(&#39;IN_UCHOME&#39;) && exit(&#39;Access Denied&#39;);
$query = $_SGLOBAL[&#39;db&#39;]->query(&#39;SELECT * FROM &#39;.tname(&#39;blog&#39;).&#39; ORDER BY dateline DESC LIMIT 10&#39;);
$bloglist = array();
while ($value = $_SGLOBAL[&#39;db&#39;]->fetch_array($query)) {
$bloglist[] = $value;
}
include template(&#39;do_demo&#39;);
?>

The content of the template file templates/default/do_demo.htm is

<!--{template header}-->
<div class="side_right">
<div class="wide">
<div class="post_list">
<ul>
<!--{loop $bloglist $value}-->
<li>
<div class="title">
<h4><a href="space.php?uid=$value[uid]&do=blog&id=$value[blogid]">$value[subject]</a></h4>
<a href="space.php?uid=$value[uid]">$value[username]</a> <span class="time"><!--{date(&#39;Y-m-d H:i&#39;,$value[dateline])}--></span>
</div>
<div class="status">
<!--{if $value[viewnum]}--><a href="space.php?uid=$value[uid]&do=blog&id=$value[blogid]">$value[viewnum] 次阅读</a><span class="pipe">|</span><!--{/if}-->
<!--{if $value[replynum]}--><a href="space.php?uid=$value[uid]&do=blog&id=$value[blogid]#comment">$value[replynum] 个评论</a><!--{else}-->没有评论<!--{/if}-->
</div>
</li>
<!--{/loop}-->
</ul>
</div>
</div>
</div>
<!--{template footer}-->

Summary
Although the current UCH is not open source, it is fully modifiable in the template interface and makes reasonable use of the above data calling mechanism. In this case, there are few page effects and data call requirements that we cannot achieve.

For more articles related to UCenter Home secondary development guide, please pay attention to the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn