dick_jj 发表于 2006 年 7 月 13 日 12:02:03

UBB Hack for Sablog Ver 1.1

UBB Hack for Sablog Ver 1.1

http://www.bpsky.net/attachments/date_200607/736f69e7007be3565c7e4aedb9dd6ee4.jpg

这个插件修改了三个文件,之前已经说过了..自已写的一个正则小函数.说是帮angel作了扩展,其实却让自已长了不少见识..呵呵..

下面说说详细的方法.
首先下载扩展包,我已经修改写好的了这个函数,你需要复修替换原来的就行了.设计思路是外挂式的.就是说,我写的函数是脱离sax内核独力执行的,所以理论上是不存在安全性问题的.


1.下载并解压扩展包,
2.替换./include/common.js文件.
3.重点了..按照下例在show.htm文件中加入ubb面板与替换表情功能...

/***********************UBB显示部分修改**************************/
//原始模板评论显示语法..
foreach($commentdb as $key => $comment){print <<<EOT
--><a name="cm$comment"></a><div class="cmcontent" id="comm_$comment">$comment</div>

//hack过后的评论内容转换...
foreach($commentdb as $key => $comment){
$UBBcomment=replaceUBB($comment,$options['templatename']);
print <<<EOT
-->
<a name="cm$comment"></a>
<div class="acmcontent" id="comm_$comment">$UBBcomment</div><!--end-->

/***************************UBB Panel*******************************/
//UBB面板插入..
<textarea name="content" id="content" cols="56" rows="8" onkeydown="ctlent(event);"></textarea>
/*   *   上面这段代码是你的模板评论输入栏的位子,你可以修改显示UBB标签的位置   *   */

<div class="UBBpanel">
<div class="title">Add UBB</div>
<!--
EOT;

$ubb=ubb_exists($options['templatename']);

foreach($ubb as $var){
print <<<EOT
-->
<div class="ubbimg" onmouseover="this.style.border='2px solid #CCCCCC'" onmouseout="this.style.border='2px solid #EDF8DD'"><img src="./templates/{$options['templatename']}/ubbimg/{$var}.gif" onclick='insertUBB("$var")' alt="表情" /></div>
<!--
EOT;}
print <<<EOT
-->
<div class="clear"></div>
</div><!--end UBBPanel-->
4.好了,去网上找你喜欢的ubb表情吧~~然后上传到你的模板(./templates/模板名/ubbimg)
5.修改你的ubb图片名称.有两项硬性规定..大家要注意一下.这是为了让系统自动扫描你的ubb图片作的一些限定.
UBB图片名称必需以ubb01.gif延伸到ubb99.gif,目前系统只扫描到01-99个UBB表情,相信已经够用了.UBB表情图片只支持gif文件.
6.特别注意一下,因为个人的blog里修改了很多global的文件,已经和官方不同..所以回收global.php文件,请自行加入以下代码..0702

function replaceUBB($content,$template){
$ubb=preg_replace('/(\)/',"<img src='./templates/$template/ubbimg/ubb\\2.gif' alt='表情'/>",$content);
return $ubb;
}

function ubb_exists($template){
$i=0;
$file_path="./templates/$template/ubbimg/";
while(true){
$i++;
$temp_path=($i<=9)?($file_path.'ubb0'.$i.'.gif'):($file_path.'ubb'.$i.'.gif');
if( file_exists($temp_path) ){
   $ubb[$i]=$i<=9?"ubb0$i":"ubb$i";
}else{
   break;
}
}
return $ubb;
}
7.不会修改s的朋友可以下载我已经修改好的show.htm文件.只能应用到官方效果中...非官方模板,自行研究了.

希望大家喜欢.第一次作hack,贯彻我的理想:积淀,思考,分享,因为别人而快乐..

下载地址:http://www.bpsky.net/?action=show&id=65

注:此文特由http://www.bpsky.net站长Byron授权我发表,禁止任何用户以自己的署名发表!
我的博客:http://www.hihacker.net
页: [1]
查看完整版本: UBB Hack for Sablog Ver 1.1