NoName Mobile

登录
NoName » Project Parasy » [PP插件] 会员头像展示Ajax缓存版1.0 完成~

[PP插件] 会员头像展示Ajax缓存版1.0 完成~

by exgbit at 2008-2-19 23:03
[PP插件] 会员头像展示Ajax缓存版1.0
/*  Project Parasynthesis 插件
会员头像展示Ajax缓存版
版本:1.0
exgbit(果比)  sai
支持站:http://saicn.com/bbs/
*/

比起0.5改进:
1、采用ParasyCore.php更新缓存
2、读取首页时,采用php随机读取,避免了ajax冲突
3、保留了ajax方式,ajax即时刷新头像覆盖php读取内容
4、FF行显示


安装:

1、上传exgbit_avatar.js到include\javascript\文件夹下

2、打开parasy_json_tab.php
找到
case 'json_home_tab_latest':

在上面加上
case 'json_exg_ava':
  require_once DISCUZ_ROOT.'./forumdata/cache/cache_exgbit_ava.php';
  $top = array();
  $i = 0;
  foreach($exgava as $exgav) {
   $i++;
   $exga[$i]['uidav'] = $exgav['uidav'];
   $exga[$i]['picav'] = $exgav['picav'];
   $exga[$i]['nameav'] = iconv('gbk', 'utf-8', $exgav['nameav']);
   $exga[$i]['nicknameav'] = iconv('gbk', 'utf-8', $exgav['nicknameav']);
  }
  header('Content-type: text/plain; charset=utf-8');
  header('Cache-control: no-cache, must-revalidate');
  if (function_exists('json_encode')) {
   $encoded = json_encode($exga);
  } else {
   $encoded = Zend_Json::encode($exht);
  }
  echo $encoded;
  break;

3、打开ParasyCore.php
找到

在上面加上
/*Parasy || Exgbit Ajax Avatar*/
function exg_avas() {
global $db, $_DCACHE, $timestamp, $tablepre, $discuz_uid, $member;
$data = array();
$query_exgava = $db->query("SELECT cm.uid,username,nickname,avatar from {$tablepre}members cm LEFT JOIN {$tablepre}memberfields cdm ON cm.uid=cdm.uid WHERE avatar !='' ORDER BY rand() LIMIT 20");
while($exgava = $db->fetch_array($query_exgava)) {
  $data['exgava'][$exgava[uid]]['uidav'] = $exgava['uid'];
  $data['exgava'][$exgava[uid]]['nameav'] = $exgava['username'];
  $data['exgava'][$exgava[uid]]['nicknameav'] = $exgava['nickname'];
  $data['exgava'][$exgava[uid]]['picav'] = $exgava['avatar'];
}
$data['exgava_expiration'] = 900 + time();
nmwritetocache(cache_exgbit_ava, '', nmgetcachevars($data),'','cache');
return $data['exgava'];
}
/*Parasy || Exgbit Ajax Avatar*/

4、打开discuz.htm
找到
<!--{if $show_cloud == 0}-->
<div class="maintable" align="left">
<span class="tip_i">New in NoName

在上面加上

下载文件:http://www.51ok.com/filedown-803967239.html (exgbit_avatar.js)

预览:
http://tu.6.cn/img/id/e306ee7cc601ef91b12ff1d82dce6510 上图红色区域,点击可即时刷新头像。

演示:http://www.csustbbs.net/bbs/

[ 本帖最后由 exgbit 于 2008-2-20 00:02 编辑 ]
# 1 - exgbit at 2008-2-19 23:06
补充:

6、打开index.php

找到:
$gid = !empty($gid) ? intval($gid) : 0;
if(!$gid) {

在上面加上:
/*Parasy || Exgbit Ajax Avatar*/
@include DISCUZ_ROOT.'./forumdata/cache/cache_exgbit_ava.php';
if((@!include('forumdata/cache/cache_exgbit_ava.php')) || $exgava_expiration < time()) {
        $exgava = exg_avas();
} else {
        $exgava = $exgava;
}
@shuffle($exgava);
/*Parasy || Exgbit Ajax Avatar*/

[ 本帖最后由 exgbit 于 2008-2-19 23:07 编辑 ]
# 2 - Sai at 2008-2-20 00:08
这是我见过的最快的版本升级....

Good job!
# 3 - exgbit at 2008-2-20 07:57
...插件嘛..没必要那么讲究哈.. = 3 =

关键功能上已经完善了,应该不用大动,直接1.0...
# 4 - kinway at 2008-2-20 11:46
哈哈 好东西~!
不过我有个小问题 就是我论坛里面有很多会员没有了头像 或者头像过期了 如何把这些会员的头像都默认为noavatar呢?
# 5 - exgbit at 2008-2-20 11:52
要把这些会员都赛选出来,有没有什么共同特征呢?

如果实在没有,干脆点

一次性把全部会员头像都清空,都重新上传

sql:
UPDATE `cdb_memberfields` SET `avatar` = ''
# 6 - Sai at 2008-2-20 12:40

UPDATE `cdb_memberfields` SET `avatar` = '' ` WHERE `avatar` LIKE 'http%';

清空使用url作为头像的会员
# 7 - kinway at 2008-2-20 21:40
感谢两位的帮助,可是用

UPDATE `cdb_memberfields` SET `avatar` = '' ` WHERE `avatar` LIKE 'http%';

提示错误

。。。

然后我又发现 在无名这直接点击copy to clipboard
会连着[Copy to clipboard]CODE:都copy掉
# 8 - exgbit at 2008-2-20 22:36

UPDATE `cdb_memberfields` SET `avatar` = ''  WHERE `avatar` LIKE 'http%';

# 9 - Sai at 2008-2-20 22:53
恩……where前面多了一个`
 下一页 1/2 
© 2007 NoNameMagazine