WP Photo Album Plus - Version 8.2.06.001

Version Description

= 8.1.08 =

  • This version addresses various bug fixes, feature requests and security fixes.
Download this release

Release Info

Developer opajaap
Plugin Icon wp plugin WP Photo Album Plus
Version 8.2.06.001
Comparing to
See all releases

Code changes from version 8.2.05.008 to 8.2.06.001

Files changed (5) hide show
  1. changelog.txt +4 -0
  2. wppa-export.php +115 -58
  3. wppa-input.php +1 -0
  4. wppa-utils.php +6 -6
  5. wppa.php +6 -7
changelog.txt CHANGED
@@ -1,5 +1,9 @@
1
  WP Photo Album Plus Changelog
2
 
 
 
 
 
3
  = 8.2.05 =
4
 
5
  * Switching language e.g. by qTranslate plugin, did no longer load the right language files. Fixed. Also retro-fixed in 8.2.04.009 on aug 08 2022.
1
  WP Photo Album Plus Changelog
2
 
3
+ = 8.2.06 =
4
+
5
+ * Export page enhanced.
6
+
7
  = 8.2.05 =
8
 
9
  * Switching language e.g. by qTranslate plugin, did no longer load the right language files. Fixed. Also retro-fixed in 8.2.04.009 on aug 08 2022.
wppa-export.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the export functions
6
- * Version 8.2.05.008
7
  *
8
  */
9
 
@@ -17,13 +17,24 @@ global $wpdb;
17
  check_admin_referer( '$wppa_nonce', WPPA_NONCE );
18
  wppa_export_photos();
19
  }
 
 
 
 
 
 
 
 
 
 
 
20
  wppa_echo( '
21
  <div class="wrap">
22
  <h2>' .
23
  __( 'Export Photos', 'wp-photo-album-plus' ) . '
24
  </h2>
25
  <br>
26
-
27
  <form action="' . esc_url( get_admin_url() . 'admin.php?page=wppa_export_photos' ) . '" method="post"> ' .
28
  wp_nonce_field( '$wppa_nonce', WPPA_NONCE ) .
29
  sprintf( __( 'Photos will be exported to: <b>%s</b>.', 'wp-photo-album-plus' ), WPPA_DEPOT ) . '
@@ -35,8 +46,13 @@ global $wpdb;
35
  // $high = '0';
36
 
37
  wppa_echo( '
38
- <table class="form-table albumtable">
39
  <thead>
 
 
 
 
 
40
  </thead>
41
  <tbody>
42
  <tr>' );
@@ -44,21 +60,31 @@ global $wpdb;
44
  foreach( $albums as $album ) {
45
  $id = $album['id'];
46
  $line = '&nbsp;' . $id . ':&nbsp;' . __( stripslashes( $album['name'] ) );
47
-
48
- if ( is_file( WPPA_DEPOT_PATH . '/album-' . $id . '.zip' ) ) {
 
 
 
 
 
 
 
 
 
 
49
  wppa_echo( '
50
- <td>
51
  <a
52
  href="' . esc_attr( WPPA_DEPOT_URL . '/album-' . $id . '.zip' ) . '"
53
  download="' . esc_attr( wppa_get_album_name( $id ) ) . '">
54
- <input type="button" class="button-primary" value="' . esc_attr( __( 'Download', 'wp-photo-album-plus' ) . ' ' . $line ) . '">
55
  </a>
56
  </td>' );
57
  }
58
  else {
59
  wppa_echo( '
60
  <td>
61
- <input type="checkbox" name="album-' . $album['id'] . '">&nbsp;' . $line . '
62
  </td>' );
63
  }
64
  if ( $ct == 4 ) {
@@ -77,6 +103,7 @@ global $wpdb;
77
  <input type="submit" class="button-primary" name="wppa-export-submit" value="' . esc_attr( __( 'Export', 'wp-photo-album-plus' ) ) . '">
78
  </p>
79
  </form>
 
80
  </div>' );
81
 
82
  }
@@ -90,7 +117,7 @@ global $wppa_temp_idx;
90
  $wppa_temp_idx = 0;
91
 
92
  wppa_echo( __( 'Exporting', 'wp-photo-album-plus' ) . '...<br>' );
93
- wppa_echo( sprintf( __( 'If you do not get a message like "nn Album exported" within %d seconds, your browser may be timed out. In tha case, just redo the export', 'wp-photo-album-plus' ), wppa_time_left() ) );
94
  if ( PHP_VERSION_ID >= 50207 && class_exists('ZipArchive') ) {
95
  $can_zip = true;
96
  }
@@ -109,39 +136,91 @@ global $wppa_temp_idx;
109
  // Process this album?
110
  if ( wppa_get( 'album-' . $id, '0', 'text' ) ) {
111
 
112
- echo('<br>' . __( 'Opening zip output file...', 'wp-photo-album-plus' ) );
113
- $wppa_zip = new ZipArchive;
114
-
115
- $zipfile = WPPA_DEPOT_PATH . '/album-' . $id . '.zip';
116
- if ( $wppa_zip->open( $zipfile, 1 ) === TRUE ) {
117
- wppa_echo( sprintf( __( 'ok, <br>Filling %1s with data from album %2s', 'wp-photo-album-plus' ), basename( $zipfile ), wppa_get_album_name( $id ) ) );
118
- } else {
119
- wppa_echo( __( 'failed', 'wp-photo-album-plus' ) );
 
 
 
 
 
 
 
 
120
  $wppa_zip = false;
121
  }
122
 
123
  wppa_echo( '<br>' . sprintf( __( 'Processing album %d. Time left: %d seconds', 'wp-photo-album-plus' ), $id, wppa_time_left() ) );
124
- wppa_write_album_file_by_id( $id );
 
 
 
125
  $photos = $wpdb->get_results($wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos
126
- WHERE album = %d", $id ), ARRAY_A );
 
 
127
  $cnt = 0;
128
  foreach ( $photos as $photo ) {
129
 
130
- // Copy the photo
131
- $photo_id = strval( intval( $photo['id'] ) );
132
- $from = wppa_get_photo_path( $photo_id );
 
 
 
 
 
 
 
 
 
 
 
 
133
  $to = WPPA_DEPOT_PATH . '/' . $photo_id . '.' . $photo['ext'];
134
 
 
135
  if ( $wppa_zip ) {
136
- $wppa_zip->addFile ( $from, basename ( $to ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  }
138
- else wppa_copy ( $from, $to );
139
 
140
- // Create the metadata
141
- if ( ! wppa_write_photo_file ( $photo ) ) {
142
- return false;
 
 
 
 
 
 
 
 
 
 
143
  }
144
- else $cnt++;
145
 
146
  if ( wppa_is_time_up() ) {
147
  $abort = true;
@@ -149,41 +228,27 @@ global $wppa_temp_idx;
149
 
150
  if ( $abort ) break;
151
 
152
- $wppa_zip->close();
153
- $wppa_zip->open( $zipfile );
154
  }
155
 
156
- if ( $abort ) {
157
- wppa_echo( ' ' . __( 'failed.', 'wp-photo-album-plus' ) );
158
  }
159
  else {
160
  wppa_echo( ' '. sprintf( __( 'done. %d photos processed', 'wp-photo-album-plus' ), $cnt ) );
 
161
  }
162
 
163
  if ( $wppa_zip ) {
164
 
165
- wppa_echo( '<br>' . __( 'Closing zip', 'wp-photo-album-plus' ) );
166
- $wppa_zip->close();
167
-
168
  wppa_echo( '<br>' . __( 'Deleting temp files', 'wp-photo-album-plus' ) );
169
 
170
- // Now the zip is closed we can destroy all tempfiles we created here
171
- // This may take some time, so skip it when aborted
172
- if ( ! $abort ) {
173
- wppa_delete_export_tempfiles();
174
- }
175
-
176
- if ( $abort ) {
177
- if ( wppa_is_file( $zipfile ) ) {
178
- wppa_unlink( $zipfile );
179
- }
180
- }
181
  }
182
 
183
-
184
  if ( ! $abort ) {
185
  wppa_echo( '
186
- <br>
187
  <a
188
  href="' . esc_attr( WPPA_DEPOT_URL . '/album-' . $id . '.zip' ) . '"
189
  download="' . esc_attr( wppa_get_album_name( $id ) ) . '">
@@ -193,18 +258,10 @@ global $wppa_temp_idx;
193
  }
194
 
195
  if ( wppa_is_time_up() ) break;
196
-
197
  }
198
-
199
  }
200
 
201
- if ( !empty( $wppa_temp ) ) {
202
- $extra = '<br>' . __( 'Not all tempfiles could be removed', 'wp-photo-album-plus' );
203
- }
204
- else {
205
- $extra = '';
206
- }
207
- wppa_echo( '<p>' . sprintf( _n( '%d Album exported', '%d Albums exported', $done, 'wp-photo-album-plus' ), $done ) . $extra . '</p>' );
208
 
209
  }
210
 
@@ -359,7 +416,7 @@ global $wppa_temp;
359
  unlink( $file );
360
  unset( $wppa_temp[$key] );
361
  }
362
- if ( wppa_is_time_up() ) {
363
  wppa_echo( '<br>' . __( 'Could not remove all temporary files', 'wp-photo-album-plus' ) );
364
  return false;
365
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the export functions
6
+ * Version 8.2.06.001
7
  *
8
  */
9
 
17
  check_admin_referer( '$wppa_nonce', WPPA_NONCE );
18
  wppa_export_photos();
19
  }
20
+ $the_js = '
21
+ function wppaToggleExportBoxes(elm) {
22
+ if (jQuery(elm).prop("checked")) {
23
+ jQuery(".exbox").prop("checked",true);
24
+ }
25
+ else {
26
+ jQuery(".exbox").prop("checked",false);
27
+ }
28
+ }
29
+ ';
30
+ wp_add_inline_script( 'wppa-admin', $the_js );
31
  wppa_echo( '
32
  <div class="wrap">
33
  <h2>' .
34
  __( 'Export Photos', 'wp-photo-album-plus' ) . '
35
  </h2>
36
  <br>
37
+ <div style="border:1px solid gray;padding:4px;margin: 3px 0">
38
  <form action="' . esc_url( get_admin_url() . 'admin.php?page=wppa_export_photos' ) . '" method="post"> ' .
39
  wp_nonce_field( '$wppa_nonce', WPPA_NONCE ) .
40
  sprintf( __( 'Photos will be exported to: <b>%s</b>.', 'wp-photo-album-plus' ), WPPA_DEPOT ) . '
46
  // $high = '0';
47
 
48
  wppa_echo( '
49
+ <table class="form-table wppa-table widefat">
50
  <thead>
51
+ <tr>
52
+ <td colspan="5">
53
+ <input type="checkbox" onclick="wppaToggleExportBoxes(this)">&nbsp;' . __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
54
+ </td>
55
+ </tr>
56
  </thead>
57
  <tbody>
58
  <tr>' );
60
  foreach( $albums as $album ) {
61
  $id = $album['id'];
62
  $line = '&nbsp;' . $id . ':&nbsp;' . __( stripslashes( $album['name'] ) );
63
+ $zipfile = WPPA_DEPOT_PATH . '/album-' . $id . '.zip';
64
+ if ( is_file( $zipfile ) ) {
65
+ $wppa_zip = new ZipArchive;
66
+ $wppa_zip->open( $zipfile, 1 );
67
+ $numfiles = $wppa_zip->numFiles;
68
+ $wppa_zip->close();
69
+ $numphotos = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album = $id AND ext NOT IN ('xxx', 'pdf')" );
70
+ $nin = ( $numfiles - 1 ) / 2;
71
+ if ( $nin < $numphotos ) {
72
+ $xtra = ' ' . __( 'Partial', 'wp-photo-album-plus' ) . ' ' . $nin . '/' . $numphotos;
73
+ }
74
+ else $xtra = '';
75
  wppa_echo( '
76
+ <td>' . ( $xtra ? '<input type="checkbox" class="exbox" name="album-' . $album['id'] . '" checked="checked">&nbsp;' : '' ) . '
77
  <a
78
  href="' . esc_attr( WPPA_DEPOT_URL . '/album-' . $id . '.zip' ) . '"
79
  download="' . esc_attr( wppa_get_album_name( $id ) ) . '">
80
+ <input type="button" class="button-primary" style="padding:0 10px !important" value="' . esc_attr( __( 'Download', 'wp-photo-album-plus' ) . ' ' . $line ) . $xtra . '">
81
  </a>
82
  </td>' );
83
  }
84
  else {
85
  wppa_echo( '
86
  <td>
87
+ <input type="checkbox" class="exbox" name="album-' . $album['id'] . '"' . ( wppa_get( 'album-' . $id, '0', 'text' ) ? ' checked="checked"' : '' ) . '>&nbsp;' . $line . '
88
  </td>' );
89
  }
90
  if ( $ct == 4 ) {
103
  <input type="submit" class="button-primary" name="wppa-export-submit" value="' . esc_attr( __( 'Export', 'wp-photo-album-plus' ) ) . '">
104
  </p>
105
  </form>
106
+ </div>
107
  </div>' );
108
 
109
  }
117
  $wppa_temp_idx = 0;
118
 
119
  wppa_echo( __( 'Exporting', 'wp-photo-album-plus' ) . '...<br>' );
120
+ wppa_echo( sprintf( __( 'If you do not get a message like "nn Albums exported" within %d seconds, your browser may be timed out. In that case, just redo the export', 'wp-photo-album-plus' ), wppa_time_left() ) );
121
  if ( PHP_VERSION_ID >= 50207 && class_exists('ZipArchive') ) {
122
  $can_zip = true;
123
  }
136
  // Process this album?
137
  if ( wppa_get( 'album-' . $id, '0', 'text' ) ) {
138
 
139
+ if ( $can_zip ) {
140
+ echo('<br><br>' . __( 'Opening zip output file...', 'wp-photo-album-plus' ) );
141
+ $wppa_zip = new ZipArchive;
142
+
143
+ $zipfile = WPPA_DEPOT_PATH . '/album-' . $id . '.zip';
144
+ if ( $wppa_zip->open( $zipfile, 1 ) === TRUE ) {
145
+ wppa_echo( sprintf( __( 'ok, <br>Filling %1s with data from album %2s', 'wp-photo-album-plus' ), basename( $zipfile ), wppa_get_album_name( $id ) ) );
146
+ wppa_write_album_file_by_id( $id );
147
+ $wppa_zip->close();
148
+ } else {
149
+ wppa_echo( __( 'failed', 'wp-photo-album-plus' ) );
150
+ $wppa_zip = false;
151
+ }
152
+ }
153
+ else {
154
+ wppa_write_album_file_by_id( $id );
155
  $wppa_zip = false;
156
  }
157
 
158
  wppa_echo( '<br>' . sprintf( __( 'Processing album %d. Time left: %d seconds', 'wp-photo-album-plus' ), $id, wppa_time_left() ) );
159
+
160
+ $usr = wppa_get_user();
161
+ $from = get_transient( "wppa-album-$id-last-export-$usr" );
162
+ if ( ! $from ) $from = '0';
163
  $photos = $wpdb->get_results($wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos
164
+ WHERE album = %d
165
+ AND id > %d
166
+ AND ext NOT IN ('xxx', 'pdf')", $id, $from ), ARRAY_A );
167
  $cnt = 0;
168
  foreach ( $photos as $photo ) {
169
 
170
+ // Find photo id
171
+ $photo_id = $photo['id'];
172
+
173
+ // Try source first
174
+ $from = wppa_get_source_path( $photo_id );
175
+
176
+ // If ot source, try display
177
+ if ( ! wppa_is_file( $from ) ) {
178
+ $from = wppa_get_photo_path( $photo_id );
179
+ }
180
+
181
+ // If not found, kip this one
182
+ if ( ! wppa_is_file( $from ) ) continue;
183
+
184
+ // Find path to depot file
185
  $to = WPPA_DEPOT_PATH . '/' . $photo_id . '.' . $photo['ext'];
186
 
187
+ // If zipfile possible
188
  if ( $wppa_zip ) {
189
+
190
+ $alreadyin = false;
191
+
192
+ // Open zip
193
+ $wppa_zip->open( $zipfile, 1 );
194
+
195
+ // Add file only when not in yet
196
+ if ( $wppa_zip->locateName( basename( $to ) ) !== false ) {
197
+ $alreadyin = true;
198
+ }
199
+ else {
200
+ $wppa_zip->addFile( $from, basename( $to ) );
201
+ wppa_write_photo_file( $photo );
202
+ wppa_echo( '.' );
203
+ }
204
+
205
+ // Close zip
206
+ $wppa_zip->close();
207
+
208
  }
 
209
 
210
+ // No zipfile, just copy to depot
211
+ else {
212
+ wppa_copy( $from, $to );
213
+ wppa_write_photo_file( $photo );
214
+ }
215
+
216
+ if ( ! $alreadyin ) {
217
+
218
+ // Create the metadata
219
+ if ( ! wppa_write_photo_file( $photo ) ) {
220
+ return false;
221
+ }
222
+ else $cnt++;
223
  }
 
224
 
225
  if ( wppa_is_time_up() ) {
226
  $abort = true;
228
 
229
  if ( $abort ) break;
230
 
231
+ set_transient( "wppa-album-$id-last-export-$usr", $photo_id, 3600 );
 
232
  }
233
 
234
+ if ( $abort && $cnt < count( $photos ) ) {
235
+ wppa_echo( ' ' . sprintf( __( 'failed. Only %d out of %d photos processed', 'wp-photo-album-plus' ), $cnt, count( $photos ) ) );
236
  }
237
  else {
238
  wppa_echo( ' '. sprintf( __( 'done. %d photos processed', 'wp-photo-album-plus' ), $cnt ) );
239
+ delete_transient( "wppa-album-$id-last-export-$usr" );
240
  }
241
 
242
  if ( $wppa_zip ) {
243
 
 
 
 
244
  wppa_echo( '<br>' . __( 'Deleting temp files', 'wp-photo-album-plus' ) );
245
 
246
+ wppa_delete_export_tempfiles();
 
 
 
 
 
 
 
 
 
 
247
  }
248
 
 
249
  if ( ! $abort ) {
250
  wppa_echo( '
251
+ <br><br>
252
  <a
253
  href="' . esc_attr( WPPA_DEPOT_URL . '/album-' . $id . '.zip' ) . '"
254
  download="' . esc_attr( wppa_get_album_name( $id ) ) . '">
258
  }
259
 
260
  if ( wppa_is_time_up() ) break;
 
261
  }
 
262
  }
263
 
264
+ wppa_echo( '<p>' . sprintf( _n( '%d Album exported', '%d Albums exported', $done, 'wp-photo-album-plus' ), $done ) . '</p>' );
 
 
 
 
 
 
265
 
266
  }
267
 
416
  unlink( $file );
417
  unset( $wppa_temp[$key] );
418
  }
419
+ if ( wppa_is_time_up( '', 1 ) ) {
420
  wppa_echo( '<br>' . __( 'Could not remove all temporary files', 'wp-photo-album-plus' ) );
421
  return false;
422
  }
wppa-input.php CHANGED
@@ -158,6 +158,7 @@ function wppa_get_get_filter( $name ) {
158
 
159
  // Tags / Cats
160
  case 'tag':
 
161
  case 'upn-tags':
162
  case 'new-tags':
163
  $result = 'tags';
158
 
159
  // Tags / Cats
160
  case 'tag':
161
+ case 'tags':
162
  case 'upn-tags':
163
  case 'new-tags':
164
  $result = 'tags';
wppa-utils.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level utility routines
6
- * Version 8.2.05.008
7
  *
8
  */
9
 
@@ -998,16 +998,16 @@ function wppa_get_imgalt( $id, $lb = false ) {
998
  }
999
 
1000
 
1001
- function wppa_is_time_up( $count = '' ) {
1002
  global $wppa_endtime;
1003
 
1004
  if ( ! $wppa_endtime ) {
1005
  wppa_log( 'err', 'Zero endtime, set to 25 secs after now' );
1006
- $wppa_endtime = time() + 55;
1007
  }
1008
 
1009
  // Time up?
1010
- if ( $wppa_endtime > time() ) {
1011
  return false; // No
1012
  }
1013
 
@@ -1023,9 +1023,9 @@ global $wppa_endtime;
1023
  return true;
1024
  }
1025
 
1026
- function wppa_time_left() {
1027
  global $wppa_endtime;
1028
- return $wppa_endtime - time();
1029
  }
1030
 
1031
  // Update photo modified timestamp
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level utility routines
6
+ * Version 8.2.06.001
7
  *
8
  */
9
 
998
  }
999
 
1000
 
1001
+ function wppa_is_time_up( $count = '', $margin = 5 ) {
1002
  global $wppa_endtime;
1003
 
1004
  if ( ! $wppa_endtime ) {
1005
  wppa_log( 'err', 'Zero endtime, set to 25 secs after now' );
1006
+ $wppa_endtime = time() + 60;
1007
  }
1008
 
1009
  // Time up?
1010
+ if ( $wppa_endtime > ( time() + $margin ) ) {
1011
  return false; // No
1012
  }
1013
 
1023
  return true;
1024
  }
1025
 
1026
+ function wppa_time_left( $margin = 5 ) {
1027
  global $wppa_endtime;
1028
+ return $wppa_endtime - time() - $margin;
1029
  }
1030
 
1031
  // Update photo modified timestamp
wppa.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  * Plugin Name: WP Photo Album Plus
4
  * Description: Easily manage and display your photo albums and slideshows within your WordPress site.
5
- * Version: 8.2.05.008
6
  * Author: J.N. Breetvelt a.k.a. OpaJaap
7
  * Author URI: http://wppa.opajaap.nl/
8
  * Plugin URI: http://wordpress.org/extend/plugins/wp-photo-album-plus/
@@ -23,7 +23,7 @@ global $wpdb;
23
  global $wp_version;
24
 
25
  /* WPPA Version */
26
- global $wppa_version; $wppa_version = '8.2.05.008'; // WPPA software version
27
  global $wppa_revno; $wppa_revno = str_replace( '.', '', $wppa_version ); // WPPA db version
28
 
29
  /* Init page js data */
@@ -36,13 +36,12 @@ global $wppa_endtime;
36
 
37
  $met = intval( ini_get( 'max_execution_time' ) );
38
  if ( $met > 120 && ! wppa_is_cron() && ! defined( 'DOING_WPPA_AJAX' ) ) {
39
- $met -= 30;
40
- }
41
- else {
42
- $met -= 5;
43
  }
 
44
  if ( $met <= 0 ) {
45
- $met = 25;
46
  }
47
 
48
  // $met = 30; // debug
2
  /*
3
  * Plugin Name: WP Photo Album Plus
4
  * Description: Easily manage and display your photo albums and slideshows within your WordPress site.
5
+ * Version: 8.2.06.001
6
  * Author: J.N. Breetvelt a.k.a. OpaJaap
7
  * Author URI: http://wppa.opajaap.nl/
8
  * Plugin URI: http://wordpress.org/extend/plugins/wp-photo-album-plus/
23
  global $wp_version;
24
 
25
  /* WPPA Version */
26
+ global $wppa_version; $wppa_version = '8.2.06.001'; // WPPA software version
27
  global $wppa_revno; $wppa_revno = str_replace( '.', '', $wppa_version ); // WPPA db version
28
 
29
  /* Init page js data */
36
 
37
  $met = intval( ini_get( 'max_execution_time' ) );
38
  if ( $met > 120 && ! wppa_is_cron() && ! defined( 'DOING_WPPA_AJAX' ) ) {
39
+ // $met -= 30;
40
+ $met = 60;
 
 
41
  }
42
+
43
  if ( $met <= 0 ) {
44
+ $met = 30;
45
  }
46
 
47
  // $met = 30; // debug