equal
deleted
inserted
replaced
|
1 <?php |
|
2 $max_size = 128*2048; // 256k |
|
3 $directory_list = array(); |
|
4 |
|
5 if ( current_user_can( 'upload_files' ) ) { |
|
6 $upload_dir = compat_get_upload_dir() . '/wptouch/custom-icons'; |
|
7 $dir_paths = explode( '/', $upload_dir ); |
|
8 $dir = ''; |
|
9 foreach ( $dir_paths as $path ) { |
|
10 $dir = $dir . "/" . $path; |
|
11 if ( !file_exists( $dir ) ) { |
|
12 @mkdir( $dir, 0755 ); |
|
13 } |
|
14 } |
|
15 |
|
16 if ( isset( $_FILES['submitted_file'] ) ) { |
|
17 $f = $_FILES['submitted_file']; |
|
18 if ( $f['size'] <= $max_size) { |
|
19 if ( $f['type'] == 'image/png' || $f['type'] == 'image/jpeg' || $f['type'] == 'image/gif' || $f['type'] == 'image/x-png' || $f['type'] == 'image/pjpeg' ) { |
|
20 @move_uploaded_file( $f['tmp_name'], $upload_dir . "/" . $f['name'] ); |
|
21 |
|
22 if ( !file_exists( $upload_dir . "/" . $f['name'] ) ) { |
|
23 echo __('<p style="color:red">There seems to have been an error.<p>Please try your upload again.</p>'); |
|
24 } else { |
|
25 echo __( '<p style="color:green">File has been saved!</p>'); |
|
26 echo '<p><strong>'; |
|
27 echo sprintf(__( "%sClick here to refresh the page%s and see your icon.", "wptouch" ), '<a style="text-decoration:underline" href="#" onclick="location.reload(true); return false;">','</a>'); |
|
28 echo '</p></strong>'; |
|
29 } |
|
30 } else { |
|
31 echo __( '<p style="color:orange">Sorry, only PNG, GIF and JPG images are supported.</p>', 'wptouch' ); |
|
32 } |
|
33 } else echo __( '<p style="color:orange">Image too large. try something like 59x60.</p>', 'wptouch' ); |
|
34 } |
|
35 } else echo __( '<p style="color:orange">Insufficient priviledges.</p><p>You need to either be an admin or have more control over your server.</p>', 'wptouch' ); |
|
36 ?> |