logo       


mantisbt/core file_api.php,1.75,1.76: msg#00026

Subject: mantisbt/core file_api.php,1.75,1.76
Update of /cvsroot/mantisbt/mantisbt/core
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv8811/core

Modified Files:
        file_api.php 
Log Message:
Fixed #7436: Detect missing attachments in case of DISK file upload method.

Index: file_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/file_api.php,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- file_api.php        15 Aug 2006 06:02:06 -0000      1.75
+++ file_api.php        15 Sep 2006 05:02:47 -0000      1.76
@@ -172,27 +172,33 @@
                                $t_href_clicket = '';
                        }
 
-                       PRINT $t_href_start;
-                       print_file_icon ( $t_file_display_name );
-                       PRINT $t_href_end . ' ' . $t_href_start . 
$t_file_display_name .
-                               $t_href_end . "$t_href_clicket ($t_filesize 
bytes) <span class=\"italic\">$t_date_added</span>";
+                       $t_exists = config_get( 'file_upload_method' ) != DISK 
|| file_exists( $v_diskfile );
 
-                       if ( $t_can_delete ) {
-                               PRINT " [<a class=\"small\" 
href=\"bug_file_delete.php?file_id=$v_id\">" . lang_get('delete_link') . 
'</a>]';
-                       }
+                       if ( !$t_exists ) {
+                               print_file_icon ( $t_file_display_name );
+                               PRINT '&nbsp;<font STYLE="text-decoration: 
line-through">' . $t_file_display_name . '</font> (attachment missing)';
+                       } else {
+                               PRINT $t_href_start;
+                               print_file_icon ( $t_file_display_name );
+                               PRINT $t_href_end . '&nbsp;' . $t_href_start . 
$t_file_display_name .
+                                       $t_href_end . "$t_href_clicket 
($t_filesize bytes) <span class=\"italic\">$t_date_added</span>";
 
-                       if ( ( FTP == config_get( 'file_upload_method' ) ) && 
file_exists ( $v_diskfile ) ) {
-                               PRINT ' (' . lang_get( 'cached' ) . ')';
-                       }
+                               if ( $t_can_delete ) {
+                                       PRINT " [<a class=\"small\" 
href=\"bug_file_delete.php?file_id=$v_id\">" . lang_get('delete_link') . 
'</a>]';
+                               }
 
-                       if ( $t_can_download &&
-                               ( $v_filesize <= config_get( 
'preview_attachments_inline_max_size' ) ) &&
-                               ( $v_filesize != 0 ) &&
-                               ( in_array( strtolower( file_get_extension( 
$t_file_display_name ) ), $t_preview_text_ext, true ) ) ) {
-                                $c_id=number_format($v_id);
-                               $t_bug_file_table = config_get( 
'mantis_bug_file_table' );
+                               if ( ( FTP == config_get( 'file_upload_method' 
) ) && file_exists ( $v_diskfile ) ) {
+                                       PRINT ' (' . lang_get( 'cached' ) . ')';
+                               }
 
-                               echo "<script language='JavaScript'>
+                               if ( $t_can_download &&
+                                       ( $v_filesize <= config_get( 
'preview_attachments_inline_max_size' ) ) &&
+                                       ( $v_filesize != 0 ) &&
+                                       ( in_array( strtolower( 
file_get_extension( $t_file_display_name ) ), $t_preview_text_ext, true ) ) ) {
+                                       $c_id = number_format( $v_id );
+                                       $t_bug_file_table = config_get( 
'mantis_bug_file_table' );
+
+                                       echo "<script language='JavaScript'>
 <!--
 function swap_content( span ) {
 displayType = ( document.getElementById( span ).style.display == 'none' ) ? 
'block' : 'none';
@@ -201,57 +207,58 @@
 
  -->
  </script>";
-                               PRINT "[<a class=\"small\" href='#' 
id='attmlink_".$c_id."' onClick='swap_content(\"attm_".$c_id."\");return 
false;'>". lang_get( 'show_content' ) ."</a>]<blockquote style='display:none' 
id='attm_".$c_id."' class=''><pre>";
-                               switch ( config_get( 'file_upload_method' ) ) {
-                                       case DISK:
-                                               if ( file_exists( $v_diskfile ) 
) {
-                                                       
$v_content=file_get_contents( $v_diskfile );
-                                               }
-                                               break;
-                                       case FTP:
-                                               if ( file_exists( $v_diskfile ) 
) {
-                                                       file_get_contents( 
$v_diskfile );
-                                               } else {
-                                                       $ftp = 
file_ftp_connect();
-                                                       file_ftp_get ( $ftp, 
$v_diskfile, $v_diskfile );
-                                                       file_ftp_disconnect( 
$ftp );
-                                                       
$v_content=file_get_contents( $v_diskfile );
-                                               }
-                                               break;
-                                       default:
-                                               $query = "SELECT *
-                                                               FROM 
$t_bug_file_table
-                                                       WHERE id='$c_id'";
-                                                       $result = db_query( 
$query );
-                                               $row = db_fetch_array( $result 
);
-                                                $v_content=$row['content'];
-                               }
-                               echo htmlspecialchars($v_content);
+                                       PRINT "[<a class=\"small\" href='#' 
id='attmlink_".$c_id."' onClick='swap_content(\"attm_".$c_id."\");return 
false;'>". lang_get( 'show_content' ) ."</a>]<blockquote style='display:none' 
id='attm_".$c_id."' class=''><pre>";
+                                       switch ( config_get( 
'file_upload_method' ) ) {
+                                               case DISK:
+                                                       if ( file_exists( 
$v_diskfile ) ) {
+                                                               
$v_content=file_get_contents( $v_diskfile );
+                                                       }
+                                                       break;
+                                               case FTP:
+                                                       if ( file_exists( 
$v_diskfile ) ) {
+                                                               
file_get_contents( $v_diskfile );
+                                                       } else {
+                                                               $ftp = 
file_ftp_connect();
+                                                               file_ftp_get ( 
$ftp, $v_diskfile, $v_diskfile );
+                                                               
file_ftp_disconnect( $ftp );
+                                                               
$v_content=file_get_contents( $v_diskfile );
+                                                       }
+                                                       break;
+                                               default:
+                                                       $query = "SELECT *
+                                                                       FROM 
$t_bug_file_table
+                                                               WHERE 
id='$c_id'";
+                                                       $result = db_query( 
$query );
+                                                       $row = db_fetch_array( 
$result );
+                                                       
$v_content=$row['content'];
+                                       }
+                                       echo htmlspecialchars($v_content);
 
-                               PRINT "</pre></blockquote>";
-                       }
+                                       PRINT "</pre></blockquote>";
+                               }
 
 
-                       if ( $t_can_download &&
-                               ( $v_filesize <= config_get( 
'preview_attachments_inline_max_size' ) ) &&
-                               ( $v_filesize != 0 ) &&
-                               ( in_array( strtolower( file_get_extension( 
$t_file_display_name ) ), $t_preview_image_ext, true ) ) ) {
+                               if ( $t_can_download &&
+                                       ( $v_filesize <= config_get( 
'preview_attachments_inline_max_size' ) ) &&
+                                       ( $v_filesize != 0 ) &&
+                                       ( in_array( strtolower( 
file_get_extension( $t_file_display_name ) ), $t_preview_image_ext, true ) ) ) {
 
-                               $t_preview_style = 'border: 0;';
-                               $t_max_width = config_get( 'preview_max_width' 
);
-                               if ( $t_max_width > 0 ) {
-                                       $t_preview_style .= ' max-width:' . 
$t_max_width . 'px;';
-                               }
+                                       $t_preview_style = 'border: 0;';
+                                       $t_max_width = config_get( 
'preview_max_width' );
+                                       if ( $t_max_width > 0 ) {
+                                               $t_preview_style .= ' 
max-width:' . $t_max_width . 'px;';
+                                       }
                                
-                               $t_max_height = config_get( 
'preview_max_height' );
-                               if ( $t_max_height > 0 ) {
-                                       $t_preview_style .= ' max-height:' . 
$t_max_height . 'px;';
-                               }
+                                       $t_max_height = config_get( 
'preview_max_height' );
+                                       if ( $t_max_height > 0 ) {
+                                               $t_preview_style .= ' 
max-height:' . $t_max_height . 'px;';
+                                       }
 
-                               $t_preview_style = 'style="' . $t_preview_style 
. '"';
+                                       $t_preview_style = 'style="' . 
$t_preview_style . '"';
 
-                               PRINT "<br />$t_href_start<img $t_preview_style 
src=\"file_download.php?file_id=$v_id&amp;type=bug\" />$t_href_end";
-                               $image_previewed = true;
+                                       PRINT "<br />$t_href_start<img 
$t_preview_style src=\"file_download.php?file_id=$v_id&amp;type=bug\" 
/>$t_href_end";
+                                       $image_previewed = true;
+                               }
                        }
 
                        if ( $i != ( $num_files - 1 ) ) {


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe