Discuz plug-in thing, I ran to Csdn to ask, believe the strength of the Organization!

Source: Internet
Author: User
This plugin, is imitation stick, in the post list display thumbnail, is I like a style, applicable to X3.0, but for the client, I can only use X2.5 version, this plug-in X2.5 not work, unable to generate thumbnails I just want to change the code, let it work in the X2.5 environment, for personal use, not commercial.
Under X3.0, it is possible to generate a folder containing thumbnails, which are stored in thumbnail images. But at 2.5, there was no discovery of this folder, so it felt like a problem in the build step.
The following post thumbbuilder.class.php the code of this file, please expert analysis, why did not generate tiebalist this folder under data/attachment/.
 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). '    /';        The 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; The Public Function createthreadcovers ($tid, $images, $force =0) {$path = $this->basedir. $this->getcoverpath ($tid        );d mkdir ($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);//Cover not limited width} $thumb->save ($target);}        catch (Exception $oEx) {//captures the exception that can be thrown by generating thumbnails, preventing interrupts 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 ($file, '. '), 1) = = $mask) $fileArray []= $file;    }} return $fileArray; }}?>


Reply to discussion (solution)

The contents of the buildthumb.inc.php seem to be of use.

 $value) {$position = ($value [' Special ']==2)? 2:1;//on the second floor, reply from the 3rd floor $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] = '

'. $message. '

'; $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].= '
      '; foreach ($imagelist as $ii = + $image) {$attach = $attachs [$image [' aid ']]; $forumimg = ($attach [' Remote ']? $_g[' Setting ' [' FTP '] [' Attachurl ']: $_g[' setting ' [' Attachurl ']). ' forum/'. $attach [' attachment ']; $tiebalist [$key].= '
    • '; } $tiebalist [$key].= '
'; $tiebalist [$key].= ' Close up|View Posts|Left|Turn right '; }}}} 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 = ' '; $echo. = '; $picturemaxwidth = $setting [' Picturemaxwidth ']? $setting [' Picturemaxwidth ']:600; $echo. = "; 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);d showmessage ($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;//get a picture of a post $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);}}? >

You find the original plugin author to see it!

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.