WP Photo Album Plus - Version 6.9.21

Version Description

  • This version addresses various bug fixes
  • This version addresses various security issues.
Download this release

Release Info

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

Code changes from version 6.9.20 to 6.9.21

Files changed (58) hide show
  1. changelog.txt +6 -0
  2. readme.txt +7 -2
  3. wppa-admin-functions.php +20 -20
  4. wppa-admin.php +9 -9
  5. wppa-adminbar.php +3 -3
  6. wppa-ajax.php +54 -56
  7. wppa-album-admin-autosave.php +27 -18
  8. wppa-album-covers.php +31 -19
  9. wppa-album-navigator-widget.php +5 -5
  10. wppa-album-widget.php +4 -4
  11. wppa-boxes-html.php +29 -28
  12. wppa-breadcrumb.php +7 -18
  13. wppa-comment-admin.php +16 -16
  14. wppa-comment-widget.php +2 -2
  15. wppa-common-functions.php +25 -24
  16. wppa-cron.php +7 -7
  17. wppa-encrypt.php +32 -16
  18. wppa-exif-iptc-common.php +19 -19
  19. wppa-export.php +1 -1
  20. wppa-featen-widget.php +6 -6
  21. wppa-filter.php +17 -12
  22. wppa-functions.php +127 -124
  23. wppa-htaccess.php +2 -2
  24. wppa-import.php +39 -34
  25. wppa-index.php +10 -10
  26. wppa-init.php +8 -8
  27. wppa-items.php +3 -3
  28. wppa-lasten-widget.php +7 -7
  29. wppa-links.php +4 -4
  30. wppa-maintenance.php +41 -41
  31. wppa-non-admin.php +20 -20
  32. wppa-photo-admin-autosave.php +29 -28
  33. wppa-potd-admin.php +4 -4
  34. wppa-potd-widget.php +2 -2
  35. wppa-privacy-policy.php +39 -39
  36. wppa-session.php +2 -1
  37. wppa-settings-autosave.php +15 -12
  38. wppa-setup.php +25 -25
  39. wppa-slideshow.php +7 -7
  40. wppa-source.php +0 -17
  41. wppa-statistics.php +27 -26
  42. wppa-stats-widget.php +9 -9
  43. wppa-styles.php +8 -1
  44. wppa-thumbnail-widget.php +8 -8
  45. wppa-thumbnails.php +2 -2
  46. wppa-tinymce-common.php +12 -13
  47. wppa-tinymce-photo-front.php +2 -2
  48. wppa-tinymce-shortcodes.php +3 -3
  49. wppa-topten-widget.php +4 -4
  50. wppa-upldr-widget.php +6 -6
  51. wppa-upload-widget.php +2 -2
  52. wppa-users.php +9 -9
  53. wppa-utils.php +62 -70
  54. wppa-widget-functions.php +26 -26
  55. wppa-wpdb-insert.php +93 -93
  56. wppa-wpdb-update.php +17 -17
  57. wppa-wrappers.php +59 -6
  58. wppa.php +3 -3
changelog.txt CHANGED
@@ -1,5 +1,11 @@
1
  WP Photo Album Plus Changelog
2
 
 
 
 
 
 
 
3
  = 6.9.20 =
4
 
5
  = Bug Fixes =
1
  WP Photo Album Plus Changelog
2
 
3
+ = 6.9.21 =
4
+
5
+ = Bug Fixes =
6
+
7
+ * Album owner could no longer be set to --- public ---. Fixed.
8
+
9
  = 6.9.20 =
10
 
11
  = Bug Fixes =
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: opajaap
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=OpaJaap@OpaJaap.nl&item_name=WP-Photo-Album-Plus&item_number=Support-Open-Source&currency_code=USD&lc=US
4
  Tags: photo, album, slideshow, video, audio, lightbox, iptc, exif, cloudinary, fotomoto, imagemagick, pdf
5
- Version: 6.9.20
6
- Stable tag: 6.9.19
7
  Author: J.N. Breetvelt
8
  Author URI: http://www.opajaap.nl/
9
  Requires at least: 3.9
@@ -137,6 +137,11 @@ See for the full changelog: <a href="http://www.wppa.nl/changelog/" >The documen
137
 
138
  == Upgrade Notice ==
139
 
 
 
 
 
 
140
  = 6.9.20 =
141
 
142
  * This version addresses various bug fixes
2
  Contributors: opajaap
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=OpaJaap@OpaJaap.nl&item_name=WP-Photo-Album-Plus&item_number=Support-Open-Source&currency_code=USD&lc=US
4
  Tags: photo, album, slideshow, video, audio, lightbox, iptc, exif, cloudinary, fotomoto, imagemagick, pdf
5
+ Version: 6.9.21
6
+ Stable tag: 6.9.20
7
  Author: J.N. Breetvelt
8
  Author URI: http://www.opajaap.nl/
9
  Requires at least: 3.9
137
 
138
  == Upgrade Notice ==
139
 
140
+ = 6.9.21 =
141
+
142
+ * This version addresses various bug fixes
143
+ * This version addresses various security issues.
144
+
145
  = 6.9.20 =
146
 
147
  * This version addresses various bug fixes
wppa-admin-functions.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * gp admin functions
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -177,7 +177,7 @@ global $wpdb;
177
 
178
  // Do it with a single photo
179
  elseif ( $pid ) {
180
- $photo = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `id` = %s", $pid ), ARRAY_A );
181
  if ( $photo ) {
182
  $file = wppa_get_source_path( $photo['id'] );
183
  if ( is_file( $file ) ) {
@@ -194,25 +194,25 @@ global $wpdb;
194
  // display usefull message
195
  function wppa_update_message( $msg, $fixed = false, $id = '' ) {
196
 
197
- echo '<div class="notice notice-info is-dismissible"><p>' . $msg . '</p></div>';
198
  }
199
 
200
  // display error message
201
  function wppa_error_message( $msg ) {
202
 
203
- echo '<div class="notice notice-error is-dismissible"><p>' . $msg . '</p></div>';
204
  }
205
 
206
  // display warning message
207
  function wppa_warning_message( $msg, $fixed = false, $id = '' ) {
208
 
209
- echo '<div class="notice notice-warning is-dismissible"><p>' . $msg . '</p></div>';
210
  }
211
 
212
  // display ok message
213
  function wppa_ok_message( $msg ) {
214
 
215
- echo '<div class="notice notice-success is-dismissible"><p>' . $msg . '</p></div>';
216
  }
217
 
218
  function wppa_check_numeric( $value, $minval, $target, $maxval = '' ) {
@@ -618,7 +618,7 @@ function wppa_admin_page_links( $curpage, $pagesize, $count, $link, $extra = ''
618
  function wppa_update_single_photo( $file, $id, $name ) {
619
  global $wpdb;
620
 
621
- $photo = $wpdb->get_row( $wpdb->prepare( "SELECT `id`, `name`, `ext`, `album`, `filename` FROM $wpdb->wppa_photos WHERE `id` = %s", $id ), ARRAY_A );
622
 
623
  // Find extension
624
  $ext = $photo['ext'];
@@ -666,10 +666,10 @@ global $allphotos;
666
  // Find photo entries that apply to the supplied filename
667
  $query = $wpdb->prepare(
668
  "SELECT * FROM $wpdb->wppa_photos WHERE ".
669
- "`filename` = %s OR ".
670
- "`filename` = %s OR ".
671
- "( `filename` = '' AND `name` = %s ) OR ".
672
- "( `filename` = %s )",
673
  wppa_sanitize_file_name( basename( $file ) ), // Usual
674
  $name, // Filename is different in is_wppa_tree import
675
  $name, // Old; pre saving filenames
@@ -707,7 +707,7 @@ global $allphotos;
707
 
708
  // Update filename if still empty ( Old )
709
  if ( ! $photo['filename'] ) {
710
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `filename` = %s WHERE `id` = %s", wppa_sanitize_file_name( basename( $file ) ), $id ) );
711
  }
712
  }
713
  return count( $photos );
@@ -947,7 +947,7 @@ global $wpdb;
947
  $result = '';
948
 
949
  // Get the fieldnames
950
- $fields = $wpdb->get_results( "DESCRIBE `".$table."`", ARRAY_A );
951
 
952
  // Write the .csv header
953
  if ( is_array( $fields ) ) {
@@ -959,13 +959,13 @@ global $wpdb;
959
  fwrite( $file, $result );
960
 
961
  // Init getting the data
962
- $count = $wpdb->get_var( "SELECT COUNT(*) FROM `" . $table . "`" );
963
  $iters = ceil( $count / 1000 );
964
  $iter = 0;
965
 
966
  // Read chunks of 1000 rows
967
  while ( $iter < $iters ) {
968
- $query = "SELECT * FROM `" . $table . "` ORDER BY `id` LIMIT " . 1000 * $iter . ",1000";
969
  $data = $wpdb->get_results( $query, ARRAY_N );
970
 
971
  // Process rows
@@ -1006,16 +1006,16 @@ global $wpdb;
1006
 
1007
  $albcount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_albums" );
1008
  $photocount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos" );
1009
- $pendingcount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `status` = 'pending'" );
1010
- $schedulecount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `status` = 'scheduled'" );
1011
 
1012
  echo sprintf(__('There are <strong>%d</strong> albums and <strong>%d</strong> photos in the system.', 'wp-photo-album-plus'), $albcount, $photocount);
1013
  if ( $pendingcount ) echo ' '.sprintf(__('<strong>%d</strong> photos are pending moderation.', 'wp-photo-album-plus'), $pendingcount);
1014
  if ( $schedulecount ) echo ' '.sprintf(__('<strong>%d</strong> photos are scheduled for later publishing.', 'wp-photo-album-plus'), $pendingcount);
1015
 
1016
- $lastalbum = $wpdb->get_row( "SELECT `id`, `name` FROM $wpdb->wppa_albums ORDER BY `id` DESC LIMIT 1", ARRAY_A );
1017
  if ( $lastalbum ) echo '<br />'.sprintf(__('The most recently added album is <strong>%s</strong> (%d).', 'wp-photo-album-plus'), __(stripslashes($lastalbum['name']), 'wp-photo-album-plus'), $lastalbum['id']);
1018
- $lastphoto = $wpdb->get_row( "SELECT `id`, `name`, `album` FROM $wpdb->wppa_photos ORDER BY `timestamp` DESC LIMIT 1", ARRAY_A );
1019
  if ( $lastphoto['album'] < '1' ) {
1020
  $trashed = true;
1021
  $album = - ( $lastphoto['album'] + '9' );
@@ -1024,7 +1024,7 @@ global $wpdb;
1024
  $trashed = false;
1025
  $album = $lastphoto['album'];
1026
  }
1027
- $lastphotoalbum = $wpdb->get_row($wpdb->prepare( "SELECT `id`, `name` FROM $wpdb->wppa_albums WHERE `id` = %s", $album), ARRAY_A );
1028
  if ( $lastphoto ) {
1029
  echo '<br />'.sprintf(__('The most recently added photo is <strong>%s</strong> (%d)', 'wp-photo-album-plus'), __(stripslashes($lastphoto['name']), 'wp-photo-album-plus'), $lastphoto['id']);
1030
  echo ' '.sprintf(__('in album <strong>%s</strong> (%d).', 'wp-photo-album-plus'), __(stripslashes($lastphotoalbum['name']), 'wp-photo-album-plus'), $lastphotoalbum['id']);
3
  * Package: wp-photo-album-plus
4
  *
5
  * gp admin functions
6
+ * Version 6.9.21
7
  *
8
  */
9
 
177
 
178
  // Do it with a single photo
179
  elseif ( $pid ) {
180
+ $photo = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE id = %s", $pid ), ARRAY_A );
181
  if ( $photo ) {
182
  $file = wppa_get_source_path( $photo['id'] );
183
  if ( is_file( $file ) ) {
194
  // display usefull message
195
  function wppa_update_message( $msg, $fixed = false, $id = '' ) {
196
 
197
+ echo '<div class="notice notice-info is-dismissible"><p>' . sanitize_text_field( $msg ) . '</p></div>';
198
  }
199
 
200
  // display error message
201
  function wppa_error_message( $msg ) {
202
 
203
+ echo '<div class="notice notice-error is-dismissible"><p>' . sanitize_text_field( $msg ) . '</p></div>';
204
  }
205
 
206
  // display warning message
207
  function wppa_warning_message( $msg, $fixed = false, $id = '' ) {
208
 
209
+ echo '<div class="notice notice-warning is-dismissible"><p>' . sanitize_text_field( $msg ) . '</p></div>';
210
  }
211
 
212
  // display ok message
213
  function wppa_ok_message( $msg ) {
214
 
215
+ echo '<div class="notice notice-success is-dismissible"><p>' . sanitize_text_field( $msg ) . '</p></div>';
216
  }
217
 
218
  function wppa_check_numeric( $value, $minval, $target, $maxval = '' ) {
618
  function wppa_update_single_photo( $file, $id, $name ) {
619
  global $wpdb;
620
 
621
+ $photo = $wpdb->get_row( $wpdb->prepare( "SELECT id, name, ext, album, filename FROM $wpdb->wppa_photos WHERE id = %s", $id ), ARRAY_A );
622
 
623
  // Find extension
624
  $ext = $photo['ext'];
666
  // Find photo entries that apply to the supplied filename
667
  $query = $wpdb->prepare(
668
  "SELECT * FROM $wpdb->wppa_photos WHERE ".
669
+ "filename = %s OR ".
670
+ "filename = %s OR ".
671
+ "( filename = '' AND name = %s ) OR ".
672
+ "( filename = %s )",
673
  wppa_sanitize_file_name( basename( $file ) ), // Usual
674
  $name, // Filename is different in is_wppa_tree import
675
  $name, // Old; pre saving filenames
707
 
708
  // Update filename if still empty ( Old )
709
  if ( ! $photo['filename'] ) {
710
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET filename = %s WHERE id = %s", wppa_sanitize_file_name( basename( $file ) ), $id ) );
711
  }
712
  }
713
  return count( $photos );
947
  $result = '';
948
 
949
  // Get the fieldnames
950
+ $fields = $wpdb->get_results( "DESCRIBE ".$table."", ARRAY_A );
951
 
952
  // Write the .csv header
953
  if ( is_array( $fields ) ) {
959
  fwrite( $file, $result );
960
 
961
  // Init getting the data
962
+ $count = $wpdb->get_var( "SELECT COUNT(*) FROM " . $table . "" );
963
  $iters = ceil( $count / 1000 );
964
  $iter = 0;
965
 
966
  // Read chunks of 1000 rows
967
  while ( $iter < $iters ) {
968
+ $query = "SELECT * FROM " . $table . " ORDER BY id LIMIT " . 1000 * $iter . ",1000";
969
  $data = $wpdb->get_results( $query, ARRAY_N );
970
 
971
  // Process rows
1006
 
1007
  $albcount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_albums" );
1008
  $photocount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos" );
1009
+ $pendingcount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE status = 'pending'" );
1010
+ $schedulecount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE status = 'scheduled'" );
1011
 
1012
  echo sprintf(__('There are <strong>%d</strong> albums and <strong>%d</strong> photos in the system.', 'wp-photo-album-plus'), $albcount, $photocount);
1013
  if ( $pendingcount ) echo ' '.sprintf(__('<strong>%d</strong> photos are pending moderation.', 'wp-photo-album-plus'), $pendingcount);
1014
  if ( $schedulecount ) echo ' '.sprintf(__('<strong>%d</strong> photos are scheduled for later publishing.', 'wp-photo-album-plus'), $pendingcount);
1015
 
1016
+ $lastalbum = $wpdb->get_row( "SELECT id, name FROM $wpdb->wppa_albums ORDER BY id DESC LIMIT 1", ARRAY_A );
1017
  if ( $lastalbum ) echo '<br />'.sprintf(__('The most recently added album is <strong>%s</strong> (%d).', 'wp-photo-album-plus'), __(stripslashes($lastalbum['name']), 'wp-photo-album-plus'), $lastalbum['id']);
1018
+ $lastphoto = $wpdb->get_row( "SELECT id, name, album FROM $wpdb->wppa_photos ORDER BY timestamp DESC LIMIT 1", ARRAY_A );
1019
  if ( $lastphoto['album'] < '1' ) {
1020
  $trashed = true;
1021
  $album = - ( $lastphoto['album'] + '9' );
1024
  $trashed = false;
1025
  $album = $lastphoto['album'];
1026
  }
1027
+ $lastphotoalbum = $wpdb->get_row($wpdb->prepare( "SELECT id, name FROM $wpdb->wppa_albums WHERE id = %s", $album), ARRAY_A );
1028
  if ( $lastphoto ) {
1029
  echo '<br />'.sprintf(__('The most recently added photo is <strong>%s</strong> (%d)', 'wp-photo-album-plus'), __(stripslashes($lastphoto['name']), 'wp-photo-album-plus'), $lastphoto['id']);
1030
  echo ' '.sprintf(__('in album <strong>%s</strong> (%d).', 'wp-photo-album-plus'), __(stripslashes($lastphotoalbum['name']), 'wp-photo-album-plus'), $lastphotoalbum['id']);
wppa-admin.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains the admin menu and startups the admin pages
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -40,7 +40,7 @@ function wppa_add_admin() {
40
 
41
  // See if there are uploads pending moderation
42
  $upl_pending = '';
43
- $upl_pending_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `status` = 'pending'" );
44
  if ( $upl_pending_count ) $upl_pending = '<span class="update-plugins"><span class="plugin-count">'.$upl_pending_count.'</span></span>';
45
 
46
  // Compute total pending moderation
@@ -243,7 +243,7 @@ global $wpdb;
243
 
244
  // Recently uploaded photos
245
  echo '<h3>' . __( 'Recently uploaded photos', 'wp-photo-album-plus' ) . '</h3>';
246
- $photos = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos ORDER BY `timestamp` DESC LIMIT 5", ARRAY_A );
247
 
248
  if ( ! empty( $photos ) ) {
249
  echo
@@ -258,8 +258,8 @@ global $wpdb;
258
  echo
259
  '<tr>' .
260
  '<td>' .
261
- '<a href="' . $href . '" target="_blank" >' .
262
- '<img src="' . wppa_get_thumb_url( $photo['id'] ) . '" style="max-width:50px;max-height:50px;" /> ' .
263
  '</a>' .
264
  '</td>' .
265
  '<td>';
@@ -268,12 +268,12 @@ global $wpdb;
268
  $usr = $usr -> display_name;
269
  }
270
  else {
271
- $usr = $photo['owner'];
272
  }
273
  echo
274
  sprintf( __( 'by %s in album %s', 'wp-photo-album-plus' ),
275
  '<b>' . $usr . '</b>',
276
- '<b>' . wppa_get_album_name( $photo['album'] ) . '</b> (' . $photo['album'] . ')'
277
  ) .
278
  '<br />' .
279
  wppa_local_date( '', $photo['timestamp'] ) .
@@ -293,7 +293,7 @@ global $wpdb;
293
 
294
  // Recent comments
295
  echo '<h3>' . __( 'Recent comments on photos', 'wp-photo-album-plus' ) . '</h3>';
296
- $comments = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_comments ORDER BY `timestamp` DESC LIMIT 5", ARRAY_A );
297
  if ( ! empty( $comments ) ) {
298
 
299
  echo
@@ -322,7 +322,7 @@ global $wpdb;
322
  $usr = $comment['user'];
323
  }
324
  echo
325
- '<i>' . $comment['comment'] . '</i>' .
326
  '<br />' .
327
  sprintf( __( 'by %s', 'wp-photo-album-plus' ),
328
  '<b>' . $usr . '</b>' ) .
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains the admin menu and startups the admin pages
6
+ * Version 6.9.21
7
  *
8
  */
9
 
40
 
41
  // See if there are uploads pending moderation
42
  $upl_pending = '';
43
+ $upl_pending_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE status = 'pending'" );
44
  if ( $upl_pending_count ) $upl_pending = '<span class="update-plugins"><span class="plugin-count">'.$upl_pending_count.'</span></span>';
45
 
46
  // Compute total pending moderation
243
 
244
  // Recently uploaded photos
245
  echo '<h3>' . __( 'Recently uploaded photos', 'wp-photo-album-plus' ) . '</h3>';
246
+ $photos = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos ORDER BY timestamp DESC LIMIT 5", ARRAY_A );
247
 
248
  if ( ! empty( $photos ) ) {
249
  echo
258
  echo
259
  '<tr>' .
260
  '<td>' .
261
+ '<a href="' . esc_url( $href ) . '" target="_blank" >' .
262
+ '<img src="' . esc_url( wppa_get_thumb_url( $photo['id'] ) ) . '" style="max-width:50px;max-height:50px;" /> ' .
263
  '</a>' .
264
  '</td>' .
265
  '<td>';
268
  $usr = $usr -> display_name;
269
  }
270
  else {
271
+ $usr = sanitize_user( $photo['owner'] );
272
  }
273
  echo
274
  sprintf( __( 'by %s in album %s', 'wp-photo-album-plus' ),
275
  '<b>' . $usr . '</b>',
276
+ '<b>' . sanitize_text_field( wppa_get_album_name( $photo['album'] ) ) . '</b> (' . strval( intval( $photo['album'] ) ) . ')'
277
  ) .
278
  '<br />' .
279
  wppa_local_date( '', $photo['timestamp'] ) .
293
 
294
  // Recent comments
295
  echo '<h3>' . __( 'Recent comments on photos', 'wp-photo-album-plus' ) . '</h3>';
296
+ $comments = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_comments ORDER BY timestamp DESC LIMIT 5", ARRAY_A );
297
  if ( ! empty( $comments ) ) {
298
 
299
  echo
322
  $usr = $comment['user'];
323
  }
324
  echo
325
+ '<i>' . sanitize_text_field( $comment['comment'] ) . '</i>' .
326
  '<br />' .
327
  sprintf( __( 'by %s', 'wp-photo-album-plus' ),
328
  '<b>' . $usr . '</b>' ) .
wppa-adminbar.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * enhances the admin bar with wppa+ menu
6
- * version 6.9.14
7
  *
8
  */
9
 
@@ -18,12 +18,12 @@ function wppa_admin_bar_menu() {
18
  $menu_items = false;
19
 
20
  // Pending comments
21
- $com_pend = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_comments WHERE `status` = 'pending'" );
22
  if ( $com_pend ) $com_pending = '&nbsp;<span id="ab-awaiting-mod" class="pending-count">'.$com_pend.'</span>';
23
  else $com_pending = '';
24
 
25
  // Pending uploads
26
- $upl_pend = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `status` = 'pending'" );
27
  if ( $upl_pend ) $upl_pending = '&nbsp;<span id="ab-awaiting-mod" class="pending-count">'.$upl_pend.'</span>';
28
  else $upl_pending = '';
29
 
3
  * Package: wp-photo-album-plus
4
  *
5
  * enhances the admin bar with wppa+ menu
6
+ * Version 6.9.21
7
  *
8
  */
9
 
18
  $menu_items = false;
19
 
20
  // Pending comments
21
+ $com_pend = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_comments WHERE status = 'pending'" );
22
  if ( $com_pend ) $com_pending = '&nbsp;<span id="ab-awaiting-mod" class="pending-count">'.$com_pend.'</span>';
23
  else $com_pending = '';
24
 
25
  // Pending uploads
26
+ $upl_pend = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE status = 'pending'" );
27
  if ( $upl_pend ) $upl_pending = '&nbsp;<span id="ab-awaiting-mod" class="pending-count">'.$upl_pend.'</span>';
28
  else $upl_pending = '';
29
 
wppa-ajax.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-ajax.php
3
  *
4
  * Functions used in ajax requests
5
- * Version 6.9.20
6
  *
7
  */
8
 
@@ -135,7 +135,7 @@ global $wppa_log_file;
135
  case 'getssexiflist':
136
  $tag = str_replace( 'H', '#', substr( $_REQUEST['tag'], 0, 6 ) );
137
  $brand = substr( $_REQUEST['tag'], 6 );
138
- $mocc = $_REQUEST['moccur'];
139
  $oldvalue = '';
140
  $ss_data = array();
141
 
@@ -253,15 +253,10 @@ global $wppa_log_file;
253
 
254
  // Is the call valid?
255
  if ( ! isset( $_REQUEST['photo-id'] ) ) die( 'Missing required argument' );
256
- if ( strlen( $_REQUEST['photo-id'] ) == 12 ) {
257
- $photo = wppa_decrypt_photo( $_REQUEST['photo-id'] );
258
- }
259
- else {
260
- $photo = $_REQUEST['photo-id'];
261
- }
262
  $photo = strval( intval( $photo ) );
263
 
264
- // Is this user aloowed to edit thisphoto?
265
  $ok = wppa_may_user_fe_edit( $photo );
266
 
267
  // No rights, die
@@ -297,12 +292,8 @@ global $wppa_log_file;
297
  case 'update-photo-new': // Do the actual edit update
298
 
299
  // Get photo id
300
- if ( strlen( $_REQUEST['photo-id'] ) == 12 ) {
301
- $photo = wppa_decrypt_photo( $_REQUEST['photo-id'] );
302
- }
303
- else {
304
- $photo = $_REQUEST['photo-id'];
305
- }
306
 
307
  // Is the call valid?
308
  $nonce = $_REQUEST['wppa-nonce'];
@@ -460,7 +451,8 @@ global $wppa_log_file;
460
 
461
  case 'remove':
462
 
463
- $pid = wppa_decrypt_photo( $_REQUEST['photo-id'] );
 
464
  $cid = isset( $_REQUEST['comment-id'] ) ? intval( $_REQUEST['comment-id'] ) : 0;
465
 
466
  // Remove photo
@@ -610,7 +602,8 @@ global $wppa_log_file;
610
  case 'addtozip':
611
 
612
  // Check if the user is allowed to do this
613
- $photo = wppa_decrypt_photo( $_REQUEST['photo-id'] );
 
614
  if ( ! wppa_user_is( 'administrator' ) ) {
615
  echo 'ER||Security check failure';
616
  wppa_exit();
@@ -673,7 +666,7 @@ global $wppa_log_file;
673
  break;
674
 
675
  case 'makeorigname':
676
- $photo = wppa_decrypt_photo( $_REQUEST['photo-id'] );
677
  $photo = strval( intval( $photo ) );
678
 
679
  $from = $_REQUEST['from'];
@@ -812,10 +805,8 @@ global $wppa_log_file;
812
 
813
  case 'bumpclickcount':
814
  $nonce = $_REQUEST['wppa-nonce'];
815
- $photo = isset( $_REQUEST['wppa-photo'] ) ? $_REQUEST['wppa-photo'] : 0;
816
- if ( strlen( $photo ) == 12 ) {
817
- $photo = wppa_decrypt_photo( $photo );
818
- }
819
  if ( $photo && wp_verify_nonce( $nonce, 'wppa-check' ) ) {
820
  wppa_bump_clickcount( $photo );
821
  }
@@ -832,7 +823,8 @@ global $wppa_log_file;
832
  }
833
 
834
  // Get commandline args
835
- $photo = wppa_decrypt_photo( $_REQUEST['wppa-rating-id'] );
 
836
  $rating = $_REQUEST['wppa-rating'];
837
  $occur = $_REQUEST['wppa-occur'];
838
  $index = isset( $_REQUEST['wppa-index'] ) ? $_REQUEST['wppa-index'] : '0';
@@ -1156,12 +1148,13 @@ global $wppa_log_file;
1156
  // Register geo shortcode if google-maps-gpx-vieuwer is on board. GPX does it in wp_head(), what is not done in an ajax call
1157
  // if ( function_exists( 'gmapv3' ) ) add_shortcode( 'map', 'gmapv3' );
1158
  // Get the post we are working for
1159
- if ( isset ( $_REQUEST['wppa-fromp'] ) ) {
1160
- $p = $_REQUEST['wppa-fromp'];
1161
- if ( wppa_is_int( $p ) ) {
1162
- $GLOBALS['post'] = get_post( $p );
1163
- }
1164
- }
 
1165
  // Render
1166
  $result = wppa_albums();
1167
  $result = wppa_make_relative( $result );
@@ -1582,13 +1575,8 @@ global $wppa_log_file;
1582
  }
1583
 
1584
  case 'update-photo':
1585
- if ( strlen( $_REQUEST['photo-id'] ) == 12 ) {
1586
- $photo = wppa_decrypt_photo( $_REQUEST['photo-id'] );
1587
- }
1588
- else {
1589
- $photo = $_REQUEST['photo-id'];
1590
- }
1591
- // $photo = $_REQUEST['photo-id'];
1592
  $nonce = $_REQUEST['wppa-nonce'];
1593
  $item = $_REQUEST['item'];
1594
  $value = isset( $_REQUEST['value'] ) ? $_REQUEST['value'] : '';
@@ -1889,7 +1877,7 @@ global $wppa_log_file;
1889
  else {
1890
 
1891
  // Horizon correction shaves size.
1892
- if ( $item = 'skyleft' || $item = 'skyright' ) {
1893
  wppa_get_photox( $id, true );
1894
  }
1895
 
@@ -2036,8 +2024,6 @@ global $wppa_log_file;
2036
  break;
2037
 
2038
  case 'status':
2039
- if ( ! current_user_can( 'wppa_moderate' ) && ! current_user_can( 'wppa_admin' ) ) die( 'Security check failure #78' );
2040
- wppa_invalidate_treecounts( wppa_get_photo_item( $photo, 'album' ) );
2041
  case 'owner':
2042
  case 'name':
2043
  case 'description':
@@ -2051,6 +2037,9 @@ global $wppa_log_file;
2051
  case 'videoy':
2052
  switch ( $item ) {
2053
  case 'status':
 
 
 
2054
  if ( wppa_switch( 'mail_on_approve' ) ) {
2055
  $oldstatus = wppa_get_photo_item( $photo, 'status' );
2056
  if ( $oldstatus == 'pending' ) {
@@ -2167,7 +2156,7 @@ global $wppa_log_file;
2167
  case 'hour':
2168
  case 'min':
2169
  $itemname = __( 'Schedule date/time' , 'wp-photo-album-plus');
2170
- $scheduledtm = $wpdb->get_var( $wpdb->prepare( "SELECT `scheduledtm` FROM$wpdb->wppa_photos WHERE `id` = %s", $photo ) );
2171
  if ( ! $scheduledtm ) {
2172
  $scheduledtm = wppa_get_default_scheduledtm();
2173
  }
@@ -2179,7 +2168,7 @@ global $wppa_log_file;
2179
  if ( $item == 'min' ) $temp[4] = $value;
2180
  $scheduledtm = implode( ',', $temp );
2181
  wppa_update_photo( array( 'id' => $photo, 'scheduledtm' => $scheduledtm, 'status' => 'scheduled' ) );
2182
- wppa_invalidate_treecounts( $wpdb->get_var( $wpdb->prepare( "SELECT `album` FROM $wpdb->wppa_photos WHERE `id` = %s", $photo ) ) );
2183
  wppa_flush_upldr_cache( 'photoid', $photo );
2184
  if ( wppa_is_video( $photo ) ) {
2185
  echo '||0||'.sprintf( __( '%s of video %s updated' , 'wp-photo-album-plus'), $itemname, $photo );
@@ -2195,7 +2184,7 @@ global $wppa_log_file;
2195
  case 'delhour':
2196
  case 'delmin':
2197
  $itemname = __( 'Delete date/time' , 'wp-photo-album-plus');
2198
- $scheduledel = $wpdb->get_var( $wpdb->prepare( "SELECT `scheduledel` FROM $wpdb->wppa_photos WHERE `id` = %s", $photo ) );
2199
  if ( ! $scheduledel ) {
2200
  $scheduledel = wppa_get_default_scheduledtm();
2201
  }
@@ -2209,7 +2198,7 @@ global $wppa_log_file;
2209
  wppa_update_photo( array( 'id' => $photo, 'scheduledel' => $scheduledel ) );
2210
 
2211
  // Make sure not deleted yet
2212
- $alb = $wpdb->get_var( $wpdb->prepare( "SELECT `album` FROM $wpdb->wppa_photos WHERE `id` = %s", $photo ) );
2213
  if ( $alb < '-9' ) {
2214
  $alb = - ( $alb + '9' );
2215
  wppa_update_photo( array( 'id' => $photo, 'album' => $alb ) );
@@ -2280,7 +2269,15 @@ global $wppa_log_file;
2280
 
2281
  // Make the files
2282
  wppa( 'unsanitized_filename', $_FILES['photo']['name'] );
2283
- $bret = wppa_make_the_photo_files( $_FILES['photo']['tmp_name'], $photo, strtolower( wppa_get_ext( $_FILES['photo']['name'] ) ) );
 
 
 
 
 
 
 
 
2284
  if ( $bret ) {
2285
 
2286
  // Update timestamps and sizes
@@ -2761,8 +2758,8 @@ global $wppa_log_file;
2761
  }
2762
  break;
2763
  case 'wppa_viewcount_clear':
2764
- $iret = $wpdb->query( "UPDATE $wpdb->wppa_photos SET `views` = '0'" ) &&
2765
- $wpdb->query( "UPDATE $wpdb->wppa_albums SET `views` = '0'" );
2766
  if ( $iret !== false ) {
2767
  $title = __( 'Viewcounts cleared' , 'wp-photo-album-plus');
2768
  }
@@ -2829,18 +2826,18 @@ global $wppa_log_file;
2829
 
2830
  case 'wppa_rating_max':
2831
  if ( $value == '5' && wppa_opt( 'rating_max' ) == '10' ) {
2832
- $rats = $wpdb->get_results( 'SELECT `id`, `value` FROM `'.WPPA_RATING.'`', ARRAY_A );
2833
  if ( $rats ) {
2834
  foreach ( $rats as $rat ) {
2835
- $wpdb->query( $wpdb->prepare( 'UPDATE `'.WPPA_RATING.'` SET `value` = %s WHERE `id` = %s', $rat['value']/2, $rat['id'] ) );
2836
  }
2837
  }
2838
  }
2839
  if ( $value == '10' && wppa_opt( 'rating_max' ) == '5' ) {
2840
- $rats = $wpdb->get_results( 'SELECT `id`, `value` FROM `'.WPPA_RATING.'`', ARRAY_A );
2841
  if ( $rats ) {
2842
  foreach ( $rats as $rat ) {
2843
- $wpdb->query( $wpdb->prepare( 'UPDATE `'.WPPA_RATING.'` SET `value` = %s WHERE `id` = %s', $rat['value']*2, $rat['id'] ) );
2844
  }
2845
  }
2846
  }
@@ -3100,9 +3097,9 @@ global $wppa_log_file;
3100
  case 'wppa_search_tags':
3101
  case 'wppa_search_cats':
3102
  case 'wppa_search_comments':
3103
- $wpdb->query( "UPDATE $wpdb->wppa_photos SET `indexdtm` = ''" );
3104
  wppa_schedule_maintenance_proc( 'wppa_remake_index_photos' );
3105
- $wpdb->query( "UPDATE $wpdb->wppa_albums SET `indexdtm` = ''" );
3106
  wppa_schedule_maintenance_proc( 'wppa_remake_index_albums' );
3107
  break;
3108
 
@@ -3111,7 +3108,7 @@ global $wppa_log_file;
3111
  $value = trim ( $value );
3112
  $user = wppa_get_user_by ( 'login', $value ); // seems to be case insensitive
3113
  if ( $user && $user->user_login === $value ) {
3114
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `status` = 'pending' WHERE `owner` = %s", $value ) );
3115
  $black_listed_users = get_option( 'wppa_black_listed_users', array() );
3116
  if ( ! in_array( $value, $black_listed_users ) ) {
3117
  $black_listed_users[] = $value;
@@ -3126,7 +3123,7 @@ global $wppa_log_file;
3126
  break;
3127
 
3128
  case 'wppa_un_blacklist_user':
3129
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `status` = 'publish' WHERE `owner` = %s", $value ) );
3130
  $black_listed_users = get_option( 'wppa_black_listed_users', array() );
3131
  if ( in_array( $value, $black_listed_users ) ) {
3132
  foreach ( array_keys( $black_listed_users ) as $usr ) {
@@ -3265,8 +3262,8 @@ global $wppa_log_file;
3265
 
3266
  case 'wppa_use_encrypted_links':
3267
  if ( $value == 'yes' ) {
3268
- $ca = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE `crypt` = ''" );
3269
- $cp = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `crypt` = ''" );
3270
  if ( $ca + $cp ) {
3271
  if ( $ca ) update_option ( 'wppa_crypt_albums_status', 'Required' );
3272
  if ( $cp ) update_option ( 'wppa_crypt_photos_status', 'Required' );
@@ -3290,6 +3287,7 @@ global $wppa_log_file;
3290
  wppa( 'error', '4711' );
3291
  $alert .= __( 'Not allowed when cryptic links is active', 'wp-photo-album-plus' );
3292
  }
 
3293
 
3294
  case 'wppa_enable_video':
3295
  // if off: set all statusses of videos to pending
2
  /* wppa-ajax.php
3
  *
4
  * Functions used in ajax requests
5
+ * Version 6.9.21
6
  *
7
  */
8
 
135
  case 'getssexiflist':
136
  $tag = str_replace( 'H', '#', substr( $_REQUEST['tag'], 0, 6 ) );
137
  $brand = substr( $_REQUEST['tag'], 6 );
138
+ $mocc = strval( intval( $_REQUEST['moccur'] ) );
139
  $oldvalue = '';
140
  $ss_data = array();
141
 
253
 
254
  // Is the call valid?
255
  if ( ! isset( $_REQUEST['photo-id'] ) ) die( 'Missing required argument' );
256
+ $photo = wppa_decrypt_photo( $_REQUEST['photo-id'], false, true );
 
 
 
 
 
257
  $photo = strval( intval( $photo ) );
258
 
259
+ // Is this user allowed to edit thisphoto?
260
  $ok = wppa_may_user_fe_edit( $photo );
261
 
262
  // No rights, die
292
  case 'update-photo-new': // Do the actual edit update
293
 
294
  // Get photo id
295
+ $photo = wppa_decrypt_photo( $_REQUEST['photo-id'], false, true );
296
+ $photo = strval( intval( $photo ) );
 
 
 
 
297
 
298
  // Is the call valid?
299
  $nonce = $_REQUEST['wppa-nonce'];
451
 
452
  case 'remove':
453
 
454
+ $pid = wppa_decrypt_photo( $_REQUEST['photo-id'], false, true );
455
+ $pid = strval( intval( $pid ) );
456
  $cid = isset( $_REQUEST['comment-id'] ) ? intval( $_REQUEST['comment-id'] ) : 0;
457
 
458
  // Remove photo
602
  case 'addtozip':
603
 
604
  // Check if the user is allowed to do this
605
+ $photo = wppa_decrypt_photo( $_REQUEST['photo-id'], false, true );
606
+ $photo = strval( intval( $photo ) );
607
  if ( ! wppa_user_is( 'administrator' ) ) {
608
  echo 'ER||Security check failure';
609
  wppa_exit();
666
  break;
667
 
668
  case 'makeorigname':
669
+ $photo = wppa_decrypt_photo( $_REQUEST['photo-id'], false, true );
670
  $photo = strval( intval( $photo ) );
671
 
672
  $from = $_REQUEST['from'];
805
 
806
  case 'bumpclickcount':
807
  $nonce = $_REQUEST['wppa-nonce'];
808
+ $photo = wppa_decrypt_photo( $_REQUEST['photo-id'], false, true );
809
+ $photo = strval( intval( $photo ) );
 
 
810
  if ( $photo && wp_verify_nonce( $nonce, 'wppa-check' ) ) {
811
  wppa_bump_clickcount( $photo );
812
  }
823
  }
824
 
825
  // Get commandline args
826
+ $photo = wppa_decrypt_photo( $_REQUEST['wppa-rating-id'], false, true );
827
+ $photo = strval( intval( $photo ) );
828
  $rating = $_REQUEST['wppa-rating'];
829
  $occur = $_REQUEST['wppa-occur'];
830
  $index = isset( $_REQUEST['wppa-index'] ) ? $_REQUEST['wppa-index'] : '0';
1148
  // Register geo shortcode if google-maps-gpx-vieuwer is on board. GPX does it in wp_head(), what is not done in an ajax call
1149
  // if ( function_exists( 'gmapv3' ) ) add_shortcode( 'map', 'gmapv3' );
1150
  // Get the post we are working for
1151
+ // if ( isset ( $_REQUEST['wppa-fromp'] ) ) {
1152
+ // $p = $_REQUEST['wppa-fromp'];
1153
+ // if ( wppa_is_int( $p ) ) {
1154
+ // wppa( 'fromp', $p );
1155
+ // $GLOBALS['post'] = get_post( $p );
1156
+ // }
1157
+ // }
1158
  // Render
1159
  $result = wppa_albums();
1160
  $result = wppa_make_relative( $result );
1575
  }
1576
 
1577
  case 'update-photo':
1578
+ $photo = wppa_decrypt_photo( $_REQUEST['photo-id'], false, true );
1579
+ $photo = strval( intval( $photo ) );
 
 
 
 
 
1580
  $nonce = $_REQUEST['wppa-nonce'];
1581
  $item = $_REQUEST['item'];
1582
  $value = isset( $_REQUEST['value'] ) ? $_REQUEST['value'] : '';
1877
  else {
1878
 
1879
  // Horizon correction shaves size.
1880
+ if ( $item == 'skyleft' || $item == 'skyright' ) {
1881
  wppa_get_photox( $id, true );
1882
  }
1883
 
2024
  break;
2025
 
2026
  case 'status':
 
 
2027
  case 'owner':
2028
  case 'name':
2029
  case 'description':
2037
  case 'videoy':
2038
  switch ( $item ) {
2039
  case 'status':
2040
+ if ( ! current_user_can( 'wppa_moderate' ) && ! current_user_can( 'wppa_admin' ) ) die( 'Security check failure #78' );
2041
+ wppa_invalidate_treecounts( wppa_get_photo_item( $photo, 'album' ) );
2042
+
2043
  if ( wppa_switch( 'mail_on_approve' ) ) {
2044
  $oldstatus = wppa_get_photo_item( $photo, 'status' );
2045
  if ( $oldstatus == 'pending' ) {
2156
  case 'hour':
2157
  case 'min':
2158
  $itemname = __( 'Schedule date/time' , 'wp-photo-album-plus');
2159
+ $scheduledtm = $wpdb->get_var( $wpdb->prepare( "SELECT scheduledtm FROM$wpdb->wppa_photos WHERE id = %s", $photo ) );
2160
  if ( ! $scheduledtm ) {
2161
  $scheduledtm = wppa_get_default_scheduledtm();
2162
  }
2168
  if ( $item == 'min' ) $temp[4] = $value;
2169
  $scheduledtm = implode( ',', $temp );
2170
  wppa_update_photo( array( 'id' => $photo, 'scheduledtm' => $scheduledtm, 'status' => 'scheduled' ) );
2171
+ wppa_invalidate_treecounts( $wpdb->get_var( $wpdb->prepare( "SELECT album FROM $wpdb->wppa_photos WHERE id = %s", $photo ) ) );
2172
  wppa_flush_upldr_cache( 'photoid', $photo );
2173
  if ( wppa_is_video( $photo ) ) {
2174
  echo '||0||'.sprintf( __( '%s of video %s updated' , 'wp-photo-album-plus'), $itemname, $photo );
2184
  case 'delhour':
2185
  case 'delmin':
2186
  $itemname = __( 'Delete date/time' , 'wp-photo-album-plus');
2187
+ $scheduledel = $wpdb->get_var( $wpdb->prepare( "SELECT scheduledel FROM $wpdb->wppa_photos WHERE id = %s", $photo ) );
2188
  if ( ! $scheduledel ) {
2189
  $scheduledel = wppa_get_default_scheduledtm();
2190
  }
2198
  wppa_update_photo( array( 'id' => $photo, 'scheduledel' => $scheduledel ) );
2199
 
2200
  // Make sure not deleted yet
2201
+ $alb = $wpdb->get_var( $wpdb->prepare( "SELECT album FROM $wpdb->wppa_photos WHERE id = %s", $photo ) );
2202
  if ( $alb < '-9' ) {
2203
  $alb = - ( $alb + '9' );
2204
  wppa_update_photo( array( 'id' => $photo, 'album' => $alb ) );
2269
 
2270
  // Make the files
2271
  wppa( 'unsanitized_filename', $_FILES['photo']['name'] );
2272
+ $alb = wppa_get_photo_item( $photo, 'album' );
2273
+ $source = wppa_get_source_album_dir( $alb ).'/'.$filename;
2274
+ if ( is_file( $source ) ) {
2275
+ $from = $source;
2276
+ }
2277
+ else {
2278
+ $from = $_FILES['photo']['tmp_name'];
2279
+ }
2280
+ $bret = wppa_make_the_photo_files( $from, $photo, strtolower( wppa_get_ext( $_FILES['photo']['name'] ) ) );
2281
  if ( $bret ) {
2282
 
2283
  // Update timestamps and sizes
2758
  }
2759
  break;
2760
  case 'wppa_viewcount_clear':
2761
+ $iret = $wpdb->query( "UPDATE $wpdb->wppa_photos SET views = '0'" ) &&
2762
+ $wpdb->query( "UPDATE $wpdb->wppa_albums SET views = '0'" );
2763
  if ( $iret !== false ) {
2764
  $title = __( 'Viewcounts cleared' , 'wp-photo-album-plus');
2765
  }
2826
 
2827
  case 'wppa_rating_max':
2828
  if ( $value == '5' && wppa_opt( 'rating_max' ) == '10' ) {
2829
+ $rats = $wpdb->get_results( 'SELECT id, value FROM '.WPPA_RATING.'', ARRAY_A );
2830
  if ( $rats ) {
2831
  foreach ( $rats as $rat ) {
2832
+ $wpdb->query( $wpdb->prepare( 'UPDATE '.WPPA_RATING.' SET value = %s WHERE id = %s', $rat['value']/2, $rat['id'] ) );
2833
  }
2834
  }
2835
  }
2836
  if ( $value == '10' && wppa_opt( 'rating_max' ) == '5' ) {
2837
+ $rats = $wpdb->get_results( 'SELECT id, value FROM '.WPPA_RATING.'', ARRAY_A );
2838
  if ( $rats ) {
2839
  foreach ( $rats as $rat ) {
2840
+ $wpdb->query( $wpdb->prepare( 'UPDATE '.WPPA_RATING.' SET value = %s WHERE id = %s', $rat['value']*2, $rat['id'] ) );
2841
  }
2842
  }
2843
  }
3097
  case 'wppa_search_tags':
3098
  case 'wppa_search_cats':
3099
  case 'wppa_search_comments':
3100
+ $wpdb->query( "UPDATE $wpdb->wppa_photos SET indexdtm = ''" );
3101
  wppa_schedule_maintenance_proc( 'wppa_remake_index_photos' );
3102
+ $wpdb->query( "UPDATE $wpdb->wppa_albums SET indexdtm = ''" );
3103
  wppa_schedule_maintenance_proc( 'wppa_remake_index_albums' );
3104
  break;
3105
 
3108
  $value = trim ( $value );
3109
  $user = wppa_get_user_by ( 'login', $value ); // seems to be case insensitive
3110
  if ( $user && $user->user_login === $value ) {
3111
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET status = 'pending' WHERE owner = %s", $value ) );
3112
  $black_listed_users = get_option( 'wppa_black_listed_users', array() );
3113
  if ( ! in_array( $value, $black_listed_users ) ) {
3114
  $black_listed_users[] = $value;
3123
  break;
3124
 
3125
  case 'wppa_un_blacklist_user':
3126
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET status = 'publish' WHERE owner = %s", $value ) );
3127
  $black_listed_users = get_option( 'wppa_black_listed_users', array() );
3128
  if ( in_array( $value, $black_listed_users ) ) {
3129
  foreach ( array_keys( $black_listed_users ) as $usr ) {
3262
 
3263
  case 'wppa_use_encrypted_links':
3264
  if ( $value == 'yes' ) {
3265
+ $ca = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE crypt = ''" );
3266
+ $cp = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE crypt = ''" );
3267
  if ( $ca + $cp ) {
3268
  if ( $ca ) update_option ( 'wppa_crypt_albums_status', 'Required' );
3269
  if ( $cp ) update_option ( 'wppa_crypt_photos_status', 'Required' );
3287
  wppa( 'error', '4711' );
3288
  $alert .= __( 'Not allowed when cryptic links is active', 'wp-photo-album-plus' );
3289
  }
3290
+ break;
3291
 
3292
  case 'wppa_enable_video':
3293
  // if off: set all statusses of videos to pending
wppa-album-admin-autosave.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * create, edit and delete albums
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -428,7 +428,7 @@ global $wppa_revno;
428
 
429
  // Clicks
430
  if ( wppa_switch( 'track_clickcounts' ) ) {
431
- $click_arr = $wpdb->get_col( "SELECT `clicks` FROM $wpdb->wppa_photos WHERE `album` = $id" );
432
  echo
433
  __( 'Clicks:', 'wp-photo-album-plus' ) . ' ' . array_sum( $click_arr ) . '. ';
434
  }
@@ -459,7 +459,8 @@ global $wppa_revno;
459
  else {
460
  echo '
461
  <select
462
- onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'owner\', this )"';
 
463
  wppa_user_select( $owner );
464
  echo '
465
  </select>&nbsp;';
@@ -787,7 +788,7 @@ global $wppa_revno;
787
  onkeyup="wppaAjaxUpdateAlbum( ' . $id . ', \'description\', this )"
788
  onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'description\', this )"
789
  >' .
790
- $description .
791
  '</textarea>
792
  </td>';
793
  }
@@ -1269,7 +1270,7 @@ global $wppa_revno;
1269
  // album delete confirm page
1270
  else if ($_REQUEST['tab'] == 'del') {
1271
 
1272
- $album_owner = $wpdb->get_var($wpdb->prepare( "SELECT `owner` FROM $wpdb->wppa_albums WHERE `id` = %s", $_REQUEST['edit_id']));
1273
  if ( ( $album_owner == '--- public ---' && ! current_user_can('administrator') ) || ! wppa_have_access($_REQUEST['edit_id']) ) {
1274
  wp_die('You do not have the rights to delete this album');
1275
  }
@@ -1327,7 +1328,7 @@ global $wppa_revno;
1327
  if (isset($_POST['wppa-del-confirm'])) {
1328
  check_admin_referer( '$wppa_nonce', WPPA_NONCE );
1329
 
1330
- $album_owner = $wpdb->get_var($wpdb->prepare("SELECT `owner` FROM $wpdb->wppa_albums WHERE `id` = %s", $_POST['wppa-del-id']));
1331
  if ( ( $album_owner == '--- public ---' && ! current_user_can('administrator') ) || ! wppa_have_access($_POST['wppa-del-id']) ) {
1332
  wp_die('You do not have the rights to delete this album');
1333
  }
@@ -1691,7 +1692,7 @@ global $wpdb;
1691
  <td><?php echo($album['owner']); ?></td>
1692
  <?php } ?>
1693
  <td><?php echo($album['a_order']) ?></td>
1694
- <td><?php echo wppa_get_album_name($album['a_parent'], array( 'extended' => true )) ?></td>
1695
  <?php $url = wppa_dbg_url(get_admin_url().'admin.php?page=wppa_admin_menu&amp;tab=edit&amp;edit_id='.$album['id']); ?>
1696
  <?php $na = $counts['selfalbums']; ?>
1697
  <?php $np = $counts['selfphotos']; ?>
@@ -1931,17 +1932,25 @@ global $wpdb;
1931
  // Make sure all (grand)parents are in
1932
  $done = false;
1933
  while ( ! $done ) {
 
1934
  $done = true;
 
1935
  foreach ( $albums as $a ) {
 
1936
  $parent = $a['a_parent'];
 
1937
  if ( $parent > '0' ) {
 
1938
  $found = false;
 
1939
  foreach ( $albums as $p ) {
 
1940
  if ( $p['id'] == $parent ) {
1941
  $found = true;
1942
  }
1943
  }
1944
  if ( ! $found ) {
 
1945
  $done = false;
1946
 
1947
  // Add missing parent
@@ -1970,7 +1979,7 @@ global $wpdb;
1970
  else update_option('wppa_album_order_'.wppa_get_user().'_reverse', 'no');
1971
  }
1972
 
1973
- if ( ! empty($albums) ) {
1974
 
1975
  // Setup the sequence array
1976
  $seq = false;
@@ -1978,20 +1987,20 @@ global $wpdb;
1978
  foreach( $albums as $album ) {
1979
  switch ( $order ) {
1980
  case 'name':
1981
- $seq[] = strtolower(__(stripslashes($album['name'])));
1982
  break;
1983
  case 'description':
1984
- $seq[] = strtolower(__(stripslashes($album['description'])));
1985
  break;
1986
  case 'owner':
1987
- $seq[] = strtolower($album['owner']);
1988
  break;
1989
  case 'a_order':
1990
  $seq[] = $album['a_order'];
1991
  $num = true;
1992
  break;
1993
  case 'a_parent':
1994
- $seq[] = strtolower(wppa_get_album_name($album['a_parent']), array( 'extended' => true ));
1995
  break;
1996
  default:
1997
  $seq[] = $album['id'];
@@ -2001,8 +2010,8 @@ global $wpdb;
2001
  }
2002
 
2003
  // Sort the seq array
2004
- if ( $num ) asort($seq, SORT_NUMERIC);
2005
- else asort($seq, SORT_REGULAR);
2006
 
2007
  // Reverse ?
2008
  if ( $reverse ) {
@@ -2114,7 +2123,7 @@ global $wpdb;
2114
  <tbody>
2115
 
2116
  <?php wppa_do_albumlist('0', '0', $albums, $seq); ?>
2117
- <?php if ( $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE `a_parent` = '-1'" ) > 0 ) { ?>
2118
  <tr>
2119
  <td colspan="<?php echo ( '19' + ( current_user_can( 'wppa_upload' ) ? '1' : '0' ) + ( current_user_can( 'wppa_import' ) ? '1' : '0' ) ) ?>" >
2120
  <em>
@@ -2321,7 +2330,7 @@ global $wpdb;
2321
  $doit = false;
2322
  if ( wppa_user_is( 'administrator' ) ) $doit = true;
2323
 
2324
- $trashed = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `album` < '0'" );
2325
 
2326
  if ( ! $trashed ) $doit = false;
2327
 
@@ -2476,7 +2485,7 @@ global $wpdb;
2476
  <td><?php echo($album['owner']); ?></td>
2477
  <?php } ?>
2478
  <td><?php echo($album['a_order']) ?></td>
2479
- <td><?php echo wppa_get_album_name($album['a_parent'], array( 'extended' => true )) ?></td>
2480
  <?php $url = wppa_dbg_url(get_admin_url().'admin.php?page=wppa_admin_menu&amp;tab=edit&amp;edit_id='.$album['id']); ?>
2481
  <?php $na = $counts['selfalbums']; ?>
2482
  <?php $np = $counts['selfphotos']; ?>
@@ -2600,7 +2609,7 @@ function wppa_main_photo($cur = '', $covertype) {
2600
  global $wpdb;
2601
 
2602
  $a_id = strval( intval( $_REQUEST['edit_id'] ) );
2603
- $photos = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->wppa_photos WHERE `album` = %s " . wppa_get_photo_order( $a_id ) . " LIMIT 1000", $a_id ), ARRAY_A );
2604
 
2605
  $output = '';
2606
  // if ( ! empty($photos) ) {
3
  * Package: wp-photo-album-plus
4
  *
5
  * create, edit and delete albums
6
+ * Version 6.9.21
7
  *
8
  */
9
 
428
 
429
  // Clicks
430
  if ( wppa_switch( 'track_clickcounts' ) ) {
431
+ $click_arr = $wpdb->get_col( "SELECT clicks FROM $wpdb->wppa_photos WHERE album = $id" );
432
  echo
433
  __( 'Clicks:', 'wp-photo-album-plus' ) . ' ' . array_sum( $click_arr ) . '. ';
434
  }
459
  else {
460
  echo '
461
  <select
462
+ onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'owner\', this )"
463
+ >';
464
  wppa_user_select( $owner );
465
  echo '
466
  </select>&nbsp;';
788
  onkeyup="wppaAjaxUpdateAlbum( ' . $id . ', \'description\', this )"
789
  onchange="wppaAjaxUpdateAlbum( ' . $id . ', \'description\', this )"
790
  >' .
791
+ esc_textarea( stripslashes( $description ) ) .
792
  '</textarea>
793
  </td>';
794
  }
1270
  // album delete confirm page
1271
  else if ($_REQUEST['tab'] == 'del') {
1272
 
1273
+ $album_owner = $wpdb->get_var($wpdb->prepare( "SELECT owner FROM $wpdb->wppa_albums WHERE id = %s", $_REQUEST['edit_id']));
1274
  if ( ( $album_owner == '--- public ---' && ! current_user_can('administrator') ) || ! wppa_have_access($_REQUEST['edit_id']) ) {
1275
  wp_die('You do not have the rights to delete this album');
1276
  }
1328
  if (isset($_POST['wppa-del-confirm'])) {
1329
  check_admin_referer( '$wppa_nonce', WPPA_NONCE );
1330
 
1331
+ $album_owner = $wpdb->get_var($wpdb->prepare("SELECT owner FROM $wpdb->wppa_albums WHERE id = %s", $_POST['wppa-del-id']));
1332
  if ( ( $album_owner == '--- public ---' && ! current_user_can('administrator') ) || ! wppa_have_access($_POST['wppa-del-id']) ) {
1333
  wp_die('You do not have the rights to delete this album');
1334
  }
1692
  <td><?php echo($album['owner']); ?></td>
1693
  <?php } ?>
1694
  <td><?php echo($album['a_order']) ?></td>
1695
+ <td><?php echo sanitize_text_field( wppa_get_album_name( $album['a_parent'], array( 'extended' => true ))) ?></td>
1696
  <?php $url = wppa_dbg_url(get_admin_url().'admin.php?page=wppa_admin_menu&amp;tab=edit&amp;edit_id='.$album['id']); ?>
1697
  <?php $na = $counts['selfalbums']; ?>
1698
  <?php $np = $counts['selfphotos']; ?>
1932
  // Make sure all (grand)parents are in
1933
  $done = false;
1934
  while ( ! $done ) {
1935
+
1936
  $done = true;
1937
+
1938
  foreach ( $albums as $a ) {
1939
+
1940
  $parent = $a['a_parent'];
1941
+
1942
  if ( $parent > '0' ) {
1943
+
1944
  $found = false;
1945
+
1946
  foreach ( $albums as $p ) {
1947
+
1948
  if ( $p['id'] == $parent ) {
1949
  $found = true;
1950
  }
1951
  }
1952
  if ( ! $found ) {
1953
+
1954
  $done = false;
1955
 
1956
  // Add missing parent
1979
  else update_option('wppa_album_order_'.wppa_get_user().'_reverse', 'no');
1980
  }
1981
 
1982
+ if ( ! empty( $albums ) ) {
1983
 
1984
  // Setup the sequence array
1985
  $seq = false;
1987
  foreach( $albums as $album ) {
1988
  switch ( $order ) {
1989
  case 'name':
1990
+ $seq[] = strtolower( __( stripslashes( $album['name'] ) ) );
1991
  break;
1992
  case 'description':
1993
+ $seq[] = strtolower( __( stripslashes( $album['description'] ) ) );
1994
  break;
1995
  case 'owner':
1996
+ $seq[] = strtolower( $album['owner'] );
1997
  break;
1998
  case 'a_order':
1999
  $seq[] = $album['a_order'];
2000
  $num = true;
2001
  break;
2002
  case 'a_parent':
2003
+ $seq[] = strtolower( wppa_get_album_name( $album['a_parent'] ), array( 'extended' => true ) );
2004
  break;
2005
  default:
2006
  $seq[] = $album['id'];
2010
  }
2011
 
2012
  // Sort the seq array
2013
+ if ( $num ) asort( $seq, SORT_NUMERIC );
2014
+ else asort( $seq, SORT_REGULAR );
2015
 
2016
  // Reverse ?
2017
  if ( $reverse ) {
2123
  <tbody>
2124
 
2125
  <?php wppa_do_albumlist('0', '0', $albums, $seq); ?>
2126
+ <?php if ( $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE a_parent = '-1'" ) > 0 ) { ?>
2127
  <tr>
2128
  <td colspan="<?php echo ( '19' + ( current_user_can( 'wppa_upload' ) ? '1' : '0' ) + ( current_user_can( 'wppa_import' ) ? '1' : '0' ) ) ?>" >
2129
  <em>
2330
  $doit = false;
2331
  if ( wppa_user_is( 'administrator' ) ) $doit = true;
2332
 
2333
+ $trashed = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album < '0'" );
2334
 
2335
  if ( ! $trashed ) $doit = false;
2336
 
2485
  <td><?php echo($album['owner']); ?></td>
2486
  <?php } ?>
2487
  <td><?php echo($album['a_order']) ?></td>
2488
+ <td><?php echo sanitize_text_field(wppa_get_album_name($album['a_parent'], array( 'extended' => true ))) ?></td>
2489
  <?php $url = wppa_dbg_url(get_admin_url().'admin.php?page=wppa_admin_menu&amp;tab=edit&amp;edit_id='.$album['id']); ?>
2490
  <?php $na = $counts['selfalbums']; ?>
2491
  <?php $np = $counts['selfphotos']; ?>
2609
  global $wpdb;
2610
 
2611
  $a_id = strval( intval( $_REQUEST['edit_id'] ) );
2612
+ $photos = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->wppa_photos WHERE album = %s " . wppa_get_photo_order( $a_id ) . " LIMIT 1000", $a_id ), ARRAY_A );
2613
 
2614
  $output = '';
2615
  // if ( ! empty($photos) ) {
wppa-album-covers.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for album covers
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -24,18 +24,23 @@ function wppa_album_cover( $id ) {
24
  // Find the cover photo position
25
  wppa( 'coverphoto_pos', wppa_opt( 'coverphoto_pos' ) );
26
 
27
- // Assume multicolumn responsive
28
- $is_mcr = true;
29
-
30
  // Dispatch on covertype
31
  switch ( $cover_type ) {
32
  case 'default':
33
- $is_mcr = false;
 
34
  case 'default-mcr':
35
- wppa_album_cover_default( $id, $is_mcr );
36
  break;
37
  case 'imagefactory':
38
- $is_mcr = false;
 
 
 
 
 
 
 
39
  case 'imagefactory-mcr':
40
  if ( wppa( 'coverphoto_pos' ) == 'left' ) {
41
  wppa( 'coverphoto_pos', 'top' );
@@ -43,10 +48,17 @@ function wppa_album_cover( $id ) {
43
  if ( wppa( 'coverphoto_pos' ) == 'right' ) {
44
  wppa( 'coverphoto_pos', 'bottom' );
45
  }
46
- wppa_album_cover_imagefactory( $id, $is_mcr );
47
  break;
48
  case 'longdesc':
49
- $is_mcr = false;
 
 
 
 
 
 
 
50
  case 'longdesc-mcr':
51
  if ( wppa( 'coverphoto_pos' ) == 'top' ) {
52
  wppa( 'coverphoto_pos', 'left' );
@@ -54,7 +66,7 @@ function wppa_album_cover( $id ) {
54
  if ( wppa( 'coverphoto_pos' ) == 'bottom' ) {
55
  wppa( 'coverphoto_pos', 'right' );
56
  }
57
- wppa_album_cover_longdesc( $id, $is_mcr );
58
  break;
59
  default:
60
  $err = 'Unimplemented covertype: ' . $cover_type;
@@ -875,7 +887,7 @@ global $wpdb;
875
  // If lightbox, we need all the album photos to set up a lightbox set
876
  if ( $photolink['is_lightbox'] ) {
877
  $thumbs = $wpdb->get_results( $wpdb->prepare(
878
- "SELECT * FROM $wpdb->wppa_photos WHERE `album` = %s " .
879
  wppa_get_photo_order( $albumid ), $albumid
880
  ), ARRAY_A );
881
 
@@ -1286,7 +1298,7 @@ static $cached_cover_photo_ids;
1286
  else {
1287
  $temp = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos
1288
  WHERE album = %s
1289
- AND ( ( status <> 'pending' AND `status` <> 'scheduled' ) OR owner = %s )
1290
  ORDER BY RAND(%d)
1291
  LIMIT %d", $alb, $rs, wppa_get_user(), $count ), ARRAY_A );
1292
  }
@@ -1303,7 +1315,7 @@ static $cached_cover_photo_ids;
1303
  else {
1304
  $temp = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos
1305
  WHERE album = %s
1306
- AND ( ( status <> 'pending' AND `status` <> 'scheduled' ) OR owner = %s )
1307
  ORDER BY timestamp DESC
1308
  LIMIT %d", $alb, wppa_get_user(), $count ), ARRAY_A );
1309
  }
@@ -1322,8 +1334,8 @@ static $cached_cover_photo_ids;
1322
  $allalb = wppa_expand_enum( wppa_alb_to_enum_children( $alb ) );
1323
  $temp = $wpdb->get_results( $wpdb->prepare(
1324
  "SELECT * FROM $wpdb->wppa_photos " .
1325
- "WHERE `album` IN ( " . str_replace( '.', ',', $allalb ) . " ) " .
1326
- "AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) " .
1327
  "ORDER BY RAND( " . wppa_get_randseed( 'page' ) . " ) LIMIT %d", wppa_get_user(), $count ), ARRAY_A );
1328
  }
1329
 
@@ -1332,9 +1344,9 @@ static $cached_cover_photo_ids;
1332
  $allalb = wppa_expand_enum( wppa_alb_to_enum_children( $alb ) );
1333
  $temp = $wpdb->get_results( $wpdb->prepare(
1334
  "SELECT * FROM $wpdb->wppa_photos " .
1335
- "WHERE `album` IN ( " . str_replace( '.', ',', $allalb ) . " ) " .
1336
- "AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) " .
1337
- "ORDER BY `timestamp` DESC LIMIT %d", wppa_get_user(), $count ), ARRAY_A );
1338
  }
1339
 
1340
  // Add to 2nd level cache
@@ -1680,7 +1692,7 @@ global $wpdb;
1680
  $first = true;
1681
 
1682
  // Get the children
1683
- // $subs = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums WHERE `a_parent` = " . $id . " " . wppa_get_album_order( $id ), ARRAY_A );
1684
  // Rewritten to:
1685
  /**/
1686
  // Get the albums sort order column
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for album covers
6
+ * Version 6.9.21
7
  *
8
  */
9
 
24
  // Find the cover photo position
25
  wppa( 'coverphoto_pos', wppa_opt( 'coverphoto_pos' ) );
26
 
 
 
 
27
  // Dispatch on covertype
28
  switch ( $cover_type ) {
29
  case 'default':
30
+ wppa_album_cover_default( $id, false );
31
+ break;
32
  case 'default-mcr':
33
+ wppa_album_cover_default( $id, true );
34
  break;
35
  case 'imagefactory':
36
+ if ( wppa( 'coverphoto_pos' ) == 'left' ) {
37
+ wppa( 'coverphoto_pos', 'top' );
38
+ }
39
+ if ( wppa( 'coverphoto_pos' ) == 'right' ) {
40
+ wppa( 'coverphoto_pos', 'bottom' );
41
+ }
42
+ wppa_album_cover_imagefactory( $id, false );
43
+ break;
44
  case 'imagefactory-mcr':
45
  if ( wppa( 'coverphoto_pos' ) == 'left' ) {
46
  wppa( 'coverphoto_pos', 'top' );
48
  if ( wppa( 'coverphoto_pos' ) == 'right' ) {
49
  wppa( 'coverphoto_pos', 'bottom' );
50
  }
51
+ wppa_album_cover_imagefactory( $id, true );
52
  break;
53
  case 'longdesc':
54
+ if ( wppa( 'coverphoto_pos' ) == 'top' ) {
55
+ wppa( 'coverphoto_pos', 'left' );
56
+ }
57
+ if ( wppa( 'coverphoto_pos' ) == 'bottom' ) {
58
+ wppa( 'coverphoto_pos', 'right' );
59
+ }
60
+ wppa_album_cover_longdesc( $id, false );
61
+ break;
62
  case 'longdesc-mcr':
63
  if ( wppa( 'coverphoto_pos' ) == 'top' ) {
64
  wppa( 'coverphoto_pos', 'left' );
66
  if ( wppa( 'coverphoto_pos' ) == 'bottom' ) {
67
  wppa( 'coverphoto_pos', 'right' );
68
  }
69
+ wppa_album_cover_longdesc( $id, true );
70
  break;
71
  default:
72
  $err = 'Unimplemented covertype: ' . $cover_type;
887
  // If lightbox, we need all the album photos to set up a lightbox set
888
  if ( $photolink['is_lightbox'] ) {
889
  $thumbs = $wpdb->get_results( $wpdb->prepare(
890
+ "SELECT * FROM $wpdb->wppa_photos WHERE album = %s " .
891
  wppa_get_photo_order( $albumid ), $albumid
892
  ), ARRAY_A );
893
 
1298
  else {
1299
  $temp = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos
1300
  WHERE album = %s
1301
+ AND ( ( status <> 'pending' AND status <> 'scheduled' ) OR owner = %s )
1302
  ORDER BY RAND(%d)
1303
  LIMIT %d", $alb, $rs, wppa_get_user(), $count ), ARRAY_A );
1304
  }
1315
  else {
1316
  $temp = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos
1317
  WHERE album = %s
1318
+ AND ( ( status <> 'pending' AND status <> 'scheduled' ) OR owner = %s )
1319
  ORDER BY timestamp DESC
1320
  LIMIT %d", $alb, wppa_get_user(), $count ), ARRAY_A );
1321
  }
1334
  $allalb = wppa_expand_enum( wppa_alb_to_enum_children( $alb ) );
1335
  $temp = $wpdb->get_results( $wpdb->prepare(
1336
  "SELECT * FROM $wpdb->wppa_photos " .
1337
+ "WHERE album IN ( " . str_replace( '.', ',', $allalb ) . " ) " .
1338
+ "AND ( ( status <> 'pending' AND status <> 'scheduled' ) OR owner = %s ) " .
1339
  "ORDER BY RAND( " . wppa_get_randseed( 'page' ) . " ) LIMIT %d", wppa_get_user(), $count ), ARRAY_A );
1340
  }
1341
 
1344
  $allalb = wppa_expand_enum( wppa_alb_to_enum_children( $alb ) );
1345
  $temp = $wpdb->get_results( $wpdb->prepare(
1346
  "SELECT * FROM $wpdb->wppa_photos " .
1347
+ "WHERE album IN ( " . str_replace( '.', ',', $allalb ) . " ) " .
1348
+ "AND ( ( status <> 'pending' AND status <> 'scheduled' ) OR owner = %s ) " .
1349
+ "ORDER BY timestamp DESC LIMIT %d", wppa_get_user(), $count ), ARRAY_A );
1350
  }
1351
 
1352
  // Add to 2nd level cache
1692
  $first = true;
1693
 
1694
  // Get the children
1695
+ // $subs = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums WHERE a_parent = " . $id . " " . wppa_get_album_order( $id ), ARRAY_A );
1696
  // Rewritten to:
1697
  /**/
1698
  // Get the albums sort order column
wppa-album-navigator-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * display album names linking to content
6
- * Version 6.9.14
7
  */
8
 
9
  class AlbumNavigatorWidget extends WP_Widget {
@@ -65,8 +65,8 @@ class AlbumNavigatorWidget extends WP_Widget {
65
  $widget_content .= $this->do_album_navigator( '-1', $page, $skip, '' );
66
  }
67
  elseif ( $parent == 'owner' ) {
68
- $widget_content .= $this->do_album_navigator( '0', $page, $skip, '', " AND ( `owner` = '--- public ---' OR `owner` = '".wppa_get_user()."' ) " );
69
- $widget_content .= $this->do_album_navigator( '-1', $page, $skip, '', " AND ( `owner` = '--- public ---' OR `owner` = '".wppa_get_user()."' ) " );
70
  }
71
  else {
72
  $widget_content .= $this->do_album_navigator( $parent, $page, $skip, '' );
@@ -146,7 +146,7 @@ class AlbumNavigatorWidget extends WP_Widget {
146
  false,
147
  false,
148
  );
149
- $albs = $wpdb->get_results( "SELECT `name`, `id` FROM $wpdb->wppa_albums ORDER BY `name`", ARRAY_A );
150
 
151
  if ( $albs ) foreach( $albs as $alb ) {
152
  $options[] = __( stripslashes( $alb['name'] ) );
@@ -199,7 +199,7 @@ class AlbumNavigatorWidget extends WP_Widget {
199
  $p = $parent;
200
  $result = '';
201
 
202
- $albums = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `a_parent` = %s ".$extraclause.wppa_get_album_order( max( '0', $parent ) ), $parent ), ARRAY_A );
203
 
204
  if ( ! empty( $albums ) ) {
205
  wppa_cache_album( 'add', $albums );
3
  * Package: wp-photo-album-plus
4
  *
5
  * display album names linking to content
6
+ * Version 6.9.21
7
  */
8
 
9
  class AlbumNavigatorWidget extends WP_Widget {
65
  $widget_content .= $this->do_album_navigator( '-1', $page, $skip, '' );
66
  }
67
  elseif ( $parent == 'owner' ) {
68
+ $widget_content .= $this->do_album_navigator( '0', $page, $skip, '', " AND ( owner = '--- public ---' OR owner = '".wppa_get_user()."' ) " );
69
+ $widget_content .= $this->do_album_navigator( '-1', $page, $skip, '', " AND ( owner = '--- public ---' OR owner = '".wppa_get_user()."' ) " );
70
  }
71
  else {
72
  $widget_content .= $this->do_album_navigator( $parent, $page, $skip, '' );
146
  false,
147
  false,
148
  );
149
+ $albs = $wpdb->get_results( "SELECT name, id FROM $wpdb->wppa_albums ORDER BY name", ARRAY_A );
150
 
151
  if ( $albs ) foreach( $albs as $alb ) {
152
  $options[] = __( stripslashes( $alb['name'] ) );
199
  $p = $parent;
200
  $result = '';
201
 
202
+ $albums = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE a_parent = %s ".$extraclause.wppa_get_album_order( max( '0', $parent ) ), $parent ), ARRAY_A );
203
 
204
  if ( ! empty( $albums ) ) {
205
  wppa_cache_album( 'add', $albums );
wppa-album-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * display thumbnail albums
6
- * Version 6.9.20
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
@@ -88,7 +88,7 @@ class AlbumWidget extends WP_Widget {
88
 
89
  $imageid = wppa_get_coverphoto_id( $album['id'] );
90
  $image = $imageid ? wppa_cache_thumb( $imageid ) : false;
91
- $imgcount = $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM '.WPPA_PHOTOS.' WHERE `album` = %s', $album['id'] ) );
92
  $subalbumcount = wppa_has_children( $album['id'] );
93
  $thumb = $image;
94
 
@@ -172,7 +172,7 @@ class AlbumWidget extends WP_Widget {
172
  $widget_content .= "\n\t".'</a>';
173
  }
174
  elseif ( $link['is_lightbox'] ) {
175
- $thumbs = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->wppa_photos WHERE `album` = %s ".wppa_get_photo_order($album['id']), $album['id']), 'ARRAY_A');
176
  if ( $thumbs ) foreach ( $thumbs as $thumb ) {
177
  $title = wppa_get_lbtitle('alw', $thumb['id']);
178
  if ( wppa_is_video( $thumb['id'] ) ) {
@@ -360,7 +360,7 @@ class AlbumWidget extends WP_Widget {
360
  wppa_widget_input( $this, 'title', $instance['title'], __( 'Title', 'wp-photo-album-plus' ) );
361
 
362
  // Parent album selection
363
- $albs = $wpdb->get_results( "SELECT `id`, `name` FROM $wpdb->wppa_albums ORDER BY `name`", ARRAY_A );
364
 
365
  $options = array(
366
  __( '--- all albums ---', 'wp-photo-album-plus' ),
3
  * Package: wp-photo-album-plus
4
  *
5
  * display thumbnail albums
6
+ * Version 6.9.21
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
88
 
89
  $imageid = wppa_get_coverphoto_id( $album['id'] );
90
  $image = $imageid ? wppa_cache_thumb( $imageid ) : false;
91
+ $imgcount = $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM '.WPPA_PHOTOS.' WHERE album = %s', $album['id'] ) );
92
  $subalbumcount = wppa_has_children( $album['id'] );
93
  $thumb = $image;
94
 
172
  $widget_content .= "\n\t".'</a>';
173
  }
174
  elseif ( $link['is_lightbox'] ) {
175
+ $thumbs = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->wppa_photos WHERE album = %s ".wppa_get_photo_order($album['id']), $album['id']), 'ARRAY_A');
176
  if ( $thumbs ) foreach ( $thumbs as $thumb ) {
177
  $title = wppa_get_lbtitle('alw', $thumb['id']);
178
  if ( wppa_is_video( $thumb['id'] ) ) {
360
  wppa_widget_input( $this, 'title', $instance['title'], __( 'Title', 'wp-photo-album-plus' ) );
361
 
362
  // Parent album selection
363
+ $albs = $wpdb->get_results( "SELECT id, name FROM $wpdb->wppa_albums ORDER BY name", ARRAY_A );
364
 
365
  $options = array(
366
  __( '--- all albums ---', 'wp-photo-album-plus' ),
wppa-boxes-html.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various wppa boxes
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -187,7 +187,7 @@ global $wppa_session;
187
  }
188
  }
189
 
190
- wppa_dbg_msg( 'Root=' . $root . ': ' . ( $root > '0' ? wppa_get_album_name( $root ) : '' ) );
191
 
192
  // Open the form
193
  $result =
@@ -495,9 +495,9 @@ global $wppa_supported_camara_brands;
495
  if ( ! empty( $exiflist ) ) {
496
  foreach( array_keys( $exiflist ) as $idx ) {
497
  // $exists = $wpdb->get_var( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_exif " .
498
- // "WHERE `photo` <> '0' " .
499
- // "AND `tag` = %s " .
500
- // "AND `description` <> '' LIMIT 1", $exiflist[$idx]['tag'] ) );
501
  // if ( ! $exists ) {
502
  // unset( $exiflist[$idx] );
503
  // }
@@ -1830,16 +1830,16 @@ global $wppa_locale;
1830
  global $wpdb;
1831
 
1832
  // The page/post id
1833
- $p = get_the_ID();
1834
 
1835
  // The share url
1836
  $share_url = wppa_convert_to_pretty( get_permalink( $p ) );
1837
 
1838
  // The share title
1839
- $share_name = $wpdb->get_var( "SELECT `post_title` FROM `" . $wpdb->prefix . 'posts' . "` WHERE `ID` = " . $p );
1840
 
1841
  // The share description
1842
- $share_desc = $wpdb->get_var( "SELECT `post_content` FROM `" . $wpdb->prefix . 'posts' . "` WHERE `ID` = " . $p );
1843
  $share_desc = strip_tags( strip_shortcodes( $share_desc ) );
1844
  if ( strlen( $share_desc ) > 150 ) {
1845
  $share_desc = substr( $share_desc, 0, 120 ) . '...';
@@ -2405,7 +2405,7 @@ static $albums_granted;
2405
  elseif ( ! is_user_logged_in() ) {
2406
  $public_exist = $wpdb->get_var( "SELECT COUNT(*) " .
2407
  "FROM $wpdb->wppa_albums " .
2408
- "WHERE `owner` = '--- public ---' " );
2409
 
2410
  if ( ! $public_exist ) {
2411
  return '';
@@ -3559,7 +3559,7 @@ global $wpdb;
3559
 
3560
  // Still no user, try to find him by display name
3561
  if ( ! $usr ) {
3562
- $usr = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE `display_name` = %s", $comment['user'] ) );
3563
 
3564
  // Accept this user if he is the only one with this display name
3565
  if ( count( $usr ) != 1 ) {
@@ -3584,7 +3584,8 @@ global $wpdb;
3584
  <img' .
3585
  ' class="wppa-box-text wppa-td"' .
3586
  ' src="http' . ( is_ssl() ? 's' : '' ) . '://www.gravatar.com/avatar/' .
3587
- md5( strtolower( trim( $comment['email'] ) ) ) .
 
3588
  '.jpg?d='.urlencode( $default ) . '&s=' . wppa_opt( 'gravatar_size' ) . '"' .
3589
  ' alt="' . __( 'Avatar', 'wp-photo-album-plus' ) . '"' .
3590
  ' />';
@@ -3898,7 +3899,7 @@ global $wppa_iptc_cache;
3898
 
3899
  // Get tha labels if not yet present
3900
  if ( ! is_array( $wppa_iptc_labels ) ) {
3901
- $wppa_iptc_labels = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_iptc WHERE `photo` = '0' ORDER BY `tag`", ARRAY_A );
3902
  }
3903
 
3904
  $count = 0;
@@ -3913,7 +3914,7 @@ global $wppa_iptc_cache;
3913
 
3914
  // Get the photo data
3915
  if ( $iptcdata === false ) {
3916
- $iptcdata = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_iptc WHERE `photo`=%s ORDER BY `tag`", $photo ), ARRAY_A );
3917
 
3918
  // Save in cache, even when empty
3919
  $wppa_iptc_cache[$photo] = $iptcdata;
@@ -4011,7 +4012,7 @@ global $wppa_exif_cache;
4011
 
4012
  // Get tha labels if not yet present
4013
  if ( ! is_array( $wppa_exif_labels ) ) {
4014
- $wppa_exif_labels = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_exif WHERE `photo` = '0' ORDER BY `tag`", ARRAY_A );
4015
  }
4016
 
4017
  $count = 0;
@@ -4213,10 +4214,10 @@ global $wpdb;
4213
  $photo = wppa( 'single_photo' );
4214
  $thumb = wppa_cache_thumb( $photo );
4215
  $album = $thumb['album'];
4216
- $photos = $wpdb->get_results( $wpdb->prepare( "SELECT `id`, `page_id` FROM $wpdb->wppa_photos WHERE `album` = %s ".wppa_get_photo_order( $album ), $album ), ARRAY_A );
4217
  $prevpag = '0';
4218
  $nextpag = '0';
4219
- $curpag = get_the_ID();
4220
  $count = count( $photos );
4221
  $count_ = $count - 1;
4222
  $current = '0';
@@ -4595,7 +4596,7 @@ global $wpdb;
4595
  $calendar_type = wppa( 'calendar' );
4596
  $autoall = wppa( 'calendarall' );
4597
  $albums = wppa( 'start_album' ) ? wppa_expand_enum( wppa_alb_to_enum_children( wppa( 'start_album' ) ) ) : '';
4598
- $alb_clause = $albums ? ' AND `album` IN ( ' . str_replace( '.', ',' , $albums ) . ' ) ' : '';
4599
  $alb_arg = wppa( 'start_album' ) ? 'wppa-album=' . wppa_alb_to_enum_children( wppa( 'start_album' ) ) . '&' : '';
4600
  $reverse = wppa( 'reverse' ) ? ' DESC ' : '';
4601
  $from = 0;
@@ -4606,13 +4607,13 @@ global $wpdb;
4606
 
4607
  switch ( $calendar_type ) {
4608
  case 'exifdtm':
4609
- $photos = $wpdb->get_results( "SELECT `id`, `exifdtm` " .
4610
  "FROM $wpdb->wppa_photos " .
4611
- "WHERE `exifdtm` <> '' " .
4612
- "AND `status` <> 'pending' " .
4613
- "AND `status` <> 'scheduled' " .
4614
  $alb_clause .
4615
- "ORDER BY `exifdtm`" . $reverse, ARRAY_A );
4616
  $dates = array();
4617
  foreach ( $photos as $photo ) {
4618
  $date = substr( $photo['exifdtm'], 0, 10 );
@@ -4631,13 +4632,13 @@ global $wpdb;
4631
 
4632
  case 'timestamp':
4633
  case 'modified':
4634
- $photos = $wpdb->get_results( "SELECT `id`, `" . $calendar_type . "` " .
4635
  "FROM $wpdb->wppa_photos " .
4636
- "WHERE `" . $calendar_type . "` > 0 " .
4637
- "AND `status` <> 'pending' " .
4638
- "AND `status` <> 'scheduled' " .
4639
  $alb_clause .
4640
- "ORDER BY `" . $calendar_type . "`" . $reverse, ARRAY_A );
4641
  $dates = array();
4642
  foreach ( $photos as $photo ) {
4643
  $date = floor( $photo[$calendar_type] / $secinday );
@@ -4966,7 +4967,7 @@ global $wppa_lang;
4966
  if ( wppa_get_get( 'page_id' ) ) {
4967
  $al .= '&page_id=' . wppa_get_get( 'page_id' );
4968
  }
4969
- $al .= '&wppa-fromp=' . get_the_ID();
4970
 
4971
  if ( wppa_get_get( 'lang' ) ) { // If lang in querystring: keep it
4972
  if ( strpos( $al, 'lang=' ) === false ) { // Not yet
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various wppa boxes
6
+ * Version 6.9.21
7
  *
8
  */
9
 
187
  }
188
  }
189
 
190
+ wppa_dbg_msg( 'Root=' . $root . ': ' . ( wppa_is_int( $root ) ? wppa_get_album_name( $root ) : $root ) );
191
 
192
  // Open the form
193
  $result =
495
  if ( ! empty( $exiflist ) ) {
496
  foreach( array_keys( $exiflist ) as $idx ) {
497
  // $exists = $wpdb->get_var( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_exif " .
498
+ // "WHERE photo <> '0' " .
499
+ // "AND tag = %s " .
500
+ // "AND description <> '' LIMIT 1", $exiflist[$idx]['tag'] ) );
501
  // if ( ! $exists ) {
502
  // unset( $exiflist[$idx] );
503
  // }
1830
  global $wpdb;
1831
 
1832
  // The page/post id
1833
+ $p = wppa_get_the_ID();
1834
 
1835
  // The share url
1836
  $share_url = wppa_convert_to_pretty( get_permalink( $p ) );
1837
 
1838
  // The share title
1839
+ $share_name = $wpdb->get_var( "SELECT post_title FROM " . $wpdb->prefix . 'posts' . " WHERE ID = " . $p );
1840
 
1841
  // The share description
1842
+ $share_desc = $wpdb->get_var( "SELECT post_content FROM " . $wpdb->prefix . 'posts' . " WHERE ID = " . $p );
1843
  $share_desc = strip_tags( strip_shortcodes( $share_desc ) );
1844
  if ( strlen( $share_desc ) > 150 ) {
1845
  $share_desc = substr( $share_desc, 0, 120 ) . '...';
2405
  elseif ( ! is_user_logged_in() ) {
2406
  $public_exist = $wpdb->get_var( "SELECT COUNT(*) " .
2407
  "FROM $wpdb->wppa_albums " .
2408
+ "WHERE owner = '--- public ---' " );
2409
 
2410
  if ( ! $public_exist ) {
2411
  return '';
3559
 
3560
  // Still no user, try to find him by display name
3561
  if ( ! $usr ) {
3562
+ $usr = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE display_name = %s", $comment['user'] ) );
3563
 
3564
  // Accept this user if he is the only one with this display name
3565
  if ( count( $usr ) != 1 ) {
3584
  <img' .
3585
  ' class="wppa-box-text wppa-td"' .
3586
  ' src="http' . ( is_ssl() ? 's' : '' ) . '://www.gravatar.com/avatar/' .
3587
+ wppa_get_unique_crypt() .
3588
+ // md5( strtolower( trim( $comment['email'] ) ) ) .
3589
  '.jpg?d='.urlencode( $default ) . '&s=' . wppa_opt( 'gravatar_size' ) . '"' .
3590
  ' alt="' . __( 'Avatar', 'wp-photo-album-plus' ) . '"' .
3591
  ' />';
3899
 
3900
  // Get tha labels if not yet present
3901
  if ( ! is_array( $wppa_iptc_labels ) ) {
3902
+ $wppa_iptc_labels = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_iptc WHERE photo = '0' ORDER BY tag", ARRAY_A );
3903
  }
3904
 
3905
  $count = 0;
3914
 
3915
  // Get the photo data
3916
  if ( $iptcdata === false ) {
3917
+ $iptcdata = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_iptc WHERE photo=%s ORDER BY tag", $photo ), ARRAY_A );
3918
 
3919
  // Save in cache, even when empty
3920
  $wppa_iptc_cache[$photo] = $iptcdata;
4012
 
4013
  // Get tha labels if not yet present
4014
  if ( ! is_array( $wppa_exif_labels ) ) {
4015
+ $wppa_exif_labels = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_exif WHERE photo = '0' ORDER BY tag", ARRAY_A );
4016
  }
4017
 
4018
  $count = 0;
4214
  $photo = wppa( 'single_photo' );
4215
  $thumb = wppa_cache_thumb( $photo );
4216
  $album = $thumb['album'];
4217
+ $photos = $wpdb->get_results( $wpdb->prepare( "SELECT id, page_id FROM $wpdb->wppa_photos WHERE album = %s ".wppa_get_photo_order( $album ), $album ), ARRAY_A );
4218
  $prevpag = '0';
4219
  $nextpag = '0';
4220
+ $curpag = wppa_get_the_ID();
4221
  $count = count( $photos );
4222
  $count_ = $count - 1;
4223
  $current = '0';
4596
  $calendar_type = wppa( 'calendar' );
4597
  $autoall = wppa( 'calendarall' );
4598
  $albums = wppa( 'start_album' ) ? wppa_expand_enum( wppa_alb_to_enum_children( wppa( 'start_album' ) ) ) : '';
4599
+ $alb_clause = $albums ? ' AND album IN ( ' . str_replace( '.', ',' , $albums ) . ' ) ' : '';
4600
  $alb_arg = wppa( 'start_album' ) ? 'wppa-album=' . wppa_alb_to_enum_children( wppa( 'start_album' ) ) . '&' : '';
4601
  $reverse = wppa( 'reverse' ) ? ' DESC ' : '';
4602
  $from = 0;
4607
 
4608
  switch ( $calendar_type ) {
4609
  case 'exifdtm':
4610
+ $photos = $wpdb->get_results( "SELECT id, exifdtm " .
4611
  "FROM $wpdb->wppa_photos " .
4612
+ "WHERE exifdtm <> '' " .
4613
+ "AND status <> 'pending' " .
4614
+ "AND status <> 'scheduled' " .
4615
  $alb_clause .
4616
+ "ORDER BY exifdtm" . $reverse, ARRAY_A );
4617
  $dates = array();
4618
  foreach ( $photos as $photo ) {
4619
  $date = substr( $photo['exifdtm'], 0, 10 );
4632
 
4633
  case 'timestamp':
4634
  case 'modified':
4635
+ $photos = $wpdb->get_results( "SELECT id, " . $calendar_type . " " .
4636
  "FROM $wpdb->wppa_photos " .
4637
+ "WHERE " . $calendar_type . " > 0 " .
4638
+ "AND status <> 'pending' " .
4639
+ "AND status <> 'scheduled' " .
4640
  $alb_clause .
4641
+ "ORDER BY " . $calendar_type . "" . $reverse, ARRAY_A );
4642
  $dates = array();
4643
  foreach ( $photos as $photo ) {
4644
  $date = floor( $photo[$calendar_type] / $secinday );
4967
  if ( wppa_get_get( 'page_id' ) ) {
4968
  $al .= '&page_id=' . wppa_get_get( 'page_id' );
4969
  }
4970
+ $al .= '&wppa-fromp=' . wppa_get_the_ID();
4971
 
4972
  if ( wppa_get_get( 'lang' ) ) { // If lang in querystring: keep it
4973
  if ( strpos( $al, 'lang=' ) === false ) { // Not yet
wppa-breadcrumb.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for breadcrumbs
6
- * Version 6.9.14
7
  *
8
  */
9
 
@@ -17,9 +17,9 @@ global $wppa_session;
17
  // See if they need us
18
  // Check Table II-A1 a and b
19
  if ( $opt == 'optional' ) {
20
- $pid = wppa_get_the_page_id();
21
  $type = $wpdb->get_var( $wpdb->prepare(
22
- "SELECT `post_type` FROM `" . $wpdb->posts . "` WHERE `ID` = %s", $pid
23
  ) );
24
  if ( $type == 'post' && ! wppa_switch( 'show_bread_posts' ) ) {
25
  return; // Nothing to do here
@@ -109,8 +109,8 @@ global $wppa_session;
109
  // Do the post/page
110
  if ( wppa_switch( 'show_page' ) ) {
111
  $value = __( stripslashes( $wpdb->get_var( $wpdb->prepare(
112
- "SELECT `post_title` FROM `".$wpdb->posts.
113
- "` WHERE `post_status` = 'publish' AND `ID` = %s LIMIT 0,1", $pid
114
  ) ) ) );
115
 
116
  if ( $alb || $virtual || $is_albenum ) {
@@ -192,7 +192,7 @@ global $wppa_session;
192
  $value .= ' ' . __('of owner:', 'wp-photo-album-plus') . ' <b>' . $ss_data['3'] . '</b>';
193
  break;
194
  case 'i':
195
- $label = $wpdb->get_var( $wpdb->prepare( "SELECT `description` FROM $wpdb->wppa_iptc WHERE `tag` = %s AND `photo` = '0'", str_replace( 'H', '#', $ss_data['2'] ) ) );
196
  $label = trim( $label, ':' );
197
  $value .= ' ' . __('with iptc tag:', 'wp-photo-album-plus') . ' <b>' . __($label, 'wp-photo-album-plus') . '</b> ' . __('with content:', 'wp-photo-album-plus') .' <b>' . $ss_data['3'] . '</b>';
198
  break;
@@ -690,7 +690,7 @@ global $wpdb;
690
  }
691
 
692
  $pagid = $wpdb->get_var( $wpdb->prepare(
693
- "SELECT `cover_linkpage` FROM $wpdb->wppa_albums WHERE `id` = %s", $parent
694
  ) );
695
 
696
  $value = wppa_get_album_name( $parent );
@@ -733,17 +733,6 @@ global $wpdb;
733
  }
734
  }
735
 
736
- // Get the page id, returns the page id we are working for, even when Ajax
737
- function wppa_get_the_page_id() {
738
- $page = @ get_the_ID();
739
- if ( ! $page ) {
740
- if ( isset( $_REQUEST['page_id'] ) ) $page = $_REQUEST['page_id'];
741
- elseif ( isset( $_REQUEST['wppa-fromp'] ) ) $page = $_REQUEST['wppa-fromp'];
742
- else $page = '0';
743
- }
744
- return $page;
745
- }
746
-
747
  // Convert display searchstring into readable format for use in title tooltip
748
  // Reurns value only if intersection or unioun symbols are in the input text
749
  function wppa_dss_to_title( $txt ) {
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for breadcrumbs
6
+ * Version 6.9.21
7
  *
8
  */
9
 
17
  // See if they need us
18
  // Check Table II-A1 a and b
19
  if ( $opt == 'optional' ) {
20
+ $pid = wppa_get_the_ID();
21
  $type = $wpdb->get_var( $wpdb->prepare(
22
+ "SELECT post_type FROM " . $wpdb->posts . " WHERE ID = %s", $pid
23
  ) );
24
  if ( $type == 'post' && ! wppa_switch( 'show_bread_posts' ) ) {
25
  return; // Nothing to do here
109
  // Do the post/page
110
  if ( wppa_switch( 'show_page' ) ) {
111
  $value = __( stripslashes( $wpdb->get_var( $wpdb->prepare(
112
+ "SELECT post_title FROM ".$wpdb->posts.
113
+ " WHERE post_status = 'publish' AND ID = %s LIMIT 0,1", $pid
114
  ) ) ) );
115
 
116
  if ( $alb || $virtual || $is_albenum ) {
192
  $value .= ' ' . __('of owner:', 'wp-photo-album-plus') . ' <b>' . $ss_data['3'] . '</b>';
193
  break;
194
  case 'i':
195
+ $label = $wpdb->get_var( $wpdb->prepare( "SELECT description FROM $wpdb->wppa_iptc WHERE tag = %s AND photo = '0'", str_replace( 'H', '#', $ss_data['2'] ) ) );
196
  $label = trim( $label, ':' );
197
  $value .= ' ' . __('with iptc tag:', 'wp-photo-album-plus') . ' <b>' . __($label, 'wp-photo-album-plus') . '</b> ' . __('with content:', 'wp-photo-album-plus') .' <b>' . $ss_data['3'] . '</b>';
198
  break;
690
  }
691
 
692
  $pagid = $wpdb->get_var( $wpdb->prepare(
693
+ "SELECT cover_linkpage FROM $wpdb->wppa_albums WHERE id = %s", $parent
694
  ) );
695
 
696
  $value = wppa_get_album_name( $parent );
733
  }
734
  }
735
 
 
 
 
 
 
 
 
 
 
 
 
736
  // Convert display searchstring into readable format for use in title tooltip
737
  // Reurns value only if intersection or unioun symbols are in the input text
738
  function wppa_dss_to_title( $txt ) {
wppa-comment-admin.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all comments
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -228,7 +228,7 @@ class WPPA_Comment_table extends WP_List_Table {
228
  // Delete
229
  if ( 'delete' === $current_action || 'deletesingle' === $current_action ) {
230
  foreach( $ids as $id ) {
231
- $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_comments WHERE `id` = %s", $id ) );
232
  }
233
  }
234
 
@@ -236,11 +236,11 @@ class WPPA_Comment_table extends WP_List_Table {
236
  if ( 'approve' === $current_action || 'approvesingle' === $current_action ) {
237
  foreach( $ids as $id ) {
238
 
239
- $iret = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_comments SET `status` = 'approved' WHERE `id` = %s", $id ) );
240
 
241
  if ( $iret ) {
242
  wppa_send_comment_approved_email( $id );
243
- $photo = $wpdb->get_var( $wpdb->prepare( "SELECT `photo` FROM $wpdb->wppa_comments WHERE `id` = %s", $id ) );
244
  wppa_add_credit_points( wppa_opt( 'cp_points_comment_appr' ), __( 'Photo comment approved' , 'wp-photo-album-plus'), $photo, '', wppa_get_photo_item( $photo, 'owner' ) );
245
  }
246
  }
@@ -249,14 +249,14 @@ class WPPA_Comment_table extends WP_List_Table {
249
  // Spam
250
  if ( 'spam' === $current_action || 'spamsingle' === $current_action ) {
251
  foreach( $ids as $id ) {
252
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_comments SET `status` = 'spam' WHERE `id` = %s", $id ) );
253
  }
254
  }
255
 
256
  // Pending
257
  if ( 'pending' === $current_action || 'pendingsingle' === $current_action ) {
258
  foreach( $ids as $id ) {
259
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_comments SET `status` = 'pending' WHERE `id` = %s", $id ) );
260
  }
261
  }
262
 
@@ -264,13 +264,13 @@ class WPPA_Comment_table extends WP_List_Table {
264
  if ( 'editsingle' === $current_action ) {
265
  $commenttext = $_GET['commenttext'];
266
  $id = $_GET['comment'];
267
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_comments SET `comment` = %s WHERE `id` = %s", $commenttext, $id ) );
268
  }
269
 
270
  // Update index in the near future
271
  if ( wppa_switch( 'search_comments' ) ) {
272
  foreach( $ids as $id ) {
273
- $photo = $wpdb->get_var( $wpdb->prepare( "SELECT `photo` FROM $wpdb->wppa_comments WHERE `id` = %s", $id ) );
274
  wppa_index_update( 'photo', $photo );
275
  }
276
  }
@@ -293,7 +293,7 @@ class WPPA_Comment_table extends WP_List_Table {
293
  // Moderate single only?
294
  $moderating = isset( $_REQUEST['commentid'] );
295
  if ( $moderating ) {
296
- $filter = "WHERE `id` = " . strval( intval( $_REQUEST['commentid'] ) );
297
  }
298
 
299
  // Normal use
@@ -303,19 +303,19 @@ class WPPA_Comment_table extends WP_List_Table {
303
  case 'all':
304
  break;
305
  case 'spam':
306
- $filter = "WHERE `status` = 'spam'";
307
  break;
308
  case 'pending':
309
- $filter = "WHERE `status` = 'pending'";
310
  break;
311
  case 'approved':
312
- $filter = "WHERE `status` = 'approved'";
313
  break;
314
  }
315
  }
316
  }
317
 
318
- $data = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_comments " . $filter . " ORDER BY `timestamp` DESC", ARRAY_A );
319
 
320
  function usort_reorder( $a, $b ) {
321
  $orderby = ( ! empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'timestamp'; //If no sort, default to title
@@ -408,17 +408,17 @@ function _wppa_comment_admin() {
408
  </tr>
409
  <tr>
410
  <td style="margin:0; font-weight:bold; color:green;">' . __( 'Approved:', 'wp-photo-album-plus' ) . '</td>
411
- <td style="margin:0; font-weight:bold;">' . $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_comments WHERE `status` = 'approved'" ) . '</td>
412
  <td></td>
413
  </tr>
414
  <tr>
415
  <td style="margin:0; font-weight:bold; color:#e66f00;">' . __( 'Pending:', 'wp-photo-album-plus' ) . '</td>
416
- <td style="margin:0; font-weight:bold;">' . $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_comments WHERE `status` = 'pending'" ) . '</td>
417
  <td></td>
418
  </tr>
419
  <tr>
420
  <td style="margin:0; font-weight:bold; color:red;">' . __( 'Spam:', 'wp-photo-album-plus' ) . '</td>
421
- <td style="margin:0; font-weight:bold;">' . $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_comments WHERE `status` = 'spam'" ) . '</td>
422
  <td></td>
423
  </tr>';
424
  if ( $spamtime ) {
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all comments
6
+ * Version 6.9.21
7
  *
8
  */
9
 
228
  // Delete
229
  if ( 'delete' === $current_action || 'deletesingle' === $current_action ) {
230
  foreach( $ids as $id ) {
231
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_comments WHERE id = %s", $id ) );
232
  }
233
  }
234
 
236
  if ( 'approve' === $current_action || 'approvesingle' === $current_action ) {
237
  foreach( $ids as $id ) {
238
 
239
+ $iret = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_comments SET status = 'approved' WHERE id = %s", $id ) );
240
 
241
  if ( $iret ) {
242
  wppa_send_comment_approved_email( $id );
243
+ $photo = $wpdb->get_var( $wpdb->prepare( "SELECT photo FROM $wpdb->wppa_comments WHERE id = %s", $id ) );
244
  wppa_add_credit_points( wppa_opt( 'cp_points_comment_appr' ), __( 'Photo comment approved' , 'wp-photo-album-plus'), $photo, '', wppa_get_photo_item( $photo, 'owner' ) );
245
  }
246
  }
249
  // Spam
250
  if ( 'spam' === $current_action || 'spamsingle' === $current_action ) {
251
  foreach( $ids as $id ) {
252
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_comments SET status = 'spam' WHERE id = %s", $id ) );
253
  }
254
  }
255
 
256
  // Pending
257
  if ( 'pending' === $current_action || 'pendingsingle' === $current_action ) {
258
  foreach( $ids as $id ) {
259
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_comments SET status = 'pending' WHERE id = %s", $id ) );
260
  }
261
  }
262
 
264
  if ( 'editsingle' === $current_action ) {
265
  $commenttext = $_GET['commenttext'];
266
  $id = $_GET['comment'];
267
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_comments SET comment = %s WHERE id = %s", $commenttext, $id ) );
268
  }
269
 
270
  // Update index in the near future
271
  if ( wppa_switch( 'search_comments' ) ) {
272
  foreach( $ids as $id ) {
273
+ $photo = $wpdb->get_var( $wpdb->prepare( "SELECT photo FROM $wpdb->wppa_comments WHERE id = %s", $id ) );
274
  wppa_index_update( 'photo', $photo );
275
  }
276
  }
293
  // Moderate single only?
294
  $moderating = isset( $_REQUEST['commentid'] );
295
  if ( $moderating ) {
296
+ $filter = "WHERE id = " . strval( intval( $_REQUEST['commentid'] ) );
297
  }
298
 
299
  // Normal use
303
  case 'all':
304
  break;
305
  case 'spam':
306
+ $filter = "WHERE status = 'spam'";
307
  break;
308
  case 'pending':
309
+ $filter = "WHERE status = 'pending'";
310
  break;
311
  case 'approved':
312
+ $filter = "WHERE status = 'approved'";
313
  break;
314
  }
315
  }
316
  }
317
 
318
+ $data = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_comments " . $filter . " ORDER BY timestamp DESC", ARRAY_A );
319
 
320
  function usort_reorder( $a, $b ) {
321
  $orderby = ( ! empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'timestamp'; //If no sort, default to title
408
  </tr>
409
  <tr>
410
  <td style="margin:0; font-weight:bold; color:green;">' . __( 'Approved:', 'wp-photo-album-plus' ) . '</td>
411
+ <td style="margin:0; font-weight:bold;">' . $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_comments WHERE status = 'approved'" ) . '</td>
412
  <td></td>
413
  </tr>
414
  <tr>
415
  <td style="margin:0; font-weight:bold; color:#e66f00;">' . __( 'Pending:', 'wp-photo-album-plus' ) . '</td>
416
+ <td style="margin:0; font-weight:bold;">' . $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_comments WHERE status = 'pending'" ) . '</td>
417
  <td></td>
418
  </tr>
419
  <tr>
420
  <td style="margin:0; font-weight:bold; color:red;">' . __( 'Spam:', 'wp-photo-album-plus' ) . '</td>
421
+ <td style="margin:0; font-weight:bold;">' . $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_comments WHERE status = 'spam'" ) . '</td>
422
  <td></td>
423
  </tr>';
424
  if ( $spamtime ) {
wppa-comment-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the recent commets on photos
6
- * Version 6.9.14
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
@@ -75,7 +75,7 @@ class wppaCommentWidget extends WP_Widget {
75
  $imgevents = wppa_get_imgevents( 'thumb', $id, true );
76
 
77
  $title = '';
78
- $comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_comments WHERE `photo` = %s AND `status` = 'approved' ORDER BY `timestamp` DESC", $id ), ARRAY_A );
79
  if ( $comments ) {
80
  $first_comment = $comments['0'];
81
  foreach ( $comments as $comment ) {
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the recent commets on photos
6
+ * Version 6.9.21
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
75
  $imgevents = wppa_get_imgevents( 'thumb', $id, true );
76
 
77
  $title = '';
78
+ $comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_comments WHERE photo = %s AND status = 'approved' ORDER BY timestamp DESC", $id ), ARRAY_A );
79
  if ( $comments ) {
80
  $first_comment = $comments['0'];
81
  foreach ( $comments as $comment ) {
wppa-common-functions.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-common-functions.php
3
  *
4
  * Functions used in admin and in themes
5
- * Version 6.9.19
6
  *
7
  */
8
 
@@ -222,6 +222,7 @@ global $thumbs;
222
  'cron' => $cron,
223
  'has_panorama' => $pano,
224
  'unsanitized_filename' => '',
 
225
 
226
  );
227
  }
@@ -683,7 +684,7 @@ global $wpdb;
683
  if ( $name == '' ) return '';
684
  $name = stripslashes( $name );
685
 
686
- $albs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `name` = %s", $name ), ARRAY_A );
687
 
688
  if ( empty( $albs ) ) {
689
  return '';
@@ -725,9 +726,9 @@ function wppa_dbg_msg( $txt = '', $color = 'blue', $force = false, $return = fal
725
 
726
  if ( wppa( 'debug' ) || $force || ( is_admin() && WPPA_DEBUG ) || ( WPPA_DEBUG && $color == 'red' ) ) {
727
 
728
- $result = '<span style="color:' . $color . ';" >' .
729
  '<small>' .
730
- '[WPPA+ dbg msg: ' . $txt . ']' .
731
  '<br />' .
732
  '</small>' .
733
  '</span>';
@@ -802,18 +803,18 @@ global $current_user;
802
 
803
  // Administrator has always access OR If all albums are public
804
  if ( wppa_user_is( 'administrator' ) || ! wppa_switch( 'owner_only' ) ) {
805
- $albs = $wpdb->get_results( "SELECT `id` FROM $wpdb->wppa_albums" );
806
  if ( $albs ) return true;
807
  else return false; // No albums in system
808
  }
809
 
810
  // Any --- public --- albums?
811
- $albs = $wpdb->get_results( "SELECT `id` FROM $wpdb->wppa_albums WHERE `owner` = '--- public ---'" );
812
 
813
  if ( $albs ) return true;
814
 
815
  // Any logged out created albums? ( owner = ip )
816
- $albs = $wpdb->get_results( "SELECT `owner` FROM $wpdb->wppa_albums", ARRAY_A );
817
  if ( $albs ) foreach ( $albs as $a ) {
818
  if ( wppa_is_int( str_replace( '.', '', $a['owner'] ) ) ) return true;
819
  }
@@ -822,7 +823,7 @@ global $current_user;
822
  if ( is_user_logged_in() ) {
823
  $current_user = wp_get_current_user();
824
  $user = $current_user->user_login;
825
- $any_albs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE `owner` = %s", $user ) );
826
 
827
  if ( $any_albs ) return true;
828
  else return false; // No albums for user accessible
@@ -844,7 +845,7 @@ global $current_user;
844
  $owner = $alb['owner'];
845
  }
846
  elseif ( is_numeric( $alb ) ) {
847
- $owner = $wpdb->get_var( $wpdb->prepare( "SELECT `owner` FROM $wpdb->wppa_albums WHERE `id` = %s", $alb ) );
848
  }
849
 
850
  // -- public --- ?
@@ -1031,7 +1032,7 @@ static $tables;
1031
  if ( $tables === false ) return true;
1032
 
1033
  if ( empty( $tables ) ) {
1034
- $tables = $wpdb->get_results( "SHOW TABLES FROM `".DB_NAME."`", ARRAY_A );
1035
  }
1036
 
1037
  if ( empty( $tables ) ) {
@@ -1160,7 +1161,7 @@ static $result_cache;
1160
 
1161
  $album = wppa_cache_album( $alb );
1162
 
1163
- $limits = $album['upload_limit']; //$wpdb->get_var( $wpdb->prepare( "SELECT `upload_limit` FROM $wpdb->wppa_albums WHERE `id` = %s", $alb ) );
1164
 
1165
  $temp = explode( '/', $limits );
1166
  $limit_max = isset( $temp[0] ) ? $temp[0] : '0';
@@ -1169,12 +1170,12 @@ static $result_cache;
1169
  if ( ! $limit_max ) return '-1'; // Unlimited max
1170
 
1171
  if ( ! $limit_time ) { // For ever
1172
- $curcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `album` = %s", $alb ) );
1173
  }
1174
  else { // Time criterium in place
1175
  $timnow = time();
1176
  $timthen = $timnow - $limit_time;
1177
- $curcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `album` = %s AND `timestamp` > %s", $alb, $timthen ) );
1178
  }
1179
 
1180
  if ( $curcount >= $limit_max ) $result = '0'; // No more allowed
@@ -1211,7 +1212,7 @@ global $wpdb;
1211
 
1212
  // Make the album clause
1213
  if ( wppa_switch( 'role_limit_per_album' ) && $album ) {
1214
- $album_clause = sprintf( " AND `album` = %d", $album );
1215
  }
1216
  else {
1217
  $album_clause = "";
@@ -1222,12 +1223,12 @@ global $wpdb;
1222
 
1223
  // Get the currently uploaded photos
1224
  if ( ! $limit_time ) { // For ever
1225
- $curcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `owner` = %s" . $album_clause, $user ) );
1226
  }
1227
  else { // Time criterium in place
1228
  $timnow = time();
1229
  $timthen = $timnow - $limit_time;
1230
- $curcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `owner` = %s AND `timestamp` > %s" . $album_clause, $user, $timthen ) );
1231
  }
1232
 
1233
  // Compute the allowed number of photos
@@ -1719,10 +1720,10 @@ global $wpdb;
1719
  // $albums = $args['array'];
1720
  $albums = array();
1721
 
1722
- $temp = $wpdb->get_results( "SELECT `id`, `name` " .
1723
  "FROM $wpdb->wppa_albums " .
1724
- "WHERE `id` IN (" . implode( ',', $args['array'] ) . ") " .
1725
- ( $args['checkowner'] && wppa_switch( 'upload_owner_only' ) && ! wppa_user_is( 'administrator' ) ? "AND `owner` IN ( '--- public ---', '" . wppa_get_user() . "' ) " : "" ) .
1726
  wppa_get_album_order( $args['root'] ),
1727
  ARRAY_A
1728
  );
@@ -1737,9 +1738,9 @@ global $wpdb;
1737
  }
1738
  }
1739
  else {
1740
- $albums = $wpdb->get_results( "SELECT `id`, `name` " .
1741
  "FROM $wpdb->wppa_albums " .
1742
- ( $args['checkowner'] && wppa_switch( 'upload_owner_only' ) && ! wppa_user_is( 'administrator' ) ? "WHERE `owner` IN ( '--- public ---', '" . wppa_get_user() . "' ) " : "" ) .
1743
  wppa_get_album_order( $args['root'] ),
1744
  ARRAY_A
1745
  );
@@ -1958,7 +1959,7 @@ global $wpdb;
1958
  if ( $last_check < ( time() - 300 ) ) { // Longer than 5 mins ago
1959
 
1960
  // Publish scheduled photos
1961
- $to_publish = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `status` = 'scheduled' AND `scheduledtm` < %s", wppa_get_default_scheduledtm() ), ARRAY_A );
1962
  if ( $to_publish ) foreach( $to_publish as $photo ) {
1963
  wppa_update_photo( array( 'id' => $photo['id'], 'scheduledtm' => '', 'status' => 'publish', 'timestamp' => time() ) );
1964
  wppa_update_album( array( 'id' => $photo['album'], 'modified' => time() ) ); // For New indicator on album
@@ -1966,14 +1967,14 @@ global $wpdb;
1966
  }
1967
 
1968
  // Publish scheduled albums ( for future use, currently not implemented )
1969
- $to_publish = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `scheduledtm` <> '' AND `scheduledtm` < %s", wppa_get_default_scheduledtm() ), ARRAY_A );
1970
  if ( $to_publish ) foreach( $to_publish as $album ) {
1971
  wppa_update_album( array( 'id' => $album['id'], 'scheduledtm' => '' ) );
1972
  wppa_invalidate_treecounts( $album['id'] );
1973
  }
1974
 
1975
  // Delete photos scheduled for deletion
1976
- $to_delete = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `scheduledel` <> '' AND `scheduledel` < %s", wppa_get_default_scheduledtm() ), ARRAY_A );
1977
  if ( $to_delete ) foreach( $to_delete as $photo ) {
1978
  wppa_delete_photo( $photo['id'] );
1979
  }
2
  /* wppa-common-functions.php
3
  *
4
  * Functions used in admin and in themes
5
+ * Version 6.9.21
6
  *
7
  */
8
 
222
  'cron' => $cron,
223
  'has_panorama' => $pano,
224
  'unsanitized_filename' => '',
225
+ 'fromp' => '',
226
 
227
  );
228
  }
684
  if ( $name == '' ) return '';
685
  $name = stripslashes( $name );
686
 
687
+ $albs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE name = %s", $name ), ARRAY_A );
688
 
689
  if ( empty( $albs ) ) {
690
  return '';
726
 
727
  if ( wppa( 'debug' ) || $force || ( is_admin() && WPPA_DEBUG ) || ( WPPA_DEBUG && $color == 'red' ) ) {
728
 
729
+ $result = '<span style="color:' . sanitize_text_field( $color ) . ';" >' .
730
  '<small>' .
731
+ '[WPPA+ dbg msg: ' . sanitize_text_field( $txt ) . ']' .
732
  '<br />' .
733
  '</small>' .
734
  '</span>';
803
 
804
  // Administrator has always access OR If all albums are public
805
  if ( wppa_user_is( 'administrator' ) || ! wppa_switch( 'owner_only' ) ) {
806
+ $albs = $wpdb->get_results( "SELECT id FROM $wpdb->wppa_albums" );
807
  if ( $albs ) return true;
808
  else return false; // No albums in system
809
  }
810
 
811
  // Any --- public --- albums?
812
+ $albs = $wpdb->get_results( "SELECT id FROM $wpdb->wppa_albums WHERE owner = '--- public ---'" );
813
 
814
  if ( $albs ) return true;
815
 
816
  // Any logged out created albums? ( owner = ip )
817
+ $albs = $wpdb->get_results( "SELECT owner FROM $wpdb->wppa_albums", ARRAY_A );
818
  if ( $albs ) foreach ( $albs as $a ) {
819
  if ( wppa_is_int( str_replace( '.', '', $a['owner'] ) ) ) return true;
820
  }
823
  if ( is_user_logged_in() ) {
824
  $current_user = wp_get_current_user();
825
  $user = $current_user->user_login;
826
+ $any_albs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE owner = %s", $user ) );
827
 
828
  if ( $any_albs ) return true;
829
  else return false; // No albums for user accessible
845
  $owner = $alb['owner'];
846
  }
847
  elseif ( is_numeric( $alb ) ) {
848
+ $owner = $wpdb->get_var( $wpdb->prepare( "SELECT owner FROM $wpdb->wppa_albums WHERE id = %s", $alb ) );
849
  }
850
 
851
  // -- public --- ?
1032
  if ( $tables === false ) return true;
1033
 
1034
  if ( empty( $tables ) ) {
1035
+ $tables = $wpdb->get_results( "SHOW TABLES FROM ".DB_NAME."", ARRAY_A );
1036
  }
1037
 
1038
  if ( empty( $tables ) ) {
1161
 
1162
  $album = wppa_cache_album( $alb );
1163
 
1164
+ $limits = $album['upload_limit']; //$wpdb->get_var( $wpdb->prepare( "SELECT upload_limit FROM $wpdb->wppa_albums WHERE id = %s", $alb ) );
1165
 
1166
  $temp = explode( '/', $limits );
1167
  $limit_max = isset( $temp[0] ) ? $temp[0] : '0';
1170
  if ( ! $limit_max ) return '-1'; // Unlimited max
1171
 
1172
  if ( ! $limit_time ) { // For ever
1173
+ $curcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album = %s", $alb ) );
1174
  }
1175
  else { // Time criterium in place
1176
  $timnow = time();
1177
  $timthen = $timnow - $limit_time;
1178
+ $curcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album = %s AND timestamp > %s", $alb, $timthen ) );
1179
  }
1180
 
1181
  if ( $curcount >= $limit_max ) $result = '0'; // No more allowed
1212
 
1213
  // Make the album clause
1214
  if ( wppa_switch( 'role_limit_per_album' ) && $album ) {
1215
+ $album_clause = sprintf( " AND album = %d", $album );
1216
  }
1217
  else {
1218
  $album_clause = "";
1223
 
1224
  // Get the currently uploaded photos
1225
  if ( ! $limit_time ) { // For ever
1226
+ $curcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE owner = %s" . $album_clause, $user ) );
1227
  }
1228
  else { // Time criterium in place
1229
  $timnow = time();
1230
  $timthen = $timnow - $limit_time;
1231
+ $curcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE owner = %s AND timestamp > %s" . $album_clause, $user, $timthen ) );
1232
  }
1233
 
1234
  // Compute the allowed number of photos
1720
  // $albums = $args['array'];
1721
  $albums = array();
1722
 
1723
+ $temp = $wpdb->get_results( "SELECT id, name " .
1724
  "FROM $wpdb->wppa_albums " .
1725
+ "WHERE id IN (" . implode( ',', $args['array'] ) . ") " .
1726
+ ( $args['checkowner'] && wppa_switch( 'upload_owner_only' ) && ! wppa_user_is( 'administrator' ) ? "AND owner IN ( '--- public ---', '" . wppa_get_user() . "' ) " : "" ) .
1727
  wppa_get_album_order( $args['root'] ),
1728
  ARRAY_A
1729
  );
1738
  }
1739
  }
1740
  else {
1741
+ $albums = $wpdb->get_results( "SELECT id, name " .
1742
  "FROM $wpdb->wppa_albums " .
1743
+ ( $args['checkowner'] && wppa_switch( 'upload_owner_only' ) && ! wppa_user_is( 'administrator' ) ? "WHERE owner IN ( '--- public ---', '" . wppa_get_user() . "' ) " : "" ) .
1744
  wppa_get_album_order( $args['root'] ),
1745
  ARRAY_A
1746
  );
1959
  if ( $last_check < ( time() - 300 ) ) { // Longer than 5 mins ago
1960
 
1961
  // Publish scheduled photos
1962
+ $to_publish = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE status = 'scheduled' AND scheduledtm < %s", wppa_get_default_scheduledtm() ), ARRAY_A );
1963
  if ( $to_publish ) foreach( $to_publish as $photo ) {
1964
  wppa_update_photo( array( 'id' => $photo['id'], 'scheduledtm' => '', 'status' => 'publish', 'timestamp' => time() ) );
1965
  wppa_update_album( array( 'id' => $photo['album'], 'modified' => time() ) ); // For New indicator on album
1967
  }
1968
 
1969
  // Publish scheduled albums ( for future use, currently not implemented )
1970
+ $to_publish = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE scheduledtm <> '' AND scheduledtm < %s", wppa_get_default_scheduledtm() ), ARRAY_A );
1971
  if ( $to_publish ) foreach( $to_publish as $album ) {
1972
  wppa_update_album( array( 'id' => $album['id'], 'scheduledtm' => '' ) );
1973
  wppa_invalidate_treecounts( $album['id'] );
1974
  }
1975
 
1976
  // Delete photos scheduled for deletion
1977
+ $to_delete = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE scheduledel <> '' AND scheduledel < %s", wppa_get_default_scheduledtm() ), ARRAY_A );
1978
  if ( $to_delete ) foreach( $to_delete as $photo ) {
1979
  wppa_delete_photo( $photo['id'] );
1980
  }
wppa-cron.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all cron functions
6
- * Version 6.9.20
7
  *
8
  *
9
  */
@@ -184,8 +184,8 @@ global $wpdb;
184
  $savetime = 86400; // Save session data for 24 hour
185
  $expire = time() - $lifetime;
186
  $purge = time() - $savetime;
187
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_session SET `status` = 'expired' WHERE `timestamp` < %s", $expire ) );
188
- $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_session WHERE `timestamp` < %s", $purge ) );
189
 
190
  // Delete obsolete spam
191
  $spammaxage = wppa_opt( 'spam_maxage' );
@@ -200,13 +200,13 @@ global $wpdb;
200
  wppa_re_animate_cron();
201
 
202
  // Find lost photos, update their album to -9, meaning trashed
203
- $album_ids = $wpdb->get_col( "SELECT `id` FROM $wpdb->wppa_albums" );
204
  if ( ! empty( $album_ids ) ) {
205
- $lost = $wpdb->query( "UPDATE $wpdb->wppa_photos SET `album` = '-9' WHERE `album` > '0' AND `album` NOT IN ( " . implode( ',', $album_ids ) . " ) " );
206
  }
207
 
208
  // Remove 'deleted' photos from system
209
- $dels = $wpdb->get_col( "SELECT `id` FROM $wpdb->wppa_photos WHERE `album` <= '-9' AND `modified` < " . ( time() - 3600 ) );
210
  foreach( $dels as $del ) {
211
  wppa_delete_photo( $del );
212
  wppa_log( 'Cron', 'Removed photo {b}' . $del . '{/b} from system' );
@@ -387,7 +387,7 @@ global $wpdb;
387
 
388
  $start = time();
389
 
390
- $albs = $wpdb->get_col( "SELECT `id` FROM $wpdb->wppa_albums WHERE `a_parent` < '1' ORDER BY `id`" );
391
 
392
  foreach( $albs as $alb ) {
393
  $treecounts = wppa_get_treecounts_a( $alb );
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all cron functions
6
+ * Version 6.9.21
7
  *
8
  *
9
  */
184
  $savetime = 86400; // Save session data for 24 hour
185
  $expire = time() - $lifetime;
186
  $purge = time() - $savetime;
187
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_session SET status = 'expired' WHERE timestamp < %s", $expire ) );
188
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_session WHERE timestamp < %s", $purge ) );
189
 
190
  // Delete obsolete spam
191
  $spammaxage = wppa_opt( 'spam_maxage' );
200
  wppa_re_animate_cron();
201
 
202
  // Find lost photos, update their album to -9, meaning trashed
203
+ $album_ids = $wpdb->get_col( "SELECT id FROM $wpdb->wppa_albums" );
204
  if ( ! empty( $album_ids ) ) {
205
+ $lost = $wpdb->query( "UPDATE $wpdb->wppa_photos SET album = '-9' WHERE album > '0' AND album NOT IN ( " . implode( ',', $album_ids ) . " ) " );
206
  }
207
 
208
  // Remove 'deleted' photos from system
209
+ $dels = $wpdb->get_col( "SELECT id FROM $wpdb->wppa_photos WHERE album <= '-9' AND modified < " . ( time() - 3600 ) );
210
  foreach( $dels as $del ) {
211
  wppa_delete_photo( $del );
212
  wppa_log( 'Cron', 'Removed photo {b}' . $del . '{/b} from system' );
387
 
388
  $start = time();
389
 
390
+ $albs = $wpdb->get_col( "SELECT id FROM $wpdb->wppa_albums WHERE a_parent < '1' ORDER BY id" );
391
 
392
  foreach( $albs as $alb ) {
393
  $treecounts = wppa_get_treecounts_a( $alb );
wppa-encrypt.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all ecryption/decryption logic
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -32,24 +32,40 @@ function wppa_get_unique_album_crypt() {
32
  }
33
 
34
  // Find a unique crypt
35
- function wppa_get_unique_crypt( $table ) {
36
  global $wpdb;
37
 
38
- $crypt = substr( md5( microtime() ), 0, 12 );
 
 
 
 
 
 
 
 
 
 
39
  if ( $table == WPPA_PHOTOS ) {
40
- $dup = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM $wpdb->wppa_photos WHERE `crypt` = %s", $crypt ) );
41
  }
42
  else {
43
- $dup = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM $wpdb->wppa_albums WHERE `crypt` = %s", $crypt ) );
44
  }
45
  while ( $dup ) {
46
- sleep( 1 );
47
- $crypt = substr( md5( microtime() ), 0, 12 );
 
 
 
 
 
 
48
  if ( $table == WPPA_PHOTOS ) {
49
- $dup = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `$wpdb->wppa_photos WHERE `crypt` = %s", $crypt ) );
50
  }
51
  else {
52
- $dup = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM $wpdb->wppa_albums WHERE `crypt` = %s", $crypt ) );
53
  }
54
  }
55
  return $crypt;
@@ -135,7 +151,7 @@ function wppa_encrypt_album( $album ) {
135
  }
136
 
137
  // Convert photo crypt to id
138
- function wppa_decrypt_photo( $photo, $report_error = true ) {
139
  global $wpdb;
140
 
141
  // Feature enabled?
@@ -145,7 +161,7 @@ global $wpdb;
145
 
146
  // Already decrypted?
147
  if ( strlen( $photo ) < 12 ) {
148
- if ( wppa_switch( 'refuse_unencrypted' ) ) {
149
  wppa_dbg_msg( __( 'Invalid photo identifier:', 'wp-photo-album-plus' ) . ' ' . $photo, 'red', 'force' );
150
  return false;
151
  }
@@ -153,7 +169,7 @@ global $wpdb;
153
  }
154
 
155
  // Just do it
156
- $id = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM $wpdb->wppa_photos WHERE `crypt` = %s", substr( $photo, 0, 12 ) ) );
157
  if ( ! $id ) {
158
  if ( $report_error ) {
159
  wppa_dbg_msg( 'Invalid photo identifier: ' . $photo, 'red', 'force' );
@@ -164,7 +180,7 @@ global $wpdb;
164
  }
165
 
166
  // Convert album crypt to id
167
- function wppa_decrypt_album( $album ) {
168
  global $wpdb;
169
 
170
  // Feature enabled?
@@ -195,7 +211,7 @@ global $wpdb;
195
  elseif ( $crypt == get_option( 'wppa_album_crypt_2', false ) ) {
196
  $id = '-2';
197
  }
198
- elseif ( $crypt == get_option( 'wppa_album_crypt_2', false ) ) {
199
  $id = '-3';
200
  }
201
  else {
@@ -203,7 +219,7 @@ global $wpdb;
203
  // Already decrypted?
204
  if ( strlen( $crypt ) < 12 ) {
205
  $id = $crypt;
206
- if ( wppa_switch( 'refuse_unencrypted' ) ) {
207
  wppa_dbg_msg( __('Invalid album identifier:', 'wp-photo-album-plus') . ' ' . $id, 'red' );
208
  wppa_log( 'dbg', 'Decrypted album foud wppa_decrypt_album(). id=' . $id, true );
209
  $id = '-9';
@@ -215,7 +231,7 @@ global $wpdb;
215
 
216
  // Just do it
217
  else {
218
- $id = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM $wpdb->wppa_albums WHERE `crypt` = %s", substr( $crypt, 0, 12 ) ) );
219
  if ( ! $id ) {
220
  wppa_log( 'Dbg', 'Invalid album identifier: ' . $crypt . ' found in: ' . $album . ' (wppa_decrypt_album)' );
221
  $id = '-9';
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all ecryption/decryption logic
6
+ * Version 6.9.21
7
  *
8
  */
9
 
32
  }
33
 
34
  // Find a unique crypt
35
+ function wppa_get_unique_crypt( $table = null ) {
36
  global $wpdb;
37
 
38
+ // $crypt = substr( md5( microtime() ), 0, 12 );
39
+ $crypt = '';
40
+ while ( strlen( $crypt ) < 12 ) {
41
+ $crypt = crypt( microtime(), rand( 1000, 4711 ) );
42
+ $crypt = str_replace( array( '.', '/' ), '', $crypt );
43
+ }
44
+ $crypt = substr( $crypt, 0, 12 );
45
+ if ( ! $table ) {
46
+ return $crypt;
47
+ }
48
+
49
  if ( $table == WPPA_PHOTOS ) {
50
+ $dup = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_photos WHERE crypt = %s", $crypt ) );
51
  }
52
  else {
53
+ $dup = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_albums WHERE crypt = %s", $crypt ) );
54
  }
55
  while ( $dup ) {
56
+ // sleep( 1 );
57
+ // $crypt = substr( md5( microtime() ), 0, 12 );
58
+ $crype = '';
59
+ while ( strlen( $crypt ) < 12 ) {
60
+ $crypt = crypt( microtime(), rand( 1000, 4711 ) );
61
+ $crypt = str_replace( array( '.', '/' ), '', $crypt );
62
+ }
63
+ $crypt = substr( $crypt, 0, 12 );
64
  if ( $table == WPPA_PHOTOS ) {
65
+ $dup = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_photos WHERE crypt = %s", $crypt ) );
66
  }
67
  else {
68
+ $dup = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_albums WHERE crypt = %s", $crypt ) );
69
  }
70
  }
71
  return $crypt;
151
  }
152
 
153
  // Convert photo crypt to id
154
+ function wppa_decrypt_photo( $photo, $report_error = true, $no_refuse = false ) {
155
  global $wpdb;
156
 
157
  // Feature enabled?
161
 
162
  // Already decrypted?
163
  if ( strlen( $photo ) < 12 ) {
164
+ if ( wppa_switch( 'refuse_unencrypted' ) && ! $no_refuse ) {
165
  wppa_dbg_msg( __( 'Invalid photo identifier:', 'wp-photo-album-plus' ) . ' ' . $photo, 'red', 'force' );
166
  return false;
167
  }
169
  }
170
 
171
  // Just do it
172
+ $id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_photos WHERE crypt = %s", substr( $photo, 0, 12 ) ) );
173
  if ( ! $id ) {
174
  if ( $report_error ) {
175
  wppa_dbg_msg( 'Invalid photo identifier: ' . $photo, 'red', 'force' );
180
  }
181
 
182
  // Convert album crypt to id
183
+ function wppa_decrypt_album( $album, $dummy = true, $no_refuse = false ) {
184
  global $wpdb;
185
 
186
  // Feature enabled?
211
  elseif ( $crypt == get_option( 'wppa_album_crypt_2', false ) ) {
212
  $id = '-2';
213
  }
214
+ elseif ( $crypt == get_option( 'wppa_album_crypt_3', false ) ) {
215
  $id = '-3';
216
  }
217
  else {
219
  // Already decrypted?
220
  if ( strlen( $crypt ) < 12 ) {
221
  $id = $crypt;
222
+ if ( wppa_switch( 'refuse_unencrypted' ) && ! $no_refuse ) {
223
  wppa_dbg_msg( __('Invalid album identifier:', 'wp-photo-album-plus') . ' ' . $id, 'red' );
224
  wppa_log( 'dbg', 'Decrypted album foud wppa_decrypt_album(). id=' . $id, true );
225
  $id = '-9';
231
 
232
  // Just do it
233
  else {
234
+ $id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_albums WHERE crypt = %s", substr( $crypt, 0, 12 ) ) );
235
  if ( ! $id ) {
236
  wppa_log( 'Dbg', 'Invalid album identifier: ' . $crypt . ' found in: ' . $album . ' (wppa_decrypt_album)' );
237
  $id = '-9';
wppa-exif-iptc-common.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * exif and iptc common functions
6
- * version 6.9.20
7
  *
8
  *
9
  */
@@ -23,7 +23,7 @@ global $wppa_iptc_cache;
23
 
24
  // Get te labels if not yet present
25
  if ( ! is_array( $wppa_iptc_labels ) ) {
26
- $wppa_iptc_labels = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_iptc WHERE `photo` = '0' ORDER BY `tag`", ARRAY_A );
27
  }
28
 
29
  // If in cache, use it
@@ -36,7 +36,7 @@ global $wppa_iptc_cache;
36
 
37
  // Get the photo data
38
  if ( $iptcdata === false ) {
39
- $iptcdata = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_iptc WHERE `photo`=%s ORDER BY `tag`", $photo ), ARRAY_A );
40
 
41
  // Save in cache, even when empty
42
  $wppa_iptc_cache[$photo] = $iptcdata;
@@ -100,7 +100,7 @@ global $wppa_exif_cache;
100
 
101
  // Get the labels if not yet present
102
  if ( ! is_array( $wppa_exif_labels ) ) {
103
- $wppa_exif_labels = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_exif WHERE `photo` = '0' ORDER BY `tag`", ARRAY_A );
104
  }
105
 
106
  // If in cache, use it
@@ -113,7 +113,7 @@ global $wppa_exif_cache;
113
 
114
  // Get the photo data
115
  if ( $exifdata === false ) {
116
- $exifdata = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_exif WHERE `photo`=%s ORDER BY `tag`", $photo ), ARRAY_A );
117
 
118
  // Save in cache, even when empty
119
  $wppa_exif_cache[$photo] = $exifdata;
@@ -2966,18 +2966,18 @@ function wppa_iptc_clean_garbage() {
2966
  global $wpdb;
2967
 
2968
  // Remove empty tags
2969
- // $empty = $wpdb->query( "DELETE FROM $wpdb->wppa_iptc WHERE `description` = '' OR `description` = ' ' OR `description` = ' '" );
2970
  // if ( $empty ) {
2971
  // wppa_log( 'dbg', $empty . ' empty iptc entries removed.' );
2972
  // }
2973
 
2974
  // Remove labels that are no longer used
2975
- $labels = $wpdb->get_results( "SELECT DISTINCT `tag` FROM $wpdb->wppa_iptc WHERE `photo` = '0'", ARRAY_A );
2976
  if ( ! empty( $labels ) ) {
2977
  foreach( $labels as $label ) {
2978
- $used = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_iptc WHERE `tag` = %s AND `photo` <> '0'", $label['tag'] ) );
2979
  if ( $used == 0 ) {
2980
- $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_iptc WHERE `tag` = %s AND `photo` = '0'", $label['tag'] ) );
2981
  wppa_log( 'dbg', 'Iptc tag label ' . $label['tag'] . ' removed.' );
2982
  }
2983
  }
@@ -2988,16 +2988,16 @@ function wppa_exif_clean_garbage() {
2988
  global $wpdb;
2989
 
2990
  // Remove empty tags
2991
- // $empty = $wpdb->query( "DELETE FROM $wpdb->wppa_exif WHERE `description` = '' OR `description` = ' ' OR `description` = ' '" );
2992
  // wppa_log( 'dbg', $empty . ' empty exif entries removed.' );
2993
 
2994
  // Remove labels that are no longer used
2995
- $labels = $wpdb->get_results( "SELECT DISTINCT `tag` FROM $wpdb->wppa_exif WHERE `photo` = '0'", ARRAY_A );
2996
  if ( ! empty( $labels ) ) {
2997
  foreach( $labels as $label ) {
2998
- $used = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_exif WHERE `tag` = %s AND `photo` <> '0'", $label['tag'] ) );
2999
  if ( $used == 0 ) {
3000
- $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_exif WHERE `tag` = %s AND `photo` = '0'", $label['tag'] ) );
3001
  wppa_log( 'dbg', 'Exif tag label ' . $label['tag'] . ' removed.' );
3002
  }
3003
  }
@@ -3013,7 +3013,7 @@ global $wpdb;
3013
  return false;
3014
  }
3015
 
3016
- $exifs = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_exif WHERE `photo` = $photo", ARRAY_A );
3017
 
3018
  if ( ! empty( $exifs ) ) {
3019
 
@@ -3027,12 +3027,12 @@ global $wpdb;
3027
  // If f_description or thabrand changed: update
3028
  if ( $f_description != $exif['f_description'] || $tagbrand != $exif['brand'] ) {
3029
  $id = $exif['id'];
3030
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_exif SET `f_description` = %s, `brand` = %s WHERE `id` = %s", $f_description, $tagbrand, $id ) );
3031
  $photodata = wppa_cache_photo( $photo );
3032
 
3033
  // If the format changed and the exif tag is used in the description, the photo must be re-indexed
3034
  if ( strpos( $photodata['description'], $exif['tag'] ) !== false ) {
3035
- $wpdb->query( "UPDATE $wpdb->wppa_photos SET `indexdtm` = '' WHERE `id` = $photo" );
3036
  wppa_schedule_maintenance_proc( 'wppa_remake_index_photos' );
3037
  }
3038
  }
@@ -3681,7 +3681,7 @@ if ( strlen($tag) != 6 ) {
3681
 
3682
  // Fill $editabletags
3683
  if ( empty( $editabletags ) ) {
3684
- $temp = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_exif WHERE `photo` = '0'", ARRAY_A );
3685
  $editabletags = array();
3686
  if ( is_array( $temp ) ) foreach ( $temp as $item ) {
3687
  $editabletags[ hexdec( substr( $item['tag'], 2, 4 ) ) ] = trim( $item['description'], ': ' );
@@ -4349,7 +4349,7 @@ global $wpdb;
4349
  // Process result
4350
  // print_r( $geo ); // debug
4351
  $result = implode( '/', $geo );
4352
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `location` = %s WHERE `id` = %s", $result, $photo_id ) );
4353
  return $geo;
4354
  }
4355
 
@@ -4357,7 +4357,7 @@ function wppa_get_camera_brand( $id ) {
4357
  global $wpdb;
4358
 
4359
  // Try stored exif data
4360
- $E010F = $wpdb->get_var( $wpdb->prepare( "SELECT `description` FROM $wpdb->wppa_exif WHERE `photo` = %s AND `tag` = 'E#010F' ", $id ) );
4361
  if ( $E010F ) {
4362
  $E010F = strtolower( $E010F );
4363
  if ( strpos( $E010F, 'canon' ) !== false ) {
3
  * Package: wp-photo-album-plus
4
  *
5
  * exif and iptc common functions
6
+ * Version 6.9.21
7
  *
8
  *
9
  */
23
 
24
  // Get te labels if not yet present
25
  if ( ! is_array( $wppa_iptc_labels ) ) {
26
+ $wppa_iptc_labels = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_iptc WHERE photo = '0' ORDER BY tag", ARRAY_A );
27
  }
28
 
29
  // If in cache, use it
36
 
37
  // Get the photo data
38
  if ( $iptcdata === false ) {
39
+ $iptcdata = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_iptc WHERE photo=%s ORDER BY tag", $photo ), ARRAY_A );
40
 
41
  // Save in cache, even when empty
42
  $wppa_iptc_cache[$photo] = $iptcdata;
100
 
101
  // Get the labels if not yet present
102
  if ( ! is_array( $wppa_exif_labels ) ) {
103
+ $wppa_exif_labels = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_exif WHERE photo = '0' ORDER BY tag", ARRAY_A );
104
  }
105
 
106
  // If in cache, use it
113
 
114
  // Get the photo data
115
  if ( $exifdata === false ) {
116
+ $exifdata = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_exif WHERE photo=%s ORDER BY tag", $photo ), ARRAY_A );
117
 
118
  // Save in cache, even when empty
119
  $wppa_exif_cache[$photo] = $exifdata;
2966
  global $wpdb;
2967
 
2968
  // Remove empty tags
2969
+ // $empty = $wpdb->query( "DELETE FROM $wpdb->wppa_iptc WHERE description = '' OR description = ' ' OR description = ' '" );
2970
  // if ( $empty ) {
2971
  // wppa_log( 'dbg', $empty . ' empty iptc entries removed.' );
2972
  // }
2973
 
2974
  // Remove labels that are no longer used
2975
+ $labels = $wpdb->get_results( "SELECT DISTINCT tag FROM $wpdb->wppa_iptc WHERE photo = '0'", ARRAY_A );
2976
  if ( ! empty( $labels ) ) {
2977
  foreach( $labels as $label ) {
2978
+ $used = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_iptc WHERE tag = %s AND photo <> '0'", $label['tag'] ) );
2979
  if ( $used == 0 ) {
2980
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_iptc WHERE tag = %s AND photo = '0'", $label['tag'] ) );
2981
  wppa_log( 'dbg', 'Iptc tag label ' . $label['tag'] . ' removed.' );
2982
  }
2983
  }
2988
  global $wpdb;
2989
 
2990
  // Remove empty tags
2991
+ // $empty = $wpdb->query( "DELETE FROM $wpdb->wppa_exif WHERE description = '' OR description = ' ' OR description = ' '" );
2992
  // wppa_log( 'dbg', $empty . ' empty exif entries removed.' );
2993
 
2994
  // Remove labels that are no longer used
2995
+ $labels = $wpdb->get_results( "SELECT DISTINCT tag FROM $wpdb->wppa_exif WHERE photo = '0'", ARRAY_A );
2996
  if ( ! empty( $labels ) ) {
2997
  foreach( $labels as $label ) {
2998
+ $used = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_exif WHERE tag = %s AND photo <> '0'", $label['tag'] ) );
2999
  if ( $used == 0 ) {
3000
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_exif WHERE tag = %s AND photo = '0'", $label['tag'] ) );
3001
  wppa_log( 'dbg', 'Exif tag label ' . $label['tag'] . ' removed.' );
3002
  }
3003
  }
3013
  return false;
3014
  }
3015
 
3016
+ $exifs = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_exif WHERE photo = $photo", ARRAY_A );
3017
 
3018
  if ( ! empty( $exifs ) ) {
3019
 
3027
  // If f_description or thabrand changed: update
3028
  if ( $f_description != $exif['f_description'] || $tagbrand != $exif['brand'] ) {
3029
  $id = $exif['id'];
3030
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_exif SET f_description = %s, brand = %s WHERE id = %s", $f_description, $tagbrand, $id ) );
3031
  $photodata = wppa_cache_photo( $photo );
3032
 
3033
  // If the format changed and the exif tag is used in the description, the photo must be re-indexed
3034
  if ( strpos( $photodata['description'], $exif['tag'] ) !== false ) {
3035
+ $wpdb->query( "UPDATE $wpdb->wppa_photos SET indexdtm = '' WHERE id = $photo" );
3036
  wppa_schedule_maintenance_proc( 'wppa_remake_index_photos' );
3037
  }
3038
  }
3681
 
3682
  // Fill $editabletags
3683
  if ( empty( $editabletags ) ) {
3684
+ $temp = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_exif WHERE photo = '0'", ARRAY_A );
3685
  $editabletags = array();
3686
  if ( is_array( $temp ) ) foreach ( $temp as $item ) {
3687
  $editabletags[ hexdec( substr( $item['tag'], 2, 4 ) ) ] = trim( $item['description'], ': ' );
4349
  // Process result
4350
  // print_r( $geo ); // debug
4351
  $result = implode( '/', $geo );
4352
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET location = %s WHERE id = %s", $result, $photo_id ) );
4353
  return $geo;
4354
  }
4355
 
4357
  global $wpdb;
4358
 
4359
  // Try stored exif data
4360
+ $E010F = $wpdb->get_var( $wpdb->prepare( "SELECT description FROM $wpdb->wppa_exif WHERE photo = %s AND tag = 'E#010F' ", $id ) );
4361
  if ( $E010F ) {
4362
  $E010F = strtolower( $E010F );
4363
  if ( strpos( $E010F, 'canon' ) !== false ) {
wppa-export.php CHANGED
@@ -121,7 +121,7 @@ global $wppa_temp_idx;
121
  if ( $wppa_zip ) {
122
  $wppa_zip->addFile ( $from, basename ( $to ) );
123
  }
124
- else copy ( $from, $to );
125
 
126
  // Create the metadata
127
  if ( ! wppa_write_photo_file ( $photo ) ) {
121
  if ( $wppa_zip ) {
122
  $wppa_zip->addFile ( $from, basename ( $to ) );
123
  }
124
+ else wppa_copy ( $from, $to );
125
 
126
  // Create the metadata
127
  if ( ! wppa_write_photo_file ( $photo ) ) {
wppa-featen-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the featured photos
6
- * Version 6.9.14
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
@@ -46,7 +46,7 @@ class FeaTenWidget extends WP_Widget {
46
 
47
  // Owner/public
48
  case '-3':
49
- $temp = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos WHERE `status` = 'featured' ORDER BY RAND(" . wppa_get_randseed() . ") DESC", ARRAY_A );
50
  if ( $temp ) {
51
  $c = '0';
52
  $thumbs = array();
@@ -66,7 +66,7 @@ class FeaTenWidget extends WP_Widget {
66
 
67
  // Generic
68
  case '-2':
69
- $temp = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos WHERE `status` = 'featured' ORDER BY RAND(" . wppa_get_randseed() . ") DESC", ARRAY_A );
70
  if ( $temp ) {
71
  $c = '0';
72
  $thumbs = array();
@@ -85,12 +85,12 @@ class FeaTenWidget extends WP_Widget {
85
 
86
  // All
87
  case '0':
88
- $thumbs = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos WHERE `status` = 'featured' ORDER BY RAND(" . wppa_get_randseed() . ") DESC LIMIT " . $max, ARRAY_A );
89
  break;
90
 
91
  // Album spec
92
  default:
93
- $thumbs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `status`= 'featured' AND `album` = %s ORDER BY RAND(" . wppa_get_randseed() . ") DESC LIMIT " . $max, $album ), ARRAY_A );
94
  }
95
 
96
  $widget_content = "\n".'<!-- WPPA+ FeaTen Widget start -->';
@@ -111,7 +111,7 @@ class FeaTenWidget extends WP_Widget {
111
  "\n" .
112
  '<div' .
113
  ' class="wppa-widget"' .
114
- ' style="width:' . $maxw . 'px;height:' . $maxh . 'px;margin:4px;display:inline;text-align:center;float:left;"' .
115
  ' data-wppa="yes"' .
116
  ' >';
117
 
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the featured photos
6
+ * Version 6.9.21
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
46
 
47
  // Owner/public
48
  case '-3':
49
+ $temp = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos WHERE status = 'featured' ORDER BY RAND(" . wppa_get_randseed() . ") DESC", ARRAY_A );
50
  if ( $temp ) {
51
  $c = '0';
52
  $thumbs = array();
66
 
67
  // Generic
68
  case '-2':
69
+ $temp = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos WHERE status = 'featured' ORDER BY RAND(" . wppa_get_randseed() . ") DESC", ARRAY_A );
70
  if ( $temp ) {
71
  $c = '0';
72
  $thumbs = array();
85
 
86
  // All
87
  case '0':
88
+ $thumbs = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos WHERE status = 'featured' ORDER BY RAND(" . wppa_get_randseed() . ") DESC LIMIT " . $max, ARRAY_A );
89
  break;
90
 
91
  // Album spec
92
  default:
93
+ $thumbs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE status= 'featured' AND album = %s ORDER BY RAND(" . wppa_get_randseed() . ") DESC LIMIT " . $max, $album ), ARRAY_A );
94
  }
95
 
96
  $widget_content = "\n".'<!-- WPPA+ FeaTen Widget start -->';
111
  "\n" .
112
  '<div' .
113
  ' class="wppa-widget"' .
114
+ ' style="width:' . strval( intval( $maxw ) ) . 'px;height:' . strval( intval( $maxh ) ) . 'px;margin:4px;display:inline;text-align:center;float:left;"' .
115
  ' data-wppa="yes"' .
116
  ' >';
117
 
wppa-filter.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * get the albums via shortcode handler
6
- * Version 6.9.14
7
  *
8
  */
9
 
@@ -25,7 +25,7 @@ function wppa_add_shortcode_to_post( $post ) {
25
 
26
  $new_post = $post;
27
  if ( ! wppa( 'ajax' ) && wppa_switch( 'add_shortcode_to_post' ) ) {
28
- $id = get_the_ID();
29
  $p = get_post( $id, ARRAY_A );
30
  if ( $p['post_type'] == 'post' ) $new_post .= wppa_opt( 'shortcode_to_add' );
31
  }
@@ -84,10 +84,10 @@ global $wppa_revno;
84
  wppa_reset_occurrance();
85
 
86
  // Find occur
87
- if ( get_the_ID() != $wppa_postid ) { // New post
88
  $wppa['occur'] = '0'; // Init this occurance
89
  $wppa['fullsize'] = ''; // Reset at each post
90
- $wppa_postid = get_the_ID(); // Remember the post id
91
  }
92
 
93
  // Whatever is entered between [wppa ...] and [/wppa]
@@ -109,6 +109,7 @@ global $wppa_revno;
109
  break;
110
  case 'landing':
111
  $wppa['is_landing'] = '1';
 
112
  case 'generic':
113
  break;
114
  case 'cover':
@@ -161,6 +162,10 @@ global $wppa_revno;
161
  $wppa['start_album'] = $atts['album'];
162
  $wppa['is_slide'] = '1';
163
  $wppa['film_on'] = '1';
 
 
 
 
164
  case 'filmonly':
165
  $wppa['start_album'] = $atts['album'];
166
  $wppa['is_slideonly'] = '1';
@@ -415,7 +420,7 @@ global $wppa_revno;
415
  // Any unique key will do, as long as it is not tampered by any content filter.
416
  // Hopefully everything keeps an unadded shortcode untouched,
417
  // therefor we wrap the random key in square brackets
418
- $key = '[' . md5( rand() ) . ']';
419
 
420
  // Store
421
  $wppa_shortcode_results[$key] = $result;
@@ -557,10 +562,10 @@ static $seed;
557
  }
558
 
559
  // Find occur
560
- if ( get_the_ID() != $wppa_postid ) { // New post
561
  $wppa['occur'] = '0'; // Init this occurance
562
  $wppa['fullsize'] = ''; // Reset at each post
563
- $wppa_postid = get_the_ID(); // Remember the post id
564
  }
565
 
566
  // Random photo?
@@ -573,24 +578,24 @@ static $seed;
573
 
574
  if ( wppa_opt( 'photo_shortcode_random_albums' ) != '-2' ) {
575
  $albs = str_replace( '.', ',', wppa_expand_enum( wppa_opt( 'photo_shortcode_random_albums' ) ) );
576
- $photo = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM $wpdb->wppa_photos " .
577
- "WHERE `album` IN (" . $albs . ") " .
578
  "ORDER BY RAND(%d) LIMIT 1", $seed ) );
579
  }
580
  else {
581
- $photo = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM $wpdb->wppa_photos " .
582
  "ORDER BY RAND(%d) LIMIT 1", $seed ) );
583
  }
584
  if ( $photo ) {
585
  if ( wppa_switch( 'photo_shortcode_random_fixed' ) ) {
586
- $post_content = $wpdb->get_var( $wpdb->prepare( "SELECT `post_content` FROM `" . $wpdb->posts . "` WHERE `ID` = %d", $wppa_postid ) );
587
  if ( wppa_switch( 'photo_shortcode_random_fixed_html' ) ) {
588
  $post_content = preg_replace( '/\[photo random\]/', do_shortcode('[photo '.$photo.']'), $post_content, 1, $done );
589
  }
590
  else {
591
  $post_content = preg_replace( '/\[photo random\]/', '[photo '.$photo.']', $post_content, 1, $done );
592
  }
593
- $wpdb->query( $wpdb->prepare( "UPDATE `" . $wpdb->posts . "` SET `post_content` = %s WHERE `ID` = %d", $post_content, $wppa_postid ) );
594
  }
595
  }
596
  else {
3
  * Package: wp-photo-album-plus
4
  *
5
  * get the albums via shortcode handler
6
+ * Version 6.9.21
7
  *
8
  */
9
 
25
 
26
  $new_post = $post;
27
  if ( ! wppa( 'ajax' ) && wppa_switch( 'add_shortcode_to_post' ) ) {
28
+ $id = wppa_get_the_ID();
29
  $p = get_post( $id, ARRAY_A );
30
  if ( $p['post_type'] == 'post' ) $new_post .= wppa_opt( 'shortcode_to_add' );
31
  }
84
  wppa_reset_occurrance();
85
 
86
  // Find occur
87
+ if ( wppa_get_the_ID() != $wppa_postid ) { // New post
88
  $wppa['occur'] = '0'; // Init this occurance
89
  $wppa['fullsize'] = ''; // Reset at each post
90
+ $wppa_postid = wppa_get_the_ID(); // Remember the post id
91
  }
92
 
93
  // Whatever is entered between [wppa ...] and [/wppa]
109
  break;
110
  case 'landing':
111
  $wppa['is_landing'] = '1';
112
+ break;
113
  case 'generic':
114
  break;
115
  case 'cover':
162
  $wppa['start_album'] = $atts['album'];
163
  $wppa['is_slide'] = '1';
164
  $wppa['film_on'] = '1';
165
+ $wppa['is_slideonly'] = '1';
166
+ $wppa['is_filmonly'] = '1';
167
+ $wppa['start_photo'] = $atts['photo'];
168
+ break;
169
  case 'filmonly':
170
  $wppa['start_album'] = $atts['album'];
171
  $wppa['is_slideonly'] = '1';
420
  // Any unique key will do, as long as it is not tampered by any content filter.
421
  // Hopefully everything keeps an unadded shortcode untouched,
422
  // therefor we wrap the random key in square brackets
423
+ $key = '[' . wppa_get_unique_crypt() . ']';
424
 
425
  // Store
426
  $wppa_shortcode_results[$key] = $result;
562
  }
563
 
564
  // Find occur
565
+ if ( wppa_get_the_ID() != $wppa_postid ) { // New post
566
  $wppa['occur'] = '0'; // Init this occurance
567
  $wppa['fullsize'] = ''; // Reset at each post
568
+ $wppa_postid = wppa_get_the_ID(); // Remember the post id
569
  }
570
 
571
  // Random photo?
578
 
579
  if ( wppa_opt( 'photo_shortcode_random_albums' ) != '-2' ) {
580
  $albs = str_replace( '.', ',', wppa_expand_enum( wppa_opt( 'photo_shortcode_random_albums' ) ) );
581
+ $photo = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_photos " .
582
+ "WHERE album IN (" . $albs . ") " .
583
  "ORDER BY RAND(%d) LIMIT 1", $seed ) );
584
  }
585
  else {
586
+ $photo = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_photos " .
587
  "ORDER BY RAND(%d) LIMIT 1", $seed ) );
588
  }
589
  if ( $photo ) {
590
  if ( wppa_switch( 'photo_shortcode_random_fixed' ) ) {
591
+ $post_content = $wpdb->get_var( $wpdb->prepare( "SELECT post_content FROM " . $wpdb->posts . " WHERE ID = %d", $wppa_postid ) );
592
  if ( wppa_switch( 'photo_shortcode_random_fixed_html' ) ) {
593
  $post_content = preg_replace( '/\[photo random\]/', do_shortcode('[photo '.$photo.']'), $post_content, 1, $done );
594
  }
595
  else {
596
  $post_content = preg_replace( '/\[photo random\]/', '[photo '.$photo.']', $post_content, 1, $done );
597
  }
598
+ $wpdb->query( $wpdb->prepare( "UPDATE " . $wpdb->posts . " SET post_content = %s WHERE ID = %d", $post_content, $wppa_postid ) );
599
  }
600
  }
601
  else {
wppa-functions.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various functions
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -158,7 +158,7 @@ global $wppa_session;
158
  if ( wppa( 'is_upldr' ) ) wppa( 'photos_only', true );
159
  wppa( 'is_owner', wppa_get_get( 'owner' ) );
160
  if ( wppa( 'is_owner' ) ) {
161
- $albs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `owner` = %s ", wppa( 'is_owner' ) ), ARRAY_A );
162
  wppa_cache_album( 'add', $albs );
163
  $id = '';
164
  if ( $albs ) foreach ( $albs as $alb ) {
@@ -235,10 +235,10 @@ global $wppa_session;
235
  return ''; // Do nothing on a landing page without a querystring while it is also not a search operation
236
  }
237
  elseif ( wppa( 'is_autopage' ) ) {
238
- $photo = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM $wpdb->wppa_photos WHERE `page_id` = %d LIMIT 1", get_the_ID() ) );
239
  wppa( 'single_photo', $photo );
240
  if ( ! wppa( 'single_photo' ) ) {
241
- wppa_dbg_msg( 'No photo found for page '.get_the_ID(), 'red', 'force' );
242
  wppa_reset_occurrance();
243
  return ''; // Give up
244
  }
@@ -289,18 +289,18 @@ global $wppa_session;
289
  if ( $limit ) {
290
  if ( $parent ) {
291
  if ( $limit ) {
292
- $q = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `a_parent` = %s ORDER BY `timestamp` DESC LIMIT %d", $parent, $limit );
293
  }
294
  else {
295
- $q = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `a_parent` = %s ORDER BY `timestamp` DESC", $parent );
296
  }
297
  }
298
  else {
299
  if ( $limit ) {
300
- $q = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums ORDER BY `timestamp` DESC LIMIT %d", $limit );
301
  }
302
  else {
303
- $q = "SELECT * FROM $wpdb->wppa_albums ORDER BY `timestamp` DESC";
304
  }
305
  }
306
  $albs = $wpdb->get_results( $q, ARRAY_A );
@@ -535,8 +535,11 @@ global $wppa_session;
535
  }
536
  }
537
  $id = implode ( '.', $albs );
 
 
 
538
  if ( ! $id ) {
539
- $id = '-9'; // Force nothing found
540
  // wppa_reset_occurrance();
541
  // return; // No children found
542
  }
@@ -880,7 +883,7 @@ function wppa_get_related_data() {
880
  global $wpdb;
881
 
882
  $pagid = wppa_get_the_id();
883
- $data = $wpdb->get_var( "SELECT `post_content` FROM `" . $wpdb->posts . "` WHERE `ID` = " . $pagid );
884
  $data = str_replace( array( ' ', ',', '.', "\t", "\r", "0", "x0B", "\n" ), ';', $data );
885
  $data = strip_tags( $data );
886
  $data = strip_shortcodes( $data );
@@ -954,13 +957,13 @@ global $wppa_session;
954
  if ( empty( $ids ) ) {
955
  $ids = array( '0' ); // Dummy
956
  }
957
- $query = "SELECT * FROM $wpdb->wppa_albums WHERE `id` IN (" . implode( ',',$ids ) . ")";
958
  $albums = $wpdb->get_results( $query, ARRAY_A );
959
  break;
960
 
961
  // Name. Name is converted to number or enum
962
  case 'n':
963
- $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `name` = %s", $data );
964
  $albums = $wpdb->get_results( $query, ARRAY_A );
965
  break;
966
 
@@ -968,26 +971,26 @@ global $wppa_session;
968
  case 't':
969
  if ( strpos( $data, '.' ) ) {
970
  $temp = explode( '.', $data );
971
- $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE `slug` = %s", $temp['0'] );
972
  $indexes = $wpdb->get_row( $query, ARRAY_A );
973
  $ids = explode( '.', wppa_expand_enum( $indexes['albums'] ) );
974
  $i = '1';
975
  while ( $i < count( $temp ) ) {
976
- $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE `slug` = %s", $temp[$i] );
977
  $indexes = $wpdb->get_row( $query, ARRAY_A );
978
  $ids = array_intersect( $ids, explode( '.', wppa_expand_enum( $indexes['albums'] ) ) );
979
  $i++;
980
  }
981
  }
982
  else {
983
- $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE `slug` = %s", $data );
984
  $indexes = $wpdb->get_row( $query, ARRAY_A );
985
  $ids = explode( '.', wppa_expand_enum( $indexes['albums'] ) );
986
  }
987
  if ( empty( $ids ) ) {
988
  $ids = array( '0' ); // Dummy
989
  }
990
- $query = "SELECT * FROM $wpdb->wppa_albums WHERE `id` IN (" . implode( ',', $ids ) . ")";
991
  $albums = $wpdb->get_results( $query, ARRAY_A );
992
  break;
993
  }
@@ -1010,9 +1013,9 @@ global $wppa_session;
1010
  }
1011
 
1012
  // Compose WHERE clause
1013
- $selection = " `id` = '0' ";
1014
  foreach ( array_keys( $final_array ) as $p ) {
1015
- $selection .= "OR `id` = '".$final_array[$p]."' ";
1016
  }
1017
 
1018
  // Get them
@@ -1067,10 +1070,10 @@ global $wppa_session;
1067
  }
1068
  elseif ( wppa( 'last_albums' ) ) { // is_cover = true. For the order sequence, see remark in wppa_albums()
1069
  if ( wppa( 'last_albums_parent' ) ) {
1070
- $q = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `a_parent` = %s ORDER BY `timestamp` DESC LIMIT %d", wppa( 'last_albums_parent' ), wppa( 'last_albums' ) );
1071
  }
1072
  else {
1073
- $q = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums ORDER BY `timestamp` DESC LIMIT %d", wppa( 'last_albums' ) );
1074
  }
1075
  $albums = $wpdb->get_results( $q, ARRAY_A );
1076
  }
@@ -1086,10 +1089,10 @@ global $wppa_session;
1086
  elseif ( strpos( $id, '.' ) !== false ) { // Album enum
1087
  $ids = wppa_series_to_array( $id );
1088
  if ( wppa( 'is_cover' ) ) {
1089
- $q = "SELECT * FROM $wpdb->wppa_albums WHERE `id` = ".implode( " OR `id` = ", $ids )." ".wppa_get_album_order();
1090
  }
1091
  else {
1092
- $q = "SELECT * FROM $wpdb->wppa_albums WHERE `a_parent` = ".implode( " OR `a_parent` = ", $ids )." ".wppa_get_album_order();
1093
  }
1094
  wppa_dbg_msg( $q, 'red' );
1095
  $albums = $wpdb->get_results( $q, ARRAY_A );
@@ -1160,20 +1163,20 @@ global $wppa_session;
1160
 
1161
  // Single album
1162
  if ( strpos( $fullalb, '.' ) == false ) {
1163
- $album_clause = " `album` = $fullalb ";
1164
  }
1165
 
1166
  // Enum albums
1167
  else {
1168
  $ids = wppa_series_to_array( $fullalb );
1169
- $album_clause = " `album` IN ( " . implode( ',', $ids ) . " ) ";
1170
  }
1171
  }
1172
 
1173
  // No album given, make sure trashed photos are not found
1174
  else {
1175
  $fullalb = '';
1176
- $album_clause = " `album` > '0' ";
1177
  }
1178
 
1179
  // For upload link on thumbarea: if startalbum is a single real album, put it in current album
@@ -1189,17 +1192,17 @@ global $wppa_session;
1189
  // Single image slideshow?
1190
  if ( wppa( 'start_photo' ) && wppa( 'is_single' ) ) {
1191
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1192
- "WHERE `id` = %s", wppa( 'start_photo' ) );
1193
  }
1194
 
1195
  // Uploader? // lasten with owner rstriction is handled at the Lasten case
1196
  elseif ( wppa( 'is_upldr' ) && ! wppa( 'is_lasten' ) ) {
1197
- $status = "`status` <> 'pending' AND `status` <> 'scheduled'";
1198
- if ( ! is_user_logged_in() ) $status .= " AND `status` <> 'private'";
1199
 
1200
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1201
- "WHERE " . $album_clause . " AND `owner` = %s AND ( " . $status . " ) " .
1202
- "ORDER BY `timestamp` DESC", wppa( 'is_upldr' ) );
1203
  }
1204
 
1205
  // Topten?
@@ -1207,13 +1210,13 @@ global $wppa_session;
1207
  $max = wppa( 'topten_count' );
1208
  switch ( wppa_opt( 'topten_sortby' ) ) {
1209
  case 'mean_rating':
1210
- $sortby = "`mean_rating` DESC, `rating_count` DESC, `views` DESC";
1211
  break;
1212
  case 'rating_count':
1213
- $sortby = "`rating_count` DESC, `mean_rating` DESC, `views` DESC";
1214
  break;
1215
  case 'views':
1216
- $sortby = "`views` DESC, `mean_rating` DESC, `rating_count` DESC";
1217
  break;
1218
  default:
1219
  wppa_error_message( 'Unimplemented sorting method' );
@@ -1221,12 +1224,12 @@ global $wppa_session;
1221
  break;
1222
  }
1223
  if ( wppa( 'medals_only' ) ) {
1224
- $status = "`status` IN ( 'gold', 'silver', 'bronze' )";
1225
  }
1226
  else {
1227
- $status = "`status` <> 'pending' AND `status` <> 'scheduled'";
1228
  }
1229
- if ( ! is_user_logged_in() ) $status .= " AND `status` <> 'private'";
1230
 
1231
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1232
  "WHERE $album_clause AND ( $status ) " .
@@ -1240,7 +1243,7 @@ global $wppa_session;
1240
  $max = wppa( 'featen_count' );
1241
 
1242
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1243
- "WHERE $album_clause AND `status` = 'featured' " .
1244
  "ORDER BY RAND( " . wppa_get_randseed() . " ) DESC LIMIT $max";
1245
 
1246
  $count_first = false;
@@ -1249,14 +1252,14 @@ global $wppa_session;
1249
  // Lasten?
1250
  elseif ( wppa( 'is_lasten' ) ) {
1251
  $max = wppa( 'lasten_count' );
1252
- $status = "`status` <> 'pending' AND `status` <> 'scheduled'";
1253
- if ( ! is_user_logged_in() ) $status .= " AND `status` <> 'private'";
1254
  $order_by = wppa_switch( 'lasten_use_modified' ) ? 'modified' : 'timestamp';
1255
 
1256
  // If you want only 'New' photos in the selection, the period must be <> 0;
1257
  if ( wppa_switch( 'lasten_limit_new' ) && wppa_opt( 'max_photo_newtime' ) ) {
1258
- $newtime = " `" . $order_by . "` >= ".( time() - wppa_opt( 'max_photo_newtime' ) );
1259
- $owner_restriction = ( wppa( 'is_upldr' ) ) ? "AND `owner` = '" . sanitize_user( wppa( 'is_upldr' ) ) . "' " : "";
1260
 
1261
  if ( current_user_can( 'wppa_moderate' ) ) {
1262
 
@@ -1264,14 +1267,14 @@ global $wppa_session;
1264
  "WHERE ( $album_clause ) " .
1265
  "AND ( $newtime ) " .
1266
  $owner_restriction .
1267
- "ORDER BY `$order_by` DESC LIMIT $max";
1268
  }
1269
  else {
1270
 
1271
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1272
  "WHERE ( $album_clause ) AND ( $status ) AND ( $newtime ) " .
1273
  $owner_restriction .
1274
- "ORDER BY `$order_by` DESC LIMIT $max";
1275
  }
1276
  }
1277
 
@@ -1281,13 +1284,13 @@ global $wppa_session;
1281
 
1282
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1283
  "WHERE $album_clause " .
1284
- "ORDER BY `$order_by` DESC LIMIT $max";
1285
  }
1286
  else {
1287
 
1288
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1289
  "WHERE ( $album_clause ) AND ( $status ) " .
1290
- "ORDER BY `$order_by` DESC LIMIT $max";
1291
  }
1292
  }
1293
 
@@ -1309,13 +1312,13 @@ global $wppa_session;
1309
  $photo_ids = false;
1310
  }
1311
 
1312
- $status = "`status` <> 'pending' AND `status` <> 'scheduled'";
1313
- if ( ! is_user_logged_in() ) $status .= " AND `status` <> 'private'";
1314
 
1315
  // To keep the sequence ok ( in sequence of comments desc ), do the queries one by one
1316
  $thumbs = array();
1317
  if ( is_array( $photo_ids ) ) foreach( $photo_ids as $id ) {
1318
- $temp = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE ".$status." AND `album` > '0' AND `id` = %s", $id ), ARRAY_A );
1319
  if ( $temp ) {
1320
  $thumbs[] = $temp;
1321
  }
@@ -1339,8 +1342,8 @@ global $wppa_session;
1339
  if ( strpos( wppa( 'is_tag' ), ';' ) ) $andor = 'OR';
1340
 
1341
  // Compute status clause for query
1342
- $status = "`status` <> 'pending' AND `status` <> 'scheduled'";
1343
- if ( ! is_user_logged_in() ) $status .= " AND `status` <> 'private'";
1344
 
1345
  // Define tags clause for query
1346
  $seltags = explode( ',', trim( wppa_sanitize_tags( wppa( 'is_tag' ) ), ',' ) );
@@ -1350,7 +1353,7 @@ global $wppa_session;
1350
  if ( ! $first ) {
1351
  $tags_like .= " " . $andor;
1352
  }
1353
- $tags_like .= " `tags` LIKE '%,".$tag.",%'";
1354
  $first = false;
1355
  }
1356
 
@@ -1359,7 +1362,7 @@ global $wppa_session;
1359
  $fac = ' AND ' . $album_clause . ' ';
1360
  }
1361
  else {
1362
- $fac = " AND `album` > '0' ";
1363
  }
1364
 
1365
  // Prepare the query
@@ -1391,8 +1394,8 @@ global $wppa_session;
1391
  $data = implode( ',', $data );
1392
  $ss_data[3] = $data;
1393
 
1394
- $status = "`status` <> 'pending' AND `status` <> 'scheduled'";
1395
- if ( ! is_user_logged_in() ) $status .= " AND `status` <> 'private'";
1396
 
1397
  switch ( $ss_data['1'] ) {
1398
 
@@ -1405,14 +1408,14 @@ global $wppa_session;
1405
  }
1406
  if ( current_user_can( 'wppa_moderate' ) ) {
1407
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1408
- "WHERE `name` " . $is . " %s " .
1409
- "AND `album` > '0' " .
1410
  wppa_get_photo_order( '0' ), $data );
1411
  }
1412
  else {
1413
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1414
- "WHERE `name` " . $is . " %s " .
1415
- "AND `album` > '0' " .
1416
  "AND " . $status . " " .
1417
  wppa_get_photo_order( '0' ), $data );
1418
  }
@@ -1422,14 +1425,14 @@ global $wppa_session;
1422
  case 'o':
1423
  if ( current_user_can( 'wppa_moderate' ) ) {
1424
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1425
- "WHERE `owner` = %s " .
1426
- "AND `album` > '0' " .
1427
  wppa_get_photo_order( '0' ), $data );
1428
  }
1429
  else {
1430
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1431
- "WHERE `owner` = %s " .
1432
- "AND `album` > '0' " .
1433
  "AND " . $status . " " .
1434
  wppa_get_photo_order( '0' ), $data );
1435
  }
@@ -1453,8 +1456,8 @@ global $wppa_session;
1453
  if ( count( $tagids ) > '0' ) {
1454
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1455
  "WHERE ".$status." " .
1456
- "AND `id` IN (" . implode( ',',$tagids ) . ") " .
1457
- "AND `album` > '0' ";
1458
  }
1459
  break;
1460
 
@@ -1472,7 +1475,7 @@ global $wppa_session;
1472
  $is = 'LIKE';
1473
  }
1474
  }
1475
- $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE `slug` ".$is." %s", $temp['0'] );
1476
  $indexes = $wpdb->get_results( $query, ARRAY_A );
1477
  $ids = array();
1478
  foreach( $indexes as $item ) {
@@ -1488,7 +1491,7 @@ global $wppa_session;
1488
  }
1489
  }
1490
 
1491
- $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE `slug` ".$is." %s", $temp[$i] );
1492
  $indexes = $wpdb->get_results( $query, ARRAY_A );
1493
  $deltaids = array();
1494
  foreach( $indexes as $item ) {
@@ -1507,7 +1510,7 @@ global $wppa_session;
1507
  $is = 'LIKE';
1508
  }
1509
  }
1510
- $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE `slug` ".$is." %s", $data );
1511
  $indexes = $wpdb->get_results( $query, ARRAY_A );
1512
  $ids = array();
1513
  foreach( $indexes as $item ) {
@@ -1519,8 +1522,8 @@ global $wppa_session;
1519
  }
1520
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1521
  "WHERE ".$status." " .
1522
- "AND `album` > '0' " .
1523
- "AND `id` IN (" . trim( implode( ',', $ids ), ',' ) . ")";
1524
  break;
1525
 
1526
  // Iptc
@@ -1528,7 +1531,7 @@ global $wppa_session;
1528
  $itag = str_replace( 'H', '#', $ss_data['2'] );
1529
  $desc = $ss_data['3'];
1530
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_iptc " .
1531
- "WHERE `tag` = %s AND `description` = %s", $itag, $desc );
1532
  $iptclines = $wpdb->get_results( $query, ARRAY_A );
1533
  $ids = '0';
1534
  if ( is_array( $iptclines ) ) foreach( $iptclines as $item ) {
@@ -1536,8 +1539,8 @@ global $wppa_session;
1536
  }
1537
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1538
  "WHERE ".$status." " .
1539
- "AND `album` > '0' " .
1540
- "AND `id` IN (" . $ids . ")";
1541
  break;
1542
 
1543
  // Exif
@@ -1547,11 +1550,11 @@ global $wppa_session;
1547
  $desc = $ss_data['3'];
1548
  // if ( $brand ) {
1549
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_exif " .
1550
- "WHERE `tag` = %s AND `f_description` = %s AND `brand` = %s", $etag, $desc, $brand );
1551
  // }
1552
  // else {
1553
  // $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_exif " .
1554
- // "WHERE `tag` = %s AND `f_description` = %s", $etag, $desc );
1555
  // }
1556
  $exiflines = $wpdb->get_results( $query, ARRAY_A );
1557
  $ids = '0';
@@ -1560,8 +1563,8 @@ global $wppa_session;
1560
  }
1561
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1562
  "WHERE ".$status." " .
1563
- "AND `album` > '0' " .
1564
- "AND `id` IN (" . $ids . ")";
1565
  break;
1566
  }
1567
  }
@@ -1569,8 +1572,8 @@ global $wppa_session;
1569
  // Search?
1570
  elseif ( wppa( 'src' ) ) { // Searching
1571
 
1572
- $status = "`status` <> 'pending' AND `status` <> 'scheduled'";
1573
- if ( ! is_user_logged_in() ) $status .= " AND `status` <> 'private'";
1574
 
1575
  $searchstring = wppa( 'searchstring' );
1576
  if ( ! empty ( $wppa_session['use_searchstring'] ) ) $searchstring = $wppa_session['use_searchstring'];
@@ -1580,7 +1583,7 @@ global $wppa_session;
1580
 
1581
  // Remove scheduled and pending and trashed when not can moderate
1582
  if ( ! current_user_can( 'wppa_moderate' ) ) {
1583
- $needmod = $wpdb->get_col( "SELECT `id` FROM $wpdb->wppa_photos WHERE `status` = 'scheduled' OR `status` = 'pending' OR `album` <= '-9'" );
1584
  if ( is_array( $needmod ) ) {
1585
  $final_array = array_diff( $final_array, $needmod );
1586
  }
@@ -1588,7 +1591,7 @@ global $wppa_session;
1588
 
1589
  // Remove private and trashed when not logged in
1590
  if ( ! is_user_logged_in() ) {
1591
- $needlogin = $wpdb->get_col( "SELECT `id` FROM $wpdb->wppa_photos WHERE `status` = 'private' OR `album` <= '-9'" );
1592
  if ( is_array( $needlogin ) ) {
1593
  $final_array = array_diff( $final_array, $needlogin );
1594
  }
@@ -1612,26 +1615,26 @@ global $wppa_session;
1612
  $root = $wppa_session['search_root'];
1613
  $root_albs = wppa_expand_enum( wppa_alb_to_enum_children( $root ) );
1614
  $root_albs = str_replace( '.', ',', $root_albs );
1615
- $alb_clause = $root_albs ? ' AND `album` IN ('.$root_albs.') ' : '';
1616
  }
1617
 
1618
  // Maybe cats limitation
1619
  elseif ( wppa( 'catbox' ) ) {
1620
 
1621
- $catalbs = $wpdb->get_col( "SELECT `id` FROM $wpdb->wppa_albums WHERE `cats` LIKE '%" . wppa( 'catbox' ) . "%' " );
1622
 
1623
  if ( ! empty( $catalbs ) ) {
1624
- $alb_clause = " AND `album` IN ( " . implode( ',', $catalbs ) . " ) ";
1625
  }
1626
  else {
1627
- $alb_clause = " AND `album` > '0' ";
1628
  }
1629
  }
1630
 
1631
  // exclude separate if required
1632
  elseif ( ! $alb_clause && wppa_switch( 'excl_sep' ) ) {
1633
  $sep_albs = '';
1634
- $temp = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums WHERE `a_parent` = '-1'", ARRAY_A );
1635
  if ( ! empty( $temp ) ) {
1636
  $t = array();
1637
  foreach ( $temp as $item ) {
@@ -1640,18 +1643,18 @@ global $wppa_session;
1640
  $sep_albs = implode( '.', $t );
1641
  $sep_albs = wppa_expand_enum( wppa_alb_to_enum_children( $sep_albs ) );
1642
  $sep_albs = str_replace( '.', ',', $sep_albs );
1643
- $alb_clause = $sep_albs ? ' AND `album` NOT IN ('.$sep_albs.') ' : '';
1644
  }
1645
  }
1646
 
1647
  // compose photo selection
1648
  if ( ! empty( $final_array ) ) {
1649
- $selection = " `id` IN (";
1650
  $selection .= implode( ',', $final_array );
1651
  $selection .= ") ";
1652
  }
1653
  else {
1654
- $selection = " `id` = '0' ";
1655
  }
1656
 
1657
  // If Related, add related count max
@@ -1670,14 +1673,14 @@ global $wppa_session;
1670
  elseif ( wppa( 'calendar' ) ) {
1671
  $order = wppa_is_int( wppa( 'start_album' ) ) ? wppa_get_photo_order( wppa( 'start_album' ) ) : wppa_get_photo_order( '0' );
1672
  if ( wppa( 'start_album' ) ) {
1673
- $alb_clause = " AND `album` IN ( ". str_replace( '.', ',', wppa_expand_enum( wppa( 'start_album' ) ) ) ." ) ";
1674
  }
1675
  else {
1676
  $alb_clause = '';
1677
  }
1678
  switch ( wppa( 'calendar' ) ) {
1679
  case 'exifdtm':
1680
- $selection = "`exifdtm` LIKE '" . strip_tags( wppa( 'caldate' ) ) . "%' AND `status` <> 'pending' AND `status` <> 'scheduled' ";
1681
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1682
  "WHERE " . $selection . $alb_clause . $order;
1683
  break;
@@ -1685,7 +1688,7 @@ global $wppa_session;
1685
  case 'timestamp':
1686
  $t1 = strval( intval( wppa( 'caldate' ) * 24*60*60 ) );
1687
  $t2 = $t1 + 24*60*60;
1688
- $selection = "`timestamp` >= $t1 AND `timestamp` < $t2 AND `status` <> 'pending' AND `status` <> 'scheduled' ";
1689
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1690
  "WHERE " . $selection . $alb_clause . $order;
1691
  break;
@@ -1693,7 +1696,7 @@ global $wppa_session;
1693
  case 'modified':
1694
  $t1 = strval( intval( wppa( 'caldate' ) * 24*60*60 ) );
1695
  $t2 = $t1 + 24*60*60;
1696
- $selection = "`modified` >= $t1 AND `modified` < $t2 AND `status` <> 'pending' AND `status` <> 'scheduled' ";
1697
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1698
  "WHERE " . $selection . $alb_clause . $order;
1699
  break;
@@ -1710,8 +1713,8 @@ global $wppa_session;
1710
  }
1711
 
1712
  // Status
1713
- $status = "`status` <> 'pending' AND `status` <> 'scheduled'";
1714
- if ( ! is_user_logged_in() ) $status .= " AND `status` <> 'private'";
1715
 
1716
  // On which album( s )?
1717
  if ( strpos( wppa( 'start_album' ), '.' ) !== false ) $allalb = wppa_series_to_array( wppa( 'start_album' ) );
@@ -1727,8 +1730,8 @@ global $wppa_session;
1727
  }
1728
  else {
1729
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1730
- "WHERE ( ( " . $status . " ) OR `owner` = %s ) " .
1731
- "AND `album` > '0' " .
1732
  wppa_get_photo_order( '0' ) .
1733
  $lim,
1734
  wppa_get_user() );
@@ -1739,13 +1742,13 @@ global $wppa_session;
1739
  elseif ( wppa_is_int( wppa( 'start_album' ) ) ) {
1740
  if ( current_user_can( 'wppa_moderate' ) ) {
1741
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1742
- "WHERE `album` = " . wppa( 'start_album' ) . " " .
1743
  wppa_get_photo_order( wppa( 'start_album' ) ) .
1744
  $lim;
1745
  }
1746
  else {
1747
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1748
- "WHERE ( ( " . $status . " ) OR `owner` = %s ) AND `album` = " . wppa( 'start_album' ) . " " .
1749
  wppa_get_photo_order( wppa( 'start_album' ) ) .
1750
  $lim,
1751
  wppa_get_user() );
@@ -1754,7 +1757,7 @@ global $wppa_session;
1754
 
1755
  // Album enumeration?
1756
  elseif ( is_array( $allalb ) ) {
1757
- $wherealbum = ' `album` IN (' . implode( ',', $allalb ) . ') ';
1758
  if ( current_user_can( 'wppa_moderate' ) ) {
1759
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1760
  "WHERE " . $wherealbum . " " .
@@ -1763,7 +1766,7 @@ global $wppa_session;
1763
  }
1764
  else {
1765
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1766
- "WHERE ( ( " . $status . " ) OR `owner` = %s ) AND " . $wherealbum . " " .
1767
  wppa_get_photo_order( '0' ) .
1768
  $lim,
1769
  wppa_get_user() );
@@ -1834,10 +1837,10 @@ global $wpdb;
1834
 
1835
  // Floating searchtoken?
1836
  if ( wppa_switch( 'wild_front' ) ) {
1837
- $idxs = $wpdb->get_col( "SELECT `" . $type . "` FROM $wpdb->wppa_index WHERE `slug` LIKE '%" . $word . "%'" );
1838
  }
1839
  else {
1840
- $idxs = $wpdb->get_col( "SELECT `" . $type . "` FROM $wpdb->wppa_index WHERE `slug` LIKE '" . $word . "%'" );
1841
  }
1842
 
1843
  // $item_array is an array of arrays with item ids per word.
@@ -1872,10 +1875,10 @@ global $wpdb;
1872
 
1873
  // Floating searchtoken?
1874
  if ( wppa_switch( 'wild_front' ) ) {
1875
- $idxs = $wpdb->get_col( "SELECT `" . $type . "` FROM $wpdb->wppa_index WHERE `slug` LIKE '%" . $word . "%'" );
1876
  }
1877
  else {
1878
- $idxs = $wpdb->get_col( "SELECT `" . $type . "` FROM $wpdb->wppa_index WHERE `slug` LIKE '" . $word . "%'" );
1879
  }
1880
 
1881
  // Find ids to exclude for the current !word
@@ -1934,7 +1937,7 @@ global $wpdb;
1934
  if ( $count_first || $invers ) {
1935
 
1936
  // Find count of the query result
1937
- $tempquery = str_replace( 'SELECT *', 'SELECT `id`', $query );
1938
  $wpdb->query( $tempquery );
1939
  $count = $wpdb->get_var( 'SELECT FOUND_ROWS()' );
1940
 
@@ -1960,7 +1963,7 @@ global $wpdb;
1960
 
1961
  // Inverse selection requested?
1962
  if ( $invers ) {
1963
- $all = $wpdb->get_results( "SELECT `id`, `album` FROM $wpdb->wppa_photos ".wppa_get_photo_order( '0' ), ARRAY_A );
1964
  if ( is_array( $thumbs ) ) foreach ( array_keys($thumbs) as $thumbs_key ) {
1965
  foreach ( array_keys($all) as $all_key ) {
1966
  if ( $thumbs[$thumbs_key]['id'] == $all[$all_key]['id'] ) {
@@ -2006,7 +2009,7 @@ function wppa_get_all_children( $root ) {
2006
  global $wpdb;
2007
 
2008
  $result = array();
2009
- $albs = $wpdb->get_results( $wpdb->prepare( "SELECT `id` FROM $wpdb->wppa_albums WHERE `a_parent` = %s", $root ), ARRAY_A );
2010
  if ( ! $albs ) return $result;
2011
  foreach ( $albs as $alb ) {
2012
  $result[] = $alb['id'];
@@ -2599,7 +2602,7 @@ global $wppa_done;
2599
  if ( wppa_opt( 'comment_notify' ) == 'upload' || wppa_opt( 'comment_notify' ) == 'upadmin' || wppa_opt( 'comment_notify' ) == 'upowner' ) {
2600
 
2601
  // Mail uploader
2602
- $uploader = $wpdb->get_var( $wpdb->prepare( "SELECT `owner` FROM $wpdb->wppa_photos WHERE `id` = %d", $id ) );
2603
  $moduser = wppa_get_user_by( 'login', $uploader );
2604
  if ( $moduser ) { // else it's an ip address ( anonymus uploader )
2605
  if ( ! in_array( $moduser->user_login, $sentto ) ) { // Already sent him?
@@ -2620,8 +2623,8 @@ global $wppa_done;
2620
  }
2621
  if ( wppa_opt( 'comment_notify' ) == 'owner' || wppa_opt( 'comment_notify' ) == 'both' || wppa_opt( 'comment_notify' ) == 'upowner' ) {
2622
  // Mail album owner
2623
- $alb = $wpdb->get_var( $wpdb->prepare( "SELECT `album` FROM $wpdb->wppa_photos WHERE `id` = %d", $id ) );
2624
- $owner = $wpdb->get_var( $wpdb->prepare( "SELECT `owner` FROM $wpdb->wppa_albums WHERE `id` = %d", $alb ) );
2625
  if ( $owner == '--- public ---' ) $owner = 'admin';
2626
  $moduser = wppa_get_user_by( 'login', $owner );
2627
  if ( ! in_array( $moduser->user_login, $sentto ) ) { // Already sent him?
@@ -4132,7 +4135,7 @@ global $wppa_children;
4132
  $children = $wppa_children[$id];
4133
  }
4134
  else {
4135
- $children = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `a_parent` = %s", $id ), ARRAY_A );
4136
  $wppa_children[$id] = $children;
4137
  }
4138
 
@@ -4165,7 +4168,7 @@ global $wppa_children;
4165
  $children = $wppa_children[$id];
4166
  }
4167
  else {
4168
- $children = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `a_parent` = %s", $id ), ARRAY_A );
4169
  $wppa_children[$id] = $children;
4170
  }
4171
 
@@ -4196,7 +4199,7 @@ global $allphotos;
4196
  else {
4197
  $albums = wppa_series_to_array( $album );
4198
  if ( is_array( $albums ) ) {
4199
- $alb = implode( " OR `album` = ", $albums );
4200
  }
4201
  else {
4202
  $alb = wppa_get_album_id_by_name( $album );
@@ -4204,10 +4207,10 @@ global $allphotos;
4204
  }
4205
 
4206
  if ( $alb ) {
4207
- $pid = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_photos WHERE `name` LIKE '%".$name."%' AND ( `album` = ".$alb." ) LIMIT 1" );
4208
  }
4209
  else {
4210
- $pid = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_photos WHERE `name` LIKE '%".$name."%' LIMIT 1" );
4211
  }
4212
 
4213
  if ( $pid ) {
@@ -4235,7 +4238,7 @@ global $allalbums;
4235
  $name = str_replace( '"', '%', $name ); // A trick for double quotes
4236
  $name = stripslashes( $name );
4237
 
4238
- $query = "SELECT * FROM $wpdb->wppa_albums WHERE `name` LIKE '%".$name."%'";
4239
  $albs = $wpdb->get_results( $query, ARRAY_A );
4240
 
4241
  if ( $albs ) {
@@ -4650,7 +4653,7 @@ global $wppa_alert;
4650
  $filename = wppa_strip_ext( $filename );
4651
 
4652
  // See if this filename with any extension already exists in this album
4653
- $id = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM $wpdb->wppa_photos WHERE `filename` LIKE %s AND `album` = %s", $filename . '.%', $alb ) );
4654
 
4655
  // Addition to an av item?
4656
  if ( $id ) {
@@ -5034,7 +5037,7 @@ global $wpdb;
5034
  $limits = wppa_get_user_upload_limits();
5035
  }
5036
  else {
5037
- $limits = $wpdb->get_var( $wpdb->prepare( "SELECT `upload_limit` FROM $wpdb->wppa_albums WHERE `id` = %s", $album ) );
5038
  }
5039
  $temp = explode( '/', $limits );
5040
  $limit_max = isset( $temp[0] ) ? $temp[0] : '0';
@@ -5046,10 +5049,10 @@ global $wpdb;
5046
 
5047
  if ( $user ) {
5048
  $owner = wppa_get_user( 'login' );
5049
- $last_upload_time = $wpdb->get_var( $wpdb->prepare( "SELECT `timestamp` FROM $wpdb->wppa_photos WHERE `owner` = %s ORDER BY `timestamp` DESC LIMIT 1", $owner ) );
5050
  }
5051
  else {
5052
- $last_upload_time = $wpdb->get_var( $wpdb->prepare( "SELECT `timestamp` FROM $wpdb->wppa_photos WHERE `album` = %s ORDER BY `timestamp` DESC LIMIT 1", $album ) );
5053
  }
5054
  $timnow = time();
5055
 
@@ -5194,7 +5197,7 @@ function wppa_zoom_in( $id ) {
5194
  function wppa_get_rating_wait_text( $id, $user ) {
5195
  global $wpdb;
5196
 
5197
- $my_youngest_rating_dtm = $wpdb->get_var( $wpdb->prepare( "SELECT `timestamp` FROM $wpdb->wppa_rating WHERE `photo` = %s AND `user` = %s ORDER BY `timestamp` DESC LIMIT 1", $id, $user ) );
5198
 
5199
  if ( ! $my_youngest_rating_dtm ) return ''; // Not votes yet
5200
 
@@ -5248,7 +5251,7 @@ global $wpdb;
5248
  * Filters the number of links found in a comment.
5249
  *
5250
  * @since 3.0.0
5251
- * @since 4.7.0 Added the `$comment` parameter.
5252
  *
5253
  * @param int $num_links The number of links found.
5254
  * @param string $url Comment author's URL. Included in allowed links total.
@@ -5349,11 +5352,11 @@ global $wpdb;
5349
  if ( ! empty( $comment_user->ID ) ) {
5350
  $ok_to_comment =
5351
  $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE user_id = %d AND comment_approved = '1'", $comment_user->ID ) ) +
5352
- $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_comments WHERE `user` = %s AND `status` = 'approved'", $user ) );
5353
  } else {
5354
  $ok_to_comment =
5355
  $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_author = %s AND comment_author_email = %s and comment_approved = '1' LIMIT 1", $user, $email ) ) +
5356
- $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_comments WHERE `email` = %s AND `status` = 'approved'", $email ) );
5357
  }
5358
  if ( ( $ok_to_comment >= 1 ) && ( empty( $mod_keys ) || false === strpos( $email, $mod_keys ) ) && ( empty( $blacklist_keys ) || false === strpos( $email, $blacklist_keys ) ) ) {
5359
  wppa_log( 'Com', 'Comment {i}' . $comment . '{/i} approved due to whitelist' );
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various functions
6
+ * Version 6.9.21
7
  *
8
  */
9
 
158
  if ( wppa( 'is_upldr' ) ) wppa( 'photos_only', true );
159
  wppa( 'is_owner', wppa_get_get( 'owner' ) );
160
  if ( wppa( 'is_owner' ) ) {
161
+ $albs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE owner = %s ", wppa( 'is_owner' ) ), ARRAY_A );
162
  wppa_cache_album( 'add', $albs );
163
  $id = '';
164
  if ( $albs ) foreach ( $albs as $alb ) {
235
  return ''; // Do nothing on a landing page without a querystring while it is also not a search operation
236
  }
237
  elseif ( wppa( 'is_autopage' ) ) {
238
+ $photo = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_photos WHERE page_id = %d LIMIT 1", wppa_get_the_id() ) );
239
  wppa( 'single_photo', $photo );
240
  if ( ! wppa( 'single_photo' ) ) {
241
+ wppa_dbg_msg( 'No photo found for page '.wppa_get_the_id(), 'red', 'force' );
242
  wppa_reset_occurrance();
243
  return ''; // Give up
244
  }
289
  if ( $limit ) {
290
  if ( $parent ) {
291
  if ( $limit ) {
292
+ $q = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE a_parent = %s ORDER BY timestamp DESC LIMIT %d", $parent, $limit );
293
  }
294
  else {
295
+ $q = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE a_parent = %s ORDER BY timestamp DESC", $parent );
296
  }
297
  }
298
  else {
299
  if ( $limit ) {
300
+ $q = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums ORDER BY timestamp DESC LIMIT %d", $limit );
301
  }
302
  else {
303
+ $q = "SELECT * FROM $wpdb->wppa_albums ORDER BY timestamp DESC";
304
  }
305
  }
306
  $albs = $wpdb->get_results( $q, ARRAY_A );
535
  }
536
  }
537
  $id = implode ( '.', $albs );
538
+ // if ( $id ) {
539
+ // wppa( 'start_album', $id );
540
+ // }
541
  if ( ! $id ) {
542
+ $id = '-9'; // Force nothing found
543
  // wppa_reset_occurrance();
544
  // return; // No children found
545
  }
883
  global $wpdb;
884
 
885
  $pagid = wppa_get_the_id();
886
+ $data = $wpdb->get_var( "SELECT post_content FROM " . $wpdb->posts . " WHERE ID = " . $pagid );
887
  $data = str_replace( array( ' ', ',', '.', "\t", "\r", "0", "x0B", "\n" ), ';', $data );
888
  $data = strip_tags( $data );
889
  $data = strip_shortcodes( $data );
957
  if ( empty( $ids ) ) {
958
  $ids = array( '0' ); // Dummy
959
  }
960
+ $query = "SELECT * FROM $wpdb->wppa_albums WHERE id IN (" . implode( ',',$ids ) . ")";
961
  $albums = $wpdb->get_results( $query, ARRAY_A );
962
  break;
963
 
964
  // Name. Name is converted to number or enum
965
  case 'n':
966
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE name = %s", $data );
967
  $albums = $wpdb->get_results( $query, ARRAY_A );
968
  break;
969
 
971
  case 't':
972
  if ( strpos( $data, '.' ) ) {
973
  $temp = explode( '.', $data );
974
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE slug = %s", $temp['0'] );
975
  $indexes = $wpdb->get_row( $query, ARRAY_A );
976
  $ids = explode( '.', wppa_expand_enum( $indexes['albums'] ) );
977
  $i = '1';
978
  while ( $i < count( $temp ) ) {
979
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE slug = %s", $temp[$i] );
980
  $indexes = $wpdb->get_row( $query, ARRAY_A );
981
  $ids = array_intersect( $ids, explode( '.', wppa_expand_enum( $indexes['albums'] ) ) );
982
  $i++;
983
  }
984
  }
985
  else {
986
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE slug = %s", $data );
987
  $indexes = $wpdb->get_row( $query, ARRAY_A );
988
  $ids = explode( '.', wppa_expand_enum( $indexes['albums'] ) );
989
  }
990
  if ( empty( $ids ) ) {
991
  $ids = array( '0' ); // Dummy
992
  }
993
+ $query = "SELECT * FROM $wpdb->wppa_albums WHERE id IN (" . implode( ',', $ids ) . ")";
994
  $albums = $wpdb->get_results( $query, ARRAY_A );
995
  break;
996
  }
1013
  }
1014
 
1015
  // Compose WHERE clause
1016
+ $selection = " id = '0' ";
1017
  foreach ( array_keys( $final_array ) as $p ) {
1018
+ $selection .= "OR id = '".$final_array[$p]."' ";
1019
  }
1020
 
1021
  // Get them
1070
  }
1071
  elseif ( wppa( 'last_albums' ) ) { // is_cover = true. For the order sequence, see remark in wppa_albums()
1072
  if ( wppa( 'last_albums_parent' ) ) {
1073
+ $q = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE a_parent = %s ORDER BY timestamp DESC LIMIT %d", wppa( 'last_albums_parent' ), wppa( 'last_albums' ) );
1074
  }
1075
  else {
1076
+ $q = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums ORDER BY timestamp DESC LIMIT %d", wppa( 'last_albums' ) );
1077
  }
1078
  $albums = $wpdb->get_results( $q, ARRAY_A );
1079
  }
1089
  elseif ( strpos( $id, '.' ) !== false ) { // Album enum
1090
  $ids = wppa_series_to_array( $id );
1091
  if ( wppa( 'is_cover' ) ) {
1092
+ $q = "SELECT * FROM $wpdb->wppa_albums WHERE id = ".implode( " OR id = ", $ids )." ".wppa_get_album_order();
1093
  }
1094
  else {
1095
+ $q = "SELECT * FROM $wpdb->wppa_albums WHERE a_parent = ".implode( " OR a_parent = ", $ids )." ".wppa_get_album_order();
1096
  }
1097
  wppa_dbg_msg( $q, 'red' );
1098
  $albums = $wpdb->get_results( $q, ARRAY_A );
1163
 
1164
  // Single album
1165
  if ( strpos( $fullalb, '.' ) == false ) {
1166
+ $album_clause = " album = $fullalb ";
1167
  }
1168
 
1169
  // Enum albums
1170
  else {
1171
  $ids = wppa_series_to_array( $fullalb );
1172
+ $album_clause = " album IN ( " . implode( ',', $ids ) . " ) ";
1173
  }
1174
  }
1175
 
1176
  // No album given, make sure trashed photos are not found
1177
  else {
1178
  $fullalb = '';
1179
+ $album_clause = " album > '0' ";
1180
  }
1181
 
1182
  // For upload link on thumbarea: if startalbum is a single real album, put it in current album
1192
  // Single image slideshow?
1193
  if ( wppa( 'start_photo' ) && wppa( 'is_single' ) ) {
1194
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1195
+ "WHERE id = %s", wppa( 'start_photo' ) );
1196
  }
1197
 
1198
  // Uploader? // lasten with owner rstriction is handled at the Lasten case
1199
  elseif ( wppa( 'is_upldr' ) && ! wppa( 'is_lasten' ) ) {
1200
+ $status = "status <> 'pending' AND status <> 'scheduled'";
1201
+ if ( ! is_user_logged_in() ) $status .= " AND status <> 'private'";
1202
 
1203
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1204
+ "WHERE " . $album_clause . " AND owner = %s AND ( " . $status . " ) " .
1205
+ "ORDER BY timestamp DESC", wppa( 'is_upldr' ) );
1206
  }
1207
 
1208
  // Topten?
1210
  $max = wppa( 'topten_count' );
1211
  switch ( wppa_opt( 'topten_sortby' ) ) {
1212
  case 'mean_rating':
1213
+ $sortby = "mean_rating DESC, rating_count DESC, views DESC";
1214
  break;
1215
  case 'rating_count':
1216
+ $sortby = "rating_count DESC, mean_rating DESC, views DESC";
1217
  break;
1218
  case 'views':
1219
+ $sortby = "views DESC, mean_rating DESC, rating_count DESC";
1220
  break;
1221
  default:
1222
  wppa_error_message( 'Unimplemented sorting method' );
1224
  break;
1225
  }
1226
  if ( wppa( 'medals_only' ) ) {
1227
+ $status = "status IN ( 'gold', 'silver', 'bronze' )";
1228
  }
1229
  else {
1230
+ $status = "status <> 'pending' AND status <> 'scheduled'";
1231
  }
1232
+ if ( ! is_user_logged_in() ) $status .= " AND status <> 'private'";
1233
 
1234
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1235
  "WHERE $album_clause AND ( $status ) " .
1243
  $max = wppa( 'featen_count' );
1244
 
1245
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1246
+ "WHERE $album_clause AND status = 'featured' " .
1247
  "ORDER BY RAND( " . wppa_get_randseed() . " ) DESC LIMIT $max";
1248
 
1249
  $count_first = false;
1252
  // Lasten?
1253
  elseif ( wppa( 'is_lasten' ) ) {
1254
  $max = wppa( 'lasten_count' );
1255
+ $status = "status <> 'pending' AND status <> 'scheduled'";
1256
+ if ( ! is_user_logged_in() ) $status .= " AND status <> 'private'";
1257
  $order_by = wppa_switch( 'lasten_use_modified' ) ? 'modified' : 'timestamp';
1258
 
1259
  // If you want only 'New' photos in the selection, the period must be <> 0;
1260
  if ( wppa_switch( 'lasten_limit_new' ) && wppa_opt( 'max_photo_newtime' ) ) {
1261
+ $newtime = " " . $order_by . " >= ".( time() - wppa_opt( 'max_photo_newtime' ) );
1262
+ $owner_restriction = ( wppa( 'is_upldr' ) ) ? "AND owner = '" . sanitize_user( wppa( 'is_upldr' ) ) . "' " : "";
1263
 
1264
  if ( current_user_can( 'wppa_moderate' ) ) {
1265
 
1267
  "WHERE ( $album_clause ) " .
1268
  "AND ( $newtime ) " .
1269
  $owner_restriction .
1270
+ "ORDER BY $order_by DESC LIMIT $max";
1271
  }
1272
  else {
1273
 
1274
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1275
  "WHERE ( $album_clause ) AND ( $status ) AND ( $newtime ) " .
1276
  $owner_restriction .
1277
+ "ORDER BY $order_by DESC LIMIT $max";
1278
  }
1279
  }
1280
 
1284
 
1285
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1286
  "WHERE $album_clause " .
1287
+ "ORDER BY $order_by DESC LIMIT $max";
1288
  }
1289
  else {
1290
 
1291
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1292
  "WHERE ( $album_clause ) AND ( $status ) " .
1293
+ "ORDER BY $order_by DESC LIMIT $max";
1294
  }
1295
  }
1296
 
1312
  $photo_ids = false;
1313
  }
1314
 
1315
+ $status = "status <> 'pending' AND status <> 'scheduled'";
1316
+ if ( ! is_user_logged_in() ) $status .= " AND status <> 'private'";
1317
 
1318
  // To keep the sequence ok ( in sequence of comments desc ), do the queries one by one
1319
  $thumbs = array();
1320
  if ( is_array( $photo_ids ) ) foreach( $photo_ids as $id ) {
1321
+ $temp = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE ".$status." AND album > '0' AND id = %s", $id ), ARRAY_A );
1322
  if ( $temp ) {
1323
  $thumbs[] = $temp;
1324
  }
1342
  if ( strpos( wppa( 'is_tag' ), ';' ) ) $andor = 'OR';
1343
 
1344
  // Compute status clause for query
1345
+ $status = "status <> 'pending' AND status <> 'scheduled'";
1346
+ if ( ! is_user_logged_in() ) $status .= " AND status <> 'private'";
1347
 
1348
  // Define tags clause for query
1349
  $seltags = explode( ',', trim( wppa_sanitize_tags( wppa( 'is_tag' ) ), ',' ) );
1353
  if ( ! $first ) {
1354
  $tags_like .= " " . $andor;
1355
  }
1356
+ $tags_like .= " tags LIKE '%,".$tag.",%'";
1357
  $first = false;
1358
  }
1359
 
1362
  $fac = ' AND ' . $album_clause . ' ';
1363
  }
1364
  else {
1365
+ $fac = " AND album > '0' ";
1366
  }
1367
 
1368
  // Prepare the query
1394
  $data = implode( ',', $data );
1395
  $ss_data[3] = $data;
1396
 
1397
+ $status = "status <> 'pending' AND status <> 'scheduled'";
1398
+ if ( ! is_user_logged_in() ) $status .= " AND status <> 'private'";
1399
 
1400
  switch ( $ss_data['1'] ) {
1401
 
1408
  }
1409
  if ( current_user_can( 'wppa_moderate' ) ) {
1410
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1411
+ "WHERE name " . $is . " %s " .
1412
+ "AND album > '0' " .
1413
  wppa_get_photo_order( '0' ), $data );
1414
  }
1415
  else {
1416
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1417
+ "WHERE name " . $is . " %s " .
1418
+ "AND album > '0' " .
1419
  "AND " . $status . " " .
1420
  wppa_get_photo_order( '0' ), $data );
1421
  }
1425
  case 'o':
1426
  if ( current_user_can( 'wppa_moderate' ) ) {
1427
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1428
+ "WHERE owner = %s " .
1429
+ "AND album > '0' " .
1430
  wppa_get_photo_order( '0' ), $data );
1431
  }
1432
  else {
1433
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1434
+ "WHERE owner = %s " .
1435
+ "AND album > '0' " .
1436
  "AND " . $status . " " .
1437
  wppa_get_photo_order( '0' ), $data );
1438
  }
1456
  if ( count( $tagids ) > '0' ) {
1457
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1458
  "WHERE ".$status." " .
1459
+ "AND id IN (" . implode( ',',$tagids ) . ") " .
1460
+ "AND album > '0' ";
1461
  }
1462
  break;
1463
 
1475
  $is = 'LIKE';
1476
  }
1477
  }
1478
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE slug ".$is." %s", $temp['0'] );
1479
  $indexes = $wpdb->get_results( $query, ARRAY_A );
1480
  $ids = array();
1481
  foreach( $indexes as $item ) {
1491
  }
1492
  }
1493
 
1494
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE slug ".$is." %s", $temp[$i] );
1495
  $indexes = $wpdb->get_results( $query, ARRAY_A );
1496
  $deltaids = array();
1497
  foreach( $indexes as $item ) {
1510
  $is = 'LIKE';
1511
  }
1512
  }
1513
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE slug ".$is." %s", $data );
1514
  $indexes = $wpdb->get_results( $query, ARRAY_A );
1515
  $ids = array();
1516
  foreach( $indexes as $item ) {
1522
  }
1523
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1524
  "WHERE ".$status." " .
1525
+ "AND album > '0' " .
1526
+ "AND id IN (" . trim( implode( ',', $ids ), ',' ) . ")";
1527
  break;
1528
 
1529
  // Iptc
1531
  $itag = str_replace( 'H', '#', $ss_data['2'] );
1532
  $desc = $ss_data['3'];
1533
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_iptc " .
1534
+ "WHERE tag = %s AND description = %s", $itag, $desc );
1535
  $iptclines = $wpdb->get_results( $query, ARRAY_A );
1536
  $ids = '0';
1537
  if ( is_array( $iptclines ) ) foreach( $iptclines as $item ) {
1539
  }
1540
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1541
  "WHERE ".$status." " .
1542
+ "AND album > '0' " .
1543
+ "AND id IN (" . $ids . ")";
1544
  break;
1545
 
1546
  // Exif
1550
  $desc = $ss_data['3'];
1551
  // if ( $brand ) {
1552
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_exif " .
1553
+ "WHERE tag = %s AND f_description = %s AND brand = %s", $etag, $desc, $brand );
1554
  // }
1555
  // else {
1556
  // $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_exif " .
1557
+ // "WHERE tag = %s AND f_description = %s", $etag, $desc );
1558
  // }
1559
  $exiflines = $wpdb->get_results( $query, ARRAY_A );
1560
  $ids = '0';
1563
  }
1564
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1565
  "WHERE ".$status." " .
1566
+ "AND album > '0' " .
1567
+ "AND id IN (" . $ids . ")";
1568
  break;
1569
  }
1570
  }
1572
  // Search?
1573
  elseif ( wppa( 'src' ) ) { // Searching
1574
 
1575
+ $status = "status <> 'pending' AND status <> 'scheduled'";
1576
+ if ( ! is_user_logged_in() ) $status .= " AND status <> 'private'";
1577
 
1578
  $searchstring = wppa( 'searchstring' );
1579
  if ( ! empty ( $wppa_session['use_searchstring'] ) ) $searchstring = $wppa_session['use_searchstring'];
1583
 
1584
  // Remove scheduled and pending and trashed when not can moderate
1585
  if ( ! current_user_can( 'wppa_moderate' ) ) {
1586
+ $needmod = $wpdb->get_col( "SELECT id FROM $wpdb->wppa_photos WHERE status = 'scheduled' OR status = 'pending' OR album <= '-9'" );
1587
  if ( is_array( $needmod ) ) {
1588
  $final_array = array_diff( $final_array, $needmod );
1589
  }
1591
 
1592
  // Remove private and trashed when not logged in
1593
  if ( ! is_user_logged_in() ) {
1594
+ $needlogin = $wpdb->get_col( "SELECT id FROM $wpdb->wppa_photos WHERE status = 'private' OR album <= '-9'" );
1595
  if ( is_array( $needlogin ) ) {
1596
  $final_array = array_diff( $final_array, $needlogin );
1597
  }
1615
  $root = $wppa_session['search_root'];
1616
  $root_albs = wppa_expand_enum( wppa_alb_to_enum_children( $root ) );
1617
  $root_albs = str_replace( '.', ',', $root_albs );
1618
+ $alb_clause = $root_albs ? ' AND album IN ('.$root_albs.') ' : '';
1619
  }
1620
 
1621
  // Maybe cats limitation
1622
  elseif ( wppa( 'catbox' ) ) {
1623
 
1624
+ $catalbs = $wpdb->get_col( "SELECT id FROM $wpdb->wppa_albums WHERE cats LIKE '%" . wppa( 'catbox' ) . "%' " );
1625
 
1626
  if ( ! empty( $catalbs ) ) {
1627
+ $alb_clause = " AND album IN ( " . implode( ',', $catalbs ) . " ) ";
1628
  }
1629
  else {
1630
+ $alb_clause = " AND album > '0' ";
1631
  }
1632
  }
1633
 
1634
  // exclude separate if required
1635
  elseif ( ! $alb_clause && wppa_switch( 'excl_sep' ) ) {
1636
  $sep_albs = '';
1637
+ $temp = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums WHERE a_parent = '-1'", ARRAY_A );
1638
  if ( ! empty( $temp ) ) {
1639
  $t = array();
1640
  foreach ( $temp as $item ) {
1643
  $sep_albs = implode( '.', $t );
1644
  $sep_albs = wppa_expand_enum( wppa_alb_to_enum_children( $sep_albs ) );
1645
  $sep_albs = str_replace( '.', ',', $sep_albs );
1646
+ $alb_clause = $sep_albs ? ' AND album NOT IN ('.$sep_albs.') ' : '';
1647
  }
1648
  }
1649
 
1650
  // compose photo selection
1651
  if ( ! empty( $final_array ) ) {
1652
+ $selection = " id IN (";
1653
  $selection .= implode( ',', $final_array );
1654
  $selection .= ") ";
1655
  }
1656
  else {
1657
+ $selection = " id = '0' ";
1658
  }
1659
 
1660
  // If Related, add related count max
1673
  elseif ( wppa( 'calendar' ) ) {
1674
  $order = wppa_is_int( wppa( 'start_album' ) ) ? wppa_get_photo_order( wppa( 'start_album' ) ) : wppa_get_photo_order( '0' );
1675
  if ( wppa( 'start_album' ) ) {
1676
+ $alb_clause = " AND album IN ( ". str_replace( '.', ',', wppa_expand_enum( wppa( 'start_album' ) ) ) ." ) ";
1677
  }
1678
  else {
1679
  $alb_clause = '';
1680
  }
1681
  switch ( wppa( 'calendar' ) ) {
1682
  case 'exifdtm':
1683
+ $selection = "exifdtm LIKE '" . strip_tags( wppa( 'caldate' ) ) . "%' AND status <> 'pending' AND status <> 'scheduled' ";
1684
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1685
  "WHERE " . $selection . $alb_clause . $order;
1686
  break;
1688
  case 'timestamp':
1689
  $t1 = strval( intval( wppa( 'caldate' ) * 24*60*60 ) );
1690
  $t2 = $t1 + 24*60*60;
1691
+ $selection = "timestamp >= $t1 AND timestamp < $t2 AND status <> 'pending' AND status <> 'scheduled' ";
1692
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1693
  "WHERE " . $selection . $alb_clause . $order;
1694
  break;
1696
  case 'modified':
1697
  $t1 = strval( intval( wppa( 'caldate' ) * 24*60*60 ) );
1698
  $t2 = $t1 + 24*60*60;
1699
+ $selection = "modified >= $t1 AND modified < $t2 AND status <> 'pending' AND status <> 'scheduled' ";
1700
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1701
  "WHERE " . $selection . $alb_clause . $order;
1702
  break;
1713
  }
1714
 
1715
  // Status
1716
+ $status = "status <> 'pending' AND status <> 'scheduled'";
1717
+ if ( ! is_user_logged_in() ) $status .= " AND status <> 'private'";
1718
 
1719
  // On which album( s )?
1720
  if ( strpos( wppa( 'start_album' ), '.' ) !== false ) $allalb = wppa_series_to_array( wppa( 'start_album' ) );
1730
  }
1731
  else {
1732
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1733
+ "WHERE ( ( " . $status . " ) OR owner = %s ) " .
1734
+ "AND album > '0' " .
1735
  wppa_get_photo_order( '0' ) .
1736
  $lim,
1737
  wppa_get_user() );
1742
  elseif ( wppa_is_int( wppa( 'start_album' ) ) ) {
1743
  if ( current_user_can( 'wppa_moderate' ) ) {
1744
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1745
+ "WHERE album = " . wppa( 'start_album' ) . " " .
1746
  wppa_get_photo_order( wppa( 'start_album' ) ) .
1747
  $lim;
1748
  }
1749
  else {
1750
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1751
+ "WHERE ( ( " . $status . " ) OR owner = %s ) AND album = " . wppa( 'start_album' ) . " " .
1752
  wppa_get_photo_order( wppa( 'start_album' ) ) .
1753
  $lim,
1754
  wppa_get_user() );
1757
 
1758
  // Album enumeration?
1759
  elseif ( is_array( $allalb ) ) {
1760
+ $wherealbum = ' album IN (' . implode( ',', $allalb ) . ') ';
1761
  if ( current_user_can( 'wppa_moderate' ) ) {
1762
  $query = "SELECT * FROM $wpdb->wppa_photos " .
1763
  "WHERE " . $wherealbum . " " .
1766
  }
1767
  else {
1768
  $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1769
+ "WHERE ( ( " . $status . " ) OR owner = %s ) AND " . $wherealbum . " " .
1770
  wppa_get_photo_order( '0' ) .
1771
  $lim,
1772
  wppa_get_user() );
1837
 
1838
  // Floating searchtoken?
1839
  if ( wppa_switch( 'wild_front' ) ) {
1840
+ $idxs = $wpdb->get_col( "SELECT " . $type . " FROM $wpdb->wppa_index WHERE slug LIKE '%" . $word . "%'" );
1841
  }
1842
  else {
1843
+ $idxs = $wpdb->get_col( "SELECT " . $type . " FROM $wpdb->wppa_index WHERE slug LIKE '" . $word . "%'" );
1844
  }
1845
 
1846
  // $item_array is an array of arrays with item ids per word.
1875
 
1876
  // Floating searchtoken?
1877
  if ( wppa_switch( 'wild_front' ) ) {
1878
+ $idxs = $wpdb->get_col( "SELECT " . $type . " FROM $wpdb->wppa_index WHERE slug LIKE '%" . $word . "%'" );
1879
  }
1880
  else {
1881
+ $idxs = $wpdb->get_col( "SELECT " . $type . " FROM $wpdb->wppa_index WHERE slug LIKE '" . $word . "%'" );
1882
  }
1883
 
1884
  // Find ids to exclude for the current !word
1937
  if ( $count_first || $invers ) {
1938
 
1939
  // Find count of the query result
1940
+ $tempquery = str_replace( 'SELECT *', 'SELECT id', $query );
1941
  $wpdb->query( $tempquery );
1942
  $count = $wpdb->get_var( 'SELECT FOUND_ROWS()' );
1943
 
1963
 
1964
  // Inverse selection requested?
1965
  if ( $invers ) {
1966
+ $all = $wpdb->get_results( "SELECT id, album FROM $wpdb->wppa_photos ".wppa_get_photo_order( '0' ), ARRAY_A );
1967
  if ( is_array( $thumbs ) ) foreach ( array_keys($thumbs) as $thumbs_key ) {
1968
  foreach ( array_keys($all) as $all_key ) {
1969
  if ( $thumbs[$thumbs_key]['id'] == $all[$all_key]['id'] ) {
2009
  global $wpdb;
2010
 
2011
  $result = array();
2012
+ $albs = $wpdb->get_results( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_albums WHERE a_parent = %s", $root ), ARRAY_A );
2013
  if ( ! $albs ) return $result;
2014
  foreach ( $albs as $alb ) {
2015
  $result[] = $alb['id'];
2602
  if ( wppa_opt( 'comment_notify' ) == 'upload' || wppa_opt( 'comment_notify' ) == 'upadmin' || wppa_opt( 'comment_notify' ) == 'upowner' ) {
2603
 
2604
  // Mail uploader
2605
+ $uploader = $wpdb->get_var( $wpdb->prepare( "SELECT owner FROM $wpdb->wppa_photos WHERE id = %d", $id ) );
2606
  $moduser = wppa_get_user_by( 'login', $uploader );
2607
  if ( $moduser ) { // else it's an ip address ( anonymus uploader )
2608
  if ( ! in_array( $moduser->user_login, $sentto ) ) { // Already sent him?
2623
  }
2624
  if ( wppa_opt( 'comment_notify' ) == 'owner' || wppa_opt( 'comment_notify' ) == 'both' || wppa_opt( 'comment_notify' ) == 'upowner' ) {
2625
  // Mail album owner
2626
+ $alb = $wpdb->get_var( $wpdb->prepare( "SELECT album FROM $wpdb->wppa_photos WHERE id = %d", $id ) );
2627
+ $owner = $wpdb->get_var( $wpdb->prepare( "SELECT owner FROM $wpdb->wppa_albums WHERE id = %d", $alb ) );
2628
  if ( $owner == '--- public ---' ) $owner = 'admin';
2629
  $moduser = wppa_get_user_by( 'login', $owner );
2630
  if ( ! in_array( $moduser->user_login, $sentto ) ) { // Already sent him?
4135
  $children = $wppa_children[$id];
4136
  }
4137
  else {
4138
+ $children = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE a_parent = %s", $id ), ARRAY_A );
4139
  $wppa_children[$id] = $children;
4140
  }
4141
 
4168
  $children = $wppa_children[$id];
4169
  }
4170
  else {
4171
+ $children = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE a_parent = %s", $id ), ARRAY_A );
4172
  $wppa_children[$id] = $children;
4173
  }
4174
 
4199
  else {
4200
  $albums = wppa_series_to_array( $album );
4201
  if ( is_array( $albums ) ) {
4202
+ $alb = implode( " OR album = ", $albums );
4203
  }
4204
  else {
4205
  $alb = wppa_get_album_id_by_name( $album );
4207
  }
4208
 
4209
  if ( $alb ) {
4210
+ $pid = $wpdb->get_var( "SELECT id FROM $wpdb->wppa_photos WHERE name LIKE '%".$name."%' AND ( album = ".$alb." ) LIMIT 1" );
4211
  }
4212
  else {
4213
+ $pid = $wpdb->get_var( "SELECT id FROM $wpdb->wppa_photos WHERE name LIKE '%".$name."%' LIMIT 1" );
4214
  }
4215
 
4216
  if ( $pid ) {
4238
  $name = str_replace( '"', '%', $name ); // A trick for double quotes
4239
  $name = stripslashes( $name );
4240
 
4241
+ $query = "SELECT * FROM $wpdb->wppa_albums WHERE name LIKE '%".$name."%'";
4242
  $albs = $wpdb->get_results( $query, ARRAY_A );
4243
 
4244
  if ( $albs ) {
4653
  $filename = wppa_strip_ext( $filename );
4654
 
4655
  // See if this filename with any extension already exists in this album
4656
+ $id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_photos WHERE filename LIKE %s AND album = %s", $filename . '.%', $alb ) );
4657
 
4658
  // Addition to an av item?
4659
  if ( $id ) {
5037
  $limits = wppa_get_user_upload_limits();
5038
  }
5039
  else {
5040
+ $limits = $wpdb->get_var( $wpdb->prepare( "SELECT upload_limit FROM $wpdb->wppa_albums WHERE id = %s", $album ) );
5041
  }
5042
  $temp = explode( '/', $limits );
5043
  $limit_max = isset( $temp[0] ) ? $temp[0] : '0';
5049
 
5050
  if ( $user ) {
5051
  $owner = wppa_get_user( 'login' );
5052
+ $last_upload_time = $wpdb->get_var( $wpdb->prepare( "SELECT timestamp FROM $wpdb->wppa_photos WHERE owner = %s ORDER BY timestamp DESC LIMIT 1", $owner ) );
5053
  }
5054
  else {
5055
+ $last_upload_time = $wpdb->get_var( $wpdb->prepare( "SELECT timestamp FROM $wpdb->wppa_photos WHERE album = %s ORDER BY timestamp DESC LIMIT 1", $album ) );
5056
  }
5057
  $timnow = time();
5058
 
5197
  function wppa_get_rating_wait_text( $id, $user ) {
5198
  global $wpdb;
5199
 
5200
+ $my_youngest_rating_dtm = $wpdb->get_var( $wpdb->prepare( "SELECT timestamp FROM $wpdb->wppa_rating WHERE photo = %s AND user = %s ORDER BY timestamp DESC LIMIT 1", $id, $user ) );
5201
 
5202
  if ( ! $my_youngest_rating_dtm ) return ''; // Not votes yet
5203
 
5251
  * Filters the number of links found in a comment.
5252
  *
5253
  * @since 3.0.0
5254
+ * @since 4.7.0 Added the $comment parameter.
5255
  *
5256
  * @param int $num_links The number of links found.
5257
  * @param string $url Comment author's URL. Included in allowed links total.
5352
  if ( ! empty( $comment_user->ID ) ) {
5353
  $ok_to_comment =
5354
  $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE user_id = %d AND comment_approved = '1'", $comment_user->ID ) ) +
5355
+ $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_comments WHERE user = %s AND status = 'approved'", $user ) );
5356
  } else {
5357
  $ok_to_comment =
5358
  $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_author = %s AND comment_author_email = %s and comment_approved = '1' LIMIT 1", $user, $email ) ) +
5359
+ $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_comments WHERE email = %s AND status = 'approved'", $email ) );
5360
  }
5361
  if ( ( $ok_to_comment >= 1 ) && ( empty( $mod_keys ) || false === strpos( $email, $mod_keys ) ) && ( empty( $blacklist_keys ) || false === strpos( $email, $blacklist_keys ) ) ) {
5362
  wppa_log( 'Com', 'Comment {i}' . $comment . '{/i} approved due to whitelist' );
wppa-htaccess.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various funcions
6
- * Version 6.9.16
7
  *
8
  */
9
 
@@ -159,7 +159,7 @@ global $wpdb;
159
  // RewriteBase /wp-content/wppa-pl
160
  fwrite( $file, "\n" . 'RewriteBase /' . str_replace( ABSPATH, '', $pl_root ) );
161
 
162
- $albs = $wpdb->get_results( "SELECT `id`, `name` FROM $wpdb->wppa_albums ORDER BY `name` DESC", ARRAY_A );
163
 
164
  if ( $albs ) foreach( $albs as $alb ) {
165
 
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various funcions
6
+ * Version 6.9.21
7
  *
8
  */
9
 
159
  // RewriteBase /wp-content/wppa-pl
160
  fwrite( $file, "\n" . 'RewriteBase /' . str_replace( ABSPATH, '', $pl_root ) );
161
 
162
+ $albs = $wpdb->get_results( "SELECT id, name FROM $wpdb->wppa_albums ORDER BY name DESC", ARRAY_A );
163
 
164
  if ( $albs ) foreach( $albs as $alb ) {
165
 
wppa-import.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the import pages and functions
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -80,17 +80,17 @@ global $wppa_session;
80
  // Verify last albums still exist
81
  $alb = get_option( 'wppa-photo-album-import-'.wppa_get_user(), '0' );
82
  if ( $alb ) {
83
- $exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE `id` = %s", $alb ) );
84
  if ( ! $exists ) update_option( 'wppa-photo-album-import-'.wppa_get_user(), '0' );
85
  }
86
  $alb = get_option( 'wppa-video-album-import-'.wppa_get_user(), '0' );
87
  if ( $alb ) {
88
- $exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE `id` = %s", $alb ) );
89
  if ( ! $exists ) update_option( 'wppa-video-album-import-'.wppa_get_user(), '0' );
90
  }
91
  $alb = get_option( 'wppa-audio-album-import-'.wppa_get_user(), '0' );
92
  if ( $alb ) {
93
- $exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE `id` = %s", $alb ) );
94
  if ( ! $exists ) update_option( 'wppa-audio-album-import-'.wppa_get_user(), '0' );
95
  }
96
 
@@ -816,7 +816,7 @@ global $wppa_session;
816
 
817
  if ( wppa( 'is_wppa_tree' ) ) {
818
  $t = explode( 'uploads/wppa/', $file );
819
- echo basename( str_replace( '/', '', $t[1] ) );
820
  }
821
  else {
822
  echo wppa_sanitize_file_name( basename( $file ) );
@@ -1739,8 +1739,8 @@ global $wppa_supported_audio_extensions;
1739
  } // while !foef
1740
  fclose( $handle );
1741
  if ( wppa_get_album_id( $name ) != '' ) {
1742
- wppa_warning_message( 'Album already exists '.stripslashes( $name ) );
1743
- if ( $dela ) unlink( $album );
1744
  }
1745
  else {
1746
  $id = basename( $album );
@@ -1762,7 +1762,7 @@ global $wppa_supported_audio_extensions;
1762
  wppa_set_last_album( $id );
1763
  wppa_index_add( 'album', $id );
1764
  wppa_ok_message( __( 'Album #', 'wp-photo-album-plus') . ' ' . $id . ': '.stripslashes( $name ).' ' . __( 'Added.', 'wp-photo-album-plus') );
1765
- if ( $dela ) unlink( $album );
1766
  $acount++;
1767
  wppa_clear_cache();
1768
  wppa_invalidate_treecounts( $id );
@@ -1860,8 +1860,8 @@ global $wppa_supported_audio_extensions;
1860
  $old_photo = wppa_strip_ext( wppa_get_photo_path( $is_poster, false ) );
1861
  $old_thumb = wppa_strip_ext( wppa_get_thumb_path( $is_poster, false ) );
1862
  foreach ( $wppa_supported_photo_extensions as $pext ) {
1863
- if ( is_file( $old_photo . '.' . $pext ) ) unlink( $old_photo . '.' . $pext );
1864
- if ( is_file( $old_thumb . '.' . $pext ) ) unlink( $old_thumb . '.' . $pext );
1865
  }
1866
 
1867
  // Clear sizes on db
@@ -1880,7 +1880,7 @@ global $wppa_supported_audio_extensions;
1880
  $pcount++;
1881
  $totpcount += $bret;
1882
  if ( $delp ) {
1883
- unlink( $file );
1884
  }
1885
  }
1886
  else { // Failed
@@ -1888,7 +1888,7 @@ global $wppa_supported_audio_extensions;
1888
  wppa_error_message('Failed to add poster for item '.$is_poster);
1889
  }
1890
  if ( $delf ) {
1891
- unlink( $file );
1892
  }
1893
  }
1894
  }
@@ -1907,12 +1907,12 @@ global $wppa_supported_audio_extensions;
1907
  $pcount++;
1908
  $totpcount += $iret;
1909
  if ( $delp ) {
1910
- unlink( $unsanitized_path_name );
1911
  }
1912
  }
1913
  else {
1914
  if ( $delf ) {
1915
- unlink( $unsanitized_path_name );
1916
  }
1917
  }
1918
  }
@@ -1932,7 +1932,7 @@ global $wppa_supported_audio_extensions;
1932
  wppa_warning_message( sprintf( __( 'Photo %s already exists in album %s. (1)', 'wp-photo-album-plus'), $id, $alb ) );
1933
  wppa( 'ajax_import_files_error', __( 'Duplicate', 'wp-photo-album-plus') );
1934
  if ( $delf ) {
1935
- unlink( $file );
1936
  }
1937
  }
1938
  else {
@@ -1945,8 +1945,10 @@ global $wppa_supported_audio_extensions;
1945
  }
1946
  $pcount++;
1947
  if ( $delp ) {
1948
- unlink( $unsanitized_path_name );
1949
- if ( is_file( $meta ) ) unlink( $meta );
 
 
1950
  }
1951
  wppa_set_default_name( $id, stripslashes( $name ) );
1952
 
@@ -1962,7 +1964,7 @@ global $wppa_supported_audio_extensions;
1962
  else {
1963
  wppa_error_message( __( 'Error inserting photo', 'wp-photo-album-plus') . ' ' . basename( $file ) . '.' );
1964
  if ( $delf ) {
1965
- unlink( $unsanitized_path_name );
1966
  }
1967
  }
1968
  }
@@ -2053,7 +2055,7 @@ global $wppa_supported_audio_extensions;
2053
 
2054
  // Remove old version if already exists
2055
  if ( is_file( $newpath ) ) {
2056
- unlink( $newpath );
2057
  }
2058
  rename( $file, $newpath );
2059
  }
@@ -2121,7 +2123,9 @@ global $wppa_supported_audio_extensions;
2121
  // Add audio filetype
2122
  $newpath = wppa_strip_ext( wppa_get_photo_path( $id, false ) ).'.'.$ext;
2123
  wppa_copy( $file, $newpath );
2124
- if ( $delu ) unlink( $file );
 
 
2125
  if ( wppa( 'ajax' ) ) {
2126
  wppa( 'ajax_import_files_done', true );
2127
  }
@@ -2275,7 +2279,7 @@ global $wppa_supported_audio_extensions;
2275
 
2276
  // Interprete and verify header. All fields from .csv MUST be in table fields, else fail
2277
  $csv_fields = str_getcsv( $header );
2278
- $db_fields = $wpdb->get_results( "DESCRIBE `" . $is_db_table . "`", ARRAY_A );
2279
 
2280
  foreach( $csv_fields as $csv_field ) {
2281
  $ok = false;
@@ -2313,14 +2317,14 @@ global $wppa_supported_audio_extensions;
2313
 
2314
  wppa_dbg_msg( 'Processing id '.$id );
2315
 
2316
- $existing_data = $wpdb->get_row( "SELECT * FROM `" . $is_db_table . "` WHERE `id` = $id", ARRAY_A );
2317
 
2318
  // If entry exists:
2319
  // 1. save existing data,
2320
  // 2. remove entry,
2321
  if ( $existing_data ) {
2322
  $data = $existing_data;
2323
- $wpdb->query( "DELETE FROM `" . $is_db_table . "` WHERE `id` = $id" );
2324
  }
2325
 
2326
  // Entry does not / no longer exist, add csv data to data array
@@ -2452,13 +2456,13 @@ global $wppa_supported_audio_extensions;
2452
  $search = $data_arr[0];
2453
  switch ( strtolower($captions[0]) ) {
2454
  case 'photoname':
2455
- $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `name` = %s", $data_arr[0] ), ARRAY_A );
2456
  break;
2457
  case 'filename':
2458
- $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `filename` = %s", $data_arr[0] ), ARRAY_A );
2459
  break;
2460
  case 'name':
2461
- $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `name` = %s OR `filename` = %s", $data_arr[0], $data_arr[0] ), ARRAY_A );
2462
  break;
2463
  }
2464
  if ( $photos ) {
@@ -2616,11 +2620,11 @@ global $wppa_supported_audio_extensions;
2616
  $csvcount++;
2617
 
2618
  // Remove tempfile
2619
- unlink( $tempfile );
2620
 
2621
  // Remove orig file
2622
  if ( ! $this_skipped && ! wppa_is_time_up() ) {
2623
- unlink( $file );
2624
  }
2625
  }
2626
  }
@@ -2827,7 +2831,6 @@ function wppa_extract( $xpath, $delz ) {
2827
  $path = wppa_sanitize_file_name( $xpath );
2828
  if ( ! file_exists( $xpath ) ) {
2829
  wppa_error_message( 'Zipfile '.$path.' does not exist.' );
2830
- // unlink( $xpath );
2831
  $err = '4';
2832
  return $err;
2833
  }
@@ -2859,7 +2862,9 @@ function wppa_extract( $xpath, $delz ) {
2859
 
2860
  $zip->close();
2861
  wppa_ok_message( sprintf( __( 'Zipfile %s processed. %s files extracted, %s files skipped.', 'wp-photo-album-plus'), basename( $path ), $done, $skip ) );
2862
- if ( $delz ) unlink( $xpath );
 
 
2863
  } else {
2864
  wppa_error_message( __( 'Failed to extract', 'wp-photo-album-plus').' '.$path );
2865
  $err = '1';
@@ -2928,7 +2933,7 @@ global $wppa_session;
2928
  $pagid = wp_insert_post( $my_post );
2929
  if ( $pagid ) {
2930
  wppa_ok_message( sprintf( __( 'Page <a href="%s" target="_blank" >%s</a> created.', 'wp-photo-album-plus'), home_url().'?page_id='.$pagid, $name ) );
2931
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_albums SET `cover_linkpage` = %s WHERE `id` = %s", $pagid, $alb ) );
2932
  }
2933
  else {
2934
  wppa_error_message( __( 'Could not create page.', 'wp-photo-album-plus') );
@@ -2949,7 +2954,7 @@ global $wppa_session;
2949
  // If we find a .csv file, move it to our depot and give a warning message
2950
  if ( wppa_get_ext( $photofile ) == 'csv' ) {
2951
  wppa_copy( $photofile, WPPA_DEPOT_PATH . '/' . basename( $photofile ) );
2952
- @ unlink( $photofile );
2953
  wppa_warning_message( sprintf( __( '.csv file %s has been moved to your depot.', 'wp-photo-album-plus' ), basename( $photofile ) ) );
2954
  }
2955
  elseif ( wppa_albumphoto_exists( $alb, basename( $photofile ) ) ) {
@@ -2965,7 +2970,7 @@ global $wppa_session;
2965
  }
2966
  }
2967
  if ( ! wppa_switch( 'keep_import_files' ) ) {
2968
- @ unlink( $photofile );
2969
  }
2970
  $wppa_session[$photofile] = true;
2971
  }
@@ -2984,7 +2989,7 @@ global $wppa_session;
2984
  }
2985
  }
2986
  }
2987
- @ rmdir( $file ); // Try to remove dir, ignore error
2988
  }
2989
  else {
2990
  wppa_dbg_msg( 'Invalid file in wppa_import_dir_to_album(): '.$file );
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the import pages and functions
6
+ * Version 6.9.21
7
  *
8
  */
9
 
80
  // Verify last albums still exist
81
  $alb = get_option( 'wppa-photo-album-import-'.wppa_get_user(), '0' );
82
  if ( $alb ) {
83
+ $exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE id = %s", $alb ) );
84
  if ( ! $exists ) update_option( 'wppa-photo-album-import-'.wppa_get_user(), '0' );
85
  }
86
  $alb = get_option( 'wppa-video-album-import-'.wppa_get_user(), '0' );
87
  if ( $alb ) {
88
+ $exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE id = %s", $alb ) );
89
  if ( ! $exists ) update_option( 'wppa-video-album-import-'.wppa_get_user(), '0' );
90
  }
91
  $alb = get_option( 'wppa-audio-album-import-'.wppa_get_user(), '0' );
92
  if ( $alb ) {
93
+ $exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE id = %s", $alb ) );
94
  if ( ! $exists ) update_option( 'wppa-audio-album-import-'.wppa_get_user(), '0' );
95
  }
96
 
816
 
817
  if ( wppa( 'is_wppa_tree' ) ) {
818
  $t = explode( 'uploads/wppa/', $file );
819
+ echo sanitize_file_name( basename( str_replace( '/', '', $t[1] ) ) );
820
  }
821
  else {
822
  echo wppa_sanitize_file_name( basename( $file ) );
1739
  } // while !foef
1740
  fclose( $handle );
1741
  if ( wppa_get_album_id( $name ) != '' ) {
1742
+ wppa_warning_message( 'Album already exists ' . stripslashes( $name ) );
1743
+ if ( $dela ) wppa_unlink( $album );
1744
  }
1745
  else {
1746
  $id = basename( $album );
1762
  wppa_set_last_album( $id );
1763
  wppa_index_add( 'album', $id );
1764
  wppa_ok_message( __( 'Album #', 'wp-photo-album-plus') . ' ' . $id . ': '.stripslashes( $name ).' ' . __( 'Added.', 'wp-photo-album-plus') );
1765
+ if ( $dela ) wppa_unlink( $album );
1766
  $acount++;
1767
  wppa_clear_cache();
1768
  wppa_invalidate_treecounts( $id );
1860
  $old_photo = wppa_strip_ext( wppa_get_photo_path( $is_poster, false ) );
1861
  $old_thumb = wppa_strip_ext( wppa_get_thumb_path( $is_poster, false ) );
1862
  foreach ( $wppa_supported_photo_extensions as $pext ) {
1863
+ if ( is_file( $old_photo . '.' . $pext ) ) wppa_unlink( $old_photo . '.' . $pext );
1864
+ if ( is_file( $old_thumb . '.' . $pext ) ) wppa_unlink( $old_thumb . '.' . $pext );
1865
  }
1866
 
1867
  // Clear sizes on db
1880
  $pcount++;
1881
  $totpcount += $bret;
1882
  if ( $delp ) {
1883
+ wppa_unlink( $file );
1884
  }
1885
  }
1886
  else { // Failed
1888
  wppa_error_message('Failed to add poster for item '.$is_poster);
1889
  }
1890
  if ( $delf ) {
1891
+ wppa_unlink( $file );
1892
  }
1893
  }
1894
  }
1907
  $pcount++;
1908
  $totpcount += $iret;
1909
  if ( $delp ) {
1910
+ wppa_unlink( $unsanitized_path_name );
1911
  }
1912
  }
1913
  else {
1914
  if ( $delf ) {
1915
+ wppa_unlink( $unsanitized_path_name );
1916
  }
1917
  }
1918
  }
1932
  wppa_warning_message( sprintf( __( 'Photo %s already exists in album %s. (1)', 'wp-photo-album-plus'), $id, $alb ) );
1933
  wppa( 'ajax_import_files_error', __( 'Duplicate', 'wp-photo-album-plus') );
1934
  if ( $delf ) {
1935
+ wppa_unlink( $file );
1936
  }
1937
  }
1938
  else {
1945
  }
1946
  $pcount++;
1947
  if ( $delp ) {
1948
+ wppa_unlink( $unsanitized_path_name );
1949
+ if ( is_file( $meta ) ) {
1950
+ wppa_unlink( $meta );
1951
+ }
1952
  }
1953
  wppa_set_default_name( $id, stripslashes( $name ) );
1954
 
1964
  else {
1965
  wppa_error_message( __( 'Error inserting photo', 'wp-photo-album-plus') . ' ' . basename( $file ) . '.' );
1966
  if ( $delf ) {
1967
+ wppa_unlink( $unsanitized_path_name );
1968
  }
1969
  }
1970
  }
2055
 
2056
  // Remove old version if already exists
2057
  if ( is_file( $newpath ) ) {
2058
+ wppa_unlink( $newpath );
2059
  }
2060
  rename( $file, $newpath );
2061
  }
2123
  // Add audio filetype
2124
  $newpath = wppa_strip_ext( wppa_get_photo_path( $id, false ) ).'.'.$ext;
2125
  wppa_copy( $file, $newpath );
2126
+ if ( $delu ) {
2127
+ wppa_unlink( $file );
2128
+ }
2129
  if ( wppa( 'ajax' ) ) {
2130
  wppa( 'ajax_import_files_done', true );
2131
  }
2279
 
2280
  // Interprete and verify header. All fields from .csv MUST be in table fields, else fail
2281
  $csv_fields = str_getcsv( $header );
2282
+ $db_fields = $wpdb->get_results( "DESCRIBE " . $is_db_table . "", ARRAY_A );
2283
 
2284
  foreach( $csv_fields as $csv_field ) {
2285
  $ok = false;
2317
 
2318
  wppa_dbg_msg( 'Processing id '.$id );
2319
 
2320
+ $existing_data = $wpdb->get_row( "SELECT * FROM " . $is_db_table . " WHERE id = $id", ARRAY_A );
2321
 
2322
  // If entry exists:
2323
  // 1. save existing data,
2324
  // 2. remove entry,
2325
  if ( $existing_data ) {
2326
  $data = $existing_data;
2327
+ $wpdb->query( "DELETE FROM " . $is_db_table . " WHERE id = $id" );
2328
  }
2329
 
2330
  // Entry does not / no longer exist, add csv data to data array
2456
  $search = $data_arr[0];
2457
  switch ( strtolower($captions[0]) ) {
2458
  case 'photoname':
2459
+ $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE name = %s", $data_arr[0] ), ARRAY_A );
2460
  break;
2461
  case 'filename':
2462
+ $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE filename = %s", $data_arr[0] ), ARRAY_A );
2463
  break;
2464
  case 'name':
2465
+ $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE name = %s OR filename = %s", $data_arr[0], $data_arr[0] ), ARRAY_A );
2466
  break;
2467
  }
2468
  if ( $photos ) {
2620
  $csvcount++;
2621
 
2622
  // Remove tempfile
2623
+ wppa_unlink( $tempfile );
2624
 
2625
  // Remove orig file
2626
  if ( ! $this_skipped && ! wppa_is_time_up() ) {
2627
+ wppa_unlink( $file );
2628
  }
2629
  }
2630
  }
2831
  $path = wppa_sanitize_file_name( $xpath );
2832
  if ( ! file_exists( $xpath ) ) {
2833
  wppa_error_message( 'Zipfile '.$path.' does not exist.' );
 
2834
  $err = '4';
2835
  return $err;
2836
  }
2862
 
2863
  $zip->close();
2864
  wppa_ok_message( sprintf( __( 'Zipfile %s processed. %s files extracted, %s files skipped.', 'wp-photo-album-plus'), basename( $path ), $done, $skip ) );
2865
+ if ( $delz ) {
2866
+ wppa_unlink( $xpath );
2867
+ }
2868
  } else {
2869
  wppa_error_message( __( 'Failed to extract', 'wp-photo-album-plus').' '.$path );
2870
  $err = '1';
2933
  $pagid = wp_insert_post( $my_post );
2934
  if ( $pagid ) {
2935
  wppa_ok_message( sprintf( __( 'Page <a href="%s" target="_blank" >%s</a> created.', 'wp-photo-album-plus'), home_url().'?page_id='.$pagid, $name ) );
2936
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_albums SET cover_linkpage = %s WHERE id = %s", $pagid, $alb ) );
2937
  }
2938
  else {
2939
  wppa_error_message( __( 'Could not create page.', 'wp-photo-album-plus') );
2954
  // If we find a .csv file, move it to our depot and give a warning message
2955
  if ( wppa_get_ext( $photofile ) == 'csv' ) {
2956
  wppa_copy( $photofile, WPPA_DEPOT_PATH . '/' . basename( $photofile ) );
2957
+ wppa_unlink( $photofile );
2958
  wppa_warning_message( sprintf( __( '.csv file %s has been moved to your depot.', 'wp-photo-album-plus' ), basename( $photofile ) ) );
2959
  }
2960
  elseif ( wppa_albumphoto_exists( $alb, basename( $photofile ) ) ) {
2970
  }
2971
  }
2972
  if ( ! wppa_switch( 'keep_import_files' ) ) {
2973
+ wppa_unlink( $photofile );
2974
  }
2975
  $wppa_session[$photofile] = true;
2976
  }
2989
  }
2990
  }
2991
  }
2992
+ wppa_rmdir( $file ); // Try to remove dir, ignore error
2993
  }
2994
  else {
2995
  wppa_dbg_msg( 'Invalid file in wppa_import_dir_to_album(): '.$file );
wppa-index.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all indexing functions
6
- * Version 6.9.20
7
  *
8
  *
9
  */
@@ -24,7 +24,7 @@ global $pcount;
24
 
25
  // Make sure this album will be re-indexed some time if we are not a cron job
26
  if ( ! wppa_is_cron() && ! $force ) {
27
- $wpdb->query( "UPDATE $wpdb->wppa_albums SET `indexdtm` = '' WHERE `id` = " . strval( intval( $id ) ) );
28
  }
29
 
30
  // If there is a cron job running adding to the index and this is not that cron job, do nothing, unless force
@@ -54,7 +54,7 @@ global $pcount;
54
  foreach ( $words as $word ) {
55
 
56
  // Get the row of the index table where the word is registered.
57
- $indexline = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE `slug` = %s", $word ), ARRAY_A );
58
 
59
  // If this line does not exist yet, create it with only one album number as data
60
  if ( ! $indexline ) {
@@ -80,7 +80,7 @@ global $pcount;
80
  $newalbums = wppa_index_array_to_string( $oldalbums );
81
 
82
  // Update db
83
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_index SET `albums` = %s WHERE `id` = %s", $newalbums, $indexline['id'] ) );
84
 
85
  }
86
  }
@@ -92,7 +92,7 @@ global $pcount;
92
 
93
  // Make sure this photo will be re-indexed some time if we are not a cron job
94
  if ( ! wppa_is_cron() && ! $force ) {
95
- $wpdb->query( "UPDATE $wpdb->wppa_photos SET `indexdtm` = '' WHERE `id` = " . strval( intval( $id ) ) );
96
  }
97
 
98
  // If there is a cron job running adding to the index and this is not that cron job, do nothing
@@ -116,7 +116,7 @@ global $pcount;
116
  foreach ( $words as $word ) {
117
 
118
  // Get the row of the index table where the word is registered.
119
- $indexline = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE `slug` = %s", $word ), ARRAY_A );
120
 
121
  // If this line does not exist yet, create it with only one album number as data
122
  if ( ! $indexline ) {
@@ -143,7 +143,7 @@ global $pcount;
143
  $newphotos = wppa_index_array_to_string( $oldphotos );
144
 
145
  // Update db
146
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_index SET `photos` = %s WHERE `id` = %s", $newphotos, $indexline['id'] ) );
147
  }
148
  }
149
 
@@ -445,7 +445,7 @@ global $wpdb;
445
  WHERE photos LIKE %s", '%' . $wpdb->esc_js( $id ) . '%' ), ARRAY_A );
446
  }
447
  else {
448
- $indexes = $wpdb->get_results( "SELECT * FROM `".WPPA_INDEX."` WHERE `photos` <> ''", ARRAY_A );
449
  // There are too many results on large systems, resulting in a 500 error, but it is strictly correct
450
  }
451
  if ( $indexes ) foreach ( $indexes as $indexline ) {
@@ -454,7 +454,7 @@ global $wpdb;
454
  if ( $array[$k] == intval($id) ) {
455
  unset ( $array[$k] );
456
  $string = wppa_index_array_to_string($array);
457
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_index SET `photos` = %s WHERE `id` = %d", $string, $indexline['id'] ) );
458
  }
459
  }
460
  }
@@ -522,7 +522,7 @@ global $wpdb;
522
 
523
  if ( wppa_switch( 'search_tags' ) ) $words .= ' '.$thumb['tags']; // Tags
524
  if ( wppa_switch( 'search_comments' ) ) {
525
- $coms = $wpdb->get_results($wpdb->prepare( "SELECT `comment` FROM $wpdb->wppa_comments WHERE `photo` = %s AND `status` = 'approved'", $thumb['id'] ), ARRAY_A );
526
  if ( $coms ) {
527
  foreach ( $coms as $com ) {
528
  $words .= ' ' . stripslashes( $com['comment'] );
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all indexing functions
6
+ * Version 6.9.21
7
  *
8
  *
9
  */
24
 
25
  // Make sure this album will be re-indexed some time if we are not a cron job
26
  if ( ! wppa_is_cron() && ! $force ) {
27
+ $wpdb->query( "UPDATE $wpdb->wppa_albums SET indexdtm = '' WHERE id = " . strval( intval( $id ) ) );
28
  }
29
 
30
  // If there is a cron job running adding to the index and this is not that cron job, do nothing, unless force
54
  foreach ( $words as $word ) {
55
 
56
  // Get the row of the index table where the word is registered.
57
+ $indexline = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE slug = %s", $word ), ARRAY_A );
58
 
59
  // If this line does not exist yet, create it with only one album number as data
60
  if ( ! $indexline ) {
80
  $newalbums = wppa_index_array_to_string( $oldalbums );
81
 
82
  // Update db
83
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_index SET albums = %s WHERE id = %s", $newalbums, $indexline['id'] ) );
84
 
85
  }
86
  }
92
 
93
  // Make sure this photo will be re-indexed some time if we are not a cron job
94
  if ( ! wppa_is_cron() && ! $force ) {
95
+ $wpdb->query( "UPDATE $wpdb->wppa_photos SET indexdtm = '' WHERE id = " . strval( intval( $id ) ) );
96
  }
97
 
98
  // If there is a cron job running adding to the index and this is not that cron job, do nothing
116
  foreach ( $words as $word ) {
117
 
118
  // Get the row of the index table where the word is registered.
119
+ $indexline = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE slug = %s", $word ), ARRAY_A );
120
 
121
  // If this line does not exist yet, create it with only one album number as data
122
  if ( ! $indexline ) {
143
  $newphotos = wppa_index_array_to_string( $oldphotos );
144
 
145
  // Update db
146
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_index SET photos = %s WHERE id = %s", $newphotos, $indexline['id'] ) );
147
  }
148
  }
149
 
445
  WHERE photos LIKE %s", '%' . $wpdb->esc_js( $id ) . '%' ), ARRAY_A );
446
  }
447
  else {
448
+ $indexes = $wpdb->get_results( "SELECT * FROM ".WPPA_INDEX." WHERE photos <> ''", ARRAY_A );
449
  // There are too many results on large systems, resulting in a 500 error, but it is strictly correct
450
  }
451
  if ( $indexes ) foreach ( $indexes as $indexline ) {
454
  if ( $array[$k] == intval($id) ) {
455
  unset ( $array[$k] );
456
  $string = wppa_index_array_to_string($array);
457
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_index SET photos = %s WHERE id = %d", $string, $indexline['id'] ) );
458
  }
459
  }
460
  }
522
 
523
  if ( wppa_switch( 'search_tags' ) ) $words .= ' '.$thumb['tags']; // Tags
524
  if ( wppa_switch( 'search_comments' ) ) {
525
+ $coms = $wpdb->get_results($wpdb->prepare( "SELECT comment FROM $wpdb->wppa_comments WHERE photo = %s AND status = 'approved'", $thumb['id'] ), ARRAY_A );
526
  if ( $coms ) {
527
  foreach ( $coms as $com ) {
528
  $words .= ' ' . stripslashes( $com['comment'] );
wppa-init.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * This file loads required php files and contains all functions used in init actions.
6
  *
7
- * Version 6.9.20
8
  */
9
 
10
  /* LOAD SIDEBAR WIDGETS */
@@ -268,7 +268,7 @@ global $wpdb;
268
 
269
  if ( current_user_can( 'wppa_settings' ) ) {
270
  if ( get_option( 'wppa_tags_ok' ) != '1' ) {
271
- $tag = $wpdb->get_var( "SELECT `tags` FROM $wpdb->wppa_photos WHERE `tags` <> '' ORDER BY `id` DESC LIMIT 1" );
272
  if ( $tag ) {
273
  if ( substr( $tag, 0, 1 ) != ',' ) {
274
  add_action('admin_notices', 'wppa_tag_message');
@@ -290,7 +290,7 @@ global $wpdb;
290
 
291
  if ( current_user_can( 'wppa_settings' ) ) {
292
  if ( get_option( 'wppa_cats_ok' ) != '1' ) {
293
- $tag = $wpdb->get_var( "SELECT `cats` FROM $wpdb->wppa_albums WHERE `cats` <> '' ORDER BY `id` DESC LIMIT 1" );
294
  if ( $tag ) {
295
  if ( substr( $tag, 0, 1 ) != ',' ) {
296
  add_action('admin_notices', 'wppa_cat_message');
@@ -315,11 +315,11 @@ global $wpdb;
315
  return;
316
  }
317
 
318
- $has_wppa_scripts = $wpdb->get_results( "SELECT `ID`, `post_title`, `post_content`, `post_type` " .
319
- "FROM `" . $wpdb->prefix . 'posts' ."` " .
320
- "WHERE `post_status` = 'publish' " .
321
- "AND ( `post_type` = 'post' OR `post_type` = 'page' ) " .
322
- "AND `post_content` LIKE '%\\%\\%wppa\\%\\%%' " , ARRAY_A );
323
 
324
  if ( $has_wppa_scripts ) {
325
  foreach( array_keys( $has_wppa_scripts ) as $key ) {
4
  *
5
  * This file loads required php files and contains all functions used in init actions.
6
  *
7
+ * Version 6.9.21
8
  */
9
 
10
  /* LOAD SIDEBAR WIDGETS */
268
 
269
  if ( current_user_can( 'wppa_settings' ) ) {
270
  if ( get_option( 'wppa_tags_ok' ) != '1' ) {
271
+ $tag = $wpdb->get_var( "SELECT tags FROM $wpdb->wppa_photos WHERE tags <> '' ORDER BY id DESC LIMIT 1" );
272
  if ( $tag ) {
273
  if ( substr( $tag, 0, 1 ) != ',' ) {
274
  add_action('admin_notices', 'wppa_tag_message');
290
 
291
  if ( current_user_can( 'wppa_settings' ) ) {
292
  if ( get_option( 'wppa_cats_ok' ) != '1' ) {
293
+ $tag = $wpdb->get_var( "SELECT cats FROM $wpdb->wppa_albums WHERE cats <> '' ORDER BY id DESC LIMIT 1" );
294
  if ( $tag ) {
295
  if ( substr( $tag, 0, 1 ) != ',' ) {
296
  add_action('admin_notices', 'wppa_cat_message');
315
  return;
316
  }
317
 
318
+ $has_wppa_scripts = $wpdb->get_results( "SELECT ID, post_title, post_content, post_type " .
319
+ "FROM " . $wpdb->prefix . 'posts' ." " .
320
+ "WHERE post_status = 'publish' " .
321
+ "AND ( post_type = 'post' OR post_type = 'page' ) " .
322
+ "AND post_content LIKE '%\\%\\%wppa\\%\\%%' " , ARRAY_A );
323
 
324
  if ( $has_wppa_scripts ) {
325
  foreach( array_keys( $has_wppa_scripts ) as $key ) {
wppa-items.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains functions to retrieve album and photo items
6
- * Version 6.9.16
7
  *
8
  */
9
 
@@ -95,7 +95,7 @@ static $album_cache_2;
95
  }
96
 
97
  // Not in cache, do query
98
- $album = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `id` = %s", $id ), ARRAY_A );
99
  wppa_dbg_cachecounts( 'albummis' );
100
 
101
  // Found one?
@@ -203,7 +203,7 @@ static $thumb_cache_2;
203
  }
204
 
205
  // Not in cache, do query
206
- $thumb = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `id` = %s", $id ), ARRAY_A );
207
  wppa_dbg_cachecounts( 'photomis' );
208
 
209
  // Found one?
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains functions to retrieve album and photo items
6
+ * Version 6.9.21
7
  *
8
  */
9
 
95
  }
96
 
97
  // Not in cache, do query
98
+ $album = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE id = %s", $id ), ARRAY_A );
99
  wppa_dbg_cachecounts( 'albummis' );
100
 
101
  // Found one?
203
  }
204
 
205
  // Not in cache, do query
206
+ $thumb = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE id = %s", $id ), ARRAY_A );
207
  wppa_dbg_cachecounts( 'photomis' );
208
 
209
  // Found one?
wppa-lasten-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the last uploaded photos
6
- * Version 6.9.14
7
  */
8
 
9
  class LasTenWidget extends WP_Widget {
@@ -63,7 +63,7 @@ class LasTenWidget extends WP_Widget {
63
  case '0': // ---all---
64
  break;
65
  case '-2': // ---generic---
66
- $albs = $wpdb->get_results( "SELECT `id` FROM $wpdb->wppa_albums WHERE `a_parent` = '0'", ARRAY_A );
67
  $album = '';
68
  foreach ( $albs as $alb ) {
69
  $album .= '.' . $alb['id'];
@@ -88,20 +88,20 @@ class LasTenWidget extends WP_Widget {
88
 
89
  // If you want only 'New' photos in the selection, the period must be <> 0;
90
  if ( wppa_switch( 'lasten_limit_new' ) && wppa_opt( 'max_photo_newtime' ) ) {
91
- $newtime = " `" . $order_by . "` >= ".( time() - wppa_opt( 'max_photo_newtime' ) );
92
  if ( $album ) {
93
- $q = "SELECT * FROM $wpdb->wppa_photos WHERE (".$newtime.") AND `album` IN ( ".$album." ) AND ( `status` <> 'pending' AND `status` <> 'scheduled' ) ORDER BY `" . $order_by . "` DESC LIMIT " . $max;
94
  }
95
  else {
96
- $q = "SELECT * FROM $wpdb->wppa_photos WHERE (".$newtime.") AND `album` > 0 AND `status` <> 'pending' AND `status` <> 'scheduled' ORDER BY `" . $order_by . "` DESC LIMIT " . $max;
97
  }
98
  }
99
  else {
100
  if ( $album ) {
101
- $q = "SELECT * FROM $wpdb->wppa_photos WHERE `album` IN ( ".$album." ) AND ( `status` <> 'pending' AND `status` <> 'scheduled' ) ORDER BY `" . $order_by . "` DESC LIMIT " . $max;
102
  }
103
  else {
104
- $q = "SELECT * FROM $wpdb->wppa_photos WHERE `album` > 0 AND `status` <> 'pending' AND `status` <> 'scheduled' ORDER BY `" . $order_by . "` DESC LIMIT " . $max;
105
  }
106
  }
107
 
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the last uploaded photos
6
+ * Version 6.9.21
7
  */
8
 
9
  class LasTenWidget extends WP_Widget {
63
  case '0': // ---all---
64
  break;
65
  case '-2': // ---generic---
66
+ $albs = $wpdb->get_results( "SELECT id FROM $wpdb->wppa_albums WHERE a_parent = '0'", ARRAY_A );
67
  $album = '';
68
  foreach ( $albs as $alb ) {
69
  $album .= '.' . $alb['id'];
88
 
89
  // If you want only 'New' photos in the selection, the period must be <> 0;
90
  if ( wppa_switch( 'lasten_limit_new' ) && wppa_opt( 'max_photo_newtime' ) ) {
91
+ $newtime = " " . $order_by . " >= ".( time() - wppa_opt( 'max_photo_newtime' ) );
92
  if ( $album ) {
93
+ $q = "SELECT * FROM $wpdb->wppa_photos WHERE (".$newtime.") AND album IN ( ".$album." ) AND ( status <> 'pending' AND status <> 'scheduled' ) ORDER BY " . $order_by . " DESC LIMIT " . $max;
94
  }
95
  else {
96
+ $q = "SELECT * FROM $wpdb->wppa_photos WHERE (".$newtime.") AND album > 0 AND status <> 'pending' AND status <> 'scheduled' ORDER BY " . $order_by . " DESC LIMIT " . $max;
97
  }
98
  }
99
  else {
100
  if ( $album ) {
101
+ $q = "SELECT * FROM $wpdb->wppa_photos WHERE album IN ( ".$album." ) AND ( status <> 'pending' AND status <> 'scheduled' ) ORDER BY " . $order_by . " DESC LIMIT " . $max;
102
  }
103
  else {
104
+ $q = "SELECT * FROM $wpdb->wppa_photos WHERE album > 0 AND status <> 'pending' AND status <> 'scheduled' ORDER BY " . $order_by . " DESC LIMIT " . $max;
105
  }
106
  }
107
 
wppa-links.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Frontend links
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -139,7 +139,7 @@ global $wppa_lang;
139
  if ( wppa_get_get( 'p' ) ) $al .= '&amp;p=' . wppa_get_get( 'p' );
140
  if ( wppa_get_get( 'page_id' ) ) $al .= '&amp;page_id=' . wppa_get_get( 'page_id' );
141
  }
142
- $al .= '&amp;wppa-fromp=' . get_the_ID();
143
  }
144
 
145
  if ( wppa_get_get( 'lang' ) ) { // If lang in querystring: keep it
@@ -1481,7 +1481,7 @@ global $wpdb;
1481
 
1482
  // owner/public?
1483
  if ( $album == '-3' ) {
1484
- $temp = $wpdb->get_results( "SELECT `id` FROM $wpdb->wppa_albums WHERE `owner` = '" . wppa_get_user() . "' OR `owner` = '--- public ---' ORDER BY `id`", ARRAY_A );
1485
  $album = '';
1486
  if ( $temp ) {
1487
  foreach( $temp as $t ) {
@@ -1749,7 +1749,7 @@ global $wpdb;
1749
  break;
1750
  case 'plainpage':
1751
  $result['url'] = get_permalink( $page );
1752
- $result['title'] = $wpdb->get_var( $wpdb->prepare( "SELECT `post_title` FROM `" . $wpdb->prefix . "posts` WHERE `ID` = %s", $page ) );
1753
  $result['is_url'] = true;
1754
  $result['is_lightbox'] = false;
1755
  return $result;
3
  * Package: wp-photo-album-plus
4
  *
5
  * Frontend links
6
+ * Version 6.9.21
7
  *
8
  */
9
 
139
  if ( wppa_get_get( 'p' ) ) $al .= '&amp;p=' . wppa_get_get( 'p' );
140
  if ( wppa_get_get( 'page_id' ) ) $al .= '&amp;page_id=' . wppa_get_get( 'page_id' );
141
  }
142
+ $al .= '&amp;wppa-fromp=' . wppa_get_the_ID();
143
  }
144
 
145
  if ( wppa_get_get( 'lang' ) ) { // If lang in querystring: keep it
1481
 
1482
  // owner/public?
1483
  if ( $album == '-3' ) {
1484
+ $temp = $wpdb->get_results( "SELECT id FROM $wpdb->wppa_albums WHERE owner = '" . wppa_get_user() . "' OR owner = '--- public ---' ORDER BY id", ARRAY_A );
1485
  $album = '';
1486
  if ( $temp ) {
1487
  foreach( $temp as $t ) {
1749
  break;
1750
  case 'plainpage':
1751
  $result['url'] = get_permalink( $page );
1752
+ $result['title'] = $wpdb->get_var( $wpdb->prepare( "SELECT post_title FROM " . $wpdb->prefix . "posts WHERE ID = %s", $page ) );
1753
  $result['is_url'] = true;
1754
  $result['is_lightbox'] = false;
1755
  return $result;
wppa-maintenance.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains (not yet, but in the future maybe) all the maintenance routines
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -187,8 +187,8 @@ global $wppa_timestamp_start;
187
 
188
  // Pre-Clear album index only if not cron
189
  if ( ! wppa_is_cron() ) {
190
- $wpdb->query( "UPDATE $wpdb->wppa_index SET `albums` = ''" );
191
- $wpdb->query( "UPDATE $wpdb->wppa_albums SET `indexdtm` = ''" );
192
  }
193
  wppa_index_compute_skips();
194
  break;
@@ -197,8 +197,8 @@ global $wppa_timestamp_start;
197
 
198
  // Pre-Clear photo index only if not cron
199
  if ( ! wppa_is_cron() ) {
200
- $wpdb->query( "UPDATE $wpdb->wppa_index SET `photos` = ''" );
201
- $wpdb->query( "UPDATE $wpdb->wppa_photos SET `indexdtm` = ''" );
202
  }
203
  wppa_index_compute_skips();
204
  break;
@@ -221,7 +221,7 @@ global $wppa_timestamp_start;
221
  break;
222
  case 'wppa_cleanup':
223
  $orphan_album = get_option( 'wppa_orphan_album', '0' );
224
- $album_exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM$wpdb->wppa_albums WHERE `id` = %s", $orphan_album ) );
225
  if ( ! $album_exists ) $orphan_album = false;
226
  if ( ! $orphan_album ) {
227
  $orphan_album = wppa_create_album_entry( array( 'name' => __('Orphan photos', 'wp-photo-album-plus'), 'a_parent' => '-1', 'description' => __('This album contains refound lost photos', 'wp-photo-album-plus') ) );
@@ -297,16 +297,16 @@ global $wppa_timestamp_start;
297
  $table = WPPA_ALBUMS;
298
 
299
  if ( $slug == 'wppa_remake_index_albums' ) {
300
- $topid = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_albums ORDER BY `id` DESC LIMIT 1" );
301
  $albums = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums " .
302
- "WHERE `id` > " . $lastid . " " .
303
- "AND `indexdtm` < `modified` " .
304
- "ORDER BY `id` " .
305
  "LIMIT 100", ARRAY_A );
306
  }
307
  else {
308
- $topid = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_albums ORDER BY `id` DESC LIMIT 1" );
309
- $albums = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums WHERE `id` > ".$lastid." ORDER BY `id` LIMIT 100", ARRAY_A );
310
  }
311
 
312
  wppa_cache_album( 'add', $albums );
@@ -326,14 +326,14 @@ global $wppa_timestamp_start;
326
  else {
327
  wppa_index_add( 'album', $id, 'force' );
328
  }
329
- $wpdb->query( "UPDATE $wpdb->wppa_albums SET `indexdtm` = '" . time() . "' WHERE `id` = $id" );
330
  break;
331
 
332
  case 'wppa_remove_empty_albums':
333
- $p = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `album` = %s", $id ) );
334
- $a = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE `a_parent` = %s", $id ) );
335
  if ( ! $a && ! $p ) {
336
- $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_albums WHERE `id` = %s", $id ) );
337
  wppa_delete_album_source( $id );
338
  wppa_invalidate_treecounts( $id );
339
  wppa_index_remove( 'album', $id );
@@ -412,16 +412,16 @@ global $wppa_timestamp_start;
412
  }
413
  }
414
  elseif ( $slug == 'wppa_remake_index_photos' ) {
415
- $topid = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_photos ORDER BY `id` DESC LIMIT 1" );
416
  $photos = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos " .
417
- "WHERE `id` > " . $lastid . " " .
418
- "AND `indexdtm` < `modified` " .
419
- "ORDER BY `id` " .
420
  "LIMIT " . $chunksize, ARRAY_A );
421
  }
422
  else {
423
- $topid = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_photos ORDER BY `id` DESC LIMIT 1" );
424
- $photos = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos WHERE `id` > ".$lastid." ORDER BY `id` LIMIT ".$chunksize, ARRAY_A );
425
  }
426
 
427
  if ( $slug == 'wppa_edit_tag' ) {
@@ -458,7 +458,7 @@ global $wppa_timestamp_start;
458
  else {
459
  wppa_index_add( 'photo', $id, 'force' );
460
  }
461
- $wpdb->query( "UPDATE $wpdb->wppa_photos SET `indexdtm` = '" . time() . "' WHERE `id` = $id" );
462
  break;
463
 
464
  case 'wppa_apply_default_photoname_all':
@@ -470,7 +470,7 @@ global $wppa_timestamp_start;
470
  $value = wppa_opt( 'newphoto_description' );
471
  $description = trim( $value );
472
  if ( $description != $photo['description'] ) { // Modified photo description
473
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `description` = %s WHERE `id` = %s", $description, $id ) );
474
  }
475
  break;
476
 
@@ -479,7 +479,7 @@ global $wppa_timestamp_start;
479
  if ( ! $value ) return 'Unexpected error: missing text to append||'.$slug.'||Error||0';
480
  $description = rtrim( $photo['description'] . ' '. $value );
481
  if ( $description != $photo['description'] ) { // Modified photo description
482
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `description` = %s WHERE `id` = %s", $description, $id ) );
483
  }
484
  break;
485
 
@@ -488,7 +488,7 @@ global $wppa_timestamp_start;
488
  if ( ! $value ) return 'Unexpected error: missing text to remove||'.$slug.'||Error||0';
489
  $description = rtrim( str_replace( $value, '', $photo['description'] ) );
490
  if ( $description != $photo['description'] ) { // Modified photo description
491
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `description` = %s WHERE `id` = %s", $description, $id ) );
492
  }
493
  break;
494
 
@@ -496,7 +496,7 @@ global $wppa_timestamp_start;
496
  if ( ! wppa_is_video( $id ) ) {
497
  $name = str_replace( array( '.jpg', '.png', '.gif', '.JPG', '.PNG', '.GIF' ), '', $photo['name'] );
498
  if ( $name != $photo['name'] ) { // Modified photo name
499
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `name` = %s WHERE `id` = %s", $name, $id ) );
500
  }
501
  }
502
  break;
@@ -505,7 +505,7 @@ global $wppa_timestamp_start;
505
  if ( ! wppa_is_video( $id ) ) {
506
  $name = str_replace( array( '.jpg', '.png', 'gif', '.JPG', '.PNG', '.GIF' ), '', $photo['name'] );
507
  if ( $name == $photo['name'] ) { // Name had no fileextension
508
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `name` = %s WHERE `id` = %s", $name.'.'.$photo['ext'], $id ) );
509
  }
510
  }
511
  break;
@@ -527,19 +527,19 @@ global $wppa_timestamp_start;
527
  else {
528
  if ( is_file( $rawpath . '.' . $EXT ) ) {
529
  if ( is_file( $rawpath . '.' . $ext ) ) {
530
- unlink( $rawpath . '.' . $EXT );
531
  }
532
  else {
533
- rename( $rawpath . '.' . $EXT, $rawpath . '.' . $ext );
534
  }
535
  $fixed_this = true;
536
  }
537
  if ( is_file( $rawthumb . '.' . $EXT ) ) {
538
  if ( is_file( $rawthumb . '.' . $ext ) ) {
539
- unlink( $rawthumb . '.' . $EXT );
540
  }
541
  else {
542
- rename( $rawthumb . '.' . $EXT, $rawthumb . '.' . $ext );
543
  }
544
  $fixed_this = true;
545
  }
@@ -593,19 +593,19 @@ global $wppa_timestamp_start;
593
  foreach ( $exts as $ext ) {
594
  if ( is_file( str_replace( '.xxx', '.'.$ext, $pathfrom ) ) ) {
595
  // wppa_log( 'dbg', str_replace( '.xxx', '.'.$ext, $pathfrom ).' -> '.str_replace( '.xxx', '.'.$ext, $pathto ));
596
- @ rename ( str_replace( '.xxx', '.'.$ext, $pathfrom ), str_replace( '.xxx', '.'.$ext, $pathto ) );
597
  }
598
  }
599
  }
600
 
601
  // Poster / photo
602
  if ( file_exists( wppa_get_photo_path( $id, true, $from ) ) ) {
603
- @ rename ( wppa_get_photo_path( $id, true, $from ), wppa_get_photo_path( $id, true, $to ) );
604
  }
605
 
606
  // Thumbnail
607
  if ( file_exists( wppa_get_thumb_path( $id, true, $from ) ) ) {
608
- @ rename ( wppa_get_thumb_path( $id, true, $from ), wppa_get_thumb_path( $id, true, $to ) );
609
  }
610
 
611
  }
@@ -625,7 +625,7 @@ global $wppa_timestamp_start;
625
  if ( $photo_files ) foreach( $photo_files as $photo_file ) {
626
  $basename = basename( $photo_file );
627
  $ext = substr( $basename, strpos( $basename, '.' ) + '1');
628
- if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `id` = %s", $id ) ) ) { // no db entry for this photo
629
  if ( wppa_is_id_free( WPPA_PHOTOS, $id ) ) {
630
  if ( wppa_create_photo_entry( array( 'id' => $id, 'album' => $orphan_album, 'ext' => $ext, 'filename' => $basename ) ) ) { // Can create entry
631
  $wppa_session[$slug.'_fixed']++; // Bump counter
@@ -695,7 +695,7 @@ global $wppa_timestamp_start;
695
  while ( strlen( $name ) < $target_len ) $name = '0'.$name;
696
  }
697
  if ( $name !== $photo['name'] ) {
698
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `name` = %s WHERE `id` = %s", $name, $id ) );
699
  }
700
  break;
701
 
@@ -861,7 +861,7 @@ global $wppa_timestamp_start;
861
  $lastid = $id;
862
  update_option( $slug.'_last', $lastid );
863
  if ( wppa_is_cron() ) {
864
- $togo = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `id` > %s ", $lastid ) );
865
  if ( $togo ) {
866
  update_option( $slug.'_togo', $togo );
867
  update_option( $slug.'_status', 'Cron job' );
@@ -993,7 +993,7 @@ global $wppa_timestamp_start;
993
 
994
  // Update status
995
  if ( wppa_is_cron() ) {
996
- $togo = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_index WHERE `id` > %s ", $lastid ) );
997
  if ( $togo ) {
998
  update_option( $slug.'_togo', $togo );
999
  update_option( $slug.'_status', 'Cron job' );
@@ -1032,7 +1032,7 @@ global $wppa_timestamp_start;
1032
  $togo = $topid - $lastid;
1033
  }
1034
  else {
1035
- $togo = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".$table."` WHERE `id` > %s ", $lastid ) );
1036
  }
1037
 
1038
  // Find status
@@ -1321,7 +1321,7 @@ global $wppa_log_file;
1321
 
1322
  case 'wppa_list_session':
1323
  $total = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_session" );
1324
- $sessions = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_session ORDER BY `id` DESC LIMIT 1000", ARRAY_A );
1325
  $result .=
1326
  '<h2>' .
1327
  sprintf( __( 'List of sessions <small>( Max 1000 entries of total %d )</small>', 'wp-photo-album-plus' ), $total ) .
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains (not yet, but in the future maybe) all the maintenance routines
6
+ * Version 6.9.21
7
  *
8
  */
9
 
187
 
188
  // Pre-Clear album index only if not cron
189
  if ( ! wppa_is_cron() ) {
190
+ $wpdb->query( "UPDATE $wpdb->wppa_index SET albums = ''" );
191
+ $wpdb->query( "UPDATE $wpdb->wppa_albums SET indexdtm = ''" );
192
  }
193
  wppa_index_compute_skips();
194
  break;
197
 
198
  // Pre-Clear photo index only if not cron
199
  if ( ! wppa_is_cron() ) {
200
+ $wpdb->query( "UPDATE $wpdb->wppa_index SET photos = ''" );
201
+ $wpdb->query( "UPDATE $wpdb->wppa_photos SET indexdtm = ''" );
202
  }
203
  wppa_index_compute_skips();
204
  break;
221
  break;
222
  case 'wppa_cleanup':
223
  $orphan_album = get_option( 'wppa_orphan_album', '0' );
224
+ $album_exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM$wpdb->wppa_albums WHERE id = %s", $orphan_album ) );
225
  if ( ! $album_exists ) $orphan_album = false;
226
  if ( ! $orphan_album ) {
227
  $orphan_album = wppa_create_album_entry( array( 'name' => __('Orphan photos', 'wp-photo-album-plus'), 'a_parent' => '-1', 'description' => __('This album contains refound lost photos', 'wp-photo-album-plus') ) );
297
  $table = WPPA_ALBUMS;
298
 
299
  if ( $slug == 'wppa_remake_index_albums' ) {
300
+ $topid = $wpdb->get_var( "SELECT id FROM $wpdb->wppa_albums ORDER BY id DESC LIMIT 1" );
301
  $albums = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums " .
302
+ "WHERE id > " . $lastid . " " .
303
+ "AND indexdtm < modified " .
304
+ "ORDER BY id " .
305
  "LIMIT 100", ARRAY_A );
306
  }
307
  else {
308
+ $topid = $wpdb->get_var( "SELECT id FROM $wpdb->wppa_albums ORDER BY id DESC LIMIT 1" );
309
+ $albums = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums WHERE id > ".$lastid." ORDER BY id LIMIT 100", ARRAY_A );
310
  }
311
 
312
  wppa_cache_album( 'add', $albums );
326
  else {
327
  wppa_index_add( 'album', $id, 'force' );
328
  }
329
+ $wpdb->query( "UPDATE $wpdb->wppa_albums SET indexdtm = '" . time() . "' WHERE id = $id" );
330
  break;
331
 
332
  case 'wppa_remove_empty_albums':
333
+ $p = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album = %s", $id ) );
334
+ $a = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE a_parent = %s", $id ) );
335
  if ( ! $a && ! $p ) {
336
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_albums WHERE id = %s", $id ) );
337
  wppa_delete_album_source( $id );
338
  wppa_invalidate_treecounts( $id );
339
  wppa_index_remove( 'album', $id );
412
  }
413
  }
414
  elseif ( $slug == 'wppa_remake_index_photos' ) {
415
+ $topid = $wpdb->get_var( "SELECT id FROM $wpdb->wppa_photos ORDER BY id DESC LIMIT 1" );
416
  $photos = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos " .
417
+ "WHERE id > " . $lastid . " " .
418
+ "AND indexdtm < modified " .
419
+ "ORDER BY id " .
420
  "LIMIT " . $chunksize, ARRAY_A );
421
  }
422
  else {
423
+ $topid = $wpdb->get_var( "SELECT id FROM $wpdb->wppa_photos ORDER BY id DESC LIMIT 1" );
424
+ $photos = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos WHERE id > ".$lastid." ORDER BY id LIMIT ".$chunksize, ARRAY_A );
425
  }
426
 
427
  if ( $slug == 'wppa_edit_tag' ) {
458
  else {
459
  wppa_index_add( 'photo', $id, 'force' );
460
  }
461
+ $wpdb->query( "UPDATE $wpdb->wppa_photos SET indexdtm = '" . time() . "' WHERE id = $id" );
462
  break;
463
 
464
  case 'wppa_apply_default_photoname_all':
470
  $value = wppa_opt( 'newphoto_description' );
471
  $description = trim( $value );
472
  if ( $description != $photo['description'] ) { // Modified photo description
473
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET description = %s WHERE id = %s", $description, $id ) );
474
  }
475
  break;
476
 
479
  if ( ! $value ) return 'Unexpected error: missing text to append||'.$slug.'||Error||0';
480
  $description = rtrim( $photo['description'] . ' '. $value );
481
  if ( $description != $photo['description'] ) { // Modified photo description
482
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET description = %s WHERE id = %s", $description, $id ) );
483
  }
484
  break;
485
 
488
  if ( ! $value ) return 'Unexpected error: missing text to remove||'.$slug.'||Error||0';
489
  $description = rtrim( str_replace( $value, '', $photo['description'] ) );
490
  if ( $description != $photo['description'] ) { // Modified photo description
491
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET description = %s WHERE id = %s", $description, $id ) );
492
  }
493
  break;
494
 
496
  if ( ! wppa_is_video( $id ) ) {
497
  $name = str_replace( array( '.jpg', '.png', '.gif', '.JPG', '.PNG', '.GIF' ), '', $photo['name'] );
498
  if ( $name != $photo['name'] ) { // Modified photo name
499
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET name = %s WHERE id = %s", $name, $id ) );
500
  }
501
  }
502
  break;
505
  if ( ! wppa_is_video( $id ) ) {
506
  $name = str_replace( array( '.jpg', '.png', 'gif', '.JPG', '.PNG', '.GIF' ), '', $photo['name'] );
507
  if ( $name == $photo['name'] ) { // Name had no fileextension
508
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET name = %s WHERE id = %s", $name.'.'.$photo['ext'], $id ) );
509
  }
510
  }
511
  break;
527
  else {
528
  if ( is_file( $rawpath . '.' . $EXT ) ) {
529
  if ( is_file( $rawpath . '.' . $ext ) ) {
530
+ wppa_unlink( $rawpath . '.' . $EXT );
531
  }
532
  else {
533
+ wppa_rename( $rawpath . '.' . $EXT, $rawpath . '.' . $ext );
534
  }
535
  $fixed_this = true;
536
  }
537
  if ( is_file( $rawthumb . '.' . $EXT ) ) {
538
  if ( is_file( $rawthumb . '.' . $ext ) ) {
539
+ wppa_unlink( $rawthumb . '.' . $EXT );
540
  }
541
  else {
542
+ wppa_rename( $rawthumb . '.' . $EXT, $rawthumb . '.' . $ext );
543
  }
544
  $fixed_this = true;
545
  }
593
  foreach ( $exts as $ext ) {
594
  if ( is_file( str_replace( '.xxx', '.'.$ext, $pathfrom ) ) ) {
595
  // wppa_log( 'dbg', str_replace( '.xxx', '.'.$ext, $pathfrom ).' -> '.str_replace( '.xxx', '.'.$ext, $pathto ));
596
+ wppa_rename ( str_replace( '.xxx', '.'.$ext, $pathfrom ), str_replace( '.xxx', '.'.$ext, $pathto ) );
597
  }
598
  }
599
  }
600
 
601
  // Poster / photo
602
  if ( file_exists( wppa_get_photo_path( $id, true, $from ) ) ) {
603
+ wppa_rename ( wppa_get_photo_path( $id, true, $from ), wppa_get_photo_path( $id, true, $to ) );
604
  }
605
 
606
  // Thumbnail
607
  if ( file_exists( wppa_get_thumb_path( $id, true, $from ) ) ) {
608
+ wppa_rename ( wppa_get_thumb_path( $id, true, $from ), wppa_get_thumb_path( $id, true, $to ) );
609
  }
610
 
611
  }
625
  if ( $photo_files ) foreach( $photo_files as $photo_file ) {
626
  $basename = basename( $photo_file );
627
  $ext = substr( $basename, strpos( $basename, '.' ) + '1');
628
+ if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE id = %s", $id ) ) ) { // no db entry for this photo
629
  if ( wppa_is_id_free( WPPA_PHOTOS, $id ) ) {
630
  if ( wppa_create_photo_entry( array( 'id' => $id, 'album' => $orphan_album, 'ext' => $ext, 'filename' => $basename ) ) ) { // Can create entry
631
  $wppa_session[$slug.'_fixed']++; // Bump counter
695
  while ( strlen( $name ) < $target_len ) $name = '0'.$name;
696
  }
697
  if ( $name !== $photo['name'] ) {
698
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET name = %s WHERE id = %s", $name, $id ) );
699
  }
700
  break;
701
 
861
  $lastid = $id;
862
  update_option( $slug.'_last', $lastid );
863
  if ( wppa_is_cron() ) {
864
+ $togo = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE id > %s ", $lastid ) );
865
  if ( $togo ) {
866
  update_option( $slug.'_togo', $togo );
867
  update_option( $slug.'_status', 'Cron job' );
993
 
994
  // Update status
995
  if ( wppa_is_cron() ) {
996
+ $togo = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_index WHERE id > %s ", $lastid ) );
997
  if ( $togo ) {
998
  update_option( $slug.'_togo', $togo );
999
  update_option( $slug.'_status', 'Cron job' );
1032
  $togo = $topid - $lastid;
1033
  }
1034
  else {
1035
+ $togo = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM ".$table." WHERE id > %s ", $lastid ) );
1036
  }
1037
 
1038
  // Find status
1321
 
1322
  case 'wppa_list_session':
1323
  $total = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_session" );
1324
+ $sessions = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_session ORDER BY id DESC LIMIT 1000", ARRAY_A );
1325
  $result .=
1326
  '<h2>' .
1327
  sprintf( __( 'List of sessions <small>( Max 1000 entries of total %d )</small>', 'wp-photo-album-plus' ), $total ) .
wppa-non-admin.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the non admin stuff
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -48,12 +48,12 @@ global $wppa_api_version;
48
 
49
  // Dynamic css
50
  if ( ! wppa_switch( 'inline_css' ) ) {
51
- if ( ! file_exists( WPPA_PATH.'/wppa-dynamic.css' ) ) {
52
  wppa_create_wppa_dynamic_css();
53
  update_option( 'wppa_dynamic_css_version', get_option( 'wppa_dynamic_css_version', '0' ) + '1' );
54
  }
55
- if ( file_exists( WPPA_PATH.'/wppa-dynamic.css' ) ) {
56
- wp_enqueue_style( 'wppa-dynamic', WPPA_URL.'/wppa-dynamic.css', array('wppa_style'), get_option( 'wppa_dynamic_css_version' ) );
57
  }
58
  }
59
  }
@@ -165,7 +165,7 @@ echo '
165
 
166
  if ( $album ) {
167
  if ( wppa_switch( 'meta_page' ) ) {
168
- $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `album` = %s AND `status` = 'featured'", $album ), ARRAY_A );
169
  wppa_cache_photo( 'add', $photos );
170
  if ( $photos ) {
171
  echo("\n<!-- WPPA+ BEGIN Featured photos on this page -->");
@@ -185,7 +185,7 @@ echo '
185
 
186
  // No photo and no album, give the plain photo links of all featured photos
187
  elseif ( wppa_switch( 'meta_all' ) ) {
188
- $photos = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos WHERE `status` = 'featured'", ARRAY_A);
189
  wppa_cache_photo( 'add', $photos );
190
  if ( $photos ) {
191
  echo("\n<!-- WPPA+ BEGIN Featured photos on this site -->");
@@ -206,9 +206,9 @@ echo '
206
  // No photo id and no album known yet. Also: not all featured.
207
  // Examine the page (if any) on an album id in the shortcode
208
  elseif ( wppa_switch( 'og_tags_on' ) ) {
209
- $page = get_the_ID();
210
  if ( $page ) {
211
- $page_content = $wpdb->get_var( "SELECT `post_content` FROM `" . $wpdb->prefix . 'posts' . "` WHERE `ID` = " . $page );
212
  if ( strpos( $page_content, '[wppa' ) !== false ) {
213
  $a_pos = strpos( $page_content, 'album="' );
214
  $album = substr( $page_content, $a_pos + 7, 20 );
@@ -225,12 +225,12 @@ echo '
225
 
226
  echo '
227
  <!-- WPPA+ meta tags -->
228
- <meta name="title" content="' . $title . '" />
229
- <meta name="description" content="' . $desc . '" />
230
  <!-- WPPA+ Og Share data -->
231
  <meta property="og:site_name" content="' . esc_attr( sanitize_text_field( $site ) ) . '" />
232
  <meta property="og:type" content="article" />
233
- <meta property="og:url" content="' . $url . '" />
234
  <meta property="og:title" content="' . esc_attr( sanitize_text_field( $title ) ) . '" />';
235
  if ( $desc ) {
236
  echo '
@@ -238,10 +238,10 @@ if ( $desc ) {
238
  }
239
  if ( $id ) {
240
  echo '
241
- <meta property="og:image" content="' . wppa_get_photo_url( $id ) . '" />
242
- <meta property="og:image:type" content="' . $mime . '" />
243
- <meta property="og:image:width" content="' . wppa_get_photox( $id ) . '" />
244
- <meta property="og:image:height" content="' . wppa_get_photoy( $id ) . '" />';
245
  }
246
  echo '
247
  <!-- WPPA+ End Og Share data -->
@@ -286,7 +286,7 @@ global $wppa_js_page_data_file;
286
 
287
  // If the user wants the js in the footer, try to open a tempfile to collect the js data during processing the page
288
  // If opening a tempfile fails, revert to js in the header.
289
- $wppa_js_page_data_file = WPPA_UPLOAD_PATH . '/temp/wppa.' . md5( $_SERVER['REMOTE_ADDR'] . time() ) . '.js';
290
 
291
  $tempdir = WPPA_UPLOAD_PATH.'/temp';
292
  if ( ! is_dir( $tempdir ) ) @ wppa_mktree( $tempdir );
@@ -450,12 +450,12 @@ global $wppa_opt;
450
  }
451
 
452
  // wppa-init
453
- if ( ! file_exists( WPPA_PATH.'/wppa-init.'.$wppa_lang.'.js' ) ) {
454
  wppa_create_wppa_init_js();
455
  update_option( 'wppa_ini_js_version_'.$wppa_lang, get_option( 'wppa_ini_js_version_'.$wppa_lang, '0' ) + '1' );
456
  }
457
- if ( file_exists( WPPA_PATH.'/wppa-init.'.$wppa_lang.'.js' ) ) {
458
- wp_enqueue_script( 'wppa-init', WPPA_URL.'/wppa-init.'.$wppa_lang.'.js', array( 'wppa' ), get_option( 'wppa_ini_js_version_'.$wppa_lang, $footer ) );
459
  }
460
 
461
  // wppa.pagedata
@@ -1062,7 +1062,7 @@ global $wppa_init_js_data;
1062
  ';
1063
 
1064
  // Open file
1065
- $file = wppa_fopen( WPPA_PATH.'/wppa-init.'.$wppa_lang.'.js', 'wb' );
1066
  if ( $file ) {
1067
  // Write file
1068
  fwrite ( $file, $content );
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the non admin stuff
6
+ * Version 6.9.21
7
  *
8
  */
9
 
48
 
49
  // Dynamic css
50
  if ( ! wppa_switch( 'inline_css' ) ) {
51
+ if ( ! file_exists( WPPA_PATH.'/dynamic/wppa-dynamic.css' ) ) {
52
  wppa_create_wppa_dynamic_css();
53
  update_option( 'wppa_dynamic_css_version', get_option( 'wppa_dynamic_css_version', '0' ) + '1' );
54
  }
55
+ if ( file_exists( WPPA_PATH.'/dynamic/wppa-dynamic.css' ) ) {
56
+ wp_enqueue_style( 'wppa-dynamic', WPPA_URL.'/dynamic/wppa-dynamic.css', array('wppa_style'), get_option( 'wppa_dynamic_css_version' ) );
57
  }
58
  }
59
  }
165
 
166
  if ( $album ) {
167
  if ( wppa_switch( 'meta_page' ) ) {
168
+ $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE album = %s AND status = 'featured'", $album ), ARRAY_A );
169
  wppa_cache_photo( 'add', $photos );
170
  if ( $photos ) {
171
  echo("\n<!-- WPPA+ BEGIN Featured photos on this page -->");
185
 
186
  // No photo and no album, give the plain photo links of all featured photos
187
  elseif ( wppa_switch( 'meta_all' ) ) {
188
+ $photos = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos WHERE status = 'featured'", ARRAY_A);
189
  wppa_cache_photo( 'add', $photos );
190
  if ( $photos ) {
191
  echo("\n<!-- WPPA+ BEGIN Featured photos on this site -->");
206
  // No photo id and no album known yet. Also: not all featured.
207
  // Examine the page (if any) on an album id in the shortcode
208
  elseif ( wppa_switch( 'og_tags_on' ) ) {
209
+ $page = wppa_get_the_ID();
210
  if ( $page ) {
211
+ $page_content = $wpdb->get_var( "SELECT post_content FROM " . $wpdb->prefix . 'posts' . " WHERE ID = " . $page );
212
  if ( strpos( $page_content, '[wppa' ) !== false ) {
213
  $a_pos = strpos( $page_content, 'album="' );
214
  $album = substr( $page_content, $a_pos + 7, 20 );
225
 
226
  echo '
227
  <!-- WPPA+ meta tags -->
228
+ <meta name="title" content="' . esc_attr( $title ) . '" />
229
+ <meta name="description" content="' . esc_attr( $desc ) . '" />
230
  <!-- WPPA+ Og Share data -->
231
  <meta property="og:site_name" content="' . esc_attr( sanitize_text_field( $site ) ) . '" />
232
  <meta property="og:type" content="article" />
233
+ <meta property="og:url" content="' . esc_url( $url ) . '" />
234
  <meta property="og:title" content="' . esc_attr( sanitize_text_field( $title ) ) . '" />';
235
  if ( $desc ) {
236
  echo '
238
  }
239
  if ( $id ) {
240
  echo '
241
+ <meta property="og:image" content="' . esc_url( wppa_get_photo_url( $id ) ) . '" />
242
+ <meta property="og:image:type" content="' . esc_attr( $mime ) . '" />
243
+ <meta property="og:image:width" content="' . esc_attr( wppa_get_photox( $id ) ) . '" />
244
+ <meta property="og:image:height" content="' . esc_attr( wppa_get_photoy( $id ) ) . '" />';
245
  }
246
  echo '
247
  <!-- WPPA+ End Og Share data -->
286
 
287
  // If the user wants the js in the footer, try to open a tempfile to collect the js data during processing the page
288
  // If opening a tempfile fails, revert to js in the header.
289
+ $wppa_js_page_data_file = WPPA_UPLOAD_PATH . '/temp/wppa.' . wppa_get_unique_crypt() . '.js';
290
 
291
  $tempdir = WPPA_UPLOAD_PATH.'/temp';
292
  if ( ! is_dir( $tempdir ) ) @ wppa_mktree( $tempdir );
450
  }
451
 
452
  // wppa-init
453
+ if ( ! file_exists( WPPA_PATH.'/dynamic/wppa-init.'.$wppa_lang.'.js' ) ) {
454
  wppa_create_wppa_init_js();
455
  update_option( 'wppa_ini_js_version_'.$wppa_lang, get_option( 'wppa_ini_js_version_'.$wppa_lang, '0' ) + '1' );
456
  }
457
+ if ( file_exists( WPPA_PATH.'/dynamic/wppa-init.'.$wppa_lang.'.js' ) ) {
458
+ wp_enqueue_script( 'wppa-init', WPPA_URL.'/dynamic/wppa-init.'.$wppa_lang.'.js', array( 'wppa' ), get_option( 'wppa_ini_js_version_'.$wppa_lang, $footer ) );
459
  }
460
 
461
  // wppa.pagedata
1062
  ';
1063
 
1064
  // Open file
1065
+ $file = wppa_fopen( WPPA_PATH.'/dynamic/wppa-init.'.$wppa_lang.'.js', 'wb' );
1066
  if ( $file ) {
1067
  // Write file
1068
  fwrite ( $file, $content );
wppa-photo-admin-autosave.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * edit and delete photos
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -17,7 +17,7 @@ function _wppa_edit_photo() {
17
 
18
  // Edit one Photo
19
  if ( isset( $_GET['photo'] ) ) {
20
- $photo = $_GET['photo'];
21
  $thumb = wppa_cache_thumb( $photo );
22
  if ( $thumb['owner'] == wppa_get_user() ) {
23
  echo
@@ -188,7 +188,7 @@ global $wpdb;
188
  // Find pending comments
189
  $cmt = $wpdb->get_results( "SELECT photo FROM $wpdb->wppa_comments
190
  WHERE status = 'pending'
191
- OR `status` = 'spam'", ARRAY_A );
192
 
193
  $photos = array();
194
 
@@ -240,7 +240,7 @@ global $wpdb;
240
  '</h3>';
241
 
242
  $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos
243
- ORDER BY `timestamp` DESC
244
  LIMIT %d, %d", $skip, $pagesize ), ARRAY_A );
245
 
246
  $count = is_array( $photos ) ? count( $photos ) : 0;
@@ -272,6 +272,7 @@ global $wpdb;
272
 
273
  // A specific photo requested
274
  if ( $photo ) {
 
275
  echo
276
  '<div id="photoitem-' . $photo . '" class="photoitem" style="width:100%; background-color: rgb( 255, 255, 224 ); border-color: rgb( 230, 219, 85 );">' .
277
  '<span style="color:red">' .
@@ -554,8 +555,8 @@ function wppaToggleExif( id, count ) {
554
  // Album for moderate
555
  if ( $modalbum != $album && ! isset( $_GET['just-edit'] ) ) {
556
  echo '<h3>' . sprintf( __( 'Edit/Moderate photos from album %s by %s', 'wp-photo-album-plus' ),
557
- '<i>' . wppa_get_album_name( $album ) . '</i>',
558
- '<i>' . wppa_get_album_item( $album, 'owner' ) . '</i>' ) . '</h3>';
559
  $modalbum = $album;
560
  }
561
 
@@ -1015,17 +1016,17 @@ function wppaToggleExif( id, count ) {
1015
  __( 'Width:', 'wp-photo-album-plus' ) .
1016
  '<input' .
1017
  ' style="width:50px;margin:0 4px;"' .
1018
- ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'videox\', this )"' .
1019
- ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'videox\', this )"' .
1020
- ' value="' . $videox . '"' .
1021
  ' />' .
1022
  sprintf( __( 'pix, (0=default:%s)', 'wp-photo-album-plus' ), wppa_opt( 'video_width' ) ) .
1023
  __( 'Height:', 'wp-photo-album-plus' ) .
1024
  '<input' .
1025
  ' style="width:50px;margin:0 4px;"' .
1026
- ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'videoy\', this )"' .
1027
- ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'videoy\', this )"' .
1028
- ' value="' . $videoy . '"' .
1029
  ' />' .
1030
  sprintf( __( 'pix, (0=default:%s)', 'wp-photo-album-plus' ), wppa_opt( 'video_height' ) ) .
1031
  ' ' .
@@ -1193,7 +1194,7 @@ function wppaToggleExif( id, count ) {
1193
  __( 'Watermark:', 'wp-photo-album-plus') . ' ';
1194
  echo
1195
  __( 'File:', 'wp-photo-album-plus' ) . ' ' . basename( $wmfile ) . ' ' .
1196
- __( 'Pos:', 'wp-photo-album-plus') . ' ' . $wmpos;
1197
  }
1198
  echo ' ';
1199
  }
@@ -1620,16 +1621,16 @@ function wppaToggleExif( id, count ) {
1620
  __( '<b>ImageMagick</b> command stack', 'wp-photo-album-plus' ) .
1621
  ': ' .
1622
  '<span' .
1623
- ' id="imstack-' . $id . '"' .
1624
  ' style="color:blue;"' .
1625
  ' >' .
1626
- $magickstack .
1627
  '</span>' .
1628
  ' ' .
1629
  '<input' .
1630
  ' type="button"' .
1631
- ' id="imstackbutton-' . $id . '"' .
1632
- ' onclick="wppaTryMagick( ' . $id . ', \'magickundo\' )"' .
1633
  ' value="' . esc_attr( __( 'Undo', 'wp-photo-album-plus' ) ) . '"' .
1634
  ' title="' . esc_attr( __( 'Undo last Magick command', 'wp-photo-album-plus' ) ) . '"' .
1635
  ' style="' . ( $magickstack ? '' : 'display:none;' ) . '"' .
@@ -1754,7 +1755,7 @@ function wppaToggleExif( id, count ) {
1754
  ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'description\', this )"' .
1755
  ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'description\', this )"' .
1756
  ' >' .
1757
- $description .
1758
  '</textarea>' .
1759
  '</td>' .
1760
  '<td>' .
@@ -1770,7 +1771,7 @@ function wppaToggleExif( id, count ) {
1770
  __( 'Description:', 'wp-photo-album-plus') .
1771
  '</td>' .
1772
  '<td>' .
1773
- $description .
1774
  '</td>' .
1775
  '<td>' .
1776
  '</td>' .
@@ -2248,9 +2249,9 @@ function wppa_album_photos_bulk( $album ) {
2248
  break;
2249
  case 'wppa-bulk-move-to':
2250
  if ( $newalb ) {
2251
- $photo = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `id` = %s", $id ), ARRAY_A );
2252
  if ( wppa_switch( 'void_dups' ) ) { // Check for already exists
2253
- $exists = $wpdb->get_var ( $wpdb->prepare ( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `filename` = %s AND `album` = %s", $photo['filename'], $newalb ) );
2254
  if ( $exists ) { // Already exists
2255
  wppa_error_message ( sprintf ( __( 'A photo with filename %s already exists in album %s.' , 'wp-photo-album-plus'), $photo['filename'], $newalb ) );
2256
  $skip = true;
@@ -2271,7 +2272,7 @@ function wppa_album_photos_bulk( $album ) {
2271
  $photo = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos
2272
  WHERE id = %d", $id ), ARRAY_A );
2273
  if ( wppa_switch( 'void_dups' ) ) { // Check for already exists
2274
- $exists = $wpdb->get_var ( $wpdb->prepare ( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `filename` = %s AND `album` = %s", $photo['filename'], $newalb ) );
2275
  if ( $exists ) { // Already exists
2276
  wppa_error_message ( sprintf ( __( $exists.'A photo with filename %s already exists in album %s.' , 'wp-photo-album-plus'), $photo['filename'], $newalb ) );
2277
  $skip = true;
@@ -2290,7 +2291,7 @@ function wppa_album_photos_bulk( $album ) {
2290
  }
2291
  if ( current_user_can( 'wppa_admin' ) || current_user_can( 'wppa_moderate' ) ) {
2292
  if ( $status == 'publish' || $status == 'pending' || wppa_user_is( 'administrator' ) || ! wppa_switch( 'ext_status_restricted' ) ) {
2293
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `status` = %s WHERE `id` = %d", $status, $id ) );
2294
  wppa_invalidate_treecounts( wppa_get_photo_item( $id, 'album' ) );
2295
  }
2296
  else wp_die( 'Security check failure 2' );
@@ -2301,9 +2302,9 @@ function wppa_album_photos_bulk( $album ) {
2301
  if ( wppa_user_is( 'administrator' ) && wppa_switch( 'photo_owner_change' ) ) {
2302
  if ( $owner ) {
2303
  $owner = sanitize_user( $owner );
2304
- $exists = $wpdb->get_var( "SELECT COUNT(*) FROM `".$wpdb->users."` WHERE `user_login` = '".$owner."'" );
2305
  if ( $exists ) {
2306
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `owner` = %s WHERE `id` = %d", $owner, $id ) );
2307
  }
2308
  else {
2309
  wppa_error_message( 'A user with login name '.$owner.' does not exist.' );
@@ -2803,7 +2804,7 @@ function wppaSetConfirmMove( id ) {
2803
  </td>
2804
  <!-- Description -->
2805
  <td style="width:25%;" >
2806
- <textarea class="wppa-bulk-dec" style="height:50px; width:100%" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id'] ?>, 'description', this )" ><?php echo( stripslashes( $photo['description'] ) ) ?></textarea>
2807
  </td>
2808
  <!-- Status -->
2809
  <td>
@@ -3361,8 +3362,8 @@ function wppa_fe_edit_new_style( $photo ) {
3361
  '<h3>' .
3362
  '<img' .
3363
  ' style="height:50px;"' .
3364
- ' ' . ( wppa_switch( 'lazy' ) ? 'data-' : '' ) . 'src="' . wppa_get_thumb_url( $photo ) . '"' .
3365
- ' alt="' . $photo . '"' .
3366
  ( wppa_switch( 'lazy' ) ? ' class="wppa-lazy"' : '' ) .
3367
  ' />' .
3368
  '&nbsp;&nbsp;' .
3
  * Package: wp-photo-album-plus
4
  *
5
  * edit and delete photos
6
+ * Version 6.9.21
7
  *
8
  */
9
 
17
 
18
  // Edit one Photo
19
  if ( isset( $_GET['photo'] ) ) {
20
+ $photo = strval( intval( $_GET['photo'] ) );
21
  $thumb = wppa_cache_thumb( $photo );
22
  if ( $thumb['owner'] == wppa_get_user() ) {
23
  echo
188
  // Find pending comments
189
  $cmt = $wpdb->get_results( "SELECT photo FROM $wpdb->wppa_comments
190
  WHERE status = 'pending'
191
+ OR status = 'spam'", ARRAY_A );
192
 
193
  $photos = array();
194
 
240
  '</h3>';
241
 
242
  $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos
243
+ ORDER BY timestamp DESC
244
  LIMIT %d, %d", $skip, $pagesize ), ARRAY_A );
245
 
246
  $count = is_array( $photos ) ? count( $photos ) : 0;
272
 
273
  // A specific photo requested
274
  if ( $photo ) {
275
+ $photo = strval( intval( $photo ) );
276
  echo
277
  '<div id="photoitem-' . $photo . '" class="photoitem" style="width:100%; background-color: rgb( 255, 255, 224 ); border-color: rgb( 230, 219, 85 );">' .
278
  '<span style="color:red">' .
555
  // Album for moderate
556
  if ( $modalbum != $album && ! isset( $_GET['just-edit'] ) ) {
557
  echo '<h3>' . sprintf( __( 'Edit/Moderate photos from album %s by %s', 'wp-photo-album-plus' ),
558
+ '<i>' . sanitize_text_field( wppa_get_album_name( $album ) ) . '</i>',
559
+ '<i>' . sanitize_user( wppa_get_album_item( $album, 'owner' ) ) . '</i>' ) . '</h3>';
560
  $modalbum = $album;
561
  }
562
 
1016
  __( 'Width:', 'wp-photo-album-plus' ) .
1017
  '<input' .
1018
  ' style="width:50px;margin:0 4px;"' .
1019
+ ' onkeyup="wppaAjaxUpdatePhoto( ' . strval( intval( $id ) ) . ', \'videox\', this )"' .
1020
+ ' onchange="wppaAjaxUpdatePhoto( ' . strval( intval( $id ) ) . ', \'videox\', this )"' .
1021
+ ' value="' . esc_attr( $videox ) . '"' .
1022
  ' />' .
1023
  sprintf( __( 'pix, (0=default:%s)', 'wp-photo-album-plus' ), wppa_opt( 'video_width' ) ) .
1024
  __( 'Height:', 'wp-photo-album-plus' ) .
1025
  '<input' .
1026
  ' style="width:50px;margin:0 4px;"' .
1027
+ ' onkeyup="wppaAjaxUpdatePhoto( ' . strval( intval( $id ) ) . ', \'videoy\', this )"' .
1028
+ ' onchange="wppaAjaxUpdatePhoto( ' . strval( intval( $id ) ) . ', \'videoy\', this )"' .
1029
+ ' value="' . esc_attr( $videoy ) . '"' .
1030
  ' />' .
1031
  sprintf( __( 'pix, (0=default:%s)', 'wp-photo-album-plus' ), wppa_opt( 'video_height' ) ) .
1032
  ' ' .
1194
  __( 'Watermark:', 'wp-photo-album-plus') . ' ';
1195
  echo
1196
  __( 'File:', 'wp-photo-album-plus' ) . ' ' . basename( $wmfile ) . ' ' .
1197
+ __( 'Pos:', 'wp-photo-album-plus') . ' ' . sanitize_text_field( $wmpos );
1198
  }
1199
  echo ' ';
1200
  }
1621
  __( '<b>ImageMagick</b> command stack', 'wp-photo-album-plus' ) .
1622
  ': ' .
1623
  '<span' .
1624
+ ' id="imstack-' . strval( intval( $id ) ). '"' .
1625
  ' style="color:blue;"' .
1626
  ' >' .
1627
+ sanitize_text_field( $magickstack ) .
1628
  '</span>' .
1629
  ' ' .
1630
  '<input' .
1631
  ' type="button"' .
1632
+ ' id="imstackbutton-' . strval( intval( $id ) ) . '"' .
1633
+ ' onclick="wppaTryMagick( ' . strval( intval( $id ) ) . ', \'magickundo\' )"' .
1634
  ' value="' . esc_attr( __( 'Undo', 'wp-photo-album-plus' ) ) . '"' .
1635
  ' title="' . esc_attr( __( 'Undo last Magick command', 'wp-photo-album-plus' ) ) . '"' .
1636
  ' style="' . ( $magickstack ? '' : 'display:none;' ) . '"' .
1755
  ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'description\', this )"' .
1756
  ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'description\', this )"' .
1757
  ' >' .
1758
+ esc_textarea( stripslashes( $description ) ) .
1759
  '</textarea>' .
1760
  '</td>' .
1761
  '<td>' .
1771
  __( 'Description:', 'wp-photo-album-plus') .
1772
  '</td>' .
1773
  '<td>' .
1774
+ esc_html( $description ) .
1775
  '</td>' .
1776
  '<td>' .
1777
  '</td>' .
2249
  break;
2250
  case 'wppa-bulk-move-to':
2251
  if ( $newalb ) {
2252
+ $photo = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE id = %s", $id ), ARRAY_A );
2253
  if ( wppa_switch( 'void_dups' ) ) { // Check for already exists
2254
+ $exists = $wpdb->get_var ( $wpdb->prepare ( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE filename = %s AND album = %s", $photo['filename'], $newalb ) );
2255
  if ( $exists ) { // Already exists
2256
  wppa_error_message ( sprintf ( __( 'A photo with filename %s already exists in album %s.' , 'wp-photo-album-plus'), $photo['filename'], $newalb ) );
2257
  $skip = true;
2272
  $photo = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos
2273
  WHERE id = %d", $id ), ARRAY_A );
2274
  if ( wppa_switch( 'void_dups' ) ) { // Check for already exists
2275
+ $exists = $wpdb->get_var ( $wpdb->prepare ( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE filename = %s AND album = %s", $photo['filename'], $newalb ) );
2276
  if ( $exists ) { // Already exists
2277
  wppa_error_message ( sprintf ( __( $exists.'A photo with filename %s already exists in album %s.' , 'wp-photo-album-plus'), $photo['filename'], $newalb ) );
2278
  $skip = true;
2291
  }
2292
  if ( current_user_can( 'wppa_admin' ) || current_user_can( 'wppa_moderate' ) ) {
2293
  if ( $status == 'publish' || $status == 'pending' || wppa_user_is( 'administrator' ) || ! wppa_switch( 'ext_status_restricted' ) ) {
2294
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET status = %s WHERE id = %d", $status, $id ) );
2295
  wppa_invalidate_treecounts( wppa_get_photo_item( $id, 'album' ) );
2296
  }
2297
  else wp_die( 'Security check failure 2' );
2302
  if ( wppa_user_is( 'administrator' ) && wppa_switch( 'photo_owner_change' ) ) {
2303
  if ( $owner ) {
2304
  $owner = sanitize_user( $owner );
2305
+ $exists = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->users." WHERE user_login = '".$owner."'" );
2306
  if ( $exists ) {
2307
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET owner = %s WHERE id = %d", $owner, $id ) );
2308
  }
2309
  else {
2310
  wppa_error_message( 'A user with login name '.$owner.' does not exist.' );
2804
  </td>
2805
  <!-- Description -->
2806
  <td style="width:25%;" >
2807
+ <textarea class="wppa-bulk-dec" style="height:50px; width:100%" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id'] ?>, 'description', this )" ><?php echo( esc_textarea( stripslashes( $photo['description'] ) ) ) ?></textarea>
2808
  </td>
2809
  <!-- Status -->
2810
  <td>
3362
  '<h3>' .
3363
  '<img' .
3364
  ' style="height:50px;"' .
3365
+ ' ' . ( wppa_switch( 'lazy' ) ? 'data-' : '' ) . 'src="' . esc_url( wppa_get_thumb_url( $photo ) ) . '"' .
3366
+ ' alt="' . esc_attr( $photo ) . '"' .
3367
  ( wppa_switch( 'lazy' ) ? ' class="wppa-lazy"' : '' ) .
3368
  ' />' .
3369
  '&nbsp;&nbsp;' .
wppa-potd-admin.php CHANGED
@@ -464,7 +464,7 @@ global $wppa_defaults;
464
  // The image if a photo
465
  else {
466
  echo '<img' .
467
- ' src=" '. wppa_get_thumb_url( $id ) . '"' .
468
  ' style="' .
469
  'max-width:180px;' .
470
  'max-height:135px;' .
@@ -497,10 +497,10 @@ global $wppa_defaults;
497
  ' style="float:right;"' .
498
  ' type="radio"' .
499
  ' name="wppa-widget-photo"' .
500
- ' id="wppa-widget-photo-' . $id . '"' .
501
- ' value="' . $id . '"' .
502
  ( $id == $curid ? 'checked="checked"' : '' ) .
503
- ' onchange="wppaSetFixed(' . $id . ');"' .
504
  ' />';
505
  }
506
 
464
  // The image if a photo
465
  else {
466
  echo '<img' .
467
+ ' src="'. esc_url( wppa_get_thumb_url( $id ) ) . '"' .
468
  ' style="' .
469
  'max-width:180px;' .
470
  'max-height:135px;' .
497
  ' style="float:right;"' .
498
  ' type="radio"' .
499
  ' name="wppa-widget-photo"' .
500
+ ' id="wppa-widget-photo-' . strval( intval( $id ) ) . '"' .
501
+ ' value="' . esc_attr( $id ) . '"' .
502
  ( $id == $curid ? 'checked="checked"' : '' ) .
503
+ ' onchange="wppaSetFixed(' . strval( intval( $id ) ) . ');"' .
504
  ' />';
505
  }
506
 
wppa-potd-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the widget
6
- * Version 6.9.14
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
@@ -136,7 +136,7 @@ class PhotoOfTheDay extends WP_Widget {
136
  // The counter
137
  if ( wppa_switch( 'potd_counter' ) ) { // If we want this
138
  $alb = wppa_get_photo_item( $id, 'album' );
139
- $c = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `album` = " . $alb ) - 1;
140
  if ( $c > 0 ) {
141
  if ( wppa_opt( 'potd_counter_link' ) == 'thumbs' ) {
142
  $lnk = wppa_get_album_url( $alb, $page, 'thumbs', '1' );
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the widget
6
+ * Version 6.9.21
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
136
  // The counter
137
  if ( wppa_switch( 'potd_counter' ) ) { // If we want this
138
  $alb = wppa_get_photo_item( $id, 'album' );
139
+ $c = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album = " . $alb ) - 1;
140
  if ( $c > 0 ) {
141
  if ( wppa_opt( 'potd_counter_link' ) == 'thumbs' ) {
142
  $lnk = wppa_get_album_url( $alb, $page, 'thumbs', '1' );
wppa-privacy-policy.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * This file contains all procedures related to the privacy policy.
6
  *
7
- * Version 6.9.14
8
  */
9
 
10
  function wppa_comment_exporter( $email_address, $page = 1 ) {
@@ -18,8 +18,8 @@ global $wpdb;
18
  $group_label = __( 'Comments on photos', 'wp-photo-album-plus' );
19
  $comments = $wpdb->get_results( $wpdb->prepare(
20
  "SELECT * FROM $wpdb->wppa_comments " .
21
- "WHERE `email` = %s " .
22
- "ORDER BY `id` " .
23
  "LIMIT %d,%d", $email_address, ( $page - 1 ) * $number, $number
24
  ), ARRAY_A );
25
 
@@ -79,11 +79,11 @@ global $wpdb;
79
 
80
  $count = $wpdb->get_var( $wpdb->prepare(
81
  "SELECT COUNT(*) FROM $wpdb->wppa_comments " .
82
- "WHERE `email` = %s ", $email_address ) );
83
 
84
  $wpdb->query( $wpdb->prepare(
85
  "DELETE FROM $wpdb->wppa_comments " .
86
- "WHERE `email` = %s ", $email_address ) );
87
 
88
  wppa_log( 'obs', $count . ' comments found to remove' );
89
 
@@ -125,8 +125,8 @@ global $wpdb;
125
  $owner = $user->user_login;
126
  $ratings = $wpdb->get_results( $wpdb->prepare(
127
  "SELECT * FROM $wpdb->wppa_rating " .
128
- "WHERE `user` = %s " .
129
- "ORDER BY `id` " .
130
  "LIMIT %d,%d", $owner, ( $page - 1 ) * $number, $number
131
  ), ARRAY_A );
132
 
@@ -188,11 +188,11 @@ global $wpdb;
188
  $owner = $user->user_login;
189
  $count = $wpdb->get_var( $wpdb->prepare(
190
  "SELECT COUNT(*) FROM $wpdb->wppa_rating " .
191
- "WHERE `user` = %s ", $owner ) );
192
 
193
  $wpdb->query( $wpdb->prepare(
194
  "DELETE FROM $wpdb->wppa_rating " .
195
- "WHERE `user` = %s ", $owner ) );
196
 
197
  wppa_log( 'obs', $count . ' ratings found to remove' );
198
 
@@ -239,8 +239,8 @@ global $wpdb;
239
  $owner = $user->user_login;
240
  $media_items = $wpdb->get_results( $wpdb->prepare(
241
  "SELECT * FROM $wpdb->wppa_photos " .
242
- "WHERE `owner` = %s " .
243
- "AND `album` > 0 " .
244
  "LIMIT %d,%d", $owner, ( $page - 1 ) * $number, $number
245
  ), ARRAY_A );
246
 
@@ -253,13 +253,13 @@ global $wpdb;
253
  $media_export_ids[] = $id;
254
  $video_exts = wppa_is_video( $id );
255
  $audio_exts = wppa_has_audio( $id );
256
-
257
  // Make image html
258
-
259
  // Video ?
260
  if ( $video_exts ) {
261
  $media_type = __( 'Video file', 'wp-photo-album-plus' );
262
-
263
  $media_html = '<video preload="metadata" style="height:150px;float:left;" controls >';
264
  foreach( $video_exts as $ext ) {
265
  $filename = str_replace( '.xxx', '.' . $ext, wppa_get_photo_item( $id, 'filename' ) );
@@ -267,7 +267,7 @@ global $wpdb;
267
  $media_html .= '<source src="wppa-media/' . $filename . '" type="' . $mime . '" >';
268
  }
269
  $media_html .= '</video>';
270
-
271
  $poster_file = wppa_fix_poster_ext( wppa_get_photo_path( $id ), $id );
272
  if ( is_file( $poster_file ) ) {
273
  $poster_ext = wppa_get_ext( $poster_file );
@@ -275,11 +275,11 @@ global $wpdb;
275
  $media_html .= '<img src="wppa-media/Poster_' . $file . '" style="height:150px;margin-left:12px;" />';
276
  }
277
  }
278
-
279
  // Audio ?
280
  elseif( $audio_exts ) {
281
  $media_type = __( 'Audio file', 'wp-photo-album-plus' );
282
-
283
  $media_html = '<audio preload="metadata" style="width:250px;" controls >';
284
  foreach( $audio_exts as $audio_ext ) {
285
  $filename = str_replace( '.xxx', '.' . $audio_ext, wppa_get_photo_item( $id, 'filename' ) );
@@ -287,7 +287,7 @@ global $wpdb;
287
  $media_html .= '<source src="wppa-media/' . $filename . '" type="' . $mime . '" >';
288
  }
289
  $media_html .= '</audio>';
290
-
291
  $poster_file = wppa_fix_poster_ext( wppa_get_photo_path( $id ), $id );
292
  if ( is_file( $poster_file ) ) {
293
  $poster_ext = wppa_get_ext( $poster_file );
@@ -295,16 +295,16 @@ global $wpdb;
295
  $media_html .= '<img src="wppa-media/Poster_' . $file . '" style="height:150px;margin-left:12px;" />';
296
  }
297
  }
298
-
299
  // PDF Document ?
300
  elseif( wppa_get_ext( $media_item['filename'] ) == 'pdf' ) {
301
  $media_type = __( 'PDF Document', 'wp-photo-album-plus' );
302
  $filename = wppa_get_photo_item( $id, 'filename' );
303
- $media_html = '<a href="wppa-media/' . $filename . '" target="_blank" >' .
304
- '<img src="wppa-media/' . wppa_strip_ext( $filename ) . '.jpg" style="height:150px;" />' .
305
  '</a>';
306
  }
307
-
308
  // Photo
309
  else {
310
  $media_type = __( 'Photo', 'wp-photo-album-plus' );
@@ -348,8 +348,8 @@ global $wpdb;
348
 
349
  // Generic exif
350
  $exifs = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_exif " .
351
- "WHERE `photo` = " . $id . " " .
352
- "ORDER BY `tag`", ARRAY_A );
353
 
354
  if ( is_array( $exifs ) && count( $exifs ) > 0 ) {
355
  $exif_html = '<small><table><tbody>';
@@ -373,8 +373,8 @@ global $wpdb;
373
 
374
  // Generic iptc
375
  $iptcs = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_iptc " .
376
- "WHERE `photo` = " . $id . " " .
377
- "ORDER BY `tag`", ARRAY_A );
378
 
379
  if ( is_array( $iptcs ) && count( $iptcs ) > 0 ) {
380
  $iptc_html = '<small><table><tbody>';
@@ -382,8 +382,8 @@ global $wpdb;
382
  $iptc_html .=
383
  '<tr>' .
384
  '<th>' .
385
- $wpdb->get_var( "SELECT `description` FROM $wpdb->wppa_iptc " .
386
- "WHERE `photo` = 0 AND `tag` = '" . $iptc['tag'] . "'" ) .
387
  '</th>' .
388
  '<td>' .
389
  $iptc['description'] .
@@ -486,7 +486,7 @@ function wppa_add_media_to_zip( $archive_pathname, $archive_url, $html_report_pa
486
  $video_exts = wppa_is_video( $id );
487
  $audio_exts = wppa_has_audio( $id );
488
  $is_pdf = wppa_get_ext( wppa_get_photo_item( $id, 'filename' ) ) == 'pdf';
489
-
490
  // PDF ?
491
  if ( $is_pdf ) {
492
  $wppa_media_file = wppa_get_source_path( $id );
@@ -496,7 +496,7 @@ function wppa_add_media_to_zip( $archive_pathname, $archive_url, $html_report_pa
496
  $wppa_media_name = wppa_strip_ext( wppa_get_photo_item( $id, 'filename' ) ) . '.jpg';
497
  wppa_zip_addfile( $zip, $wppa_media_file, $wppa_media_name );
498
  }
499
-
500
  // VIDEO ?
501
  elseif ( $video_exts ) {
502
  foreach( $video_exts as $video_ext ) {
@@ -505,7 +505,7 @@ function wppa_add_media_to_zip( $archive_pathname, $archive_url, $html_report_pa
505
  wppa_zip_addfile( $zip, $wppa_media_file, $wppa_media_name );
506
  }
507
  }
508
-
509
  // AUDIO ?
510
  elseif ( $audio_exts ) {
511
  foreach( $audio_exts as $audio_ext ) {
@@ -514,7 +514,7 @@ function wppa_add_media_to_zip( $archive_pathname, $archive_url, $html_report_pa
514
  wppa_zip_addfile( $zip, $wppa_media_file, $wppa_media_name );
515
  }
516
  }
517
-
518
  // Photo
519
  else {
520
  $wppa_media_file = wppa_get_photo_path( $id );
@@ -542,7 +542,7 @@ function wppa_add_media_to_zip( $archive_pathname, $archive_url, $html_report_pa
542
  function wppa_zip_addfile( $zip, $wppa_media_file, $wppa_media_name ) {
543
 
544
  if ( is_file( $wppa_media_file ) ) {
545
-
546
  if ( ! $zip->addFile( $wppa_media_file, 'wppa-media/' . $wppa_media_name ) ) {
547
  $error = __( 'Unable to add data to export file.' ) . ' ' . $wppa_media_file . ' as ' . $wppa_media_name;
548
  wppa_log( 'err', $error );
@@ -550,12 +550,12 @@ function wppa_zip_addfile( $zip, $wppa_media_file, $wppa_media_name ) {
550
  else {
551
  wppa_log('obs', $wppa_media_file.' added as '. $wppa_media_name);
552
  }
553
-
554
  }
555
  else {
556
  wppa_log('err', $wppa_media_file . ' does not exist' );
557
  }
558
- }
559
 
560
  function wppa_media_eraser( $email_address, $page = 1 ) {
561
  global $wpdb;
@@ -566,8 +566,8 @@ global $wpdb;
566
  $user = get_user_by( 'email', $email_address );
567
  $media_items = $wpdb->get_results( $wpdb->prepare(
568
  "SELECT * FROM $wpdb->wppa_photos " .
569
- "WHERE `owner` = %s " .
570
- "AND `album` > 0 " .
571
  "LIMIT %d,%d", $user->user_login, ( $page - 1 ) * $number, $number
572
  ), ARRAY_A );
573
  $count = is_countable( $media_items ) ? count( $media_items ) : 0;
@@ -580,8 +580,8 @@ global $wpdb;
580
 
581
  $left_items = $wpdb->get_var( $wpdb->prepare(
582
  "SELECT COUNT(*) FROM $wpdb->wppa_photos " .
583
- "WHERE `owner` = %s " .
584
- "AND `album` > 0 ",
585
  $user->user_login
586
  ), ARRAY_A );
587
 
4
  *
5
  * This file contains all procedures related to the privacy policy.
6
  *
7
+ * Version 6.9.21
8
  */
9
 
10
  function wppa_comment_exporter( $email_address, $page = 1 ) {
18
  $group_label = __( 'Comments on photos', 'wp-photo-album-plus' );
19
  $comments = $wpdb->get_results( $wpdb->prepare(
20
  "SELECT * FROM $wpdb->wppa_comments " .
21
+ "WHERE email = %s " .
22
+ "ORDER BY id " .
23
  "LIMIT %d,%d", $email_address, ( $page - 1 ) * $number, $number
24
  ), ARRAY_A );
25
 
79
 
80
  $count = $wpdb->get_var( $wpdb->prepare(
81
  "SELECT COUNT(*) FROM $wpdb->wppa_comments " .
82
+ "WHERE email = %s ", $email_address ) );
83
 
84
  $wpdb->query( $wpdb->prepare(
85
  "DELETE FROM $wpdb->wppa_comments " .
86
+ "WHERE email = %s ", $email_address ) );
87
 
88
  wppa_log( 'obs', $count . ' comments found to remove' );
89
 
125
  $owner = $user->user_login;
126
  $ratings = $wpdb->get_results( $wpdb->prepare(
127
  "SELECT * FROM $wpdb->wppa_rating " .
128
+ "WHERE user = %s " .
129
+ "ORDER BY id " .
130
  "LIMIT %d,%d", $owner, ( $page - 1 ) * $number, $number
131
  ), ARRAY_A );
132
 
188
  $owner = $user->user_login;
189
  $count = $wpdb->get_var( $wpdb->prepare(
190
  "SELECT COUNT(*) FROM $wpdb->wppa_rating " .
191
+ "WHERE user = %s ", $owner ) );
192
 
193
  $wpdb->query( $wpdb->prepare(
194
  "DELETE FROM $wpdb->wppa_rating " .
195
+ "WHERE user = %s ", $owner ) );
196
 
197
  wppa_log( 'obs', $count . ' ratings found to remove' );
198
 
239
  $owner = $user->user_login;
240
  $media_items = $wpdb->get_results( $wpdb->prepare(
241
  "SELECT * FROM $wpdb->wppa_photos " .
242
+ "WHERE owner = %s " .
243
+ "AND album > 0 " .
244
  "LIMIT %d,%d", $owner, ( $page - 1 ) * $number, $number
245
  ), ARRAY_A );
246
 
253
  $media_export_ids[] = $id;
254
  $video_exts = wppa_is_video( $id );
255
  $audio_exts = wppa_has_audio( $id );
256
+
257
  // Make image html
258
+
259
  // Video ?
260
  if ( $video_exts ) {
261
  $media_type = __( 'Video file', 'wp-photo-album-plus' );
262
+
263
  $media_html = '<video preload="metadata" style="height:150px;float:left;" controls >';
264
  foreach( $video_exts as $ext ) {
265
  $filename = str_replace( '.xxx', '.' . $ext, wppa_get_photo_item( $id, 'filename' ) );
267
  $media_html .= '<source src="wppa-media/' . $filename . '" type="' . $mime . '" >';
268
  }
269
  $media_html .= '</video>';
270
+
271
  $poster_file = wppa_fix_poster_ext( wppa_get_photo_path( $id ), $id );
272
  if ( is_file( $poster_file ) ) {
273
  $poster_ext = wppa_get_ext( $poster_file );
275
  $media_html .= '<img src="wppa-media/Poster_' . $file . '" style="height:150px;margin-left:12px;" />';
276
  }
277
  }
278
+
279
  // Audio ?
280
  elseif( $audio_exts ) {
281
  $media_type = __( 'Audio file', 'wp-photo-album-plus' );
282
+
283
  $media_html = '<audio preload="metadata" style="width:250px;" controls >';
284
  foreach( $audio_exts as $audio_ext ) {
285
  $filename = str_replace( '.xxx', '.' . $audio_ext, wppa_get_photo_item( $id, 'filename' ) );
287
  $media_html .= '<source src="wppa-media/' . $filename . '" type="' . $mime . '" >';
288
  }
289
  $media_html .= '</audio>';
290
+
291
  $poster_file = wppa_fix_poster_ext( wppa_get_photo_path( $id ), $id );
292
  if ( is_file( $poster_file ) ) {
293
  $poster_ext = wppa_get_ext( $poster_file );
295
  $media_html .= '<img src="wppa-media/Poster_' . $file . '" style="height:150px;margin-left:12px;" />';
296
  }
297
  }
298
+
299
  // PDF Document ?
300
  elseif( wppa_get_ext( $media_item['filename'] ) == 'pdf' ) {
301
  $media_type = __( 'PDF Document', 'wp-photo-album-plus' );
302
  $filename = wppa_get_photo_item( $id, 'filename' );
303
+ $media_html = '<a href="wppa-media/' . $filename . '" target="_blank" >' .
304
+ '<img src="wppa-media/' . wppa_strip_ext( $filename ) . '.jpg" style="height:150px;" />' .
305
  '</a>';
306
  }
307
+
308
  // Photo
309
  else {
310
  $media_type = __( 'Photo', 'wp-photo-album-plus' );
348
 
349
  // Generic exif
350
  $exifs = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_exif " .
351
+ "WHERE photo = " . $id . " " .
352
+ "ORDER BY tag", ARRAY_A );
353
 
354
  if ( is_array( $exifs ) && count( $exifs ) > 0 ) {
355
  $exif_html = '<small><table><tbody>';
373
 
374
  // Generic iptc
375
  $iptcs = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_iptc " .
376
+ "WHERE photo = " . $id . " " .
377
+ "ORDER BY tag", ARRAY_A );
378
 
379
  if ( is_array( $iptcs ) && count( $iptcs ) > 0 ) {
380
  $iptc_html = '<small><table><tbody>';
382
  $iptc_html .=
383
  '<tr>' .
384
  '<th>' .
385
+ $wpdb->get_var( "SELECT description FROM $wpdb->wppa_iptc " .
386
+ "WHERE photo = 0 AND tag = '" . $iptc['tag'] . "'" ) .
387
  '</th>' .
388
  '<td>' .
389
  $iptc['description'] .
486
  $video_exts = wppa_is_video( $id );
487
  $audio_exts = wppa_has_audio( $id );
488
  $is_pdf = wppa_get_ext( wppa_get_photo_item( $id, 'filename' ) ) == 'pdf';
489
+
490
  // PDF ?
491
  if ( $is_pdf ) {
492
  $wppa_media_file = wppa_get_source_path( $id );
496
  $wppa_media_name = wppa_strip_ext( wppa_get_photo_item( $id, 'filename' ) ) . '.jpg';
497
  wppa_zip_addfile( $zip, $wppa_media_file, $wppa_media_name );
498
  }
499
+
500
  // VIDEO ?
501
  elseif ( $video_exts ) {
502
  foreach( $video_exts as $video_ext ) {
505
  wppa_zip_addfile( $zip, $wppa_media_file, $wppa_media_name );
506
  }
507
  }
508
+
509
  // AUDIO ?
510
  elseif ( $audio_exts ) {
511
  foreach( $audio_exts as $audio_ext ) {
514
  wppa_zip_addfile( $zip, $wppa_media_file, $wppa_media_name );
515
  }
516
  }
517
+
518
  // Photo
519
  else {
520
  $wppa_media_file = wppa_get_photo_path( $id );
542
  function wppa_zip_addfile( $zip, $wppa_media_file, $wppa_media_name ) {
543
 
544
  if ( is_file( $wppa_media_file ) ) {
545
+
546
  if ( ! $zip->addFile( $wppa_media_file, 'wppa-media/' . $wppa_media_name ) ) {
547
  $error = __( 'Unable to add data to export file.' ) . ' ' . $wppa_media_file . ' as ' . $wppa_media_name;
548
  wppa_log( 'err', $error );
550
  else {
551
  wppa_log('obs', $wppa_media_file.' added as '. $wppa_media_name);
552
  }
553
+
554
  }
555
  else {
556
  wppa_log('err', $wppa_media_file . ' does not exist' );
557
  }
558
+ }
559
 
560
  function wppa_media_eraser( $email_address, $page = 1 ) {
561
  global $wpdb;
566
  $user = get_user_by( 'email', $email_address );
567
  $media_items = $wpdb->get_results( $wpdb->prepare(
568
  "SELECT * FROM $wpdb->wppa_photos " .
569
+ "WHERE owner = %s " .
570
+ "AND album > 0 " .
571
  "LIMIT %d,%d", $user->user_login, ( $page - 1 ) * $number, $number
572
  ), ARRAY_A );
573
  $count = is_countable( $media_items ) ? count( $media_items ) : 0;
580
 
581
  $left_items = $wpdb->get_var( $wpdb->prepare(
582
  "SELECT COUNT(*) FROM $wpdb->wppa_photos " .
583
+ "WHERE owner = %s " .
584
+ "AND album > 0 ",
585
  $user->user_login
586
  ), ARRAY_A );
587
 
wppa-session.php CHANGED
@@ -18,7 +18,8 @@ if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
18
  // Generate a unique session id
19
  function wppa_get_session_id() {
20
  global $wppa_api_version;
21
- $id = md5( $_SERVER["REMOTE_ADDR"] . ( isset( $_SERVER["HTTP_USER_AGENT"] ) ? $_SERVER["HTTP_USER_AGENT"] : '' ) . $wppa_api_version );
 
22
  return $id;
23
  }
24
 
18
  // Generate a unique session id
19
  function wppa_get_session_id() {
20
  global $wppa_api_version;
21
+ $id = $_SERVER["REMOTE_ADDR"] . ( isset( $_SERVER["HTTP_USER_AGENT"] ) ? $_SERVER["HTTP_USER_AGENT"] : '' ) . $wppa_api_version;
22
+ $id = str_replace( array( ' ', '.', '/', ':', ')', '(', ';', '-' ), '', $id );
23
  return $id;
24
  }
25
 
wppa-settings-autosave.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all options
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -40,6 +40,9 @@ var_dump ( json_decode( json_encode( unserialize( $session['data'] ) )));
40
  */
41
  //global $wppa_session;
42
  //var_dump($wppa_session['wfcart']);
 
 
 
43
  // End test area
44
 
45
  // Initialize
@@ -207,7 +210,7 @@ var_dump ( json_decode( json_encode( unserialize( $session['data'] ) )));
207
  wppa_update_option( 'wppa_audiostub', 'audiostub'. $ext );
208
 
209
  // Thumbx, thumby, phtox and photoy must be cleared for the new stub
210
- $wpdb->query( "UPDATE $wpdb->wppa_photos SET `thumbx` = 0, `thumby` = 0, `photox` = 0, `photoy` = 0 WHERE `ext` = 'xxx'" );
211
  wppa_alert( sprintf( __( 'Upload of %s done', 'wp-photo-album-plus'), basename( sanitize_file_name( $file['name'] ) ) ) );
212
  }
213
  }
@@ -230,9 +233,9 @@ var_dump ( json_decode( json_encode( unserialize( $session['data'] ) )));
230
  'document.location=' .
231
  'document.location+"&' .
232
  'wppa_settings_submit=Doit&' .
233
- 'wppa-nonce=' . $_REQUEST['wppa-nonce'] . '&' .
234
  'wppa-key=' . $key . '&' .
235
- '_wp_http_referer=' . $_REQUEST['_wp_http_referer'] . '"' .
236
  '</script>';
237
  }
238
  break;
@@ -250,9 +253,9 @@ var_dump ( json_decode( json_encode( unserialize( $session['data'] ) )));
250
  'document.location=' .
251
  'document.location+"&' .
252
  'wppa_settings_submit=Doit&' .
253
- 'wppa-nonce=' . $_REQUEST['wppa-nonce'] . '&' .
254
  'wppa-key=' . $key . '&' .
255
- '_wp_http_referer=' . $_REQUEST['_wp_http_referer'] . '"' .
256
  '</script>';
257
  }
258
  break;
@@ -9041,7 +9044,7 @@ var_dump ( json_decode( json_encode( unserialize( $session['data'] ) )));
9041
  $slug = 'wppa_default_parent';
9042
  $opts = array( __('--- none ---', 'wp-photo-album-plus'), __('--- separate ---', 'wp-photo-album-plus') );
9043
  $vals = array( '0', '-1');
9044
- $albs = $wpdb->get_results( "SELECT `id`, `name` FROM $wpdb->wppa_albums ORDER BY `name`", ARRAY_A );
9045
  if ( $albs ) {
9046
  foreach ( $albs as $alb ) {
9047
  $opts[] = __(stripslashes($alb['name']), 'wp-photo-album-plus');
@@ -9117,7 +9120,7 @@ var_dump ( json_decode( json_encode( unserialize( $session['data'] ) )));
9117
  $slug = 'wppa_grant_parent';
9118
  $opts = array( __('--- none ---', 'wp-photo-album-plus'), __('--- separate ---', 'wp-photo-album-plus') );
9119
  $vals = array( 'zero', '-1');
9120
- $albs = $wpdb->get_results( "SELECT `id`, `name` FROM $wpdb->wppa_albums ORDER BY `name`", ARRAY_A );
9121
  if ( $albs ) {
9122
  foreach ( $albs as $alb ) {
9123
  $opts[] = __(stripslashes($alb['name']), 'wp-photo-album-plus');
@@ -9742,7 +9745,7 @@ var_dump ( json_decode( json_encode( unserialize( $session['data'] ) )));
9742
  $desc = __('A real life preview. To update: refresh the page.', 'wp-photo-album-plus');
9743
  $help = '';
9744
  $slug = 'wppa_watermark_preview';
9745
- $id = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_photos ORDER BY RAND() LIMIT 1" );
9746
  $tr = floor( 127 * ( 100 - wppa_opt( 'watermark_opacity_text' ) ) / 100 );
9747
  $args = array( 'id' => $id, 'content' => '---predef---', 'pos' => 'cencen', 'url' => true, 'width' => '1000', 'height' => '400', 'transp' => $tr );
9748
  $html = '<div style="text-align:center; max-width:400px; overflow:hidden; background-image:url('.WPPA_UPLOAD_URL.'/fonts/turkije.jpg);" ><img src="'.wppa_create_textual_watermark_file( $args ).'?ver='.rand(0, 4711).'" /></div><div style="clear:both;"></div>';
@@ -10535,7 +10538,7 @@ var_dump ( json_decode( json_encode( unserialize( $session['data'] ) )));
10535
  $html = wppa_input( $slug, '220', __('Enter album ids separated by commas','wp-photo-album-plus' ) );
10536
  }
10537
  else {
10538
- $albums = $wpdb->get_results( "SELECT `id`, `name` FROM $wpdb->wppa_albums", ARRAY_A );
10539
  $albums = wppa_add_paths( $albums );
10540
  $albums = wppa_array_sort( $albums, 'name' );
10541
  $opts = array();
@@ -11257,7 +11260,7 @@ function wppa_textarea($xslug, $buttonlabel = '') {
11257
  $tit = __('Slug =', 'wp-photo-album-plus').' '.$xslug;
11258
  $title = wppa_switch( 'enable_shortcode_wppa_set' ) ? ' title="'.esc_attr( $tit ).'"' : '';
11259
 
11260
- $html = '<textarea id="'.$slug.'"'.$title.' style="float:left; width:300px;" onchange="wppaAjaxUpdateOptionValue(\''.$slug.'\', this)" >';
11261
  $html .= esc_textarea( stripslashes( wppa_opt( $slug )));
11262
  $html .= '</textarea>';
11263
 
@@ -11690,7 +11693,7 @@ global $wppa_opt;
11690
  $slug = substr( $xslug, 5 );
11691
 
11692
  // If page vanished, update to 0
11693
- $iret = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . $wpdb->posts . "` WHERE `post_type` = 'page' AND `post_status` = 'publish' AND `ID` = %s", wppa_opt( $slug )));
11694
  if ( ! $iret ) {
11695
  wppa_update_option($slug, '0');
11696
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all options
6
+ * Version 6.9.21
7
  *
8
  */
9
 
40
  */
41
  //global $wppa_session;
42
  //var_dump($wppa_session['wfcart']);
43
+ //for ( $i = 0; $i < 10; $i++ ) {
44
+ // echo crypt( microtime(), rand( 1000, 4711 ) ) . '<br />';
45
+ //}
46
  // End test area
47
 
48
  // Initialize
210
  wppa_update_option( 'wppa_audiostub', 'audiostub'. $ext );
211
 
212
  // Thumbx, thumby, phtox and photoy must be cleared for the new stub
213
+ $wpdb->query( "UPDATE $wpdb->wppa_photos SET thumbx = 0, thumby = 0, photox = 0, photoy = 0 WHERE ext = 'xxx'" );
214
  wppa_alert( sprintf( __( 'Upload of %s done', 'wp-photo-album-plus'), basename( sanitize_file_name( $file['name'] ) ) ) );
215
  }
216
  }
233
  'document.location=' .
234
  'document.location+"&' .
235
  'wppa_settings_submit=Doit&' .
236
+ 'wppa-nonce=' . esc_attr( $_REQUEST['wppa-nonce'] ) . '&' .
237
  'wppa-key=' . $key . '&' .
238
+ '_wp_http_referer=' . esc_url( $_REQUEST['_wp_http_referer'] ) . '"' .
239
  '</script>';
240
  }
241
  break;
253
  'document.location=' .
254
  'document.location+"&' .
255
  'wppa_settings_submit=Doit&' .
256
+ 'wppa-nonce=' . esc_attr( $_REQUEST['wppa-nonce'] ) . '&' .
257
  'wppa-key=' . $key . '&' .
258
+ '_wp_http_referer=' . esc_url( $_REQUEST['_wp_http_referer'] ) . '"' .
259
  '</script>';
260
  }
261
  break;
9044
  $slug = 'wppa_default_parent';
9045
  $opts = array( __('--- none ---', 'wp-photo-album-plus'), __('--- separate ---', 'wp-photo-album-plus') );
9046
  $vals = array( '0', '-1');
9047
+ $albs = $wpdb->get_results( "SELECT id, name FROM $wpdb->wppa_albums ORDER BY name", ARRAY_A );
9048
  if ( $albs ) {
9049
  foreach ( $albs as $alb ) {
9050
  $opts[] = __(stripslashes($alb['name']), 'wp-photo-album-plus');
9120
  $slug = 'wppa_grant_parent';
9121
  $opts = array( __('--- none ---', 'wp-photo-album-plus'), __('--- separate ---', 'wp-photo-album-plus') );
9122
  $vals = array( 'zero', '-1');
9123
+ $albs = $wpdb->get_results( "SELECT id, name FROM $wpdb->wppa_albums ORDER BY name", ARRAY_A );
9124
  if ( $albs ) {
9125
  foreach ( $albs as $alb ) {
9126
  $opts[] = __(stripslashes($alb['name']), 'wp-photo-album-plus');
9745
  $desc = __('A real life preview. To update: refresh the page.', 'wp-photo-album-plus');
9746
  $help = '';
9747
  $slug = 'wppa_watermark_preview';
9748
+ $id = $wpdb->get_var( "SELECT id FROM $wpdb->wppa_photos ORDER BY RAND() LIMIT 1" );
9749
  $tr = floor( 127 * ( 100 - wppa_opt( 'watermark_opacity_text' ) ) / 100 );
9750
  $args = array( 'id' => $id, 'content' => '---predef---', 'pos' => 'cencen', 'url' => true, 'width' => '1000', 'height' => '400', 'transp' => $tr );
9751
  $html = '<div style="text-align:center; max-width:400px; overflow:hidden; background-image:url('.WPPA_UPLOAD_URL.'/fonts/turkije.jpg);" ><img src="'.wppa_create_textual_watermark_file( $args ).'?ver='.rand(0, 4711).'" /></div><div style="clear:both;"></div>';
10538
  $html = wppa_input( $slug, '220', __('Enter album ids separated by commas','wp-photo-album-plus' ) );
10539
  }
10540
  else {
10541
+ $albums = $wpdb->get_results( "SELECT id, name FROM $wpdb->wppa_albums", ARRAY_A );
10542
  $albums = wppa_add_paths( $albums );
10543
  $albums = wppa_array_sort( $albums, 'name' );
10544
  $opts = array();
11260
  $tit = __('Slug =', 'wp-photo-album-plus').' '.$xslug;
11261
  $title = wppa_switch( 'enable_shortcode_wppa_set' ) ? ' title="'.esc_attr( $tit ).'"' : '';
11262
 
11263
+ $html = '<textarea id="'.esc_attr($slug).'"'.$title.' style="float:left; width:300px;" onchange="wppaAjaxUpdateOptionValue(\''.$slug.'\', this)" >';
11264
  $html .= esc_textarea( stripslashes( wppa_opt( $slug )));
11265
  $html .= '</textarea>';
11266
 
11693
  $slug = substr( $xslug, 5 );
11694
 
11695
  // If page vanished, update to 0
11696
+ $iret = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM " . $wpdb->posts . " WHERE post_type = 'page' AND post_status = 'publish' AND ID = %s", wppa_opt( $slug )));
11697
  if ( ! $iret ) {
11698
  wppa_update_option($slug, '0');
11699
  }
wppa-setup.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the setup stuff
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -252,7 +252,7 @@ global $silent;
252
  if ( $old_rev <= '455') { // rating_count added to WPPA_PHOTOS
253
  $phs = $wpdb->get_results( "SELECT id FROM $wpdb->wppa_photos", ARRAY_A );
254
  if ($phs) foreach ($phs as $ph) {
255
- $cnt = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM `'.WPPA_RATING.'` WHERE `photo` = %s', $ph['id']));
256
  $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos
257
  SET rating_count = %d
258
  WHERE id = %d", $cnt, $ph['id'] ) );
@@ -266,12 +266,12 @@ global $silent;
266
  if ( $old_rev <= '474' ) { // Convert album and photo descriptions to contain html instead of htmlspecialchars. Allowing html is assumed, if not permitted, wppa_html will convert to specialcars.
267
  // html
268
  $at = 0; $ah = 0; $pt = 0; $ph = 0;
269
- $albs = $wpdb->get_results('SELECT `id`, `description` FROM '.WPPA_ALBUMS, ARRAY_A);
270
  if ($albs) {
271
  foreach($albs as $alb) {
272
  $at++;
273
  if (html_entity_decode($alb['description']) != $alb['description']) {
274
- $wpdb->query($wpdb->prepare('UPDATE `'.WPPA_ALBUMS.'` SET `description` = %s WHERE `id` = %s', html_entity_decode($alb['description']), $alb['id']));
275
  $ah++;
276
  }
277
  }
@@ -343,7 +343,7 @@ global $silent;
343
  }
344
 
345
  if ( $old_rev <= '5307' ) {
346
- $wpdb->query( "TRUNCATE TABLE `".WPPA_SESSION."`" );
347
  }
348
 
349
  if ( $old_rev <= '5308' ) {
@@ -383,13 +383,13 @@ global $silent;
383
  }
384
 
385
  if ( $old_rev <= '6310' ) {
386
- $wpdb->query("UPDATE $wpdb->wppa_photos SET `timestamp` = '0' WHERE `timestamp` = ''");
387
- $wpdb->query("UPDATE $wpdb->wppa_photos SET `modified` = `timestamp` WHERE `modified` = '' OR `modified` = '0'");
388
  }
389
 
390
  if ( $old_rev <= '6312' ) {
391
- $wpdb->query("UPDATE $wpdb->wppa_albums SET `timestamp` = '0' WHERE `timestamp` = ''");
392
- $wpdb->query("UPDATE $wpdb->wppa_albums SET `modified` = `timestamp` WHERE `modified` = '' OR `modified` = '0'");
393
  wppa_copy_setting( 'wppa_wppa_set_shortcodes', 'wppa_set_shortcodes' );
394
  wppa_remove_setting( 'wppa_wppa_set_shortcodes' );
395
  wppa_copy_setting( 'wppa_max_album_newtime', 'wppa_max_album_modtime' );
@@ -425,7 +425,7 @@ global $silent;
425
  }
426
 
427
  if ( $old_rev <= '6410' ) {
428
- // @ $wpdb->query( "UPDATE `wp_options` SET `autoload` = 'no' WHERE `option_name` LIKE 'wppa_%'");
429
  }
430
 
431
  if ( $old_rev <= '6411' ) {
@@ -521,7 +521,7 @@ global $silent;
521
  if ( $old_rev <= '6611' ) {
522
  delete_option( 'wppa_cached_options' );
523
  delete_option( 'wppa_md5_options' );
524
- @ $wpdb->query( "UPDATE `" . $wpdb->options . "` SET `autoload` = 'yes' WHERE `option_name` LIKE 'wppa_%'");
525
  if ( get_option( 'wppa_fe_alert' ) == 'no' ) {
526
  update_option( 'wppa_fe_alert', '-none-' );
527
  }
@@ -555,9 +555,9 @@ global $silent;
555
  }
556
 
557
  if ( $old_rev <= '6800' ) {
558
- $wpdb->query( "ALTER TABLE $wpdb->wppa_iptc MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT" );
559
- $wpdb->query( "ALTER TABLE $wpdb->wppa_exif MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT" );
560
- $wpdb->query( "ALTER TABLE $wpdb->wppa_index MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT" );
561
  delete_option( 'wppa_' . WPPA_IPTC . '_lastkey' );
562
  delete_option( 'wppa_' . WPPA_EXIF . '_lastkey' );
563
  delete_option( 'wppa_' . WPPA_INDEX . '_lastkey' );
@@ -568,11 +568,11 @@ global $silent;
568
  // Fix exiflables that were undefined so far but have a known description by now
569
  if ( $old_rev <= '6801' ) {
570
  if ( function_exists( 'exif_tagname' ) && function_exists( 'exif_read_data' ) ) {
571
- $exif_labels = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_exif WHERE `photo` = 0 AND `description` LIKE 'UndefinedTag%'", ARRAY_A );
572
  if ( ! empty( $exif_labels ) ) foreach( $exif_labels as $label ) {
573
  $newdesc = wppa_exif_tagname( $label['tag'] );
574
  if ( $newdesc != $label['description'] ) {
575
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_exif SET `description` = %s WHERE `photo` = 0 AND `tag` = %s", $newdesc, $label['tag'] ) );
576
  wppa_log( 'obs', 'There is a new desc for '.$label['tag'].' being: '.$newdesc );
577
  }
578
  }
@@ -657,14 +657,14 @@ global $silent;
657
  }
658
 
659
  // Remove dynamic files
660
- $files = glob( WPPA_PATH.'/wppa-init.*.js' );
661
  if ( $files ) {
662
  foreach ( $files as $file ) {
663
- unlink ( $file ); // Will be auto re-created
664
  }
665
  }
666
- if ( is_file( WPPA_PATH.'/wppa-dynamic.css' ) ) {
667
- unlink ( WPPA_PATH.'/wppa-dynamic.css' ); // Will be auto re-created
668
  }
669
 
670
  // Done!
@@ -2100,9 +2100,9 @@ static $user;
2100
  case 'category':
2101
 
2102
  // The option hold a category
2103
- $grant_parents = $wpdb->get_col( "SELECT `id` " .
2104
  "FROM $wpdb->wppa_albums " .
2105
- "WHERE `cats` LIKE '%," . wppa_opt( 'grant_parent' ) . ",%'"
2106
  );
2107
  if ( empty( $grant_parents ) ) {
2108
  // Selection set to category, but no albums exist with that category
@@ -2111,9 +2111,9 @@ static $user;
2111
  break;
2112
 
2113
  case 'indexsearch':
2114
- $temp = $wpdb->get_var( "SELECT `albums` " .
2115
  "FROM $wpdb->wppa_index " .
2116
- "WHERE `slug` = '" . wppa_opt( 'grant_parent' ) . "'"
2117
  );
2118
 
2119
  $grant_parents = explode( '.', wppa_expand_enum( $temp ) );
@@ -2133,7 +2133,7 @@ static $user;
2133
 
2134
  // Get all the parents of the current user albums if not done already
2135
  if ( ! is_array( $my_albs_parents ) ) {
2136
- $query = $wpdb->prepare( "SELECT DISTINCT `a_parent` FROM $wpdb->wppa_albums WHERE `owner` = %s", $owner );
2137
  $my_albs_parents = $wpdb->get_col( $query );
2138
  if ( ! is_array( $my_albs_parents ) ) {
2139
  $my_albs_parents = array();
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the setup stuff
6
+ * Version 6.9.21
7
  *
8
  */
9
 
252
  if ( $old_rev <= '455') { // rating_count added to WPPA_PHOTOS
253
  $phs = $wpdb->get_results( "SELECT id FROM $wpdb->wppa_photos", ARRAY_A );
254
  if ($phs) foreach ($phs as $ph) {
255
+ $cnt = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM '.WPPA_RATING.' WHERE photo = %s', $ph['id']));
256
  $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos
257
  SET rating_count = %d
258
  WHERE id = %d", $cnt, $ph['id'] ) );
266
  if ( $old_rev <= '474' ) { // Convert album and photo descriptions to contain html instead of htmlspecialchars. Allowing html is assumed, if not permitted, wppa_html will convert to specialcars.
267
  // html
268
  $at = 0; $ah = 0; $pt = 0; $ph = 0;
269
+ $albs = $wpdb->get_results('SELECT id, description FROM '.WPPA_ALBUMS, ARRAY_A);
270
  if ($albs) {
271
  foreach($albs as $alb) {
272
  $at++;
273
  if (html_entity_decode($alb['description']) != $alb['description']) {
274
+ $wpdb->query($wpdb->prepare('UPDATE '.WPPA_ALBUMS.' SET description = %s WHERE id = %s', html_entity_decode($alb['description']), $alb['id']));
275
  $ah++;
276
  }
277
  }
343
  }
344
 
345
  if ( $old_rev <= '5307' ) {
346
+ $wpdb->query( "TRUNCATE TABLE ".WPPA_SESSION."" );
347
  }
348
 
349
  if ( $old_rev <= '5308' ) {
383
  }
384
 
385
  if ( $old_rev <= '6310' ) {
386
+ $wpdb->query("UPDATE $wpdb->wppa_photos SET timestamp = '0' WHERE timestamp = ''");
387
+ $wpdb->query("UPDATE $wpdb->wppa_photos SET modified = timestamp WHERE modified = '' OR modified = '0'");
388
  }
389
 
390
  if ( $old_rev <= '6312' ) {
391
+ $wpdb->query("UPDATE $wpdb->wppa_albums SET timestamp = '0' WHERE timestamp = ''");
392
+ $wpdb->query("UPDATE $wpdb->wppa_albums SET modified = timestamp WHERE modified = '' OR modified = '0'");
393
  wppa_copy_setting( 'wppa_wppa_set_shortcodes', 'wppa_set_shortcodes' );
394
  wppa_remove_setting( 'wppa_wppa_set_shortcodes' );
395
  wppa_copy_setting( 'wppa_max_album_newtime', 'wppa_max_album_modtime' );
425
  }
426
 
427
  if ( $old_rev <= '6410' ) {
428
+ // @ $wpdb->query( "UPDATE wp_options SET autoload = 'no' WHERE option_name LIKE 'wppa_%'");
429
  }
430
 
431
  if ( $old_rev <= '6411' ) {
521
  if ( $old_rev <= '6611' ) {
522
  delete_option( 'wppa_cached_options' );
523
  delete_option( 'wppa_md5_options' );
524
+ @ $wpdb->query( "UPDATE " . $wpdb->options . " SET autoload = 'yes' WHERE option_name LIKE 'wppa_%'");
525
  if ( get_option( 'wppa_fe_alert' ) == 'no' ) {
526
  update_option( 'wppa_fe_alert', '-none-' );
527
  }
555
  }
556
 
557
  if ( $old_rev <= '6800' ) {
558
+ $wpdb->query( "ALTER TABLE $wpdb->wppa_iptc MODIFY id bigint(20) NOT NULL AUTO_INCREMENT" );
559
+ $wpdb->query( "ALTER TABLE $wpdb->wppa_exif MODIFY id bigint(20) NOT NULL AUTO_INCREMENT" );
560
+ $wpdb->query( "ALTER TABLE $wpdb->wppa_index MODIFY id bigint(20) NOT NULL AUTO_INCREMENT" );
561
  delete_option( 'wppa_' . WPPA_IPTC . '_lastkey' );
562
  delete_option( 'wppa_' . WPPA_EXIF . '_lastkey' );
563
  delete_option( 'wppa_' . WPPA_INDEX . '_lastkey' );
568
  // Fix exiflables that were undefined so far but have a known description by now
569
  if ( $old_rev <= '6801' ) {
570
  if ( function_exists( 'exif_tagname' ) && function_exists( 'exif_read_data' ) ) {
571
+ $exif_labels = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_exif WHERE photo = 0 AND description LIKE 'UndefinedTag%'", ARRAY_A );
572
  if ( ! empty( $exif_labels ) ) foreach( $exif_labels as $label ) {
573
  $newdesc = wppa_exif_tagname( $label['tag'] );
574
  if ( $newdesc != $label['description'] ) {
575
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_exif SET description = %s WHERE photo = 0 AND tag = %s", $newdesc, $label['tag'] ) );
576
  wppa_log( 'obs', 'There is a new desc for '.$label['tag'].' being: '.$newdesc );
577
  }
578
  }
657
  }
658
 
659
  // Remove dynamic files
660
+ $files = glob( WPPA_PATH.'/dynamic/wppa-init.*.js' );
661
  if ( $files ) {
662
  foreach ( $files as $file ) {
663
+ wppa_unlink ( $file ); // Will be auto re-created
664
  }
665
  }
666
+ if ( is_file( WPPA_PATH.'/dynamic/wppa-dynamic.css' ) ) {
667
+ wppa_unlink ( WPPA_PATH.'/dynamic/wppa-dynamic.css' ); // Will be auto re-created
668
  }
669
 
670
  // Done!
2100
  case 'category':
2101
 
2102
  // The option hold a category
2103
+ $grant_parents = $wpdb->get_col( "SELECT id " .
2104
  "FROM $wpdb->wppa_albums " .
2105
+ "WHERE cats LIKE '%," . wppa_opt( 'grant_parent' ) . ",%'"
2106
  );
2107
  if ( empty( $grant_parents ) ) {
2108
  // Selection set to category, but no albums exist with that category
2111
  break;
2112
 
2113
  case 'indexsearch':
2114
+ $temp = $wpdb->get_var( "SELECT albums " .
2115
  "FROM $wpdb->wppa_index " .
2116
+ "WHERE slug = '" . wppa_opt( 'grant_parent' ) . "'"
2117
  );
2118
 
2119
  $grant_parents = explode( '.', wppa_expand_enum( $temp ) );
2133
 
2134
  // Get all the parents of the current user albums if not done already
2135
  if ( ! is_array( $my_albs_parents ) ) {
2136
+ $query = $wpdb->prepare( "SELECT DISTINCT a_parent FROM $wpdb->wppa_albums WHERE owner = %s", $owner );
2137
  $my_albs_parents = $wpdb->get_col( $query );
2138
  if ( ! is_array( $my_albs_parents ) ) {
2139
  $my_albs_parents = array();
wppa-slideshow.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the slideshow high level functions
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -660,7 +660,7 @@ function wppa_slide_custom( $opt = '' ) {
660
  // w#fotomoto
661
  $f_on_this = false;
662
  if ( function_exists( 'fotomoto_page_enabled' ) ) {
663
- $f_on_this = ! wppa( 'in_widget' ) && fotomoto_page_enabled( get_the_ID() );
664
  }
665
  if ( wppa_switch( 'fotomoto_on' ) && $f_on_this ) {
666
  $fontsize = wppa_opt( 'fotomoto_fontsize' );
@@ -888,7 +888,7 @@ global $wpdb;
888
  if ( wppa_get_photo_item( $id, 'owner' ) == wppa_get_user() && ! wppa_switch( 'allow_owner_votes' ) ) {
889
  return '<span class="'.$class.'" >' . __( 'Sorry, you can not rate your own photos' , 'wp-photo-album-plus') . '</span>';
890
  }
891
- $mylast = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM `'.WPPA_RATING.'` WHERE `photo` = %s AND `user` = %s ORDER BY `id` DESC LIMIT 1', $id, wppa_get_user() ), ARRAY_A );
892
  if ( $mylast && ! wppa_switch( 'rating_change' ) && ! wppa_switch( 'rating_multi' ) ) {
893
  return '<span class="'.$class.'" >' . __( 'Sorry, you can rate a photo only once', 'wp-photo-album-plus' ) . '</span>';
894
  }
@@ -1475,8 +1475,8 @@ function wppa_numberbar( $opt = '' ) {
1475
  '</a>'
1476
  );
1477
  if ( $numid == 0 ) {
1478
- wppa_out( '<span
1479
- id="wppa-nbar-' . wppa( 'mocc' ) . '-lodots"
1480
  style="float:left;
1481
  display:none;
1482
  background-color:transparent;
@@ -1485,8 +1485,8 @@ function wppa_numberbar( $opt = '' ) {
1485
  >...</span>' );
1486
  }
1487
  if ( $numid == $count - 2 ) {
1488
- wppa_out( '<span
1489
- id="wppa-nbar-' . wppa( 'mocc' ) . '-hidots"
1490
  style="float:left;
1491
  display:none;
1492
  background-color:transparent;
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the slideshow high level functions
6
+ * Version 6.9.21
7
  *
8
  */
9
 
660
  // w#fotomoto
661
  $f_on_this = false;
662
  if ( function_exists( 'fotomoto_page_enabled' ) ) {
663
+ $f_on_this = ! wppa( 'in_widget' ) && fotomoto_page_enabled( wppa_get_the_ID() );
664
  }
665
  if ( wppa_switch( 'fotomoto_on' ) && $f_on_this ) {
666
  $fontsize = wppa_opt( 'fotomoto_fontsize' );
888
  if ( wppa_get_photo_item( $id, 'owner' ) == wppa_get_user() && ! wppa_switch( 'allow_owner_votes' ) ) {
889
  return '<span class="'.$class.'" >' . __( 'Sorry, you can not rate your own photos' , 'wp-photo-album-plus') . '</span>';
890
  }
891
+ $mylast = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM '.WPPA_RATING.' WHERE photo = %s AND user = %s ORDER BY id DESC LIMIT 1', $id, wppa_get_user() ), ARRAY_A );
892
  if ( $mylast && ! wppa_switch( 'rating_change' ) && ! wppa_switch( 'rating_multi' ) ) {
893
  return '<span class="'.$class.'" >' . __( 'Sorry, you can rate a photo only once', 'wp-photo-album-plus' ) . '</span>';
894
  }
1475
  '</a>'
1476
  );
1477
  if ( $numid == 0 ) {
1478
+ wppa_out( '<span
1479
+ id="wppa-nbar-' . wppa( 'mocc' ) . '-lodots"
1480
  style="float:left;
1481
  display:none;
1482
  background-color:transparent;
1485
  >...</span>' );
1486
  }
1487
  if ( $numid == $count - 2 ) {
1488
+ wppa_out( '<span
1489
+ id="wppa-nbar-' . wppa( 'mocc' ) . '-hidots"
1490
  style="float:left;
1491
  display:none;
1492
  background-color:transparent;
wppa-source.php CHANGED
@@ -120,23 +120,6 @@ global $wppa_supported_photo_extensions;
120
  }
121
  }
122
 
123
- // rename without warnings
124
- function wppa_rename( $from, $to ) {
125
-
126
- $from = str_replace( '../', '', $from );
127
- $to = str_replace( '../', '', $to );
128
-
129
- if ( is_file( $from ) ) {
130
- if ( is_file( $to ) ) {
131
- wppa_copy( $from, $to );
132
- unlink( $from );
133
- }
134
- else {
135
- rename( $from, $to );
136
- }
137
- }
138
- }
139
-
140
  function wppa_copy_source( $name, $from, $to ) {
141
  global $wppa_supported_photo_extensions;
142
 
120
  }
121
  }
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  function wppa_copy_source( $name, $from, $to ) {
124
  global $wppa_supported_photo_extensions;
125
 
wppa-statistics.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * Functions for counts etc
6
  * Common use front and admin
7
- * Version 6.9.20
8
  *
9
  */
10
 
@@ -56,7 +56,7 @@ global $wpdb;
56
  $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos " );
57
  }
58
  else {
59
- $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s )", wppa_get_user() ) );
60
  }
61
  }
62
  else {
@@ -114,7 +114,7 @@ global $wpdb;
114
 
115
  // If album array given, prepare partial where clause to limit album ids.
116
  if ( is_array( $alb ) ) {
117
- $where = " `id` IN (" . implode( ',', $alb ) . ") ";
118
  $where = trim( $where, ',' );
119
  }
120
  else {
@@ -133,7 +133,7 @@ global $wpdb;
133
  elseif ( wppa_switch( 'upload_owner_only' ) ) {
134
  $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) " .
135
  "FROM $wpdb->wppa_albums " .
136
- "WHERE `owner` = '--- public ---' OR `owner` = %s" .
137
  ( $where ? "AND " . $where : "" ),
138
  wppa_get_user()
139
  )
@@ -179,7 +179,7 @@ global $wpdb;
179
  function wppa_get_youngest_album_id() {
180
  global $wpdb;
181
 
182
- $result = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_albums ORDER BY `timestamp` DESC, `id` DESC LIMIT 1" );
183
 
184
  return $result;
185
  }
@@ -188,7 +188,7 @@ global $wpdb;
188
  function wppa_get_youngest_album_name() {
189
  global $wpdb;
190
 
191
- $result = $wpdb->get_var( "SELECT `name` FROM $wpdb->wppa_albums ORDER BY `timestamp` DESC, `id` DESC LIMIT 1" );
192
 
193
  return stripslashes($result);
194
  }
@@ -216,9 +216,9 @@ global $wppa_session;
216
  // Remember click and update photodata, only if first time
217
  if ( ! isset( $wppa_session['click'][$id] ) ) {
218
  $wppa_session['click'][$id] = true;
219
- $count = $wpdb->get_var( "SELECT `clicks` FROM $wpdb->wppa_photos WHERE `id` = $id" );
220
  $count++;
221
- $wpdb->query( "UPDATE $wpdb->wppa_photos SET `clicks` = $count WHERE `id` = $id" );
222
 
223
  // Invalidate cache
224
  wppa_cache_photo( 'invalidate', $id );
@@ -253,13 +253,13 @@ global $wppa_session;
253
  if ( ! isset($wppa_session[$type][$id] ) ) { // This one not done yest
254
  $wppa_session[$type][$id] = true; // Mark as viewed
255
  if ( $type == 'album' ) {
256
- $count = $wpdb->get_var( $wpdb->prepare( "SELECT `views` FROM $wpdb->wppa_albums WHERE `id` = %d", $id ) );
257
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_albums SET `views` = %d WHERE `id` = %d", $count+1, $id ) );
258
  wppa_log( 'dbg', 'Bumped viewcount for album ' . $id . ' to ' . $count );
259
  }
260
  else {
261
- $count = $wpdb->get_var( $wpdb->prepare( "SELECT `views` FROM $wpdb->wppa_photos WHERE `id` = %d", $id ) );
262
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `views` = %d WHERE `id` = %d", $count+1, $id ) );
263
  wppa_log( 'dbg', 'Bumped viewcount for photo ' . $id . ' to ' . $count );
264
  }
265
 
@@ -295,6 +295,7 @@ function wppa_flush_upldr_cache( $key = '', $id = '' ) {
295
  if ( $id == $widget_id ) {
296
  unset ( $upldrcache[$widget_id] );
297
  }
 
298
 
299
  case 'photoid':
300
  $usr = wppa_get_photo_item( $id, 'owner');
@@ -325,7 +326,7 @@ function wppa_flush_upldr_cache( $key = '', $id = '' ) {
325
  function wppa_get_random_photo_id_from_youngest_album() {
326
  global $wpdb;
327
 
328
- $albums = $wpdb->get_col( "SELECT `id` FROM $wpdb->wppa_albums ORDER BY `timestamp` DESC" );
329
  $found = false;
330
  $count = count( $albums );
331
  $idx = 0;
@@ -333,7 +334,7 @@ global $wpdb;
333
 
334
  while ( ! $found && $idx < $count ) {
335
  $album = $albums[$idx];
336
- $result = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM $wpdb->wppa_photos WHERE `album` = %d ORDER BY RAND() LIMIT 1", $album ) );
337
  if ( $result ) {
338
  $found = true;
339
  }
@@ -394,9 +395,9 @@ global $wpdb;
394
  }
395
 
396
  // Get the ids of the child albums
397
- $child_ids = $wpdb->get_col( "SELECT `id` " .
398
  "FROM $wpdb->wppa_albums " .
399
- "WHERE `a_parent` = $alb"
400
  );
401
 
402
 
@@ -424,7 +425,7 @@ global $wpdb;
424
  // Self albums
425
  $result['selfalbums'] = $wpdb->get_var( "SELECT COUNT(*) " .
426
  "FROM $wpdb->wppa_albums " .
427
- "WHERE `a_parent` = $alb "
428
  );
429
 
430
  // Tree albums
@@ -439,9 +440,9 @@ global $wpdb;
439
  // Self photos
440
  $result['selfphotos'] = $wpdb->get_var( "SELECT COUNT(*) " .
441
  "FROM $wpdb->wppa_photos " .
442
- "WHERE `album` = $alb " .
443
- "AND `status` <> 'pending' " .
444
- "AND `status` <> 'scheduled'"
445
  );
446
 
447
  // Tree photos
@@ -456,8 +457,8 @@ global $wpdb;
456
  // Pending self photos
457
  $result['pendselfphotos'] = $wpdb->get_var( "SELECT COUNT(*) " .
458
  "FROM $wpdb->wppa_photos " .
459
- "WHERE `album` = $alb " .
460
- "AND `status` = 'pending'"
461
  );
462
 
463
  // Pending tree photos
@@ -472,8 +473,8 @@ global $wpdb;
472
  // Scheduled self photos
473
  $result['scheduledselfphotos'] = $wpdb->get_var( "SELECT COUNT(*) " .
474
  "FROM $wpdb->wppa_photos " .
475
- "WHERE `album` = $alb " .
476
- "AND `status` = 'scheduled'"
477
  );
478
 
479
  // Scheduled tree photos
@@ -486,7 +487,7 @@ global $wpdb;
486
  }
487
 
488
  // Self photo views
489
- $views = $wpdb->get_col( "SELECT `views` FROM $wpdb->wppa_photos WHERE `album` = $alb" );
490
  $result['selfphotoviews'] = array_sum( $views );
491
 
492
  // Tree photo views
@@ -559,7 +560,7 @@ global $wpdb;
559
  $result = serialize( $result );
560
 
561
  // Manually update. If used wppa_update_album, remake index would be triggered
562
- $iret = $wpdb->query( "UPDATE $wpdb->wppa_albums SET `treecounts` = '$result' WHERE `id` = $alb" );
563
  wppa_cache_album( 'invalidate', $alb );
564
  }
565
  }
4
  *
5
  * Functions for counts etc
6
  * Common use front and admin
7
+ * Version 6.9.21
8
  *
9
  */
10
 
56
  $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos " );
57
  }
58
  else {
59
+ $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE ( ( status <> 'pending' AND status <> 'scheduled' ) OR owner = %s )", wppa_get_user() ) );
60
  }
61
  }
62
  else {
114
 
115
  // If album array given, prepare partial where clause to limit album ids.
116
  if ( is_array( $alb ) ) {
117
+ $where = " id IN (" . implode( ',', $alb ) . ") ";
118
  $where = trim( $where, ',' );
119
  }
120
  else {
133
  elseif ( wppa_switch( 'upload_owner_only' ) ) {
134
  $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) " .
135
  "FROM $wpdb->wppa_albums " .
136
+ "WHERE owner = '--- public ---' OR owner = %s" .
137
  ( $where ? "AND " . $where : "" ),
138
  wppa_get_user()
139
  )
179
  function wppa_get_youngest_album_id() {
180
  global $wpdb;
181
 
182
+ $result = $wpdb->get_var( "SELECT id FROM $wpdb->wppa_albums ORDER BY timestamp DESC, id DESC LIMIT 1" );
183
 
184
  return $result;
185
  }
188
  function wppa_get_youngest_album_name() {
189
  global $wpdb;
190
 
191
+ $result = $wpdb->get_var( "SELECT name FROM $wpdb->wppa_albums ORDER BY timestamp DESC, id DESC LIMIT 1" );
192
 
193
  return stripslashes($result);
194
  }
216
  // Remember click and update photodata, only if first time
217
  if ( ! isset( $wppa_session['click'][$id] ) ) {
218
  $wppa_session['click'][$id] = true;
219
+ $count = $wpdb->get_var( "SELECT clicks FROM $wpdb->wppa_photos WHERE id = $id" );
220
  $count++;
221
+ $wpdb->query( "UPDATE $wpdb->wppa_photos SET clicks = $count WHERE id = $id" );
222
 
223
  // Invalidate cache
224
  wppa_cache_photo( 'invalidate', $id );
253
  if ( ! isset($wppa_session[$type][$id] ) ) { // This one not done yest
254
  $wppa_session[$type][$id] = true; // Mark as viewed
255
  if ( $type == 'album' ) {
256
+ $count = $wpdb->get_var( $wpdb->prepare( "SELECT views FROM $wpdb->wppa_albums WHERE id = %d", $id ) );
257
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_albums SET views = %d WHERE id = %d", $count+1, $id ) );
258
  wppa_log( 'dbg', 'Bumped viewcount for album ' . $id . ' to ' . $count );
259
  }
260
  else {
261
+ $count = $wpdb->get_var( $wpdb->prepare( "SELECT views FROM $wpdb->wppa_photos WHERE id = %d", $id ) );
262
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET views = %d WHERE id = %d", $count+1, $id ) );
263
  wppa_log( 'dbg', 'Bumped viewcount for photo ' . $id . ' to ' . $count );
264
  }
265
 
295
  if ( $id == $widget_id ) {
296
  unset ( $upldrcache[$widget_id] );
297
  }
298
+ break;
299
 
300
  case 'photoid':
301
  $usr = wppa_get_photo_item( $id, 'owner');
326
  function wppa_get_random_photo_id_from_youngest_album() {
327
  global $wpdb;
328
 
329
+ $albums = $wpdb->get_col( "SELECT id FROM $wpdb->wppa_albums ORDER BY timestamp DESC" );
330
  $found = false;
331
  $count = count( $albums );
332
  $idx = 0;
334
 
335
  while ( ! $found && $idx < $count ) {
336
  $album = $albums[$idx];
337
+ $result = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_photos WHERE album = %d ORDER BY RAND() LIMIT 1", $album ) );
338
  if ( $result ) {
339
  $found = true;
340
  }
395
  }
396
 
397
  // Get the ids of the child albums
398
+ $child_ids = $wpdb->get_col( "SELECT id " .
399
  "FROM $wpdb->wppa_albums " .
400
+ "WHERE a_parent = $alb"
401
  );
402
 
403
 
425
  // Self albums
426
  $result['selfalbums'] = $wpdb->get_var( "SELECT COUNT(*) " .
427
  "FROM $wpdb->wppa_albums " .
428
+ "WHERE a_parent = $alb "
429
  );
430
 
431
  // Tree albums
440
  // Self photos
441
  $result['selfphotos'] = $wpdb->get_var( "SELECT COUNT(*) " .
442
  "FROM $wpdb->wppa_photos " .
443
+ "WHERE album = $alb " .
444
+ "AND status <> 'pending' " .
445
+ "AND status <> 'scheduled'"
446
  );
447
 
448
  // Tree photos
457
  // Pending self photos
458
  $result['pendselfphotos'] = $wpdb->get_var( "SELECT COUNT(*) " .
459
  "FROM $wpdb->wppa_photos " .
460
+ "WHERE album = $alb " .
461
+ "AND status = 'pending'"
462
  );
463
 
464
  // Pending tree photos
473
  // Scheduled self photos
474
  $result['scheduledselfphotos'] = $wpdb->get_var( "SELECT COUNT(*) " .
475
  "FROM $wpdb->wppa_photos " .
476
+ "WHERE album = $alb " .
477
+ "AND status = 'scheduled'"
478
  );
479
 
480
  // Scheduled tree photos
487
  }
488
 
489
  // Self photo views
490
+ $views = $wpdb->get_col( "SELECT views FROM $wpdb->wppa_photos WHERE album = $alb" );
491
  $result['selfphotoviews'] = array_sum( $views );
492
 
493
  // Tree photo views
560
  $result = serialize( $result );
561
 
562
  // Manually update. If used wppa_update_album, remake index would be triggered
563
+ $iret = $wpdb->query( "UPDATE $wpdb->wppa_albums SET treecounts = '$result' WHERE id = $alb" );
564
  wppa_cache_album( 'invalidate', $alb );
565
  }
566
  }
wppa-stats-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the stats widget
6
- * Version 6.9.20
7
  *
8
  */
9
  class WppaStatsWidget extends WP_Widget {
@@ -63,18 +63,18 @@ class WppaStatsWidget extends WP_Widget {
63
  $widget_content .= __('Today is day no', 'wp-photo-album-plus') . ': <b>' . ( date_i18n( 'z', time() ) + 1 ) . '</b><br />';
64
  }
65
  if ( wppa_checked( $instance['sessions-active'] ) ) {
66
- $sescount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_session WHERE `timestamp` > '" . ( time() - 3600 ) . "'" );
67
  $widget_content .= __('Number of active sessions', 'wp-photo-album-plus') . ': <b>' . $sescount . '</b><br />';
68
  }
69
  if ( wppa_checked( $instance['sessions-day'] ) ) {
70
  $t = time() - 3600*24;
71
- $daysescount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_session WHERE `timestamp` > '" . $t . "'" );
72
- $robots = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_session WHERE `timestamp` > '" . $t . "' AND `data` LIKE '%\"isrobot\";b:1;%'" );
73
  $widget_content .= __('Number of sessions last 24 hours', 'wp-photo-album-plus') . ': <b>' . $daysescount . '</b><br />' .
74
  __('Of which robots', 'wp-photo-album-plus') . ': <b>' . $robots . '</b><br />';
75
  }
76
  if ( wppa_checked( $instance['reg-users'] ) ) {
77
- $users = $wpdb->get_var( "SELECT COUNT(*) FROM `" . $wpdb->prefix . 'users' . "`" );
78
  $widget_content .= __('Number of registered users', 'wp-photo-album-plus') . ': <b>' . $users . '</b><br />';
79
  }
80
  if ( wppa_checked( $instance['albums'] ) ) {
@@ -90,14 +90,14 @@ class WppaStatsWidget extends WP_Widget {
90
  }
91
  }
92
  if ( wppa_checked( $instance['photos'] ) ) {
93
- $photos = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `ext` <> 'xxx' AND `filename` NOT LIKE '%.pdf'" );
94
  if ( $photos ) {
95
  $widget_content .= __('Number of photos', 'wp-photo-album-plus') . ': <b>' . $photos . '</b><br />';
96
  }
97
  }
98
  $multi = false;
99
  if ( wppa_checked( $instance['videos'] ) && wppa_switch( 'enable_video' ) ) {
100
- $multi = $wpdb->get_col( "SELECT `id` FROM $wpdb->wppa_photos WHERE `ext` = 'xxx'" );
101
  $cnt = 0;
102
  foreach( $multi as $item ) {
103
  if ( wppa_is_video( $item ) ) $cnt++;
@@ -108,7 +108,7 @@ class WppaStatsWidget extends WP_Widget {
108
  }
109
  if ( wppa_checked( $instance['audios'] ) && wppa_switch( 'enable_audio' ) ) {
110
  if ( ! $multi ) {
111
- $multi = $wpdb->get_col( "SELECT `id` FROM $wpdb->wppa_photos WHERE `ext` = 'xxx'" );
112
  }
113
  $cnt = 0;
114
  foreach( $multi as $item ) {
@@ -119,7 +119,7 @@ class WppaStatsWidget extends WP_Widget {
119
  }
120
  }
121
  if ( wppa_checked( $instance['pdfs'] ) && wppa_can_pdf() ) {
122
- $pdfs = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `filename` LIKE '%.pdf'" );
123
  if ( $pdfs ) {
124
  $widget_content .= __('Number of pdfs', 'wp-photo-album-plus') . ': <b>' . $pdfs . '</b><br />';
125
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the stats widget
6
+ * Version 6.9.21
7
  *
8
  */
9
  class WppaStatsWidget extends WP_Widget {
63
  $widget_content .= __('Today is day no', 'wp-photo-album-plus') . ': <b>' . ( date_i18n( 'z', time() ) + 1 ) . '</b><br />';
64
  }
65
  if ( wppa_checked( $instance['sessions-active'] ) ) {
66
+ $sescount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_session WHERE timestamp > '" . ( time() - 3600 ) . "'" );
67
  $widget_content .= __('Number of active sessions', 'wp-photo-album-plus') . ': <b>' . $sescount . '</b><br />';
68
  }
69
  if ( wppa_checked( $instance['sessions-day'] ) ) {
70
  $t = time() - 3600*24;
71
+ $daysescount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_session WHERE timestamp > '" . $t . "'" );
72
+ $robots = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_session WHERE timestamp > '" . $t . "' AND data LIKE '%\"isrobot\";b:1;%'" );
73
  $widget_content .= __('Number of sessions last 24 hours', 'wp-photo-album-plus') . ': <b>' . $daysescount . '</b><br />' .
74
  __('Of which robots', 'wp-photo-album-plus') . ': <b>' . $robots . '</b><br />';
75
  }
76
  if ( wppa_checked( $instance['reg-users'] ) ) {
77
+ $users = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . 'users' . "" );
78
  $widget_content .= __('Number of registered users', 'wp-photo-album-plus') . ': <b>' . $users . '</b><br />';
79
  }
80
  if ( wppa_checked( $instance['albums'] ) ) {
90
  }
91
  }
92
  if ( wppa_checked( $instance['photos'] ) ) {
93
+ $photos = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE ext <> 'xxx' AND filename NOT LIKE '%.pdf'" );
94
  if ( $photos ) {
95
  $widget_content .= __('Number of photos', 'wp-photo-album-plus') . ': <b>' . $photos . '</b><br />';
96
  }
97
  }
98
  $multi = false;
99
  if ( wppa_checked( $instance['videos'] ) && wppa_switch( 'enable_video' ) ) {
100
+ $multi = $wpdb->get_col( "SELECT id FROM $wpdb->wppa_photos WHERE ext = 'xxx'" );
101
  $cnt = 0;
102
  foreach( $multi as $item ) {
103
  if ( wppa_is_video( $item ) ) $cnt++;
108
  }
109
  if ( wppa_checked( $instance['audios'] ) && wppa_switch( 'enable_audio' ) ) {
110
  if ( ! $multi ) {
111
+ $multi = $wpdb->get_col( "SELECT id FROM $wpdb->wppa_photos WHERE ext = 'xxx'" );
112
  }
113
  $cnt = 0;
114
  foreach( $multi as $item ) {
119
  }
120
  }
121
  if ( wppa_checked( $instance['pdfs'] ) && wppa_can_pdf() ) {
122
+ $pdfs = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE filename LIKE '%.pdf'" );
123
  if ( $pdfs ) {
124
  $widget_content .= __('Number of pdfs', 'wp-photo-album-plus') . ': <b>' . $pdfs . '</b><br />';
125
  }
wppa-styles.php CHANGED
@@ -262,7 +262,7 @@ global $wppa_dynamic_css_data;
262
  $content .= wppa_opt( 'custom_style' );
263
 
264
  // Open file
265
- $file = wppa_fopen ( WPPA_PATH . '/wppa-dynamic.css', 'wb' );
266
  if ( $file ) {
267
  // Minify
268
  $old_len = strlen( $content );
@@ -743,6 +743,13 @@ function wppa_wcs( $class ) {
743
  case 'wppa-box-text':
744
  $opt = wppa_opt( 'fontcolor_box' );
745
  if ( $opt ) $result .= 'color:' . $opt . '; ';
 
 
 
 
 
 
 
746
  case 'wppa-box-text-nocolor':
747
  $opt = wppa_opt( 'fontfamily_box' );
748
  if ( $opt ) $result .= 'font-family:' . $opt . '; ';
262
  $content .= wppa_opt( 'custom_style' );
263
 
264
  // Open file
265
+ $file = wppa_fopen ( WPPA_PATH . '/dynamic/wppa-dynamic.css', 'wb' );
266
  if ( $file ) {
267
  // Minify
268
  $old_len = strlen( $content );
743
  case 'wppa-box-text':
744
  $opt = wppa_opt( 'fontcolor_box' );
745
  if ( $opt ) $result .= 'color:' . $opt . '; ';
746
+ $opt = wppa_opt( 'fontfamily_box' );
747
+ if ( $opt ) $result .= 'font-family:' . $opt . '; ';
748
+ $opt = wppa_opt( 'fontsize_box' );
749
+ if ( $opt ) $result .= 'font-size:' . $opt . 'px; ';
750
+ $opt = wppa_opt( 'fontweight_box' );
751
+ if ( $opt ) $result .= 'font-weight:' . $opt . '; ';
752
+ break;
753
  case 'wppa-box-text-nocolor':
754
  $opt = wppa_opt( 'fontfamily_box' );
755
  if ( $opt ) $result .= 'font-family:' . $opt . '; ';
wppa-thumbnail-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * display thumbnail photos
6
- * Version 6.9.14
7
  */
8
 
9
  class ThumbnailWidget extends WP_Widget {
@@ -65,10 +65,10 @@ class ThumbnailWidget extends WP_Widget {
65
  }
66
 
67
  if ( $album ) {
68
- $thumbs = $wpdb->get_results($wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `status` <> 'pending' AND `status` <> 'scheduled' AND `album` = %s ".$sortby." LIMIT %d", $album, $max ), 'ARRAY_A' );
69
  }
70
  else {
71
- $thumbs = $wpdb->get_results($wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `status` <> 'pending' AND `status` <> 'scheduled'".$sortby." LIMIT %d", $max ), 'ARRAY_A' );
72
  }
73
 
74
  global $widget_content;
@@ -223,12 +223,12 @@ class ThumbnailWidget extends WP_Widget {
223
  __( 'Timestamp desc', 'wp-photo-album-plus' ),
224
  );
225
  $values = array( '',
226
- 'ORDER BY `p_order`',
227
- 'ORDER BY `name`',
228
  'ORDER BY RAND()',
229
- 'ORDER BY `mean_rating` DESC',
230
- 'ORDER BY `rating_count` DESC',
231
- 'ORDER BY `timestamp` DESC',
232
  );
233
  echo
234
  wppa_widget_selection( $this, 'sortby', $instance['sortby'], __( 'Sort by', 'wp-photo-album-plus' ), $options, $values );
3
  * Package: wp-photo-album-plus
4
  *
5
  * display thumbnail photos
6
+ * Version 6.9.21
7
  */
8
 
9
  class ThumbnailWidget extends WP_Widget {
65
  }
66
 
67
  if ( $album ) {
68
+ $thumbs = $wpdb->get_results($wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE status <> 'pending' AND status <> 'scheduled' AND album = %s ".$sortby." LIMIT %d", $album, $max ), 'ARRAY_A' );
69
  }
70
  else {
71
+ $thumbs = $wpdb->get_results($wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE status <> 'pending' AND status <> 'scheduled'".$sortby." LIMIT %d", $max ), 'ARRAY_A' );
72
  }
73
 
74
  global $widget_content;
223
  __( 'Timestamp desc', 'wp-photo-album-plus' ),
224
  );
225
  $values = array( '',
226
+ 'ORDER BY p_order',
227
+ 'ORDER BY name',
228
  'ORDER BY RAND()',
229
+ 'ORDER BY mean_rating DESC',
230
+ 'ORDER BY rating_count DESC',
231
+ 'ORDER BY timestamp DESC',
232
  );
233
  echo
234
  wppa_widget_selection( $this, 'sortby', $instance['sortby'], __( 'Sort by', 'wp-photo-album-plus' ), $options, $values );
wppa-thumbnails.php CHANGED
@@ -5,7 +5,7 @@
5
  * Various funcions to display a thumbnail image
6
  * Contains all possible frontend thumbnail types
7
  *
8
- * Version 6.9.20
9
  *
10
  */
11
 
@@ -546,7 +546,7 @@ global $wpdb;
546
 
547
  // Single button voting system
548
  if ( wppa_opt( 'rating_max' ) == '1' && wppa_switch( 'vote_thumb' ) ) {
549
- $mylast = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM `'.WPPA_RATING.'` WHERE `photo` = %s AND `user` = %s ORDER BY `id` DESC LIMIT 1', $id, wppa_get_user() ), ARRAY_A );
550
 
551
  // Likes
552
  if ( wppa_opt( 'rating_display_type' ) == 'likes' ) {
5
  * Various funcions to display a thumbnail image
6
  * Contains all possible frontend thumbnail types
7
  *
8
+ * Version 6.9.21
9
  *
10
  */
11
 
546
 
547
  // Single button voting system
548
  if ( wppa_opt( 'rating_max' ) == '1' && wppa_switch( 'vote_thumb' ) ) {
549
+ $mylast = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM '.WPPA_RATING.' WHERE photo = %s AND user = %s ORDER BY id DESC LIMIT 1', $id, wppa_get_user() ), ARRAY_A );
550
 
551
  // Likes
552
  if ( wppa_opt( 'rating_display_type' ) == 'likes' ) {
wppa-tinymce-common.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-tinymce-common.php
3
  * Pachkage: wp-photo-album-plus
4
  *
5
- * Version 6.9.14
6
  *
7
  */
8
 
@@ -10,11 +10,11 @@ function wppa_make_tinymce_photo_dialog( $front = false ) {
10
  global $wpdb;
11
 
12
  // Prepare albuminfo
13
- $albums = $wpdb->get_results( "SELECT `id`, `name` " .
14
  "FROM $wpdb->wppa_albums " .
15
- "WHERE `owner` = '" . wppa_get_user() . "' " .
16
- "OR `owner` = '--- public ---' " .
17
- "ORDER BY `name` ",
18
  ARRAY_A );
19
 
20
  // Make the html
@@ -332,10 +332,10 @@ global $wpdb;
332
  $result = '';
333
 
334
  // Prepare photoinfo
335
- $my_photos = $wpdb->get_results( "SELECT `id`, `name`, `album`, `ext` " .
336
  "FROM $wpdb->wppa_photos " .
337
- "WHERE `owner` = '" . wppa_get_user() . "' " .
338
- "ORDER BY `timestamp` DESC LIMIT 100",
339
  ARRAY_A );
340
 
341
  if ( $my_photos ) {
@@ -398,9 +398,9 @@ global $wpdb;
398
  $result = '';
399
 
400
  // Prepare photoinfo
401
- $all_photos = $wpdb->get_results( "SELECT `id`, `name`, `album`, `ext` " .
402
  "FROM $wpdb->wppa_photos " .
403
- "ORDER BY `timestamp` DESC LIMIT 100",
404
  ARRAY_A );
405
 
406
  if ( $all_photos ) {
@@ -437,10 +437,9 @@ global $wpdb;
437
 
438
  $result .= '<option' .
439
  ' class="wppa-photo-select-item"' .
440
- ' value="' . $value . '"' .
441
  ' >' .
442
- $name .
443
- ' (' . wppa_get_album_name( $photo['album'] ) . ')' .
444
  '</option>';
445
 
446
  }
2
  /* wppa-tinymce-common.php
3
  * Pachkage: wp-photo-album-plus
4
  *
5
+ * Version 6.9.21
6
  *
7
  */
8
 
10
  global $wpdb;
11
 
12
  // Prepare albuminfo
13
+ $albums = $wpdb->get_results( "SELECT id, name " .
14
  "FROM $wpdb->wppa_albums " .
15
+ "WHERE owner = '" . wppa_get_user() . "' " .
16
+ "OR owner = '--- public ---' " .
17
+ "ORDER BY name ",
18
  ARRAY_A );
19
 
20
  // Make the html
332
  $result = '';
333
 
334
  // Prepare photoinfo
335
+ $my_photos = $wpdb->get_results( "SELECT id, name, album, ext " .
336
  "FROM $wpdb->wppa_photos " .
337
+ "WHERE owner = '" . wppa_get_user() . "' " .
338
+ "ORDER BY timestamp DESC LIMIT 100",
339
  ARRAY_A );
340
 
341
  if ( $my_photos ) {
398
  $result = '';
399
 
400
  // Prepare photoinfo
401
+ $all_photos = $wpdb->get_results( "SELECT id, name, album, ext " .
402
  "FROM $wpdb->wppa_photos " .
403
+ "ORDER BY timestamp DESC LIMIT 100",
404
  ARRAY_A );
405
 
406
  if ( $all_photos ) {
437
 
438
  $result .= '<option' .
439
  ' class="wppa-photo-select-item"' .
440
+ ' value="' . esc_attr( $value ) . '"' .
441
  ' >' .
442
+ sanitize_text_field( $name . ' (' . wppa_get_album_name( $photo['album'] ) . ')' ) .
 
443
  '</option>';
444
 
445
  }
wppa-tinymce-photo-front.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-tinymce-photo-front.php
3
  * Pachkage: wp-photo-album-plus
4
  *
5
- * Version 6.9.20
6
  *
7
  */
8
 
@@ -52,7 +52,7 @@ global $wppa_js_page_data_file;
52
  if ( wppa_switch( 'photo_shortcode_enabled' ) && ! $done ) {
53
 
54
  // Find an existing photo
55
- $id = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_photos WHERE `ext` <> 'xxx' AND `panorama` = 0 ORDER BY `timestamp` DESC LIMIT 1" );
56
 
57
  // Fake we are in a widget, to prevent wppa_get_picture_html() from bumping viewcount
58
  wppa( 'in_widget', true );
2
  /* wppa-tinymce-photo-front.php
3
  * Pachkage: wp-photo-album-plus
4
  *
5
+ * Version 6.9.21
6
  *
7
  */
8
 
52
  if ( wppa_switch( 'photo_shortcode_enabled' ) && ! $done ) {
53
 
54
  // Find an existing photo
55
+ $id = $wpdb->get_var( "SELECT id FROM $wpdb->wppa_photos WHERE ext <> 'xxx' AND panorama = 0 ORDER BY timestamp DESC LIMIT 1" );
56
 
57
  // Fake we are in a widget, to prevent wppa_get_picture_html() from bumping viewcount
58
  wppa( 'in_widget', true );
wppa-tinymce-shortcodes.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-tinymce-shortcodes.php
3
  * Pachkage: wp-photo-album-plus
4
  *
5
- * Version 6.9.14
6
  */
7
 
8
  if ( ! defined( 'ABSPATH' ) )
@@ -73,7 +73,7 @@ global $wpdb;
73
  $albums = null;
74
  }
75
  else {
76
- $albums = $wpdb->get_results( "SELECT `id`, `name` FROM $wpdb->wppa_albums ORDER BY `timestamp` DESC", ARRAY_A );
77
  if ( wppa_switch( 'hier_albsel' ) ) {
78
  $albums = wppa_add_paths( $albums );
79
  $albums = wppa_array_sort( $albums, 'name' );
@@ -81,7 +81,7 @@ global $wpdb;
81
  }
82
 
83
  // Prepare photoinfo
84
- $photos = $wpdb->get_results( "SELECT `id`, `name`, `album`, `ext` FROM $wpdb->wppa_photos ORDER BY `timestamp` DESC LIMIT 100", ARRAY_A );
85
 
86
  // Get Tags/cats
87
  $tags = wppa_get_taglist();
2
  /* wppa-tinymce-shortcodes.php
3
  * Pachkage: wp-photo-album-plus
4
  *
5
+ * Version 6.9.21
6
  */
7
 
8
  if ( ! defined( 'ABSPATH' ) )
73
  $albums = null;
74
  }
75
  else {
76
+ $albums = $wpdb->get_results( "SELECT id, name FROM $wpdb->wppa_albums ORDER BY timestamp DESC", ARRAY_A );
77
  if ( wppa_switch( 'hier_albsel' ) ) {
78
  $albums = wppa_add_paths( $albums );
79
  $albums = wppa_array_sort( $albums, 'name' );
81
  }
82
 
83
  // Prepare photoinfo
84
+ $photos = $wpdb->get_results( "SELECT id, name, album, ext FROM $wpdb->wppa_photos ORDER BY timestamp DESC LIMIT 100", ARRAY_A );
85
 
86
  // Get Tags/cats
87
  $tags = wppa_get_taglist();
wppa-topten-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the top rated photos
6
- * Version 6.9.20
7
  */
8
 
9
  class TopTenWidget extends WP_Widget {
@@ -54,13 +54,13 @@ class TopTenWidget extends WP_Widget {
54
  /*
55
  switch ( $instance['sortby'] ) {
56
  case 'mean_rating':
57
- $sortby = '`mean_rating` DESC, `rating_count` DESC, `views` DESC';
58
  break;
59
  case 'rating_count':
60
- $sortby = '`rating_count` DESC, `mean_rating` DESC, `views` DESC';
61
  break;
62
  case 'views':
63
- $sortby = '`views` DESC, `mean_rating` DESC, `rating_count` DESC';
64
  break;
65
  }
66
  */
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the top rated photos
6
+ * Version 6.9.21
7
  */
8
 
9
  class TopTenWidget extends WP_Widget {
54
  /*
55
  switch ( $instance['sortby'] ) {
56
  case 'mean_rating':
57
+ $sortby = 'mean_rating DESC, rating_count DESC, views DESC';
58
  break;
59
  case 'rating_count':
60
+ $sortby = 'rating_count DESC, mean_rating DESC, views DESC';
61
  break;
62
  case 'views':
63
+ $sortby = 'views DESC, mean_rating DESC, rating_count DESC';
64
  break;
65
  }
66
  */
wppa-upldr-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * display a list of users linking to their photos
6
- * Version 6.9.14
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
@@ -63,10 +63,10 @@ class UpldrWidget extends WP_Widget {
63
  }
64
  else {
65
  if ( $instance['parent'] ) {
66
- $query = $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `owner` = %s AND `album` IN (".$selalbs.") AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s )", $user['user_login'], $me );//);
67
  }
68
  else {
69
- $query = $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `owner` = %s AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s )", $user['user_login'], $me );//);
70
  }
71
  $photo_count = $wpdb->get_var( $query );
72
  if ( $user['user_login'] != $me ) {
@@ -78,10 +78,10 @@ class UpldrWidget extends WP_Widget {
78
  if ( $user['user_login'] != $me && isset ( $upldrcache[$this->get_widget_id()][$user['user_login']]['d'] ) ) $last_dtm = $upldrcache[$this->get_widget_id()][$user['user_login']]['d'];
79
  else {
80
  if ( $instance['parent'] ) {
81
- $last_dtm = $wpdb->get_var($wpdb->prepare( "SELECT `timestamp` FROM $wpdb->wppa_photos WHERE `owner` = %s AND `album` IN (".$selalbs.") AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) ORDER BY `timestamp` DESC LIMIT 1", $user['user_login'], $me ));
82
  }
83
  else {
84
- $last_dtm = $wpdb->get_var($wpdb->prepare( "SELECT `timestamp` FROM $wpdb->wppa_photos WHERE `owner` = %s AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) ORDER BY `timestamp` DESC LIMIT 1", $user['user_login'], $me ));
85
  }
86
  }
87
  if ( $user['user_login'] != $me ) {
@@ -246,7 +246,7 @@ class UpldrWidget extends WP_Widget {
246
  $albums = array();
247
  }
248
  else {
249
- $albums = $wpdb->get_results( "SELECT `id`, `name` FROM $wpdb->wppa_albums", ARRAY_A );
250
  }
251
  if ( ! empty( $albums ) ) {
252
  if ( wppa_switch( 'hier_albsel' ) ) {
3
  * Package: wp-photo-album-plus
4
  *
5
  * display a list of users linking to their photos
6
+ * Version 6.9.21
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
63
  }
64
  else {
65
  if ( $instance['parent'] ) {
66
+ $query = $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE owner = %s AND album IN (".$selalbs.") AND ( ( status <> 'pending' AND status <> 'scheduled' ) OR owner = %s )", $user['user_login'], $me );//);
67
  }
68
  else {
69
+ $query = $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE owner = %s AND ( ( status <> 'pending' AND status <> 'scheduled' ) OR owner = %s )", $user['user_login'], $me );//);
70
  }
71
  $photo_count = $wpdb->get_var( $query );
72
  if ( $user['user_login'] != $me ) {
78
  if ( $user['user_login'] != $me && isset ( $upldrcache[$this->get_widget_id()][$user['user_login']]['d'] ) ) $last_dtm = $upldrcache[$this->get_widget_id()][$user['user_login']]['d'];
79
  else {
80
  if ( $instance['parent'] ) {
81
+ $last_dtm = $wpdb->get_var($wpdb->prepare( "SELECT timestamp FROM $wpdb->wppa_photos WHERE owner = %s AND album IN (".$selalbs.") AND ( ( status <> 'pending' AND status <> 'scheduled' ) OR owner = %s ) ORDER BY timestamp DESC LIMIT 1", $user['user_login'], $me ));
82
  }
83
  else {
84
+ $last_dtm = $wpdb->get_var($wpdb->prepare( "SELECT timestamp FROM $wpdb->wppa_photos WHERE owner = %s AND ( ( status <> 'pending' AND status <> 'scheduled' ) OR owner = %s ) ORDER BY timestamp DESC LIMIT 1", $user['user_login'], $me ));
85
  }
86
  }
87
  if ( $user['user_login'] != $me ) {
246
  $albums = array();
247
  }
248
  else {
249
+ $albums = $wpdb->get_results( "SELECT id, name FROM $wpdb->wppa_albums", ARRAY_A );
250
  }
251
  if ( ! empty( $albums ) ) {
252
  if ( wppa_switch( 'hier_albsel' ) ) {
wppa-upload-widget.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * A wppa widget to upload photos
6
  *
7
- * Version 6.9.14
8
  */
9
 
10
  class WppaUploadWidget extends WP_Widget {
@@ -34,7 +34,7 @@ class WppaUploadWidget extends WP_Widget {
34
  $title = apply_filters( 'widget_title', $instance['title'] );
35
  $album = $instance['album'];
36
 
37
- if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE `id` = %d", $album ) ) ) {
38
  $album = '0'; // Album vanished
39
  }
40
 
4
  *
5
  * A wppa widget to upload photos
6
  *
7
+ * Version 6.9.21
8
  */
9
 
10
  class WppaUploadWidget extends WP_Widget {
34
  $title = apply_filters( 'widget_title', $instance['title'] );
35
  $album = $instance['album'];
36
 
37
+ if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE id = %d", $album ) ) ) {
38
  $album = '0'; // Album vanished
39
  }
40
 
wppa-users.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains user and capabilities related routines
6
- * Version 6.9.14
7
  *
8
  */
9
 
@@ -15,7 +15,7 @@ global $wpdb;
15
  static $usercount;
16
 
17
  if ( empty( $usercount ) ) {
18
- $usercount = $wpdb->get_var( "SELECT COUNT(*) FROM `" . $wpdb->users . "`" );
19
  }
20
 
21
  return $usercount;
@@ -31,8 +31,8 @@ static $users;
31
  $users = array();
32
  }
33
  else {
34
- $users = $wpdb->get_results( "SELECT * FROM `".$wpdb->users."` " .
35
- "ORDER BY `display_name`", ARRAY_A );
36
  }
37
  }
38
  return $users;
@@ -145,7 +145,7 @@ global $wp_roles;
145
 
146
  // If logged out max set, check if limit reached
147
  if ( $rmax ) {
148
- $albs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE `owner` = %s", wppa_get_user() ) );
149
  if ( $albs >= $rmax ) {
150
  return false; // Limit reached
151
  }
@@ -172,7 +172,7 @@ global $wp_roles;
172
  }
173
 
174
  // Check for global max albums per user setting
175
- $albs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE `owner` = %s", wppa_get_user() ) );
176
  $gmax = wppa_opt( 'max_albums' );
177
  if ( $gmax && $albs >= $gmax ) {
178
  return false;
@@ -247,7 +247,7 @@ static $result = -1;
247
 
248
  if ( is_numeric( $user ) ) {
249
  $user = $wpdb->get_var( $wpdb->prepare(
250
- "SELECT `user_login` FROM `".$wpdb->users."` WHERE `ID` = %d", $user
251
  ) );
252
  }
253
  else {
@@ -364,7 +364,7 @@ static $usercache;
364
  // Get userdata
365
  else {
366
  $user = $email ? get_user_by( 'email', $owner ) : get_user_by( 'login', $owner );
367
-
368
  // User exists
369
  if ( $user ) {
370
 
@@ -376,7 +376,7 @@ static $usercache;
376
  $result = $user->display_name;
377
  }
378
  }
379
-
380
  // User vanished
381
  else {
382
  $result = $owner;
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains user and capabilities related routines
6
+ * Version 6.9.21
7
  *
8
  */
9
 
15
  static $usercount;
16
 
17
  if ( empty( $usercount ) ) {
18
+ $usercount = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->users . "" );
19
  }
20
 
21
  return $usercount;
31
  $users = array();
32
  }
33
  else {
34
+ $users = $wpdb->get_results( "SELECT * FROM ".$wpdb->users." " .
35
+ "ORDER BY display_name", ARRAY_A );
36
  }
37
  }
38
  return $users;
145
 
146
  // If logged out max set, check if limit reached
147
  if ( $rmax ) {
148
+ $albs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE owner = %s", wppa_get_user() ) );
149
  if ( $albs >= $rmax ) {
150
  return false; // Limit reached
151
  }
172
  }
173
 
174
  // Check for global max albums per user setting
175
+ $albs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE owner = %s", wppa_get_user() ) );
176
  $gmax = wppa_opt( 'max_albums' );
177
  if ( $gmax && $albs >= $gmax ) {
178
  return false;
247
 
248
  if ( is_numeric( $user ) ) {
249
  $user = $wpdb->get_var( $wpdb->prepare(
250
+ "SELECT user_login FROM ".$wpdb->users." WHERE ID = %d", $user
251
  ) );
252
  }
253
  else {
364
  // Get userdata
365
  else {
366
  $user = $email ? get_user_by( 'email', $owner ) : get_user_by( 'login', $owner );
367
+
368
  // User exists
369
  if ( $user ) {
370
 
376
  $result = $user->display_name;
377
  }
378
  }
379
+
380
  // User vanished
381
  else {
382
  $result = $owner;
wppa-utils.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level utility routines
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -368,7 +368,7 @@ global $wpdb;
368
 
369
  if ( ! is_numeric($id) || $id < '1' ) wppa_dbg_msg('Invalid arg wppa_get_my_rating_by_id('.$id.', '.$opt.')', 'red');
370
 
371
- $my_ratings = $wpdb->get_results( $wpdb->prepare( "SELECT `value` FROM $wpdb->wppa_rating WHERE `photo` = %d AND `user` = %s", $id, wppa_get_user() ), ARRAY_A );
372
  if ( $my_ratings ) {
373
  $rating = 0;
374
  foreach ( $my_ratings as $r ) {
@@ -549,7 +549,7 @@ static $titles;
549
 
550
  // Pre-fill $parents
551
  if ( empty( $parents ) ) {
552
- $temp = $wpdb->get_results( "SELECT `ID`, `post_parent` FROM `" . $wpdb->posts . "`", ARRAY_A );
553
  if ( ! empty( $temp ) ) {
554
  foreach( $temp as $item ) {
555
  $parents[$item['ID']] = $item['post_parent'];
@@ -565,13 +565,13 @@ static $titles;
565
  $tempid = $parents[$tempid];
566
  }
567
  else {
568
- $t = $wpdb->get_var( $wpdb->prepare( "SELECT `post_parent` FROM `" . $wpdb->posts . "` WHERE `ID` = %s", $tempid ) );
569
  $parents[$tempid] = $t;
570
  $tempid = $t;
571
  }
572
  if ( $tempid > '0' ) {
573
  if ( ! isset( $titles[$tempid] ) ) {
574
- $titles[$tempid] = __( stripslashes( $wpdb->get_var( $wpdb->prepare( "SELECT `post_title` FROM `" . $wpdb->posts . "` WHERE `ID` = %s", $tempid ) ) ) );
575
  }
576
  $pages[$index]['post_title'] = $titles[$tempid].' > '.$pages[$index]['post_title'];
577
  }
@@ -654,11 +654,11 @@ global $wpdb;
654
  while ( ! $done ) {
655
 
656
  // Get the chunk
657
- $photos = $wpdb->get_results( "SELECT `id`, `tags` " .
658
  "FROM $wpdb->wppa_photos " .
659
- "WHERE `status` <> 'pending' " .
660
- "AND `status` <> 'scheduled' " .
661
- "AND `tags` <> '' " .
662
  "LIMIT " . $skip . "," . $pagsize,
663
  ARRAY_A );
664
 
@@ -758,7 +758,7 @@ global $wpdb;
758
 
759
  $result = false;
760
  $total = '0';
761
- $albums = $wpdb->get_results("SELECT `id`, `cats` FROM $wpdb->wppa_albums WHERE `cats` <> ''", ARRAY_A);
762
  if ( $albums ) foreach ( $albums as $album ) {
763
  $cats = explode(',', $album['cats']);
764
  if ( $cats ) foreach ( $cats as $cat ) {
@@ -804,16 +804,16 @@ global $wppa_opt;
804
  $wppa_opt[$option] = $value;
805
 
806
  // Remove init.js files, they will be auto re-created
807
- $files = glob( WPPA_PATH.'/wppa-init.*.js' );
808
  if ( $files ) {
809
  foreach ( $files as $file ) {
810
- @ unlink ( $file );
811
  }
812
  }
813
 
814
  // Remove dynamic css files, they will be auto re-created
815
- if ( is_file ( WPPA_PATH.'/wppa-dynamic.css' ) ) {
816
- @ unlink ( WPPA_PATH.'/wppa-dynamic.css' );
817
  }
818
  }
819
 
@@ -827,7 +827,7 @@ static $existing_albums;
827
 
828
  // If existing albums cache not filled yet, fill it.
829
  if ( ! $existing_albums ) {
830
- $existing_albums = $wpdb->get_col( "SELECT `id` FROM $wpdb->wppa_albums" );
831
  }
832
 
833
  return in_array( $id, $existing_albums, true );
@@ -839,18 +839,18 @@ global $wpdb;
839
  if ( ! wppa_is_int( $id ) ) {
840
  return false;
841
  }
842
- return $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `id` = %s", $id ) );
843
  }
844
 
845
  function wppa_albumphoto_exists($alb, $photo) {
846
  global $wpdb;
847
- return $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `album` = %s AND `filename` = %s", $alb, $photo));
848
  }
849
 
850
  function wppa_dislike_check($photo) {
851
  global $wpdb;
852
 
853
- $count = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_RATING."` WHERE `photo` = %s AND `value` = -1", $photo ));
854
 
855
  if ( wppa_opt( 'dislike_mail_every' ) > '0') { // Feature enabled?
856
  if ( $count % wppa_opt( 'dislike_mail_every' ) == '0' ) { // Mail the admin
@@ -864,7 +864,7 @@ global $wpdb;
864
 
865
  if ( wppa_opt( 'dislike_set_pending' ) > '0') { // Feature enabled?
866
  if ( $count == wppa_opt( 'dislike_set_pending' ) ) {
867
- $wpdb->query($wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `status` = 'pending' WHERE `id` = %s", $photo ));
868
  $to = get_bloginfo('admin_email');
869
  $subj = __('Notification of inappropriate image', 'wp-photo-album-plus');
870
  $cont['0'] = sprintf(__('Photo %s has been marked as inappropriate by %s different visitors.', 'wp-photo-album-plus'), $photo, $count);
@@ -894,8 +894,8 @@ global $wpdb;
894
 
895
  $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) " .
896
  "FROM $wpdb->wppa_rating " .
897
- "WHERE `photo` = %s " .
898
- "AND `value` = -1",
899
  $id
900
  )
901
  );
@@ -908,8 +908,8 @@ global $wpdb;
908
 
909
  $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) " .
910
  "FROM $wpdb->wppa_rating " .
911
- "WHERE `photo` = %s AND " .
912
- "`status` = 'pending'",
913
  $id
914
  )
915
  );
@@ -925,7 +925,7 @@ global $wpdb;
925
  if ( ! wppa_switch( 'com_notify_approved' ) ) return;
926
 
927
  // Get comment
928
- $com = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_comments WHERE `id` = %d", $id ), ARRAY_A );
929
  if ( ! $com ) return;
930
 
931
  // Get photo owner
@@ -1150,7 +1150,7 @@ global $wppa_starttime;
1150
  // Update photo modified timestamp
1151
  function wppa_update_modified($photo) {
1152
  global $wpdb;
1153
- $wpdb->query($wpdb->prepare("UPDATE $wpdb->wppa_photos SET `modified` = %s WHERE `id` = %s", time(), $photo));
1154
  }
1155
 
1156
  function wppa_nl_to_txt($text) {
@@ -1287,22 +1287,17 @@ global $wpdb;
1287
  $start = get_option('wppa_sourcefile_fix_start', '0');
1288
  if ( $start == '-1' ) return; // Done!
1289
 
1290
- $photos = $wpdb->get_results( "SELECT `id`, `album`, `name`, `filename`" .
1291
  " FROM $wpdb->wppa_photos" .
1292
- " WHERE `filename` <> '' AND `filename` <> `name` AND `id` > " . $start .
1293
- " ORDER BY `id`", ARRAY_A
1294
  );
1295
  if ( $photos ) {
1296
  foreach ( $photos as $data ) {
1297
  $faulty_sourcefile_name = wppa_opt( 'source_dir' ).'/album-'.$data['album'].'/'.preg_replace('/\.[^.]*$/', '', $data['filename']);
1298
  if ( is_file($faulty_sourcefile_name) ) {
1299
  $proper_sourcefile_name = wppa_opt( 'source_dir' ).'/album-'.$data['album'].'/'.$data['filename'];
1300
- if ( is_file($proper_sourcefile_name) ) {
1301
- unlink($faulty_sourcefile_name);
1302
- }
1303
- else {
1304
- rename($faulty_sourcefile_name, $proper_sourcefile_name);
1305
- }
1306
  $count++;
1307
  }
1308
  if ( time() > $end ) {
@@ -1378,14 +1373,14 @@ global $wpdb;
1378
  $mmfile = wppa_strip_ext( wppa_get_photo_path( $photo, false ) );
1379
  $allsup = array_merge( $wppa_supported_audio_extensions, $wppa_supported_video_extensions );
1380
  foreach( $allsup as $mmext ) {
1381
- if ( is_file( $mmfile.'.'.$mmext ) ) {
1382
- @ unlink( $mmfile.'.'.$mmext );
1383
  }
1384
  }
1385
  }
1386
 
1387
  // If still a photo with the same name exists in the original album, do not delete tge source
1388
- $still_exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `filename` = %s AND `album` = %s", $photoinfo['filename'], $album ) );
1389
  if ( ! $still_exists ) {
1390
 
1391
  // Delete sourcefile
@@ -1394,21 +1389,21 @@ global $wpdb;
1394
 
1395
  // Delete fullsize image
1396
  $file = wppa_get_photo_path( $photo );
1397
- if ( is_file( $file ) ) unlink( $file );
1398
 
1399
  // Delete thumbnail image
1400
  $file = wppa_get_thumb_path( $photo );
1401
- if ( is_file( $file ) ) unlink( $file );
1402
 
1403
  // Delete index
1404
  wppa_index_remove('photo', $photo);
1405
 
1406
  // Delete db entries
1407
  $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_photos WHERE id = %d", $photo ) );
1408
- $wpdb->query($wpdb->prepare('DELETE FROM `'.WPPA_RATING.'` WHERE `photo` = %s', $photo));
1409
- $wpdb->query($wpdb->prepare('DELETE FROM `'.WPPA_COMMENTS.'` WHERE `photo` = %s', $photo));
1410
- $wpdb->query($wpdb->prepare('DELETE FROM `'.WPPA_IPTC.'` WHERE `photo` = %s', $photo));
1411
- $wpdb->query($wpdb->prepare('DELETE FROM `'.WPPA_EXIF.'` WHERE `photo` = %s', $photo));
1412
  wppa_invalidate_treecounts($album);
1413
  wppa_flush_upldr_cache('photoid', $photo);
1414
 
@@ -1858,7 +1853,7 @@ global $wpdb;
1858
  $page = wppa_create_page( $thumb['name'], '[wppa type="autopage"][/wppa]' );
1859
 
1860
  // Store with photo data
1861
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `page_id` = ".$page." WHERE `id` = %d", $photo ) );
1862
 
1863
  // Update cache
1864
  $thumb['page_id'] = $page;
@@ -1907,11 +1902,11 @@ static $pages_exist;
1907
  }
1908
 
1909
  // Do a query
1910
- $iret = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `" .
1911
- $wpdb->posts . "` " .
1912
- "WHERE `post_type` = 'page' " .
1913
- "AND `post_status` = 'publish' " .
1914
- "AND `ID` = %s", $id ) );
1915
 
1916
  // Save result
1917
  $pages_exist[$id] = ( $iret > 0 );
@@ -2230,7 +2225,7 @@ global $wpdb;
2230
 
2231
  if ( $status != $thumb['status'] ) {
2232
  $thumb['status'] = $status; // Update cache
2233
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `status` = %s WHERE `id` = %s", $status, $id ) );
2234
  }
2235
  }
2236
 
@@ -2270,7 +2265,7 @@ global $wpdb;
2270
 
2271
  // Phase 2, get the ratings of the period
2272
  // find $ratings, ordered by photo id
2273
- $ratings = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_RATING."` WHERE `timestamp` >= %s AND `timestamp` < %s ORDER BY `photo`", $start, $end ), ARRAY_A );
2274
 
2275
  // Phase 3, set up an array with data we need
2276
  // There are two methods: photo oriented and owner oriented, depending on
@@ -2368,8 +2363,8 @@ function wppa_file_is_in_album( $filename, $alb ) {
2368
  global $wpdb;
2369
 
2370
  if ( ! $filename ) return false; // Copy/move very old photo, before filnametracking
2371
- $photo_id = $wpdb->get_var ( $wpdb->prepare ( "SELECT `id` FROM $wpdb->wppa_photos " .
2372
- "WHERE ( `filename` = %s OR `filename` = %s ) AND `album` = %s LIMIT 1",
2373
  wppa_sanitize_file_name( $filename ), $filename, $alb
2374
  )
2375
  );
@@ -2388,7 +2383,7 @@ static $childcounts;
2388
  else {
2389
  $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) " .
2390
  "FROM $wpdb->wppa_albums " .
2391
- "WHERE `a_parent` = %s", $alb) );
2392
 
2393
  // Save result
2394
  $childcounts[$alb] = $result;
@@ -2806,9 +2801,9 @@ global $wpdb;
2806
  $max_count = wppa_opt( 'comten_count' );
2807
  }
2808
 
2809
- $photo_ids = $wpdb->get_results( $wpdb->prepare( "SELECT `photo` FROM `".WPPA_COMMENTS."` " .
2810
- "WHERE `status` = 'approved' " .
2811
- "ORDER BY `timestamp` DESC LIMIT %d", 100 * $max_count ), ARRAY_A );
2812
  $result = array();
2813
 
2814
  if ( is_array( $photo_ids ) ) {
@@ -3343,7 +3338,7 @@ static $usercache;
3343
  $user = $usercache[$p['name']];
3344
  }
3345
  else {
3346
- $user = $wpdb->get_var( $wpdb->prepare( "SELECT `user_login` FROM `".$wpdb->users."` WHERE `display_name` = %s", $p['name'] ) );
3347
  if ( $user ) {
3348
  $usercache[$p['name']] = $user;
3349
  }
@@ -3372,10 +3367,10 @@ static $usercache;
3372
  function wppa_get_my_last_vote( $id ) {
3373
  global $wpdb;
3374
 
3375
- $result = $wpdb->get_var( $wpdb->prepare( "SELECT `value` FROM $wpdb->wppa_rating " .
3376
- "WHERE `photo` = %s " .
3377
- "AND `user` = %s " .
3378
- "ORDER BY `id` DESC " .
3379
  "LIMIT 1 ",
3380
  $id,
3381
  wppa_get_user()
@@ -3807,7 +3802,7 @@ global $wpdb;
3807
 
3808
  $me = wppa_get_user();
3809
  $likes = wppa_get_photo_item( $id, 'rating_count');
3810
- $mylike = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_rating WHERE `photo` = %d AND `user` = %s", $id, $me ) );
3811
 
3812
  if ( $mylike ) {
3813
  if ( $likes > 1 ) {
@@ -4850,15 +4845,12 @@ function wppa_dump( $txt = '' ) {
4850
  // Init
4851
  $file = WPPA_PATH . '/wppa-dump.txt';
4852
 
4853
- // Clear
4854
- if ( ! $txt && file_exists( $file ) ) {
4855
- unlink( $file );
4856
- }
4857
-
4858
- // Open file
4859
- if ( file_exists( $file ) ) {
4860
  $mode = 'ab';
4861
  }
 
 
4862
  else {
4863
  $mode = 'wb';
4864
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level utility routines
6
+ * Version 6.9.21
7
  *
8
  */
9
 
368
 
369
  if ( ! is_numeric($id) || $id < '1' ) wppa_dbg_msg('Invalid arg wppa_get_my_rating_by_id('.$id.', '.$opt.')', 'red');
370
 
371
+ $my_ratings = $wpdb->get_results( $wpdb->prepare( "SELECT value FROM $wpdb->wppa_rating WHERE photo = %d AND user = %s", $id, wppa_get_user() ), ARRAY_A );
372
  if ( $my_ratings ) {
373
  $rating = 0;
374
  foreach ( $my_ratings as $r ) {
549
 
550
  // Pre-fill $parents
551
  if ( empty( $parents ) ) {
552
+ $temp = $wpdb->get_results( "SELECT ID, post_parent FROM " . $wpdb->posts . "", ARRAY_A );
553
  if ( ! empty( $temp ) ) {
554
  foreach( $temp as $item ) {
555
  $parents[$item['ID']] = $item['post_parent'];
565
  $tempid = $parents[$tempid];
566
  }
567
  else {
568
+ $t = $wpdb->get_var( $wpdb->prepare( "SELECT post_parent FROM " . $wpdb->posts . " WHERE ID = %s", $tempid ) );
569
  $parents[$tempid] = $t;
570
  $tempid = $t;
571
  }
572
  if ( $tempid > '0' ) {
573
  if ( ! isset( $titles[$tempid] ) ) {
574
+ $titles[$tempid] = __( stripslashes( $wpdb->get_var( $wpdb->prepare( "SELECT post_title FROM " . $wpdb->posts . " WHERE ID = %s", $tempid ) ) ) );
575
  }
576
  $pages[$index]['post_title'] = $titles[$tempid].' > '.$pages[$index]['post_title'];
577
  }
654
  while ( ! $done ) {
655
 
656
  // Get the chunk
657
+ $photos = $wpdb->get_results( "SELECT id, tags " .
658
  "FROM $wpdb->wppa_photos " .
659
+ "WHERE status <> 'pending' " .
660
+ "AND status <> 'scheduled' " .
661
+ "AND tags <> '' " .
662
  "LIMIT " . $skip . "," . $pagsize,
663
  ARRAY_A );
664
 
758
 
759
  $result = false;
760
  $total = '0';
761
+ $albums = $wpdb->get_results("SELECT id, cats FROM $wpdb->wppa_albums WHERE cats <> ''", ARRAY_A);
762
  if ( $albums ) foreach ( $albums as $album ) {
763
  $cats = explode(',', $album['cats']);
764
  if ( $cats ) foreach ( $cats as $cat ) {
804
  $wppa_opt[$option] = $value;
805
 
806
  // Remove init.js files, they will be auto re-created
807
+ $files = wppa_glob( WPPA_PATH . '/dynamic/wppa-init.*.js' );
808
  if ( $files ) {
809
  foreach ( $files as $file ) {
810
+ wppa_unlink ( $file );
811
  }
812
  }
813
 
814
  // Remove dynamic css files, they will be auto re-created
815
+ if ( is_file ( WPPA_PATH . '/dynamic/wppa-dynamic.css' ) ) {
816
+ wppa_unlink ( WPPA_PATH . '/dynamic/wppa-dynamic.css' );
817
  }
818
  }
819
 
827
 
828
  // If existing albums cache not filled yet, fill it.
829
  if ( ! $existing_albums ) {
830
+ $existing_albums = $wpdb->get_col( "SELECT id FROM $wpdb->wppa_albums" );
831
  }
832
 
833
  return in_array( $id, $existing_albums, true );
839
  if ( ! wppa_is_int( $id ) ) {
840
  return false;
841
  }
842
+ return $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE id = %s", $id ) );
843
  }
844
 
845
  function wppa_albumphoto_exists($alb, $photo) {
846
  global $wpdb;
847
+ return $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album = %s AND filename = %s", $alb, $photo));
848
  }
849
 
850
  function wppa_dislike_check($photo) {
851
  global $wpdb;
852
 
853
+ $count = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*) FROM ".WPPA_RATING." WHERE photo = %s AND value = -1", $photo ));
854
 
855
  if ( wppa_opt( 'dislike_mail_every' ) > '0') { // Feature enabled?
856
  if ( $count % wppa_opt( 'dislike_mail_every' ) == '0' ) { // Mail the admin
864
 
865
  if ( wppa_opt( 'dislike_set_pending' ) > '0') { // Feature enabled?
866
  if ( $count == wppa_opt( 'dislike_set_pending' ) ) {
867
+ $wpdb->query($wpdb->prepare( "UPDATE $wpdb->wppa_photos SET status = 'pending' WHERE id = %s", $photo ));
868
  $to = get_bloginfo('admin_email');
869
  $subj = __('Notification of inappropriate image', 'wp-photo-album-plus');
870
  $cont['0'] = sprintf(__('Photo %s has been marked as inappropriate by %s different visitors.', 'wp-photo-album-plus'), $photo, $count);
894
 
895
  $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) " .
896
  "FROM $wpdb->wppa_rating " .
897
+ "WHERE photo = %s " .
898
+ "AND value = -1",
899
  $id
900
  )
901
  );
908
 
909
  $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) " .
910
  "FROM $wpdb->wppa_rating " .
911
+ "WHERE photo = %s AND " .
912
+ "status = 'pending'",
913
  $id
914
  )
915
  );
925
  if ( ! wppa_switch( 'com_notify_approved' ) ) return;
926
 
927
  // Get comment
928
+ $com = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_comments WHERE id = %d", $id ), ARRAY_A );
929
  if ( ! $com ) return;
930
 
931
  // Get photo owner
1150
  // Update photo modified timestamp
1151
  function wppa_update_modified($photo) {
1152
  global $wpdb;
1153
+ $wpdb->query($wpdb->prepare("UPDATE $wpdb->wppa_photos SET modified = %s WHERE id = %s", time(), $photo));
1154
  }
1155
 
1156
  function wppa_nl_to_txt($text) {
1287
  $start = get_option('wppa_sourcefile_fix_start', '0');
1288
  if ( $start == '-1' ) return; // Done!
1289
 
1290
+ $photos = $wpdb->get_results( "SELECT id, album, name, filename" .
1291
  " FROM $wpdb->wppa_photos" .
1292
+ " WHERE filename <> '' AND filename <> name AND id > " . $start .
1293
+ " ORDER BY id", ARRAY_A
1294
  );
1295
  if ( $photos ) {
1296
  foreach ( $photos as $data ) {
1297
  $faulty_sourcefile_name = wppa_opt( 'source_dir' ).'/album-'.$data['album'].'/'.preg_replace('/\.[^.]*$/', '', $data['filename']);
1298
  if ( is_file($faulty_sourcefile_name) ) {
1299
  $proper_sourcefile_name = wppa_opt( 'source_dir' ).'/album-'.$data['album'].'/'.$data['filename'];
1300
+ wppa_rename($faulty_sourcefile_name, $proper_sourcefile_name);
 
 
 
 
 
1301
  $count++;
1302
  }
1303
  if ( time() > $end ) {
1373
  $mmfile = wppa_strip_ext( wppa_get_photo_path( $photo, false ) );
1374
  $allsup = array_merge( $wppa_supported_audio_extensions, $wppa_supported_video_extensions );
1375
  foreach( $allsup as $mmext ) {
1376
+ if ( is_file( $mmfile . '.' . $mmext ) ) {
1377
+ wppa_unlink( $mmfile . '.' . $mmext );
1378
  }
1379
  }
1380
  }
1381
 
1382
  // If still a photo with the same name exists in the original album, do not delete tge source
1383
+ $still_exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE filename = %s AND album = %s", $photoinfo['filename'], $album ) );
1384
  if ( ! $still_exists ) {
1385
 
1386
  // Delete sourcefile
1389
 
1390
  // Delete fullsize image
1391
  $file = wppa_get_photo_path( $photo );
1392
+ if ( is_file( $file ) ) wppa_unlink( $file );
1393
 
1394
  // Delete thumbnail image
1395
  $file = wppa_get_thumb_path( $photo );
1396
+ if ( is_file( $file ) ) wppa_unlink( $file );
1397
 
1398
  // Delete index
1399
  wppa_index_remove('photo', $photo);
1400
 
1401
  // Delete db entries
1402
  $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_photos WHERE id = %d", $photo ) );
1403
+ $wpdb->query($wpdb->prepare('DELETE FROM '.WPPA_RATING.' WHERE photo = %s', $photo));
1404
+ $wpdb->query($wpdb->prepare('DELETE FROM '.WPPA_COMMENTS.' WHERE photo = %s', $photo));
1405
+ $wpdb->query($wpdb->prepare('DELETE FROM '.WPPA_IPTC.' WHERE photo = %s', $photo));
1406
+ $wpdb->query($wpdb->prepare('DELETE FROM '.WPPA_EXIF.' WHERE photo = %s', $photo));
1407
  wppa_invalidate_treecounts($album);
1408
  wppa_flush_upldr_cache('photoid', $photo);
1409
 
1853
  $page = wppa_create_page( $thumb['name'], '[wppa type="autopage"][/wppa]' );
1854
 
1855
  // Store with photo data
1856
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET page_id = ".$page." WHERE id = %d", $photo ) );
1857
 
1858
  // Update cache
1859
  $thumb['page_id'] = $page;
1902
  }
1903
 
1904
  // Do a query
1905
+ $iret = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM " .
1906
+ $wpdb->posts . " " .
1907
+ "WHERE post_type = 'page' " .
1908
+ "AND post_status = 'publish' " .
1909
+ "AND ID = %s", $id ) );
1910
 
1911
  // Save result
1912
  $pages_exist[$id] = ( $iret > 0 );
2225
 
2226
  if ( $status != $thumb['status'] ) {
2227
  $thumb['status'] = $status; // Update cache
2228
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET status = %s WHERE id = %s", $status, $id ) );
2229
  }
2230
  }
2231
 
2265
 
2266
  // Phase 2, get the ratings of the period
2267
  // find $ratings, ordered by photo id
2268
+ $ratings = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM ".WPPA_RATING." WHERE timestamp >= %s AND timestamp < %s ORDER BY photo", $start, $end ), ARRAY_A );
2269
 
2270
  // Phase 3, set up an array with data we need
2271
  // There are two methods: photo oriented and owner oriented, depending on
2363
  global $wpdb;
2364
 
2365
  if ( ! $filename ) return false; // Copy/move very old photo, before filnametracking
2366
+ $photo_id = $wpdb->get_var ( $wpdb->prepare ( "SELECT id FROM $wpdb->wppa_photos " .
2367
+ "WHERE ( filename = %s OR filename = %s ) AND album = %s LIMIT 1",
2368
  wppa_sanitize_file_name( $filename ), $filename, $alb
2369
  )
2370
  );
2383
  else {
2384
  $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) " .
2385
  "FROM $wpdb->wppa_albums " .
2386
+ "WHERE a_parent = %s", $alb) );
2387
 
2388
  // Save result
2389
  $childcounts[$alb] = $result;
2801
  $max_count = wppa_opt( 'comten_count' );
2802
  }
2803
 
2804
+ $photo_ids = $wpdb->get_results( $wpdb->prepare( "SELECT photo FROM ".WPPA_COMMENTS." " .
2805
+ "WHERE status = 'approved' " .
2806
+ "ORDER BY timestamp DESC LIMIT %d", 100 * $max_count ), ARRAY_A );
2807
  $result = array();
2808
 
2809
  if ( is_array( $photo_ids ) ) {
3338
  $user = $usercache[$p['name']];
3339
  }
3340
  else {
3341
+ $user = $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM ".$wpdb->users." WHERE display_name = %s", $p['name'] ) );
3342
  if ( $user ) {
3343
  $usercache[$p['name']] = $user;
3344
  }
3367
  function wppa_get_my_last_vote( $id ) {
3368
  global $wpdb;
3369
 
3370
+ $result = $wpdb->get_var( $wpdb->prepare( "SELECT value FROM $wpdb->wppa_rating " .
3371
+ "WHERE photo = %s " .
3372
+ "AND user = %s " .
3373
+ "ORDER BY id DESC " .
3374
  "LIMIT 1 ",
3375
  $id,
3376
  wppa_get_user()
3802
 
3803
  $me = wppa_get_user();
3804
  $likes = wppa_get_photo_item( $id, 'rating_count');
3805
+ $mylike = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_rating WHERE photo = %d AND user = %s", $id, $me ) );
3806
 
3807
  if ( $mylike ) {
3808
  if ( $likes > 1 ) {
4845
  // Init
4846
  $file = WPPA_PATH . '/wppa-dump.txt';
4847
 
4848
+ // Open file, append if text not empty
4849
+ if ( file_exists( $file ) && $txt ) {
 
 
 
 
 
4850
  $mode = 'ab';
4851
  }
4852
+
4853
+ // Overwrite if file not exists or empty text
4854
  else {
4855
  $mode = 'wb';
4856
  }
wppa-widget-functions.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-widget-functions.php
3
  /* Package: wp-photo-album-plus
4
  /*
5
- /* Version 6.9.14
6
  /*
7
  */
8
 
@@ -37,27 +37,27 @@ global $wpdb;
37
  // Compile status clause
38
  switch( wppa_opt( 'potd_status_filter' ) ) {
39
  case 'publish':
40
- $statusclause = " `status` = 'publish' ";
41
  break;
42
  case 'featured':
43
- $statusclause = " `status` = 'featured' ";
44
  break;
45
  case 'gold':
46
- $statusclause = " `status` = 'gold' ";
47
  break;
48
  case 'silver':
49
- $statusclause = " `status` = 'silver' ";
50
  break;
51
  case 'bronze':
52
- $statusclause = " `status` = 'bronze' ";
53
  break;
54
  case 'anymedal':
55
- $statusclause = " `status` IN ( 'gold', 'silver', 'bronze' ) ";
56
  break;
57
  default:
58
- $statusclause = " `status` <> 'scheduled' ";
59
  if ( ! is_user_logged_in() ) {
60
- $statusclause .= " AND `status` <> 'private' ";
61
  }
62
  }
63
 
@@ -71,7 +71,7 @@ global $wpdb;
71
  // If physical albums and inverse selection is active, invert selection
72
  if ( wppa_opt( 'potd_album_type' ) == 'physical' && wppa_switch( 'potd_inverse' ) ) {
73
  $albs = explode( ',', $alb );
74
- $all = $wpdb->get_col( "SELECT `id` FROM $wpdb->wppa_albums " );
75
  $alb = implode( ',', array_diff( $all, $albs ) );
76
  }
77
 
@@ -81,9 +81,9 @@ global $wpdb;
81
 
82
  // Is it a single album?
83
  if ( wppa_is_int( $alb ) ) {
84
- $query = $wpdb->prepare( "SELECT `id`, `p_order` " .
85
  "FROM $wpdb->wppa_photos " .
86
- "WHERE `album` = %s " .
87
  "AND " . $statusclause . $option,
88
  $alb );
89
  }
@@ -92,28 +92,28 @@ global $wpdb;
92
  elseif ( strchr( $alb, ',' ) ) {
93
  $alb = trim( $alb, ',' );
94
 
95
- $query = "SELECT `id`, `p_order` " .
96
  "FROM $wpdb->wppa_photos " .
97
- "WHERE `album` IN ( " . $alb . " ) " .
98
  "AND " . $statusclause . $option;
99
  }
100
 
101
  /* Virtual albums */
102
  // Is it ALL?
103
  elseif ( $alb == 'all' ) {
104
- $query = "SELECT `id`, `p_order` " .
105
  "FROM $wpdb->wppa_photos " .
106
  "WHERE " . $statusclause . $option;
107
  }
108
 
109
  // Is it SEP?
110
  elseif ( $alb == 'sep' ) {
111
- $albs = $wpdb->get_results( "SELECT `id`, `a_parent` FROM $wpdb->wppa_albums", ARRAY_A );
112
- $query = "SELECT `id`, `p_order` FROM $wpdb->wppa_photos WHERE ( `album` = '0' ";
113
  $first = true;
114
  foreach ( $albs as $a ) {
115
  if ( $a['a_parent'] == '-1' ) {
116
- $query .= "OR `album` = '" . $a['id'] . "' ";
117
  }
118
  }
119
  $query .= ") AND " . $statusclause . $option;
@@ -121,8 +121,8 @@ global $wpdb;
121
 
122
  // Is it ALL-SEP?
123
  elseif ( $alb == 'all-sep' ) {
124
- $albs = $wpdb->get_results( "SELECT `id`, `a_parent` FROM $wpdb->wppa_albums", ARRAY_A );
125
- $query = "SELECT `id`, `p_order` FROM $wpdb->wppa_photos WHERE ( `album` IN ('0'";
126
  foreach ( $albs as $a ) {
127
  if ( $a['a_parent'] != '-1' ) {
128
  $query .= ",'" . $a['id'] . "'";
@@ -137,13 +137,13 @@ global $wpdb;
137
  // Find the 'top' policy
138
  switch ( wppa_opt( 'topten_sortby' ) ) {
139
  case 'mean_rating':
140
- $sortby = '`mean_rating` DESC, `rating_count` DESC, `views` DESC';
141
  break;
142
  case 'rating_count':
143
- $sortby = '`rating_count` DESC, `mean_rating` DESC, `views` DESC';
144
  break;
145
  case 'views':
146
- $sortby = '`views` DESC, `mean_rating` DESC, `rating_count` DESC';
147
  break;
148
  default:
149
  wppa_error_message( 'Unimplemented sorting method' );
@@ -152,7 +152,7 @@ global $wpdb;
152
  }
153
 
154
  // It is assumed that status is ok for top rated photos
155
- $query = "SELECT `id`, `p_order` FROM $wpdb->wppa_photos ORDER BY " . $sortby . " LIMIT " . wppa_opt( 'topten_count' );
156
  $query .= $option;
157
  }
158
 
@@ -293,9 +293,9 @@ static $potd;
293
  foreach( $photos as $photo ) {
294
  $ids[] = $photo['id'];
295
  }
296
- $photos = $wpdb->get_results( "SELECT `id`, `p_order` " .
297
  "FROM $wpdb->wppa_photos " .
298
- "WHERE `id` IN (" . implode( ',', $ids ) . ") " .
299
  "ORDER BY RAND(".$idn.")",
300
  ARRAY_A );
301
  }
2
  /* wppa-widget-functions.php
3
  /* Package: wp-photo-album-plus
4
  /*
5
+ /* Version 6.9.21
6
  /*
7
  */
8
 
37
  // Compile status clause
38
  switch( wppa_opt( 'potd_status_filter' ) ) {
39
  case 'publish':
40
+ $statusclause = " status = 'publish' ";
41
  break;
42
  case 'featured':
43
+ $statusclause = " status = 'featured' ";
44
  break;
45
  case 'gold':
46
+ $statusclause = " status = 'gold' ";
47
  break;
48
  case 'silver':
49
+ $statusclause = " status = 'silver' ";
50
  break;
51
  case 'bronze':
52
+ $statusclause = " status = 'bronze' ";
53
  break;
54
  case 'anymedal':
55
+ $statusclause = " status IN ( 'gold', 'silver', 'bronze' ) ";
56
  break;
57
  default:
58
+ $statusclause = " status <> 'scheduled' ";
59
  if ( ! is_user_logged_in() ) {
60
+ $statusclause .= " AND status <> 'private' ";
61
  }
62
  }
63
 
71
  // If physical albums and inverse selection is active, invert selection
72
  if ( wppa_opt( 'potd_album_type' ) == 'physical' && wppa_switch( 'potd_inverse' ) ) {
73
  $albs = explode( ',', $alb );
74
+ $all = $wpdb->get_col( "SELECT id FROM $wpdb->wppa_albums " );
75
  $alb = implode( ',', array_diff( $all, $albs ) );
76
  }
77
 
81
 
82
  // Is it a single album?
83
  if ( wppa_is_int( $alb ) ) {
84
+ $query = $wpdb->prepare( "SELECT id, p_order " .
85
  "FROM $wpdb->wppa_photos " .
86
+ "WHERE album = %s " .
87
  "AND " . $statusclause . $option,
88
  $alb );
89
  }
92
  elseif ( strchr( $alb, ',' ) ) {
93
  $alb = trim( $alb, ',' );
94
 
95
+ $query = "SELECT id, p_order " .
96
  "FROM $wpdb->wppa_photos " .
97
+ "WHERE album IN ( " . $alb . " ) " .
98
  "AND " . $statusclause . $option;
99
  }
100
 
101
  /* Virtual albums */
102
  // Is it ALL?
103
  elseif ( $alb == 'all' ) {
104
+ $query = "SELECT id, p_order " .
105
  "FROM $wpdb->wppa_photos " .
106
  "WHERE " . $statusclause . $option;
107
  }
108
 
109
  // Is it SEP?
110
  elseif ( $alb == 'sep' ) {
111
+ $albs = $wpdb->get_results( "SELECT id, a_parent FROM $wpdb->wppa_albums", ARRAY_A );
112
+ $query = "SELECT id, p_order FROM $wpdb->wppa_photos WHERE ( album = '0' ";
113
  $first = true;
114
  foreach ( $albs as $a ) {
115
  if ( $a['a_parent'] == '-1' ) {
116
+ $query .= "OR album = '" . $a['id'] . "' ";
117
  }
118
  }
119
  $query .= ") AND " . $statusclause . $option;
121
 
122
  // Is it ALL-SEP?
123
  elseif ( $alb == 'all-sep' ) {
124
+ $albs = $wpdb->get_results( "SELECT id, a_parent FROM $wpdb->wppa_albums", ARRAY_A );
125
+ $query = "SELECT id, p_order FROM $wpdb->wppa_photos WHERE ( album IN ('0'";
126
  foreach ( $albs as $a ) {
127
  if ( $a['a_parent'] != '-1' ) {
128
  $query .= ",'" . $a['id'] . "'";
137
  // Find the 'top' policy
138
  switch ( wppa_opt( 'topten_sortby' ) ) {
139
  case 'mean_rating':
140
+ $sortby = 'mean_rating DESC, rating_count DESC, views DESC';
141
  break;
142
  case 'rating_count':
143
+ $sortby = 'rating_count DESC, mean_rating DESC, views DESC';
144
  break;
145
  case 'views':
146
+ $sortby = 'views DESC, mean_rating DESC, rating_count DESC';
147
  break;
148
  default:
149
  wppa_error_message( 'Unimplemented sorting method' );
152
  }
153
 
154
  // It is assumed that status is ok for top rated photos
155
+ $query = "SELECT id, p_order FROM $wpdb->wppa_photos ORDER BY " . $sortby . " LIMIT " . wppa_opt( 'topten_count' );
156
  $query .= $option;
157
  }
158
 
293
  foreach( $photos as $photo ) {
294
  $ids[] = $photo['id'];
295
  }
296
+ $photos = $wpdb->get_results( "SELECT id, p_order " .
297
  "FROM $wpdb->wppa_photos " .
298
+ "WHERE id IN (" . implode( ',', $ids ) . ") " .
299
  "ORDER BY RAND(".$idn.")",
300
  ARRAY_A );
301
  }
wppa-wpdb-insert.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level wpdb routines that add new records
6
- * Version 6.9.20
7
  *
8
  */
9
 
@@ -26,13 +26,13 @@ global $wpdb;
26
  // WPPA_SESSION is auto increment
27
  $query = $wpdb->prepare( "INSERT INTO $wpdb->wppa_session (
28
 
29
- `session`,
30
- `timestamp`,
31
- `user`,
32
- `ip`,
33
- `status`,
34
- `data`,
35
- `count`
36
  )
37
  VALUES ( %s, %s, %s, %s, %s, %s, %s )",
38
 
@@ -48,7 +48,7 @@ global $wpdb;
48
 
49
  // Succcessful insert: return record id
50
  if ( $iret ) {
51
- $result = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM $wpdb->wppa_session WHERE `session` = %s ORDER BY `id` DESC LIMIT 1", wppa_get_session_id() ) );
52
  return $result;
53
  }
54
  else {
@@ -70,9 +70,9 @@ global $wpdb;
70
  // WPPA_INDEX is now AUTO_INCREMENT
71
 
72
  $query = $wpdb->prepare("INSERT INTO $wpdb->wppa_index (
73
- `slug`,
74
- `albums`,
75
- `photos`
76
  )
77
  VALUES ( %s, %s, %s )",
78
 
@@ -105,12 +105,12 @@ global $wpdb;
105
  $args['description'] = str_replace( array(chr(0),chr(1),chr(2),chr(3),chr(4),chr(5),chr(6),chr(7)), '', $args['description'] );
106
 
107
  $query = $wpdb->prepare("INSERT INTO $wpdb->wppa_exif (
108
- `photo`,
109
- `tag`,
110
- `description`,
111
- `f_description`,
112
- `status`,
113
- `brand`
114
  )
115
  VALUES ( %s, %s, %s, %s, %s, %s )",
116
 
@@ -144,10 +144,10 @@ global $wpdb;
144
  $args['description'] = str_replace( array(chr(0),chr(1),chr(2),chr(3),chr(4),chr(5),chr(6),chr(7)), '', $args['description'] );
145
 
146
  $query = $wpdb->prepare("INSERT INTO $wpdb->wppa_iptc (
147
- `photo`,
148
- `tag`,
149
- `description`,
150
- `status`
151
  )
152
  VALUES ( %s, %s, %s, %s )",
153
 
@@ -178,14 +178,14 @@ global $wpdb;
178
 
179
  if ( ! wppa_is_id_free( WPPA_COMMENTS, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_COMMENTS );
180
 
181
- $query = $wpdb->prepare("INSERT INTO $wpdb->wppa_comments ( `id`,
182
- `timestamp`,
183
- `photo`,
184
- `user`,
185
- `ip`,
186
- `email`,
187
- `comment`,
188
- `status`
189
  )
190
  VALUES ( %s, %s, %s, %s, %s, %s, %s, %s )",
191
  $args['id'],
@@ -223,12 +223,12 @@ global $wpdb;
223
 
224
  if ( ! wppa_is_id_free( WPPA_RATING, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_RATING );
225
 
226
- $query = $wpdb->prepare("INSERT INTO $wpdb->wppa_rating ( `id`,
227
- `timestamp`,
228
- `photo`,
229
- `value`,
230
- `user`,
231
- `status`
232
  )
233
  VALUES ( %s, %s, %s, %s, %s, %s )",
234
  $args['id'],
@@ -273,7 +273,7 @@ global $wpdb;
273
  'exifdtm' => '',
274
  'videox' => '0',
275
  'videoy' => '0',
276
- 'scheduledtm' => $args['album'] ? $wpdb->get_var( $wpdb->prepare( "SELECT `scheduledtm` FROM $wpdb->wppa_albums WHERE `id` = %s", $args['album'] ) ) : '',
277
  'scheduledel' => '',
278
  'custom' => '',
279
  'crypt' => wppa_get_unique_photo_crypt(),
@@ -286,37 +286,37 @@ global $wpdb;
286
 
287
  if ( ! wppa_is_id_free( WPPA_PHOTOS, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_PHOTOS );
288
 
289
- $query = $wpdb->prepare( "INSERT INTO $wpdb->wppa_photos ( `id`,
290
- `album`,
291
- `ext`,
292
- `name`,
293
- `description`,
294
- `p_order`,
295
- `mean_rating`,
296
- `linkurl`,
297
- `linktitle`,
298
- `linktarget`,
299
- `owner`,
300
- `timestamp`,
301
- `status`,
302
- `rating_count`,
303
- `tags`,
304
- `alt`,
305
- `filename`,
306
- `modified`,
307
- `location`,
308
- `views`,
309
- `page_id`,
310
- `exifdtm`,
311
- `videox`,
312
- `videoy`,
313
- `scheduledtm`,
314
- `scheduledel`,
315
- `custom`,
316
- `crypt`,
317
- `magickstack`,
318
- `indexdtm`,
319
- `panorama`
320
  )
321
  VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )",
322
  $args['id'],
@@ -397,29 +397,29 @@ global $wpdb;
397
 
398
  if ( ! wppa_is_id_free( WPPA_ALBUMS, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_ALBUMS );
399
 
400
- $query = $wpdb->prepare("INSERT INTO $wpdb->wppa_albums ( `id`,
401
- `name`,
402
- `description`,
403
- `a_order`,
404
- `main_photo`,
405
- `a_parent`,
406
- `p_order_by`,
407
- `cover_linktype`,
408
- `cover_linkpage`,
409
- `owner`,
410
- `timestamp`,
411
- `modified`,
412
- `upload_limit`,
413
- `alt_thumbsize`,
414
- `default_tags`,
415
- `cover_type`,
416
- `suba_order_by`,
417
- `views`,
418
- `cats`,
419
- `scheduledtm`,
420
- `crypt`,
421
- `treecounts`,
422
- `indexdtm`
423
  )
424
  VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s ,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )",
425
  $args['id'],
@@ -475,7 +475,7 @@ global $wpdb;
475
  $lastkey = get_option( $name, 'nil' );
476
 
477
  if ( $lastkey == 'nil' ) { // Init option
478
- $lastkey = $wpdb->get_var( "SELECT `id` FROM `".$table."` WHERE `id` < '9223372036854775806' ORDER BY `id` DESC LIMIT 1" );
479
  if ( ! is_numeric( $lastkey ) || $lastkey <= '0' ) {
480
  $lastkey = '0';
481
  }
@@ -504,7 +504,7 @@ global $wpdb;
504
  exit();
505
  }
506
 
507
- $exists = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `$table` WHERE `id` = %s", $id ), ARRAY_A );
508
  if ( $exists ) return false;
509
  return true;
510
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level wpdb routines that add new records
6
+ * Version 6.9.21
7
  *
8
  */
9
 
26
  // WPPA_SESSION is auto increment
27
  $query = $wpdb->prepare( "INSERT INTO $wpdb->wppa_session (
28
 
29
+ session,
30
+ timestamp,
31
+ user,
32
+ ip,
33
+ status,
34
+ data,
35
+ count
36
  )
37
  VALUES ( %s, %s, %s, %s, %s, %s, %s )",
38
 
48
 
49
  // Succcessful insert: return record id
50
  if ( $iret ) {
51
+ $result = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->wppa_session WHERE session = %s ORDER BY id DESC LIMIT 1", wppa_get_session_id() ) );
52
  return $result;
53
  }
54
  else {
70
  // WPPA_INDEX is now AUTO_INCREMENT
71
 
72
  $query = $wpdb->prepare("INSERT INTO $wpdb->wppa_index (
73
+ slug,
74
+ albums,
75
+ photos
76
  )
77
  VALUES ( %s, %s, %s )",
78
 
105
  $args['description'] = str_replace( array(chr(0),chr(1),chr(2),chr(3),chr(4),chr(5),chr(6),chr(7)), '', $args['description'] );
106
 
107
  $query = $wpdb->prepare("INSERT INTO $wpdb->wppa_exif (
108
+ photo,
109
+ tag,
110
+ description,
111
+ f_description,
112
+ status,
113
+ brand
114
  )
115
  VALUES ( %s, %s, %s, %s, %s, %s )",
116
 
144
  $args['description'] = str_replace( array(chr(0),chr(1),chr(2),chr(3),chr(4),chr(5),chr(6),chr(7)), '', $args['description'] );
145
 
146
  $query = $wpdb->prepare("INSERT INTO $wpdb->wppa_iptc (
147
+ photo,
148
+ tag,
149
+ description,
150
+ status
151
  )
152
  VALUES ( %s, %s, %s, %s )",
153
 
178
 
179
  if ( ! wppa_is_id_free( WPPA_COMMENTS, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_COMMENTS );
180
 
181
+ $query = $wpdb->prepare("INSERT INTO $wpdb->wppa_comments ( id,
182
+ timestamp,
183
+ photo,
184
+ user,
185
+ ip,
186
+ email,
187
+ comment,
188
+ status
189
  )
190
  VALUES ( %s, %s, %s, %s, %s, %s, %s, %s )",
191
  $args['id'],
223
 
224
  if ( ! wppa_is_id_free( WPPA_RATING, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_RATING );
225
 
226
+ $query = $wpdb->prepare("INSERT INTO $wpdb->wppa_rating ( id,
227
+ timestamp,
228
+ photo,
229
+ value,
230
+ user,
231
+ status
232
  )
233
  VALUES ( %s, %s, %s, %s, %s, %s )",
234
  $args['id'],
273
  'exifdtm' => '',
274
  'videox' => '0',
275
  'videoy' => '0',
276
+ 'scheduledtm' => $args['album'] ? $wpdb->get_var( $wpdb->prepare( "SELECT scheduledtm FROM $wpdb->wppa_albums WHERE id = %s", $args['album'] ) ) : '',
277
  'scheduledel' => '',
278
  'custom' => '',
279
  'crypt' => wppa_get_unique_photo_crypt(),
286
 
287
  if ( ! wppa_is_id_free( WPPA_PHOTOS, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_PHOTOS );
288
 
289
+ $query = $wpdb->prepare( "INSERT INTO $wpdb->wppa_photos ( id,
290
+ album,
291
+ ext,
292
+ name,
293
+ description,
294
+ p_order,
295
+ mean_rating,
296
+ linkurl,
297
+ linktitle,
298
+ linktarget,
299
+ owner,
300
+ timestamp,
301
+ status,
302
+ rating_count,
303
+ tags,
304
+ alt,
305
+ filename,
306
+ modified,
307
+ location,
308
+ views,
309
+ page_id,
310
+ exifdtm,
311
+ videox,
312
+ videoy,
313
+ scheduledtm,
314
+ scheduledel,
315
+ custom,
316
+ crypt,
317
+ magickstack,
318
+ indexdtm,
319
+ panorama
320
  )
321
  VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )",
322
  $args['id'],
397
 
398
  if ( ! wppa_is_id_free( WPPA_ALBUMS, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_ALBUMS );
399
 
400
+ $query = $wpdb->prepare("INSERT INTO $wpdb->wppa_albums ( id,
401
+ name,
402
+ description,
403
+ a_order,
404
+ main_photo,
405
+ a_parent,
406
+ p_order_by,
407
+ cover_linktype,
408
+ cover_linkpage,
409
+ owner,
410
+ timestamp,
411
+ modified,
412
+ upload_limit,
413
+ alt_thumbsize,
414
+ default_tags,
415
+ cover_type,
416
+ suba_order_by,
417
+ views,
418
+ cats,
419
+ scheduledtm,
420
+ crypt,
421
+ treecounts,
422
+ indexdtm
423
  )
424
  VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s ,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )",
425
  $args['id'],
475
  $lastkey = get_option( $name, 'nil' );
476
 
477
  if ( $lastkey == 'nil' ) { // Init option
478
+ $lastkey = $wpdb->get_var( "SELECT id FROM ".$table." WHERE id < '9223372036854775806' ORDER BY id DESC LIMIT 1" );
479
  if ( ! is_numeric( $lastkey ) || $lastkey <= '0' ) {
480
  $lastkey = '0';
481
  }
504
  exit();
505
  }
506
 
507
+ $exists = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table WHERE id = %s", $id ), ARRAY_A );
508
  if ( $exists ) return false;
509
  return true;
510
  }
wppa-wpdb-update.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level wpdb routines that update records
6
- * Version 6.9.14
7
  *
8
  */
9
 
@@ -78,7 +78,7 @@ global $wpdb;
78
  }
79
 
80
  if ( $doit ) {
81
- if ( $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_albums SET `".$itemname."` = %s WHERE `id` = %s LIMIT 1", $itemvalue, $id ) ) ) {
82
  wppa_cache_album( 'invalidate' );
83
  }
84
  }
@@ -93,20 +93,20 @@ global $wpdb;
93
  return true;
94
 
95
  /*
96
- `a_order`,
97
- `main_photo`,
98
- `a_parent`,
99
- `p_order_by`,
100
- `cover_linktype`,
101
- `cover_linkpage`,
102
- `owner`,
103
- `upload_limit`,
104
- `alt_thumbsize`,
105
- `default_tags`,
106
- `cover_type`,
107
- `suba_order_by`,
108
- `views`,
109
- `cats`
110
  */
111
  }
112
 
@@ -219,7 +219,7 @@ global $wpdb;
219
  }
220
 
221
  if ( $doit ) {
222
- if ( $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `".$itemname."` = %s WHERE `id` = %s LIMIT 1", $itemvalue, $id ) ) ) {
223
  wppa_cache_photo( 'invalidate', $id );
224
  }
225
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level wpdb routines that update records
6
+ * Version 6.9.21
7
  *
8
  */
9
 
78
  }
79
 
80
  if ( $doit ) {
81
+ if ( $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_albums SET ".$itemname." = %s WHERE id = %s LIMIT 1", $itemvalue, $id ) ) ) {
82
  wppa_cache_album( 'invalidate' );
83
  }
84
  }
93
  return true;
94
 
95
  /*
96
+ a_order,
97
+ main_photo,
98
+ a_parent,
99
+ p_order_by,
100
+ cover_linktype,
101
+ cover_linkpage,
102
+ owner,
103
+ upload_limit,
104
+ alt_thumbsize,
105
+ default_tags,
106
+ cover_type,
107
+ suba_order_by,
108
+ views,
109
+ cats
110
  */
111
  }
112
 
219
  }
220
 
221
  if ( $doit ) {
222
+ if ( $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET ".$itemname." = %s WHERE id = %s LIMIT 1", $itemvalue, $id ) ) ) {
223
  wppa_cache_photo( 'invalidate', $id );
224
  }
225
  }
wppa-wrappers.php CHANGED
@@ -46,16 +46,46 @@ function wppa_copy( $from, $to ) {
46
  function wppa_move_uploaded_file( $from, $to ) {
47
 
48
  if ( ! wppa_is_path_safe( $to ) ) {
49
- wppa_log( 'War', 'Unsafe to path detected in move_uploaded_file(): ' . sanitize_text_field( $to ), true );
50
  return false; // For diagnostic purposes, no return here yet
51
  }
52
- $bret = move_uploaded_file( $from, $to );
 
 
 
 
 
53
  if ( ! $bret ) {
54
  wppa_log( 'War', 'Could not move uploaded file ' . sanitize_text_field( $from ) . ' to ' . sanitize_text_field( $to ), true );
55
  }
56
  return $bret;
57
  }
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  // Wrapper for fopen
60
  function wppa_fopen( $file, $mode ) {
61
 
@@ -78,13 +108,35 @@ function wppa_glob( $pattern, $flags = null ) {
78
  // Is path safe?
79
  $dir = dirname( $pattern );
80
  if ( ! wppa_is_path_safe( $dir ) ) {
81
- wppa_log( 'War', 'Unsafe to path detected in wppa_glob(): ' . sanitize_text_field( $pattern ), true );
82
  return false;
83
  }
84
 
85
  return glob( $pattern, $flags );
86
  }
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  // Utility to check if a given full filepath is safe to manipulate upon
89
  function wppa_is_path_safe( $path ) {
90
  static $safe_roots;
@@ -95,9 +147,8 @@ global $wppa_log_file;
95
  if ( empty( $safe_files ) ) {
96
 
97
  // The following files are safe to read or write to
98
- $safe_files = array( WPPA_PATH . '/wppa-init.' . $wppa_lang . '.js',
99
- WPPA_PATH . '/wppa-dynamic.css',
100
- WPPA_PATH . '/index.php',
101
  WPPA_CONTENT_PATH . '/uploads/index.php',
102
  $wppa_log_file,
103
  WPPA_CONTENT_PATH . '/plugins/wp-photo-album-plus/img/audiostub.jpg',
@@ -114,6 +165,7 @@ global $wppa_log_file;
114
  WPPA_PATH . '/fonts',
115
  WPPA_PATH . '/watermarks',
116
  WPPA_PATH . '/wppa-dump.txt',
 
117
  WPPA_UPLOAD_PATH . '/temp/',
118
  WPPA_UPLOAD_PATH . '/zips/',
119
  );
@@ -274,3 +326,4 @@ function wppa_unserialize( $xstring, $is_session = false ) {
274
  return $result;
275
  }
276
  }
 
46
  function wppa_move_uploaded_file( $from, $to ) {
47
 
48
  if ( ! wppa_is_path_safe( $to ) ) {
49
+ wppa_log( 'War', 'Unsafe to path detected in wppa_move_uploaded_file(): ' . sanitize_text_field( $to ), true );
50
  return false; // For diagnostic purposes, no return here yet
51
  }
52
+ if ( strpos( $from, '../' ) !== false ) {
53
+ $bret = false;
54
+ }
55
+ else {
56
+ $bret = move_uploaded_file( $from, $to );
57
+ }
58
  if ( ! $bret ) {
59
  wppa_log( 'War', 'Could not move uploaded file ' . sanitize_text_field( $from ) . ' to ' . sanitize_text_field( $to ), true );
60
  }
61
  return $bret;
62
  }
63
 
64
+ // Wrapper for rename
65
+ function wppa_rename( $from, $to ) {
66
+
67
+ $bret = false;
68
+ if ( ! wppa_is_path_safe( $from ) ) {
69
+ wppa_log( 'War', 'Unsafe from path detected in wppa_rename(): ' . sanitize_text_field( $from ), true );
70
+ return false;
71
+ }
72
+ if ( ! wppa_is_path_safe( $to ) ) {
73
+ wppa_log( 'War', 'Unsafe to path detected in wppa_rename(): ' . sanitize_text_field( $to ), true );
74
+ return false;
75
+ }
76
+ if ( file_exists( $from ) ) {
77
+ $bret = rename( $from, $to );
78
+ if ( ! $bret ) {
79
+ wppa_log( 'Fso', 'Could not rename file ' . sanitize_text_field( $from ) . ' to ' . sanitize_text_field( $to ), true );
80
+ }
81
+ }
82
+ else {
83
+ wppa_log( 'Fso', 'Could not rename non existent file ' . sanitize_text_field( $from ) . ' to ' . sanitize_text_field( $to ), true );
84
+ }
85
+
86
+ return $bret;
87
+ }
88
+
89
  // Wrapper for fopen
90
  function wppa_fopen( $file, $mode ) {
91
 
108
  // Is path safe?
109
  $dir = dirname( $pattern );
110
  if ( ! wppa_is_path_safe( $dir ) ) {
111
+ wppa_log( 'War', 'Unsafe path detected in wppa_glob(): ' . sanitize_text_field( $pattern ), true );
112
  return false;
113
  }
114
 
115
  return glob( $pattern, $flags );
116
  }
117
 
118
+ // Wrapper for unlink
119
+ function wppa_unlink( $file ) {
120
+
121
+ if ( ! wppa_is_path_safe( $file ) ) {
122
+ wppa_log( 'War', 'Unsafe path detected in wppa_unlink(): ' . sanitize_text_field( $file ), true );
123
+ return false;
124
+ }
125
+
126
+ return unlink( $file );
127
+ }
128
+
129
+ // Wrapper for rmdir
130
+ function wppa_rmdir( $dir ) {
131
+
132
+ if ( ! wppa_is_path_safe( $dir ) ) {
133
+ wppa_log( 'War', 'Unsafe path detected in wppa_rmdir(): ' . sanitize_text_field( $dir ), true );
134
+ return false;
135
+ }
136
+
137
+ return rmdir( $dir );
138
+ }
139
+
140
  // Utility to check if a given full filepath is safe to manipulate upon
141
  function wppa_is_path_safe( $path ) {
142
  static $safe_roots;
147
  if ( empty( $safe_files ) ) {
148
 
149
  // The following files are safe to read or write to
150
+ $safe_files = array( WPPA_PATH . '/index.php',
151
+ WPPA_PATH . '/wppa-dump.txt',
 
152
  WPPA_CONTENT_PATH . '/uploads/index.php',
153
  $wppa_log_file,
154
  WPPA_CONTENT_PATH . '/plugins/wp-photo-album-plus/img/audiostub.jpg',
165
  WPPA_PATH . '/fonts',
166
  WPPA_PATH . '/watermarks',
167
  WPPA_PATH . '/wppa-dump.txt',
168
+ WPPA_PATH . '/dynamic',
169
  WPPA_UPLOAD_PATH . '/temp/',
170
  WPPA_UPLOAD_PATH . '/zips/',
171
  );
326
  return $result;
327
  }
328
  }
329
+
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: 6.9.20.004
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/
@@ -22,8 +22,8 @@ global $wpdb;
22
  global $wp_version;
23
 
24
  /* WPPA GLOBALS */
25
- global $wppa_revno; $wppa_revno = '6920'; // WPPA db version
26
- global $wppa_api_version; $wppa_api_version = '6-9-20-004'; // WPPA software version
27
 
28
  /* start timers */
29
  global $wppa_starttime; $wppa_starttime = microtime( true );
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: 6.9.21.005
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/
22
  global $wp_version;
23
 
24
  /* WPPA GLOBALS */
25
+ global $wppa_revno; $wppa_revno = '6921'; // WPPA db version
26
+ global $wppa_api_version; $wppa_api_version = '6-9-21-005'; // WPPA software version
27
 
28
  /* start timers */
29
  global $wppa_starttime; $wppa_starttime = microtime( true );