由于用JS方法无法调出UCHOME及论坛的数据,固决定通过设计模块脚本来现实,目的是为了调用UCHOME的最新日志,项目包括日志标题、链接、作者、更新时间,代码如下,共两个,一个blog.php放在UCHOME 的API目录下的DISCUZ下,另一个blog.inc.php放在论坛include目录下的request文件下,两文件代码如下:
blog.php- <?php
- /*
- [UCenter Home] (C) 2007-2008 Comsenz Inc.
- $Id: blog.php 10881 2008-12-09 07:01:06Z zhengqingpeng $
- */
- if(!defined('IN_UCHOME')) {
- exit('Access Denied');
- }
- $wherearr = $bloglist = array();
- $sql = '';
- $uid = !empty($_GET['uid']) ? trim($_GET['uid']) : '';
- $mood = !empty($_GET['mood']) ? intval($_GET['mood']) : 0;
- $start = !empty($_GET['start']) ? intval($_GET['start']) : 0;
- $limit = !empty($_GET['limit']) ? intval($_GET['limit']) : 10;
- $uids = getdotstring($uid, 'int');
- if($uids) $wherearr[] = 'uid IN ('.$uids.')';
- if($wherearr) $sql = 'WHERE '.implode(' AND ', $wherearr);
- $query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('blog')." $sql ORDER BY dateline DESC LIMIT $start,$limit");
- while($value = $_SGLOBAL['db']->fetch_array($query)) {
- $value['subject'] = makeurl($value['subject']);
- $value['userlink'] = $siteurl.'space.php?uid='.$value['uid'];
- $value['link'] = $siteurl.'space.php?blogid='.$value['blogid'];
- $value['viewnum'] = avatar($value['viewnum']);
- $value['dateline'] = sgmdate('m-d H:i', $value['dateline']);
- $value = sstripslashes($value);
- $bloglist[] = $value;
- }
- echo serialize($bloglist);
- ?>
复制代码 blog.inc.php- <?php
- /*
- [Discuz!] (C)2001-2009 Comsenz Inc.
- This is NOT a freeware, use is subject to license terms
- $Id: blog.inc.php 10882 2008-12-12 07:36:51Z andy $
- */
- if(!defined('IN_DISCUZ')) {
- exit('Access Denied');
- }
- if($requestrun) {
- $parameter = array();
- $parameter[] = 'ac=blog';
- if(!empty($settings['uid'])) {
- $parameter[] = 'uid='.trim($settings['uid']);
- }
- if(!empty($settings['mood'])) {
- $parameter[] = 'mood='.intval($settings['mood']);
- }
- $start = !empty($settings['start']) ? intval($settings['start']) : 0;
- $limit = !empty($settings['limit']) ? intval($settings['limit']) : 10;
- $parameter[] = 'start='.$start;
- $parameter[] = 'limit='.$limit;
- $plus = implode('&', $parameter);
- $url = $GLOBALS['uchomeurl']."/api/discuz.php?$plus";
- $bloglist = unserialize(dfopen($url));
- $writedata = '';
- if($bloglist && is_array($bloglist)) {
- $writedata = '<div class="sidebox"><h4>'.$settings['title'].'</h4><table>';
- foreach($bloglist as $blog) {
- $searchs = $replaces = array();
- foreach(array_keys($blog) as $key) {
- $searchs[] = '{'.$key.'}';
- $replaces[] = $blog[$key];
- }
- $writedata .= '<tr><td>'.str_replace($searchs, $replaces, stripslashes($settings['template'])).'</td></tr>';
- }
- $writedata .= '</table></div>';
- }
- } else {
- $request_version = '1.0';
- $request_name = $requestlang['blog_name'];
- $request_description = $requestlang['blog_desc'];
- $request_copyright = '<a href="http://u.discuz.net/home/" target="_blank">Comsenz Inc.</a>';
- $request_settings = array(
- 'title' => array($requestlang['blog_title'], $requestlang['blog_title_comment'], 'text', '', $requestlang['blog_title_value']),
- 'uid' => array($requestlang['blog_uids'], $requestlang['blog_uids_comment'], 'text'),
- 'mood' => array($requestlang['blog_mood'], '', 'mradio', array(array('0', $requestlang['blog_mood_nolimit']), array('1', $requestlang['blog_mood_moodonly'])), '0'),
- 'start' => array($requestlang['blog_start'], $requestlang['blog_start_comment'], 'text', '', '0'),
- 'limit' => array($requestlang['blog_limit'], $requestlang['blog_limit_comment'], 'text', '', '10'),
- 'template' => array($requestlang['blog_template'], $requestlang['blog_template_comment'], 'textarea', '','<a href="{link}">{subject}</a>')
- );
- }
- ?>
复制代码 上传至空间,进入模块脚本,能看到脚本文件,但脚本文件名不显示,点添加进入设置页面,发现很多中文字都没有的。请高人指点,如有相关说明,也烦请给个链接,小弟在此谢过!!! |