来源: nfo2pic for IPB2.x ver1.0
帖子:
http://www.molyx.com/showthread.php?t=2...indpost&p=19427
安装难度:简单
插件安装:
1. 进入后台,点击常规设置->主题显示选项[showthread.php]->创建新设置按钮
添加设置:
标题:是否启用nfo2pic图形显示介面
变量值:shownfoimg
类型:是或否按钮
默认值:1
添加这个选项到 setting 缓冲 CACHE 文件?:是
2.后台,点击附件管理->附件类型->添加新的附件类型
文件扩展名:nfo
Mime-Type 类型:text/plain
附件的表示图片:attach/nfo.gif
允许在帖子中使用此种格式的附件?:是
3.打开includes/functions_showthread.php 文件
查找:
:
if ( $bboptions['viewattachedimages'] AND $row['image'] ) {
替换为:
:
if ( ($bboptions['viewattachedimages'] AND $row['image']) OR ($row['extension']=='nfo' AND $bboptions['shownfoimg'])) {
4.打开attachment.php
查找:
:
$DB->shutdown_query("UPDATE ".TABLE_PREFIX."attachment SET counter=counter+1 WHERE attachmentid=".intval($_INPUT['id'])."");
在前面添加:
:
if ( $_INPUT['extension'] == "nfo" AND $bboptions['shownfoimg'] )
{
$fh = file_get_contents( $file );
$forums->func->nfo2pic($fh,$_INPUT['filename'].".png");
exit();
}
5打开 includes/functions.php 文件,在最后
:
}
?>
在上面添加:
:
function nfo2pic($nfocontent, $picname, $font_w="8", $font_h="12", $bgcolor = "#FFFFFF", $txtcolor = "#000000")
{
$fontfile=ROOT_PATH."includes/fonts/8x12.dft";
$content = explode("n",$nfocontent);
$im = imagecreate ($font_w * 80, $font_h * count($content));
$bgcolor = $this->ImageColorAllocateHEX($im,$bgcolor);
$bgcolor = imageColorTransparent($im,$bgcolor); //Transparent
$txtcolor = $this->ImageColorAllocateHEX($im,$txtcolor);
$font = imageloadfont($fontfile);
//draw text
foreach($content as $line => $string)
{
imagestring ($im, $font, 0, $font_h * $line, $string, $txtcolor);
}
//display
header("Content-Type: image/gif");
header('Content-disposition: inline; filename='.$picname.'.png');
imagepng($im);
ImageDestroy($im);
}
function ImageColorAllocateHEX($im,$s)
{
if($s[0] == "#") $s = substr($s,1);
$bg_dec = hexdec($s);
return imagecolorallocate($im,
($bg_dec & 0xFF0000) >> 16,
($bg_dec & 0x00FF00) >> 8,
($bg_dec & 0x0000FF)
);
}
最后,将附件内的 nfo.gif 上传到 风格目录内的attach目录下
font文件夹上传到includes目录内
全部完成!
(在此由衷感谢原作者开发思路)