Changeset 1206

Show
Ignore:
Timestamp:
07/28/08 07:33:13 (4 months ago)
Author:
_ck_
Message:

0.1.9 handle missing inline images a bit better

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • bb-attachments/trunk/bb-attachments.php

    r1205 r1206  
    66Author: _ck_ 
    77Author URI: http://bbShowcase.org 
    8 Version: 0.1.8 
     8Version: 0.1.9 
    99 
    1010License: CC-GNU-GPL http://creativecommons.org/licenses/GPL/2.0/ 
     
    4545$bb_attachments['inline']['solution']="resize"; // resize|frame - images can be either resized or CSS framed to meet above requirement 
    4646                                                                        // only resize is supported at this time 
    47 $bb_attachments['style']="#thread .post li {clear:none;}"; 
     47$bb_attachments['style']=".bb_attachments_link, .bb_attachments_link img {border:0; text-decoration:none;} #thread .post li {clear:none;}"; 
    4848 
    4949// stop editing here (advanced user settings below) 
     
    5656 
    5757$bb_attachments['icons']['url']=bb_get_option('uri').trim(str_replace(array(trim(BBPATH,"/\\"),"\\"),array("","/"),dirname(__FILE__)),' /\\').'/icons/';  
     58$bb_attachments['icons']['path']=rtrim(dirname(__FILE__),' /\\').'/icons/';  
    5859 
    5960$bb_attachments['title']=" <img title='attachments' border='0' align='absmiddle' src='".$bb_attachments['icons']['url'].$bb_attachments['icons']['default']."' />"; // text, html or image to show on topic titles if has attachments 
     
    172173                                $output.="<li>";  
    173174                                $output.="<span".(($attachment->status>0) ? " class='deleted' ": "")."> ";  
    174                                 if (isset($bb_attachments['icons'][$attachment->ext])) {$icon=$bb_attachments['icons'][$attachment->ext];} else {$icon=$bb_attachments['icons']['default'];} 
     175                                if ($attachment->status>0) {$icon="missing.gif";} 
     176                                else {if (isset($bb_attachments['icons'][$attachment->ext])) {$icon=$bb_attachments['icons'][$attachment->ext];} else {$icon=$bb_attachments['icons']['default'];}} 
    175177                                $output.=" <img align='absmiddle' title='".$attachment->ext."' src='".$bb_attachments['icons']['url'].$icon."' /> "; 
    176178                                 
     
    230232 
    231233function bb_attachments_bbcode($text) { 
    232 $text = preg_replace("/\[attachment=([0-9]+?)\,([0-9]+?)\]/sim","<a href='?bb_attachments=$1&bbat=$2'><img src='?bb_attachments=$1&bbat=$2&inline'></a>",$text); 
     234$text = preg_replace("/\[attachment=([0-9]+?)\,([0-9]+?)\]/sim","<a class='bb_attachments_link' href='?bb_attachments=$1&bbat=$2'><img src='?bb_attachments=$1&bbat=$2&inline'></a>",$text); 
    233235return $text; 
    234236} 
     
    446448                                        set_time_limit(0);  
    447449                                fpassthru($fp); // avoids file touch bug with readfile 
    448                                 fclose($fp);                     
     450                                fclose($fp); 
     451                                exit();                  
    449452                        }                                                                                        
    450                         }                
    451                 exit();          
    452         }        
    453 } else { 
    454         $im=@imagecreatetruecolor(1,1); 
     453                        } else {        bb_attachments_inline_missing();}                                                
     454        } else {        bb_attachments_inline_missing();}        
     455} else {        bb_attachments_inline_missing();} 
     456
     457 
     458function bb_attachments_inline_missing() { 
     459global $bb_attachments; 
     460        $missing=$bb_attachments['icons']['path']."missing.gif"; 
    455461        header("Cache-Control: public, must-revalidate, post-check=0, pre-check=0"); 
    456         header("Content-type: image/png"); 
    457         header("Content-Length: ".strlen($im)); 
    458         imagepng($im); 
    459         imagedestroy($im); 
     462        header("Content-Type: image/gif"); 
     463        header("Content-Length: ".filesize($missing)); 
     464        header('Content-Disposition: inline; filename="missing.gif"'); 
     465        header("Content-Transfer-Encoding: binary");               
     466        ob_clean(); 
     467        flush();  
     468        $fp = @fopen($missing,"rb"); 
     469        set_time_limit(0);  
     470        fpassthru($fp); // avoids file touch bug with readfile 
     471        fclose($fp);                             
    460472        exit(); 
    461 } 
    462473} 
    463474 
  • bb-attachments/trunk/readme.txt

    r1205 r1206  
    5555* 0.1.7 bug squashed for IIS ? 
    5656* 0.1.8 workaround for lack of apache_request_headers, javascript insert bug 
     57* 0.1.9 handle missing inline images a bit better with "x" icon 
    5758         
    5859== To Do ==