Gallery – Flagallery Photo Portfolio - Version 4.29

Version Description

Download this release

Release Info

Developer pasyuk
Plugin Icon 128x128 Gallery – Flagallery Photo Portfolio
Version 4.29
Comparing to
See all releases

Code changes from version 4.28 to 4.29

Files changed (5) hide show
  1. admin/addgallery.php +127 -104
  2. admin/admin.php +193 -150
  3. admin/skins.php +77 -2
  4. flag.php +2 -2
  5. readme.txt +3 -0
admin/addgallery.php CHANGED
@@ -1,81 +1,81 @@
1
  <?php
2
- if ( preg_match( '#' . basename( __FILE__ ) . '#', $_SERVER['PHP_SELF'] ) ) {
3
- die( 'You are not allowed to call this page directly.' );
4
  }
5
 
6
  // sometimes a error feedback is better than a white screen
7
- @ini_set( 'error_reporting', E_ALL ^ E_NOTICE );
8
 
9
- function flag_admin_add_gallery() {
10
 
11
  global $wpdb, $flagdb, $flag;
12
 
13
  // same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0
14
- $filepath = admin_url() . 'admin.php?page=' . urlencode( $_GET['page'] );
15
 
16
  // check for the max image size
17
  $maxsize = flagGallery::check_memory_limit();
18
 
19
  $defaultpath = $flag->options['galleryPath'];
20
 
21
- if ( $_POST['addgallery'] ) {
22
- check_admin_referer( 'flag_addgallery' );
23
- $newgallery = trim( $_POST['galleryname'] );
24
- if ( ! empty( $newgallery ) ) {
25
- flagAdmin::create_gallery( $newgallery, $defaultpath );
26
  }
27
  }
28
- if ( $_POST['uploadimage'] ) {
29
- check_admin_referer( 'flag_upload' );
30
 
31
- $flag->options['thumbWidth'] = intval( $_POST['thumbWidth'] ) ? intval( $_POST['thumbWidth'] ) : 100;
32
- $flag->options['thumbHeight'] = intval( $_POST['thumbHeight'] ) ? intval( $_POST['thumbHeight'] ) : 100;
33
- $flag->options['thumbFix'] = isset( $_POST['thumbFix'] ) ? 1 : 0;
34
- update_option( 'flag_options', $flag->options );
35
 
36
- if ( $_FILES['MF__F_0_0']['error'] == 0 ) {
37
  flagAdmin::upload_images();
38
- } else {
39
- flagGallery::show_error( __( 'Upload failed!', 'flag' ) );
40
  }
41
  }
42
- if ( $_POST['importfolder'] ) {
43
- check_admin_referer( 'flag_addgallery' );
44
  $galleryfolder = $_POST['galleryfolder'];
45
- if ( ( ! empty( $galleryfolder ) ) AND ( $defaultpath != $galleryfolder ) AND false === strpos( $galleryfolder, '..' ) ) {
46
- flagAdmin::import_gallery( $galleryfolder );
47
  }
48
  }
49
 
50
 
51
- if ( isset( $_POST['disable_flash'] ) ) {
52
- check_admin_referer( 'flag_upload' );
53
  $flag->options['swfUpload'] = false;
54
- update_option( 'flag_options', $flag->options );
55
  }
56
 
57
- if ( isset( $_POST['enable_flash'] ) ) {
58
- check_admin_referer( 'flag_upload' );
59
  $flag->options['swfUpload'] = true;
60
- update_option( 'flag_options', $flag->options );
61
  }
62
 
63
  //get all galleries (after we added new ones)
64
- $gallerylist = $flagdb->find_all_galleries( $flag->options['albSort'], $flag->options['albSortDir'], false, 0, 0, 0, true );
65
 
66
  ?>
67
 
68
- <?php if ( ! IS_WPMU || current_user_can( 'FlAG Import folder' ) ) { ?>
69
  <link rel="stylesheet" type="text/css" href="<?php echo FLAG_URLPATH; ?>admin/js/jqueryFileTree/jqueryFileTree.css"/>
70
  <script type="text/javascript" src="<?php echo FLAG_URLPATH; ?>admin/js/jqueryFileTree/jqueryFileTree.js"></script>
71
  <script type="text/javascript">
72
  /* <![CDATA[ */
73
- jQuery(function () {
74
- jQuery("span.browsefiles").show().click(function () {
75
  jQuery("#file_browser").fileTree({
76
  script: "admin-ajax.php?action=flag_file_browser&nonce=<?php echo wp_create_nonce( 'flag-ajax' ) ;?>",
77
  root: jQuery("#galleryfolder").val()
78
- }, function (file) {
79
  //var path = file.replace("<?php echo WINABSPATH; ?>", "");
80
  jQuery("#galleryfolder").val(file);
81
  });
@@ -89,32 +89,37 @@ function flag_admin_add_gallery() {
89
  <div id="slider" class="wrap">
90
 
91
  <ul id="tabs" class="tabs">
92
- <li class="selected"><a href="#" rel="addgallery"><?php _e( 'Add new gallery', 'flag' ); ?></a></li>
93
- <li><a href="#" rel="uploadimage"><?php _e( 'Upload Images', 'flag' ); ?></a></li>
94
- <?php if ( ! IS_WPMU || current_user_can( 'FlAG Import folder' ) ) { ?>
95
- <li><a href="#" rel="importfolder"><?php _e( 'Import image folder', 'flag' ); ?></a></li>
96
  <?php } ?>
97
  </ul>
98
 
99
  <!-- create gallery -->
100
  <div id="addgallery" class="cptab">
101
- <h2><?php _e( 'Create a new gallery', 'flag' ); ?></h2>
102
 
103
  <form name="addgallery" id="addgallery_form" method="POST" action="<?php echo $filepath; ?>" accept-charset="utf-8">
104
- <?php wp_nonce_field( 'flag_addgallery' ); ?>
105
  <table class="form-table" style="width: auto;">
106
  <tr>
107
- <th scope="col" colspan="2" style="padding-bottom: 0;"><strong><?php _e( 'New Gallery', 'flag' ); ?></strong></th>
 
108
  </tr>
109
  <tr valign="top">
110
  <td><input type="text" size="65" name="galleryname" value=""/><br/>
111
- <?php if ( ! IS_WPMU ) { ?>
112
- <?php _e( 'Create a new , empty gallery below the folder', 'flag' ); ?> <strong><?php echo $defaultpath; ?></strong><br/>
 
113
  <?php } ?>
114
- <i>( <?php _e( 'Allowed characters for file and folder names are', 'flag' ); ?>: a-z, A-Z, 0-9, -, _ )</i></td>
115
- <?php do_action( 'flag_add_new_gallery_form' ); ?>
 
116
  <td>
117
- <div class="submit" style="margin: 0; padding: 0;"><input class="button-primary" type="submit" name="addgallery" value="<?php _e( 'Add gallery', 'flag' ); ?>"/></div>
 
 
118
  </td>
119
  </tr>
120
  </table>
@@ -123,50 +128,54 @@ function flag_admin_add_gallery() {
123
  </div>
124
  <!-- upload images -->
125
  <div id="uploadimage" class="cptab">
126
- <h2><?php _e( 'Upload images', 'flag' ); ?></h2>
127
 
128
  <form name="uploadimage" id="gmUpload" method="POST" enctype="multipart/form-data" action="<?php echo $filepath; ?>" accept-charset="utf-8">
129
- <?php wp_nonce_field( 'flag_upload' ); ?>
130
  <table class="form-table">
131
  <tr valign="top">
132
- <td style="width: 216px;"><label for="galleryselect"><?php _e( 'Upload images in', 'flag' ); ?> *</label>
 
133
  <select name="galleryselect" id="galleryselect" style="width: 200px">
134
- <option value="0"><?php _e( 'Choose gallery', 'flag' ); ?></option>
135
- <?php $ingallery = isset( $_GET['gid'] ) ? (int) $_GET['gid'] : '';
136
- foreach ( $gallerylist as $gallery ) {
137
- if ( ! flagAdmin::can_manage_this_gallery( $gallery->author ) ) {
138
  continue;
139
  }
140
- $name = ( empty( $gallery->title ) ) ? $gallery->name : esc_html( stripslashes( $gallery->title ) );
141
- if ( $flag->options['albSort'] == 'gid' ) {
142
  $name = '#' . $gallery->gid . ' - ' . $name;
143
  }
144
- if ( $flag->options['albSort'] == 'title' ) {
145
  $name = $name . ' (#' . $gallery->gid . ')';
146
  }
147
- $sel = ( $ingallery == $gallery->gid ) ? 'selected="selected" ' : '';
148
  echo '<option ' . $sel . 'value="' . $gallery->gid . '" >' . $name . '</option>' . "\n";
149
  } ?>
150
  </select>
151
  <?php echo $maxsize; ?>
152
- <br/><?php if ( ( IS_WPMU ) && flagGallery::flag_wpmu_enable_function( 'wpmuQuotaCheck' ) ) {
153
  display_space_usage();
154
  } ?>
155
  <br/>
156
 
157
- <p><?php _e( 'Thumbnail WIDTH x HEIGHT (in pixel)', 'flag' ); ?> *
158
- <br/><input type="text" size="5" maxlength="5" name="thumbWidth" id="thumbWidth" value="<?php echo $flag->options['thumbWidth']; ?>"/> x <input type="text" size="5" maxlength="5" name="thumbHeight" id="thumbHeight" value="<?php echo $flag->options['thumbHeight']; ?>"/>
 
159
  <br/>
160
- <small><?php _e( 'These values are maximum values ', 'flag' ); ?></small>
161
  </p>
162
- <p><label><input type="checkbox" name="thumbFix" id="thumbFix" value="1" <?php checked( '1', $flag->options['thumbFix'] ); ?> /> <?php _e( 'Ignore the aspect ratio, no portrait thumbnails', 'flag' ); ?></label></p>
 
 
163
 
164
  <div class="submit">
165
  <span class="useflashupload">
166
- <?php if ( $flag->options['swfUpload'] ) { ?>
167
- <input type="submit" name="disable_flash" id="disable_flash" title="<?php _e( 'The batch upload via Plupload, disable it if you have problems', 'flag' ); ?>" value="<?php _e( 'Switch to Browser Upload', 'flag' ); ?>"/>
168
- <?php } else { ?>
169
- <input type="submit" name="enable_flash" id="enable_flash" title="<?php _e( 'Upload multiple files at once by ctrl/shift-selecting in dialog', 'flag' ); ?>" value="<?php _e( 'Switch to Plupload based Upload', 'flag' ); ?>"/>
170
  <?php } ?>
171
  </span>
172
 
@@ -177,11 +186,12 @@ function flag_admin_add_gallery() {
177
 
178
  <td>
179
  <div id="pluploadUploader">
180
- <?php if ( ! $flag->options['swfUpload']) { ?>
181
- <strong><?php _e( 'Upload image(s):', 'flag' ); ?></strong><br>
182
- <input type="file" name="imagefiles[]" id="imagefiles" size="35" class="imagefiles"/></div>
 
183
  <span id="choosegalfirst">
184
- <input class="button-primary" type="submit" name="uploadimage" id="uploadimage_btn" value="<?php _e( 'Upload images', 'flag' ); ?>"/>
185
  <span class="disabledbut" style="display: none;"></span>
186
  </span>
187
  <?php } ?>
@@ -190,12 +200,12 @@ function flag_admin_add_gallery() {
190
  </table>
191
  <div id="pl-message"></div>
192
  </form>
193
- <?php if ( $flag->options['swfUpload'] ) {
194
- $nonce = wp_create_nonce( 'flag_upload' );
195
  ?>
196
  <script type="text/javascript">
197
  // Convert divs to queue widgets when the DOM is ready
198
- jQuery(function ($) {
199
  var files_remaining = 0;
200
  $("#pluploadUploader").plupload({
201
  runtimes: 'html5,flash,html4',
@@ -220,22 +230,30 @@ function flag_admin_add_gallery() {
220
  });
221
 
222
  var uploader = $("#pluploadUploader").plupload('getUploader');
223
- uploader.bind('QueueChanged StateChanged', function (up) {
224
- if (up.state == plupload.QUEUED) {
225
  files_remaining = up.files.length;
226
  }
227
- if (up.state == plupload.STARTED) {
228
- up.settings.multipart_params = {galleryselect: jQuery('#galleryselect').val(), thumbw: jQuery('#thumbWidth').val(), thumbh: jQuery('#thumbHeight').val(), thumbf: jQuery('#thumbFix').prop("checked"), last: files_remaining, action: 'flag_plupload_uploader', _wpnonce: '<?php echo $nonce; ?>'};
 
 
 
 
 
 
 
 
229
  }
230
- if ($("#galleryselect").val() == 0) {
231
  $("#pluploadUploader_start").addClass('ui-button-disabled ui-state-disabled');
232
  }
233
  console.log('[StateChanged]', up.state, up.settings.multipart_params);
234
  });
235
- uploader.bind('ChunkUploaded', function (up, file, info) {
236
  console.log('[ChunkUploaded] File:', file, "Info:", info);
237
  var response = jQuery.parseJSON(info.response);
238
- if (response && response.error) {
239
  up.stop();
240
  file.status = plupload.FAILED;
241
  console.log(response.error);
@@ -244,37 +262,37 @@ function flag_admin_add_gallery() {
244
  up.start();
245
  }
246
  });
247
- uploader.bind('FileUploaded', function (up, file, info) {
248
  console.log('[FileUploaded] File:', file, "Info:", info);
249
  files_remaining--;
250
- if (info.response) {
251
  file.status = plupload.FAILED;
252
  jQuery('<div/>').addClass('error').html('<span><u><em>' + file.name + ':</em></u> ' + info.response + '</span>').appendTo('#pl-message');
253
  }
254
  });
255
- uploader.bind('UploadProgress', function (up, file) {
256
  var percent = uploader.total.percent;
257
  $('#total-progress-info .progress-bar').css('width', percent + "%").attr('aria-valuenow', percent);
258
  });
259
- uploader.bind('Error', function (up, args) {
260
  jQuery('<div/>').addClass('error').html('<span><u><em>' + args.file.name + ':</em></u> ' + args.message + ' ' + args.status + '</span>').appendTo('#pl-message');
261
  console.log('[error] ', args);
262
  });
263
- uploader.bind('UploadComplete', function (up, files) {
264
  console.log('[UploadComplete]', files);
265
  jQuery('<div/>').addClass('success').html('<?php _e('Done!', 'flag'); ?> <a href="<?php echo wp_nonce_url( $flag->manage_page->base_page . "&mode=edit", 'flag_editgallery'); ?>&gid=' + jQuery("#galleryselect").val() + '">Open Gallery</a>').appendTo('#pl-message');
266
  });
267
 
268
- jQuery("#gmUpload").on('click', '.ui-button-disabled', function () {
269
- if (files_remaining) {
270
  alert("Choose gallery, please.")
271
  }
272
  });
273
- jQuery("#galleryselect").change(function () {
274
- if (jQuery(this).val() == 0) {
275
  jQuery("#pluploadUploader_start").addClass('ui-button-disabled ui-state-disabled');
276
- } else {
277
- if (files_remaining) {
278
  jQuery("#pluploadUploader_start").removeClass('ui-button-disabled ui-state-disabled');
279
  }
280
  }
@@ -286,25 +304,25 @@ function flag_admin_add_gallery() {
286
  <!-- MultiFile script -->
287
  <script type="text/javascript">
288
  /* <![CDATA[ */
289
- jQuery(document).ready(function () {
290
  jQuery('#imagefiles').MultiFile({
291
  STRING: {
292
  remove: '<?php _e('remove', 'flag'); ?>'
293
  }
294
  });
295
 
296
- if (jQuery("#galleryselect").val() == 0) {
297
  jQuery("#choosegalfirst").animate({opacity: "0.5"}, 600);
298
  jQuery("#choosegalfirst .disabledbut").show();
299
  }
300
- jQuery("#choosegalfirst .disabledbut").click(function () {
301
  alert("Choose gallery, please.")
302
  });
303
- jQuery("#galleryselect").change(function () {
304
- if (jQuery(this).val() == 0) {
305
  jQuery("#choosegalfirst .disabledbut").show();
306
  jQuery("#choosegalfirst").animate({opacity: "0.5"}, 600);
307
- } else {
308
  jQuery("#choosegalfirst .disabledbut").hide();
309
  jQuery("#choosegalfirst").animate({opacity: "1"}, 600);
310
  }
@@ -315,25 +333,30 @@ function flag_admin_add_gallery() {
315
 
316
  <?php } ?>
317
  </div>
318
- <?php if ( ! IS_WPMU || current_user_can( 'FlAG Import folder' ) ) { ?>
319
  <!-- import folder -->
320
  <div id="importfolder" class="cptab">
321
- <h2><?php _e( 'Import image folder', 'flag' ); ?></h2>
322
 
323
  <form name="importfolder" id="importfolder_form" method="POST" action="<?php echo $filepath; ?>" accept-charset="utf-8">
324
- <?php wp_nonce_field( 'flag_addgallery' ); ?>
325
  <table class="form-table">
326
  <tr valign="top">
327
- <th scope="row"><?php _e( 'Import from Server path:', 'flag' ); ?></th>
328
- <td><input type="text" size="35" id="galleryfolder" name="galleryfolder" value="<?php echo $defaultpath; ?>"/><span class="browsefiles button" style="display:none"><?php _e( 'Browse...', "flag" ); ?></span>
 
329
 
330
  <div id="file_browser"></div>
331
  <div><?php echo $maxsize; ?>
332
- <?php if ( SAFE_MODE ) { ?><br/><?php _e( ' Please note : For safe-mode = ON you need to add the subfolder thumbs manually', 'flag' ); ?><?php }; ?></div>
 
 
333
  </td>
334
  </tr>
335
  </table>
336
- <div class="submit"><input class="button-primary" type="submit" name="importfolder" value="<?php _e( 'Import folder', 'flag' ); ?>"/></div>
 
 
337
  </form>
338
  </div>
339
  <?php } ?>
1
  <?php
2
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])){
3
+ die('You are not allowed to call this page directly.');
4
  }
5
 
6
  // sometimes a error feedback is better than a white screen
7
+ @ini_set('error_reporting', E_ALL ^ E_NOTICE);
8
 
9
+ function flag_admin_add_gallery(){
10
 
11
  global $wpdb, $flagdb, $flag;
12
 
13
  // same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0
14
+ $filepath = admin_url() . 'admin.php?page=' . urlencode($_GET['page']);
15
 
16
  // check for the max image size
17
  $maxsize = flagGallery::check_memory_limit();
18
 
19
  $defaultpath = $flag->options['galleryPath'];
20
 
21
+ if($_POST['addgallery']){
22
+ check_admin_referer('flag_addgallery');
23
+ $newgallery = trim($_POST['galleryname']);
24
+ if(!empty($newgallery)){
25
+ flagAdmin::create_gallery($newgallery, $defaultpath);
26
  }
27
  }
28
+ if($_POST['uploadimage']){
29
+ check_admin_referer('flag_upload');
30
 
31
+ $flag->options['thumbWidth'] = intval($_POST['thumbWidth'])? intval($_POST['thumbWidth']) : 100;
32
+ $flag->options['thumbHeight'] = intval($_POST['thumbHeight'])? intval($_POST['thumbHeight']) : 100;
33
+ $flag->options['thumbFix'] = isset($_POST['thumbFix'])? 1 : 0;
34
+ update_option('flag_options', $flag->options);
35
 
36
+ if($_FILES['MF__F_0_0']['error'] == 0){
37
  flagAdmin::upload_images();
38
+ } else{
39
+ flagGallery::show_error(__('Upload failed!', 'flag'));
40
  }
41
  }
42
+ if($_POST['importfolder']){
43
+ check_admin_referer('flag_addgallery');
44
  $galleryfolder = $_POST['galleryfolder'];
45
+ if((!empty($galleryfolder)) AND ($defaultpath != $galleryfolder) AND false === strpos($galleryfolder, '..')){
46
+ flagAdmin::import_gallery($galleryfolder);
47
  }
48
  }
49
 
50
 
51
+ if(isset($_POST['disable_flash'])){
52
+ check_admin_referer('flag_upload');
53
  $flag->options['swfUpload'] = false;
54
+ update_option('flag_options', $flag->options);
55
  }
56
 
57
+ if(isset($_POST['enable_flash'])){
58
+ check_admin_referer('flag_upload');
59
  $flag->options['swfUpload'] = true;
60
+ update_option('flag_options', $flag->options);
61
  }
62
 
63
  //get all galleries (after we added new ones)
64
+ $gallerylist = $flagdb->find_all_galleries($flag->options['albSort'], $flag->options['albSortDir'], false, 0, 0, 0, true);
65
 
66
  ?>
67
 
68
+ <?php if(!IS_WPMU || current_user_can('FlAG Import folder')){ ?>
69
  <link rel="stylesheet" type="text/css" href="<?php echo FLAG_URLPATH; ?>admin/js/jqueryFileTree/jqueryFileTree.css"/>
70
  <script type="text/javascript" src="<?php echo FLAG_URLPATH; ?>admin/js/jqueryFileTree/jqueryFileTree.js"></script>
71
  <script type="text/javascript">
72
  /* <![CDATA[ */
73
+ jQuery(function(){
74
+ jQuery("span.browsefiles").show().click(function(){
75
  jQuery("#file_browser").fileTree({
76
  script: "admin-ajax.php?action=flag_file_browser&nonce=<?php echo wp_create_nonce( 'flag-ajax' ) ;?>",
77
  root: jQuery("#galleryfolder").val()
78
+ }, function(file){
79
  //var path = file.replace("<?php echo WINABSPATH; ?>", "");
80
  jQuery("#galleryfolder").val(file);
81
  });
89
  <div id="slider" class="wrap">
90
 
91
  <ul id="tabs" class="tabs">
92
+ <li class="selected"><a href="#" rel="addgallery"><?php _e('Add new gallery', 'flag'); ?></a></li>
93
+ <li><a href="#" rel="uploadimage"><?php _e('Upload Images', 'flag'); ?></a></li>
94
+ <?php if(!IS_WPMU || current_user_can('FlAG Import folder')){ ?>
95
+ <li><a href="#" rel="importfolder"><?php _e('Import image folder', 'flag'); ?></a></li>
96
  <?php } ?>
97
  </ul>
98
 
99
  <!-- create gallery -->
100
  <div id="addgallery" class="cptab">
101
+ <h2><?php _e('Create a new gallery', 'flag'); ?></h2>
102
 
103
  <form name="addgallery" id="addgallery_form" method="POST" action="<?php echo $filepath; ?>" accept-charset="utf-8">
104
+ <?php wp_nonce_field('flag_addgallery'); ?>
105
  <table class="form-table" style="width: auto;">
106
  <tr>
107
+ <th scope="col" colspan="2" style="padding-bottom: 0;">
108
+ <strong><?php _e('New Gallery', 'flag'); ?></strong></th>
109
  </tr>
110
  <tr valign="top">
111
  <td><input type="text" size="65" name="galleryname" value=""/><br/>
112
+ <?php if(!IS_WPMU){ ?>
113
+ <?php _e('Create a new , empty gallery below the folder', 'flag'); ?>
114
+ <strong><?php echo $defaultpath; ?></strong><br/>
115
  <?php } ?>
116
+ <i>( <?php _e('Allowed characters for file and folder names are', 'flag'); ?>: a-z, A-Z, 0-9, -, _ )</i>
117
+ </td>
118
+ <?php do_action('flag_add_new_gallery_form'); ?>
119
  <td>
120
+ <div class="submit" style="margin: 0; padding: 0;">
121
+ <input class="button-primary" type="submit" name="addgallery" value="<?php _e('Add gallery', 'flag'); ?>"/>
122
+ </div>
123
  </td>
124
  </tr>
125
  </table>
128
  </div>
129
  <!-- upload images -->
130
  <div id="uploadimage" class="cptab">
131
+ <h2><?php _e('Upload images', 'flag'); ?></h2>
132
 
133
  <form name="uploadimage" id="gmUpload" method="POST" enctype="multipart/form-data" action="<?php echo $filepath; ?>" accept-charset="utf-8">
134
+ <?php wp_nonce_field('flag_upload'); ?>
135
  <table class="form-table">
136
  <tr valign="top">
137
+ <td style="width: 216px;">
138
+ <label for="galleryselect"><?php _e('Upload images in', 'flag'); ?> *</label>
139
  <select name="galleryselect" id="galleryselect" style="width: 200px">
140
+ <option value="0"><?php _e('Choose gallery', 'flag'); ?></option>
141
+ <?php $ingallery = isset($_GET['gid'])? (int) $_GET['gid'] : '';
142
+ foreach($gallerylist as $gallery){
143
+ if(!flagAdmin::can_manage_this_gallery($gallery->author)){
144
  continue;
145
  }
146
+ $name = (empty($gallery->title))? $gallery->name : esc_html(stripslashes($gallery->title));
147
+ if($flag->options['albSort'] == 'gid'){
148
  $name = '#' . $gallery->gid . ' - ' . $name;
149
  }
150
+ if($flag->options['albSort'] == 'title'){
151
  $name = $name . ' (#' . $gallery->gid . ')';
152
  }
153
+ $sel = ($ingallery == $gallery->gid)? 'selected="selected" ' : '';
154
  echo '<option ' . $sel . 'value="' . $gallery->gid . '" >' . $name . '</option>' . "\n";
155
  } ?>
156
  </select>
157
  <?php echo $maxsize; ?>
158
+ <br/><?php if((IS_WPMU) && flagGallery::flag_wpmu_enable_function('wpmuQuotaCheck')){
159
  display_space_usage();
160
  } ?>
161
  <br/>
162
 
163
+ <p><?php _e('Thumbnail WIDTH x HEIGHT (in pixel)', 'flag'); ?> *
164
+ <br/><input type="text" size="5" maxlength="5" name="thumbWidth" id="thumbWidth" value="<?php echo $flag->options['thumbWidth']; ?>"/> x
165
+ <input type="text" size="5" maxlength="5" name="thumbHeight" id="thumbHeight" value="<?php echo $flag->options['thumbHeight']; ?>"/>
166
  <br/>
167
+ <small><?php _e('These values are maximum values ', 'flag'); ?></small>
168
  </p>
169
+ <p>
170
+ <label><input type="checkbox" name="thumbFix" id="thumbFix" value="1" <?php checked('1', $flag->options['thumbFix']); ?> /> <?php _e('Ignore the aspect ratio, no portrait thumbnails', 'flag'); ?>
171
+ </label></p>
172
 
173
  <div class="submit">
174
  <span class="useflashupload">
175
+ <?php if($flag->options['swfUpload']){ ?>
176
+ <input type="submit" name="disable_flash" id="disable_flash" title="<?php _e('The batch upload via Plupload, disable it if you have problems', 'flag'); ?>" value="<?php _e('Switch to Browser Upload', 'flag'); ?>"/>
177
+ <?php } else{ ?>
178
+ <input type="submit" name="enable_flash" id="enable_flash" title="<?php _e('Upload multiple files at once by ctrl/shift-selecting in dialog', 'flag'); ?>" value="<?php _e('Switch to Plupload based Upload', 'flag'); ?>"/>
179
  <?php } ?>
180
  </span>
181
 
186
 
187
  <td>
188
  <div id="pluploadUploader">
189
+ <?php if (!$flag->options['swfUpload']) { ?>
190
+ <strong><?php _e('Upload image(s):', 'flag'); ?></strong><br>
191
+ <input type="file" name="imagefiles[]" id="imagefiles" size="35" class="imagefiles"/>
192
+ </div>
193
  <span id="choosegalfirst">
194
+ <input class="button-primary" type="submit" name="uploadimage" id="uploadimage_btn" value="<?php _e('Upload images', 'flag'); ?>"/>
195
  <span class="disabledbut" style="display: none;"></span>
196
  </span>
197
  <?php } ?>
200
  </table>
201
  <div id="pl-message"></div>
202
  </form>
203
+ <?php if($flag->options['swfUpload']){
204
+ $nonce = wp_create_nonce('flag_upload');
205
  ?>
206
  <script type="text/javascript">
207
  // Convert divs to queue widgets when the DOM is ready
208
+ jQuery(function($){
209
  var files_remaining = 0;
210
  $("#pluploadUploader").plupload({
211
  runtimes: 'html5,flash,html4',
230
  });
231
 
232
  var uploader = $("#pluploadUploader").plupload('getUploader');
233
+ uploader.bind('QueueChanged StateChanged', function(up){
234
+ if(up.state == plupload.QUEUED){
235
  files_remaining = up.files.length;
236
  }
237
+ if(up.state == plupload.STARTED){
238
+ up.settings.multipart_params = {
239
+ galleryselect: jQuery('#galleryselect').val(),
240
+ thumbw: jQuery('#thumbWidth').val(),
241
+ thumbh: jQuery('#thumbHeight').val(),
242
+ thumbf: jQuery('#thumbFix').prop("checked"),
243
+ last: files_remaining,
244
+ action: 'flag_plupload_uploader',
245
+ _wpnonce: '<?php echo $nonce; ?>'
246
+ };
247
  }
248
+ if($("#galleryselect").val() == 0){
249
  $("#pluploadUploader_start").addClass('ui-button-disabled ui-state-disabled');
250
  }
251
  console.log('[StateChanged]', up.state, up.settings.multipart_params);
252
  });
253
+ uploader.bind('ChunkUploaded', function(up, file, info){
254
  console.log('[ChunkUploaded] File:', file, "Info:", info);
255
  var response = jQuery.parseJSON(info.response);
256
+ if(response && response.error){
257
  up.stop();
258
  file.status = plupload.FAILED;
259
  console.log(response.error);
262
  up.start();
263
  }
264
  });
265
+ uploader.bind('FileUploaded', function(up, file, info){
266
  console.log('[FileUploaded] File:', file, "Info:", info);
267
  files_remaining--;
268
+ if(info.response){
269
  file.status = plupload.FAILED;
270
  jQuery('<div/>').addClass('error').html('<span><u><em>' + file.name + ':</em></u> ' + info.response + '</span>').appendTo('#pl-message');
271
  }
272
  });
273
+ uploader.bind('UploadProgress', function(up, file){
274
  var percent = uploader.total.percent;
275
  $('#total-progress-info .progress-bar').css('width', percent + "%").attr('aria-valuenow', percent);
276
  });
277
+ uploader.bind('Error', function(up, args){
278
  jQuery('<div/>').addClass('error').html('<span><u><em>' + args.file.name + ':</em></u> ' + args.message + ' ' + args.status + '</span>').appendTo('#pl-message');
279
  console.log('[error] ', args);
280
  });
281
+ uploader.bind('UploadComplete', function(up, files){
282
  console.log('[UploadComplete]', files);
283
  jQuery('<div/>').addClass('success').html('<?php _e('Done!', 'flag'); ?> <a href="<?php echo wp_nonce_url( $flag->manage_page->base_page . "&mode=edit", 'flag_editgallery'); ?>&gid=' + jQuery("#galleryselect").val() + '">Open Gallery</a>').appendTo('#pl-message');
284
  });
285
 
286
+ jQuery("#gmUpload").on('click', '.ui-button-disabled', function(){
287
+ if(files_remaining){
288
  alert("Choose gallery, please.")
289
  }
290
  });
291
+ jQuery("#galleryselect").change(function(){
292
+ if(jQuery(this).val() == 0){
293
  jQuery("#pluploadUploader_start").addClass('ui-button-disabled ui-state-disabled');
294
+ } else{
295
+ if(files_remaining){
296
  jQuery("#pluploadUploader_start").removeClass('ui-button-disabled ui-state-disabled');
297
  }
298
  }
304
  <!-- MultiFile script -->
305
  <script type="text/javascript">
306
  /* <![CDATA[ */
307
+ jQuery(document).ready(function(){
308
  jQuery('#imagefiles').MultiFile({
309
  STRING: {
310
  remove: '<?php _e('remove', 'flag'); ?>'
311
  }
312
  });
313
 
314
+ if(jQuery("#galleryselect").val() == 0){
315
  jQuery("#choosegalfirst").animate({opacity: "0.5"}, 600);
316
  jQuery("#choosegalfirst .disabledbut").show();
317
  }
318
+ jQuery("#choosegalfirst .disabledbut").click(function(){
319
  alert("Choose gallery, please.")
320
  });
321
+ jQuery("#galleryselect").change(function(){
322
+ if(jQuery(this).val() == 0){
323
  jQuery("#choosegalfirst .disabledbut").show();
324
  jQuery("#choosegalfirst").animate({opacity: "0.5"}, 600);
325
+ } else{
326
  jQuery("#choosegalfirst .disabledbut").hide();
327
  jQuery("#choosegalfirst").animate({opacity: "1"}, 600);
328
  }
333
 
334
  <?php } ?>
335
  </div>
336
+ <?php if(!IS_WPMU || current_user_can('FlAG Import folder')){ ?>
337
  <!-- import folder -->
338
  <div id="importfolder" class="cptab">
339
+ <h2><?php _e('Import image folder', 'flag'); ?></h2>
340
 
341
  <form name="importfolder" id="importfolder_form" method="POST" action="<?php echo $filepath; ?>" accept-charset="utf-8">
342
+ <?php wp_nonce_field('flag_addgallery'); ?>
343
  <table class="form-table">
344
  <tr valign="top">
345
+ <th scope="row"><?php _e('Import from Server path:', 'flag'); ?></th>
346
+ <td>
347
+ <input type="text" size="35" id="galleryfolder" name="galleryfolder" value="<?php echo $defaultpath; ?>"/><span class="browsefiles button" style="display:none"><?php _e('Browse...', "flag"); ?></span>
348
 
349
  <div id="file_browser"></div>
350
  <div><?php echo $maxsize; ?>
351
+ <?php if(SAFE_MODE){ ?>
352
+ <br/><?php _e(' Please note : For safe-mode = ON you need to add the subfolder thumbs manually', 'flag'); ?><?php }; ?>
353
+ </div>
354
  </td>
355
  </tr>
356
  </table>
357
+ <div class="submit">
358
+ <input class="button-primary" type="submit" name="importfolder" value="<?php _e('Import folder', 'flag'); ?>"/>
359
+ </div>
360
  </form>
361
  </div>
362
  <?php } ?>
admin/admin.php CHANGED
@@ -1,34 +1,35 @@
1
  <?php
 
2
  /**
3
  * flagAdminPanel - Admin Section for Flash Album Gallery
4
- *
5
  */
6
- class flagAdminPanel{
7
-
8
  // constructor
9
- function flagAdminPanel() {
10
 
11
  // Add the admin menu
12
- add_action( 'admin_menu', array(&$this, 'add_menu') );
13
- add_action('init', array(&$this, 'wp_flag_check_options'),2);
14
 
15
  // Add the script and style files
16
- add_action('admin_print_scripts', array(&$this, 'load_scripts') );
17
- add_action('admin_print_styles', array(&$this, 'load_styles') );
18
-
19
  add_filter('contextual_help', array(&$this, 'show_help'), 10, 2);
20
  add_filter('screen_meta_screen', array(&$this, 'edit_screen_meta'));
21
  }
22
 
23
- function wp_flag_check_options() {
24
  global $flag;
25
- require_once(dirname (__FILE__) . '/flag_install.php' );
26
  $default_options = flag_list_options();
27
  $flag_db_options = get_option('flag_options');
28
  if($flag_db_options){
29
- if(function_exists('array_diff_key')) {
30
  $flag_new_options = array_diff_key($default_options, $flag_db_options);
31
- } else {
32
  $flag_new_options = $this->PHP4_array_diff_key($default_options, $flag_db_options);
33
  }
34
  $flag_options = array_merge($flag_db_options, $flag_new_options);
@@ -38,195 +39,233 @@ class flagAdminPanel{
38
  }
39
  }
40
 
41
- function PHP4_array_diff_key() {
42
  $arrs = func_get_args();
43
  $result = array_shift($arrs);
44
- foreach ($arrs as $array) {
45
- foreach ($result as $key => $v) {
46
- if (array_key_exists($key, $array)) {
47
  unset($result[$key]);
48
  }
49
  }
50
  }
 
51
  return $result;
52
  }
53
 
54
  // integrate the menu
55
- function add_menu() {
56
-
57
- add_menu_page( __('GRAND Flash Album Gallery overview','flag'), __('FlAGallery'), 'FlAG overview', 'flag-overview', array (&$this, 'show_menu'), FLAG_URLPATH .'admin/images/flag.png' );
58
- add_submenu_page( 'flag-overview' , __('GRAND Flash Album Gallery overview', 'flag'), __('Overview', 'flag'), 'FlAG overview', 'flag-overview', array (&$this, 'show_menu'));
59
- add_submenu_page( 'flag-overview' , __('FlAG Manage gallery', 'flag'), __('Manage Galleries', 'flag'), 'FlAG Manage gallery', 'flag-manage-gallery', array (&$this, 'show_menu'));
60
- add_submenu_page( 'flag-overview' , __('FlAG Music Box', 'flag'), __('Music Box', 'flag'), 'FlAG Manage music', 'flag-music-box', array (&$this, 'show_menu'));
61
- add_submenu_page( 'flag-overview' , __('FlAG Video Box', 'flag'), __('Video Box', 'flag'), 'FlAG Manage video', 'flag-video-box', array (&$this, 'show_menu'));
62
- add_submenu_page( 'flag-overview' , __('FlAG Banner Box', 'flag'), __('Banner Box', 'flag'), 'FlAG Manage banners', 'flag-banner-box', array (&$this, 'show_menu'));
63
- add_submenu_page( 'flag-overview' , __('FlAG Manage skins', 'flag'), __('Skins', 'flag'), 'FlAG Change skin', 'flag-skins', array (&$this, 'show_menu'));
64
- add_submenu_page( 'flag-overview' , __('FlAG Change options', 'flag'), __('Options', 'flag'), 'FlAG Change options', 'flag-options', array (&$this, 'show_menu'));
65
- add_submenu_page( 'flag-overview' , __('Flagallery in iframe', 'flag'), __('Iframe', 'flag'), 'FlAG iFrame page', 'flag-iframe', array (&$this, 'show_menu'));
66
- if ( flag_wpmu_site_admin() )
67
- add_submenu_page( 'wpmu-admin.php' , __('GRAND Flash Album Gallery', 'flag'), __('Grand Flagallery', 'flag'), 'activate_plugins', 'flag-wpmu', array (&$this, 'show_menu'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  //register the column fields
70
- $this->register_columns();
71
 
72
  }
73
 
74
  // load the script for the defined page and load only this code
75
- function show_menu() {
76
-
77
  global $flag;
78
-
79
  // Set installation date
80
- if( empty($flag->options['installDate']) ) {
81
  $flag->options['installDate'] = time();
82
- update_option('flag_options', $flag->options);
83
  }
84
-
85
- switch ($_GET['page']){
86
  case "flag-manage-gallery" :
87
- include_once ( dirname (__FILE__) . '/functions.php' ); // admin functions
88
- include_once ( dirname (__FILE__) . '/manage.php' ); // flag_admin_manage_gallery
89
  // Initate the Manage Gallery page
90
  $flag->manage_page = new flagManageGallery();
91
  // Render the output now, because you cannot access a object during the constructor is not finished
92
  $flag->manage_page->controller();
93
-
94
  break;
95
  case "flag-music-box" :
96
- include_once ( dirname (__FILE__) . '/music-box.php' ); // flag_music_box
97
  flag_music_controler();
98
  break;
99
  case "flag-video-box" :
100
- include_once ( dirname (__FILE__) . '/video-box.php' ); // flag_video_box
101
  flag_video_controler();
102
  break;
103
  case "flag-banner-box" :
104
- include_once ( dirname (__FILE__) . '/banner-box.php' ); // flag_banner_box
105
  flag_banner_controler();
106
  break;
107
  case "flag-options" :
108
- include_once ( dirname (__FILE__) . '/settings.php' ); // flag_admin_options
109
  flag_admin_options();
110
  break;
111
  case "flag-skins" :
112
- include_once ( dirname (__FILE__) . '/skins.php' ); // flag_manage_skins
113
  break;
114
  case "flag-iframe" :
115
- include_once ( dirname(__FILE__) . '/flagframe-tool.php' ); // flagframe-tool
116
  break;
117
  case "flag-wpmu" :
118
- include_once ( dirname (__FILE__) . '/wpmu.php' ); // flag_wpmu_admin
119
  flag_wpmu_setup();
120
  break;
121
  default :
122
- include_once ( dirname (__FILE__) . '/overview.php' ); // flag_admin_overview
123
  flag_admin_overview();
124
  break;
125
  }
126
  }
127
-
128
- function load_scripts() {
129
-
130
- wp_register_script('flag-ajax', FLAG_URLPATH .'admin/js/flag.ajax.js', array('jquery'), '1.4.0');
131
  wp_localize_script('flag-ajax', 'flagAjaxSetup', array(
132
- 'url' => admin_url('admin-ajax.php'),
133
- 'action' => 'flag_ajax_operation',
134
- 'operation' => '',
135
- 'nonce' => wp_create_nonce( 'flag-ajax' ),
136
- 'ids' => '',
137
- 'permission' => __('You do not have the correct permission', 'flag'),
138
- 'error' => __('Unexpected Error', 'flag'),
139
- 'failure' => __('A failure occurred', 'flag')
140
- ) );
141
- wp_register_script('flag-progressbar', FLAG_URLPATH .'admin/js/flag.progressbar.js', array('jquery'), '1.0.0');
142
-
143
- if (isset($_GET['page'])) {
144
- switch ($_GET['page']) {
145
- case 'flag-overview' :
146
- wp_enqueue_script( 'postbox' );
147
  case "flag-manage-gallery" :
148
- print "<script type='text/javascript' src='".FLAG_URLPATH."admin/js/tabs.js'></script>\n";
149
 
150
  wp_enqueue_style('jquery-ui-smoothness', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.min.css', array(), '1.10.4', 'screen');
151
  wp_enqueue_script('jquery-ui-full', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js', array('jquery'), '1.10.4');
152
 
153
- wp_enqueue_script( 'jquery-ui-droppable' );
154
 
155
- wp_enqueue_script( 'multifile', FLAG_URLPATH .'admin/js/jquery.MultiFile.js', array('jquery'), '1.4.6' );
156
 
157
- wp_enqueue_script('flag-plupload', FLAG_URLPATH . 'admin/js/plupload/plupload.full.min.js', array('jquery', 'jquery-ui-full'), '2.1.1');
 
 
 
158
 
159
- wp_enqueue_style( 'jquery.ui.plupload', FLAG_URLPATH . 'admin/js/plupload/jquery.ui.plupload/css/jquery.ui.plupload.css', array( 'jquery-ui-smoothness' ), '2.1.1', 'screen' );
160
- wp_enqueue_script( 'jquery.ui.plupload', FLAG_URLPATH . 'admin/js/plupload/jquery.ui.plupload/jquery.ui.plupload.min.js', array( 'flag-plupload', 'jquery-ui-full' ), '2.1.1' );
 
 
 
161
 
162
 
163
- wp_enqueue_script('dataset', FLAG_URLPATH .'admin/js/jquery.dataset.js', array('jquery'), '0.1.0');
164
- wp_enqueue_script( 'postbox' );
165
- wp_enqueue_script( 'flag-ajax' );
166
- wp_enqueue_script( 'flag-progressbar' );
167
  add_thickbox();
168
- break;
169
  case "flag-music-box" :
170
- wp_enqueue_script( 'swfobject' );
171
- wp_enqueue_script( 'thickbox' );
172
- break;
173
  case "flag-video-box" :
174
- wp_enqueue_script( 'swfobject' );
175
- wp_enqueue_script( 'thickbox' );
176
- break;
177
  case "flag-banner-box" :
178
- wp_enqueue_script( 'thickbox' );
179
- break;
180
  case "flag-options" :
181
- wp_enqueue_script('farbtastic-nosharp', FLAG_URLPATH.'admin/js/farbtastic-nosharp.js', array('jquery'), '1.2');
182
- print "<script type='text/javascript' src='".FLAG_URLPATH."admin/js/tabs.js'></script>\n";
183
- break;
184
  case "flag-skins" :
185
- wp_enqueue_script( 'thickbox' );
186
- wp_enqueue_script('farbtastic-nosharp', FLAG_URLPATH.'admin/js/farbtastic-nosharp.js', array('jquery'), '1.2');
187
  //wp_enqueue_script( 'farbtastic' );
188
- print "<script type='text/javascript' src='".FLAG_URLPATH."admin/js/tabs.js'></script>\n";
189
- break;
190
  }
191
  }
192
- }
193
-
194
- function load_styles() {
195
-
196
- if (isset($_GET['page'])) {
197
- switch ($_GET['page']) {
198
  case 'flag-overview' :
199
- wp_enqueue_style( 'flagadmin', FLAG_URLPATH .'admin/css/flagadmin.css', false, '2.8.1', 'screen' );
200
- wp_admin_css( 'css/dashboard' );
201
- break;
202
  case "flag-options" :
203
- wp_enqueue_style( 'farbtastic' );
204
  case "flag-manage-gallery" :
205
- wp_enqueue_style( 'flagtabs', FLAG_URLPATH .'admin/css/tabs.css', false, '1.0.0', 'screen' );
206
  case "flag-music-box" :
207
- case "flag-video-box" :
208
- case "flag-banner-box" :
209
- wp_enqueue_style( 'thickbox' );
210
- wp_enqueue_style( 'flagadmin', FLAG_URLPATH .'admin/css/flagadmin.css', false, '2.8.1', 'screen' );
211
- break;
212
  case "flag-skins" :
213
- wp_enqueue_style( 'thickbox' );
214
- wp_enqueue_style( 'farbtastic' );
215
- wp_enqueue_style( 'flagtabs', FLAG_URLPATH .'admin/css/tabs.css', false, '1.0.0', 'screen' );
216
- wp_enqueue_style( 'flagadmin', FLAG_URLPATH .'admin/css/flagadmin.css', false, '2.8.1', 'screen' );
217
- wp_admin_css( 'css/dashboard' );
218
- break;
219
- }
220
  }
221
  }
222
-
223
- function show_help($help, $screen) {
224
 
225
- $link ='';
 
 
226
  // menu title is localized...
227
- $i18n = strtolower ( _n( 'Gallery', 'Galleries', 1, 'flag' ) );
228
 
229
- switch ($screen) {
230
  case 'toplevel_page_' . 'flag-overview' :
231
  case "{$i18n}_page_flag-manage-gallery" :
232
  case "flag-manage-gallery":
@@ -234,11 +273,11 @@ class flagAdminPanel{
234
  case "{$i18n}_page_flag-skins" :
235
  case "{$i18n}_page_flag-options" :
236
  $link = '<a href="http://codeasily.com/wordpress-plugins/flag/" target="_blank">CodEasily.com</a>';
237
- break;
238
  }
239
-
240
- if ( !empty($link) ) {
241
- $help = '<h5>' . __('Get help with Grand Flagallery', 'flag') . '</h5>';
242
  $help .= '<div class="metabox-prefs">';
243
  $help .= $link;
244
  $help .= "</div>\n";
@@ -249,54 +288,58 @@ class flagAdminPanel{
249
  $help .= ' | <a href="http://codeasily.com/community/topic/language-files/" target="_blank">' . __('Get your language pack', 'flag') . '</a>';
250
  $help .= ' | <a href="http://codeasily.com/portfolio/grand-flagallery-skins/" target="_blank">' . __('Skins for Grand Flagallery', 'flag') . '</a>';
251
  $help .= "</div>\n";
252
- }
253
-
254
  return $help;
255
  }
256
-
257
- function edit_screen_meta($screen) {
258
 
259
  // menu title is localized, so we need to change the toplevel name
260
- $i18n = strtolower ( _n( 'Gallery', 'Galleries', 1, 'flag' ) );
261
-
262
- switch ($screen) {
263
  case "{$i18n}_page_flag-manage-gallery" :
264
  // we would like to have screen option only at the manage images / gallery page
265
- if ( isset ($_POST['sortGallery']) )
266
  $screen = $screen;
267
- else if ( ($_GET['mode'] == 'edit') || isset ($_POST['backToGallery']) )
268
  $screen = 'flag-manage-images';
269
- else if ( ($_GET['mode'] == 'sort') )
270
  $screen = $screen;
271
- else
272
- $screen = 'flag-manage-gallery';
273
- break;
 
274
  }
275
 
276
  return $screen;
277
  }
278
 
279
- function register_column_headers($screen, $columns) {
280
  global $_wp_column_headers;
281
-
282
- if ( !isset($_wp_column_headers) )
283
  $_wp_column_headers = array();
284
-
 
285
  $_wp_column_headers[$screen] = $columns;
286
  }
287
 
288
- function register_columns() {
289
- include_once ( dirname (__FILE__) . '/manage-images.php' );
290
- $this->register_column_headers('flag-manage-images', flag_manage_gallery_columns() );
291
  }
292
 
293
  }
294
 
295
- function flag_wpmu_site_admin() {
296
  // Check for site admin
297
- if ( function_exists('is_site_admin') )
298
- if ( is_super_admin() )
299
  return true;
300
-
 
 
301
  return false;
302
  }
1
  <?php
2
+
3
  /**
4
  * flagAdminPanel - Admin Section for Flash Album Gallery
5
+ *
6
  */
7
+ class flagAdminPanel {
8
+
9
  // constructor
10
+ function flagAdminPanel(){
11
 
12
  // Add the admin menu
13
+ add_action('admin_menu', array(&$this, 'add_menu'));
14
+ add_action('init', array(&$this, 'wp_flag_check_options'), 2);
15
 
16
  // Add the script and style files
17
+ add_action('admin_print_scripts', array(&$this, 'load_scripts'));
18
+ add_action('admin_print_styles', array(&$this, 'load_styles'));
19
+
20
  add_filter('contextual_help', array(&$this, 'show_help'), 10, 2);
21
  add_filter('screen_meta_screen', array(&$this, 'edit_screen_meta'));
22
  }
23
 
24
+ function wp_flag_check_options(){
25
  global $flag;
26
+ require_once(dirname(__FILE__) . '/flag_install.php');
27
  $default_options = flag_list_options();
28
  $flag_db_options = get_option('flag_options');
29
  if($flag_db_options){
30
+ if(function_exists('array_diff_key')){
31
  $flag_new_options = array_diff_key($default_options, $flag_db_options);
32
+ } else{
33
  $flag_new_options = $this->PHP4_array_diff_key($default_options, $flag_db_options);
34
  }
35
  $flag_options = array_merge($flag_db_options, $flag_new_options);
39
  }
40
  }
41
 
42
+ function PHP4_array_diff_key(){
43
  $arrs = func_get_args();
44
  $result = array_shift($arrs);
45
+ foreach($arrs as $array){
46
+ foreach($result as $key => $v){
47
+ if(array_key_exists($key, $array)){
48
  unset($result[$key]);
49
  }
50
  }
51
  }
52
+
53
  return $result;
54
  }
55
 
56
  // integrate the menu
57
+ function add_menu(){
58
+
59
+ add_menu_page(__('GRAND Flash Album Gallery overview', 'flag'), __('FlAGallery'), 'FlAG overview', 'flag-overview', array(
60
+ &$this,
61
+ 'show_menu'
62
+ ), FLAG_URLPATH . 'admin/images/flag.png');
63
+ add_submenu_page('flag-overview', __('GRAND Flash Album Gallery overview', 'flag'), __('Overview', 'flag'), 'FlAG overview', 'flag-overview', array(
64
+ &$this,
65
+ 'show_menu'
66
+ ));
67
+ add_submenu_page('flag-overview', __('FlAG Manage gallery', 'flag'), __('Manage Galleries', 'flag'), 'FlAG Manage gallery', 'flag-manage-gallery', array(
68
+ &$this,
69
+ 'show_menu'
70
+ ));
71
+ add_submenu_page('flag-overview', __('FlAG Music Box', 'flag'), __('Music Box', 'flag'), 'FlAG Manage music', 'flag-music-box', array(
72
+ &$this,
73
+ 'show_menu'
74
+ ));
75
+ add_submenu_page('flag-overview', __('FlAG Video Box', 'flag'), __('Video Box', 'flag'), 'FlAG Manage video', 'flag-video-box', array(
76
+ &$this,
77
+ 'show_menu'
78
+ ));
79
+ add_submenu_page('flag-overview', __('FlAG Banner Box', 'flag'), __('Banner Box', 'flag'), 'FlAG Manage banners', 'flag-banner-box', array(
80
+ &$this,
81
+ 'show_menu'
82
+ ));
83
+ add_submenu_page('flag-overview', __('FlAG Manage skins', 'flag'), __('Skins', 'flag'), 'FlAG Change skin', 'flag-skins', array(
84
+ &$this,
85
+ 'show_menu'
86
+ ));
87
+ add_submenu_page('flag-overview', __('FlAG Change options', 'flag'), __('Options', 'flag'), 'FlAG Change options', 'flag-options', array(
88
+ &$this,
89
+ 'show_menu'
90
+ ));
91
+ add_submenu_page('flag-overview', __('Flagallery in iframe', 'flag'), __('Iframe', 'flag'), 'FlAG iFrame page', 'flag-iframe', array(
92
+ &$this,
93
+ 'show_menu'
94
+ ));
95
+ if(flag_wpmu_site_admin()){
96
+ add_submenu_page('wpmu-admin.php', __('GRAND Flash Album Gallery', 'flag'), __('Grand Flagallery', 'flag'), 'activate_plugins', 'flag-wpmu', array(
97
+ &$this,
98
+ 'show_menu'
99
+ ));
100
+ }
101
 
102
  //register the column fields
103
+ $this->register_columns();
104
 
105
  }
106
 
107
  // load the script for the defined page and load only this code
108
+ function show_menu(){
109
+
110
  global $flag;
111
+
112
  // Set installation date
113
+ if(empty($flag->options['installDate'])){
114
  $flag->options['installDate'] = time();
115
+ update_option('flag_options', $flag->options);
116
  }
117
+
118
+ switch($_GET['page']){
119
  case "flag-manage-gallery" :
120
+ include_once(dirname(__FILE__) . '/functions.php'); // admin functions
121
+ include_once(dirname(__FILE__) . '/manage.php'); // flag_admin_manage_gallery
122
  // Initate the Manage Gallery page
123
  $flag->manage_page = new flagManageGallery();
124
  // Render the output now, because you cannot access a object during the constructor is not finished
125
  $flag->manage_page->controller();
126
+
127
  break;
128
  case "flag-music-box" :
129
+ include_once(dirname(__FILE__) . '/music-box.php'); // flag_music_box
130
  flag_music_controler();
131
  break;
132
  case "flag-video-box" :
133
+ include_once(dirname(__FILE__) . '/video-box.php'); // flag_video_box
134
  flag_video_controler();
135
  break;
136
  case "flag-banner-box" :
137
+ include_once(dirname(__FILE__) . '/banner-box.php'); // flag_banner_box
138
  flag_banner_controler();
139
  break;
140
  case "flag-options" :
141
+ include_once(dirname(__FILE__) . '/settings.php'); // flag_admin_options
142
  flag_admin_options();
143
  break;
144
  case "flag-skins" :
145
+ include_once(dirname(__FILE__) . '/skins.php'); // flag_manage_skins
146
  break;
147
  case "flag-iframe" :
148
+ include_once(dirname(__FILE__) . '/flagframe-tool.php'); // flagframe-tool
149
  break;
150
  case "flag-wpmu" :
151
+ include_once(dirname(__FILE__) . '/wpmu.php'); // flag_wpmu_admin
152
  flag_wpmu_setup();
153
  break;
154
  default :
155
+ include_once(dirname(__FILE__) . '/overview.php'); // flag_admin_overview
156
  flag_admin_overview();
157
  break;
158
  }
159
  }
160
+
161
+ function load_scripts(){
162
+
163
+ wp_register_script('flag-ajax', FLAG_URLPATH . 'admin/js/flag.ajax.js', array('jquery'), '1.4.0');
164
  wp_localize_script('flag-ajax', 'flagAjaxSetup', array(
165
+ 'url' => admin_url('admin-ajax.php'),
166
+ 'action' => 'flag_ajax_operation',
167
+ 'operation' => '',
168
+ 'nonce' => wp_create_nonce('flag-ajax'),
169
+ 'ids' => '',
170
+ 'permission' => __('You do not have the correct permission', 'flag'),
171
+ 'error' => __('Unexpected Error', 'flag'),
172
+ 'failure' => __('A failure occurred', 'flag')
173
+ ));
174
+ wp_register_script('flag-progressbar', FLAG_URLPATH . 'admin/js/flag.progressbar.js', array('jquery'), '1.0.0');
175
+
176
+ if(isset($_GET['page'])){
177
+ switch($_GET['page']){
178
+ case 'flag-overview' :
179
+ wp_enqueue_script('postbox');
180
  case "flag-manage-gallery" :
181
+ print "<script type='text/javascript' src='" . FLAG_URLPATH . "admin/js/tabs.js'></script>\n";
182
 
183
  wp_enqueue_style('jquery-ui-smoothness', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.min.css', array(), '1.10.4', 'screen');
184
  wp_enqueue_script('jquery-ui-full', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js', array('jquery'), '1.10.4');
185
 
186
+ wp_enqueue_script('jquery-ui-droppable');
187
 
188
+ wp_enqueue_script('multifile', FLAG_URLPATH . 'admin/js/jquery.MultiFile.js', array('jquery'), '1.4.6');
189
 
190
+ wp_enqueue_script('flag-plupload', FLAG_URLPATH . 'admin/js/plupload/plupload.full.min.js', array(
191
+ 'jquery',
192
+ 'jquery-ui-full'
193
+ ), '2.1.1');
194
 
195
+ wp_enqueue_style('jquery.ui.plupload', FLAG_URLPATH . 'admin/js/plupload/jquery.ui.plupload/css/jquery.ui.plupload.css', array('jquery-ui-smoothness'), '2.1.1', 'screen');
196
+ wp_enqueue_script('jquery.ui.plupload', FLAG_URLPATH . 'admin/js/plupload/jquery.ui.plupload/jquery.ui.plupload.min.js', array(
197
+ 'flag-plupload',
198
+ 'jquery-ui-full'
199
+ ), '2.1.1');
200
 
201
 
202
+ wp_enqueue_script('dataset', FLAG_URLPATH . 'admin/js/jquery.dataset.js', array('jquery'), '0.1.0');
203
+ wp_enqueue_script('postbox');
204
+ wp_enqueue_script('flag-ajax');
205
+ wp_enqueue_script('flag-progressbar');
206
  add_thickbox();
207
+ break;
208
  case "flag-music-box" :
209
+ wp_enqueue_script('swfobject');
210
+ wp_enqueue_script('thickbox');
211
+ break;
212
  case "flag-video-box" :
213
+ wp_enqueue_script('swfobject');
214
+ wp_enqueue_script('thickbox');
215
+ break;
216
  case "flag-banner-box" :
217
+ wp_enqueue_script('thickbox');
218
+ break;
219
  case "flag-options" :
220
+ wp_enqueue_script('farbtastic-nosharp', FLAG_URLPATH . 'admin/js/farbtastic-nosharp.js', array('jquery'), '1.2');
221
+ print "<script type='text/javascript' src='" . FLAG_URLPATH . "admin/js/tabs.js'></script>\n";
222
+ break;
223
  case "flag-skins" :
224
+ wp_enqueue_script('thickbox');
225
+ wp_enqueue_script('farbtastic-nosharp', FLAG_URLPATH . 'admin/js/farbtastic-nosharp.js', array('jquery'), '1.2');
226
  //wp_enqueue_script( 'farbtastic' );
227
+ print "<script type='text/javascript' src='" . FLAG_URLPATH . "admin/js/tabs.js'></script>\n";
228
+ break;
229
  }
230
  }
231
+ }
232
+
233
+ function load_styles(){
234
+
235
+ if(isset($_GET['page'])){
236
+ switch($_GET['page']){
237
  case 'flag-overview' :
238
+ wp_enqueue_style('flagadmin', FLAG_URLPATH . 'admin/css/flagadmin.css', false, '2.8.1', 'screen');
239
+ wp_admin_css('css/dashboard');
240
+ break;
241
  case "flag-options" :
242
+ wp_enqueue_style('farbtastic');
243
  case "flag-manage-gallery" :
244
+ wp_enqueue_style('flagtabs', FLAG_URLPATH . 'admin/css/tabs.css', false, '1.0.0', 'screen');
245
  case "flag-music-box" :
246
+ case "flag-video-box" :
247
+ case "flag-banner-box" :
248
+ wp_enqueue_style('thickbox');
249
+ wp_enqueue_style('flagadmin', FLAG_URLPATH . 'admin/css/flagadmin.css', false, '2.8.1', 'screen');
250
+ break;
251
  case "flag-skins" :
252
+ wp_enqueue_style('thickbox');
253
+ wp_enqueue_style('farbtastic');
254
+ wp_enqueue_style('flagtabs', FLAG_URLPATH . 'admin/css/tabs.css', false, '1.0.0', 'screen');
255
+ wp_enqueue_style('flagadmin', FLAG_URLPATH . 'admin/css/flagadmin.css', false, '2.8.1', 'screen');
256
+ wp_admin_css('css/dashboard');
257
+ break;
258
+ }
259
  }
260
  }
 
 
261
 
262
+ function show_help($help, $screen){
263
+
264
+ $link = '';
265
  // menu title is localized...
266
+ $i18n = strtolower(_n('Gallery', 'Galleries', 1, 'flag'));
267
 
268
+ switch($screen){
269
  case 'toplevel_page_' . 'flag-overview' :
270
  case "{$i18n}_page_flag-manage-gallery" :
271
  case "flag-manage-gallery":
273
  case "{$i18n}_page_flag-skins" :
274
  case "{$i18n}_page_flag-options" :
275
  $link = '<a href="http://codeasily.com/wordpress-plugins/flag/" target="_blank">CodEasily.com</a>';
276
+ break;
277
  }
278
+
279
+ if(!empty($link)){
280
+ $help = '<h5>' . __('Get help with Grand Flagallery', 'flag') . '</h5>';
281
  $help .= '<div class="metabox-prefs">';
282
  $help .= $link;
283
  $help .= "</div>\n";
288
  $help .= ' | <a href="http://codeasily.com/community/topic/language-files/" target="_blank">' . __('Get your language pack', 'flag') . '</a>';
289
  $help .= ' | <a href="http://codeasily.com/portfolio/grand-flagallery-skins/" target="_blank">' . __('Skins for Grand Flagallery', 'flag') . '</a>';
290
  $help .= "</div>\n";
291
+ }
292
+
293
  return $help;
294
  }
295
+
296
+ function edit_screen_meta($screen){
297
 
298
  // menu title is localized, so we need to change the toplevel name
299
+ $i18n = strtolower(_n('Gallery', 'Galleries', 1, 'flag'));
300
+
301
+ switch($screen){
302
  case "{$i18n}_page_flag-manage-gallery" :
303
  // we would like to have screen option only at the manage images / gallery page
304
+ if(isset ($_POST['sortGallery'])){
305
  $screen = $screen;
306
+ } else if(($_GET['mode'] == 'edit') || isset ($_POST['backToGallery'])){
307
  $screen = 'flag-manage-images';
308
+ } else if(($_GET['mode'] == 'sort')){
309
  $screen = $screen;
310
+ } else{
311
+ $screen = 'flag-manage-gallery';
312
+ }
313
+ break;
314
  }
315
 
316
  return $screen;
317
  }
318
 
319
+ function register_column_headers($screen, $columns){
320
  global $_wp_column_headers;
321
+
322
+ if(!isset($_wp_column_headers)){
323
  $_wp_column_headers = array();
324
+ }
325
+
326
  $_wp_column_headers[$screen] = $columns;
327
  }
328
 
329
+ function register_columns(){
330
+ include_once(dirname(__FILE__) . '/manage-images.php');
331
+ $this->register_column_headers('flag-manage-images', flag_manage_gallery_columns());
332
  }
333
 
334
  }
335
 
336
+ function flag_wpmu_site_admin(){
337
  // Check for site admin
338
+ if(function_exists('is_site_admin')){
339
+ if(is_super_admin()){
340
  return true;
341
+ }
342
+ }
343
+
344
  return false;
345
  }
admin/skins.php CHANGED
@@ -357,6 +357,79 @@ if( isset($_GET['skins_refresh']) ) {
357
  $all_skins = get_skins(false,$type);
358
  $total_all_skins = count($all_skins);
359
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
  $skins_remote_xml = 'https://dl.dropbox.com/u/104873029/flagallery_skins/skins_v2.xml';
361
  // not installed skins
362
  $skins_xml = @simplexml_load_file($skins_remote_xml, 'SimpleXMLElement', LIBXML_NOCDATA);
@@ -364,15 +437,17 @@ $total_all_skins = count($all_skins);
364
  $skins_xml_error = false;
365
  if(empty($skins_xml) && function_exists('curl_init')){
366
  $ch = curl_init($skins_remote_xml);
367
- curl_setopt($ch, CURLOPT_HEADER, 0);
368
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
369
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
370
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
371
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
372
  curl_setopt($ch, CURLOPT_TIMEOUT, 15);
373
- $skins_xml = @simplexml_load_string(curl_exec($ch));
 
374
  curl_close ($ch);
375
  }
 
376
  if(!empty($skins_xml)) {
377
  foreach($skins_xml as $skin){
378
  $suid = (string) $skin->uid;
357
  $all_skins = get_skins(false,$type);
358
  $total_all_skins = count($all_skins);
359
 
360
+ function flag_curl_exec_follow($ch, &$maxredirect = null) {
361
+
362
+ // we emulate a browser here since some websites detect
363
+ // us as a bot and don't let us do our job
364
+ $user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5)".
365
+ " Gecko/20041107 Firefox/1.0";
366
+ curl_setopt($ch, CURLOPT_USERAGENT, $user_agent );
367
+
368
+ $mr = $maxredirect === null ? 5 : intval($maxredirect);
369
+
370
+ if (filter_var(ini_get('open_basedir'), FILTER_VALIDATE_BOOLEAN) === false
371
+ && filter_var(ini_get('safe_mode'), FILTER_VALIDATE_BOOLEAN) === false
372
+ ) {
373
+
374
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $mr > 0);
375
+ curl_setopt($ch, CURLOPT_MAXREDIRS, $mr);
376
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
377
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
378
+
379
+ } else {
380
+
381
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
382
+
383
+ if ($mr > 0)
384
+ {
385
+ $original_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
386
+ $newurl = $original_url;
387
+
388
+ $rch = curl_copy_handle($ch);
389
+
390
+ curl_setopt($rch, CURLOPT_HEADER, true);
391
+ curl_setopt($rch, CURLOPT_NOBODY, true);
392
+ curl_setopt($rch, CURLOPT_FORBID_REUSE, false);
393
+ do
394
+ {
395
+ curl_setopt($rch, CURLOPT_URL, $newurl);
396
+ $header = curl_exec($rch);
397
+ if (curl_errno($rch)) {
398
+ $code = 0;
399
+ } else {
400
+ $code = curl_getinfo($rch, CURLINFO_HTTP_CODE);
401
+ if ($code == 301 || $code == 302) {
402
+ preg_match('/Location:(.*?)\n/i', $header, $matches);
403
+ $newurl = trim(array_pop($matches));
404
+
405
+ // if no scheme is present then the new url is a
406
+ // relative path and thus needs some extra care
407
+ if(!preg_match("/^https?:/i", $newurl)){
408
+ $newurl = $original_url . $newurl;
409
+ }
410
+ } else {
411
+ $code = 0;
412
+ }
413
+ }
414
+ } while ($code && --$mr);
415
+
416
+ curl_close($rch);
417
+
418
+ if (!$mr)
419
+ {
420
+ if ($maxredirect === null)
421
+ trigger_error('Too many redirects.', E_USER_WARNING);
422
+ else
423
+ $maxredirect = 0;
424
+
425
+ return false;
426
+ }
427
+ curl_setopt($ch, CURLOPT_URL, $newurl);
428
+ }
429
+ }
430
+ return curl_exec($ch);
431
+ }
432
+
433
  $skins_remote_xml = 'https://dl.dropbox.com/u/104873029/flagallery_skins/skins_v2.xml';
434
  // not installed skins
435
  $skins_xml = @simplexml_load_file($skins_remote_xml, 'SimpleXMLElement', LIBXML_NOCDATA);
437
  $skins_xml_error = false;
438
  if(empty($skins_xml) && function_exists('curl_init')){
439
  $ch = curl_init($skins_remote_xml);
440
+ /*curl_setopt($ch, CURLOPT_HEADER, 0);
441
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
442
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
443
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
444
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
445
  curl_setopt($ch, CURLOPT_TIMEOUT, 15);
446
+ */
447
+ $skins_xml = @simplexml_load_string(flag_curl_exec_follow($ch));
448
  curl_close ($ch);
449
  }
450
+
451
  if(!empty($skins_xml)) {
452
  foreach($skins_xml as $skin){
453
  $suid = (string) $skin->uid;
flag.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: GRAND Flash Album Gallery
4
  Plugin URI: http://codeasily.com/wordpress-plugins/flag/
5
  Description: The Grand Flagallery plugin - provides a comprehensive interface for managing photos and images through a set of admin pages, and it displays photos in a way that makes your web site look very professional.
6
- Version: 4.28
7
  Author: Rattus
8
  Author URI: http://codeasily.com/
9
 
@@ -23,7 +23,7 @@ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You
23
  if (!class_exists('flagLoad')) {
24
  class flagLoad {
25
 
26
- var $version = '4.28';
27
  var $dbversion = '2.75';
28
  var $minium_WP = '3.0';
29
  var $minium_WPMU = '3.0';
3
  Plugin Name: GRAND Flash Album Gallery
4
  Plugin URI: http://codeasily.com/wordpress-plugins/flag/
5
  Description: The Grand Flagallery plugin - provides a comprehensive interface for managing photos and images through a set of admin pages, and it displays photos in a way that makes your web site look very professional.
6
+ Version: 4.29
7
  Author: Rattus
8
  Author URI: http://codeasily.com/
9
 
23
  if (!class_exists('flagLoad')) {
24
  class flagLoad {
25
 
26
+ var $version = '4.29';
27
  var $dbversion = '2.75';
28
  var $minium_WP = '3.0';
29
  var $minium_WPMU = '3.0';
readme.txt CHANGED
@@ -52,6 +52,9 @@ Also available mp3 players and widgets.
52
 
53
  == Changelog ==
54
 
 
 
 
55
  = v4.28 - 12.01.2015 =
56
  * Fixed urls to install skins and other plugin's website links
57
 
52
 
53
  == Changelog ==
54
 
55
+ = v4.29 - 21.01.2015 =
56
+ * Fixed warning on Skins page when open_basedir = 'Off'
57
+
58
  = v4.28 - 12.01.2015 =
59
  * Fixed urls to install skins and other plugin's website links
60