Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial discuz插件的事,我又跑到csdn来问,相信组织的力量!

discuz插件的事,我又跑到csdn来问,相信组织的力量!

Jun 23, 2016 pm 01:54 PM
strength plug-in

这个插件呢,是仿贴吧的,在帖子列表显示缩略图,是我很喜欢的一种风格,适用于X3.0,但是为了客户端,我只能用X2.5版本,这个插件在X2.5不工作,无法生成缩略图我就是想改一改代码,让其在X2.5环境下工作,自用,不商用。
在X3.0下,是能生成一个存放缩略图的文件夹,里面存放有缩略图。但是在2.5下,没有发现这个文件夹,所以感觉在build这一步出了问题。
下面贴出thumbbuilder.class.php这个文件的代码,请高手分析一下,为什么没有在data/attachment/下生成tiebalist这个文件夹。

<?phpif(!defined('IN_DISCUZ')) {    exit('Access Denied');}if (!class_exists('PhpThumbFactory',false)) require_once('source/plugin/chs_tiebalist/phpthumb/ThumbLib.inc.php');class ThumbBuilder {    private $basedir;	private $baseurl;    public function __construct(){        global $_G;		$this->basedir=!$_G['setting']['attachdir'] ? (DISCUZ_ROOT.'data/attachment/'):$_G['setting']['attachdir'];		$this->baseurl=!$_G['setting']['attachurl'] ? ('data/attachment/'):$_G['setting']['attachurl'];    }    private function getCoverPath($tid){        return 'tiebalist/'.substr(md5($tid), 0, 2).'/'.substr(md5($tid), 2, 2).'/';    }    public function GetThreadCovers($tid,$aids){        $coverpath=$this->getCoverPath($tid);        $fullpath=$this->basedir.$coverpath;        $fullurl=$this->baseurl.$coverpath;        $images=array();        foreach($aids as $aid){            if (file_exists($fullpath.$aid.'.jpg')) $images[]=array('aid'=>$aid,'thumbfile'=>$fullurl.$aid.'.jpg');          }        return $images;    }    public function CreateThreadCovers($tid,$images,$force=0){        $path=$this->basedir.$this->getCoverPath($tid);		dmkdir($path);        global $_G;        $setting=&$_G['cache']['plugin']['chs_tiebalist'];        $thumbheight=$setting['thumbheight']?$setting['thumbheight']:80;        $thumbmaxwidth=$setting['thumbmaxwidth']?$setting['thumbmaxwidth']:300;        foreach($images as $aid=>$image){            $target=$path.$aid.'.jpg';            if (file_exists($target)&&(!$force)) continue;            try {				$thumb = PhpThumbFactory::create($image,array('resizeUp'=>true));                $dimensions=$thumb->getCurrentDimensions();                $newwidth=$thumbheight*$dimensions['width']/$dimensions['height'];                if ($newwidth>$thumbmaxwidth) {                    $thumb->adaptiveResize($thumbmaxwidth,$thumbheight);                }else {                    $thumb->resize(0,$thumbheight);//封面不限定宽度                }				$thumb->save($target);			}catch(Exception $oEx){//捕获生成缩略图可能抛出的异常,防止中断                writelog('tiebalistlog',$oEx->getMessage());				continue;			}        }        if ($force) {            $thumbfiles=$this->getfiles($path,'jpg');            $aids=array_keys($images);            foreach($thumbfiles as $filename){                $aid=intval(substr($filename,0,strpos($filename,'.')));                if (!in_array($aid,$aids)) unlink($path.$filename);            }        }    }        private function getfiles($dir,$mask=''){         $fileArray=array();         if (false != ($handle = opendir ($dir))) {            while (false!==($file=readdir($handle))){                if ($file == '.' || $file == '..') continue;                if (empty($mask)) $fileArray[]=$file;                else if (substr(strrchr($file, '.'), 1)==$mask) $fileArray[]=$file;            }          }         return $fileArray;    }}?>
Copy after login


回复讨论(解决方案)

buildthumb.inc.php内的内容,好像也有用处呢

<?phpif(!defined('IN_DISCUZ')) {    exit('Access Denied');}class plugin_chs_tiebalist {       function common() {}}class plugin_chs_tiebalist_forum extends plugin_chs_tiebalist {     function forumdisplay_thread_subject_output(){           global $_G;        $setting=&$_G['cache']['plugin']['chs_tiebalist'];        if (!$setting['enabled']) return;        $fid = intval($_G['fid']);        $forumselected=unserialize($setting['forumselected']);        if(!in_array($fid,$forumselected)) return;                if ($_G['forum']['picstyle'] == 0||$_G['cookie']['forumdefstyle']==1){            global $_G;            $threadlist = array();            $threadlist = $_G['forum_threadlist'];            $tiebalist = array();            $messagelength=$setting['messagelength']?$setting['messagelength']:100;            $picturenum=$setting['$picturenum']?$setting['$picturenum']:3;            include libfile('function/post');            require_once('thumbbuilder.class.php');            $oTB=new ThumbBuilder();            foreach($threadlist as $key => $value){                $position=($value['special']==2)?2:1;//商品主题的首帖在第二楼,回复从第3楼开始                $firstpost=C::t('forum_post')->fetch_all_by_tid_position('tid:'.$value['tid'],$value['tid'],$position);                if (count($firstpost)>0&&$firstpost[0]['invisible']>=0){                    $post=&$firstpost[0];                    $message=messagecutstr($post['message'],$messagelength);                    $tiebalist[$key] = '<p>'.$message.'</p>';                    $attachs=C::t('forum_attachment_n')->fetch_all_by_id('pid:'.$post['pid'],'pid',$post['pid'],false,true,false,false,$picturenum);                    $aids=array_keys($attachs);                    if ($aids){                        $imagelist=$oTB->GetThreadCovers($value['tid'],$aids);                        if (count($imagelist)>0) {                            $tiebalist[$key].='<ul id="thumblist_'.$value['tid'].'" class="thumblist cl">';                            foreach($imagelist as $ii=>$image){                                $attach=$attachs[$image['aid']];                                $forumimg=($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/'.$attach['attachment'];                                $tiebalist[$key].='<li data="'.$forumimg.'" onclick="showpicture('.$value['tid'].','.$ii.');return false;"><img  src="/static/imghw/default1.png"  data-src="'.$image['thumbfile'].'"  class="lazy"  .$image['thumbfile'].'"/ alt="discuz插件的事,我又跑到csdn来问,相信组织的力量!" ></li>';                            }                            $tiebalist[$key].='</ul>';                            $tiebalist[$key].=                            '<div id="picturebox_'.$value['tid'].'" class="picturedisplay"   style="max-width:90%">                                <div class="picturecontrol">                                    <a class="icon_close" onclick="closepicture('.$value['tid'].');return false;">收起</a>                                    <span>|</span>                                    <a class="icon_viewpost" href="forum.php?mod=viewthread&tid='.$value['tid'].'&extra=page%3D1">查看帖子</a>                                    <span>|</span>                                    <a class="icon_turnleft" onclick="turnimg('.$value['tid'].',1);return false;">左转</a>                                    <span>|</span>                                    <a class="icon_turnright" onclick="turnimg('.$value['tid'].',0);return false;">右转</a>                                </div>                                <div class="picturewrap" >                                    <a onclick="closepicture('.$value['tid'].');return false;"><img  class="picture lazy"  src="/static/imghw/default1.png"  data-src="" / alt="discuz插件的事,我又跑到csdn来问,相信组织的力量!" ></a>                                    <div class="    /></a>                                    <div ></div>                                    <div class="gonext"></div>                                </div>                            </div>';                          }                    }                }            }            return $tiebalist;        }    }    function  forumdisplay_threadlist_bottom() {		global $_G;        $setting=&$_G['cache']['plugin']['chs_tiebalist'];        if (!$setting['enabled']) return;        $fid = intval($_G['fid']);        $forumselected=unserialize($setting['forumselected']);        if(!in_array($fid,$forumselected)) return;		$echo = '<link rel="stylesheet" type="text/css" href="source/plugin/chs_tiebalist/template/css/tiebalist.css" />';		$echo .= '<script src="source/plugin/chs_tiebalist/template/js/tiebalist.js"  type="text/javascript"></script>';        $picturemaxwidth=$setting['picturemaxwidth']?$setting['picturemaxwidth']:600;        $echo .='<script type="text/javascript">var picturemaxwidth='.$picturemaxwidth.';</script>';		return $echo;	}    function post_chs_tiebalist_message($params) {		global $_G, $tid, $pid, $modthread, $isfirstpost;        $setting=&$_G['cache']['plugin']['chs_tiebalist'];        if (!$setting['enabled']) return;        $fid = intval($_G['fid']);        $forumselected=unserialize($setting['forumselected']);        if(!in_array($fid,$forumselected)) return;		list($msg, $url_forward, $values, $extraparam) = $params['param'];		if (($msg == 'post_newthread_succeed')||($msg == 'post_newthread_mod_succeed')) {			$pid = $modthread->pid;			$this->create_covers($pid,$tid);			dshowmessage($msg, $url_forward, $values, $extraparam);		}else if (($msg == 'post_edit_succeed')&&$isfirstpost) {			$tid=$_G['tid'];			$this->create_covers($pid,$tid);			dshowmessage($msg, $url_forward, $values, $extraparam);		}    }    private function create_covers($pid,$tid){		global $_G;        $setting=&$_G['cache']['plugin']['chs_tiebalist'];        $picturenum=$setting['$picturenum']?$setting['$picturenum']:3;		//获取帖子的图片		$attachs=C::t('forum_attachment_n')->fetch_all_by_id('pid:'.$pid,'pid',$pid,false,true,false,false,$picturenum);		$images=array();		foreach($attachs as $attach){			$images[$attach['aid']]=($attach['remote'] ? $_G['setting']['ftp']['attachdir'] : $_G['setting']['attachdir']).'forum/'.$attach['attachment'];		}		if ($images){			require_once("thumbbuilder.class.php");			$oTB=new ThumbBuilder();			$oTB->CreateThreadCovers($tid,$images);		}	}}?>
Copy after login

这个你找原插件作者去瞅瞅吧!

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PyCharm Beginner's Guide: Comprehensive understanding of plug-in installation! PyCharm Beginner's Guide: Comprehensive understanding of plug-in installation! Feb 25, 2024 pm 11:57 PM

PyCharm is a powerful and popular Python integrated development environment (IDE) that provides a wealth of functions and tools so that developers can write code more efficiently. The plug-in mechanism of PyCharm is a powerful tool for extending its functions. By installing different plug-ins, various functions and customized features can be added to PyCharm. Therefore, it is crucial for newbies to PyCharm to understand and be proficient in installing plug-ins. This article will give you a detailed introduction to the complete installation of PyCharm plug-in.

Error loading plugin in Illustrator [Fixed] Error loading plugin in Illustrator [Fixed] Feb 19, 2024 pm 12:00 PM

When launching Adobe Illustrator, does a message about an error loading the plug-in pop up? Some Illustrator users have encountered this error when opening the application. The message is followed by a list of problematic plugins. This error message indicates that there is a problem with the installed plug-in, but it may also be caused by other reasons such as a damaged Visual C++ DLL file or a damaged preference file. If you encounter this error, we will guide you in this article to fix the problem, so continue reading below. Error loading plug-in in Illustrator If you receive an "Error loading plug-in" error message when trying to launch Adobe Illustrator, you can use the following: As an administrator

What is the Chrome plug-in extension installation directory? What is the Chrome plug-in extension installation directory? Mar 08, 2024 am 08:55 AM

What is the Chrome plug-in extension installation directory? Under normal circumstances, the default installation directory of Chrome plug-in extensions is as follows: 1. The default installation directory location of chrome plug-ins in windowsxp: C:\DocumentsandSettings\username\LocalSettings\ApplicationData\Google\Chrome\UserData\Default\Extensions2. chrome in windows7 The default installation directory location of the plug-in: C:\Users\username\AppData\Local\Google\Chrome\User

Share three solutions to why Edge browser does not support this plug-in Share three solutions to why Edge browser does not support this plug-in Mar 13, 2024 pm 04:34 PM

When users use the Edge browser, they may add some plug-ins to meet more of their needs. But when adding a plug-in, it shows that this plug-in is not supported. How to solve this problem? Today, the editor will share with you three solutions. Come and try it. Method 1: Try using another browser. Method 2: The Flash Player on the browser may be out of date or missing, causing the plug-in to be unsupported. You can download the latest version from the official website. Method 3: Press the "Ctrl+Shift+Delete" keys at the same time. Click "Clear Data" and reopen the browser.

Does PyCharm Community Edition support enough plugins? Does PyCharm Community Edition support enough plugins? Feb 20, 2024 pm 04:42 PM

Does PyCharm Community Edition support enough plugins? Need specific code examples As the Python language becomes more and more widely used in the field of software development, PyCharm, as a professional Python integrated development environment (IDE), is favored by developers. PyCharm is divided into two versions: professional version and community version. The community version is provided for free, but its plug-in support is limited compared to the professional version. So the question is, does PyCharm Community Edition support enough plug-ins? This article will use specific code examples to

How to use WordPress plug-in to implement video playback function How to use WordPress plug-in to implement video playback function Sep 05, 2023 pm 12:55 PM

How to use WordPress plug-in to implement video playback function 1. Introduction The application of video on websites and blogs is becoming more and more common. In order to provide a high-quality user experience, we can use WordPress plug-ins to implement video playback functions. This article will introduce how to use WordPress plugins to implement video playback functions and provide code examples. 2. Choose plug-ins WordPress has many video playback plug-ins to choose from. When choosing a plug-in, we need to consider the following aspects: Compatibility: Make sure the plug-in

How to add online ordering functionality to WordPress plugin How to add online ordering functionality to WordPress plugin Sep 05, 2023 pm 03:42 PM

How to Add Online Ordering Function to WordPress Plugin In today’s digital era, many restaurants and coffee shops have chosen to move the ordering process online to meet the needs of customers. WordPress is a widely used content management system (CMS), and many businesses are using WordPress to build their websites. This article will introduce how to add online ordering functionality to WordPress plug-in and provide corresponding code examples. Step 1: Choose the Right Plugin First, we need to create a custom plugin in WordPress

How to add WeChat mini program functionality to WordPress plug-in How to add WeChat mini program functionality to WordPress plug-in Sep 06, 2023 am 09:03 AM

How to Add WeChat Mini Program Functions to WordPress Plugins With the popularity and popularity of WeChat mini programs, more and more websites and applications are beginning to consider integrating them with WeChat mini programs. For websites that use WordPress as their content management system, adding the WeChat applet function can provide users with a more convenient access experience and more functional choices. This article will introduce how to add WeChat mini program functionality to WordPress plug-in. Step 1: Register a WeChat mini program account. First, you need to open the WeChat app

See all articles