Skip to content

Commit

Permalink
Modified BLOB field to LONGBLOB. Added file upload into database. Ren…
Browse files Browse the repository at this point in the history
…amed g_store_file_to to g_file_upload_method.

git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@586 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
Kenzaburo Ito committed Dec 28, 2001
1 parent b40c647 commit 423dad7
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 26 deletions.
5 changes: 4 additions & 1 deletion ChangeLog
Expand Up @@ -3,10 +3,13 @@ Mantis
01.01.2001 - 0.17.0

* Modified many files for extensive use of CSS.
* Modified BLOB field to LONGBLOB.
* Added view by page feature.
* Added edit new link in news update page.
* Added file upload into database.
* Removed site_settings pages.
* Removed unused cookie varaibles.
* Removed unused cookie variables.
* Renamed g_store_file_to to g_file_upload_method.

12.01.2001 - 0.16.1

Expand Down
2 changes: 1 addition & 1 deletion bug_delete.php3
Expand Up @@ -50,7 +50,7 @@
WHERE bug_id='$f_id'";
$result = db_query($query);

if ( $g_store_file_to==1 ) {
if ( DISK == $g_file_upload_method ) {
### Delete files from disk
$query = "SELECT diskfile
FROM $g_mantis_bug_file_table
Expand Down
22 changes: 15 additions & 7 deletions bug_file_add.php3
Expand Up @@ -24,14 +24,22 @@

### prepare variables for insertion
$f_file_name = $f_id."-".$f_file_name;
umask( 0333 ); # make read only
copy($f_file, $t_file_path.$f_file_name);
$t_file_size = filesize( $f_file );
$t_content = addslashes(fread(fopen($f_file, "r"), filesize($f_file)));
$query = "INSERT INTO $g_mantis_bug_file_table
(id, bug_id, title, description, diskfile, filename, folder, filesize, date_added, content)
VALUES
(null, $f_id, '', '', '$t_file_path$f_file_name', '$f_file_name', '$t_file_path', $t_file_size, NOW(), '')";

switch ( $g_file_upload_method ) {
case DISK: umask( 0333 ); # make read only
copy($f_file, $t_file_path.$f_file_name);
$query = "INSERT INTO $g_mantis_bug_file_table
(id, bug_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content)
VALUES
(null, $f_id, '', '', '$t_file_path$f_file_name', '$f_file_name', '$t_file_path', $t_file_size, '$f_file_type', NOW(), '')";
case DATABASE:
$t_content = addslashes( fread ( fopen( $f_file, "r" ), $t_file_size ) );
$query = "INSERT INTO $g_mantis_bug_file_table
(id, bug_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content)
VALUES
(null, $f_id, '', '', '$t_file_path$f_file_name', '$f_file_name', '$t_file_path', $t_file_size, '$f_file_type', NOW(), '$t_content')";
}
$result = db_query( $query );
}
?>
Expand Down
10 changes: 5 additions & 5 deletions config_inc.php
Expand Up @@ -307,11 +307,10 @@
$g_allow_file_upload = 1;

# Upload destination: specify actual location in project settings
# 1 = "disk"
# 2 = "database" (currently only disk is supported)
$g_store_file_to = 1;
# DISK or DATABASE
$g_file_upload_method = DATABASE;

$g_max_file_size = 5000000;
$g_max_file_size = 5000000; # 5 MB

############################
### Mantis HTML Settings ###
Expand Down Expand Up @@ -582,7 +581,6 @@
#----------------------------------
# bugnote includes
$g_bugnote_include_file = $g_absolute_path."bugnote_inc.php";
#$g_bugnote_add_include_file = $g_path."bugnote_add_inc.php";
#----------------------------------

#----------------------------------
Expand Down Expand Up @@ -750,6 +748,8 @@
$g_view_bug_inc = $g_absolute_path."view_bug_inc.php";
$g_bug_file_upload_inc = $g_absolute_path."bug_file_upload_inc.php";

$g_file_download = $g_path."file_download".$g_php;

$g_print_all_bug_page = $g_path."print_all_bug_page".$g_php;

$g_csv_export_inc = $g_path."view_csv_export_inc.php";
Expand Down
4 changes: 4 additions & 0 deletions constant_inc.php
Expand Up @@ -78,6 +78,10 @@
define( "MD5", 2 );
define( "LDAP", 3 );

# file upload methods
define( "DISK", 1 );
define( "DATABASE", 2 );

# email padding
define( "EMAIL_PAD_LENGTH", 28 );
?>
4 changes: 2 additions & 2 deletions db_generate.sql
Expand Up @@ -19,7 +19,7 @@ CREATE TABLE mantis_bug_file_table (
filesize int(11) DEFAULT '0' NOT NULL,
file_type varchar(250) NOT NULL default '',
date_added datetime DEFAULT '1970-01-01 00:00:01' NOT NULL,
content blob NOT NULL,
content longblob NOT NULL,
PRIMARY KEY (id)
);

Expand Down Expand Up @@ -165,7 +165,7 @@ CREATE TABLE mantis_project_file_table (
filesize int(11) DEFAULT '0' NOT NULL,
file_type varchar(250) NOT NULL default '',
date_added datetime DEFAULT '1970-01-01 00:00:01' NOT NULL,
content blob NOT NULL,
content longblob NOT NULL,
PRIMARY KEY (id)
);

Expand Down
10 changes: 9 additions & 1 deletion db_upgrade.sql
Expand Up @@ -373,4 +373,12 @@ CREATE TABLE mantis_bug_history_table (
KEY user_id (user_id)
);

ALTER TABLE mantis_project_version_table ADD date_order DATETIME DEFAULT '1970-01-01 00:00:01' NOT NULL;
ALTER TABLE mantis_project_version_table ADD date_order DATETIME DEFAULT '1970-01-01 00:00:01' NOT NULL;

# =================
# 0.16.x to 0.17.0
# =================

# Allow for files greater than 64KB
ALTER TABLE mantis_bug_file_table CHANGE content content LONGBLOB NOT NULL;
ALTER TABLE mantis_project_file_table CHANGE content content LONGBLOB NOT NULL;
37 changes: 37 additions & 0 deletions file_download.php3
@@ -0,0 +1,37 @@
<?
# Mantis - a php based bugtracking system
# Copyright (C) 2000, 2001 Kenzaburo Ito - kenito@300baud.org
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details
?>
<?
### Add file and redirect to the referring page
?>
<? include( "core_API.php" ) ?>
<? login_cookie_check() ?>
<?
db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name );
#check_access( DEVELOPER );

switch ( $f_type ) {
case "bug": $query = "SELECT *
FROM $g_mantis_bug_file_table
WHERE id='$f_id'";
break;
case "doc": $query = "SELECT *
FROM $g_mantis_project_file_table
WHERE id='$f_id'";
break;
}

$result = db_query( $query );
$row = db_fetch_array( $result );
extract( $row, EXTR_PREFIX_ALL, "v" );

header( "Content-type: $v_file_type" );
header( "Content-Length: ".$v_filesize );
header( "Content-Disposition: filename=$v_filename" );
header( "Content-Description: Download Data" );

echo $v_content;
?>
22 changes: 15 additions & 7 deletions proj_doc_add.php3
Expand Up @@ -22,14 +22,22 @@
$f_description = string_prepare_textarea( $f_description );

$f_file_name = $g_project_cookie_val."-".$f_file_name;
umask(0333); # make read only
copy($f_file, $t_file_path.$f_file_name);
$t_file_size = filesize( $f_file );
$t_content = addslashes(fread(fopen($f_file, "r"), filesize($f_file)));
$query = "INSERT INTO mantis_project_file_table
(id, project_id, title, description, diskfile, filename, folder, filesize, date_added, content)
VALUES
(null, $g_project_cookie_val, '$f_title', '$f_description', '$t_file_path$f_file_name', '$f_file_name', '$t_file_path', $t_file_size, NOW(), '')";

switch ( $g_file_upload_method ) {
case DISK: umask( 0333 ); # make read only
copy($f_file, $t_file_path.$f_file_name);
$query = "INSERT INTO mantis_project_file_table
(id, project_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content)
VALUES
(null, $g_project_cookie_val, '$f_title', '$f_description', '$t_file_path$f_file_name', '$f_file_name', '$t_file_path', $t_file_size, '$f_file_type', NOW(), '')";
case DATABASE:
$t_content = addslashes( fread ( fopen( $f_file, "r" ), $t_file_size ) );
$query = "INSERT INTO mantis_project_file_table
(id, project_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content)
VALUES
(null, $g_project_cookie_val, '$f_title', '$f_description', '$t_file_path$f_file_name', '$f_file_name', '$t_file_path', $t_file_size, '$f_file_type', NOW(), '$t_content')";
}
$result = db_query( $query );
}
?>
Expand Down
8 changes: 7 additions & 1 deletion proj_doc_page.php3
Expand Up @@ -55,8 +55,14 @@
?>
<tr valign="top" bgcolor="<? echo $status_color ?>">
<td>
<a href="<? echo $v_diskfile ?>"><? echo $v_title ?></a>
<?
switch ( $g_file_upload_method ) {
case DISK: PRINT "<a href=\"$v_diskfile\">$v_title</a> ($v_filesize KB)";
break;
case DATABASE:
PRINT "<a href=\"$g_file_download?f_id=$v_id&f_type=doc\">$v_title</a> ($v_filesize KB)";
break;
}
if ( access_level_check_greater_or_equal( MANAGER ) ) {
print_bracket_link( $g_proj_doc_edit_page."?f_id=".$v_id, "edit" );
}
Expand Down
8 changes: 7 additions & 1 deletion view_bug_page.php3
Expand Up @@ -204,7 +204,13 @@
$v2_diskfile = str_replace( $DOCUMENT_ROOT, "", $v2_diskfile );
$v2_filesize = round( $v2_filesize / 1024 );

PRINT "<a href=\"$v2_diskfile\">$v2_filename</a> ($v2_filesize KB)";
switch ( $g_file_upload_method ) {
case DISK: PRINT "<a href=\"$v2_diskfile\">$v2_filename</a> ($v2_filesize KB)";
break;
case DATABASE:
PRINT "<a href=\"$g_file_download?f_id=$v2_id&f_type=bug\">$v2_filename</a> ($v2_filesize KB)";
break;
}
if ( $i != ($num_files - 1) ) {
PRINT "<br>";
}
Expand Down

0 comments on commit 423dad7

Please sign in to comment.