Changeset 1631
- Timestamp:
- Dec 3, 2006, 11:32:02 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/thumbnail.php
r1379 r1631 64 64 unset($extension); 65 65 } 66 66 67 67 if ( isset( $srcImage ) ) 68 68 { … … 107 107 $destWidth,$destHeight,$srcWidth,$srcHeight ); 108 108 } 109 110 $tndir = $dirname.'/thumbnail'; 111 if (!is_dir($tndir)) 112 { 113 if (!is_writable($dirname)) 114 { 115 array_push($page['errors'], 116 '['.$dirname.'] : '.$lang['no_write_access']); 117 return false; 118 } 119 umask(0000); 120 mkdir($tndir, 0777); 121 } 122 109 110 if (($tndir = mkget_thumbnail_dir($dirname, $page['errors'])) == false) 111 { 112 return false; 113 } 114 123 115 $dest_file = $tndir.'/'.$conf['prefix_thumbnail']; 124 116 $dest_file.= get_filename_wo_extension($filename); -
trunk/include/functions.inc.php
r1609 r1631 216 216 } 217 217 218 /** 219 * returns thumbnail directory name of input diretoty name 220 * make thumbnail directory is necessary 221 * set error messages on array messages 222 * 223 * @param: 224 * string $dirname 225 * arrayy $errors 226 * @return bool false on error else string directory name 227 */ 228 function mkget_thumbnail_dir($dirname, &$errors) 229 { 230 $tndir = $dirname.'/thumbnail'; 231 if (!is_dir($tndir)) 232 { 233 if (!is_writable($dirname)) 234 { 235 array_push($errors, 236 '['.$dirname.'] : '.l10n('no_write_access')); 237 return false; 238 } 239 umask(0000); 240 mkdir($tndir, 0777); 241 } 242 243 return $tndir; 244 } 245 218 246 // The get_picture_size function return an array containing : 219 247 // - $picture_size[0] : final width -
trunk/template/yoga/content.css
r1450 r1631 6 6 7 7 BODY#theCommentsPage #content, 8 BODY#theUploadPage #content, 8 9 BODY#theRegisterPage #content, 9 10 BODY#theIdentificationPage #content, -
trunk/template/yoga/upload.tpl
r859 r1631 1 <h2>{L_TITLE}</h2> 2 <!-- BEGIN upload_not_successful --> 3 <form enctype="multipart/form-data" method="post" action="{F_ACTION}"> 4 <table style="width:80%;margin-left:auto;margin-right:auto;"> 5 <!-- BEGIN errors --> 6 <tr> 7 <td colspan="2"> 8 <div class="errors"> 9 <ul> 10 <!-- BEGIN error --> 11 <li>{upload_not_successful.errors.error.ERROR}</li> 12 <!-- END error --> 13 </ul> 14 </div> 15 </td> 16 </tr> 17 <!-- END errors --> 18 <tr> 19 <td colspan="2" class="menu"> 20 <div style="text-align:center;">{ADVISE_TITLE}</div> 21 <ul> 22 <!-- BEGIN advise --> 23 <li>{upload_not_successful.advise.ADVISE}</li> 24 <!-- END advise --> 25 </ul> 26 </td> 27 </tr> 28 <tr> 29 <td colspan="2" align="center" style="padding:10px;"> 30 <input name="picture" type="file" value="" /> 31 </td> 32 </tr> 33 <!-- BEGIN fields --> 34 <!-- username --> 35 <tr> 36 <td class="menu">{L_USERNAME} <span style="color:red;">*</span></td> 37 <td align="center" style="padding:10px;"> 38 <input name="username" type="text" value="{NAME}" /> 39 </td> 40 </tr> 41 <!-- mail address --> 42 <tr> 43 <td class="menu">{L_EMAIL} <span style="color:red;">*</span></td> 44 <td align="center" style="padding:10px;"> 45 <input name="mail_address" type="text" value="{EMAIL}" /> 46 </td> 47 </tr> 48 <!-- name of the picture --> 49 <tr> 50 <td class="menu">{L_NAME_IMG}</td> 51 <td align="center" style="padding:10px;"> 52 <input name="name" type="text" value="{NAME_IMG}" /> 53 </td> 54 </tr> 55 <!-- author --> 56 <tr> 57 <td class="menu">{L_AUTHOR}</td> 58 <td align="center" style="padding:10px;"> 59 <input name="author" type="text" value="{AUTHOR_IMG}" /> 60 </td> 61 </tr> 62 <!-- date of creation --> 63 <tr> 64 <td class="menu">{L_CREATION_DATE}</td> 65 <td align="center" style="padding:10px;"> 66 <input name="date_creation" type="text" value="{DATE_IMG}" /> 67 </td> 68 </tr> 69 <!-- comment --> 70 <tr> 71 <td class="menu">{L_COMMENT}</td> 72 <td align="center" style="padding:10px;"> 73 <textarea name="comment" rows="3" cols="40" style="overflow:auto">{COMMENT_IMG}</textarea> 74 </td> 75 </tr> 76 <!-- END fields --> 77 <tr> 78 <td colspan="2" align="center"> 79 <input name="submit" type="submit" value="{L_SUBMIT}" class="bouton" /> 80 </td> 81 </tr> 82 </table> 83 </form> 84 <!-- END upload_not_successful --> 85 <!-- BEGIN upload_successful --> 86 {L_UPLOAD_DONE}<br /> 87 <!-- END upload_successful --> 88 <div style="text-align:center;"> 89 <a href="{U_RETURN}">[ {L_RETURN} ]</a> 90 </div> 91 <!-- BEGIN note --> 92 <div style="text-align:left;"><span style="color:red;">*</span> : {L_MANDATORY}</div> 93 <!-- END note --> 1 <div id="content"> 2 3 <div class="titrePage"> 4 <ul class="categoryActions"> 5 <li><a href="{U_HOME}" title="{lang:return to homepage}"><img src="{themeconf:icon_dir}/home.png" class="button" alt="{lang:home}"/></a></li> 6 </ul> 7 <h2>{lang:upload_title}</h2> 8 </div> 9 10 <!-- BEGIN upload_not_successful --> 11 <form enctype="multipart/form-data" method="post" action="{F_ACTION}"> 12 <table style="width:80%;margin-left:auto;margin-right:auto;"> 13 <!-- BEGIN errors --> 14 <tr> 15 <td colspan="2"> 16 <div class="errors"> 17 <ul> 18 <!-- BEGIN error --> 19 <li>{upload_not_successful.errors.error.ERROR}</li> 20 <!-- END error --> 21 </ul> 22 </div> 23 </td> 24 </tr> 25 <!-- END errors --> 26 <tr> 27 <td colspan="2" class="menu"> 28 <div style="text-align:center;">{ADVISE_TITLE}</div> 29 <ul> 30 <!-- BEGIN advise --> 31 <li>{upload_not_successful.advise.ADVISE}</li> 32 <!-- END advise --> 33 </ul> 34 </td> 35 </tr> 36 <tr> 37 <td colspan="2" align="center" style="padding:10px;"> 38 <input name="picture" type="file" value="" /> 39 </td> 40 </tr> 41 <!-- BEGIN fields --> 42 <!-- username --> 43 <tr> 44 <td class="menu">{lang:upload_username} <span style="color:red;">*</span></td> 45 <td align="left" style="padding:10px;"> 46 <input name="username" type="text" value="{NAME}" /> 47 </td> 48 </tr> 49 <!-- mail address --> 50 <tr> 51 <td class="menu">{lang:mail_address} <span style="color:red;">*</span></td> 52 <td align="left" style="padding:10px;"> 53 <input name="mail_address" type="text" value="{EMAIL}" /> 54 </td> 55 </tr> 56 <!-- name of the picture --> 57 <tr> 58 <td class="menu">{lang:upload_name}</td> 59 <td align="left" style="padding:10px;"> 60 <input name="name" type="text" value="{NAME_IMG}" /> 61 </td> 62 </tr> 63 <!-- author --> 64 <tr> 65 <td class="menu">{lang:upload_author}</td> 66 <td align="left" style="padding:10px;"> 67 <input name="author" type="text" value="{AUTHOR_IMG}" /> 68 </td> 69 </tr> 70 <!-- date of creation --> 71 <tr> 72 <td class="menu">{lang:upload_creation_date}</td> 73 <td align="left" style="padding:10px;"> 74 <input name="date_creation" type="text" value="{DATE_IMG}" /> 75 </td> 76 </tr> 77 <!-- comment --> 78 <tr> 79 <td class="menu">{lang:comment}</td> 80 <td align="left" style="padding:10px;"> 81 <textarea name="comment" rows="3" cols="40" style="overflow:auto">{COMMENT_IMG}</textarea> 82 </td> 83 </tr> 84 <!-- END fields --> 85 <tr> 86 <td colspan="2" align="center"> 87 <input name="submit" type="submit" value="{lang:submit}" class="bouton" /> 88 </td> 89 </tr> 90 </table> 91 </form> 92 <!-- END upload_not_successful --> 93 <!-- BEGIN upload_successful --> 94 {lang:upload_successful}<br /> 95 <div style="text-align:center;"> 96 <a href="{U_RETURN}">[ {lang:home} ]</a> 97 </div> 98 <!-- END upload_successful --> 99 <!-- BEGIN note --> 100 <div style="text-align:left;"><span style="color:red;">*</span> : {lang:mandatory}</div> 101 <!-- END note --> 102 </div> <!-- content --> -
trunk/upload.php
r1082 r1631 28 28 include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); 29 29 30 $username = !empty($_POST['username'])?$_POST['username']:$user['username']; 31 $mail_address = !empty($_POST['mail_address'])?$_POST['mail_address']:@$user['mail_address']; 32 $name = !empty($_POST['name'])?$_POST['name']:''; 33 $author = !empty($_POST['author'])?$_POST['author']:''; 34 $date_creation = !empty($_POST['date_creation'])?$_POST['date_creation']:''; 35 $comment = !empty($_POST['comment'])?$_POST['comment']:''; 36 30 37 //------------------------------------------------------------------- functions 31 38 // The validate_upload function checks if the image of the given path is valid. … … 41 48 $image_max_width, $image_max_height ) 42 49 { 43 global $conf, $lang ;44 50 global $conf, $lang, $page, $mail_address; 51 45 52 $result = array(); 46 53 $result['error'] = array(); … … 49 56 if (!in_array($extension, $conf['picture_ext'])) 50 57 { 51 array_push( $result['error'], $lang['upload_advise_filetype']);58 array_push( $result['error'], l10n('upload_advise_filetype') ); 52 59 return $result; 53 60 } … … 60 67 { 61 68 array_push( $result['error'], 62 $lang['upload_advise_filesize'].$my_max_file_size.' KB' );69 l10n('upload_advise_filesize').$my_max_file_size.' KB' ); 63 70 } 64 71 else … … 68 75 if ( !move_uploaded_file( $_FILES['picture']['tmp_name'], $temp_name ) ) 69 76 { 70 array_push( $result['error'], $lang['upload_cannot_upload']);77 array_push( $result['error'], l10n('upload_cannot_upload') ); 71 78 } 72 79 else … … 78 85 { 79 86 array_push( $result['error'], 80 $lang['upload_advise_width'].$image_max_width.' px' );87 l10n('upload_advise_width').$image_max_width.' px' ); 81 88 } 82 89 if ( isset( $image_max_height ) … … 85 92 { 86 93 array_push( $result['error'], 87 $lang['upload_advise_height'].$image_max_height.' px' );94 l10n('upload_advise_height').$image_max_height.' px' ); 88 95 } 89 96 // $size[2] == 1 means GIF … … 96 103 case 3 : $result['type'] = 'png'; break; 97 104 default : 98 array_push( $result['error'], $lang['upload_advise_filetype']);105 array_push( $result['error'], l10n('upload_advise_filetype') ); 99 106 } 100 107 } … … 109 116 @chmod( $temp_name, 0644); 110 117 } 118 119 //------------------------------------------------------------ log informations 120 pwg_log('upload', 121 get_cat_display_name($page['cat_name']), 122 $_FILES['picture']['name']. 123 ' ['.$mail_address.'] '.'['.($result ? 'OK' : 'KO').']'); 124 111 125 return $result; 112 } 126 } 113 127 114 128 //-------------------------------------------------- access authorization check … … 146 160 if ( @is_file( $path ) ) 147 161 { 148 array_push( $error, $lang['upload_file_exists']);162 array_push( $error, l10n('upload_file_exists') ); 149 163 } 150 164 // test de la présence des champs obligatoires 151 165 if ( empty($_FILES['picture']['name'])) 152 166 { 153 array_push( $error, $lang['upload_filenotfound']);167 array_push( $error, l10n('upload_filenotfound') ); 154 168 } 155 169 if ( !ereg( "([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+)", 156 170 $_POST['mail_address'] ) ) 157 171 { 158 array_push( $error, $lang['reg_err_mail_address']);172 array_push( $error, l10n('reg_err_mail_address') ); 159 173 } 160 174 if ( empty($_POST['username']) ) 161 175 { 162 array_push( $error, $lang['upload_err_username']);176 array_push( $error, l10n('upload_err_username') ); 163 177 } 164 178 … … 174 188 else 175 189 { 176 array_push( $error, $lang['err_date']);190 array_push( $error, l10n('err_date') ); 177 191 } 178 192 } … … 189 203 if ( !preg_match( '/^[a-zA-Z0-9-_.]+$/', $_FILES['picture']['name'] ) ) 190 204 { 191 array_push( $error, $lang['update_wrong_dirname']);205 array_push( $error, l10n('update_wrong_dirname') ); 192 206 } 193 207 … … 229 243 $file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") ); 230 244 $extension = get_extension( $_FILES['picture']['name'] ); 231 $path = $page['cat_dir'].'thumbnail/'; 232 $path.= $conf['prefix_thumbnail'].$file.'.'.$extension; 233 $result = validate_upload( $path, $conf['upload_maxfilesize'], 234 $conf['upload_maxwidth_thumbnail'], 235 $conf['upload_maxheight_thumbnail'] ); 236 for ( $j = 0; $j < sizeof( $result['error'] ); $j++ ) 237 { 238 array_push( $error, $result['error'][$j] ); 239 } 245 246 if (($path = mkget_thumbnail_dir($page['cat_dir'], $error)) != false) 247 { 248 $path.= '/'.$conf['prefix_thumbnail'].$file.'.'.$extension; 249 $result = validate_upload( $path, $conf['upload_maxfilesize'], 250 $conf['upload_maxwidth_thumbnail'], 251 $conf['upload_maxheight_thumbnail'] ); 252 for ( $j = 0; $j < sizeof( $result['error'] ); $j++ ) 253 { 254 array_push( $error, $result['error'][$j] ); 255 } 256 } 257 240 258 if ( sizeof( $error ) == 0 ) 241 259 { … … 252 270 // Start output of page 253 271 // 254 $title= $lang['upload_title']; 272 $title= l10n('upload_title'); 273 $page['body_id'] = 'theUploadPage'; 255 274 include(PHPWG_ROOT_PATH.'include/page_header.php'); 256 275 $template->set_filenames(array('upload'=>'upload.tpl')); … … 264 283 if ( isset( $page['waiting_id'] ) ) 265 284 { 266 $advise_title= $lang['upload_advise_thumbnail'].$_FILES['picture']['name'];285 $advise_title=l10n('upload_advise_thumbnail').$_FILES['picture']['name']; 267 286 } 268 287 else 269 288 { 270 $advise_title = $lang['upload_advise'];289 $advise_title = l10n('upload_advise'); 271 290 $advise_title.= get_cat_display_name($page['cat_name']); 272 291 } 273 274 $username = !empty($_POST['username'])?$_POST['username']:$user['username'];275 $mail_address = !empty($_POST['mail_address'])?$_POST['mail_address']:@$user['mail_address'];276 $name = !empty($_POST['name'])?$_POST['name']:'';277 $author = !empty($_POST['author'])?$_POST['author']:'';278 $date_creation = !empty($_POST['date_creation'])?$_POST['date_creation']:'';279 $comment = !empty($_POST['comment'])?$_POST['comment']:'';280 292 281 293 $template->assign_vars( 282 294 array( 295 'U_HOME' => make_index_url(), 296 283 297 'ADVISE_TITLE' => $advise_title, 284 298 'NAME' => $username, … … 288 302 'DATE_IMG' => $date_creation, 289 303 'COMMENT_IMG' => $comment, 290 291 'L_TITLE' => $lang['upload_title'], 292 'L_USERNAME' => $lang['upload_username'], 293 'L_EMAIL' => $lang['mail_address'], 294 'L_NAME_IMG' => $lang['upload_name'], 295 'L_SUBMIT' => $lang['submit'], 296 'L_AUTHOR' => $lang['upload_author'], 297 'L_CREATION_DATE' => $lang['upload_creation_date'], 298 'L_COMMENT' => $lang['comment'], 299 'L_RETURN' => $lang['home'], 300 'L_RETURN_HINT' => $lang['home_hint'], 301 'L_UPLOAD_DONE' => $lang['upload_successful'], 302 'L_MANDATORY' => $lang['mandatory'], 303 304 304 305 'F_ACTION' => $u_form, 305 306 … … 324 325 if ( !empty($conf['upload_maxfilesize']) ) 325 326 { 326 $content = $lang['upload_advise_filesize'];327 $content = l10n('upload_advise_filesize'); 327 328 $content.= $conf['upload_maxfilesize'].' KB'; 328 329 $template->assign_block_vars('upload_not_successful.advise',array('ADVISE'=>$content)); … … 333 334 if ( $conf['upload_maxwidth_thumbnail'] != '' ) 334 335 { 335 $content = $lang['upload_advise_width'];336 $content = l10n('upload_advise_width'); 336 337 $content.= $conf['upload_maxwidth_thumbnail'].' px'; 337 338 $template->assign_block_vars('upload_not_successful.advise',array('ADVISE'=>$content)); 338 339 } 339 340 if ( $conf['upload_maxheight_thumbnail'] != '' ) 340 341 { 341 $content = $lang['upload_advise_height'];342 $content = l10n('upload_advise_height'); 342 343 $content.= $conf['upload_maxheight_thumbnail'].' px'; 343 344 $template->assign_block_vars('upload_not_successful.advise',array('ADVISE'=>$content)); 344 345 } 345 346 } … … 348 349 if ( $conf['upload_maxwidth'] != '' ) 349 350 { 350 $content = $lang['upload_advise_width'];351 $content = l10n('upload_advise_width'); 351 352 $content.= $conf['upload_maxwidth'].' px'; 352 353 $template->assign_block_vars('upload_not_successful.advise',array('ADVISE'=>$content)); 353 354 } 354 355 if ( $conf['upload_maxheight'] != '' ) 355 356 { 356 $content = $lang['upload_advise_height'];357 $content = l10n('upload_advise_height'); 357 358 $content.= $conf['upload_maxheight'].' px'; 358 359 } 360 } 361 $template->assign_block_vars('upload_not_successful.advise',array('ADVISE'=> $lang['upload_advise_filetype']));359 $template->assign_block_vars('upload_not_successful.advise',array('ADVISE'=>$content)); 360 } 361 } 362 $template->assign_block_vars('upload_not_successful.advise',array('ADVISE'=>l10n('upload_advise_filetype'))); 362 363 363 364 //----------------------------------------- optionnal username and mail address … … 365 366 { 366 367 $template->assign_block_vars('upload_not_successful.fields',array()); 367 368 $template->assign_block_vars('note',array()); 368 369 } 369 370 } … … 372 373 $template->assign_block_vars('upload_successful',array()); 373 374 } 375 374 376 //----------------------------------------------------------- html code display 375 377 $template->parse('upload');
Note: See TracChangeset
for help on using the changeset viewer.