Skip to content

Commit

Permalink
Some cleanup work for file_api.php:
Browse files Browse the repository at this point in the history
- Used config_get() to get configs
- Used lang_get() to get strings.
- Handled ftp connection errors.


git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@1357 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
vboctor committed Aug 26, 2002
1 parent 589d07e commit fc325f3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
1 change: 1 addition & 0 deletions constant_inc.php
Expand Up @@ -157,6 +157,7 @@
define( 'ERROR_BUGNOTE_NOT_FOUND', 21 );
define( 'ERROR_PROJECT_NOT_FOUND', 22 );
define( 'ERROR_DB_FIELD_NOT_FOUND', 23 );
define( 'ERROR_FTP_CONNECT_ERROR', 24 );

# Status Legend Position
define( 'STATUS_LEGEND_POSITION_TOP', 1);
Expand Down
23 changes: 9 additions & 14 deletions core/file_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: file_api.php,v 1.2 2002-08-25 08:14:59 jfitzell Exp $
# $Id: file_api.php,v 1.3 2002-08-26 22:42:26 vboctor Exp $
# --------------------------------------------------------

###########################################################################
Expand All @@ -23,29 +23,26 @@ function file_get_display_name( $p_filename ) {
# List the attachments belonging to the specified bug. This is used from within
# view_bug_page.php and view_bug_advanced_page.php
function file_list_attachments ( $p_bug_id ) {
global $g_mantis_bug_file_table, $g_normal_date_format, $g_handle_bug_threshold,
$g_file_upload_method, $s_delete_link;

$c_id = (integer) $p_bug_id;

$query = "SELECT *, UNIX_TIMESTAMP(date_added) as date_added ".
"FROM $g_mantis_bug_file_table ".
"FROM " . config_get('mantis_bug_file_table') . ' '.
"WHERE bug_id='$c_id'";
$result = db_query( $query );
$num_files = db_num_rows( $result );
for ($i = 0; $i < $num_files; $i++) {
$row = db_fetch_array( $result );
extract( $row, EXTR_PREFIX_ALL, 'v' );
$v_filesize = number_format( $v_filesize );
$v_date_added = date( $g_normal_date_format, ( $v_date_added ) );
$v_date_added = date( config_get( 'normal_date_format' ), ( $v_date_added ) );

PRINT "<a href=\"file_download.php?f_id=$v_id&amp;f_type=bug\">".file_get_display_name($v_filename)."</a> ($v_filesize bytes) <span class=\"italic\">$v_date_added</span>";

if ( access_level_check_greater_or_equal( $g_handle_bug_threshold ) ) {
PRINT " [<a class=\"small\" href=\"bug_file_delete.php?f_id=$p_bug_id&amp;f_file_id=$v_id\">$s_delete_link</a>]";
if ( access_level_check_greater_or_equal( config_get( 'handle_bug_threshold' ) ) ) {
PRINT " [<a class=\"small\" href=\"bug_file_delete.php?f_id=$p_bug_id&amp;f_file_id=$v_id\">" . lang_get('delete_link') . '</a>]';
}

if ( ( FTP == $g_file_upload_method ) && file_exists ( $v_diskfile ) ) {
if ( ( FTP == config_get( 'file_upload_method' ) ) && file_exists ( $v_diskfile ) ) {
PRINT " (cached)";
}

Expand All @@ -62,13 +59,11 @@ function file_ftp_cache_cleanup() {
# --------------------
# Connect to ftp server using configured server address, user name, and password.
function file_ftp_connect() {
global $g_file_upload_ftp_server, $g_file_upload_ftp_user, $g_file_upload_ftp_pass;

$conn_id = ftp_connect($g_file_upload_ftp_server);
$login_result = ftp_login($conn_id, $g_file_upload_ftp_user, $g_file_upload_ftp_pass);
$conn_id = ftp_connect( config_get( 'file_upload_ftp_server' ) );
$login_result = ftp_login( $conn_id, config_get( 'file_upload_ftp_user' ), config_get( 'file_upload_ftp_pass' ) );

if ( ( !$conn_id ) || ( !$login_result ) ) {
# @@@ handle error
trigger_error( ERROR_FTP_CONNECT_ERROR, ERROR );
}

return $conn_id;
Expand Down
9 changes: 5 additions & 4 deletions lang/strings_english.txt
Expand Up @@ -9,11 +9,11 @@
###########################################################################
# English strings for Mantis
# -------------------------------------------------
# $Revision: 1.76 $
# $Author: jfitzell $
# $Date: 2002-08-26 00:40:23 $
# $Revision: 1.77 $
# $Author: vboctor $
# $Date: 2002-08-26 22:42:28 $
#
# $Id: strings_english.txt,v 1.76 2002-08-26 00:40:23 jfitzell Exp $
# $Id: strings_english.txt,v 1.77 2002-08-26 22:42:28 vboctor Exp $
###########################################################################
?>
<?php
Expand Down Expand Up @@ -168,6 +168,7 @@
$MANTIS_ERROR[ERROR_BUGNOTE_NOT_FOUND] = 'ERROR: Bugnote not found.';
$MANTIS_ERROR[ERROR_PROJECT_NOT_FOUND] = 'ERROR: Project not found.';
$MANTIS_ERROR[ERROR_DB_FIELD_NOT_FOUND] = 'ERROR: Database field not found.';
$MANTIS_ERROR[ERROR_FTP_CONNECT_ERROR] = 'ERROR: Unable to connect to FTP server.';

# General Strings
$s_go_back = 'Go Back';
Expand Down

0 comments on commit fc325f3

Please sign in to comment.