Changeset 10 for trunk/upload.php
- Timestamp:
- May 17, 2003, 12:49:14 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/upload.php
r2 r10 1 1 <?php 2 2 /*************************************************************************** 3 * upload.php is a part of PhpWebGallery*3 * upload.php * 4 4 * ------------------- * 5 * last update : Sunday, October 27, 2002*6 * email : pierrick@z0rglub.com*5 * application : PhpWebGallery 1.3 * 6 * author : Pierrick LE GALL <pierrick@z0rglub.com> * 7 7 * * 8 8 ***************************************************************************/ … … 15 15 * * 16 16 ***************************************************************************/ 17 function get_extension( $filename ) 18 { 19 return substr ( strrchr( $filename, "." ), 1, strlen ( $filename ) ); 20 } 17 18 //------------------------------------------------------------------- functions 19 21 20 // The validate_upload function checks if the image of the given path is valid. 22 21 // A picture is valid when : … … 38 37 //echo $_FILES['picture']['name']."<br />".$temp_name; 39 38 $extension = get_extension( $_FILES['picture']['name'] ); 40 if ( $extension != 'gif' && $extension != 'jpg' &&$extension != 'png' )39 if ( $extension != 'gif' and $extension != 'jpg' and $extension != 'png' ) 41 40 { 42 41 $result['error'][$i++] = $lang['upload_advise_filetype']; … … 50 49 else if ( $_FILES['picture']['size'] > $my_max_file_size * 1024 ) 51 50 { 52 $result['error'][$i++] = $lang['upload_advise_width'].$my_max_file_size." KB"; 51 $result['error'][$i++] = 52 $lang['upload_advise_width'].$my_max_file_size.' KB'; 53 53 } 54 54 else … … 64 64 $size = getimagesize( $temp_name ); 65 65 if ( isset( $image_max_width ) 66 &&$image_max_width != ""67 &&$size[0] > $image_max_width )66 and $image_max_width != "" 67 and $size[0] > $image_max_width ) 68 68 { 69 $result['error'][$i++] = $lang['upload_advise_width'].$image_max_width." px"; 69 $result['error'][$i++] = 70 $lang['upload_advise_width'].$image_max_width." px"; 70 71 } 71 72 if ( isset( $image_max_height ) 72 &&$image_max_height != ""73 &&$size[1] > $image_max_height )73 and $image_max_height != "" 74 and $size[1] > $image_max_height ) 74 75 { 75 $result['error'][$i++] = $lang['upload_advise_height'].$image_max_height." px"; 76 $result['error'][$i++] = 77 $lang['upload_advise_height'].$image_max_height." px"; 76 78 } 77 79 // $size[2] == 1 means GIF 78 80 // $size[2] == 2 means JPG 79 81 // $size[2] == 3 means PNG 80 if ( $size[2] != 1 && $size[2] != 2 &&$size[2] != 3 )82 if ( $size[2] != 1 and $size[2] != 2 and $size[2] != 3 ) 81 83 { 82 84 $result['error'][$i++] = $lang['upload_advise_filetype']; … … 87 89 { 88 90 case 1 : 89 { 90 $result['type'] = 'gif'; 91 break; 92 } 91 $result['type'] = 'gif'; break; 93 92 case 2 : 94 { 95 $result['type'] = 'jpg'; 96 break; 97 } 93 $result['type'] = 'jpg'; break; 98 94 case 3 : 99 { 100 $result['type'] = 'png'; 101 break; 102 } 95 $result['type'] = 'png'; break; 103 96 } 104 97 } … … 117 110 check_login_authorization(); 118 111 check_cat_id( $_GET['cat'] ); 119 if ( isset( $page['cat'] ) &&is_numeric( $page['cat'] ) )112 if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) 120 113 { 121 114 check_restrictions( $page['cat'] ); … … 130 123 } 131 124 if ( $access_forbidden == true 132 || $page['cat_site_id'] != 1 133 || $conf['upload_available'] == 'false' ) 134 { 135 echo"<div style=\"text-align:center;\">".$lang['upload_forbidden']."<br />"; 136 echo "<a href=\"".add_session_id_to_url( "./diapo.php" )."\">".$lang['thumbnails']."</a></div>"; 125 or $page['cat_site_id'] != 1 126 or $conf['upload_available'] == 'false' ) 127 { 128 echo '<div style="text-align:center;">'.$lang['upload_forbidden'].'<br />'; 129 echo '<a href="'.add_session_id_to_url( './diapo.php' ).'">'; 130 echo $lang['thumbnails'].'</a></div>'; 137 131 exit(); 138 132 } 139 133 //----------------------------------------------------- template initialization 140 134 $vtp = new VTemplate; 141 $handle = $vtp->Open( './template/default/upload.vtp' ); 142 // language 143 $vtp->setGlobalVar( $handle, 'upload_page_title',$lang['upload_title'] ); 144 $vtp->setGlobalVar( $handle, 'upload_title', $lang['upload_title'] ); 145 $vtp->setGlobalVar( $handle, 'upload_username', $lang['upload_username'] ); 146 $vtp->setGlobalVar( $handle, 'reg_mail_address', $lang['reg_mail_address'] ); 147 $vtp->setGlobalVar( $handle, 'submit', $lang['submit'] ); 148 $vtp->setGlobalVar( $handle, 'upload_successful',$lang['upload_successful'] ); 149 $vtp->setGlobalVar( $handle, 'search_return_main_page', 150 $lang['search_return_main_page'] ); 135 $handle = $vtp->Open( './template/'.$user['template'].'/upload.vtp' ); 136 initialize_template(); 137 138 $tpl = array( 'upload_title', 'upload_username', 'mail_address', 'submit', 139 'upload_successful', 'search_return_main_page' ); 140 templatize_array( $tpl, 'lang', $sub ); 151 141 // user 152 $vtp->setGlobalVar( $handle, ' page_style',$user['style'] );153 $vtp->setGlobalVar( $handle, 'user_login', $user[' pseudo'] );142 $vtp->setGlobalVar( $handle, 'style', $user['style'] ); 143 $vtp->setGlobalVar( $handle, 'user_login', $user['username'] ); 154 144 $vtp->setGlobalVar( $handle, 'user_mail_address',$user['mail_address'] ); 155 // structure156 $vtp->setGlobalVar( $handle, 'frame_start', get_frame_start() );157 $vtp->setGlobalVar( $handle, 'frame_begin', get_frame_begin() );158 $vtp->setGlobalVar( $handle, 'frame_end', get_frame_end() );159 145 160 146 $error = array(); … … 167 153 //-------------------------------------------------------------- picture upload 168 154 // vérification de la présence et de la validité des champs. 169 if ( isset( $_POST['submit'] ) &&!isset( $_GET['waiting_id'] ) )155 if ( isset( $_POST['submit'] ) and !isset( $_GET['waiting_id'] ) ) 170 156 { 171 157 $path = $page['cat_dir'].$_FILES['picture']['name']; … … 203 189 if ( sizeof( $error ) == 0 ) 204 190 { 205 $query = 'insert into '. $prefixeTable.'waiting';191 $query = 'insert into '.PREFIX_TABLE.'waiting'; 206 192 $query.= ' (cat_id,file,username,mail_address,date) values'; 207 193 $query.= " (".$page['cat'].",'".$_FILES['picture']['name']."'"; … … 214 200 } 215 201 //------------------------------------------------------------ thumbnail upload 216 if ( isset( $_POST['submit'] ) &&isset( $_GET['waiting_id'] ) )202 if ( isset( $_POST['submit'] ) and isset( $_GET['waiting_id'] ) ) 217 203 { 218 204 // upload of the thumbnail 219 205 $query = 'select file'; 220 $query.= ' from '. $prefixeTable.'waiting';206 $query.= ' from '.PREFIX_TABLE.'waiting'; 221 207 $query.= ' where id = '.$_GET['waiting_id']; 222 208 $query.= ';'; … … 237 223 if ( sizeof( $error ) == 0 ) 238 224 { 239 $query = 'update '. $prefixeTable.'waiting';225 $query = 'update '.PREFIX_TABLE.'waiting'; 240 226 $query.= " set tn_ext = '".$extension."'"; 241 227 $query.= ' where id = '.$_GET['waiting_id'];
Note: See TracChangeset
for help on using the changeset viewer.