| [ Index ] |
|
Code source de Mantis 1.1.0rc3 |
1 <?php 2 # Mantis - a php based bugtracking system 3 4 # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 5 # Copyright (C) 2002 - 2007 Mantis Team - mantisbt-dev@lists.sourceforge.net 6 7 # Mantis is free software: you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation, either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # Mantis is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with Mantis. If not, see <http://www.gnu.org/licenses/>. 19 20 # -------------------------------------------------------- 21 # $Id: proj_doc_update.php,v 1.30.2.1 2007-10-13 22:34:24 giallu Exp $ 22 # -------------------------------------------------------- 23 24 require_once ( 'core.php' ); 25 26 $t_core_path = config_get( 'core_path' ); 27 28 require_once( $t_core_path.'file_api.php' ); 29 30 # Check if project documentation feature is enabled. 31 if ( OFF == config_get( 'enable_project_documentation' ) || 32 !file_is_uploading_enabled() || 33 !file_allow_project_upload() ) { 34 access_denied(); 35 } 36 37 $f_file_id = gpc_get_int( 'file_id' ); 38 $f_title = gpc_get_string( 'title' ); 39 $f_description = gpc_get_string( 'description' ); 40 $f_file = gpc_get_file( 'file' ); 41 42 $t_project_id = file_get_field( $f_file_id, 'project_id', 'project' ); 43 44 access_ensure_project_level( config_get( 'upload_project_file_threshold' ), $t_project_id ); 45 46 if ( is_blank( $f_title ) ) { 47 trigger_error( ERROR_EMPTY_FIELD, ERROR ); 48 } 49 50 $c_file_id = db_prepare_int( $f_file_id ); 51 $c_title = db_prepare_string( $f_title ); 52 $c_description = db_prepare_string( $f_description ); 53 54 $t_project_file_table = config_get( 'mantis_project_file_table' ); 55 56 #@@@ (thraxisp) this code should probably be integrated into file_api to share 57 # methods used to store files 58 59 extract( $f_file, EXTR_PREFIX_ALL, 'v' ); 60 61 if ( is_uploaded_file( $v_tmp_name ) ) { 62 if ( php_version_at_least( '4.2.0' ) ) { 63 switch ( (int) $v_error ) { 64 case UPLOAD_ERR_INI_SIZE: 65 case UPLOAD_ERR_FORM_SIZE: 66 trigger_error( ERROR_FILE_TOO_BIG, ERROR ); 67 break; 68 case UPLOAD_ERR_PARTIAL: 69 case UPLOAD_ERR_NO_FILE: 70 trigger_error( ERROR_FILE_NO_UPLOAD_FAILURE, ERROR ); 71 break; 72 default: 73 break; 74 } 75 } 76 77 if ( ( '' == $v_tmp_name ) || ( '' == $v_name ) ) { 78 trigger_error( ERROR_FILE_NO_UPLOAD_FAILURE, ERROR ); 79 } 80 if ( !file_type_check( $v_name ) ) { 81 trigger_error( ERROR_FILE_NOT_ALLOWED, ERROR ); 82 } 83 84 if ( !is_readable( $v_tmp_name ) ) { 85 trigger_error( ERROR_UPLOAD_FAILURE, ERROR ); 86 } 87 88 $t_project_id = helper_get_current_project(); 89 90 # grab the original file path and name 91 $t_disk_file_name = file_get_field( $f_file_id, 'diskfile', 'project' ); 92 $t_file_path = dirname( $t_disk_file_name ); 93 94 # prepare variables for insertion 95 $c_file_name = db_prepare_string( $v_name ); 96 $c_file_type = db_prepare_string( $v_type ); 97 $t_file_size = filesize( $v_tmp_name ); 98 $t_max_file_size = (int)min( ini_get_number( 'upload_max_filesize' ), ini_get_number( 'post_max_size' ), config_get( 'max_file_size' ) ); 99 if ( $t_file_size > $t_max_file_size ) { 100 trigger_error( ERROR_FILE_TOO_BIG, ERROR ); 101 } 102 $c_file_size = db_prepare_int( $t_file_size ); 103 104 $t_method = config_get( 'file_upload_method' ); 105 switch ( $t_method ) { 106 case FTP: 107 case DISK: 108 file_ensure_valid_upload_path( $t_file_path ); 109 110 if ( FTP == $t_method ) { 111 $conn_id = file_ftp_connect(); 112 file_ftp_delete ( $conn_id, $t_disk_file_name ); 113 file_ftp_put ( $conn_id, $t_disk_file_name, $v_tmp_name ); 114 file_ftp_disconnect ( $conn_id ); 115 } 116 if ( file_exists( $t_disk_file_name ) ) { 117 file_delete_local( $t_disk_file_name ); 118 } 119 if ( !move_uploaded_file( $v_tmp_name, $t_disk_file_name ) ) { 120 trigger_error( FILE_MOVE_FAILED, ERROR ); 121 } 122 chmod( $t_disk_file_name, config_get( 'attachments_file_permissions' ) ); 123 124 $c_content = ''; 125 break; 126 case DATABASE: 127 $c_content = db_prepare_string( fread ( fopen( $v_tmp_name, 'rb' ), $v_size ) ); 128 break; 129 default: 130 # @@@ Such errors should be checked in the admin checks 131 trigger_error( ERROR_GENERIC, ERROR ); 132 } 133 $t_now = db_now(); 134 $query = "UPDATE $t_project_file_table 135 SET title='$c_title', description='$c_description', date_added=$t_now, 136 filename='$c_file_name', filesize=$c_file_size, file_type='$c_file_type', content='$c_content' 137 WHERE id='$c_file_id'"; 138 } else { 139 $query = "UPDATE $t_project_file_table 140 SET title='$c_title', description='$c_description' 141 WHERE id='$c_file_id'"; 142 } 143 144 $result = db_query( $query ); 145 if ( !$result ) { 146 trigger_error( ERROR_GENERIC, ERROR ); 147 } 148 149 $t_redirect_url = 'proj_doc_page.php'; 150 151 html_page_top1(); 152 html_meta_redirect( $t_redirect_url ); 153 html_page_top2(); 154 ?> 155 <br /> 156 <div align="center"> 157 <?php 158 echo lang_get( 'operation_successful' ).'<br />'; 159 print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); 160 ?> 161 </div> 162 163 <?php html_page_bottom1( __FILE__ ) ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Thu Nov 29 09:42:17 2007 | par Balluche grâce à PHPXref 0.7 |
|