WP Photo Album Plus - Version 6.9.14

Version Description

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

Release Info

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

Code changes from version 6.9.13 to 6.9.14

changelog.txt CHANGED
@@ -1,5 +1,12 @@
1
  WP Photo Album Plus Changelog
2
 
 
 
 
 
 
 
 
3
  = 6.9.13 =
4
 
5
  = Bug Fixes =
1
  WP Photo Album Plus Changelog
2
 
3
+ = 6.9.14 =
4
+
5
+ = Other Changes =
6
+
7
+ * Added Table IX-A14: Load front-end code always.
8
+ * Various security fixes.
9
+
10
  = 6.9.13 =
11
 
12
  = 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.13
6
- Stable tag: 6.9.12
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.13 =
141
 
142
  * Security release.
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.14
6
+ Stable tag: 6.9.13
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.14 =
141
+
142
+ * This version addresses various minor bug fixes and feature requests.
143
+ * This version addresses various security issues.
144
+
145
  = 6.9.13 =
146
 
147
  * Security release.
wppa-admin-functions.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * gp admin functions
6
- * Version 6.8.09
7
  *
8
  */
9
 
@@ -147,7 +147,7 @@ global $wpdb;
147
  if ( $files ) foreach ( $files as $file ) {
148
  if ( ! is_dir( $file ) ) {
149
  $filename = basename( $file );
150
- $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `filename` = %s OR ( `filename` = '' AND `name` = %s )", $filename, $filename ), ARRAY_A );
151
  if ( $photos ) foreach ( $photos as $photo ) { // Photo exists
152
  $modified_time = $photo['modified'];
153
  if ( $modified_time < $start_time ) {
@@ -174,7 +174,7 @@ global $wpdb;
174
 
175
  // Do it with a single photo
176
  elseif ( $pid ) {
177
- $photo = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $pid ), ARRAY_A );
178
  if ( $photo ) {
179
  $file = wppa_get_source_path( $photo['id'] );
180
  if ( is_file( $file ) ) {
@@ -612,7 +612,7 @@ function wppa_admin_page_links( $curpage, $pagesize, $count, $link, $extra = ''
612
  function wppa_update_single_photo( $file, $id, $name ) {
613
  global $wpdb;
614
 
615
- $photo = $wpdb->get_row( $wpdb->prepare( "SELECT `id`, `name`, `ext`, `album`, `filename` FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $id ), ARRAY_A );
616
 
617
  // Find extension
618
  $ext = $photo['ext'];
@@ -659,7 +659,7 @@ global $allphotos;
659
 
660
  // Find photo entries that apply to the supplied filename
661
  $query = $wpdb->prepare(
662
- "SELECT * FROM `".WPPA_PHOTOS."` WHERE ".
663
  "`filename` = %s OR ".
664
  "`filename` = %s OR ".
665
  "( `filename` = '' AND `name` = %s ) OR ".
@@ -701,7 +701,7 @@ global $allphotos;
701
 
702
  // Update filename if still empty ( Old )
703
  if ( ! $photo['filename'] ) {
704
- $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `filename` = %s WHERE `id` = %s", wppa_sanitize_file_name( basename( $file ) ), $id ) );
705
  }
706
  }
707
  return count( $photos );
@@ -998,18 +998,18 @@ function wppa_prep_for_csv( $data ) {
998
  function wppa_album_admin_footer() {
999
  global $wpdb;
1000
 
1001
- $albcount = $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_ALBUMS."`" );
1002
- $photocount = $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."`" );
1003
- $pendingcount = $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `status` = 'pending'" );
1004
- $schedulecount = $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `status` = 'scheduled'" );
1005
 
1006
  echo sprintf(__('There are <strong>%d</strong> albums and <strong>%d</strong> photos in the system.', 'wp-photo-album-plus'), $albcount, $photocount);
1007
  if ( $pendingcount ) echo ' '.sprintf(__('<strong>%d</strong> photos are pending moderation.', 'wp-photo-album-plus'), $pendingcount);
1008
  if ( $schedulecount ) echo ' '.sprintf(__('<strong>%d</strong> photos are scheduled for later publishing.', 'wp-photo-album-plus'), $pendingcount);
1009
 
1010
- $lastalbum = $wpdb->get_row( "SELECT `id`, `name` FROM `".WPPA_ALBUMS."` ORDER BY `id` DESC LIMIT 1", ARRAY_A );
1011
  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']);
1012
- $lastphoto = $wpdb->get_row( "SELECT `id`, `name`, `album` FROM `".WPPA_PHOTOS."` ORDER BY `timestamp` DESC LIMIT 1", ARRAY_A );
1013
  if ( $lastphoto['album'] < '1' ) {
1014
  $trashed = true;
1015
  $album = - ( $lastphoto['album'] + '9' );
@@ -1018,7 +1018,7 @@ global $wpdb;
1018
  $trashed = false;
1019
  $album = $lastphoto['album'];
1020
  }
1021
- $lastphotoalbum = $wpdb->get_row($wpdb->prepare( "SELECT `id`, `name` FROM `".WPPA_ALBUMS."` WHERE `id` = %s", $album), ARRAY_A );
1022
  if ( $lastphoto ) {
1023
  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']);
1024
  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.14
7
  *
8
  */
9
 
147
  if ( $files ) foreach ( $files as $file ) {
148
  if ( ! is_dir( $file ) ) {
149
  $filename = basename( $file );
150
+ $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `filename` = %s OR ( `filename` = '' AND `name` = %s )", $filename, $filename ), ARRAY_A );
151
  if ( $photos ) foreach ( $photos as $photo ) { // Photo exists
152
  $modified_time = $photo['modified'];
153
  if ( $modified_time < $start_time ) {
174
 
175
  // Do it with a single photo
176
  elseif ( $pid ) {
177
+ $photo = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `id` = %s", $pid ), ARRAY_A );
178
  if ( $photo ) {
179
  $file = wppa_get_source_path( $photo['id'] );
180
  if ( is_file( $file ) ) {
612
  function wppa_update_single_photo( $file, $id, $name ) {
613
  global $wpdb;
614
 
615
+ $photo = $wpdb->get_row( $wpdb->prepare( "SELECT `id`, `name`, `ext`, `album`, `filename` FROM $wpdb->wppa_photos WHERE `id` = %s", $id ), ARRAY_A );
616
 
617
  // Find extension
618
  $ext = $photo['ext'];
659
 
660
  // Find photo entries that apply to the supplied filename
661
  $query = $wpdb->prepare(
662
+ "SELECT * FROM $wpdb->wppa_photos WHERE ".
663
  "`filename` = %s OR ".
664
  "`filename` = %s OR ".
665
  "( `filename` = '' AND `name` = %s ) OR ".
701
 
702
  // Update filename if still empty ( Old )
703
  if ( ! $photo['filename'] ) {
704
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `filename` = %s WHERE `id` = %s", wppa_sanitize_file_name( basename( $file ) ), $id ) );
705
  }
706
  }
707
  return count( $photos );
998
  function wppa_album_admin_footer() {
999
  global $wpdb;
1000
 
1001
+ $albcount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_albums" );
1002
+ $photocount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos" );
1003
+ $pendingcount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `status` = 'pending'" );
1004
+ $schedulecount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `status` = 'scheduled'" );
1005
 
1006
  echo sprintf(__('There are <strong>%d</strong> albums and <strong>%d</strong> photos in the system.', 'wp-photo-album-plus'), $albcount, $photocount);
1007
  if ( $pendingcount ) echo ' '.sprintf(__('<strong>%d</strong> photos are pending moderation.', 'wp-photo-album-plus'), $pendingcount);
1008
  if ( $schedulecount ) echo ' '.sprintf(__('<strong>%d</strong> photos are scheduled for later publishing.', 'wp-photo-album-plus'), $pendingcount);
1009
 
1010
+ $lastalbum = $wpdb->get_row( "SELECT `id`, `name` FROM $wpdb->wppa_albums ORDER BY `id` DESC LIMIT 1", ARRAY_A );
1011
  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']);
1012
+ $lastphoto = $wpdb->get_row( "SELECT `id`, `name`, `album` FROM $wpdb->wppa_photos ORDER BY `timestamp` DESC LIMIT 1", ARRAY_A );
1013
  if ( $lastphoto['album'] < '1' ) {
1014
  $trashed = true;
1015
  $album = - ( $lastphoto['album'] + '9' );
1018
  $trashed = false;
1019
  $album = $lastphoto['album'];
1020
  }
1021
+ $lastphotoalbum = $wpdb->get_row($wpdb->prepare( "SELECT `id`, `name` FROM $wpdb->wppa_albums WHERE `id` = %s", $album), ARRAY_A );
1022
  if ( $lastphoto ) {
1023
  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']);
1024
  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.13
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 `".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
@@ -179,6 +179,10 @@ require_once 'wppa-tinymce-shortcodes.php';
179
  require_once 'wppa-tinymce-photo.php';
180
  require_once 'wppa-privacy-policy.php';
181
 
 
 
 
 
182
  /* This is for the changelog text when an update is available */
183
  global $pagenow;
184
  if ( 'plugins.php' === $pagenow )
@@ -239,7 +243,7 @@ global $wpdb;
239
 
240
  // Recently uploaded photos
241
  echo '<h3>' . __( 'Recently uploaded photos', 'wp-photo-album-plus' ) . '</h3>';
242
- $photos = $wpdb->get_results( "SELECT * FROM `" . WPPA_PHOTOS . "` ORDER BY `timestamp` DESC LIMIT 5", ARRAY_A );
243
 
244
  if ( ! empty( $photos ) ) {
245
  echo
@@ -289,7 +293,7 @@ global $wpdb;
289
 
290
  // Recent comments
291
  echo '<h3>' . __( 'Recent comments on photos', 'wp-photo-album-plus' ) . '</h3>';
292
- $comments = $wpdb->get_results( "SELECT * FROM `" . WPPA_COMMENTS . "` ORDER BY `timestamp` DESC LIMIT 5", ARRAY_A );
293
  if ( ! empty( $comments ) ) {
294
 
295
  echo
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains the admin menu and startups the admin pages
6
+ * Version 6.9.14
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
179
  require_once 'wppa-tinymce-photo.php';
180
  require_once 'wppa-privacy-policy.php';
181
 
182
+ if ( is_file( dirname( __FILE__ ) . '/wppa-gutenberg-photo.php' ) ) {
183
+ require_once 'wppa-gutenberg-photo.php';
184
+ }
185
+
186
  /* This is for the changelog text when an update is available */
187
  global $pagenow;
188
  if ( 'plugins.php' === $pagenow )
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
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
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.6.29
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 `".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 `".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.14
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.13
6
  *
7
  */
8
 
@@ -121,7 +121,7 @@ global $wppa_log_file;
121
  }
122
  }
123
  if ( ! $any ) {
124
- $query = $wpdb->prepare( "UPDATE `" . WPPA_IPTC . "` SET `status` = 'hide' WHERE `photo` = '0' AND `tag` = %s", $tag );
125
  $wpdb->query( $query );
126
  }
127
  wppa_exit();
@@ -235,7 +235,7 @@ global $wppa_log_file;
235
 
236
  // Cleanup possible unused label
237
  if ( ! $any ) {
238
- $query = $wpdb->prepare( "UPDATE `" . WPPA_EXIF . "` SET `status` = 'hide' WHERE `photo` = '0' AND `tag` = %s", $tag );
239
  $wpdb->query( $query );
240
  }
241
  wppa_exit();
@@ -251,6 +251,7 @@ global $wppa_log_file;
251
  else {
252
  $photo = $_REQUEST['photo-id'];
253
  }
 
254
 
255
  // Is this user aloowed to edit thisphoto?
256
  $ok = wppa_may_user_fe_edit( $photo );
@@ -398,9 +399,9 @@ global $wppa_log_file;
398
  }
399
 
400
  if ( isset( $_REQUEST['photo-id'] ) && current_user_can( 'wppa_moderate' ) ) {
401
- $iret = $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `status` = 'publish' WHERE `id` = %s", $_REQUEST['photo-id'] ) );
402
  wppa_flush_upldr_cache( 'photoid', $_REQUEST['photo-id'] );
403
- $alb = $wpdb->get_var( $wpdb->prepare( "SELECT `album` FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $_REQUEST['photo-id'] ) );
404
  wppa_clear_taglist();
405
  wppa_invalidate_treecounts( $alb );
406
  }
@@ -463,7 +464,7 @@ global $wppa_log_file;
463
  wppa_exit();
464
  }
465
 
466
- $photo = $wpdb->get_var( $wpdb->prepare( "SELECT `photo` FROM `" . WPPA_COMMENTS . "` WHERE `id` = %s", $_REQUEST['comment-id'] ) );
467
  $iret = $wpdb->query( $wpdb->prepare( "DELETE FROM `".WPPA_COMMENTS."` WHERE `id`= %s", $_REQUEST['comment-id'] ) );
468
  if ( $iret ) {
469
  if ( wppa_opt( 'search_comments' ) ) {
@@ -492,7 +493,7 @@ global $wppa_log_file;
492
  $status = "`status` <> 'pending' AND `status` <> 'scheduled'";
493
  if ( ! is_user_logged_in() ) $status .= " AND `status` <> 'private'";
494
 
495
- $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `album` = %s AND ( ( ".$status." ) OR owner = %s ) ".wppa_get_photo_order( $alb ), $alb, wppa_get_user() ), ARRAY_A );
496
  if ( ! $photos ) {
497
  echo '||ER||'.__( 'The album is empty' , 'wp-photo-album-plus');
498
  wppa_exit();
@@ -595,7 +596,7 @@ global $wppa_log_file;
595
  $zipfile = $zipsdir.wppa_get_user().'.zip';
596
 
597
  // Find the photo data
598
- $data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $photo ), ARRAY_A );
599
 
600
  // Find the photo file
601
  if ( is_file ( wppa_get_source_path( $photo ) ) ) {
@@ -645,7 +646,7 @@ global $wppa_log_file;
645
  wppa_exit();
646
  }
647
 
648
- $data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $photo ), ARRAY_A );
649
 
650
  if ( $data ) { // The photo is supposed to exist
651
 
@@ -740,6 +741,21 @@ global $wppa_log_file;
740
  wppa_exit();
741
  break;
742
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
743
  case 'bumpviewcount':
744
  $nonce = $_REQUEST['wppa-nonce'];
745
  if ( wp_verify_nonce( $nonce, 'wppa-check' ) ) {
@@ -864,7 +880,7 @@ global $wppa_log_file;
864
  if ( $mylast ) {
865
 
866
  // Remove my like
867
- $wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPPA_RATING . "` WHERE `photo` = %s AND `user` = %s", $photo, $user ) );
868
  $myavgrat = '0';
869
  }
870
  else {
@@ -1020,7 +1036,7 @@ global $wppa_log_file;
1020
  // Compute rating_count and store in the photo info
1021
  $ratcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_RATING."` WHERE `photo` = %s", $photo ) );
1022
  if ( $ratcount !== false ) {
1023
- $iret = $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `rating_count` = %s WHERE `id` = %s", $ratcount, $photo ) );
1024
  if ( $iret === false ) {
1025
  echo '0||107||'.$wartxt;
1026
  wppa_exit(); // Fail on save
@@ -1332,7 +1348,7 @@ global $wppa_log_file;
1332
  case 'hour':
1333
  case 'min':
1334
  $itemname = __( 'Schedule date/time' , 'wp-photo-album-plus');
1335
- $scheduledtm = $wpdb->get_var( $wpdb->prepare( "SELECT `scheduledtm` FROM`".WPPA_ALBUMS."` WHERE `id` = %s", $album ) );
1336
  if ( ! $scheduledtm ) {
1337
  $scheduledtm = wppa_get_default_scheduledtm();
1338
  }
@@ -1349,9 +1365,9 @@ global $wppa_log_file;
1349
  break;
1350
 
1351
  case 'setallscheduled':
1352
- $scheduledtm = $wpdb->get_var( $wpdb->prepare( "SELECT `scheduledtm` FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $album ) );
1353
  if ( $scheduledtm ) {
1354
- $iret = $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `status` = 'scheduled', `scheduledtm` = %s WHERE `album` = %s", $scheduledtm, $album ) );
1355
  echo '||0||'.__( 'All photos set to scheduled per date', 'wp-photo-album-plus' ) . ' ' . wppa_format_scheduledtm( $scheduledtm );
1356
  }
1357
  wppa_exit();
@@ -2044,7 +2060,7 @@ global $wppa_log_file;
2044
  case 'hour':
2045
  case 'min':
2046
  $itemname = __( 'Schedule date/time' , 'wp-photo-album-plus');
2047
- $scheduledtm = $wpdb->get_var( $wpdb->prepare( "SELECT `scheduledtm` FROM`".WPPA_PHOTOS."` WHERE `id` = %s", $photo ) );
2048
  if ( ! $scheduledtm ) {
2049
  $scheduledtm = wppa_get_default_scheduledtm();
2050
  }
@@ -2056,7 +2072,7 @@ global $wppa_log_file;
2056
  if ( $item == 'min' ) $temp[4] = $value;
2057
  $scheduledtm = implode( ',', $temp );
2058
  wppa_update_photo( array( 'id' => $photo, 'scheduledtm' => $scheduledtm, 'status' => 'scheduled' ) );
2059
- wppa_invalidate_treecounts( $wpdb->get_var( $wpdb->prepare( "SELECT `album` FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $photo ) ) );
2060
  wppa_flush_upldr_cache( 'photoid', $photo );
2061
  if ( wppa_is_video( $photo ) ) {
2062
  echo '||0||'.sprintf( __( '%s of video %s updated' , 'wp-photo-album-plus'), $itemname, $photo );
@@ -2072,7 +2088,7 @@ global $wppa_log_file;
2072
  case 'delhour':
2073
  case 'delmin':
2074
  $itemname = __( 'Delete date/time' , 'wp-photo-album-plus');
2075
- $scheduledel = $wpdb->get_var( $wpdb->prepare( "SELECT `scheduledel` FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $photo ) );
2076
  if ( ! $scheduledel ) {
2077
  $scheduledel = wppa_get_default_scheduledtm();
2078
  }
@@ -2086,7 +2102,7 @@ global $wppa_log_file;
2086
  wppa_update_photo( array( 'id' => $photo, 'scheduledel' => $scheduledel ) );
2087
 
2088
  // Make sure not deleted yet
2089
- $alb = $wpdb->get_var( $wpdb->prepare( "SELECT `album` FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $photo ) );
2090
  if ( $alb < '-9' ) {
2091
  $alb = - ( $alb + '9' );
2092
  wppa_update_photo( array( 'id' => $photo, 'album' => $alb ) );
@@ -2635,8 +2651,8 @@ global $wppa_log_file;
2635
  }
2636
  break;
2637
  case 'wppa_viewcount_clear':
2638
- $iret = $wpdb->query( "UPDATE `".WPPA_PHOTOS."` SET `views` = '0'" ) &&
2639
- $wpdb->query( "UPDATE `".WPPA_ALBUMS."` SET `views` = '0'" );
2640
  if ( $iret !== false ) {
2641
  $title = __( 'Viewcounts cleared' , 'wp-photo-album-plus');
2642
  }
@@ -2974,9 +2990,9 @@ global $wppa_log_file;
2974
  case 'wppa_search_tags':
2975
  case 'wppa_search_cats':
2976
  case 'wppa_search_comments':
2977
- $wpdb->query( "UPDATE `" . WPPA_PHOTOS . "` SET `indexdtm` = ''" );
2978
  wppa_schedule_maintenance_proc( 'wppa_remake_index_photos' );
2979
- $wpdb->query( "UPDATE `" . WPPA_ALBUMS . "` SET `indexdtm` = ''" );
2980
  wppa_schedule_maintenance_proc( 'wppa_remake_index_albums' );
2981
  break;
2982
 
@@ -2985,7 +3001,7 @@ global $wppa_log_file;
2985
  $value = trim ( $value );
2986
  $user = wppa_get_user_by ( 'login', $value ); // seems to be case insensitive
2987
  if ( $user && $user->user_login === $value ) {
2988
- $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `status` = 'pending' WHERE `owner` = %s", $value ) );
2989
  $black_listed_users = get_option( 'wppa_black_listed_users', array() );
2990
  if ( ! in_array( $value, $black_listed_users ) ) {
2991
  $black_listed_users[] = $value;
@@ -3000,7 +3016,7 @@ global $wppa_log_file;
3000
  break;
3001
 
3002
  case 'wppa_un_blacklist_user':
3003
- $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `status` = 'publish' WHERE `owner` = %s", $value ) );
3004
  $black_listed_users = get_option( 'wppa_black_listed_users', array() );
3005
  if ( in_array( $value, $black_listed_users ) ) {
3006
  foreach ( array_keys( $black_listed_users ) as $usr ) {
@@ -3139,8 +3155,8 @@ global $wppa_log_file;
3139
 
3140
  case 'wppa_use_encrypted_links':
3141
  if ( $value == 'yes' ) {
3142
- $ca = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `crypt` = ''" );
3143
- $cp = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `crypt` = ''" );
3144
  if ( $ca + $cp ) {
3145
  if ( $ca ) update_option ( 'wppa_crypt_albums_status', 'Required' );
3146
  if ( $cp ) update_option ( 'wppa_crypt_photos_status', 'Required' );
2
  /* wppa-ajax.php
3
  *
4
  * Functions used in ajax requests
5
+ * Version 6.9.14
6
  *
7
  */
8
 
121
  }
122
  }
123
  if ( ! $any ) {
124
+ $query = $wpdb->prepare( "UPDATE $wpdb->wppa_iptc SET `status` = 'hide' WHERE `photo` = '0' AND `tag` = %s", $tag );
125
  $wpdb->query( $query );
126
  }
127
  wppa_exit();
235
 
236
  // Cleanup possible unused label
237
  if ( ! $any ) {
238
+ $query = $wpdb->prepare( "UPDATE $wpdb->wppa_exif SET `status` = 'hide' WHERE `photo` = '0' AND `tag` = %s", $tag );
239
  $wpdb->query( $query );
240
  }
241
  wppa_exit();
251
  else {
252
  $photo = $_REQUEST['photo-id'];
253
  }
254
+ $photo = strval( intval( $photo ) );
255
 
256
  // Is this user aloowed to edit thisphoto?
257
  $ok = wppa_may_user_fe_edit( $photo );
399
  }
400
 
401
  if ( isset( $_REQUEST['photo-id'] ) && current_user_can( 'wppa_moderate' ) ) {
402
+ $iret = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `status` = 'publish' WHERE `id` = %s", $_REQUEST['photo-id'] ) );
403
  wppa_flush_upldr_cache( 'photoid', $_REQUEST['photo-id'] );
404
+ $alb = $wpdb->get_var( $wpdb->prepare( "SELECT `album` FROM $wpdb->wppa_photos WHERE `id` = %s", $_REQUEST['photo-id'] ) );
405
  wppa_clear_taglist();
406
  wppa_invalidate_treecounts( $alb );
407
  }
464
  wppa_exit();
465
  }
466
 
467
+ $photo = $wpdb->get_var( $wpdb->prepare( "SELECT `photo` FROM $wpdb->wppa_comments WHERE `id` = %s", $_REQUEST['comment-id'] ) );
468
  $iret = $wpdb->query( $wpdb->prepare( "DELETE FROM `".WPPA_COMMENTS."` WHERE `id`= %s", $_REQUEST['comment-id'] ) );
469
  if ( $iret ) {
470
  if ( wppa_opt( 'search_comments' ) ) {
493
  $status = "`status` <> 'pending' AND `status` <> 'scheduled'";
494
  if ( ! is_user_logged_in() ) $status .= " AND `status` <> 'private'";
495
 
496
+ $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `album` = %s AND ( ( ".$status." ) OR owner = %s ) ".wppa_get_photo_order( $alb ), $alb, wppa_get_user() ), ARRAY_A );
497
  if ( ! $photos ) {
498
  echo '||ER||'.__( 'The album is empty' , 'wp-photo-album-plus');
499
  wppa_exit();
596
  $zipfile = $zipsdir.wppa_get_user().'.zip';
597
 
598
  // Find the photo data
599
+ $data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `id` = %s", $photo ), ARRAY_A );
600
 
601
  // Find the photo file
602
  if ( is_file ( wppa_get_source_path( $photo ) ) ) {
646
  wppa_exit();
647
  }
648
 
649
+ $data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `id` = %s", $photo ), ARRAY_A );
650
 
651
  if ( $data ) { // The photo is supposed to exist
652
 
741
  wppa_exit();
742
  break;
743
 
744
+ case 'gutenbergphotodialog':
745
+ $result = wppa_make_gutenberg_photo_dialog();
746
+ echo $result;
747
+ wppa_exit();
748
+ break;
749
+
750
+ case 'getshortcodedrendered':
751
+ require_once 'wppa-non-admin.php';
752
+ $id = trim( substr( $_REQUEST['shortcode'], 6 ), ' ]' );
753
+ // $result = do_shortcode( $_REQUEST['shortcode'] );
754
+ $result = wppa_photo_shortcodes( array( 0 => $id ) );
755
+ echo $result;
756
+ wppa_exit();
757
+ break;
758
+
759
  case 'bumpviewcount':
760
  $nonce = $_REQUEST['wppa-nonce'];
761
  if ( wp_verify_nonce( $nonce, 'wppa-check' ) ) {
880
  if ( $mylast ) {
881
 
882
  // Remove my like
883
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_rating WHERE `photo` = %s AND `user` = %s", $photo, $user ) );
884
  $myavgrat = '0';
885
  }
886
  else {
1036
  // Compute rating_count and store in the photo info
1037
  $ratcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_RATING."` WHERE `photo` = %s", $photo ) );
1038
  if ( $ratcount !== false ) {
1039
+ $iret = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `rating_count` = %s WHERE `id` = %s", $ratcount, $photo ) );
1040
  if ( $iret === false ) {
1041
  echo '0||107||'.$wartxt;
1042
  wppa_exit(); // Fail on save
1348
  case 'hour':
1349
  case 'min':
1350
  $itemname = __( 'Schedule date/time' , 'wp-photo-album-plus');
1351
+ $scheduledtm = $wpdb->get_var( $wpdb->prepare( "SELECT `scheduledtm` FROM$wpdb->wppa_albums WHERE `id` = %s", $album ) );
1352
  if ( ! $scheduledtm ) {
1353
  $scheduledtm = wppa_get_default_scheduledtm();
1354
  }
1365
  break;
1366
 
1367
  case 'setallscheduled':
1368
+ $scheduledtm = $wpdb->get_var( $wpdb->prepare( "SELECT `scheduledtm` FROM $wpdb->wppa_albums WHERE `id` = %s", $album ) );
1369
  if ( $scheduledtm ) {
1370
+ $iret = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `status` = 'scheduled', `scheduledtm` = %s WHERE `album` = %s", $scheduledtm, $album ) );
1371
  echo '||0||'.__( 'All photos set to scheduled per date', 'wp-photo-album-plus' ) . ' ' . wppa_format_scheduledtm( $scheduledtm );
1372
  }
1373
  wppa_exit();
2060
  case 'hour':
2061
  case 'min':
2062
  $itemname = __( 'Schedule date/time' , 'wp-photo-album-plus');
2063
+ $scheduledtm = $wpdb->get_var( $wpdb->prepare( "SELECT `scheduledtm` FROM$wpdb->wppa_photos WHERE `id` = %s", $photo ) );
2064
  if ( ! $scheduledtm ) {
2065
  $scheduledtm = wppa_get_default_scheduledtm();
2066
  }
2072
  if ( $item == 'min' ) $temp[4] = $value;
2073
  $scheduledtm = implode( ',', $temp );
2074
  wppa_update_photo( array( 'id' => $photo, 'scheduledtm' => $scheduledtm, 'status' => 'scheduled' ) );
2075
+ wppa_invalidate_treecounts( $wpdb->get_var( $wpdb->prepare( "SELECT `album` FROM $wpdb->wppa_photos WHERE `id` = %s", $photo ) ) );
2076
  wppa_flush_upldr_cache( 'photoid', $photo );
2077
  if ( wppa_is_video( $photo ) ) {
2078
  echo '||0||'.sprintf( __( '%s of video %s updated' , 'wp-photo-album-plus'), $itemname, $photo );
2088
  case 'delhour':
2089
  case 'delmin':
2090
  $itemname = __( 'Delete date/time' , 'wp-photo-album-plus');
2091
+ $scheduledel = $wpdb->get_var( $wpdb->prepare( "SELECT `scheduledel` FROM $wpdb->wppa_photos WHERE `id` = %s", $photo ) );
2092
  if ( ! $scheduledel ) {
2093
  $scheduledel = wppa_get_default_scheduledtm();
2094
  }
2102
  wppa_update_photo( array( 'id' => $photo, 'scheduledel' => $scheduledel ) );
2103
 
2104
  // Make sure not deleted yet
2105
+ $alb = $wpdb->get_var( $wpdb->prepare( "SELECT `album` FROM $wpdb->wppa_photos WHERE `id` = %s", $photo ) );
2106
  if ( $alb < '-9' ) {
2107
  $alb = - ( $alb + '9' );
2108
  wppa_update_photo( array( 'id' => $photo, 'album' => $alb ) );
2651
  }
2652
  break;
2653
  case 'wppa_viewcount_clear':
2654
+ $iret = $wpdb->query( "UPDATE $wpdb->wppa_photos SET `views` = '0'" ) &&
2655
+ $wpdb->query( "UPDATE $wpdb->wppa_albums SET `views` = '0'" );
2656
  if ( $iret !== false ) {
2657
  $title = __( 'Viewcounts cleared' , 'wp-photo-album-plus');
2658
  }
2990
  case 'wppa_search_tags':
2991
  case 'wppa_search_cats':
2992
  case 'wppa_search_comments':
2993
+ $wpdb->query( "UPDATE $wpdb->wppa_photos SET `indexdtm` = ''" );
2994
  wppa_schedule_maintenance_proc( 'wppa_remake_index_photos' );
2995
+ $wpdb->query( "UPDATE $wpdb->wppa_albums SET `indexdtm` = ''" );
2996
  wppa_schedule_maintenance_proc( 'wppa_remake_index_albums' );
2997
  break;
2998
 
3001
  $value = trim ( $value );
3002
  $user = wppa_get_user_by ( 'login', $value ); // seems to be case insensitive
3003
  if ( $user && $user->user_login === $value ) {
3004
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `status` = 'pending' WHERE `owner` = %s", $value ) );
3005
  $black_listed_users = get_option( 'wppa_black_listed_users', array() );
3006
  if ( ! in_array( $value, $black_listed_users ) ) {
3007
  $black_listed_users[] = $value;
3016
  break;
3017
 
3018
  case 'wppa_un_blacklist_user':
3019
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `status` = 'publish' WHERE `owner` = %s", $value ) );
3020
  $black_listed_users = get_option( 'wppa_black_listed_users', array() );
3021
  if ( in_array( $value, $black_listed_users ) ) {
3022
  foreach ( array_keys( $black_listed_users ) as $usr ) {
3155
 
3156
  case 'wppa_use_encrypted_links':
3157
  if ( $value == 'yes' ) {
3158
+ $ca = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE `crypt` = ''" );
3159
+ $cp = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `crypt` = ''" );
3160
  if ( $ca + $cp ) {
3161
  if ( $ca ) update_option ( 'wppa_crypt_albums_status', 'Required' );
3162
  if ( $cp ) update_option ( 'wppa_crypt_photos_status', 'Required' );
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.8.09
7
  *
8
  */
9
 
@@ -25,7 +25,7 @@ function _wppa_admin() {
25
  ';
26
 
27
  // Delete trashed comments
28
- $query = "DELETE FROM " . WPPA_COMMENTS . " WHERE status='trash'";
29
  $wpdb->query($query);
30
 
31
  $sel = 'selected="selected"';
@@ -36,7 +36,7 @@ function _wppa_admin() {
36
  }
37
 
38
  // Fix orphan albums and deleted target pages
39
- $albs = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "`", ARRAY_A);
40
 
41
  // Now we have them, put them in cache
42
  wppa_cache_album( 'add', $albs );
@@ -44,12 +44,12 @@ function _wppa_admin() {
44
  if ( $albs ) {
45
  foreach ($albs as $alb) {
46
  if ( $alb['a_parent'] > '0' && wppa_get_parentalbumid($alb['a_parent']) <= '-9' ) { // Parent died?
47
- $wpdb->query("UPDATE `".WPPA_ALBUMS."` SET `a_parent` = '-1' WHERE `id` = '".$alb['id']."'");
48
  }
49
  if ( $alb['cover_linkpage'] > '0' ) {
50
  $iret = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `".$wpdb->posts."` WHERE `ID` = %s AND `post_type` = 'page' AND `post_status` = 'publish'", $alb['cover_linkpage']));
51
  if ( ! $iret ) { // Page gone?
52
- $wpdb->query("UPDATE `".WPPA_ALBUMS."` SET `cover_linkpage` = '0' WHERE `id` = '".$alb['id']."'");
53
  }
54
  }
55
  }
@@ -140,13 +140,13 @@ function _wppa_admin() {
140
  }
141
  $name = wppa_get_album_name($parent).'-#'.$id;
142
  if ( ! current_user_can('administrator') ) { // someone creating an album for someone else?
143
- $parentowner = $wpdb->get_var($wpdb->prepare("SELECT `owner` FROM `".WPPA_ALBUMS."` WHERE `id` = %s", $parent));
144
  if ( $parentowner !== wppa_get_user() ) wp_die('You are not allowed to create an album for someone else');
145
  }
146
  }
147
  else {
148
  $parent = wppa_opt( 'default_parent' );
149
- if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $parent ) ) ) { // Deafault parent vanished
150
  wppa_update_option( 'wppa_default_parent', '0' );
151
  $parent = '0';
152
  }
@@ -171,7 +171,7 @@ function _wppa_admin() {
171
  $edit_id = $_REQUEST['edit_id'];
172
  }
173
 
174
- $album_owner = $wpdb->get_var($wpdb->prepare("SELECT `owner` FROM ".WPPA_ALBUMS." WHERE `id` = %s", $edit_id));
175
  if ( ( $album_owner == '--- public ---' && ! current_user_can('wppa_admin') ) || ! wppa_have_access($edit_id) ) {
176
  wp_die('You do not have the rights to edit this album');
177
  }
@@ -179,7 +179,7 @@ function _wppa_admin() {
179
  // Apply new desc
180
  if ( isset($_REQUEST['applynewdesc']) ) {
181
  if ( ! wp_verify_nonce($_REQUEST['wppa_nonce'], 'wppa_nonce') ) wp_die('You do not have the rights to do this');
182
- $iret = $wpdb->query($wpdb->prepare("UPDATE `".WPPA_PHOTOS."` SET `description` = %s WHERE `album` = %s", wppa_opt( 'newphoto_description' ), $edit_id));
183
  wppa_ok_message($iret.' descriptions updated.');
184
  }
185
 
@@ -204,7 +204,7 @@ function _wppa_admin() {
204
  }
205
 
206
  // Get the album information
207
- $albuminfo = $wpdb->get_row($wpdb->prepare('SELECT * FROM `'.WPPA_ALBUMS.'` WHERE `id` = %s', $edit_id), ARRAY_A);
208
 
209
  // We may not use extract(), so we do something like it here manually, hence controlled.
210
  $id = $albuminfo['id'];
@@ -380,7 +380,7 @@ function wppaTryScheduleAll( id ) {
380
 
381
  // Clicks
382
  if ( wppa_switch( 'track_clickcounts' ) ) {
383
- $click_arr = $wpdb->get_col( "SELECT `clicks` FROM `" . WPPA_PHOTOS . "` WHERE `album` = $id" );
384
  echo
385
  __( 'Clicks:', 'wp-photo-album-plus' ) . ' ' . array_sum( $click_arr ) . '. ';
386
  }
@@ -1206,7 +1206,7 @@ function wppaTryScheduleAll( id ) {
1206
  // album delete confirm page
1207
  else if ($_REQUEST['tab'] == 'del') {
1208
 
1209
- $album_owner = $wpdb->get_var($wpdb->prepare("SELECT `owner` FROM ".WPPA_ALBUMS." WHERE `id` = %s", $_REQUEST['edit_id']));
1210
  if ( ( $album_owner == '--- public ---' && ! current_user_can('administrator') ) || ! wppa_have_access($_REQUEST['edit_id']) ) {
1211
  wp_die('You do not have the rights to delete this album');
1212
  }
@@ -1258,7 +1258,7 @@ function wppaTryScheduleAll( id ) {
1258
  if (isset($_POST['wppa-del-confirm'])) {
1259
  check_admin_referer( '$wppa_nonce', WPPA_NONCE );
1260
 
1261
- $album_owner = $wpdb->get_var($wpdb->prepare("SELECT `owner` FROM ".WPPA_ALBUMS." WHERE `id` = %s", $_POST['wppa-del-id']));
1262
  if ( ( $album_owner == '--- public ---' && ! current_user_can('administrator') ) || ! wppa_have_access($_POST['wppa-del-id']) ) {
1263
  wp_die('You do not have the rights to delete this album');
1264
  }
@@ -1372,7 +1372,7 @@ global $wpdb;
1372
  }
1373
 
1374
  // Read all albums, pre-ordered
1375
- $albums = $wpdb->get_results( "SELECT * FROM `" . WPPA_ALBUMS . "` ORDER BY " . get_option( 'wppa_album_order_'.wppa_get_user(), 'id' ) . ( get_option( 'wppa_album_order_' . wppa_get_user() . '_reverse' ) == 'yes' ? " DESC" : "" ) , ARRAY_A );
1376
 
1377
  // Remove non accessible albums
1378
  $temp = $albums;
@@ -1566,7 +1566,7 @@ global $wpdb;
1566
  if ( wppa_have_access( $album ) && ( wppa_user_is( 'administrator' ) || $album['owner'] != '--- public ---' ) ) {
1567
  $counts = wppa_get_treecounts_a($album['id'], true);
1568
  $pendcount = $counts['pendselfphotos'];
1569
- // $pendcount = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE album=%s AND status=%s", $album['id'], 'pending'));
1570
  ?>
1571
  <tr <?php echo($alt); if ($pendcount) echo 'style="background-color:#ffdddd"' ?>>
1572
  <td><?php echo($album['id']) ?></td>
@@ -1740,7 +1740,7 @@ global $wpdb;
1740
  }
1741
 
1742
  // Read all albums, pre-ordered
1743
- $albums = $wpdb->get_results( "SELECT * FROM `" . WPPA_ALBUMS . "` ORDER BY " . get_option( 'wppa_album_order_'.wppa_get_user(), 'id' ) . ( get_option( 'wppa_album_order_' . wppa_get_user() . '_reverse' ) == 'yes' ? " DESC" : "" ) , ARRAY_A );
1744
 
1745
  // Remove non accessible albums
1746
  $temp = $albums;
@@ -1784,7 +1784,7 @@ global $wpdb;
1784
  $done = false;
1785
 
1786
  // Add missing parent
1787
- $albums[] = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" .WPPA_ALBUMS . "` WHERE `id` = %d", $parent ), ARRAY_A );
1788
  }
1789
  }
1790
  }
@@ -1953,7 +1953,7 @@ global $wpdb;
1953
  <tbody>
1954
 
1955
  <?php wppa_do_albumlist('0', '0', $albums, $seq); ?>
1956
- <?php if ( $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_ALBUMS."` WHERE `a_parent` = '-1'" ) > 0 ) { ?>
1957
  <tr>
1958
  <td colspan="<?php echo ( '19' + ( current_user_can( 'wppa_upload' ) ? '1' : '0' ) + ( current_user_can( 'wppa_import' ) ? '1' : '0' ) ) ?>" >
1959
  <em>
@@ -2160,7 +2160,7 @@ global $wpdb;
2160
  $doit = false;
2161
  if ( wppa_user_is( 'administrator' ) ) $doit = true;
2162
 
2163
- $trashed = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `album` < '0'" );
2164
 
2165
  if ( ! $trashed ) $doit = false;
2166
 
@@ -2370,11 +2370,11 @@ global $wpdb;
2370
  function wppa_have_accessible_children( $alb ) {
2371
  global $wpdb;
2372
 
2373
- $albums = $wpdb->get_results( "SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = " . $alb['id'], ARRAY_A );
2374
 
2375
- if ( ! $albums || ! count($albums) ) return false;
2376
  foreach ( $albums as $album ) {
2377
- if ( wppa_have_access($album) ) return true;
2378
  }
2379
  return false;
2380
  }
@@ -2393,11 +2393,11 @@ global $wpdb;
2393
  }
2394
 
2395
  // Photos in the album
2396
- $photos = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `album` = %s', $id ), ARRAY_A );
2397
 
2398
  if ( is_array( $photos ) ) {
2399
  foreach ( $photos as $photo ) {
2400
- $wpdb->query( $wpdb->prepare( 'UPDATE `' . WPPA_PHOTOS . '` SET `album` = %s WHERE `id` = %s', $move, $photo['id'] ) );
2401
 
2402
  // Move to trash?
2403
  if ( $move > '0' ) {
@@ -2419,7 +2419,7 @@ global $wpdb;
2419
  wppa_invalidate_treecounts( $id );
2420
 
2421
  // Now delete the album
2422
- $wpdb->query( $wpdb->prepare( 'DELETE FROM `' . WPPA_ALBUMS . '` WHERE `id` = %s LIMIT 1', $id ) );
2423
  wppa_delete_album_source( $id );
2424
  wppa_index_remove( 'album', $id );
2425
  wppa_clear_catlist();
@@ -2439,7 +2439,7 @@ function wppa_main_photo($cur = '', $covertype) {
2439
  global $wpdb;
2440
 
2441
  $a_id = $_REQUEST['edit_id'];
2442
- $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `'.WPPA_PHOTOS.'` WHERE `album` = %s '.wppa_get_photo_order($a_id).' LIMIT 1000', $a_id), ARRAY_A);
2443
 
2444
  $output = '';
2445
  // if ( ! empty($photos) ) {
@@ -2499,7 +2499,7 @@ global $wpdb;
2499
  // Get the albums
2500
  $albumorder = wppa_get_album_order( $parent );
2501
  $is_descending = strpos( $albumorder, 'DESC' ) !== false;
2502
- $albums = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM `'.WPPA_ALBUMS.'` WHERE `a_parent` = %s '.$albumorder, $parent ), ARRAY_A );
2503
 
2504
  // Anything to do here ?
2505
  if ( empty ( $albums ) ) {
3
  * Package: wp-photo-album-plus
4
  *
5
  * create, edit and delete albums
6
+ * Version 6.9.14
7
  *
8
  */
9
 
25
  ';
26
 
27
  // Delete trashed comments
28
+ $query = "DELETE FROM `" . WPPA_COMMENTS . "` WHERE status='trash'";
29
  $wpdb->query($query);
30
 
31
  $sel = 'selected="selected"';
36
  }
37
 
38
  // Fix orphan albums and deleted target pages
39
+ $albs = $wpdb->get_results("SELECT * FROM $wpdb->wppa_albums", ARRAY_A);
40
 
41
  // Now we have them, put them in cache
42
  wppa_cache_album( 'add', $albs );
44
  if ( $albs ) {
45
  foreach ($albs as $alb) {
46
  if ( $alb['a_parent'] > '0' && wppa_get_parentalbumid($alb['a_parent']) <= '-9' ) { // Parent died?
47
+ $wpdb->query("UPDATE $wpdb->wppa_albums SET `a_parent` = '-1' WHERE `id` = '".$alb['id']."'");
48
  }
49
  if ( $alb['cover_linkpage'] > '0' ) {
50
  $iret = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `".$wpdb->posts."` WHERE `ID` = %s AND `post_type` = 'page' AND `post_status` = 'publish'", $alb['cover_linkpage']));
51
  if ( ! $iret ) { // Page gone?
52
+ $wpdb->query("UPDATE $wpdb->wppa_albums SET `cover_linkpage` = '0' WHERE `id` = '".$alb['id']."'");
53
  }
54
  }
55
  }
140
  }
141
  $name = wppa_get_album_name($parent).'-#'.$id;
142
  if ( ! current_user_can('administrator') ) { // someone creating an album for someone else?
143
+ $parentowner = $wpdb->get_var($wpdb->prepare("SELECT `owner` FROM $wpdb->wppa_albums WHERE `id` = %s", $parent));
144
  if ( $parentowner !== wppa_get_user() ) wp_die('You are not allowed to create an album for someone else');
145
  }
146
  }
147
  else {
148
  $parent = wppa_opt( 'default_parent' );
149
+ if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE `id` = %s", $parent ) ) ) { // Deafault parent vanished
150
  wppa_update_option( 'wppa_default_parent', '0' );
151
  $parent = '0';
152
  }
171
  $edit_id = $_REQUEST['edit_id'];
172
  }
173
 
174
+ $album_owner = $wpdb->get_var($wpdb->prepare("SELECT `owner` FROM " . WPPA_ALBUMS . " WHERE `id` = %s", $edit_id));
175
  if ( ( $album_owner == '--- public ---' && ! current_user_can('wppa_admin') ) || ! wppa_have_access($edit_id) ) {
176
  wp_die('You do not have the rights to edit this album');
177
  }
179
  // Apply new desc
180
  if ( isset($_REQUEST['applynewdesc']) ) {
181
  if ( ! wp_verify_nonce($_REQUEST['wppa_nonce'], 'wppa_nonce') ) wp_die('You do not have the rights to do this');
182
+ $iret = $wpdb->query($wpdb->prepare("UPDATE $wpdb->wppa_photos SET `description` = %s WHERE `album` = %s", wppa_opt( 'newphoto_description' ), $edit_id));
183
  wppa_ok_message($iret.' descriptions updated.');
184
  }
185
 
204
  }
205
 
206
  // Get the album information
207
+ $albuminfo = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `id` = %s", $edit_id ), ARRAY_A );
208
 
209
  // We may not use extract(), so we do something like it here manually, hence controlled.
210
  $id = $albuminfo['id'];
380
 
381
  // Clicks
382
  if ( wppa_switch( 'track_clickcounts' ) ) {
383
+ $click_arr = $wpdb->get_col( "SELECT `clicks` FROM $wpdb->wppa_photos WHERE `album` = $id" );
384
  echo
385
  __( 'Clicks:', 'wp-photo-album-plus' ) . ' ' . array_sum( $click_arr ) . '. ';
386
  }
1206
  // album delete confirm page
1207
  else if ($_REQUEST['tab'] == 'del') {
1208
 
1209
+ $album_owner = $wpdb->get_var($wpdb->prepare( "SELECT `owner` FROM $wpdb->wppa_albums WHERE `id` = %s", $_REQUEST['edit_id']));
1210
  if ( ( $album_owner == '--- public ---' && ! current_user_can('administrator') ) || ! wppa_have_access($_REQUEST['edit_id']) ) {
1211
  wp_die('You do not have the rights to delete this album');
1212
  }
1258
  if (isset($_POST['wppa-del-confirm'])) {
1259
  check_admin_referer( '$wppa_nonce', WPPA_NONCE );
1260
 
1261
+ $album_owner = $wpdb->get_var($wpdb->prepare("SELECT `owner` FROM $wpdb->wppa_albums WHERE `id` = %s", $_POST['wppa-del-id']));
1262
  if ( ( $album_owner == '--- public ---' && ! current_user_can('administrator') ) || ! wppa_have_access($_POST['wppa-del-id']) ) {
1263
  wp_die('You do not have the rights to delete this album');
1264
  }
1372
  }
1373
 
1374
  // Read all albums, pre-ordered
1375
+ $albums = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums ORDER BY " . get_option( 'wppa_album_order_'.wppa_get_user(), 'id' ) . ( get_option( 'wppa_album_order_' . wppa_get_user() . '_reverse' ) == 'yes' ? " DESC" : "" ) , ARRAY_A );
1376
 
1377
  // Remove non accessible albums
1378
  $temp = $albums;
1566
  if ( wppa_have_access( $album ) && ( wppa_user_is( 'administrator' ) || $album['owner'] != '--- public ---' ) ) {
1567
  $counts = wppa_get_treecounts_a($album['id'], true);
1568
  $pendcount = $counts['pendselfphotos'];
1569
+ // $pendcount = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE album=%s AND status=%s", $album['id'], 'pending'));
1570
  ?>
1571
  <tr <?php echo($alt); if ($pendcount) echo 'style="background-color:#ffdddd"' ?>>
1572
  <td><?php echo($album['id']) ?></td>
1740
  }
1741
 
1742
  // Read all albums, pre-ordered
1743
+ $albums = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums ORDER BY " . get_option( 'wppa_album_order_'.wppa_get_user(), 'id' ) . ( get_option( 'wppa_album_order_' . wppa_get_user() . '_reverse' ) == 'yes' ? " DESC" : "" ) , ARRAY_A );
1744
 
1745
  // Remove non accessible albums
1746
  $temp = $albums;
1784
  $done = false;
1785
 
1786
  // Add missing parent
1787
+ $albums[] = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `id` = %d", $parent ), ARRAY_A );
1788
  }
1789
  }
1790
  }
1953
  <tbody>
1954
 
1955
  <?php wppa_do_albumlist('0', '0', $albums, $seq); ?>
1956
+ <?php if ( $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE `a_parent` = '-1'" ) > 0 ) { ?>
1957
  <tr>
1958
  <td colspan="<?php echo ( '19' + ( current_user_can( 'wppa_upload' ) ? '1' : '0' ) + ( current_user_can( 'wppa_import' ) ? '1' : '0' ) ) ?>" >
1959
  <em>
2160
  $doit = false;
2161
  if ( wppa_user_is( 'administrator' ) ) $doit = true;
2162
 
2163
+ $trashed = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `album` < '0'" );
2164
 
2165
  if ( ! $trashed ) $doit = false;
2166
 
2370
  function wppa_have_accessible_children( $alb ) {
2371
  global $wpdb;
2372
 
2373
+ $albums = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `a_parent` = %d", $alb['id'] ), ARRAY_A );
2374
 
2375
+ if ( ! $albums || ! count( $albums ) ) return false;
2376
  foreach ( $albums as $album ) {
2377
+ if ( wppa_have_access( $album ) ) return true;
2378
  }
2379
  return false;
2380
  }
2393
  }
2394
 
2395
  // Photos in the album
2396
+ $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `album` = %s", $id ), ARRAY_A );
2397
 
2398
  if ( is_array( $photos ) ) {
2399
  foreach ( $photos as $photo ) {
2400
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `album` = %s WHERE `id` = %s", $move, $photo['id'] ) );
2401
 
2402
  // Move to trash?
2403
  if ( $move > '0' ) {
2419
  wppa_invalidate_treecounts( $id );
2420
 
2421
  // Now delete the album
2422
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_albums WHERE `id` = %s LIMIT 1", $id ) );
2423
  wppa_delete_album_source( $id );
2424
  wppa_index_remove( 'album', $id );
2425
  wppa_clear_catlist();
2439
  global $wpdb;
2440
 
2441
  $a_id = $_REQUEST['edit_id'];
2442
+ $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 );
2443
 
2444
  $output = '';
2445
  // if ( ! empty($photos) ) {
2499
  // Get the albums
2500
  $albumorder = wppa_get_album_order( $parent );
2501
  $is_descending = strpos( $albumorder, 'DESC' ) !== false;
2502
+ $albums = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `a_parent` = %s " . $albumorder, $parent ), ARRAY_A );
2503
 
2504
  // Anything to do here ?
2505
  if ( empty ( $albums ) ) {
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.09
7
  *
8
  */
9
 
@@ -78,7 +78,7 @@ global $wpdb;
78
  // Find album details
79
  $coverphoto = wppa_get_coverphoto_id( $albumid );
80
  // $query = $wpdb->prepare( "SELECT * " .
81
- // "FROM `" . WPPA_PHOTOS . "` " .
82
  // "WHERE `id` = %s",
83
  // $coverphoto
84
  // );
@@ -431,7 +431,7 @@ global $wpdb;
431
  // Find the coverphotos details
432
  foreach ( $coverphotos as $coverphoto ) {
433
  // $query = $wpdb->prepare( "SELECT * " .
434
- // "FROM `" . WPPA_PHOTOS . "` " .
435
  // "WHERE `id` = %s",
436
  // $coverphoto
437
  // );
@@ -616,7 +616,7 @@ global $wpdb;
616
 
617
  $coverphoto = wppa_get_coverphoto_id( $albumid );
618
  $image = wppa_cache_thumb( $coverphoto ); //$wpdb->get_row( $wpdb->prepare(
619
- // "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `id` = %s", $coverphoto
620
  // ), ARRAY_A );
621
  $photocount = wppa_get_photo_count( $albumid );
622
  $albumcount = wppa_get_album_count( $albumid, true );
@@ -886,7 +886,7 @@ global $wpdb;
886
  // If lightbox, we need all the album photos to set up a lightbox set
887
  if ( $photolink['is_lightbox'] ) {
888
  $thumbs = $wpdb->get_results( $wpdb->prepare(
889
- "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s " .
890
  wppa_get_photo_order( $albumid ), $albumid
891
  ), ARRAY_A );
892
 
@@ -1289,13 +1289,13 @@ static $cached_cover_photo_ids;
1289
  if ( '0' == $id ) {
1290
  if ( current_user_can( 'wppa_moderate' ) ) {
1291
  $temp = $wpdb->get_results( $wpdb->prepare(
1292
- "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s ORDER BY RAND( " . wppa_get_randseed( 'page' ) . " ) LIMIT %d",
1293
- $alb, $count ), ARRAY_A );
1294
  }
1295
  else {
1296
  $temp = $wpdb->get_results( $wpdb->prepare(
1297
- "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) ORDER BY RAND( " . wppa_get_randseed( 'page' ) . " ) LIMIT %d",
1298
- $alb, wppa_get_user(), $count ), ARRAY_A );
1299
  }
1300
  }
1301
 
@@ -1327,7 +1327,7 @@ static $cached_cover_photo_ids;
1327
  if ( '-3' == $id ) {
1328
  $allalb = wppa_expand_enum( wppa_alb_to_enum_children( $alb ) );
1329
  $temp = $wpdb->get_results( $wpdb->prepare(
1330
- "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1331
  "WHERE `album` IN ( " . str_replace( '.', ',', $allalb ) . " ) " .
1332
  "AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) " .
1333
  "ORDER BY RAND( " . wppa_get_randseed( 'page' ) . " ) LIMIT %d", wppa_get_user(), $count ), ARRAY_A );
@@ -1337,7 +1337,7 @@ static $cached_cover_photo_ids;
1337
  if ( '-4' == $id ) {
1338
  $allalb = wppa_expand_enum( wppa_alb_to_enum_children( $alb ) );
1339
  $temp = $wpdb->get_results( $wpdb->prepare(
1340
- "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1341
  "WHERE `album` IN ( " . str_replace( '.', ',', $allalb ) . " ) " .
1342
  "AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) " .
1343
  "ORDER BY `timestamp` DESC LIMIT %d", wppa_get_user(), $count ), ARRAY_A );
@@ -1686,7 +1686,7 @@ global $wpdb;
1686
  $first = true;
1687
 
1688
  // Get the children
1689
- $subs = $wpdb->get_results( "SELECT * FROM `".WPPA_ALBUMS."` WHERE `a_parent` = " . $id . " " . wppa_get_album_order( $id ), ARRAY_A );
1690
 
1691
  // Only if there are sub-albums
1692
  if ( ! empty( $subs ) ) {
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for album covers
6
+ * Version 6.9.14
7
  *
8
  */
9
 
78
  // Find album details
79
  $coverphoto = wppa_get_coverphoto_id( $albumid );
80
  // $query = $wpdb->prepare( "SELECT * " .
81
+ // "FROM $wpdb->wppa_photos " .
82
  // "WHERE `id` = %s",
83
  // $coverphoto
84
  // );
431
  // Find the coverphotos details
432
  foreach ( $coverphotos as $coverphoto ) {
433
  // $query = $wpdb->prepare( "SELECT * " .
434
+ // "FROM $wpdb->wppa_photos " .
435
  // "WHERE `id` = %s",
436
  // $coverphoto
437
  // );
616
 
617
  $coverphoto = wppa_get_coverphoto_id( $albumid );
618
  $image = wppa_cache_thumb( $coverphoto ); //$wpdb->get_row( $wpdb->prepare(
619
+ // "SELECT * FROM $wpdb->wppa_photos WHERE `id` = %s", $coverphoto
620
  // ), ARRAY_A );
621
  $photocount = wppa_get_photo_count( $albumid );
622
  $albumcount = wppa_get_album_count( $albumid, true );
886
  // If lightbox, we need all the album photos to set up a lightbox set
887
  if ( $photolink['is_lightbox'] ) {
888
  $thumbs = $wpdb->get_results( $wpdb->prepare(
889
+ "SELECT * FROM $wpdb->wppa_photos WHERE `album` = %s " .
890
  wppa_get_photo_order( $albumid ), $albumid
891
  ), ARRAY_A );
892
 
1289
  if ( '0' == $id ) {
1290
  if ( current_user_can( 'wppa_moderate' ) ) {
1291
  $temp = $wpdb->get_results( $wpdb->prepare(
1292
+ "SELECT * FROM $wpdb->wppa_photos WHERE `album` = %s ORDER BY RAND( %d ) LIMIT %d",
1293
+ $alb, wppa_get_randseed( 'page' ), $count ), ARRAY_A );
1294
  }
1295
  else {
1296
  $temp = $wpdb->get_results( $wpdb->prepare(
1297
+ "SELECT * FROM $wpdb->wppa_photos WHERE `album` = %s AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) ORDER BY RAND( %d ) LIMIT %d",
1298
+ $alb, wppa_get_randseed( 'page' ), wppa_get_user(), $count ), ARRAY_A );
1299
  }
1300
  }
1301
 
1327
  if ( '-3' == $id ) {
1328
  $allalb = wppa_expand_enum( wppa_alb_to_enum_children( $alb ) );
1329
  $temp = $wpdb->get_results( $wpdb->prepare(
1330
+ "SELECT * FROM $wpdb->wppa_photos " .
1331
  "WHERE `album` IN ( " . str_replace( '.', ',', $allalb ) . " ) " .
1332
  "AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) " .
1333
  "ORDER BY RAND( " . wppa_get_randseed( 'page' ) . " ) LIMIT %d", wppa_get_user(), $count ), ARRAY_A );
1337
  if ( '-4' == $id ) {
1338
  $allalb = wppa_expand_enum( wppa_alb_to_enum_children( $alb ) );
1339
  $temp = $wpdb->get_results( $wpdb->prepare(
1340
+ "SELECT * FROM $wpdb->wppa_photos " .
1341
  "WHERE `album` IN ( " . str_replace( '.', ',', $allalb ) . " ) " .
1342
  "AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) " .
1343
  "ORDER BY `timestamp` DESC LIMIT %d", wppa_get_user(), $count ), ARRAY_A );
1686
  $first = true;
1687
 
1688
  // Get the children
1689
+ $subs = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums WHERE `a_parent` = " . $id . " " . wppa_get_album_order( $id ), ARRAY_A );
1690
 
1691
  // Only if there are sub-albums
1692
  if ( ! empty( $subs ) ) {
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.12
7
  */
8
 
9
  class AlbumNavigatorWidget extends WP_Widget {
@@ -146,7 +146,7 @@ class AlbumNavigatorWidget extends WP_Widget {
146
  false,
147
  false,
148
  );
149
- $albs = $wpdb->get_results( "SELECT `name`, `id` FROM `" . 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 `".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.14
7
  */
8
 
9
  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
  $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.12
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
@@ -170,7 +170,7 @@ class AlbumWidget extends WP_Widget {
170
  $widget_content .= "\n\t".'</a>';
171
  }
172
  elseif ( $link['is_lightbox'] ) {
173
- $thumbs = $wpdb->get_results($wpdb->prepare("SELECT * FROM `".WPPA_PHOTOS."` WHERE `album` = %s ".wppa_get_photo_order($album['id']), $album['id']), 'ARRAY_A');
174
  if ( $thumbs ) foreach ( $thumbs as $thumb ) {
175
  $title = wppa_get_lbtitle('alw', $thumb['id']);
176
  if ( wppa_is_video( $thumb['id'] ) ) {
@@ -358,7 +358,7 @@ class AlbumWidget extends WP_Widget {
358
  wppa_widget_input( $this, 'title', $instance['title'], __( 'Title', 'wp-photo-album-plus' ) );
359
 
360
  // Parent album selection
361
- $albs = $wpdb->get_results( "SELECT `id`, `name` FROM `" . WPPA_ALBUMS . "` ORDER BY `name`", ARRAY_A );
362
 
363
  $options = array(
364
  __( '--- all albums ---', 'wp-photo-album-plus' ),
3
  * Package: wp-photo-album-plus
4
  *
5
  * display thumbnail albums
6
+ * Version 6.9.14
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
170
  $widget_content .= "\n\t".'</a>';
171
  }
172
  elseif ( $link['is_lightbox'] ) {
173
+ $thumbs = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->wppa_photos WHERE `album` = %s ".wppa_get_photo_order($album['id']), $album['id']), 'ARRAY_A');
174
  if ( $thumbs ) foreach ( $thumbs as $thumb ) {
175
  $title = wppa_get_lbtitle('alw', $thumb['id']);
176
  if ( wppa_is_video( $thumb['id'] ) ) {
358
  wppa_widget_input( $this, 'title', $instance['title'], __( 'Title', 'wp-photo-album-plus' ) );
359
 
360
  // Parent album selection
361
+ $albs = $wpdb->get_results( "SELECT `id`, `name` FROM $wpdb->wppa_albums ORDER BY `name`", ARRAY_A );
362
 
363
  $options = array(
364
  __( '--- 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.09
7
  *
8
  */
9
 
@@ -431,7 +431,7 @@ global $wppa_supported_camara_brands;
431
  );
432
  $pagelink = wppa_dbg_url( get_page_link( $page ) );
433
  $fontsize = wppa_in_widget() ? 'font-size: 9px;' : '';
434
- $query = "SELECT `id`, `name`, `owner` FROM `" . WPPA_ALBUMS . "` ORDER BY `name`";
435
  $albums = $wpdb->get_results( $query, ARRAY_A );
436
  $query = "SELECT `name` FROM `" . WPPA_PHOTOS .
437
  "` WHERE `status` <> 'pending' AND `status` <> 'scheduled' ORDER BY `name`";
@@ -487,7 +487,7 @@ global $wppa_supported_camara_brands;
487
  //echo serialize($exiflist);
488
  if ( ! empty( $exiflist ) ) {
489
  foreach( array_keys( $exiflist ) as $idx ) {
490
- // $exists = $wpdb->get_var( $wpdb->prepare( "SELECT * FROM `" . WPPA_EXIF . "` " .
491
  // "WHERE `photo` <> '0' " .
492
  // "AND `tag` = %s " .
493
  // "AND `description` <> '' LIMIT 1", $exiflist[$idx]['tag'] ) );
@@ -2397,7 +2397,7 @@ static $albums_granted;
2397
  // Login not required, but there are no public albums while user not logged in?
2398
  elseif ( ! is_user_logged_in() ) {
2399
  $public_exist = $wpdb->get_var( "SELECT COUNT(*) " .
2400
- "FROM `" . WPPA_ALBUMS . "` " .
2401
  "WHERE `owner` = '--- public ---' " );
2402
 
2403
  if ( ! $public_exist ) {
@@ -3888,7 +3888,7 @@ global $wppa_iptc_cache;
3888
 
3889
  // Get tha labels if not yet present
3890
  if ( ! is_array( $wppa_iptc_labels ) ) {
3891
- $wppa_iptc_labels = $wpdb->get_results( "SELECT * FROM `" . WPPA_IPTC . "` WHERE `photo` = '0' ORDER BY `tag`", ARRAY_A );
3892
  }
3893
 
3894
  $count = 0;
@@ -3903,7 +3903,7 @@ global $wppa_iptc_cache;
3903
 
3904
  // Get the photo data
3905
  if ( $iptcdata === false ) {
3906
- $iptcdata = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `" . WPPA_IPTC . "` WHERE `photo`=%s ORDER BY `tag`", $photo ), ARRAY_A );
3907
 
3908
  // Save in cache, even when empty
3909
  $wppa_iptc_cache[$photo] = $iptcdata;
@@ -4001,7 +4001,7 @@ global $wppa_exif_cache;
4001
 
4002
  // Get tha labels if not yet present
4003
  if ( ! is_array( $wppa_exif_labels ) ) {
4004
- $wppa_exif_labels = $wpdb->get_results( "SELECT * FROM `" . WPPA_EXIF . "` WHERE `photo` = '0' ORDER BY `tag`", ARRAY_A );
4005
  }
4006
 
4007
  $count = 0;
@@ -4203,7 +4203,7 @@ global $wpdb;
4203
  $photo = wppa( 'single_photo' );
4204
  $thumb = wppa_cache_thumb( $photo );
4205
  $album = $thumb['album'];
4206
- $photos = $wpdb->get_results( $wpdb->prepare( "SELECT `id`, `page_id` FROM `".WPPA_PHOTOS."` WHERE `album` = %s ".wppa_get_photo_order( $album ), $album ), ARRAY_A );
4207
  $prevpag = '0';
4208
  $nextpag = '0';
4209
  $curpag = get_the_ID();
@@ -4597,7 +4597,7 @@ global $wpdb;
4597
  switch ( $calendar_type ) {
4598
  case 'exifdtm':
4599
  $photos = $wpdb->get_results( "SELECT `id`, `exifdtm` " .
4600
- "FROM `" . WPPA_PHOTOS . "` " .
4601
  "WHERE `exifdtm` <> '' " .
4602
  "AND `status` <> 'pending' " .
4603
  "AND `status` <> 'scheduled' " .
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various wppa boxes
6
+ * Version 6.9.14
7
  *
8
  */
9
 
431
  );
432
  $pagelink = wppa_dbg_url( get_page_link( $page ) );
433
  $fontsize = wppa_in_widget() ? 'font-size: 9px;' : '';
434
+ $query = "SELECT `id`, `name`, `owner` FROM $wpdb->wppa_albums ORDER BY `name`";
435
  $albums = $wpdb->get_results( $query, ARRAY_A );
436
  $query = "SELECT `name` FROM `" . WPPA_PHOTOS .
437
  "` WHERE `status` <> 'pending' AND `status` <> 'scheduled' ORDER BY `name`";
487
  //echo serialize($exiflist);
488
  if ( ! empty( $exiflist ) ) {
489
  foreach( array_keys( $exiflist ) as $idx ) {
490
+ // $exists = $wpdb->get_var( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_exif " .
491
  // "WHERE `photo` <> '0' " .
492
  // "AND `tag` = %s " .
493
  // "AND `description` <> '' LIMIT 1", $exiflist[$idx]['tag'] ) );
2397
  // Login not required, but there are no public albums while user not logged in?
2398
  elseif ( ! is_user_logged_in() ) {
2399
  $public_exist = $wpdb->get_var( "SELECT COUNT(*) " .
2400
+ "FROM $wpdb->wppa_albums " .
2401
  "WHERE `owner` = '--- public ---' " );
2402
 
2403
  if ( ! $public_exist ) {
3888
 
3889
  // Get tha labels if not yet present
3890
  if ( ! is_array( $wppa_iptc_labels ) ) {
3891
+ $wppa_iptc_labels = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_iptc WHERE `photo` = '0' ORDER BY `tag`", ARRAY_A );
3892
  }
3893
 
3894
  $count = 0;
3903
 
3904
  // Get the photo data
3905
  if ( $iptcdata === false ) {
3906
+ $iptcdata = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_iptc WHERE `photo`=%s ORDER BY `tag`", $photo ), ARRAY_A );
3907
 
3908
  // Save in cache, even when empty
3909
  $wppa_iptc_cache[$photo] = $iptcdata;
4001
 
4002
  // Get tha labels if not yet present
4003
  if ( ! is_array( $wppa_exif_labels ) ) {
4004
+ $wppa_exif_labels = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_exif WHERE `photo` = '0' ORDER BY `tag`", ARRAY_A );
4005
  }
4006
 
4007
  $count = 0;
4203
  $photo = wppa( 'single_photo' );
4204
  $thumb = wppa_cache_thumb( $photo );
4205
  $album = $thumb['album'];
4206
+ $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 );
4207
  $prevpag = '0';
4208
  $nextpag = '0';
4209
  $curpag = get_the_ID();
4597
  switch ( $calendar_type ) {
4598
  case 'exifdtm':
4599
  $photos = $wpdb->get_results( "SELECT `id`, `exifdtm` " .
4600
+ "FROM $wpdb->wppa_photos " .
4601
  "WHERE `exifdtm` <> '' " .
4602
  "AND `status` <> 'pending' " .
4603
  "AND `status` <> 'scheduled' " .
wppa-breadcrumb.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for breadcrumbs
6
- * Version 6.9.06
7
  *
8
  */
9
 
@@ -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 `" . 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 `".WPPA_ALBUMS."` WHERE `id` = %s", $parent
694
  ) );
695
 
696
  $value = wppa_get_album_name( $parent );
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for breadcrumbs
6
+ * Version 6.9.14
7
  *
8
  */
9
 
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 );
wppa-cart.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains the interface to SCABN
6
- * Version 6.8.02
7
  *
8
  */
9
 
@@ -25,7 +25,7 @@ global $wppa_session;
25
  $thumb = wppa( 'current_photo' );
26
 
27
  extract( shortcode_atts( array(
28
- 'name' => wppa_get_photo_name( $thumb['id'] ),
29
  'price' => '0.01',
30
  'qty_field' => '',
31
  'b_title' => __('Buy now', 'wp-photo-album-plus'),
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains the interface to SCABN
6
+ * Version 6.9.14
7
  *
8
  */
9
 
25
  $thumb = wppa( 'current_photo' );
26
 
27
  extract( shortcode_atts( array(
28
+ 'name' => wppa_get_photo_name( strval( intval( $thumb['id'] ) ) ),
29
  'price' => '0.01',
30
  'qty_field' => '',
31
  'b_title' => __('Buy now', 'wp-photo-album-plus'),
wppa-comment-admin.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all comments
6
- * Version 6.9.02
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 `" . 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 `" . 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 `" . 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 `" . 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 `" . 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 `" . 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 `" . WPPA_COMMENTS . "` WHERE `id` = %s", $id ) );
274
  wppa_index_update( 'photo', $photo );
275
  }
276
  }
@@ -315,7 +315,7 @@ class WPPA_Comment_table extends WP_List_Table {
315
  }
316
  }
317
 
318
- $data = $wpdb->get_results( "SELECT * FROM `" . 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
@@ -403,22 +403,22 @@ function _wppa_comment_admin() {
403
  <tbody>
404
  <tr>
405
  <td style="margin:0; font-weight:bold; color:#777777;">' . __( 'Total:', 'wp-photo-album-plus' ) . '</td>
406
- <td style="margin:0; font-weight:bold;">' . $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "`" ) . '</td>
407
  <td></td>
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 `" . 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 `" . 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 `" . 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.14
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
  }
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
403
  <tbody>
404
  <tr>
405
  <td style="margin:0; font-weight:bold; color:#777777;">' . __( 'Total:', 'wp-photo-album-plus' ) . '</td>
406
+ <td style="margin:0; font-weight:bold;">' . $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_comments" ) . '</td>
407
  <td></td>
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.12
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 `" . 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.14
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.12
6
  *
7
  */
8
 
@@ -548,7 +548,7 @@ global $wpdb;
548
  if ( $name == '' ) return '';
549
  $name = stripslashes( $name );
550
 
551
- $albs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `name` = %s", $name ), ARRAY_A );
552
 
553
  if ( empty( $albs ) ) {
554
  return '';
@@ -667,18 +667,18 @@ global $current_user;
667
 
668
  // Administrator has always access OR If all albums are public
669
  if ( wppa_user_is( 'administrator' ) || ! wppa_switch( 'owner_only' ) ) {
670
- $albs = $wpdb->get_results( "SELECT `id` FROM `".WPPA_ALBUMS."`" );
671
  if ( $albs ) return true;
672
  else return false; // No albums in system
673
  }
674
 
675
  // Any --- public --- albums?
676
- $albs = $wpdb->get_results( "SELECT `id` FROM `".WPPA_ALBUMS."` WHERE `owner` = '--- public ---'" );
677
 
678
  if ( $albs ) return true;
679
 
680
  // Any logged out created albums? ( owner = ip )
681
- $albs = $wpdb->get_results( "SELECT `owner` FROM `".WPPA_ALBUMS."`", ARRAY_A );
682
  if ( $albs ) foreach ( $albs as $a ) {
683
  if ( wppa_is_int( str_replace( '.', '', $a['owner'] ) ) ) return true;
684
  }
@@ -687,7 +687,7 @@ global $current_user;
687
  if ( is_user_logged_in() ) {
688
  $current_user = wp_get_current_user();
689
  $user = $current_user->user_login;
690
- $any_albs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_ALBUMS."` WHERE `owner` = %s", $user ) );
691
 
692
  if ( $any_albs ) return true;
693
  else return false; // No albums for user accessible
@@ -709,7 +709,7 @@ global $current_user;
709
  $owner = $alb['owner'];
710
  }
711
  elseif ( is_numeric( $alb ) ) {
712
- $owner = $wpdb->get_var( $wpdb->prepare( "SELECT `owner` FROM `".WPPA_ALBUMS."` WHERE `id` = %s", $alb ) );
713
  }
714
 
715
  // -- public --- ?
@@ -1025,7 +1025,7 @@ static $result_cache;
1025
 
1026
  $album = wppa_cache_album( $alb );
1027
 
1028
- $limits = $album['upload_limit']; //$wpdb->get_var( $wpdb->prepare( "SELECT `upload_limit` FROM `".WPPA_ALBUMS."` WHERE `id` = %s", $alb ) );
1029
 
1030
  $temp = explode( '/', $limits );
1031
  $limit_max = isset( $temp[0] ) ? $temp[0] : '0';
@@ -1034,12 +1034,12 @@ static $result_cache;
1034
  if ( ! $limit_max ) return '-1'; // Unlimited max
1035
 
1036
  if ( ! $limit_time ) { // For ever
1037
- $curcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `album` = %s", $alb ) );
1038
  }
1039
  else { // Time criterium in place
1040
  $timnow = time();
1041
  $timthen = $timnow - $limit_time;
1042
- $curcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `album` = %s AND `timestamp` > %s", $alb, $timthen ) );
1043
  }
1044
 
1045
  if ( $curcount >= $limit_max ) $result = '0'; // No more allowed
@@ -1087,13 +1087,13 @@ global $wpdb;
1087
 
1088
  // Get the currently uploaded photos
1089
  if ( ! $limit_time ) { // For ever
1090
- $curcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `owner` = %s" . $album_clause, $user ) );
1091
  }
1092
  else { // Time criterium in place
1093
  $timnow = time();
1094
  $timthen = $timnow - $limit_time;
1095
- $curcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `owner` = %s AND `timestamp` > %s" . $album_clause, $user, $timthen ) );
1096
- wppa_log('obs', $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `owner` = %s AND `timestamp` > %s", $user, $timthen ) . ' returns:' . $curcount );
1097
  }
1098
 
1099
  // Compute the allowed number of photos
@@ -1586,7 +1586,7 @@ global $wpdb;
1586
  $albums = array();
1587
 
1588
  $temp = $wpdb->get_results( "SELECT `id`, `name` " .
1589
- "FROM `" . WPPA_ALBUMS . "` " .
1590
  "WHERE `id` IN (" . implode( ',', $args['array'] ) . ") " .
1591
  ( $args['checkowner'] && wppa_switch( 'upload_owner_only' ) && ! wppa_user_is( 'administrator' ) ? "AND `owner` IN ( '--- public ---', '" . wppa_get_user() . "' ) " : "" ) .
1592
  wppa_get_album_order( $args['root'] ),
@@ -1604,7 +1604,7 @@ global $wpdb;
1604
  }
1605
  else {
1606
  $albums = $wpdb->get_results( "SELECT `id`, `name` " .
1607
- "FROM `" . WPPA_ALBUMS . "` " .
1608
  ( $args['checkowner'] && wppa_switch( 'upload_owner_only' ) && ! wppa_user_is( 'administrator' ) ? "WHERE `owner` IN ( '--- public ---', '" . wppa_get_user() . "' ) " : "" ) .
1609
  wppa_get_album_order( $args['root'] ),
1610
  ARRAY_A
@@ -1824,7 +1824,7 @@ global $wpdb;
1824
  if ( $last_check < ( time() - 300 ) ) { // Longer than 5 mins ago
1825
 
1826
  // Publish scheduled photos
1827
- $to_publish = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `status` = 'scheduled' AND `scheduledtm` < %s", wppa_get_default_scheduledtm() ), ARRAY_A );
1828
  if ( $to_publish ) foreach( $to_publish as $photo ) {
1829
  wppa_update_photo( array( 'id' => $photo['id'], 'scheduledtm' => '', 'status' => 'publish', 'timestamp' => time() ) );
1830
  wppa_update_album( array( 'id' => $photo['album'], 'modified' => time() ) ); // For New indicator on album
@@ -1832,14 +1832,14 @@ global $wpdb;
1832
  }
1833
 
1834
  // Publish scheduled albums ( for future use, currently not implemented )
1835
- $to_publish = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_ALBUMS."` WHERE `scheduledtm` <> '' AND `scheduledtm` < %s", wppa_get_default_scheduledtm() ), ARRAY_A );
1836
  if ( $to_publish ) foreach( $to_publish as $album ) {
1837
  wppa_update_album( array( 'id' => $album['id'], 'scheduledtm' => '' ) );
1838
  wppa_invalidate_treecounts( $album['id'] );
1839
  }
1840
 
1841
  // Delete photos scheduled for deletion
1842
- $to_delete = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `scheduledel` <> '' AND `scheduledel` < %s", wppa_get_default_scheduledtm() ), ARRAY_A );
1843
  if ( $to_delete ) foreach( $to_delete as $photo ) {
1844
  wppa_delete_photo( $photo['id'] );
1845
  }
2
  /* wppa-common-functions.php
3
  *
4
  * Functions used in admin and in themes
5
+ * Version 6.9.14
6
  *
7
  */
8
 
548
  if ( $name == '' ) return '';
549
  $name = stripslashes( $name );
550
 
551
+ $albs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `name` = %s", $name ), ARRAY_A );
552
 
553
  if ( empty( $albs ) ) {
554
  return '';
667
 
668
  // Administrator has always access OR If all albums are public
669
  if ( wppa_user_is( 'administrator' ) || ! wppa_switch( 'owner_only' ) ) {
670
+ $albs = $wpdb->get_results( "SELECT `id` FROM $wpdb->wppa_albums" );
671
  if ( $albs ) return true;
672
  else return false; // No albums in system
673
  }
674
 
675
  // Any --- public --- albums?
676
+ $albs = $wpdb->get_results( "SELECT `id` FROM $wpdb->wppa_albums WHERE `owner` = '--- public ---'" );
677
 
678
  if ( $albs ) return true;
679
 
680
  // Any logged out created albums? ( owner = ip )
681
+ $albs = $wpdb->get_results( "SELECT `owner` FROM $wpdb->wppa_albums", ARRAY_A );
682
  if ( $albs ) foreach ( $albs as $a ) {
683
  if ( wppa_is_int( str_replace( '.', '', $a['owner'] ) ) ) return true;
684
  }
687
  if ( is_user_logged_in() ) {
688
  $current_user = wp_get_current_user();
689
  $user = $current_user->user_login;
690
+ $any_albs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE `owner` = %s", $user ) );
691
 
692
  if ( $any_albs ) return true;
693
  else return false; // No albums for user accessible
709
  $owner = $alb['owner'];
710
  }
711
  elseif ( is_numeric( $alb ) ) {
712
+ $owner = $wpdb->get_var( $wpdb->prepare( "SELECT `owner` FROM $wpdb->wppa_albums WHERE `id` = %s", $alb ) );
713
  }
714
 
715
  // -- public --- ?
1025
 
1026
  $album = wppa_cache_album( $alb );
1027
 
1028
+ $limits = $album['upload_limit']; //$wpdb->get_var( $wpdb->prepare( "SELECT `upload_limit` FROM $wpdb->wppa_albums WHERE `id` = %s", $alb ) );
1029
 
1030
  $temp = explode( '/', $limits );
1031
  $limit_max = isset( $temp[0] ) ? $temp[0] : '0';
1034
  if ( ! $limit_max ) return '-1'; // Unlimited max
1035
 
1036
  if ( ! $limit_time ) { // For ever
1037
+ $curcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `album` = %s", $alb ) );
1038
  }
1039
  else { // Time criterium in place
1040
  $timnow = time();
1041
  $timthen = $timnow - $limit_time;
1042
+ $curcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `album` = %s AND `timestamp` > %s", $alb, $timthen ) );
1043
  }
1044
 
1045
  if ( $curcount >= $limit_max ) $result = '0'; // No more allowed
1087
 
1088
  // Get the currently uploaded photos
1089
  if ( ! $limit_time ) { // For ever
1090
+ $curcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `owner` = %s" . $album_clause, $user ) );
1091
  }
1092
  else { // Time criterium in place
1093
  $timnow = time();
1094
  $timthen = $timnow - $limit_time;
1095
+ $curcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `owner` = %s AND `timestamp` > %s" . $album_clause, $user, $timthen ) );
1096
+ wppa_log('obs', $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `owner` = %s AND `timestamp` > %s", $user, $timthen ) . ' returns:' . $curcount );
1097
  }
1098
 
1099
  // Compute the allowed number of photos
1586
  $albums = array();
1587
 
1588
  $temp = $wpdb->get_results( "SELECT `id`, `name` " .
1589
+ "FROM $wpdb->wppa_albums " .
1590
  "WHERE `id` IN (" . implode( ',', $args['array'] ) . ") " .
1591
  ( $args['checkowner'] && wppa_switch( 'upload_owner_only' ) && ! wppa_user_is( 'administrator' ) ? "AND `owner` IN ( '--- public ---', '" . wppa_get_user() . "' ) " : "" ) .
1592
  wppa_get_album_order( $args['root'] ),
1604
  }
1605
  else {
1606
  $albums = $wpdb->get_results( "SELECT `id`, `name` " .
1607
+ "FROM $wpdb->wppa_albums " .
1608
  ( $args['checkowner'] && wppa_switch( 'upload_owner_only' ) && ! wppa_user_is( 'administrator' ) ? "WHERE `owner` IN ( '--- public ---', '" . wppa_get_user() . "' ) " : "" ) .
1609
  wppa_get_album_order( $args['root'] ),
1610
  ARRAY_A
1824
  if ( $last_check < ( time() - 300 ) ) { // Longer than 5 mins ago
1825
 
1826
  // Publish scheduled photos
1827
+ $to_publish = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `status` = 'scheduled' AND `scheduledtm` < %s", wppa_get_default_scheduledtm() ), ARRAY_A );
1828
  if ( $to_publish ) foreach( $to_publish as $photo ) {
1829
  wppa_update_photo( array( 'id' => $photo['id'], 'scheduledtm' => '', 'status' => 'publish', 'timestamp' => time() ) );
1830
  wppa_update_album( array( 'id' => $photo['album'], 'modified' => time() ) ); // For New indicator on album
1832
  }
1833
 
1834
  // Publish scheduled albums ( for future use, currently not implemented )
1835
+ $to_publish = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `scheduledtm` <> '' AND `scheduledtm` < %s", wppa_get_default_scheduledtm() ), ARRAY_A );
1836
  if ( $to_publish ) foreach( $to_publish as $album ) {
1837
  wppa_update_album( array( 'id' => $album['id'], 'scheduledtm' => '' ) );
1838
  wppa_invalidate_treecounts( $album['id'] );
1839
  }
1840
 
1841
  // Delete photos scheduled for deletion
1842
+ $to_delete = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `scheduledel` <> '' AND `scheduledel` < %s", wppa_get_default_scheduledtm() ), ARRAY_A );
1843
  if ( $to_delete ) foreach( $to_delete as $photo ) {
1844
  wppa_delete_photo( $photo['id'] );
1845
  }
wppa-cron.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all cron functions
6
- * Version 6.8.07
7
  *
8
  *
9
  */
@@ -184,7 +184,7 @@ 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 `" . WPPA_SESSION . "` SET `status` = 'expired' WHERE `timestamp` < %s", $expire ) );
188
  $wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPPA_SESSION ."` WHERE `timestamp` < %s", $purge ) );
189
 
190
  // Delete obsolete spam
@@ -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 `" . WPPA_ALBUMS . "`" );
204
  if ( ! empty( $album_ids ) ) {
205
- $lost = $wpdb->query( "UPDATE `" . 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 `".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 `" . 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.14
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 `" . WPPA_SESSION ."` WHERE `timestamp` < %s", $purge ) );
189
 
190
  // Delete obsolete spam
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.6.09
7
  *
8
  */
9
 
@@ -36,11 +36,21 @@ function wppa_get_unique_crypt( $table ) {
36
  global $wpdb;
37
 
38
  $crypt = substr( md5( microtime() ), 0, 12 );
39
- $dup = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `" . $table . "` WHERE `crypt` = %s", $crypt ) );
 
 
 
 
 
40
  while ( $dup ) {
41
  sleep( 1 );
42
  $crypt = substr( md5( microtime() ), 0, 12 );
43
- $dup = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `" . $table . "` WHERE `crypt` = %s", $crypt ) );
 
 
 
 
 
44
  }
45
  return $crypt;
46
  }
@@ -143,7 +153,7 @@ global $wpdb;
143
  }
144
 
145
  // Just do it
146
- $id = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `" . WPPA_PHOTOS . "` WHERE `crypt` = %s", substr( $photo, 0, 12 ) ) );
147
  if ( ! $id ) {
148
  if ( $report_error ) {
149
  wppa_dbg_msg( 'Invalid photo identifier: ' . $photo, 'red', 'force' );
@@ -205,7 +215,7 @@ global $wpdb;
205
 
206
  // Just do it
207
  else {
208
- $id = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `" . WPPA_ALBUMS . "` WHERE `crypt` = %s", substr( $crypt, 0, 12 ) ) );
209
  if ( ! $id ) {
210
  wppa_log( 'Dbg', 'Invalid album identifier: ' . $crypt . ' found in: ' . $album . ' (wppa_decrypt_album)' );
211
  $id = '-9';
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all ecryption/decryption logic
6
+ * Version 6.9.14
7
  *
8
  */
9
 
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 `" . 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;
56
  }
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' );
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';
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.8.04
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 `" . 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 `" . 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 `" . 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 `" . 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;
@@ -2961,18 +2961,18 @@ function wppa_iptc_clean_garbage() {
2961
  global $wpdb;
2962
 
2963
  // Remove empty tags
2964
- // $empty = $wpdb->query( "DELETE FROM `" . WPPA_IPTC . "` WHERE `description` = '' OR `description` = ' ' OR `description` = ' '" );
2965
  // if ( $empty ) {
2966
  // wppa_log( 'dbg', $empty . ' empty iptc entries removed.' );
2967
  // }
2968
 
2969
  // Remove labels that are no longer used
2970
- $labels = $wpdb->get_results( "SELECT DISTINCT `tag` FROM `" . WPPA_IPTC . "` WHERE `photo` = '0'", ARRAY_A );
2971
  if ( ! empty( $labels ) ) {
2972
  foreach( $labels as $label ) {
2973
- $used = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `" . WPPA_IPTC . "` WHERE `tag` = %s AND `photo` <> '0'", $label['tag'] ) );
2974
  if ( $used == 0 ) {
2975
- $wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPPA_IPTC . "` WHERE `tag` = %s AND `photo` = '0'", $label['tag'] ) );
2976
  wppa_log( 'dbg', 'Iptc tag label ' . $label['tag'] . ' removed.' );
2977
  }
2978
  }
@@ -2983,16 +2983,16 @@ function wppa_exif_clean_garbage() {
2983
  global $wpdb;
2984
 
2985
  // Remove empty tags
2986
- // $empty = $wpdb->query( "DELETE FROM `" . WPPA_EXIF . "` WHERE `description` = '' OR `description` = ' ' OR `description` = ' '" );
2987
  // wppa_log( 'dbg', $empty . ' empty exif entries removed.' );
2988
 
2989
  // Remove labels that are no longer used
2990
- $labels = $wpdb->get_results( "SELECT DISTINCT `tag` FROM `" . WPPA_EXIF . "` WHERE `photo` = '0'", ARRAY_A );
2991
  if ( ! empty( $labels ) ) {
2992
  foreach( $labels as $label ) {
2993
- $used = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `" . WPPA_EXIF . "` WHERE `tag` = %s AND `photo` <> '0'", $label['tag'] ) );
2994
  if ( $used == 0 ) {
2995
- $wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPPA_EXIF . "` WHERE `tag` = %s AND `photo` = '0'", $label['tag'] ) );
2996
  wppa_log( 'dbg', 'Exif tag label ' . $label['tag'] . ' removed.' );
2997
  }
2998
  }
@@ -3008,7 +3008,7 @@ global $wpdb;
3008
  return false;
3009
  }
3010
 
3011
- $exifs = $wpdb->get_results( "SELECT * FROM `" . WPPA_EXIF . "` WHERE `photo` = $photo", ARRAY_A );
3012
 
3013
  if ( ! empty( $exifs ) ) {
3014
 
@@ -3022,12 +3022,12 @@ global $wpdb;
3022
  // If f_description or thabrand changed: update
3023
  if ( $f_description != $exif['f_description'] || $tagbrand != $exif['brand'] ) {
3024
  $id = $exif['id'];
3025
- $wpdb->query( $wpdb->prepare( "UPDATE `" . WPPA_EXIF . "` SET `f_description` = %s, `brand` = %s WHERE `id` = %s", $f_description, $tagbrand, $id ) );
3026
  $photodata = wppa_cache_photo( $photo );
3027
 
3028
  // If the format changed and the exif tag is used in the description, the photo must be re-indexed
3029
  if ( strpos( $photodata['description'], $exif['tag'] ) !== false ) {
3030
- $wpdb->query( "UPDATE `" . WPPA_PHOTOS . "` SET `indexdtm` = '' WHERE `id` = $photo" );
3031
  wppa_schedule_maintenance_proc( 'wppa_remake_index_photos' );
3032
  }
3033
  }
@@ -3676,7 +3676,7 @@ if ( strlen($tag) != 6 ) {
3676
 
3677
  // Fill $editabletags
3678
  if ( empty( $editabletags ) ) {
3679
- $temp = $wpdb->get_results( "SELECT * FROM `" . WPPA_EXIF . "` WHERE `photo` = '0'", ARRAY_A );
3680
  $editabletags = array();
3681
  if ( is_array( $temp ) ) foreach ( $temp as $item ) {
3682
  $editabletags[ hexdec( substr( $item['tag'], 2, 4 ) ) ] = trim( $item['description'], ': ' );
@@ -4344,7 +4344,7 @@ global $wpdb;
4344
  // Process result
4345
  // print_r( $geo ); // debug
4346
  $result = implode( '/', $geo );
4347
- $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `location` = %s WHERE `id` = %s", $result, $photo_id ) );
4348
  return $geo;
4349
  }
4350
 
@@ -4352,7 +4352,7 @@ function wppa_get_camera_brand( $id ) {
4352
  global $wpdb;
4353
 
4354
  // Try stored exif data
4355
- $E010F = $wpdb->get_var( $wpdb->prepare( "SELECT `description` FROM `" . WPPA_EXIF . "` WHERE `photo` = %s AND `tag` = 'E#010F' ", $id ) );
4356
  if ( $E010F ) {
4357
  $E010F = strtolower( $E010F );
4358
  if ( strpos( $E010F, 'canon' ) !== false ) {
3
  * Package: wp-photo-album-plus
4
  *
5
  * exif and iptc common functions
6
+ * version 6.9.14
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;
2961
  global $wpdb;
2962
 
2963
  // Remove empty tags
2964
+ // $empty = $wpdb->query( "DELETE FROM $wpdb->wppa_iptc WHERE `description` = '' OR `description` = ' ' OR `description` = ' '" );
2965
  // if ( $empty ) {
2966
  // wppa_log( 'dbg', $empty . ' empty iptc entries removed.' );
2967
  // }
2968
 
2969
  // Remove labels that are no longer used
2970
+ $labels = $wpdb->get_results( "SELECT DISTINCT `tag` FROM $wpdb->wppa_iptc WHERE `photo` = '0'", ARRAY_A );
2971
  if ( ! empty( $labels ) ) {
2972
  foreach( $labels as $label ) {
2973
+ $used = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_iptc WHERE `tag` = %s AND `photo` <> '0'", $label['tag'] ) );
2974
  if ( $used == 0 ) {
2975
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_iptc WHERE `tag` = %s AND `photo` = '0'", $label['tag'] ) );
2976
  wppa_log( 'dbg', 'Iptc tag label ' . $label['tag'] . ' removed.' );
2977
  }
2978
  }
2983
  global $wpdb;
2984
 
2985
  // Remove empty tags
2986
+ // $empty = $wpdb->query( "DELETE FROM $wpdb->wppa_exif WHERE `description` = '' OR `description` = ' ' OR `description` = ' '" );
2987
  // wppa_log( 'dbg', $empty . ' empty exif entries removed.' );
2988
 
2989
  // Remove labels that are no longer used
2990
+ $labels = $wpdb->get_results( "SELECT DISTINCT `tag` FROM $wpdb->wppa_exif WHERE `photo` = '0'", ARRAY_A );
2991
  if ( ! empty( $labels ) ) {
2992
  foreach( $labels as $label ) {
2993
+ $used = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_exif WHERE `tag` = %s AND `photo` <> '0'", $label['tag'] ) );
2994
  if ( $used == 0 ) {
2995
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_exif WHERE `tag` = %s AND `photo` = '0'", $label['tag'] ) );
2996
  wppa_log( 'dbg', 'Exif tag label ' . $label['tag'] . ' removed.' );
2997
  }
2998
  }
3008
  return false;
3009
  }
3010
 
3011
+ $exifs = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_exif WHERE `photo` = $photo", ARRAY_A );
3012
 
3013
  if ( ! empty( $exifs ) ) {
3014
 
3022
  // If f_description or thabrand changed: update
3023
  if ( $f_description != $exif['f_description'] || $tagbrand != $exif['brand'] ) {
3024
  $id = $exif['id'];
3025
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_exif SET `f_description` = %s, `brand` = %s WHERE `id` = %s", $f_description, $tagbrand, $id ) );
3026
  $photodata = wppa_cache_photo( $photo );
3027
 
3028
  // If the format changed and the exif tag is used in the description, the photo must be re-indexed
3029
  if ( strpos( $photodata['description'], $exif['tag'] ) !== false ) {
3030
+ $wpdb->query( "UPDATE $wpdb->wppa_photos SET `indexdtm` = '' WHERE `id` = $photo" );
3031
  wppa_schedule_maintenance_proc( 'wppa_remake_index_photos' );
3032
  }
3033
  }
3676
 
3677
  // Fill $editabletags
3678
  if ( empty( $editabletags ) ) {
3679
+ $temp = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_exif WHERE `photo` = '0'", ARRAY_A );
3680
  $editabletags = array();
3681
  if ( is_array( $temp ) ) foreach ( $temp as $item ) {
3682
  $editabletags[ hexdec( substr( $item['tag'], 2, 4 ) ) ] = trim( $item['description'], ': ' );
4344
  // Process result
4345
  // print_r( $geo ); // debug
4346
  $result = implode( '/', $geo );
4347
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `location` = %s WHERE `id` = %s", $result, $photo_id ) );
4348
  return $geo;
4349
  }
4350
 
4352
  global $wpdb;
4353
 
4354
  // Try stored exif data
4355
+ $E010F = $wpdb->get_var( $wpdb->prepare( "SELECT `description` FROM $wpdb->wppa_exif WHERE `photo` = %s AND `tag` = 'E#010F' ", $id ) );
4356
  if ( $E010F ) {
4357
  $E010F = strtolower( $E010F );
4358
  if ( strpos( $E010F, 'canon' ) !== false ) {
wppa-export.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the export functions
6
- * Version 6.6.18
7
  *
8
  */
9
 
@@ -35,7 +35,7 @@ global $wpdb;
35
  <?php wp_nonce_field('$wppa_nonce', WPPA_NONCE); ?>
36
  <?php echo(sprintf(__('Photos will be exported to: <b>%s</b>.', 'wp-photo-album-plus'), WPPA_DEPOT)) ?>
37
  <h2><?php _e('Export photos from album <span style="font-size:12px;">(Including Album information)</span>:', 'wp-photo-album-plus'); ?></h2>
38
- <?php $albums = $wpdb->get_results( "SELECT * FROM `" . WPPA_ALBUMS . "` " . wppa_get_album_order(), ARRAY_A);
39
  $high = '0'; ?>
40
 
41
  <table class="form-table albumtable">
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the export functions
6
+ * Version 6.9.14
7
  *
8
  */
9
 
35
  <?php wp_nonce_field('$wppa_nonce', WPPA_NONCE); ?>
36
  <?php echo(sprintf(__('Photos will be exported to: <b>%s</b>.', 'wp-photo-album-plus'), WPPA_DEPOT)) ?>
37
  <h2><?php _e('Export photos from album <span style="font-size:12px;">(Including Album information)</span>:', 'wp-photo-album-plus'); ?></h2>
38
+ <?php $albums = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums " . wppa_get_album_order(), ARRAY_A);
39
  $high = '0'; ?>
40
 
41
  <table class="form-table albumtable">
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.12
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 `" . 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 `" . 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 `" . 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 `" . 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 -->';
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
 
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 -->';
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.08
7
  *
8
  */
9
 
@@ -77,6 +77,9 @@ global $wppa_revno;
77
  'button' => '',
78
  ), $xatts );
79
 
 
 
 
80
  // Init
81
  wppa_reset_occurrance();
82
 
@@ -570,12 +573,12 @@ static $seed;
570
 
571
  if ( wppa_opt( 'photo_shortcode_random_albums' ) != '-2' ) {
572
  $albs = str_replace( '.', ',', wppa_expand_enum( wppa_opt( 'photo_shortcode_random_albums' ) ) );
573
- $photo = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `" . WPPA_PHOTOS . "` " .
574
  "WHERE `album` IN (" . $albs . ") " .
575
  "ORDER BY RAND(%d) LIMIT 1", $seed ) );
576
  }
577
  else {
578
- $photo = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `" . WPPA_PHOTOS . "` " .
579
  "ORDER BY RAND(%d) LIMIT 1", $seed ) );
580
  }
581
  if ( $photo ) {
@@ -640,4 +643,4 @@ static $seed;
640
  $wppa['align'] = $align;
641
 
642
  return wppa_albums();
643
- }
3
  * Package: wp-photo-album-plus
4
  *
5
  * get the albums via shortcode handler
6
+ * Version 6.9.14
7
  *
8
  */
9
 
77
  'button' => '',
78
  ), $xatts );
79
 
80
+ // Sanitize input
81
+ if ( $atts['alt'] && $atss['alt'] != 'none' ) $atts['alt'] = strval( intval( $atts['alt'] ) );
82
+
83
  // Init
84
  wppa_reset_occurrance();
85
 
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 ) {
643
  $wppa['align'] = $align;
644
 
645
  return wppa_albums();
646
+ }
wppa-functions.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various functions
6
- * Version 6.9.13
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 `".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,7 +235,7 @@ 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 `".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' );
@@ -289,18 +289,18 @@ global $wppa_session;
289
  if ( $limit ) {
290
  if ( $parent ) {
291
  if ( $limit ) {
292
- $q = $wpdb->prepare( "SELECT * FROM `".WPPA_ALBUMS."` WHERE `a_parent` = %s ORDER BY `timestamp` DESC LIMIT %d", $parent, $limit );
293
  }
294
  else {
295
- $q = $wpdb->prepare( "SELECT * FROM `".WPPA_ALBUMS."` WHERE `a_parent` = %s ORDER BY `timestamp` DESC", $parent );
296
  }
297
  }
298
  else {
299
  if ( $limit ) {
300
- $q = $wpdb->prepare( "SELECT * FROM `".WPPA_ALBUMS."` ORDER BY `timestamp` DESC LIMIT %d", $limit );
301
  }
302
  else {
303
- $q = "SELECT * FROM `".WPPA_ALBUMS."` ORDER BY `timestamp` DESC";
304
  }
305
  }
306
  $albs = $wpdb->get_results( $q, ARRAY_A );
@@ -431,7 +431,7 @@ global $wppa_session;
431
  }
432
 
433
  // Get all albums and cache its data
434
- $albs = $wpdb->get_results( "SELECT * FROM `".WPPA_ALBUMS."`", ARRAY_A );
435
  wppa_cache_album( 'add', $albs );
436
 
437
  // $cats is not empty. If it contains a , all cats must be met ( AND case )
@@ -954,13 +954,13 @@ global $wppa_session;
954
  if ( empty( $ids ) ) {
955
  $ids = array( '0' ); // Dummy
956
  }
957
- $query = "SELECT * FROM `" . 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 `" . WPPA_ALBUMS . "` WHERE `name` = %s", $data );
964
  $albums = $wpdb->get_results( $query, ARRAY_A );
965
  break;
966
 
@@ -968,26 +968,26 @@ global $wppa_session;
968
  case 't':
969
  if ( strpos( $data, '.' ) ) {
970
  $temp = explode( '.', $data );
971
- $query = $wpdb->prepare( "SELECT * FROM `" . 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 `" . 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 `" . 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 `" . WPPA_ALBUMS . "` WHERE `id` IN (" . implode( ',', $ids ) . ")";
991
  $albums = $wpdb->get_results( $query, ARRAY_A );
992
  break;
993
  }
@@ -1003,7 +1003,7 @@ global $wppa_session;
1003
 
1004
  // If Catbox specifies a category to limit, remove all albums that do not have the desired cat.
1005
  if ( wppa( 'catbox' ) ) {
1006
- $catalbs = $wpdb->get_col( "SELECT `id` FROM `" . WPPA_ALBUMS . "` WHERE `cats` LIKE '%" . wppa( 'catbox' ) . "%' " );
1007
  $final_array = array_intersect( $final_array, $catalbs );
1008
  }
1009
 
@@ -1014,7 +1014,7 @@ global $wppa_session;
1014
  }
1015
 
1016
  // Get them
1017
- $albums = $wpdb->get_results( "SELECT * FROM `" . WPPA_ALBUMS . "` WHERE " . $selection . " " . wppa_get_album_order( '0' ), ARRAY_A );
1018
 
1019
  // Exclusive separate albums?
1020
  if ( wppa_switch( 'excl_sep' ) ) {
@@ -1057,17 +1057,17 @@ global $wppa_session;
1057
  // Do the query
1058
  if ( $id == '-2' ) { // All albums
1059
  if ( wppa( 'is_cover' ) ) {
1060
- $q = "SELECT * FROM `".WPPA_ALBUMS."` ".wppa_get_album_order();
1061
  $albums = $wpdb->get_results( $q, ARRAY_A );
1062
  }
1063
  else $albums = false;
1064
  }
1065
  elseif ( wppa( 'last_albums' ) ) { // is_cover = true. For the order sequence, see remark in wppa_albums()
1066
  if ( wppa( 'last_albums_parent' ) ) {
1067
- $q = $wpdb->prepare( "SELECT * FROM `".WPPA_ALBUMS."` WHERE `a_parent` = %s ORDER BY `timestamp` DESC LIMIT %d", wppa( 'last_albums_parent' ), wppa( 'last_albums' ) );
1068
  }
1069
  else {
1070
- $q = $wpdb->prepare( "SELECT * FROM `".WPPA_ALBUMS."` ORDER BY `timestamp` DESC LIMIT %d", wppa( 'last_albums' ) );
1071
  }
1072
  $albums = $wpdb->get_results( $q, ARRAY_A );
1073
  }
@@ -1083,10 +1083,10 @@ global $wppa_session;
1083
  elseif ( strpos( $id, '.' ) !== false ) { // Album enum
1084
  $ids = wppa_series_to_array( $id );
1085
  if ( wppa( 'is_cover' ) ) {
1086
- $q = "SELECT * FROM `".WPPA_ALBUMS."` WHERE `id` = ".implode( " OR `id` = ", $ids )." ".wppa_get_album_order();
1087
  }
1088
  else {
1089
- $q = "SELECT * FROM `".WPPA_ALBUMS."` WHERE `a_parent` = ".implode( " OR `a_parent` = ", $ids )." ".wppa_get_album_order();
1090
  }
1091
  wppa_dbg_msg( $q, 'red' );
1092
  $albums = $wpdb->get_results( $q, ARRAY_A );
@@ -1185,7 +1185,7 @@ global $wppa_session;
1185
 
1186
  // Single image slideshow?
1187
  if ( wppa( 'start_photo' ) && wppa( 'is_single' ) ) {
1188
- $query = $wpdb->prepare( "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1189
  "WHERE `id` = %s", wppa( 'start_photo' ) );
1190
  }
1191
 
@@ -1194,7 +1194,7 @@ global $wppa_session;
1194
  $status = "`status` <> 'pending' AND `status` <> 'scheduled'";
1195
  if ( ! is_user_logged_in() ) $status .= " AND `status` <> 'private'";
1196
 
1197
- $query = $wpdb->prepare( "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1198
  "WHERE " . $album_clause . " AND `owner` = %s AND ( " . $status . " ) " .
1199
  "ORDER BY `timestamp` DESC", wppa( 'is_upldr' ) );
1200
  }
@@ -1225,7 +1225,7 @@ global $wppa_session;
1225
  }
1226
  if ( ! is_user_logged_in() ) $status .= " AND `status` <> 'private'";
1227
 
1228
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1229
  "WHERE $album_clause AND ( $status ) " .
1230
  "ORDER BY $sortby LIMIT $max";
1231
 
@@ -1236,7 +1236,7 @@ global $wppa_session;
1236
  elseif ( wppa( 'is_featen' ) ) {
1237
  $max = wppa( 'featen_count' );
1238
 
1239
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1240
  "WHERE $album_clause AND `status` = 'featured' " .
1241
  "ORDER BY RAND( " . wppa_get_randseed() . " ) DESC LIMIT $max";
1242
 
@@ -1257,7 +1257,7 @@ global $wppa_session;
1257
 
1258
  if ( current_user_can( 'wppa_moderate' ) ) {
1259
 
1260
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1261
  "WHERE ( $album_clause ) " .
1262
  "AND ( $newtime ) " .
1263
  $owner_restriction .
@@ -1265,7 +1265,7 @@ global $wppa_session;
1265
  }
1266
  else {
1267
 
1268
- $query = "SELECT * FROM `".WPPA_PHOTOS."` " .
1269
  "WHERE ( $album_clause ) AND ( $status ) AND ( $newtime ) " .
1270
  $owner_restriction .
1271
  "ORDER BY `$order_by` DESC LIMIT $max";
@@ -1276,13 +1276,13 @@ global $wppa_session;
1276
  else {
1277
  if ( current_user_can( 'wppa_moderate' ) ) {
1278
 
1279
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1280
  "WHERE $album_clause " .
1281
  "ORDER BY `$order_by` DESC LIMIT $max";
1282
  }
1283
  else {
1284
 
1285
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1286
  "WHERE ( $album_clause ) AND ( $status ) " .
1287
  "ORDER BY `$order_by` DESC LIMIT $max";
1288
  }
@@ -1312,7 +1312,7 @@ global $wppa_session;
1312
  // To keep the sequence ok ( in sequence of comments desc ), do the queries one by one
1313
  $thumbs = array();
1314
  if ( is_array( $photo_ids ) ) foreach( $photo_ids as $id ) {
1315
- $temp = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE ".$status." AND `album` > '0' AND `id` = %s", $id ), ARRAY_A );
1316
  if ( $temp ) {
1317
  $thumbs[] = $temp;
1318
  }
@@ -1361,13 +1361,13 @@ global $wppa_session;
1361
 
1362
  // Prepare the query
1363
  if ( current_user_can( 'wppa_moderate' ) ) {
1364
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1365
  "WHERE ( $tags_like ) " .
1366
  "AND $album_clause " .
1367
  wppa_get_photo_order( '0' );
1368
  }
1369
  else {
1370
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1371
  "WHERE ( $tags_like ) " .
1372
  "AND $album_clause " .
1373
  "AND $status " .
@@ -1401,13 +1401,13 @@ global $wppa_session;
1401
  $is = 'LIKE';
1402
  }
1403
  if ( current_user_can( 'wppa_moderate' ) ) {
1404
- $query = $wpdb->prepare( "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1405
  "WHERE `name` " . $is . " %s " .
1406
  "AND `album` > '0' " .
1407
  wppa_get_photo_order( '0' ), $data );
1408
  }
1409
  else {
1410
- $query = $wpdb->prepare( "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1411
  "WHERE `name` " . $is . " %s " .
1412
  "AND `album` > '0' " .
1413
  "AND " . $status . " " .
@@ -1418,13 +1418,13 @@ global $wppa_session;
1418
  // Owner
1419
  case 'o':
1420
  if ( current_user_can( 'wppa_moderate' ) ) {
1421
- $query = $wpdb->prepare( "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1422
  "WHERE `owner` = %s " .
1423
  "AND `album` > '0' " .
1424
  wppa_get_photo_order( '0' ), $data );
1425
  }
1426
  else {
1427
- $query = $wpdb->prepare( "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1428
  "WHERE `owner` = %s " .
1429
  "AND `album` > '0' " .
1430
  "AND " . $status . " " .
@@ -1448,7 +1448,7 @@ global $wppa_session;
1448
  $tagids = $taglist[$data]['ids'];
1449
  }
1450
  if ( count( $tagids ) > '0' ) {
1451
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1452
  "WHERE ".$status." " .
1453
  "AND `id` IN (" . implode( ',',$tagids ) . ") " .
1454
  "AND `album` > '0' ";
@@ -1469,7 +1469,7 @@ global $wppa_session;
1469
  $is = 'LIKE';
1470
  }
1471
  }
1472
- $query = $wpdb->prepare( "SELECT * FROM `" . WPPA_INDEX . "` WHERE `slug` ".$is." %s", $temp['0'] );
1473
  $indexes = $wpdb->get_results( $query, ARRAY_A );
1474
  $ids = array();
1475
  foreach( $indexes as $item ) {
@@ -1485,7 +1485,7 @@ global $wppa_session;
1485
  }
1486
  }
1487
 
1488
- $query = $wpdb->prepare( "SELECT * FROM `" . WPPA_INDEX . "` WHERE `slug` ".$is." %s", $temp[$i] );
1489
  $indexes = $wpdb->get_results( $query, ARRAY_A );
1490
  $deltaids = array();
1491
  foreach( $indexes as $item ) {
@@ -1504,7 +1504,7 @@ global $wppa_session;
1504
  $is = 'LIKE';
1505
  }
1506
  }
1507
- $query = $wpdb->prepare( "SELECT * FROM `" . WPPA_INDEX . "` WHERE `slug` ".$is." %s", $data );
1508
  $indexes = $wpdb->get_results( $query, ARRAY_A );
1509
  $ids = array();
1510
  foreach( $indexes as $item ) {
@@ -1514,7 +1514,7 @@ global $wppa_session;
1514
  if ( empty( $ids ) ) {
1515
  $ids = array( '0' ); // Dummy
1516
  }
1517
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1518
  "WHERE ".$status." " .
1519
  "AND `album` > '0' " .
1520
  "AND `id` IN (" . trim( implode( ',', $ids ), ',' ) . ")";
@@ -1524,14 +1524,14 @@ global $wppa_session;
1524
  case 'i':
1525
  $itag = str_replace( 'H', '#', $ss_data['2'] );
1526
  $desc = $ss_data['3'];
1527
- $query = $wpdb->prepare( "SELECT * FROM `" . WPPA_IPTC . "` " .
1528
  "WHERE `tag` = %s AND `description` = %s", $itag, $desc );
1529
  $iptclines = $wpdb->get_results( $query, ARRAY_A );
1530
  $ids = '0';
1531
  if ( is_array( $iptclines ) ) foreach( $iptclines as $item ) {
1532
  $ids .= ','.$item['photo'];
1533
  }
1534
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1535
  "WHERE ".$status." " .
1536
  "AND `album` > '0' " .
1537
  "AND `id` IN (" . $ids . ")";
@@ -1543,11 +1543,11 @@ global $wppa_session;
1543
  $brand = substr( $ss_data[2], 6 );
1544
  $desc = $ss_data['3'];
1545
  // if ( $brand ) {
1546
- $query = $wpdb->prepare( "SELECT * FROM `" . WPPA_EXIF . "` " .
1547
  "WHERE `tag` = %s AND `f_description` = %s AND `brand` = %s", $etag, $desc, $brand );
1548
  // }
1549
  // else {
1550
- // $query = $wpdb->prepare( "SELECT * FROM `" . WPPA_EXIF . "` " .
1551
  // "WHERE `tag` = %s AND `f_description` = %s", $etag, $desc );
1552
  // }
1553
  $exiflines = $wpdb->get_results( $query, ARRAY_A );
@@ -1555,7 +1555,7 @@ global $wppa_session;
1555
  if ( is_array( $exiflines ) ) foreach( $exiflines as $item ) {
1556
  $ids .= ','.$item['photo'];
1557
  }
1558
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1559
  "WHERE ".$status." " .
1560
  "AND `album` > '0' " .
1561
  "AND `id` IN (" . $ids . ")";
@@ -1577,7 +1577,7 @@ global $wppa_session;
1577
 
1578
  // Remove scheduled and pending and trashed when not can moderate
1579
  if ( ! current_user_can( 'wppa_moderate' ) ) {
1580
- $needmod = $wpdb->get_col( "SELECT `id` FROM `" . WPPA_PHOTOS . "` WHERE `status` = 'scheduled' OR `status` = 'pending' OR `album` <= '-9'" );
1581
  if ( is_array( $needmod ) ) {
1582
  $final_array = array_diff( $final_array, $needmod );
1583
  }
@@ -1585,7 +1585,7 @@ global $wppa_session;
1585
 
1586
  // Remove private and trashed when not logged in
1587
  if ( ! is_user_logged_in() ) {
1588
- $needlogin = $wpdb->get_col( "SELECT `id` FROM `" . WPPA_PHOTOS . "` WHERE `status` = 'private' OR `album` <= '-9'" );
1589
  if ( is_array( $needlogin ) ) {
1590
  $final_array = array_diff( $final_array, $needlogin );
1591
  }
@@ -1615,7 +1615,7 @@ global $wppa_session;
1615
  // Maybe cats limitation
1616
  elseif ( wppa( 'catbox' ) ) {
1617
 
1618
- $catalbs = $wpdb->get_col( "SELECT `id` FROM `" . WPPA_ALBUMS . "` WHERE `cats` LIKE '%" . wppa( 'catbox' ) . "%' " );
1619
 
1620
  if ( ! empty( $catalbs ) ) {
1621
  $alb_clause = " AND `album` IN ( " . implode( ',', $catalbs ) . " ) ";
@@ -1628,7 +1628,7 @@ global $wppa_session;
1628
  // exclude separate if required
1629
  elseif ( ! $alb_clause && wppa_switch( 'excl_sep' ) ) {
1630
  $sep_albs = '';
1631
- $temp = $wpdb->get_results( "SELECT * FROM `".WPPA_ALBUMS."` WHERE `a_parent` = '-1'", ARRAY_A );
1632
  if ( ! empty( $temp ) ) {
1633
  $t = array();
1634
  foreach ( $temp as $item ) {
@@ -1660,7 +1660,7 @@ global $wppa_session;
1660
  }
1661
 
1662
  // Construct the query
1663
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE " . $selection . $alb_clause . wppa_get_photo_order( '0' ) . $limit;
1664
  }
1665
 
1666
  // Calendar?
@@ -1675,7 +1675,7 @@ global $wppa_session;
1675
  switch ( wppa( 'calendar' ) ) {
1676
  case 'exifdtm':
1677
  $selection = "`exifdtm` LIKE '" . strip_tags( wppa( 'caldate' ) ) . "%' AND `status` <> 'pending' AND `status` <> 'scheduled' ";
1678
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1679
  "WHERE " . $selection . $alb_clause . $order;
1680
  break;
1681
 
@@ -1683,7 +1683,7 @@ global $wppa_session;
1683
  $t1 = strval( intval( wppa( 'caldate' ) * 24*60*60 ) );
1684
  $t2 = $t1 + 24*60*60;
1685
  $selection = "`timestamp` >= $t1 AND `timestamp` < $t2 AND `status` <> 'pending' AND `status` <> 'scheduled' ";
1686
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1687
  "WHERE " . $selection . $alb_clause . $order;
1688
  break;
1689
 
@@ -1691,7 +1691,7 @@ global $wppa_session;
1691
  $t1 = strval( intval( wppa( 'caldate' ) * 24*60*60 ) );
1692
  $t2 = $t1 + 24*60*60;
1693
  $selection = "`modified` >= $t1 AND `modified` < $t2 AND `status` <> 'pending' AND `status` <> 'scheduled' ";
1694
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1695
  "WHERE " . $selection . $alb_clause . $order;
1696
  break;
1697
  }
@@ -1720,10 +1720,10 @@ global $wppa_session;
1720
  if ( wppa( 'start_album' ) == -2 ) {
1721
 
1722
  if ( current_user_can( 'wppa_moderate' ) ) {
1723
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " . wppa_get_photo_order( '0' ) . $lim;
1724
  }
1725
  else {
1726
- $query = $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` " .
1727
  "WHERE ( ( " . $status . " ) OR `owner` = %s ) " .
1728
  "AND `album` > '0' " .
1729
  wppa_get_photo_order( '0' ) .
@@ -1735,13 +1735,13 @@ global $wppa_session;
1735
  // Single album ?
1736
  elseif ( wppa_is_int( wppa( 'start_album' ) ) ) {
1737
  if ( current_user_can( 'wppa_moderate' ) ) {
1738
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1739
  "WHERE `album` = " . wppa( 'start_album' ) . " " .
1740
  wppa_get_photo_order( wppa( 'start_album' ) ) .
1741
  $lim;
1742
  }
1743
  else {
1744
- $query = $wpdb->prepare( "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1745
  "WHERE ( ( " . $status . " ) OR `owner` = %s ) AND `album` = " . wppa( 'start_album' ) . " " .
1746
  wppa_get_photo_order( wppa( 'start_album' ) ) .
1747
  $lim,
@@ -1753,13 +1753,13 @@ global $wppa_session;
1753
  elseif ( is_array( $allalb ) ) {
1754
  $wherealbum = ' `album` IN (' . implode( ',', $allalb ) . ') ';
1755
  if ( current_user_can( 'wppa_moderate' ) ) {
1756
- $query = "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1757
  "WHERE " . $wherealbum . " " .
1758
  wppa_get_photo_order( '0' ) .
1759
  $lim;
1760
  }
1761
  else {
1762
- $query = $wpdb->prepare( "SELECT * FROM `" . WPPA_PHOTOS . "` " .
1763
  "WHERE ( ( " . $status . " ) OR `owner` = %s ) AND " . $wherealbum . " " .
1764
  wppa_get_photo_order( '0' ) .
1765
  $lim,
@@ -1831,10 +1831,10 @@ global $wpdb;
1831
 
1832
  // Floating searchtoken?
1833
  if ( wppa_switch( 'wild_front' ) ) {
1834
- $idxs = $wpdb->get_col( "SELECT `" . $type . "` FROM `" . WPPA_INDEX . "` WHERE `slug` LIKE '%" . $word . "%'" );
1835
  }
1836
  else {
1837
- $idxs = $wpdb->get_col( "SELECT `" . $type . "` FROM `" . WPPA_INDEX . "` WHERE `slug` LIKE '" . $word . "%'" );
1838
  }
1839
 
1840
  // $item_array is an array of arrays with item ids per word.
@@ -1869,10 +1869,10 @@ global $wpdb;
1869
 
1870
  // Floating searchtoken?
1871
  if ( wppa_switch( 'wild_front' ) ) {
1872
- $idxs = $wpdb->get_col( "SELECT `" . $type . "` FROM `" . WPPA_INDEX . "` WHERE `slug` LIKE '%" . $word . "%'" );
1873
  }
1874
  else {
1875
- $idxs = $wpdb->get_col( "SELECT `" . $type . "` FROM `" . WPPA_INDEX . "` WHERE `slug` LIKE '" . $word . "%'" );
1876
  }
1877
 
1878
  // Find ids to exclude for the current !word
@@ -1957,7 +1957,7 @@ global $wpdb;
1957
 
1958
  // Inverse selection requested?
1959
  if ( $invers ) {
1960
- $all = $wpdb->get_results( "SELECT `id`, `album` FROM `".WPPA_PHOTOS."` ".wppa_get_photo_order( '0' ), ARRAY_A );
1961
  if ( is_array( $thumbs ) ) foreach ( array_keys($thumbs) as $thumbs_key ) {
1962
  foreach ( array_keys($all) as $all_key ) {
1963
  if ( $thumbs[$thumbs_key]['id'] == $all[$all_key]['id'] ) {
@@ -2003,7 +2003,7 @@ function wppa_get_all_children( $root ) {
2003
  global $wpdb;
2004
 
2005
  $result = array();
2006
- $albs = $wpdb->get_results( $wpdb->prepare( "SELECT `id` FROM `".WPPA_ALBUMS."` WHERE `a_parent` = %s", $root ), ARRAY_A );
2007
  if ( ! $albs ) return $result;
2008
  foreach ( $albs as $alb ) {
2009
  $result[] = $alb['id'];
@@ -2432,7 +2432,7 @@ global $wppa_done;
2432
  if ( $comment ) {
2433
  if ( $cedit ) {
2434
  $query = $wpdb->prepare(
2435
- "UPDATE `" . WPPA_COMMENTS . "`".
2436
  " SET `comment` = %s, `user` = %s, `email` = %s, `status` = %s, `timestamp` = %s " .
2437
  " WHERE `id` = %s LIMIT 1",
2438
  $save_comment,
@@ -2592,7 +2592,7 @@ global $wppa_done;
2592
  if ( wppa_opt( 'comment_notify' ) == 'upload' || wppa_opt( 'comment_notify' ) == 'upadmin' || wppa_opt( 'comment_notify' ) == 'upowner' ) {
2593
 
2594
  // Mail uploader
2595
- $uploader = $wpdb->get_var( $wpdb->prepare( "SELECT `owner` FROM `".WPPA_PHOTOS."` WHERE `id` = %d", $id ) );
2596
  $moduser = wppa_get_user_by( 'login', $uploader );
2597
  if ( $moduser ) { // else it's an ip address ( anonymus uploader )
2598
  if ( ! in_array( $moduser->user_login, $sentto ) ) { // Already sent him?
@@ -2613,8 +2613,8 @@ global $wppa_done;
2613
  }
2614
  if ( wppa_opt( 'comment_notify' ) == 'owner' || wppa_opt( 'comment_notify' ) == 'both' || wppa_opt( 'comment_notify' ) == 'upowner' ) {
2615
  // Mail album owner
2616
- $alb = $wpdb->get_var( $wpdb->prepare( "SELECT `album` FROM `".WPPA_PHOTOS."` WHERE `id` = %d", $id ) );
2617
- $owner = $wpdb->get_var( $wpdb->prepare( "SELECT `owner` FROM `".WPPA_ALBUMS."` WHERE `id` = %d", $alb ) );
2618
  if ( $owner == '--- public ---' ) $owner = 'admin';
2619
  $moduser = wppa_get_user_by( 'login', $owner );
2620
  if ( ! in_array( $moduser->user_login, $sentto ) ) { // Already sent him?
@@ -4114,7 +4114,7 @@ global $wppa_children;
4114
  $children = $wppa_children[$id];
4115
  }
4116
  else {
4117
- $children = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_ALBUMS."` WHERE `a_parent` = %s", $id ), ARRAY_A );
4118
  $wppa_children[$id] = $children;
4119
  }
4120
 
@@ -4147,7 +4147,7 @@ global $wppa_children;
4147
  $children = $wppa_children[$id];
4148
  }
4149
  else {
4150
- $children = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_ALBUMS."` WHERE `a_parent` = %s", $id ), ARRAY_A );
4151
  $wppa_children[$id] = $children;
4152
  }
4153
 
@@ -4186,10 +4186,10 @@ global $allphotos;
4186
  }
4187
 
4188
  if ( $alb ) {
4189
- $pid = $wpdb->get_var( "SELECT `id` FROM `".WPPA_PHOTOS."` WHERE `name` LIKE '%".$name."%' AND ( `album` = ".$alb." ) LIMIT 1" );
4190
  }
4191
  else {
4192
- $pid = $wpdb->get_var( "SELECT `id` FROM `".WPPA_PHOTOS."` WHERE `name` LIKE '%".$name."%' LIMIT 1" );
4193
  }
4194
 
4195
  if ( $pid ) {
@@ -4217,7 +4217,7 @@ global $allalbums;
4217
  $name = str_replace( '"', '%', $name ); // A trick for double quotes
4218
  $name = stripslashes( $name );
4219
 
4220
- $query = "SELECT * FROM `".WPPA_ALBUMS."` WHERE `name` LIKE '%".$name."%'";
4221
  $albs = $wpdb->get_results( $query, ARRAY_A );
4222
 
4223
  if ( $albs ) {
@@ -4630,7 +4630,7 @@ global $wppa_alert;
4630
  $filename = wppa_strip_ext( $filename );
4631
 
4632
  // See if this filename with any extension already exists in this album
4633
- $id = $wpdb->get_var( "SELECT `id` FROM `" . WPPA_PHOTOS . "` WHERE `filename` LIKE '" . $filename . ".%' AND `album` = " . $alb );
4634
 
4635
  // Addition to an av item?
4636
  if ( $id ) {
@@ -5012,7 +5012,7 @@ global $wpdb;
5012
  $limits = wppa_get_user_upload_limits();
5013
  }
5014
  else {
5015
- $limits = $wpdb->get_var( $wpdb->prepare( "SELECT `upload_limit` FROM `".WPPA_ALBUMS."` WHERE `id` = %s", $album ) );
5016
  }
5017
  $temp = explode( '/', $limits );
5018
  $limit_max = isset( $temp[0] ) ? $temp[0] : '0';
@@ -5024,10 +5024,10 @@ global $wpdb;
5024
 
5025
  if ( $user ) {
5026
  $owner = wppa_get_user( 'login' );
5027
- $last_upload_time = $wpdb->get_var( $wpdb->prepare( "SELECT `timestamp` FROM `".WPPA_PHOTOS."` WHERE `owner` = %s ORDER BY `timestamp` DESC LIMIT 1", $owner ) );
5028
  }
5029
  else {
5030
- $last_upload_time = $wpdb->get_var( $wpdb->prepare( "SELECT `timestamp` FROM `".WPPA_PHOTOS."` WHERE `album` = %s ORDER BY `timestamp` DESC LIMIT 1", $album ) );
5031
  }
5032
  $timnow = time();
5033
 
@@ -5172,7 +5172,7 @@ function wppa_zoom_in( $id ) {
5172
  function wppa_get_rating_wait_text( $id, $user ) {
5173
  global $wpdb;
5174
 
5175
- $my_youngest_rating_dtm = $wpdb->get_var( $wpdb->prepare( "SELECT `timestamp` FROM `" . WPPA_RATING . "` WHERE `photo` = %s AND `user` = %s ORDER BY `timestamp` DESC LIMIT 1", $id, $user ) );
5176
 
5177
  if ( ! $my_youngest_rating_dtm ) return ''; // Not votes yet
5178
 
@@ -5327,11 +5327,11 @@ global $wpdb;
5327
  if ( ! empty( $comment_user->ID ) ) {
5328
  $ok_to_comment =
5329
  $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE user_id = %d AND comment_approved = '1'", $comment_user->ID ) ) +
5330
- $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "` WHERE `user` = %s AND `status` = 'approved'", $user ) );
5331
  } else {
5332
  $ok_to_comment =
5333
  $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 ) ) +
5334
- $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "` WHERE `email` = %s AND `status` = 'approved'", $email ) );
5335
  }
5336
  if ( ( $ok_to_comment >= 1 ) && ( empty( $mod_keys ) || false === strpos( $email, $mod_keys ) ) && ( empty( $blacklist_keys ) || false === strpos( $email, $blacklist_keys ) ) ) {
5337
  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.14
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", 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' );
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 );
431
  }
432
 
433
  // Get all albums and cache its data
434
+ $albs = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums", ARRAY_A );
435
  wppa_cache_album( 'add', $albs );
436
 
437
  // $cats is not empty. If it contains a , all cats must be met ( AND case )
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
  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
  }
1003
 
1004
  // If Catbox specifies a category to limit, remove all albums that do not have the desired cat.
1005
  if ( wppa( 'catbox' ) ) {
1006
+ $catalbs = $wpdb->get_col( "SELECT `id` FROM $wpdb->wppa_albums WHERE `cats` LIKE '%" . wppa( 'catbox' ) . "%' " );
1007
  $final_array = array_intersect( $final_array, $catalbs );
1008
  }
1009
 
1014
  }
1015
 
1016
  // Get them
1017
+ $albums = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums WHERE " . $selection . " " . wppa_get_album_order( '0' ), ARRAY_A );
1018
 
1019
  // Exclusive separate albums?
1020
  if ( wppa_switch( 'excl_sep' ) ) {
1057
  // Do the query
1058
  if ( $id == '-2' ) { // All albums
1059
  if ( wppa( 'is_cover' ) ) {
1060
+ $q = "SELECT * FROM $wpdb->wppa_albums ".wppa_get_album_order();
1061
  $albums = $wpdb->get_results( $q, ARRAY_A );
1062
  }
1063
  else $albums = false;
1064
  }
1065
  elseif ( wppa( 'last_albums' ) ) { // is_cover = true. For the order sequence, see remark in wppa_albums()
1066
  if ( wppa( 'last_albums_parent' ) ) {
1067
+ $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' ) );
1068
  }
1069
  else {
1070
+ $q = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums ORDER BY `timestamp` DESC LIMIT %d", wppa( 'last_albums' ) );
1071
  }
1072
  $albums = $wpdb->get_results( $q, ARRAY_A );
1073
  }
1083
  elseif ( strpos( $id, '.' ) !== false ) { // Album enum
1084
  $ids = wppa_series_to_array( $id );
1085
  if ( wppa( 'is_cover' ) ) {
1086
+ $q = "SELECT * FROM $wpdb->wppa_albums WHERE `id` = ".implode( " OR `id` = ", $ids )." ".wppa_get_album_order();
1087
  }
1088
  else {
1089
+ $q = "SELECT * FROM $wpdb->wppa_albums WHERE `a_parent` = ".implode( " OR `a_parent` = ", $ids )." ".wppa_get_album_order();
1090
  }
1091
  wppa_dbg_msg( $q, 'red' );
1092
  $albums = $wpdb->get_results( $q, ARRAY_A );
1185
 
1186
  // Single image slideshow?
1187
  if ( wppa( 'start_photo' ) && wppa( 'is_single' ) ) {
1188
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1189
  "WHERE `id` = %s", wppa( 'start_photo' ) );
1190
  }
1191
 
1194
  $status = "`status` <> 'pending' AND `status` <> 'scheduled'";
1195
  if ( ! is_user_logged_in() ) $status .= " AND `status` <> 'private'";
1196
 
1197
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1198
  "WHERE " . $album_clause . " AND `owner` = %s AND ( " . $status . " ) " .
1199
  "ORDER BY `timestamp` DESC", wppa( 'is_upldr' ) );
1200
  }
1225
  }
1226
  if ( ! is_user_logged_in() ) $status .= " AND `status` <> 'private'";
1227
 
1228
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1229
  "WHERE $album_clause AND ( $status ) " .
1230
  "ORDER BY $sortby LIMIT $max";
1231
 
1236
  elseif ( wppa( 'is_featen' ) ) {
1237
  $max = wppa( 'featen_count' );
1238
 
1239
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1240
  "WHERE $album_clause AND `status` = 'featured' " .
1241
  "ORDER BY RAND( " . wppa_get_randseed() . " ) DESC LIMIT $max";
1242
 
1257
 
1258
  if ( current_user_can( 'wppa_moderate' ) ) {
1259
 
1260
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1261
  "WHERE ( $album_clause ) " .
1262
  "AND ( $newtime ) " .
1263
  $owner_restriction .
1265
  }
1266
  else {
1267
 
1268
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1269
  "WHERE ( $album_clause ) AND ( $status ) AND ( $newtime ) " .
1270
  $owner_restriction .
1271
  "ORDER BY `$order_by` DESC LIMIT $max";
1276
  else {
1277
  if ( current_user_can( 'wppa_moderate' ) ) {
1278
 
1279
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1280
  "WHERE $album_clause " .
1281
  "ORDER BY `$order_by` DESC LIMIT $max";
1282
  }
1283
  else {
1284
 
1285
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1286
  "WHERE ( $album_clause ) AND ( $status ) " .
1287
  "ORDER BY `$order_by` DESC LIMIT $max";
1288
  }
1312
  // To keep the sequence ok ( in sequence of comments desc ), do the queries one by one
1313
  $thumbs = array();
1314
  if ( is_array( $photo_ids ) ) foreach( $photo_ids as $id ) {
1315
+ $temp = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE ".$status." AND `album` > '0' AND `id` = %s", $id ), ARRAY_A );
1316
  if ( $temp ) {
1317
  $thumbs[] = $temp;
1318
  }
1361
 
1362
  // Prepare the query
1363
  if ( current_user_can( 'wppa_moderate' ) ) {
1364
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1365
  "WHERE ( $tags_like ) " .
1366
  "AND $album_clause " .
1367
  wppa_get_photo_order( '0' );
1368
  }
1369
  else {
1370
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1371
  "WHERE ( $tags_like ) " .
1372
  "AND $album_clause " .
1373
  "AND $status " .
1401
  $is = 'LIKE';
1402
  }
1403
  if ( current_user_can( 'wppa_moderate' ) ) {
1404
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1405
  "WHERE `name` " . $is . " %s " .
1406
  "AND `album` > '0' " .
1407
  wppa_get_photo_order( '0' ), $data );
1408
  }
1409
  else {
1410
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1411
  "WHERE `name` " . $is . " %s " .
1412
  "AND `album` > '0' " .
1413
  "AND " . $status . " " .
1418
  // Owner
1419
  case 'o':
1420
  if ( current_user_can( 'wppa_moderate' ) ) {
1421
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1422
  "WHERE `owner` = %s " .
1423
  "AND `album` > '0' " .
1424
  wppa_get_photo_order( '0' ), $data );
1425
  }
1426
  else {
1427
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1428
  "WHERE `owner` = %s " .
1429
  "AND `album` > '0' " .
1430
  "AND " . $status . " " .
1448
  $tagids = $taglist[$data]['ids'];
1449
  }
1450
  if ( count( $tagids ) > '0' ) {
1451
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1452
  "WHERE ".$status." " .
1453
  "AND `id` IN (" . implode( ',',$tagids ) . ") " .
1454
  "AND `album` > '0' ";
1469
  $is = 'LIKE';
1470
  }
1471
  }
1472
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE `slug` ".$is." %s", $temp['0'] );
1473
  $indexes = $wpdb->get_results( $query, ARRAY_A );
1474
  $ids = array();
1475
  foreach( $indexes as $item ) {
1485
  }
1486
  }
1487
 
1488
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE `slug` ".$is." %s", $temp[$i] );
1489
  $indexes = $wpdb->get_results( $query, ARRAY_A );
1490
  $deltaids = array();
1491
  foreach( $indexes as $item ) {
1504
  $is = 'LIKE';
1505
  }
1506
  }
1507
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_index WHERE `slug` ".$is." %s", $data );
1508
  $indexes = $wpdb->get_results( $query, ARRAY_A );
1509
  $ids = array();
1510
  foreach( $indexes as $item ) {
1514
  if ( empty( $ids ) ) {
1515
  $ids = array( '0' ); // Dummy
1516
  }
1517
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1518
  "WHERE ".$status." " .
1519
  "AND `album` > '0' " .
1520
  "AND `id` IN (" . trim( implode( ',', $ids ), ',' ) . ")";
1524
  case 'i':
1525
  $itag = str_replace( 'H', '#', $ss_data['2'] );
1526
  $desc = $ss_data['3'];
1527
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_iptc " .
1528
  "WHERE `tag` = %s AND `description` = %s", $itag, $desc );
1529
  $iptclines = $wpdb->get_results( $query, ARRAY_A );
1530
  $ids = '0';
1531
  if ( is_array( $iptclines ) ) foreach( $iptclines as $item ) {
1532
  $ids .= ','.$item['photo'];
1533
  }
1534
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1535
  "WHERE ".$status." " .
1536
  "AND `album` > '0' " .
1537
  "AND `id` IN (" . $ids . ")";
1543
  $brand = substr( $ss_data[2], 6 );
1544
  $desc = $ss_data['3'];
1545
  // if ( $brand ) {
1546
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_exif " .
1547
  "WHERE `tag` = %s AND `f_description` = %s AND `brand` = %s", $etag, $desc, $brand );
1548
  // }
1549
  // else {
1550
+ // $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_exif " .
1551
  // "WHERE `tag` = %s AND `f_description` = %s", $etag, $desc );
1552
  // }
1553
  $exiflines = $wpdb->get_results( $query, ARRAY_A );
1555
  if ( is_array( $exiflines ) ) foreach( $exiflines as $item ) {
1556
  $ids .= ','.$item['photo'];
1557
  }
1558
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1559
  "WHERE ".$status." " .
1560
  "AND `album` > '0' " .
1561
  "AND `id` IN (" . $ids . ")";
1577
 
1578
  // Remove scheduled and pending and trashed when not can moderate
1579
  if ( ! current_user_can( 'wppa_moderate' ) ) {
1580
+ $needmod = $wpdb->get_col( "SELECT `id` FROM $wpdb->wppa_photos WHERE `status` = 'scheduled' OR `status` = 'pending' OR `album` <= '-9'" );
1581
  if ( is_array( $needmod ) ) {
1582
  $final_array = array_diff( $final_array, $needmod );
1583
  }
1585
 
1586
  // Remove private and trashed when not logged in
1587
  if ( ! is_user_logged_in() ) {
1588
+ $needlogin = $wpdb->get_col( "SELECT `id` FROM $wpdb->wppa_photos WHERE `status` = 'private' OR `album` <= '-9'" );
1589
  if ( is_array( $needlogin ) ) {
1590
  $final_array = array_diff( $final_array, $needlogin );
1591
  }
1615
  // Maybe cats limitation
1616
  elseif ( wppa( 'catbox' ) ) {
1617
 
1618
+ $catalbs = $wpdb->get_col( "SELECT `id` FROM $wpdb->wppa_albums WHERE `cats` LIKE '%" . wppa( 'catbox' ) . "%' " );
1619
 
1620
  if ( ! empty( $catalbs ) ) {
1621
  $alb_clause = " AND `album` IN ( " . implode( ',', $catalbs ) . " ) ";
1628
  // exclude separate if required
1629
  elseif ( ! $alb_clause && wppa_switch( 'excl_sep' ) ) {
1630
  $sep_albs = '';
1631
+ $temp = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums WHERE `a_parent` = '-1'", ARRAY_A );
1632
  if ( ! empty( $temp ) ) {
1633
  $t = array();
1634
  foreach ( $temp as $item ) {
1660
  }
1661
 
1662
  // Construct the query
1663
+ $query = "SELECT * FROM $wpdb->wppa_photos WHERE " . $selection . $alb_clause . wppa_get_photo_order( '0' ) . $limit;
1664
  }
1665
 
1666
  // Calendar?
1675
  switch ( wppa( 'calendar' ) ) {
1676
  case 'exifdtm':
1677
  $selection = "`exifdtm` LIKE '" . strip_tags( wppa( 'caldate' ) ) . "%' AND `status` <> 'pending' AND `status` <> 'scheduled' ";
1678
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1679
  "WHERE " . $selection . $alb_clause . $order;
1680
  break;
1681
 
1683
  $t1 = strval( intval( wppa( 'caldate' ) * 24*60*60 ) );
1684
  $t2 = $t1 + 24*60*60;
1685
  $selection = "`timestamp` >= $t1 AND `timestamp` < $t2 AND `status` <> 'pending' AND `status` <> 'scheduled' ";
1686
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1687
  "WHERE " . $selection . $alb_clause . $order;
1688
  break;
1689
 
1691
  $t1 = strval( intval( wppa( 'caldate' ) * 24*60*60 ) );
1692
  $t2 = $t1 + 24*60*60;
1693
  $selection = "`modified` >= $t1 AND `modified` < $t2 AND `status` <> 'pending' AND `status` <> 'scheduled' ";
1694
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1695
  "WHERE " . $selection . $alb_clause . $order;
1696
  break;
1697
  }
1720
  if ( wppa( 'start_album' ) == -2 ) {
1721
 
1722
  if ( current_user_can( 'wppa_moderate' ) ) {
1723
+ $query = "SELECT * FROM $wpdb->wppa_photos " . wppa_get_photo_order( '0' ) . $lim;
1724
  }
1725
  else {
1726
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1727
  "WHERE ( ( " . $status . " ) OR `owner` = %s ) " .
1728
  "AND `album` > '0' " .
1729
  wppa_get_photo_order( '0' ) .
1735
  // Single album ?
1736
  elseif ( wppa_is_int( wppa( 'start_album' ) ) ) {
1737
  if ( current_user_can( 'wppa_moderate' ) ) {
1738
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1739
  "WHERE `album` = " . wppa( 'start_album' ) . " " .
1740
  wppa_get_photo_order( wppa( 'start_album' ) ) .
1741
  $lim;
1742
  }
1743
  else {
1744
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1745
  "WHERE ( ( " . $status . " ) OR `owner` = %s ) AND `album` = " . wppa( 'start_album' ) . " " .
1746
  wppa_get_photo_order( wppa( 'start_album' ) ) .
1747
  $lim,
1753
  elseif ( is_array( $allalb ) ) {
1754
  $wherealbum = ' `album` IN (' . implode( ',', $allalb ) . ') ';
1755
  if ( current_user_can( 'wppa_moderate' ) ) {
1756
+ $query = "SELECT * FROM $wpdb->wppa_photos " .
1757
  "WHERE " . $wherealbum . " " .
1758
  wppa_get_photo_order( '0' ) .
1759
  $lim;
1760
  }
1761
  else {
1762
+ $query = $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos " .
1763
  "WHERE ( ( " . $status . " ) OR `owner` = %s ) AND " . $wherealbum . " " .
1764
  wppa_get_photo_order( '0' ) .
1765
  $lim,
1831
 
1832
  // Floating searchtoken?
1833
  if ( wppa_switch( 'wild_front' ) ) {
1834
+ $idxs = $wpdb->get_col( "SELECT `" . $type . "` FROM $wpdb->wppa_index WHERE `slug` LIKE '%" . $word . "%'" );
1835
  }
1836
  else {
1837
+ $idxs = $wpdb->get_col( "SELECT `" . $type . "` FROM $wpdb->wppa_index WHERE `slug` LIKE '" . $word . "%'" );
1838
  }
1839
 
1840
  // $item_array is an array of arrays with item ids per word.
1869
 
1870
  // Floating searchtoken?
1871
  if ( wppa_switch( 'wild_front' ) ) {
1872
+ $idxs = $wpdb->get_col( "SELECT `" . $type . "` FROM $wpdb->wppa_index WHERE `slug` LIKE '%" . $word . "%'" );
1873
  }
1874
  else {
1875
+ $idxs = $wpdb->get_col( "SELECT `" . $type . "` FROM $wpdb->wppa_index WHERE `slug` LIKE '" . $word . "%'" );
1876
  }
1877
 
1878
  // Find ids to exclude for the current !word
1957
 
1958
  // Inverse selection requested?
1959
  if ( $invers ) {
1960
+ $all = $wpdb->get_results( "SELECT `id`, `album` FROM $wpdb->wppa_photos ".wppa_get_photo_order( '0' ), ARRAY_A );
1961
  if ( is_array( $thumbs ) ) foreach ( array_keys($thumbs) as $thumbs_key ) {
1962
  foreach ( array_keys($all) as $all_key ) {
1963
  if ( $thumbs[$thumbs_key]['id'] == $all[$all_key]['id'] ) {
2003
  global $wpdb;
2004
 
2005
  $result = array();
2006
+ $albs = $wpdb->get_results( $wpdb->prepare( "SELECT `id` FROM $wpdb->wppa_albums WHERE `a_parent` = %s", $root ), ARRAY_A );
2007
  if ( ! $albs ) return $result;
2008
  foreach ( $albs as $alb ) {
2009
  $result[] = $alb['id'];
2432
  if ( $comment ) {
2433
  if ( $cedit ) {
2434
  $query = $wpdb->prepare(
2435
+ "UPDATE $wpdb->wppa_comments".
2436
  " SET `comment` = %s, `user` = %s, `email` = %s, `status` = %s, `timestamp` = %s " .
2437
  " WHERE `id` = %s LIMIT 1",
2438
  $save_comment,
2592
  if ( wppa_opt( 'comment_notify' ) == 'upload' || wppa_opt( 'comment_notify' ) == 'upadmin' || wppa_opt( 'comment_notify' ) == 'upowner' ) {
2593
 
2594
  // Mail uploader
2595
+ $uploader = $wpdb->get_var( $wpdb->prepare( "SELECT `owner` FROM $wpdb->wppa_photos WHERE `id` = %d", $id ) );
2596
  $moduser = wppa_get_user_by( 'login', $uploader );
2597
  if ( $moduser ) { // else it's an ip address ( anonymus uploader )
2598
  if ( ! in_array( $moduser->user_login, $sentto ) ) { // Already sent him?
2613
  }
2614
  if ( wppa_opt( 'comment_notify' ) == 'owner' || wppa_opt( 'comment_notify' ) == 'both' || wppa_opt( 'comment_notify' ) == 'upowner' ) {
2615
  // Mail album owner
2616
+ $alb = $wpdb->get_var( $wpdb->prepare( "SELECT `album` FROM $wpdb->wppa_photos WHERE `id` = %d", $id ) );
2617
+ $owner = $wpdb->get_var( $wpdb->prepare( "SELECT `owner` FROM $wpdb->wppa_albums WHERE `id` = %d", $alb ) );
2618
  if ( $owner == '--- public ---' ) $owner = 'admin';
2619
  $moduser = wppa_get_user_by( 'login', $owner );
2620
  if ( ! in_array( $moduser->user_login, $sentto ) ) { // Already sent him?
4114
  $children = $wppa_children[$id];
4115
  }
4116
  else {
4117
+ $children = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `a_parent` = %s", $id ), ARRAY_A );
4118
  $wppa_children[$id] = $children;
4119
  }
4120
 
4147
  $children = $wppa_children[$id];
4148
  }
4149
  else {
4150
+ $children = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_albums WHERE `a_parent` = %s", $id ), ARRAY_A );
4151
  $wppa_children[$id] = $children;
4152
  }
4153
 
4186
  }
4187
 
4188
  if ( $alb ) {
4189
+ $pid = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_photos WHERE `name` LIKE '%".$name."%' AND ( `album` = ".$alb." ) LIMIT 1" );
4190
  }
4191
  else {
4192
+ $pid = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_photos WHERE `name` LIKE '%".$name."%' LIMIT 1" );
4193
  }
4194
 
4195
  if ( $pid ) {
4217
  $name = str_replace( '"', '%', $name ); // A trick for double quotes
4218
  $name = stripslashes( $name );
4219
 
4220
+ $query = "SELECT * FROM $wpdb->wppa_albums WHERE `name` LIKE '%".$name."%'";
4221
  $albs = $wpdb->get_results( $query, ARRAY_A );
4222
 
4223
  if ( $albs ) {
4630
  $filename = wppa_strip_ext( $filename );
4631
 
4632
  // See if this filename with any extension already exists in this album
4633
+ $id = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM $wpdb->wppa_photos WHERE `filename` LIKE %s AND `album` = %s", $filename . '.%', $alb ) );
4634
 
4635
  // Addition to an av item?
4636
  if ( $id ) {
5012
  $limits = wppa_get_user_upload_limits();
5013
  }
5014
  else {
5015
+ $limits = $wpdb->get_var( $wpdb->prepare( "SELECT `upload_limit` FROM $wpdb->wppa_albums WHERE `id` = %s", $album ) );
5016
  }
5017
  $temp = explode( '/', $limits );
5018
  $limit_max = isset( $temp[0] ) ? $temp[0] : '0';
5024
 
5025
  if ( $user ) {
5026
  $owner = wppa_get_user( 'login' );
5027
+ $last_upload_time = $wpdb->get_var( $wpdb->prepare( "SELECT `timestamp` FROM $wpdb->wppa_photos WHERE `owner` = %s ORDER BY `timestamp` DESC LIMIT 1", $owner ) );
5028
  }
5029
  else {
5030
+ $last_upload_time = $wpdb->get_var( $wpdb->prepare( "SELECT `timestamp` FROM $wpdb->wppa_photos WHERE `album` = %s ORDER BY `timestamp` DESC LIMIT 1", $album ) );
5031
  }
5032
  $timnow = time();
5033
 
5172
  function wppa_get_rating_wait_text( $id, $user ) {
5173
  global $wpdb;
5174
 
5175
+ $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 ) );
5176
 
5177
  if ( ! $my_youngest_rating_dtm ) return ''; // Not votes yet
5178
 
5327
  if ( ! empty( $comment_user->ID ) ) {
5328
  $ok_to_comment =
5329
  $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE user_id = %d AND comment_approved = '1'", $comment_user->ID ) ) +
5330
+ $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_comments WHERE `user` = %s AND `status` = 'approved'", $user ) );
5331
  } else {
5332
  $ok_to_comment =
5333
  $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 ) ) +
5334
+ $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_comments WHERE `email` = %s AND `status` = 'approved'", $email ) );
5335
  }
5336
  if ( ( $ok_to_comment >= 1 ) && ( empty( $mod_keys ) || false === strpos( $email, $mod_keys ) ) && ( empty( $blacklist_keys ) || false === strpos( $email, $blacklist_keys ) ) ) {
5337
  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.7.04
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 `".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.14
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.8.13
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 `" . 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 `" . 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 `" . WPPA_ALBUMS . "` WHERE `id` = %s", $alb ) );
94
  if ( ! $exists ) update_option( 'wppa-audio-album-import-'.wppa_get_user(), '0' );
95
  }
96
 
@@ -1607,6 +1607,13 @@ function wppa_get_import_files() {
1607
  }
1608
  }
1609
 
 
 
 
 
 
 
 
1610
  // Sort to keep synchronicity when doing ajax import
1611
  if ( is_array( $files ) ) sort( $files );
1612
 
@@ -2443,13 +2450,13 @@ global $wppa_supported_audio_extensions;
2443
  $search = $data_arr[0];
2444
  switch ( strtolower($captions[0]) ) {
2445
  case 'photoname':
2446
- $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `name` = %s", $data_arr[0] ), ARRAY_A );
2447
  break;
2448
  case 'filename':
2449
- $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `filename` = %s", $data_arr[0] ), ARRAY_A );
2450
  break;
2451
  case 'name':
2452
- $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `name` = %s OR `filename` = %s", $data_arr[0], $data_arr[0] ), ARRAY_A );
2453
  break;
2454
  }
2455
  if ( $photos ) {
@@ -2919,7 +2926,7 @@ global $wppa_session;
2919
  $pagid = wp_insert_post( $my_post );
2920
  if ( $pagid ) {
2921
  wppa_ok_message( sprintf( __( 'Page <a href="%s" target="_blank" >%s</a> created.', 'wp-photo-album-plus'), home_url().'?page_id='.$pagid, $name ) );
2922
- $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_ALBUMS."` SET `cover_linkpage` = %s WHERE `id` = %s", $pagid, $alb ) );
2923
  }
2924
  else {
2925
  wppa_error_message( __( 'Could not create page.', 'wp-photo-album-plus') );
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the import pages and functions
6
+ * Version 6.9.14
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
 
1607
  }
1608
  }
1609
 
1610
+ // Security fix: remove paths with path traversal character sequences (../)
1611
+ if ( is_array( $files ) ) foreach ( array_keys( $files ) as $key ) {
1612
+ if ( strpos( $files[$key], '../' ) || strpos( $files[$key], '..\\' ) ) {
1613
+ unset( $files[$key] );
1614
+ }
1615
+ }
1616
+
1617
  // Sort to keep synchronicity when doing ajax import
1618
  if ( is_array( $files ) ) sort( $files );
1619
 
2450
  $search = $data_arr[0];
2451
  switch ( strtolower($captions[0]) ) {
2452
  case 'photoname':
2453
+ $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `name` = %s", $data_arr[0] ), ARRAY_A );
2454
  break;
2455
  case 'filename':
2456
+ $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `filename` = %s", $data_arr[0] ), ARRAY_A );
2457
  break;
2458
  case 'name':
2459
+ $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 );
2460
  break;
2461
  }
2462
  if ( $photos ) {
2926
  $pagid = wp_insert_post( $my_post );
2927
  if ( $pagid ) {
2928
  wppa_ok_message( sprintf( __( 'Page <a href="%s" target="_blank" >%s</a> created.', 'wp-photo-album-plus'), home_url().'?page_id='.$pagid, $name ) );
2929
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_albums SET `cover_linkpage` = %s WHERE `id` = %s", $pagid, $alb ) );
2930
  }
2931
  else {
2932
  wppa_error_message( __( 'Could not create page.', 'wp-photo-album-plus') );
wppa-index.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all indexing functions
6
- * Version 6.8.04
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 `" . 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 `" . 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 `" . 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 `" . 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 `" . 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 `" . WPPA_INDEX . "` SET `photos` = %s WHERE `id` = %s", $newphotos, $indexline['id'] ) );
147
  }
148
  }
149
 
@@ -432,7 +432,7 @@ global $wpdb;
432
  if ( $array[$k] == intval($id) ) {
433
  unset ( $array[$k] );
434
  $string = wppa_index_array_to_string($array);
435
- $wpdb->query( "UPDATE `".WPPA_INDEX."` SET `albums` = '".$string."' WHERE `id` = ".$indexline['id'] );
436
  }
437
  }
438
  }
@@ -452,7 +452,7 @@ global $wpdb;
452
  if ( $array[$k] == intval($id) ) {
453
  unset ( $array[$k] );
454
  $string = wppa_index_array_to_string($array);
455
- $wpdb->query( "UPDATE `".WPPA_INDEX."` SET `photos` = '".$string."' WHERE `id` = ".$indexline['id'] );
456
  }
457
  }
458
  }
@@ -520,7 +520,7 @@ global $wpdb;
520
 
521
  if ( wppa_switch( 'search_tags' ) ) $words .= ' '.$thumb['tags']; // Tags
522
  if ( wppa_switch( 'search_comments' ) ) {
523
- $coms = $wpdb->get_results($wpdb->prepare( "SELECT `comment` FROM `" . WPPA_COMMENTS . "` WHERE `photo` = %s AND `status` = 'approved'", $thumb['id'] ), ARRAY_A );
524
  if ( $coms ) {
525
  foreach ( $coms as $com ) {
526
  $words .= ' ' . stripslashes( $com['comment'] );
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all indexing functions
6
+ * Version 6.9.14
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
 
432
  if ( $array[$k] == intval($id) ) {
433
  unset ( $array[$k] );
434
  $string = wppa_index_array_to_string($array);
435
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_index SET `albums` = %s WHERE `id` = %d", $string, $indexline['id'] ) );
436
  }
437
  }
438
  }
452
  if ( $array[$k] == intval($id) ) {
453
  unset ( $array[$k] );
454
  $string = wppa_index_array_to_string($array);
455
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_index SET `photos` = %s WHERE `id` = %d", $string, $indexline['id'] ) );
456
  }
457
  }
458
  }
520
 
521
  if ( wppa_switch( 'search_tags' ) ) $words .= ' '.$thumb['tags']; // Tags
522
  if ( wppa_switch( 'search_comments' ) ) {
523
+ $coms = $wpdb->get_results($wpdb->prepare( "SELECT `comment` FROM $wpdb->wppa_comments WHERE `photo` = %s AND `status` = 'approved'", $thumb['id'] ), ARRAY_A );
524
  if ( $coms ) {
525
  foreach ( $coms as $com ) {
526
  $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.12
8
  */
9
 
10
  /* LOAD SIDEBAR WIDGETS */
@@ -71,7 +71,9 @@ if ( PHP_VERSION_ID >= 50300 ) require_once 'wppa-cloudinary.php';
71
 
72
  /* DO THE ADMIN/NON ADMIN SPECIFIC STUFF */
73
  if ( is_admin() ) require_once 'wppa-admin.php';
74
- else require_once 'wppa-non-admin.php';
 
 
75
 
76
  /* ADD AJAX */
77
  if ( defined( 'DOING_AJAX' ) ) {
@@ -265,7 +267,7 @@ global $wpdb;
265
 
266
  if ( current_user_can( 'wppa_settings' ) ) {
267
  if ( get_option( 'wppa_tags_ok' ) != '1' ) {
268
- $tag = $wpdb->get_var( "SELECT `tags` FROM `" . WPPA_PHOTOS . "` WHERE `tags` <> '' ORDER BY `id` DESC LIMIT 1" );
269
  if ( $tag ) {
270
  if ( substr( $tag, 0, 1 ) != ',' ) {
271
  add_action('admin_notices', 'wppa_tag_message');
@@ -287,7 +289,7 @@ global $wpdb;
287
 
288
  if ( current_user_can( 'wppa_settings' ) ) {
289
  if ( get_option( 'wppa_cats_ok' ) != '1' ) {
290
- $tag = $wpdb->get_var( "SELECT `cats` FROM `" . WPPA_ALBUMS . "` WHERE `cats` <> '' ORDER BY `id` DESC LIMIT 1" );
291
  if ( $tag ) {
292
  if ( substr( $tag, 0, 1 ) != ',' ) {
293
  add_action('admin_notices', 'wppa_cat_message');
4
  *
5
  * This file loads required php files and contains all functions used in init actions.
6
  *
7
+ * Version 6.9.14
8
  */
9
 
10
  /* LOAD SIDEBAR WIDGETS */
71
 
72
  /* DO THE ADMIN/NON ADMIN SPECIFIC STUFF */
73
  if ( is_admin() ) require_once 'wppa-admin.php';
74
+ if ( ! is_admin() || get_option( 'wppa_load_frontend_always' ) == 'yes' ) {
75
+ require_once 'wppa-non-admin.php';
76
+ }
77
 
78
  /* ADD AJAX */
79
  if ( defined( 'DOING_AJAX' ) ) {
267
 
268
  if ( current_user_can( 'wppa_settings' ) ) {
269
  if ( get_option( 'wppa_tags_ok' ) != '1' ) {
270
+ $tag = $wpdb->get_var( "SELECT `tags` FROM $wpdb->wppa_photos WHERE `tags` <> '' ORDER BY `id` DESC LIMIT 1" );
271
  if ( $tag ) {
272
  if ( substr( $tag, 0, 1 ) != ',' ) {
273
  add_action('admin_notices', 'wppa_tag_message');
289
 
290
  if ( current_user_can( 'wppa_settings' ) ) {
291
  if ( get_option( 'wppa_cats_ok' ) != '1' ) {
292
+ $tag = $wpdb->get_var( "SELECT `cats` FROM $wpdb->wppa_albums WHERE `cats` <> '' ORDER BY `id` DESC LIMIT 1" );
293
  if ( $tag ) {
294
  if ( substr( $tag, 0, 1 ) != ',' ) {
295
  add_action('admin_notices', 'wppa_cat_message');
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.02
7
  *
8
  */
9
 
@@ -26,12 +26,12 @@ static $album_cache_2;
26
  if ( empty( $album_cache_2 ) && ! is_admin() ) {
27
 
28
  // Find # of albums
29
- $n_albs = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "`" );
30
 
31
  if ( $n_albs && $n_albs < 1000 ) {
32
 
33
  // Get them all
34
- $allalbs = $wpdb->get_results( "SELECT * FROM `" . WPPA_ALBUMS ."`", ARRAY_A );
35
 
36
  // Store in 2nd level cache
37
  foreach( $allalbs as $album ) { // Add multiple
@@ -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 `".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 `".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.14
7
  *
8
  */
9
 
26
  if ( empty( $album_cache_2 ) && ! is_admin() ) {
27
 
28
  // Find # of albums
29
+ $n_albs = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_albums" );
30
 
31
  if ( $n_albs && $n_albs < 1000 ) {
32
 
33
  // Get them all
34
+ $allalbs = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums", ARRAY_A );
35
 
36
  // Store in 2nd level cache
37
  foreach( $allalbs as $album ) { // Add multiple
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.12
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 `" . WPPA_ALBUMS . "` WHERE `a_parent` = '0'", ARRAY_A );
67
  $album = '';
68
  foreach ( $albs as $alb ) {
69
  $album .= '.' . $alb['id'];
@@ -90,18 +90,18 @@ class LasTenWidget extends WP_Widget {
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 `".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 `".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 `".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 `".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.14
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'];
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.11
7
  *
8
  */
9
 
@@ -1481,7 +1481,7 @@ global $wpdb;
1481
 
1482
  // owner/public?
1483
  if ( $album == '-3' ) {
1484
- $temp = $wpdb->get_results( "SELECT `id` FROM `" . 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 ) {
3
  * Package: wp-photo-album-plus
4
  *
5
  * Frontend links
6
+ * Version 6.9.14
7
  *
8
  */
9
 
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 ) {
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.8.05
7
  *
8
  */
9
 
@@ -185,8 +185,8 @@ global $wppa_timestamp_start;
185
 
186
  // Pre-Clear album index only if not cron
187
  if ( ! wppa_is_cron() ) {
188
- $wpdb->query( "UPDATE `" . WPPA_INDEX . "` SET `albums` = ''" );
189
- $wpdb->query( "UPDATE `" . WPPA_ALBUMS . "` SET `indexdtm` = ''" );
190
  }
191
  wppa_index_compute_skips();
192
  break;
@@ -195,8 +195,8 @@ global $wppa_timestamp_start;
195
 
196
  // Pre-Clear photo index only if not cron
197
  if ( ! wppa_is_cron() ) {
198
- $wpdb->query( "UPDATE `" . WPPA_INDEX . "` SET `photos` = ''" );
199
- $wpdb->query( "UPDATE `" . WPPA_PHOTOS . "` SET `indexdtm` = ''" );
200
  }
201
  wppa_index_compute_skips();
202
  break;
@@ -209,8 +209,8 @@ global $wppa_timestamp_start;
209
 
210
  // Pre-Clear exif and iptc tables only if not cron
211
  if ( ! wppa_is_cron() ) {
212
- $wpdb->query( "TRUNCATE TABLE `" . WPPA_IPTC . "`" );
213
- $wpdb->query( "TRUNCATE TABLE `" . WPPA_EXIF . "`" );
214
  }
215
  break;
216
  case 'wppa_file_system':
@@ -219,7 +219,7 @@ global $wppa_timestamp_start;
219
  break;
220
  case 'wppa_cleanup':
221
  $orphan_album = get_option( 'wppa_orphan_album', '0' );
222
- $album_exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM`".WPPA_ALBUMS."` WHERE `id` = %s", $orphan_album ) );
223
  if ( ! $album_exists ) $orphan_album = false;
224
  if ( ! $orphan_album ) {
225
  $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') ) );
@@ -295,16 +295,16 @@ global $wppa_timestamp_start;
295
  $table = WPPA_ALBUMS;
296
 
297
  if ( $slug == 'wppa_remake_index_albums' ) {
298
- $topid = $wpdb->get_var( "SELECT `id` FROM `".WPPA_ALBUMS."` ORDER BY `id` DESC LIMIT 1" );
299
- $albums = $wpdb->get_results( "SELECT * FROM `" . WPPA_ALBUMS . "` " .
300
  "WHERE `id` > " . $lastid . " " .
301
  "AND `indexdtm` < `modified` " .
302
  "ORDER BY `id` " .
303
  "LIMIT 100", ARRAY_A );
304
  }
305
  else {
306
- $topid = $wpdb->get_var( "SELECT `id` FROM `".WPPA_ALBUMS."` ORDER BY `id` DESC LIMIT 1" );
307
- $albums = $wpdb->get_results( "SELECT * FROM `".WPPA_ALBUMS."` WHERE `id` > ".$lastid." ORDER BY `id` LIMIT 100", ARRAY_A );
308
  }
309
 
310
  wppa_cache_album( 'add', $albums );
@@ -324,14 +324,14 @@ global $wppa_timestamp_start;
324
  else {
325
  wppa_index_add( 'album', $id, 'force' );
326
  }
327
- $wpdb->query( "UPDATE `" . WPPA_ALBUMS . "` SET `indexdtm` = '" . time() . "' WHERE `id` = $id" );
328
  break;
329
 
330
  case 'wppa_remove_empty_albums':
331
- $p = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `album` = %s", $id ) );
332
- $a = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_ALBUMS."` WHERE `a_parent` = %s", $id ) );
333
  if ( ! $a && ! $p ) {
334
- $wpdb->query( $wpdb->prepare( "DELETE FROM `".WPPA_ALBUMS."` WHERE `id` = %s", $id ) );
335
  wppa_delete_album_source( $id );
336
  wppa_invalidate_treecounts( $id );
337
  wppa_index_remove( 'album', $id );
@@ -409,16 +409,16 @@ global $wppa_timestamp_start;
409
  }
410
  }
411
  elseif ( $slug == 'wppa_remake_index_photos' ) {
412
- $topid = $wpdb->get_var( "SELECT `id` FROM `".WPPA_PHOTOS."` ORDER BY `id` DESC LIMIT 1" );
413
- $photos = $wpdb->get_results( "SELECT * FROM `" . WPPA_PHOTOS . "` " .
414
  "WHERE `id` > " . $lastid . " " .
415
  "AND `indexdtm` < `modified` " .
416
  "ORDER BY `id` " .
417
  "LIMIT " . $chunksize, ARRAY_A );
418
  }
419
  else {
420
- $topid = $wpdb->get_var( "SELECT `id` FROM `".WPPA_PHOTOS."` ORDER BY `id` DESC LIMIT 1" );
421
- $photos = $wpdb->get_results( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `id` > ".$lastid." ORDER BY `id` LIMIT ".$chunksize, ARRAY_A );
422
  }
423
 
424
  if ( $slug == 'wppa_edit_tag' ) {
@@ -455,7 +455,7 @@ global $wppa_timestamp_start;
455
  else {
456
  wppa_index_add( 'photo', $id, 'force' );
457
  }
458
- $wpdb->query( "UPDATE `" . WPPA_PHOTOS . "` SET `indexdtm` = '" . time() . "' WHERE `id` = $id" );
459
  break;
460
 
461
  case 'wppa_apply_default_photoname_all':
@@ -467,7 +467,7 @@ global $wppa_timestamp_start;
467
  $value = wppa_opt( 'newphoto_description' );
468
  $description = trim( $value );
469
  if ( $description != $photo['description'] ) { // Modified photo description
470
- $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `description` = %s WHERE `id` = %s", $description, $id ) );
471
  }
472
  break;
473
 
@@ -476,7 +476,7 @@ global $wppa_timestamp_start;
476
  if ( ! $value ) return 'Unexpected error: missing text to append||'.$slug.'||Error||0';
477
  $description = rtrim( $photo['description'] . ' '. $value );
478
  if ( $description != $photo['description'] ) { // Modified photo description
479
- $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `description` = %s WHERE `id` = %s", $description, $id ) );
480
  }
481
  break;
482
 
@@ -485,7 +485,7 @@ global $wppa_timestamp_start;
485
  if ( ! $value ) return 'Unexpected error: missing text to remove||'.$slug.'||Error||0';
486
  $description = rtrim( str_replace( $value, '', $photo['description'] ) );
487
  if ( $description != $photo['description'] ) { // Modified photo description
488
- $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `description` = %s WHERE `id` = %s", $description, $id ) );
489
  }
490
  break;
491
 
@@ -493,7 +493,7 @@ global $wppa_timestamp_start;
493
  if ( ! wppa_is_video( $id ) ) {
494
  $name = str_replace( array( '.jpg', '.png', '.gif', '.JPG', '.PNG', '.GIF' ), '', $photo['name'] );
495
  if ( $name != $photo['name'] ) { // Modified photo name
496
- $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `name` = %s WHERE `id` = %s", $name, $id ) );
497
  }
498
  }
499
  break;
@@ -502,7 +502,7 @@ global $wppa_timestamp_start;
502
  if ( ! wppa_is_video( $id ) ) {
503
  $name = str_replace( array( '.jpg', '.png', 'gif', '.JPG', '.PNG', '.GIF' ), '', $photo['name'] );
504
  if ( $name == $photo['name'] ) { // Name had no fileextension
505
- $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `name` = %s WHERE `id` = %s", $name.'.'.$photo['ext'], $id ) );
506
  }
507
  }
508
  break;
@@ -622,7 +622,7 @@ global $wppa_timestamp_start;
622
  if ( $photo_files ) foreach( $photo_files as $photo_file ) {
623
  $basename = basename( $photo_file );
624
  $ext = substr( $basename, strpos( $basename, '.' ) + '1');
625
- if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $id ) ) ) { // no db entry for this photo
626
  if ( wppa_is_id_free( WPPA_PHOTOS, $id ) ) {
627
  if ( wppa_create_photo_entry( array( 'id' => $id, 'album' => $orphan_album, 'ext' => $ext, 'filename' => $basename ) ) ) { // Can create entry
628
  $wppa_session[$slug.'_fixed']++; // Bump counter
@@ -692,7 +692,7 @@ global $wppa_timestamp_start;
692
  while ( strlen( $name ) < $target_len ) $name = '0'.$name;
693
  }
694
  if ( $name !== $photo['name'] ) {
695
- $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `name` = %s WHERE `id` = %s", $name, $id ) );
696
  }
697
  break;
698
 
@@ -850,7 +850,7 @@ global $wppa_timestamp_start;
850
  $lastid = $id;
851
  update_option( $slug.'_last', $lastid );
852
  if ( wppa_is_cron() ) {
853
- $togo = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `id` > %s ", $lastid ) );
854
  if ( $togo ) {
855
  update_option( $slug.'_togo', $togo );
856
  update_option( $slug.'_status', 'Cron job' );
@@ -979,7 +979,7 @@ global $wppa_timestamp_start;
979
 
980
  // Update status
981
  if ( wppa_is_cron() ) {
982
- $togo = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `" . WPPA_INDEX . "` WHERE `id` > %s ", $lastid ) );
983
  if ( $togo ) {
984
  update_option( $slug.'_togo', $togo );
985
  update_option( $slug.'_status', 'Cron job' );
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains (not yet, but in the future maybe) all the maintenance routines
6
+ * Version 6.9.14
7
  *
8
  */
9
 
185
 
186
  // Pre-Clear album index only if not cron
187
  if ( ! wppa_is_cron() ) {
188
+ $wpdb->query( "UPDATE $wpdb->wppa_index SET `albums` = ''" );
189
+ $wpdb->query( "UPDATE $wpdb->wppa_albums SET `indexdtm` = ''" );
190
  }
191
  wppa_index_compute_skips();
192
  break;
195
 
196
  // Pre-Clear photo index only if not cron
197
  if ( ! wppa_is_cron() ) {
198
+ $wpdb->query( "UPDATE $wpdb->wppa_index SET `photos` = ''" );
199
+ $wpdb->query( "UPDATE $wpdb->wppa_photos SET `indexdtm` = ''" );
200
  }
201
  wppa_index_compute_skips();
202
  break;
209
 
210
  // Pre-Clear exif and iptc tables only if not cron
211
  if ( ! wppa_is_cron() ) {
212
+ $wpdb->query( "TRUNCATE TABLE $wpdb->wppa_iptc" );
213
+ $wpdb->query( "TRUNCATE TABLE $wpdb->wppa_exif" );
214
  }
215
  break;
216
  case 'wppa_file_system':
219
  break;
220
  case 'wppa_cleanup':
221
  $orphan_album = get_option( 'wppa_orphan_album', '0' );
222
+ $album_exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM$wpdb->wppa_albums WHERE `id` = %s", $orphan_album ) );
223
  if ( ! $album_exists ) $orphan_album = false;
224
  if ( ! $orphan_album ) {
225
  $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') ) );
295
  $table = WPPA_ALBUMS;
296
 
297
  if ( $slug == 'wppa_remake_index_albums' ) {
298
+ $topid = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_albums ORDER BY `id` DESC LIMIT 1" );
299
+ $albums = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums " .
300
  "WHERE `id` > " . $lastid . " " .
301
  "AND `indexdtm` < `modified` " .
302
  "ORDER BY `id` " .
303
  "LIMIT 100", ARRAY_A );
304
  }
305
  else {
306
+ $topid = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_albums ORDER BY `id` DESC LIMIT 1" );
307
+ $albums = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_albums WHERE `id` > ".$lastid." ORDER BY `id` LIMIT 100", ARRAY_A );
308
  }
309
 
310
  wppa_cache_album( 'add', $albums );
324
  else {
325
  wppa_index_add( 'album', $id, 'force' );
326
  }
327
+ $wpdb->query( "UPDATE $wpdb->wppa_albums SET `indexdtm` = '" . time() . "' WHERE `id` = $id" );
328
  break;
329
 
330
  case 'wppa_remove_empty_albums':
331
+ $p = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `album` = %s", $id ) );
332
+ $a = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE `a_parent` = %s", $id ) );
333
  if ( ! $a && ! $p ) {
334
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->wppa_albums WHERE `id` = %s", $id ) );
335
  wppa_delete_album_source( $id );
336
  wppa_invalidate_treecounts( $id );
337
  wppa_index_remove( 'album', $id );
409
  }
410
  }
411
  elseif ( $slug == 'wppa_remake_index_photos' ) {
412
+ $topid = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_photos ORDER BY `id` DESC LIMIT 1" );
413
+ $photos = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos " .
414
  "WHERE `id` > " . $lastid . " " .
415
  "AND `indexdtm` < `modified` " .
416
  "ORDER BY `id` " .
417
  "LIMIT " . $chunksize, ARRAY_A );
418
  }
419
  else {
420
+ $topid = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_photos ORDER BY `id` DESC LIMIT 1" );
421
+ $photos = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos WHERE `id` > ".$lastid." ORDER BY `id` LIMIT ".$chunksize, ARRAY_A );
422
  }
423
 
424
  if ( $slug == 'wppa_edit_tag' ) {
455
  else {
456
  wppa_index_add( 'photo', $id, 'force' );
457
  }
458
+ $wpdb->query( "UPDATE $wpdb->wppa_photos SET `indexdtm` = '" . time() . "' WHERE `id` = $id" );
459
  break;
460
 
461
  case 'wppa_apply_default_photoname_all':
467
  $value = wppa_opt( 'newphoto_description' );
468
  $description = trim( $value );
469
  if ( $description != $photo['description'] ) { // Modified photo description
470
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `description` = %s WHERE `id` = %s", $description, $id ) );
471
  }
472
  break;
473
 
476
  if ( ! $value ) return 'Unexpected error: missing text to append||'.$slug.'||Error||0';
477
  $description = rtrim( $photo['description'] . ' '. $value );
478
  if ( $description != $photo['description'] ) { // Modified photo description
479
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `description` = %s WHERE `id` = %s", $description, $id ) );
480
  }
481
  break;
482
 
485
  if ( ! $value ) return 'Unexpected error: missing text to remove||'.$slug.'||Error||0';
486
  $description = rtrim( str_replace( $value, '', $photo['description'] ) );
487
  if ( $description != $photo['description'] ) { // Modified photo description
488
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `description` = %s WHERE `id` = %s", $description, $id ) );
489
  }
490
  break;
491
 
493
  if ( ! wppa_is_video( $id ) ) {
494
  $name = str_replace( array( '.jpg', '.png', '.gif', '.JPG', '.PNG', '.GIF' ), '', $photo['name'] );
495
  if ( $name != $photo['name'] ) { // Modified photo name
496
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `name` = %s WHERE `id` = %s", $name, $id ) );
497
  }
498
  }
499
  break;
502
  if ( ! wppa_is_video( $id ) ) {
503
  $name = str_replace( array( '.jpg', '.png', 'gif', '.JPG', '.PNG', '.GIF' ), '', $photo['name'] );
504
  if ( $name == $photo['name'] ) { // Name had no fileextension
505
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `name` = %s WHERE `id` = %s", $name.'.'.$photo['ext'], $id ) );
506
  }
507
  }
508
  break;
622
  if ( $photo_files ) foreach( $photo_files as $photo_file ) {
623
  $basename = basename( $photo_file );
624
  $ext = substr( $basename, strpos( $basename, '.' ) + '1');
625
+ if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `id` = %s", $id ) ) ) { // no db entry for this photo
626
  if ( wppa_is_id_free( WPPA_PHOTOS, $id ) ) {
627
  if ( wppa_create_photo_entry( array( 'id' => $id, 'album' => $orphan_album, 'ext' => $ext, 'filename' => $basename ) ) ) { // Can create entry
628
  $wppa_session[$slug.'_fixed']++; // Bump counter
692
  while ( strlen( $name ) < $target_len ) $name = '0'.$name;
693
  }
694
  if ( $name !== $photo['name'] ) {
695
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `name` = %s WHERE `id` = %s", $name, $id ) );
696
  }
697
  break;
698
 
850
  $lastid = $id;
851
  update_option( $slug.'_last', $lastid );
852
  if ( wppa_is_cron() ) {
853
+ $togo = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `id` > %s ", $lastid ) );
854
  if ( $togo ) {
855
  update_option( $slug.'_togo', $togo );
856
  update_option( $slug.'_status', 'Cron job' );
979
 
980
  // Update status
981
  if ( wppa_is_cron() ) {
982
+ $togo = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_index WHERE `id` > %s ", $lastid ) );
983
  if ( $togo ) {
984
  update_option( $slug.'_togo', $togo );
985
  update_option( $slug.'_status', 'Cron job' );
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.12
7
  *
8
  */
9
 
@@ -165,7 +165,7 @@ echo '
165
 
166
  if ( $album ) {
167
  if ( wppa_switch( 'meta_page' ) ) {
168
- $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".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 `".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 -->");
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the non admin stuff
6
+ * Version 6.9.14
7
  *
8
  */
9
 
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 -->");
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.11
7
  *
8
  */
9
 
@@ -109,8 +109,8 @@ global $wpdb;
109
 
110
  // Edit trashed photos
111
  elseif ( $album == 'trash' ) {
112
- $count = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `album` < '0'" );
113
- $photos = $wpdb->get_results( "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` < '0' ORDER BY `modified` DESC " . $limit, ARRAY_A );
114
  // $count = count( $photos );
115
  $link = wppa_dbg_url( get_admin_url() . 'admin.php' .
116
  '?page=wppa_admin_menu' .
@@ -124,7 +124,7 @@ global $wpdb;
124
  elseif ( $album == 'single' ) {
125
  $p = strval( intval( $_REQUEST['photo'] ) );
126
  $count = $p ? 1 : 0;
127
- $photos = $wpdb->get_results( "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `id` = '$p'", ARRAY_A );
128
  $count = count( $photos );
129
  $link = '';
130
  }
@@ -134,7 +134,7 @@ global $wpdb;
134
  $counts = wppa_get_treecounts_a( $album, true );
135
  $count = $counts['selfphotos'] + $counts['pendselfphotos'] + $counts['scheduledselfphotos'];
136
  $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * " .
137
- "FROM `" . WPPA_PHOTOS . "` " .
138
  "WHERE `album` = %s " .
139
  wppa_get_photo_order( $album, 'norandom' ) .
140
  $limit,
@@ -154,7 +154,7 @@ global $wpdb;
154
  elseif ( $photo && ! $moderate ) {
155
  $count = '1';
156
  $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * " .
157
- "FROM `" . WPPA_PHOTOS . "` " .
158
  "WHERE `id` = %s",
159
  $photo
160
  ), ARRAY_A
@@ -165,13 +165,13 @@ global $wpdb;
165
  // Edit the photos of a specific owner
166
  elseif ( $owner ) {
167
  $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) " .
168
- "FROM `" . WPPA_PHOTOS . "` " .
169
  "WHERE `owner` = %s",
170
  $owner
171
  )
172
  );
173
  $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * " .
174
- "FROM `" . WPPA_PHOTOS . "` " .
175
  "WHERE `owner` = %s " .
176
  "ORDER BY `timestamp` DESC " .
177
  $limit,
@@ -193,7 +193,7 @@ global $wpdb;
193
  if ( $photo ) {
194
  $count = '1';
195
  $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * " .
196
- "FROM `" . WPPA_PHOTOS . "` " .
197
  "WHERE `id` = %s",
198
  $photo
199
  ), ARRAY_A
@@ -204,7 +204,7 @@ global $wpdb;
204
  // Are there photos with pending comments?
205
  else {
206
  $cmt = $wpdb->get_results( "SELECT `photo` " .
207
- "FROM `" . WPPA_COMMENTS . "` " .
208
  "WHERE `status` = 'pending' " .
209
  "OR `status` = 'spam'",
210
  ARRAY_A
@@ -213,17 +213,17 @@ global $wpdb;
213
  if ( $cmt ) {
214
  $orphotois = '';
215
  foreach ( $cmt as $c ) {
216
- $orphotois .= "OR `id` = " . $c['photo'] . " ";
217
  }
218
  }
219
  else $orphotois = '';
220
  $count = $wpdb->get_var( "SELECT COUNT(*) " .
221
- "FROM `" . WPPA_PHOTOS . "` " .
222
  "WHERE `status` = 'pending' " .
223
  $orphotois
224
  );
225
  $photos = $wpdb->get_results( "SELECT * " .
226
- "FROM `" . WPPA_PHOTOS . "` " .
227
  "WHERE `status` = 'pending' " . $orphotois . " " .
228
  "ORDER BY `album` DESC, `timestamp` DESC " .
229
  $limit, ARRAY_A
@@ -257,10 +257,10 @@ global $wpdb;
257
  __( 'Manage all photos by timestamp' , 'wp-photo-album-plus') .
258
  '</h3>';
259
  $count = $wpdb->get_var( "SELECT COUNT(*) " .
260
- "FROM `" . WPPA_PHOTOS . "`"
261
  );
262
  $photos = $wpdb->get_results( "SELECT * " .
263
- "FROM `" . WPPA_PHOTOS . "` " .
264
  "ORDER BY `timestamp` DESC" .
265
  $limit,
266
  ARRAY_A
@@ -2087,7 +2087,7 @@ function wppaToggleExif( id, count ) {
2087
 
2088
  // Exif
2089
  if ( ! $quick ) {
2090
- $exifs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `" . WPPA_EXIF . "` " .
2091
  "WHERE `photo` = %s " .
2092
  "ORDER BY `tag`, `id` ", $id ), ARRAY_A );
2093
  if ( ! empty( $exifs ) ) {
@@ -2158,7 +2158,7 @@ function wppaToggleExif( id, count ) {
2158
 
2159
  // Comments
2160
  if ( ! $quick ) {
2161
- $comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `" . WPPA_COMMENTS."` " .
2162
  "WHERE `photo` = %s " .
2163
  "ORDER BY `timestamp` DESC ", $id ), ARRAY_A );
2164
  if ( ! empty( $comments ) ) {
@@ -2270,9 +2270,9 @@ function wppa_album_photos_bulk( $album ) {
2270
  break;
2271
  case 'wppa-bulk-move-to':
2272
  if ( $newalb ) {
2273
- $photo = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM '.WPPA_PHOTOS.' WHERE `id` = %s', $id ), ARRAY_A );
2274
  if ( wppa_switch( 'void_dups' ) ) { // Check for already exists
2275
- $exists = $wpdb->get_var ( $wpdb->prepare ( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `filename` = %s AND `album` = %s", $photo['filename'], $newalb ) );
2276
  if ( $exists ) { // Already exists
2277
  wppa_error_message ( sprintf ( __( 'A photo with filename %s already exists in album %s.' , 'wp-photo-album-plus'), $photo['filename'], $newalb ) );
2278
  $skip = true;
@@ -2290,7 +2290,7 @@ function wppa_album_photos_bulk( $album ) {
2290
  if ( $newalb ) {
2291
  $photo = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM '.WPPA_PHOTOS.' WHERE `id` = %s', $id ), ARRAY_A );
2292
  if ( wppa_switch( 'void_dups' ) ) { // Check for already exists
2293
- $exists = $wpdb->get_var ( $wpdb->prepare ( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `filename` = %s AND `album` = %s", $photo['filename'], $newalb ) );
2294
  if ( $exists ) { // Already exists
2295
  wppa_error_message ( sprintf ( __( $exists.'A photo with filename %s already exists in album %s.' , 'wp-photo-album-plus'), $photo['filename'], $newalb ) );
2296
  $skip = true;
@@ -2309,7 +2309,7 @@ function wppa_album_photos_bulk( $album ) {
2309
  }
2310
  if ( current_user_can( 'wppa_admin' ) || current_user_can( 'wppa_moderate' ) ) {
2311
  if ( $status == 'publish' || $status == 'pending' || wppa_user_is( 'administrator' ) || ! wppa_switch( 'ext_status_restricted' ) ) {
2312
- $wpdb->query( "UPDATE `".WPPA_PHOTOS."` SET `status` = '".$status."' WHERE `id` = ".$id );
2313
  wppa_invalidate_treecounts( wppa_get_photo_item( $id, 'album' ) );
2314
  }
2315
  else wp_die( 'Security check failure 2' );
@@ -2322,7 +2322,7 @@ function wppa_album_photos_bulk( $album ) {
2322
  $owner = sanitize_user( $owner );
2323
  $exists = $wpdb->get_var( "SELECT COUNT(*) FROM `".$wpdb->users."` WHERE `user_login` = '".$owner."'" );
2324
  if ( $exists ) {
2325
- $wpdb->query( "UPDATE `".WPPA_PHOTOS."` SET `owner` = '".$owner."' WHERE `id` = ".$id );
2326
  }
2327
  else {
2328
  wppa_error_message( 'A user with login name '.$owner.' does not exist.' );
@@ -2391,7 +2391,7 @@ echo 'Page='.$page;
2391
  */
2392
  if ( $album ) {
2393
  if ( $album == 'moderate' ) {
2394
- $photos = $wpdb->get_results( "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status` = 'pending' ORDER BY `album` DESC, `timestamp` DESC " . $limit, ARRAY_A );
2395
  $count = count( $photos );
2396
  $link = wppa_dbg_url( get_admin_url().'admin.php?page=wppa_moderate_photos' );
2397
  }
@@ -3158,13 +3158,13 @@ global $wppa_search_stats;
3158
  }
3159
 
3160
  if ( current_user_can( 'wppa_admin' ) && current_user_can( 'wppa_moderate' ) ) {
3161
- $real_count = $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `id` IN (".$list.") " );
3162
  if ( $count != $real_count ) {
3163
  update_option( 'wppa_remake_index_photos_status', __('Required', 'wp-photo-album-plus') );
3164
  }
3165
  }
3166
  else { // Not admin, can edit own photos only
3167
- $real_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `id` IN (".$list.") AND `owner` = %s", wppa_get_user() ) );
3168
  }
3169
 
3170
  $wppa_search_stats[] = array( 'word' => $word, 'count' => $real_count );
@@ -3176,13 +3176,13 @@ global $wppa_search_stats;
3176
  $list = implode( ',', $temp_array );
3177
 
3178
  if ( current_user_can( 'wppa_admin' ) && current_user_can( 'wppa_moderate' ) ) {
3179
- $real_count = $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `id` IN (".$list.") " );
3180
  if ( $count != $real_count ) {
3181
  update_option( 'wppa_remake_index_photos_status', __('Required', 'wp-photo-album-plus') );
3182
  }
3183
  }
3184
  else { // Not admin, can edit own photos only
3185
- $real_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `id` IN (".$list.") AND `owner` = %s", wppa_get_user() ) );
3186
  }
3187
 
3188
  $wppa_search_stats[] = array( 'word' => $word, 'count' => $real_count );
@@ -3193,24 +3193,25 @@ global $wppa_search_stats;
3193
 
3194
  if ( ! empty( $photo_array ) ) {
3195
 
 
 
 
3196
  $list = implode( ',', $photo_array );
3197
 
3198
- // if ( wppa_user_is( 'administrator' ) ) {
3199
  if ( current_user_can( 'wppa_admin' ) && current_user_can( 'wppa_moderate' ) ) {
3200
- $totcount = $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `id` IN (".$list.") " );
3201
  }
3202
  else { // Not admin, can edit own photos only
3203
- $totcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `id` IN (".$list.") AND `owner` = %s" , wppa_get_user() ) );
3204
  }
3205
 
3206
  $wppa_search_stats[] = array( 'word' => __( 'Combined', 'wp-photo-album-plus'), 'count' => $totcount );
3207
 
3208
- // if ( wppa_user_is( 'administrator' ) ) {
3209
  if ( current_user_can( 'wppa_admin' ) && current_user_can( 'wppa_moderate' ) ) {
3210
- $photos = $wpdb->get_results( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `id` IN (".$list.") " . wppa_get_photo_order( '0', 'norandom' ).$limit, ARRAY_A );
3211
  }
3212
  else { // Not admin, can edit own photos only
3213
- $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `id` IN (".$list.") AND `owner` = %s" . wppa_get_photo_order( '0', 'norandom' ).$limit, wppa_get_user() ), ARRAY_A );
3214
  }
3215
  }
3216
  else {
3
  * Package: wp-photo-album-plus
4
  *
5
  * edit and delete photos
6
+ * Version 6.9.14
7
  *
8
  */
9
 
109
 
110
  // Edit trashed photos
111
  elseif ( $album == 'trash' ) {
112
+ $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `album` < '0'" );
113
+ $photos = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos WHERE `album` < '0' ORDER BY `modified` DESC " . $limit, ARRAY_A );
114
  // $count = count( $photos );
115
  $link = wppa_dbg_url( get_admin_url() . 'admin.php' .
116
  '?page=wppa_admin_menu' .
124
  elseif ( $album == 'single' ) {
125
  $p = strval( intval( $_REQUEST['photo'] ) );
126
  $count = $p ? 1 : 0;
127
+ $photos = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos WHERE `id` = '$p'", ARRAY_A );
128
  $count = count( $photos );
129
  $link = '';
130
  }
134
  $counts = wppa_get_treecounts_a( $album, true );
135
  $count = $counts['selfphotos'] + $counts['pendselfphotos'] + $counts['scheduledselfphotos'];
136
  $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * " .
137
+ "FROM $wpdb->wppa_photos " .
138
  "WHERE `album` = %s " .
139
  wppa_get_photo_order( $album, 'norandom' ) .
140
  $limit,
154
  elseif ( $photo && ! $moderate ) {
155
  $count = '1';
156
  $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * " .
157
+ "FROM $wpdb->wppa_photos " .
158
  "WHERE `id` = %s",
159
  $photo
160
  ), ARRAY_A
165
  // Edit the photos of a specific owner
166
  elseif ( $owner ) {
167
  $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) " .
168
+ "FROM $wpdb->wppa_photos " .
169
  "WHERE `owner` = %s",
170
  $owner
171
  )
172
  );
173
  $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * " .
174
+ "FROM $wpdb->wppa_photos " .
175
  "WHERE `owner` = %s " .
176
  "ORDER BY `timestamp` DESC " .
177
  $limit,
193
  if ( $photo ) {
194
  $count = '1';
195
  $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * " .
196
+ "FROM $wpdb->wppa_photos " .
197
  "WHERE `id` = %s",
198
  $photo
199
  ), ARRAY_A
204
  // Are there photos with pending comments?
205
  else {
206
  $cmt = $wpdb->get_results( "SELECT `photo` " .
207
+ "FROM $wpdb->wppa_comments " .
208
  "WHERE `status` = 'pending' " .
209
  "OR `status` = 'spam'",
210
  ARRAY_A
213
  if ( $cmt ) {
214
  $orphotois = '';
215
  foreach ( $cmt as $c ) {
216
+ $orphotois .= "OR `id` = '" . $c['photo'] . "' ";
217
  }
218
  }
219
  else $orphotois = '';
220
  $count = $wpdb->get_var( "SELECT COUNT(*) " .
221
+ "FROM $wpdb->wppa_photos " .
222
  "WHERE `status` = 'pending' " .
223
  $orphotois
224
  );
225
  $photos = $wpdb->get_results( "SELECT * " .
226
+ "FROM $wpdb->wppa_photos " .
227
  "WHERE `status` = 'pending' " . $orphotois . " " .
228
  "ORDER BY `album` DESC, `timestamp` DESC " .
229
  $limit, ARRAY_A
257
  __( 'Manage all photos by timestamp' , 'wp-photo-album-plus') .
258
  '</h3>';
259
  $count = $wpdb->get_var( "SELECT COUNT(*) " .
260
+ "FROM $wpdb->wppa_photos"
261
  );
262
  $photos = $wpdb->get_results( "SELECT * " .
263
+ "FROM $wpdb->wppa_photos " .
264
  "ORDER BY `timestamp` DESC" .
265
  $limit,
266
  ARRAY_A
2087
 
2088
  // Exif
2089
  if ( ! $quick ) {
2090
+ $exifs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_exif " .
2091
  "WHERE `photo` = %s " .
2092
  "ORDER BY `tag`, `id` ", $id ), ARRAY_A );
2093
  if ( ! empty( $exifs ) ) {
2158
 
2159
  // Comments
2160
  if ( ! $quick ) {
2161
+ $comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `" . WPPA_COMMENTS . "` " .
2162
  "WHERE `photo` = %s " .
2163
  "ORDER BY `timestamp` DESC ", $id ), ARRAY_A );
2164
  if ( ! empty( $comments ) ) {
2270
  break;
2271
  case 'wppa-bulk-move-to':
2272
  if ( $newalb ) {
2273
+ $photo = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `id` = %s", $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 ( __( 'A photo with filename %s already exists in album %s.' , 'wp-photo-album-plus'), $photo['filename'], $newalb ) );
2278
  $skip = true;
2290
  if ( $newalb ) {
2291
  $photo = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM '.WPPA_PHOTOS.' WHERE `id` = %s', $id ), ARRAY_A );
2292
  if ( wppa_switch( 'void_dups' ) ) { // Check for already exists
2293
+ $exists = $wpdb->get_var ( $wpdb->prepare ( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `filename` = %s AND `album` = %s", $photo['filename'], $newalb ) );
2294
  if ( $exists ) { // Already exists
2295
  wppa_error_message ( sprintf ( __( $exists.'A photo with filename %s already exists in album %s.' , 'wp-photo-album-plus'), $photo['filename'], $newalb ) );
2296
  $skip = true;
2309
  }
2310
  if ( current_user_can( 'wppa_admin' ) || current_user_can( 'wppa_moderate' ) ) {
2311
  if ( $status == 'publish' || $status == 'pending' || wppa_user_is( 'administrator' ) || ! wppa_switch( 'ext_status_restricted' ) ) {
2312
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `status` = %s WHERE `id` = %d", $status, $id ) );
2313
  wppa_invalidate_treecounts( wppa_get_photo_item( $id, 'album' ) );
2314
  }
2315
  else wp_die( 'Security check failure 2' );
2322
  $owner = sanitize_user( $owner );
2323
  $exists = $wpdb->get_var( "SELECT COUNT(*) FROM `".$wpdb->users."` WHERE `user_login` = '".$owner."'" );
2324
  if ( $exists ) {
2325
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `owner` = %s WHERE `id` = %d", $owner, $id ) );
2326
  }
2327
  else {
2328
  wppa_error_message( 'A user with login name '.$owner.' does not exist.' );
2391
  */
2392
  if ( $album ) {
2393
  if ( $album == 'moderate' ) {
2394
+ $photos = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos WHERE `status` = 'pending' ORDER BY `album` DESC, `timestamp` DESC " . $limit, ARRAY_A );
2395
  $count = count( $photos );
2396
  $link = wppa_dbg_url( get_admin_url().'admin.php?page=wppa_moderate_photos' );
2397
  }
3158
  }
3159
 
3160
  if ( current_user_can( 'wppa_admin' ) && current_user_can( 'wppa_moderate' ) ) {
3161
+ $real_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `id` IN (".$list.") " );
3162
  if ( $count != $real_count ) {
3163
  update_option( 'wppa_remake_index_photos_status', __('Required', 'wp-photo-album-plus') );
3164
  }
3165
  }
3166
  else { // Not admin, can edit own photos only
3167
+ $real_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `id` IN (".$list.") AND `owner` = %s", wppa_get_user() ) );
3168
  }
3169
 
3170
  $wppa_search_stats[] = array( 'word' => $word, 'count' => $real_count );
3176
  $list = implode( ',', $temp_array );
3177
 
3178
  if ( current_user_can( 'wppa_admin' ) && current_user_can( 'wppa_moderate' ) ) {
3179
+ $real_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `id` IN (".$list.") " );
3180
  if ( $count != $real_count ) {
3181
  update_option( 'wppa_remake_index_photos_status', __('Required', 'wp-photo-album-plus') );
3182
  }
3183
  }
3184
  else { // Not admin, can edit own photos only
3185
+ $real_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `id` IN (".$list.") AND `owner` = %s", wppa_get_user() ) );
3186
  }
3187
 
3188
  $wppa_search_stats[] = array( 'word' => $word, 'count' => $real_count );
3193
 
3194
  if ( ! empty( $photo_array ) ) {
3195
 
3196
+ foreach( array_keys( $photo_array ) as $key ) {
3197
+ $photo_array[$key] = "'" . strval( intval ( $photo_array[$key] ) ) . "'";
3198
+ }
3199
  $list = implode( ',', $photo_array );
3200
 
 
3201
  if ( current_user_can( 'wppa_admin' ) && current_user_can( 'wppa_moderate' ) ) {
3202
+ $totcount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `id` IN (".$list.") " );
3203
  }
3204
  else { // Not admin, can edit own photos only
3205
+ $totcount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `id` IN (".$list.") AND `owner` = %s" , wppa_get_user() ) );
3206
  }
3207
 
3208
  $wppa_search_stats[] = array( 'word' => __( 'Combined', 'wp-photo-album-plus'), 'count' => $totcount );
3209
 
 
3210
  if ( current_user_can( 'wppa_admin' ) && current_user_can( 'wppa_moderate' ) ) {
3211
+ $photos = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_photos WHERE `id` IN (".$list.") " . wppa_get_photo_order( '0', 'norandom' ).$limit, ARRAY_A );
3212
  }
3213
  else { // Not admin, can edit own photos only
3214
+ $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_photos WHERE `id` IN (".$list.") AND `owner` = %s" . wppa_get_photo_order( '0', 'norandom' ).$limit, wppa_get_user() ), ARRAY_A );
3215
  }
3216
  }
3217
  else {
wppa-photo-files.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-photo-files.php
3
  *
4
  * Functions used to create/manipulate photofiles
5
- * Version 6.9.13
6
  *
7
  */
8
 
@@ -680,7 +680,7 @@ function wppa_image_magick( $command ) {
680
  }
681
  $out = array();
682
  $err = 0;
683
- $run = exec( $path . $command, $out, $err );
684
 
685
  $logcom = $command;
686
  $logcom = str_replace( ABSPATH, '...', $logcom );
2
  /* wppa-photo-files.php
3
  *
4
  * Functions used to create/manipulate photofiles
5
+ * Version 6.9.14
6
  *
7
  */
8
 
680
  }
681
  $out = array();
682
  $err = 0;
683
+ $run = exec( escapeshellcmd( $path . $command ), $out, $err );
684
 
685
  $logcom = $command;
686
  $logcom = str_replace( ABSPATH, '...', $logcom );
wppa-potd-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the widget
6
- * Version 6.9.12
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 `" . 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.14
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.01
8
  */
9
 
10
  function wppa_comment_exporter( $email_address, $page = 1 ) {
@@ -17,7 +17,7 @@ global $wpdb;
17
  $group_id = 'wppa-comments';
18
  $group_label = __( 'Comments on photos', 'wp-photo-album-plus' );
19
  $comments = $wpdb->get_results( $wpdb->prepare(
20
- "SELECT * FROM `" . WPPA_COMMENTS . "` " .
21
  "WHERE `email` = %s " .
22
  "ORDER BY `id` " .
23
  "LIMIT %d,%d", $email_address, ( $page - 1 ) * $number, $number
@@ -78,11 +78,11 @@ function wppa_comment_eraser( $email_address, $page = 1 ) {
78
  global $wpdb;
79
 
80
  $count = $wpdb->get_var( $wpdb->prepare(
81
- "SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "` " .
82
  "WHERE `email` = %s ", $email_address ) );
83
 
84
  $wpdb->query( $wpdb->prepare(
85
- "DELETE FROM `" . WPPA_COMMENTS . "` " .
86
  "WHERE `email` = %s ", $email_address ) );
87
 
88
  wppa_log( 'obs', $count . ' comments found to remove' );
@@ -124,7 +124,7 @@ global $wpdb;
124
  $user = get_user_by( 'email', $email_address );
125
  $owner = $user->user_login;
126
  $ratings = $wpdb->get_results( $wpdb->prepare(
127
- "SELECT * FROM `" . WPPA_RATING . "` " .
128
  "WHERE `user` = %s " .
129
  "ORDER BY `id` " .
130
  "LIMIT %d,%d", $owner, ( $page - 1 ) * $number, $number
@@ -187,11 +187,11 @@ global $wpdb;
187
  $user = get_user_by( 'email', $email_address );
188
  $owner = $user->user_login;
189
  $count = $wpdb->get_var( $wpdb->prepare(
190
- "SELECT COUNT(*) FROM `" . WPPA_RATING . "` " .
191
  "WHERE `user` = %s ", $owner ) );
192
 
193
  $wpdb->query( $wpdb->prepare(
194
- "DELETE FROM `" . WPPA_RATING . "` " .
195
  "WHERE `user` = %s ", $owner ) );
196
 
197
  wppa_log( 'obs', $count . ' ratings found to remove' );
@@ -238,7 +238,7 @@ global $wpdb;
238
  $user = get_user_by( 'email', $email_address );
239
  $owner = $user->user_login;
240
  $media_items = $wpdb->get_results( $wpdb->prepare(
241
- "SELECT * FROM `" . WPPA_PHOTOS . "` " .
242
  "WHERE `owner` = %s " .
243
  "AND `album` > 0 " .
244
  "LIMIT %d,%d", $owner, ( $page - 1 ) * $number, $number
@@ -347,7 +347,7 @@ global $wpdb;
347
  }
348
 
349
  // Generic exif
350
- $exifs = $wpdb->get_results( "SELECT * FROM `" . WPPA_EXIF . "` " .
351
  "WHERE `photo` = " . $id . " " .
352
  "ORDER BY `tag`", ARRAY_A );
353
 
@@ -372,7 +372,7 @@ global $wpdb;
372
  }
373
 
374
  // Generic iptc
375
- $iptcs = $wpdb->get_results( "SELECT * FROM `" . WPPA_IPTC . "` " .
376
  "WHERE `photo` = " . $id . " " .
377
  "ORDER BY `tag`", ARRAY_A );
378
 
@@ -382,7 +382,7 @@ global $wpdb;
382
  $iptc_html .=
383
  '<tr>' .
384
  '<th>' .
385
- $wpdb->get_var( "SELECT `description` FROM `" . WPPA_IPTC . "` " .
386
  "WHERE `photo` = 0 AND `tag` = '" . $iptc['tag'] . "'" ) .
387
  '</th>' .
388
  '<td>' .
@@ -565,7 +565,7 @@ global $wpdb;
565
  $page = (int) $page;
566
  $user = get_user_by( 'email', $email_address );
567
  $media_items = $wpdb->get_results( $wpdb->prepare(
568
- "SELECT * FROM `" . WPPA_PHOTOS . "` " .
569
  "WHERE `owner` = %s " .
570
  "AND `album` > 0 " .
571
  "LIMIT %d,%d", $user->user_login, ( $page - 1 ) * $number, $number
@@ -579,7 +579,7 @@ global $wpdb;
579
  }
580
 
581
  $left_items = $wpdb->get_var( $wpdb->prepare(
582
- "SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` " .
583
  "WHERE `owner` = %s " .
584
  "AND `album` > 0 ",
585
  $user->user_login
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 ) {
17
  $group_id = 'wppa-comments';
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
78
  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' );
124
  $user = get_user_by( 'email', $email_address );
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
187
  $user = get_user_by( 'email', $email_address );
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' );
238
  $user = get_user_by( 'email', $email_address );
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
347
  }
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
 
372
  }
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
 
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>' .
565
  $page = (int) $page;
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
579
  }
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
wppa-session.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all session routines
6
- * Version 6.9.00
7
  *
8
  * Firefox modifies data in the superglobal $_SESSION.
9
  * See https://bugzilla.mozilla.org/show_bug.cgi?id=991019
@@ -37,17 +37,17 @@ global $wppa_session;
37
  $expire = time() - $lifetime;
38
 
39
  // Is session already started?
40
- $session = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".WPPA_SESSION."` WHERE `session` = %s AND `status` = 'valid' LIMIT 1", wppa_get_session_id() ), ARRAY_A );
41
 
42
  // Started but expired?
43
  if ( $session ) {
44
  if ( $session['timestamp'] < $expire ) {
45
 
46
- $wpdb->query( $wpdb->prepare( "UPDATE `" . WPPA_SESSION . "` SET `status` = 'expired' WHERE `id` = %s", $session['id'] ) );
47
  $session = false;
48
 
49
  // Anonimize all expired sessions, except robots (for the statistics widget)
50
- $wpdb->query( "UPDATE `" . WPPA_SESSION . "` " .
51
  "SET `ip` = '', `user` = '', `data` = '' " .
52
  "WHERE `status` = 'expired' " .
53
  "AND `data` NOT LIKE '%\"isrobot\";b:1;%'" );
@@ -94,7 +94,7 @@ global $wppa_session;
94
  else {
95
  $wppa_session = unserialize( $data );
96
 
97
- $wpdb->query( $wpdb->prepare( "UPDATE `" . WPPA_SESSION . "` SET `count` = %s WHERE `id` = %s", $session['count'] + '1', $session['id'] ) );
98
  }
99
 
100
  // Get info for root and sub search
@@ -189,7 +189,7 @@ static $last_query;
189
  }
190
 
191
  // Compose the query
192
- $query = $wpdb->prepare( "UPDATE `".WPPA_SESSION."` SET `data` = %s WHERE `id` = %s", serialize( $wppa_session ), $wppa_session['id'] );
193
 
194
  // Only update if data differs from previous update
195
  if ( $query != $last_query ) {
@@ -224,5 +224,5 @@ function wppa_extend_session() {
224
  global $wpdb;
225
 
226
  $sessionid = wppa_get_session_id();
227
- $wpdb->query( $wpdb->prepare( "UPDATE `" . WPPA_SESSION . "` SET `timestamp` = %d WHERE `session` = %s", time(), $sessionid ) );
228
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all session routines
6
+ * Version 6.9.14
7
  *
8
  * Firefox modifies data in the superglobal $_SESSION.
9
  * See https://bugzilla.mozilla.org/show_bug.cgi?id=991019
37
  $expire = time() - $lifetime;
38
 
39
  // Is session already started?
40
+ $session = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->wppa_session WHERE `session` = %s AND `status` = 'valid' LIMIT 1", wppa_get_session_id() ), ARRAY_A );
41
 
42
  // Started but expired?
43
  if ( $session ) {
44
  if ( $session['timestamp'] < $expire ) {
45
 
46
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_session SET `status` = 'expired' WHERE `id` = %s", $session['id'] ) );
47
  $session = false;
48
 
49
  // Anonimize all expired sessions, except robots (for the statistics widget)
50
+ $wpdb->query( "UPDATE $wpdb->wppa_session " .
51
  "SET `ip` = '', `user` = '', `data` = '' " .
52
  "WHERE `status` = 'expired' " .
53
  "AND `data` NOT LIKE '%\"isrobot\";b:1;%'" );
94
  else {
95
  $wppa_session = unserialize( $data );
96
 
97
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_session SET `count` = %s WHERE `id` = %s", $session['count'] + '1', $session['id'] ) );
98
  }
99
 
100
  // Get info for root and sub search
189
  }
190
 
191
  // Compose the query
192
+ $query = $wpdb->prepare( "UPDATE $wpdb->wppa_session SET `data` = %s WHERE `id` = %s", serialize( $wppa_session ), $wppa_session['id'] );
193
 
194
  // Only update if data differs from previous update
195
  if ( $query != $last_query ) {
224
  global $wpdb;
225
 
226
  $sessionid = wppa_get_session_id();
227
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_session SET `timestamp` = %d WHERE `session` = %s", time(), $sessionid ) );
228
  }
wppa-settings-autosave.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all options
6
- * Version 6.9.13
7
  *
8
  */
9
 
@@ -197,7 +197,7 @@ echo '<input type="button" vaue="Click me" onclick="wppaTimedConfirm( \'My Text\
197
  wppa_update_option( 'wppa_audiostub', 'audiostub'. $ext );
198
 
199
  // Thumbx, thumby, phtox and photoy must be cleared for the new stub
200
- $wpdb->query( "UPDATE `" . WPPA_PHOTOS ."` SET `thumbx` = 0, `thumby` = 0, `photox` = 0, `photoy` = 0 WHERE `ext` = 'xxx'" );
201
  wppa_alert( sprintf( __( 'Upload of %s done', 'wp-photo-album-plus'), basename( wppa_sima( $file['name'] ) ) ) );
202
  }
203
  }
@@ -258,7 +258,7 @@ echo '<input type="button" vaue="Click me" onclick="wppaTimedConfirm( \'My Text\
258
  } // wppa-settings-submit
259
 
260
  // Fix invalid ratings
261
- $iret = $wpdb->query( "DELETE FROM `".WPPA_RATING."` WHERE `value` = 0" );
262
  if ( $iret ) wppa_update_message( sprintf( __( '%s invalid ratings removed. Please run Table VIII-A5: Rerate to fix the averages.' , 'wp-photo-album-plus'), $iret ) );
263
 
264
  // Fix invalid source path
@@ -282,6 +282,9 @@ echo '<input type="button" vaue="Click me" onclick="wppaTimedConfirm( \'My Text\
282
  __( 'WP Charset:', 'wp-photo-album-plus') . ' ' . get_bloginfo( 'charset' ) . '. ' .
283
  __( 'Current PHP version:', 'wp-photo-album-plus' ) . ' ' . phpversion() . ' ' .
284
  __( 'WPPA+ API Version:', 'wp-photo-album-plus' ) . ' ' . $wppa_api_version . '.';
 
 
 
285
  ?>
286
  <br /><?php if ( is_multisite() ) {
287
  if ( WPPA_MULTISITE_GLOBAL ) {
@@ -350,7 +353,7 @@ echo '<input type="button" vaue="Click me" onclick="wppaTimedConfirm( \'My Text\
350
 
351
  // Check for 'many' albums
352
  if ( wppa_opt( 'photo_admin_max_albums' ) ) { // Not OFF
353
- $abs = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` " );
354
  if ( wppa_opt( 'photo_admin_max_albums' ) < $abs ) {
355
  wppa_warning_message( __( 'This system contains more albums than the maximum set in Table IX-B6.3.', 'wp-photo-album-plus' ) . ' ' .
356
  __( 'No problem, but some widgets may not work and some album selectionboxes will revert to a simple input field asking for an album id.', 'wp-photo-album-plus' ) . ' ' .
@@ -8528,6 +8531,16 @@ echo '<input type="button" vaue="Click me" onclick="wppaTimedConfirm( \'My Text\
8528
  $clas = '';
8529
  $tags = 'system';
8530
  wppa_setting($slug, '13', $name, $desc, $html, $help, $clas, $tags);
 
 
 
 
 
 
 
 
 
 
8531
  }
8532
  wppa_setting_subheader( 'B', '1', __( 'WPPA+ Admin related miscellaneous settings' , 'wp-photo-album-plus') );
8533
  {
@@ -9004,7 +9017,7 @@ echo '<input type="button" vaue="Click me" onclick="wppaTimedConfirm( \'My Text\
9004
  $slug = 'wppa_default_parent';
9005
  $opts = array( __('--- none ---', 'wp-photo-album-plus'), __('--- separate ---', 'wp-photo-album-plus') );
9006
  $vals = array( '0', '-1');
9007
- $albs = $wpdb->get_results( "SELECT `id`, `name` FROM `" . WPPA_ALBUMS . "` ORDER BY `name`", ARRAY_A );
9008
  if ( $albs ) {
9009
  foreach ( $albs as $alb ) {
9010
  $opts[] = __(stripslashes($alb['name']), 'wp-photo-album-plus');
@@ -9080,7 +9093,7 @@ echo '<input type="button" vaue="Click me" onclick="wppaTimedConfirm( \'My Text\
9080
  $slug = 'wppa_grant_parent';
9081
  $opts = array( __('--- none ---', 'wp-photo-album-plus'), __('--- separate ---', 'wp-photo-album-plus') );
9082
  $vals = array( 'zero', '-1');
9083
- $albs = $wpdb->get_results( "SELECT `id`, `name` FROM`" . WPPA_ALBUMS . "` ORDER BY `name`", ARRAY_A );
9084
  if ( $albs ) {
9085
  foreach ( $albs as $alb ) {
9086
  $opts[] = __(stripslashes($alb['name']), 'wp-photo-album-plus');
@@ -9697,7 +9710,7 @@ echo '<input type="button" vaue="Click me" onclick="wppaTimedConfirm( \'My Text\
9697
  $desc = __('A real life preview. To update: refresh the page.', 'wp-photo-album-plus');
9698
  $help = '';
9699
  $slug = 'wppa_watermark_preview';
9700
- $id = $wpdb->get_var( "SELECT `id` FROM `".WPPA_PHOTOS."` ORDER BY RAND() LIMIT 1" );
9701
  $tr = floor( 127 * ( 100 - wppa_opt( 'watermark_opacity_text' ) ) / 100 );
9702
  $args = array( 'id' => $id, 'content' => '---predef---', 'pos' => 'cencen', 'url' => true, 'width' => '1000', 'height' => '400', 'transp' => $tr );
9703
  $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>';
@@ -10490,7 +10503,7 @@ echo '<input type="button" vaue="Click me" onclick="wppaTimedConfirm( \'My Text\
10490
  $html = wppa_input( $slug, '220', __('Enter album ids separated by commas','wp-photo-album-plus' ) );
10491
  }
10492
  else {
10493
- $albums = $wpdb->get_results( "SELECT `id`, `name` FROM `" . WPPA_ALBUMS . "`", ARRAY_A );
10494
  $albums = wppa_add_paths( $albums );
10495
  $albums = wppa_array_sort( $albums, 'name' );
10496
  $opts = array();
@@ -10570,7 +10583,7 @@ echo '<input type="button" vaue="Click me" onclick="wppaTimedConfirm( \'My Text\
10570
 
10571
  $wppa_subtable = 'Z';
10572
 
10573
- $labels = $wpdb->get_results( "SELECT * FROM `".WPPA_IPTC."` WHERE `photo` = '0' ORDER BY `tag`", ARRAY_A );
10574
  if ( is_array( $labels ) ) {
10575
  $i = '1';
10576
  foreach ( $labels as $label ) {
@@ -10638,7 +10651,7 @@ echo '<input type="button" vaue="Click me" onclick="wppaTimedConfirm( \'My Text\
10638
  '<b></span>');
10639
  }
10640
 
10641
- $labels = $wpdb->get_results( "SELECT * FROM `".WPPA_EXIF."` WHERE `photo` = '0' ORDER BY `tag`", ARRAY_A);
10642
  if ( is_array( $labels ) ) {
10643
  $i = '1';
10644
  foreach ( $labels as $label ) {
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all options
6
+ * Version 6.9.14
7
  *
8
  */
9
 
197
  wppa_update_option( 'wppa_audiostub', 'audiostub'. $ext );
198
 
199
  // Thumbx, thumby, phtox and photoy must be cleared for the new stub
200
+ $wpdb->query( "UPDATE $wpdb->wppa_photos SET `thumbx` = 0, `thumby` = 0, `photox` = 0, `photoy` = 0 WHERE `ext` = 'xxx'" );
201
  wppa_alert( sprintf( __( 'Upload of %s done', 'wp-photo-album-plus'), basename( wppa_sima( $file['name'] ) ) ) );
202
  }
203
  }
258
  } // wppa-settings-submit
259
 
260
  // Fix invalid ratings
261
+ $iret = $wpdb->query( "DELETE FROM `" . WPPA_RATING . "` WHERE `value` = 0" );
262
  if ( $iret ) wppa_update_message( sprintf( __( '%s invalid ratings removed. Please run Table VIII-A5: Rerate to fix the averages.' , 'wp-photo-album-plus'), $iret ) );
263
 
264
  // Fix invalid source path
282
  __( 'WP Charset:', 'wp-photo-album-plus') . ' ' . get_bloginfo( 'charset' ) . '. ' .
283
  __( 'Current PHP version:', 'wp-photo-album-plus' ) . ' ' . phpversion() . ' ' .
284
  __( 'WPPA+ API Version:', 'wp-photo-album-plus' ) . ' ' . $wppa_api_version . '.';
285
+ if ( function_exists( 'wppa_shortcodes' ) ) {
286
+ echo ' ' . __( 'Front-end code loaded', 'wp-photo-album-plus' );
287
+ }
288
  ?>
289
  <br /><?php if ( is_multisite() ) {
290
  if ( WPPA_MULTISITE_GLOBAL ) {
353
 
354
  // Check for 'many' albums
355
  if ( wppa_opt( 'photo_admin_max_albums' ) ) { // Not OFF
356
+ $abs = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_albums " );
357
  if ( wppa_opt( 'photo_admin_max_albums' ) < $abs ) {
358
  wppa_warning_message( __( 'This system contains more albums than the maximum set in Table IX-B6.3.', 'wp-photo-album-plus' ) . ' ' .
359
  __( 'No problem, but some widgets may not work and some album selectionboxes will revert to a simple input field asking for an album id.', 'wp-photo-album-plus' ) . ' ' .
8531
  $clas = '';
8532
  $tags = 'system';
8533
  wppa_setting($slug, '13', $name, $desc, $html, $help, $clas, $tags);
8534
+
8535
+ $name = __('Load front-end code always', 'wp-photo-album-plus');
8536
+ $desc = __('Load front-end code also on admin pages', 'wp-photo-album-plus');
8537
+ $help = '';
8538
+ $slug = 'wppa_load_frontend_always';
8539
+ $html = wppa_checkbox($slug);
8540
+ $clas = '';
8541
+ $tags = 'system';
8542
+ wppa_setting($slug, '14', $name, $desc, $html, $help, $clas, $tags);
8543
+
8544
  }
8545
  wppa_setting_subheader( 'B', '1', __( 'WPPA+ Admin related miscellaneous settings' , 'wp-photo-album-plus') );
8546
  {
9017
  $slug = 'wppa_default_parent';
9018
  $opts = array( __('--- none ---', 'wp-photo-album-plus'), __('--- separate ---', 'wp-photo-album-plus') );
9019
  $vals = array( '0', '-1');
9020
+ $albs = $wpdb->get_results( "SELECT `id`, `name` FROM $wpdb->wppa_albums ORDER BY `name`", ARRAY_A );
9021
  if ( $albs ) {
9022
  foreach ( $albs as $alb ) {
9023
  $opts[] = __(stripslashes($alb['name']), 'wp-photo-album-plus');
9093
  $slug = 'wppa_grant_parent';
9094
  $opts = array( __('--- none ---', 'wp-photo-album-plus'), __('--- separate ---', 'wp-photo-album-plus') );
9095
  $vals = array( 'zero', '-1');
9096
+ $albs = $wpdb->get_results( "SELECT `id`, `name` FROM $wpdb->wppa_albums ORDER BY `name`", ARRAY_A );
9097
  if ( $albs ) {
9098
  foreach ( $albs as $alb ) {
9099
  $opts[] = __(stripslashes($alb['name']), 'wp-photo-album-plus');
9710
  $desc = __('A real life preview. To update: refresh the page.', 'wp-photo-album-plus');
9711
  $help = '';
9712
  $slug = 'wppa_watermark_preview';
9713
+ $id = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_photos ORDER BY RAND() LIMIT 1" );
9714
  $tr = floor( 127 * ( 100 - wppa_opt( 'watermark_opacity_text' ) ) / 100 );
9715
  $args = array( 'id' => $id, 'content' => '---predef---', 'pos' => 'cencen', 'url' => true, 'width' => '1000', 'height' => '400', 'transp' => $tr );
9716
  $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>';
10503
  $html = wppa_input( $slug, '220', __('Enter album ids separated by commas','wp-photo-album-plus' ) );
10504
  }
10505
  else {
10506
+ $albums = $wpdb->get_results( "SELECT `id`, `name` FROM $wpdb->wppa_albums", ARRAY_A );
10507
  $albums = wppa_add_paths( $albums );
10508
  $albums = wppa_array_sort( $albums, 'name' );
10509
  $opts = array();
10583
 
10584
  $wppa_subtable = 'Z';
10585
 
10586
+ $labels = $wpdb->get_results( "SELECT * FROM `" . WPPA_IPTC . "` WHERE `photo` = '0' ORDER BY `tag`", ARRAY_A );
10587
  if ( is_array( $labels ) ) {
10588
  $i = '1';
10589
  foreach ( $labels as $label ) {
10651
  '<b></span>');
10652
  }
10653
 
10654
+ $labels = $wpdb->get_results( "SELECT * FROM `" . WPPA_EXIF . "` WHERE `photo` = '0' ORDER BY `tag`", ARRAY_A);
10655
  if ( is_array( $labels ) ) {
10656
  $i = '1';
10657
  foreach ( $labels as $label ) {
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.11
7
  *
8
  */
9
 
@@ -379,13 +379,13 @@ global $silent;
379
  }
380
 
381
  if ( $old_rev <= '6310' ) {
382
- $wpdb->query("UPDATE `".WPPA_PHOTOS."` SET `timestamp` = '0' WHERE `timestamp` = ''");
383
- $wpdb->query("UPDATE `".WPPA_PHOTOS."` SET `modified` = `timestamp` WHERE `modified` = '' OR `modified` = '0'");
384
  }
385
 
386
  if ( $old_rev <= '6312' ) {
387
- $wpdb->query("UPDATE `".WPPA_ALBUMS."` SET `timestamp` = '0' WHERE `timestamp` = ''");
388
- $wpdb->query("UPDATE `".WPPA_ALBUMS."` SET `modified` = `timestamp` WHERE `modified` = '' OR `modified` = '0'");
389
  wppa_copy_setting( 'wppa_wppa_set_shortcodes', 'wppa_set_shortcodes' );
390
  wppa_remove_setting( 'wppa_wppa_set_shortcodes' );
391
  wppa_copy_setting( 'wppa_max_album_newtime', 'wppa_max_album_modtime' );
@@ -551,9 +551,9 @@ global $silent;
551
  }
552
 
553
  if ( $old_rev <= '6800' ) {
554
- $wpdb->query( "ALTER TABLE `" . WPPA_IPTC . "` MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT" );
555
- $wpdb->query( "ALTER TABLE `" . WPPA_EXIF . "` MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT" );
556
- $wpdb->query( "ALTER TABLE `" . WPPA_INDEX . "` MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT" );
557
  delete_option( 'wppa_' . WPPA_IPTC . '_lastkey' );
558
  delete_option( 'wppa_' . WPPA_EXIF . '_lastkey' );
559
  delete_option( 'wppa_' . WPPA_INDEX . '_lastkey' );
@@ -564,11 +564,11 @@ global $silent;
564
  // Fix exiflables that were undefined so far but have a known description by now
565
  if ( $old_rev <= '6801' ) {
566
  if ( function_exists( 'exif_tagname' ) && function_exists( 'exif_read_data' ) ) {
567
- $exif_labels = $wpdb->get_results( "SELECT * FROM `" . WPPA_EXIF . "` WHERE `photo` = 0 AND `description` LIKE 'UndefinedTag%'", ARRAY_A );
568
  if ( ! empty( $exif_labels ) ) foreach( $exif_labels as $label ) {
569
  $newdesc = wppa_exif_tagname( $label['tag'] );
570
  if ( $newdesc != $label['description'] ) {
571
- $wpdb->query( $wpdb->prepare( "UPDATE `" . WPPA_EXIF . "` SET `description` = %s WHERE `photo` = 0 AND `tag` = %s", $newdesc, $label['tag'] ) );
572
  wppa_log( 'obs', 'There is a new desc for '.$label['tag'].' being: '.$newdesc );
573
  }
574
  }
@@ -1669,6 +1669,7 @@ cursorborder:'2px solid transparent',";
1669
 
1670
  'wppa_login_url' => site_url( 'wp-login.php', 'login' ), // A
1671
  'wppa_cache_root' => 'cache',
 
1672
 
1673
 
1674
  // IX D New
@@ -2086,7 +2087,7 @@ static $user;
2086
 
2087
  // The option hold a category
2088
  $grant_parents = $wpdb->get_col( "SELECT `id` " .
2089
- "FROM `" . WPPA_ALBUMS . "` " .
2090
  "WHERE `cats` LIKE '%," . wppa_opt( 'grant_parent' ) . ",%'"
2091
  );
2092
  if ( empty( $grant_parents ) ) {
@@ -2097,7 +2098,7 @@ static $user;
2097
 
2098
  case 'indexsearch':
2099
  $temp = $wpdb->get_var( "SELECT `albums` " .
2100
- "FROM `" . WPPA_INDEX . "` " .
2101
  "WHERE `slug` = '" . wppa_opt( 'grant_parent' ) . "'"
2102
  );
2103
 
@@ -2118,7 +2119,7 @@ static $user;
2118
 
2119
  // Get all the parents of the current user albums if not done already
2120
  if ( ! is_array( $my_albs_parents ) ) {
2121
- $query = $wpdb->prepare( "SELECT DISTINCT `a_parent` FROM `" . WPPA_ALBUMS . "` WHERE `owner` = %s", $owner );
2122
  $my_albs_parents = $wpdb->get_col( $query );
2123
  if ( ! is_array( $my_albs_parents ) ) {
2124
  $my_albs_parents = array();
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the setup stuff
6
+ * Version 6.9.14
7
  *
8
  */
9
 
379
  }
380
 
381
  if ( $old_rev <= '6310' ) {
382
+ $wpdb->query("UPDATE $wpdb->wppa_photos SET `timestamp` = '0' WHERE `timestamp` = ''");
383
+ $wpdb->query("UPDATE $wpdb->wppa_photos SET `modified` = `timestamp` WHERE `modified` = '' OR `modified` = '0'");
384
  }
385
 
386
  if ( $old_rev <= '6312' ) {
387
+ $wpdb->query("UPDATE $wpdb->wppa_albums SET `timestamp` = '0' WHERE `timestamp` = ''");
388
+ $wpdb->query("UPDATE $wpdb->wppa_albums SET `modified` = `timestamp` WHERE `modified` = '' OR `modified` = '0'");
389
  wppa_copy_setting( 'wppa_wppa_set_shortcodes', 'wppa_set_shortcodes' );
390
  wppa_remove_setting( 'wppa_wppa_set_shortcodes' );
391
  wppa_copy_setting( 'wppa_max_album_newtime', 'wppa_max_album_modtime' );
551
  }
552
 
553
  if ( $old_rev <= '6800' ) {
554
+ $wpdb->query( "ALTER TABLE $wpdb->wppa_iptc MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT" );
555
+ $wpdb->query( "ALTER TABLE $wpdb->wppa_exif MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT" );
556
+ $wpdb->query( "ALTER TABLE $wpdb->wppa_index MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT" );
557
  delete_option( 'wppa_' . WPPA_IPTC . '_lastkey' );
558
  delete_option( 'wppa_' . WPPA_EXIF . '_lastkey' );
559
  delete_option( 'wppa_' . WPPA_INDEX . '_lastkey' );
564
  // Fix exiflables that were undefined so far but have a known description by now
565
  if ( $old_rev <= '6801' ) {
566
  if ( function_exists( 'exif_tagname' ) && function_exists( 'exif_read_data' ) ) {
567
+ $exif_labels = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_exif WHERE `photo` = 0 AND `description` LIKE 'UndefinedTag%'", ARRAY_A );
568
  if ( ! empty( $exif_labels ) ) foreach( $exif_labels as $label ) {
569
  $newdesc = wppa_exif_tagname( $label['tag'] );
570
  if ( $newdesc != $label['description'] ) {
571
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_exif SET `description` = %s WHERE `photo` = 0 AND `tag` = %s", $newdesc, $label['tag'] ) );
572
  wppa_log( 'obs', 'There is a new desc for '.$label['tag'].' being: '.$newdesc );
573
  }
574
  }
1669
 
1670
  'wppa_login_url' => site_url( 'wp-login.php', 'login' ), // A
1671
  'wppa_cache_root' => 'cache',
1672
+ 'wppa_load_frontend_always' => 'no',
1673
 
1674
 
1675
  // IX D New
2087
 
2088
  // The option hold a category
2089
  $grant_parents = $wpdb->get_col( "SELECT `id` " .
2090
+ "FROM $wpdb->wppa_albums " .
2091
  "WHERE `cats` LIKE '%," . wppa_opt( 'grant_parent' ) . ",%'"
2092
  );
2093
  if ( empty( $grant_parents ) ) {
2098
 
2099
  case 'indexsearch':
2100
  $temp = $wpdb->get_var( "SELECT `albums` " .
2101
+ "FROM $wpdb->wppa_index " .
2102
  "WHERE `slug` = '" . wppa_opt( 'grant_parent' ) . "'"
2103
  );
2104
 
2119
 
2120
  // Get all the parents of the current user albums if not done already
2121
  if ( ! is_array( $my_albs_parents ) ) {
2122
+ $query = $wpdb->prepare( "SELECT DISTINCT `a_parent` FROM $wpdb->wppa_albums WHERE `owner` = %s", $owner );
2123
  $my_albs_parents = $wpdb->get_col( $query );
2124
  if ( ! is_array( $my_albs_parents ) ) {
2125
  $my_albs_parents = array();
wppa-statistics.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * Functions for counts etc
6
  * Common use front and admin
7
- * Version 6.7.02
8
  *
9
  */
10
 
@@ -53,10 +53,10 @@ global $wpdb;
53
  }
54
  elseif ( ! $id ) {
55
  if ( current_user_can('wppa_moderate') ) {
56
- $count = $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` " );
57
  }
58
  else {
59
- $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s )", wppa_get_user() ) );
60
  }
61
  }
62
  else {
@@ -74,7 +74,7 @@ global $wpdb;
74
 
75
  // Substract private photos if not logged in and album given
76
  if ( $id && ! is_user_logged_in() ) {
77
- $count -= $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `album` = %s AND `status` = 'private' ", $id ) );
78
  }
79
  return $count;
80
  }
@@ -100,7 +100,7 @@ global $wpdb;
100
  static $count;
101
 
102
  if ( ! $count ) {
103
- $count = $wpdb->get_var("SELECT COUNT(*) FROM `".WPPA_ALBUMS."`");
104
  }
105
 
106
  return $count;
@@ -123,7 +123,7 @@ global $wpdb;
123
  // Admin, do not look to owner
124
  if ( wppa_user_is( 'administrator' ) ) {
125
  $result = $wpdb->get_var( "SELECT COUNT(*) " .
126
- "FROM `" . WPPA_ALBUMS . "` " .
127
  ( $where ? "WHERE " . $where : "" )
128
  );
129
  }
@@ -131,7 +131,7 @@ global $wpdb;
131
  // Owner or public
132
  elseif ( wppa_switch( 'upload_owner_only' ) ) {
133
  $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) " .
134
- "FROM `" . WPPA_ALBUMS . "` " .
135
  "WHERE `owner` = '--- public ---' OR `owner` = %s" .
136
  ( $where ? "AND " . $where : "" ),
137
  wppa_get_user()
@@ -142,7 +142,7 @@ global $wpdb;
142
  // No upload owners only
143
  else {
144
  $result = $wpdb->get_var( "SELECT COUNT(*) " .
145
- "FROM `" . WPPA_ALBUMS . "` " .
146
  ( $where ? "WHERE " . $where : "" )
147
  );
148
  }
@@ -178,7 +178,7 @@ global $wpdb;
178
  function wppa_get_youngest_album_id() {
179
  global $wpdb;
180
 
181
- $result = $wpdb->get_var( "SELECT `id` FROM `" . WPPA_ALBUMS . "` ORDER BY `timestamp` DESC, `id` DESC LIMIT 1" );
182
 
183
  return $result;
184
  }
@@ -187,7 +187,7 @@ global $wpdb;
187
  function wppa_get_youngest_album_name() {
188
  global $wpdb;
189
 
190
- $result = $wpdb->get_var( "SELECT `name` FROM `" . WPPA_ALBUMS . "` ORDER BY `timestamp` DESC, `id` DESC LIMIT 1" );
191
 
192
  return stripslashes($result);
193
  }
@@ -215,9 +215,9 @@ global $wppa_session;
215
  // Remember click and update photodata, only if first time
216
  if ( ! isset( $wppa_session['click'][$id] ) ) {
217
  $wppa_session['click'][$id] = true;
218
- $count = $wpdb->get_var( "SELECT `clicks` FROM `" . WPPA_PHOTOS . "` WHERE `id` = $id" );
219
  $count++;
220
- $wpdb->query( "UPDATE `" . WPPA_PHOTOS . "` SET `clicks` = $count WHERE `id` = $id" );
221
 
222
  // Invalidate cache
223
  wppa_cache_photo( 'invalidate', $id );
@@ -251,13 +251,16 @@ global $wppa_session;
251
  }
252
  if ( ! isset($wppa_session[$type][$id] ) ) { // This one not done yest
253
  $wppa_session[$type][$id] = true; // Mark as viewed
254
- if ( $type == 'album' ) $table = WPPA_ALBUMS; else $table = WPPA_PHOTOS;
255
-
256
- $count = $wpdb->get_var("SELECT `views` FROM `".$table."` WHERE `id` = ".$id);
257
- $count++;
258
-
259
- $wpdb->query("UPDATE `".$table."` SET `views` = ".$count." WHERE `id` = ".$id);
260
- wppa_log( 'dbg', 'Bumped viewcount for '.$type.' '.$id.' to '.$count );
 
 
 
261
 
262
  // If 'wppa_owner_to_name'
263
  if ( $type == 'photo' ) {
@@ -321,7 +324,7 @@ function wppa_flush_upldr_cache( $key = '', $id = '' ) {
321
  function wppa_get_random_photo_id_from_youngest_album() {
322
  global $wpdb;
323
 
324
- $albums = $wpdb->get_col( "SELECT `id` FROM `" . WPPA_ALBUMS . "` ORDER BY `timestamp` DESC" );
325
  $found = false;
326
  $count = count( $albums );
327
  $idx = 0;
@@ -329,7 +332,7 @@ global $wpdb;
329
 
330
  while ( ! $found && $idx < $count ) {
331
  $album = $albums[$idx];
332
- $result = $wpdb->get_var( "SELECT `id` FROM `" . WPPA_PHOTOS ."` WHERE `album` = $album ORDER BY RAND() LIMIT 1" );
333
  if ( $result ) {
334
  $found = true;
335
  }
@@ -357,7 +360,7 @@ global $wpdb;
357
 
358
  // No album id, flush them all
359
  else {
360
- $iret = $wpdb->query( "UPDATE `" . WPPA_ALBUMS . "` SET `treecounts` = ''" );
361
  if ( ! $iret ) {
362
  wppa_log( 'Dbg', 'Unable to clear all treecounts' );
363
  }
@@ -387,7 +390,7 @@ global $wpdb;
387
 
388
  // Get the ids of the child albums
389
  $child_ids = $wpdb->get_col( "SELECT `id` " .
390
- "FROM `" . WPPA_ALBUMS . "` " .
391
  "WHERE `a_parent` = $alb"
392
  );
393
 
@@ -415,7 +418,7 @@ global $wpdb;
415
 
416
  // Self albums
417
  $result['selfalbums'] = $wpdb->get_var( "SELECT COUNT(*) " .
418
- "FROM `" . WPPA_ALBUMS . "` " .
419
  "WHERE `a_parent` = $alb "
420
  );
421
 
@@ -430,7 +433,7 @@ global $wpdb;
430
 
431
  // Self photos
432
  $result['selfphotos'] = $wpdb->get_var( "SELECT COUNT(*) " .
433
- "FROM `" . WPPA_PHOTOS . "` " .
434
  "WHERE `album` = $alb " .
435
  "AND `status` <> 'pending' " .
436
  "AND `status` <> 'scheduled'"
@@ -447,7 +450,7 @@ global $wpdb;
447
 
448
  // Pending self photos
449
  $result['pendselfphotos'] = $wpdb->get_var( "SELECT COUNT(*) " .
450
- "FROM `" . WPPA_PHOTOS . "` " .
451
  "WHERE `album` = $alb " .
452
  "AND `status` = 'pending'"
453
  );
@@ -463,7 +466,7 @@ global $wpdb;
463
 
464
  // Scheduled self photos
465
  $result['scheduledselfphotos'] = $wpdb->get_var( "SELECT COUNT(*) " .
466
- "FROM `" . WPPA_PHOTOS . "` " .
467
  "WHERE `album` = $alb " .
468
  "AND `status` = 'scheduled'"
469
  );
@@ -478,7 +481,7 @@ global $wpdb;
478
  }
479
 
480
  // Self photo views
481
- $views = $wpdb->get_col( "SELECT `views` FROM `" . WPPA_PHOTOS . "` WHERE `album` = $alb" );
482
  $result['selfphotoviews'] = array_sum( $views );
483
 
484
  // Tree photo views
@@ -547,7 +550,7 @@ global $wpdb;
547
  $result = serialize( $result );
548
 
549
  // Manually update. If used wppa_update_album, remake index would be triggered
550
- $iret = $wpdb->query( "UPDATE `" . WPPA_ALBUMS . "` SET `treecounts` = '$result' WHERE `id` = $alb" );
551
  wppa_cache_album( 'invalidate', $alb );
552
  }
553
  }
4
  *
5
  * Functions for counts etc
6
  * Common use front and admin
7
+ * Version 6.9.14
8
  *
9
  */
10
 
53
  }
54
  elseif ( ! $id ) {
55
  if ( current_user_can('wppa_moderate') ) {
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 {
74
 
75
  // Substract private photos if not logged in and album given
76
  if ( $id && ! is_user_logged_in() ) {
77
+ $count -= $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `album` = %s AND `status` = 'private' ", $id ) );
78
  }
79
  return $count;
80
  }
100
  static $count;
101
 
102
  if ( ! $count ) {
103
+ $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->wppa_albums");
104
  }
105
 
106
  return $count;
123
  // Admin, do not look to owner
124
  if ( wppa_user_is( 'administrator' ) ) {
125
  $result = $wpdb->get_var( "SELECT COUNT(*) " .
126
+ "FROM $wpdb->wppa_albums " .
127
  ( $where ? "WHERE " . $where : "" )
128
  );
129
  }
131
  // Owner or public
132
  elseif ( wppa_switch( 'upload_owner_only' ) ) {
133
  $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) " .
134
+ "FROM $wpdb->wppa_albums " .
135
  "WHERE `owner` = '--- public ---' OR `owner` = %s" .
136
  ( $where ? "AND " . $where : "" ),
137
  wppa_get_user()
142
  // No upload owners only
143
  else {
144
  $result = $wpdb->get_var( "SELECT COUNT(*) " .
145
+ "FROM $wpdb->wppa_albums " .
146
  ( $where ? "WHERE " . $where : "" )
147
  );
148
  }
178
  function wppa_get_youngest_album_id() {
179
  global $wpdb;
180
 
181
+ $result = $wpdb->get_var( "SELECT `id` FROM $wpdb->wppa_albums ORDER BY `timestamp` DESC, `id` DESC LIMIT 1" );
182
 
183
  return $result;
184
  }
187
  function wppa_get_youngest_album_name() {
188
  global $wpdb;
189
 
190
+ $result = $wpdb->get_var( "SELECT `name` FROM $wpdb->wppa_albums ORDER BY `timestamp` DESC, `id` DESC LIMIT 1" );
191
 
192
  return stripslashes($result);
193
  }
215
  // Remember click and update photodata, only if first time
216
  if ( ! isset( $wppa_session['click'][$id] ) ) {
217
  $wppa_session['click'][$id] = true;
218
+ $count = $wpdb->get_var( "SELECT `clicks` FROM $wpdb->wppa_photos WHERE `id` = $id" );
219
  $count++;
220
+ $wpdb->query( "UPDATE $wpdb->wppa_photos SET `clicks` = $count WHERE `id` = $id" );
221
 
222
  // Invalidate cache
223
  wppa_cache_photo( 'invalidate', $id );
251
  }
252
  if ( ! isset($wppa_session[$type][$id] ) ) { // This one not done yest
253
  $wppa_session[$type][$id] = true; // Mark as viewed
254
+ if ( $type == 'album' ) {
255
+ $count = $wpdb->get_var( $wpdb->prepare( "SELECT `views` FROM $wpdb->wppa_albums WHERE `id` = %d", $id ) );
256
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_albums SET `views` = %d WHERE `id` = %d", $count+1, $id ) );
257
+ wppa_log( 'dbg', 'Bumped viewcount for album ' . $id . ' to ' . $count );
258
+ }
259
+ else {
260
+ $count = $wpdb->get_var( $wpdb->prepare( "SELECT `views` FROM $wpdb->wppa_photos WHERE `id` = %d", $id ) );
261
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `views` = %d WHERE `id` = %d", $count+1, $id ) );
262
+ wppa_log( 'dbg', 'Bumped viewcount for photo ' . $id . ' to ' . $count );
263
+ }
264
 
265
  // If 'wppa_owner_to_name'
266
  if ( $type == 'photo' ) {
324
  function wppa_get_random_photo_id_from_youngest_album() {
325
  global $wpdb;
326
 
327
+ $albums = $wpdb->get_col( "SELECT `id` FROM $wpdb->wppa_albums ORDER BY `timestamp` DESC" );
328
  $found = false;
329
  $count = count( $albums );
330
  $idx = 0;
332
 
333
  while ( ! $found && $idx < $count ) {
334
  $album = $albums[$idx];
335
+ $result = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM $wpdb->wppa_photos WHERE `album` = %d ORDER BY RAND() LIMIT 1", $album ) );
336
  if ( $result ) {
337
  $found = true;
338
  }
360
 
361
  // No album id, flush them all
362
  else {
363
+ $iret = $wpdb->query( "UPDATE $wpdb->wppa_albums SET `treecounts` = ''" );
364
  if ( ! $iret ) {
365
  wppa_log( 'Dbg', 'Unable to clear all treecounts' );
366
  }
390
 
391
  // Get the ids of the child albums
392
  $child_ids = $wpdb->get_col( "SELECT `id` " .
393
+ "FROM $wpdb->wppa_albums " .
394
  "WHERE `a_parent` = $alb"
395
  );
396
 
418
 
419
  // Self albums
420
  $result['selfalbums'] = $wpdb->get_var( "SELECT COUNT(*) " .
421
+ "FROM $wpdb->wppa_albums " .
422
  "WHERE `a_parent` = $alb "
423
  );
424
 
433
 
434
  // Self photos
435
  $result['selfphotos'] = $wpdb->get_var( "SELECT COUNT(*) " .
436
+ "FROM $wpdb->wppa_photos " .
437
  "WHERE `album` = $alb " .
438
  "AND `status` <> 'pending' " .
439
  "AND `status` <> 'scheduled'"
450
 
451
  // Pending self photos
452
  $result['pendselfphotos'] = $wpdb->get_var( "SELECT COUNT(*) " .
453
+ "FROM $wpdb->wppa_photos " .
454
  "WHERE `album` = $alb " .
455
  "AND `status` = 'pending'"
456
  );
466
 
467
  // Scheduled self photos
468
  $result['scheduledselfphotos'] = $wpdb->get_var( "SELECT COUNT(*) " .
469
+ "FROM $wpdb->wppa_photos " .
470
  "WHERE `album` = $alb " .
471
  "AND `status` = 'scheduled'"
472
  );
481
  }
482
 
483
  // Self photo views
484
+ $views = $wpdb->get_col( "SELECT `views` FROM $wpdb->wppa_photos WHERE `album` = $alb" );
485
  $result['selfphotoviews'] = array_sum( $views );
486
 
487
  // Tree photo views
550
  $result = serialize( $result );
551
 
552
  // Manually update. If used wppa_update_album, remake index would be triggered
553
+ $iret = $wpdb->query( "UPDATE $wpdb->wppa_albums SET `treecounts` = '$result' WHERE `id` = $alb" );
554
  wppa_cache_album( 'invalidate', $alb );
555
  }
556
  }
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.12
7
  *
8
  */
9
  class WppaStatsWidget extends WP_Widget {
@@ -63,13 +63,13 @@ 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 `" . 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 `" . WPPA_SESSION . "` WHERE `timestamp` > '" . $t . "'" );
72
- $robots = $wpdb->get_var( "SELECT COUNT(*) FROM `" . 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
  }
@@ -78,26 +78,26 @@ class WppaStatsWidget extends WP_Widget {
78
  $widget_content .= __('Number of registered users', 'wp-photo-album-plus') . ': <b>' . $users . '</b><br />';
79
  }
80
  if ( wppa_checked( $instance['albums'] ) ) {
81
- $albums = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "`" );
82
  if ( $albums ) {
83
  $widget_content .= __('Number of albums', 'wp-photo-album-plus') . ': <b>' . $albums . '</b><br />';
84
  }
85
  }
86
  if ( wppa_checked( $instance['mediaitems'] ) ) {
87
- $items = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "`" );
88
  if ( $items ) {
89
  $widget_content .= __('Number of media items', 'wp-photo-album-plus') . ': <b>' . $items . '</b><br />';
90
  }
91
  }
92
  if ( wppa_checked( $instance['photos'] ) ) {
93
- $photos = $wpdb->get_var( "SELECT COUNT(*) FROM `" . 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 `" . 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 `" . WPPA_PHOTOS . "` WHERE `ext` = 'xxx'" );
112
  }
113
  $cnt = 0;
114
  foreach( $multi as $item ) {
@@ -119,19 +119,19 @@ class WppaStatsWidget extends WP_Widget {
119
  }
120
  }
121
  if ( wppa_checked( $instance['pdfs'] ) && wppa_can_pdf() ) {
122
- $pdfs = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `filename` LIKE '%.pdf'" );
123
  if ( $pdfs ) {
124
  $widget_content .= __('Number of pdfs', 'wp-photo-album-plus') . ': <b>' . $pdfs . '</b><br />';
125
  }
126
  }
127
  if ( wppa_checked( $instance['comments'] ) && wppa_switch( 'show_comments' ) ) {
128
- $comments = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "`" );
129
  if ( $comments ) {
130
  $widget_content .= __('Number of comments', 'wp-photo-album-plus') . ': <b>' . $comments . '</b><br />';
131
  }
132
  }
133
  if ( wppa_checked( $instance['rating'] ) && wppa_switch( 'rating_on' ) ) {
134
- $ratings = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPPA_RATING . "`" );
135
  if ( $ratings ) {
136
  $widget_content .= __('Number of ratings', 'wp-photo-album-plus') . ': <b>' . $ratings . '</b><br />';
137
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the stats widget
6
+ * Version 6.9.14
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
  }
78
  $widget_content .= __('Number of registered users', 'wp-photo-album-plus') . ': <b>' . $users . '</b><br />';
79
  }
80
  if ( wppa_checked( $instance['albums'] ) ) {
81
+ $albums = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_albums" );
82
  if ( $albums ) {
83
  $widget_content .= __('Number of albums', 'wp-photo-album-plus') . ': <b>' . $albums . '</b><br />';
84
  }
85
  }
86
  if ( wppa_checked( $instance['mediaitems'] ) ) {
87
+ $items = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos" );
88
  if ( $items ) {
89
  $widget_content .= __('Number of media items', 'wp-photo-album-plus') . ': <b>' . $items . '</b><br />';
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
  }
126
  }
127
  if ( wppa_checked( $instance['comments'] ) && wppa_switch( 'show_comments' ) ) {
128
+ $comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_comments" );
129
  if ( $comments ) {
130
  $widget_content .= __('Number of comments', 'wp-photo-album-plus') . ': <b>' . $comments . '</b><br />';
131
  }
132
  }
133
  if ( wppa_checked( $instance['rating'] ) && wppa_switch( 'rating_on' ) ) {
134
+ $ratings = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_rating" );
135
  if ( $ratings ) {
136
  $widget_content .= __('Number of ratings', 'wp-photo-album-plus') . ': <b>' . $ratings . '</b><br />';
137
  }
wppa-thumbnail-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * display thumbnail photos
6
- * Version 6.9.12
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 `".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 `".WPPA_PHOTOS."` WHERE `status` <> 'pending' AND `status` <> 'scheduled'".$sortby." LIMIT %d", $max ), 'ARRAY_A' );
72
  }
73
 
74
  global $widget_content;
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
  }
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;
wppa-tinymce-common.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-tinymce-common.php
3
  * Pachkage: wp-photo-album-plus
4
  *
5
- * Version 6.7.11
6
  *
7
  */
8
 
@@ -11,7 +11,7 @@ global $wpdb;
11
 
12
  // Prepare albuminfo
13
  $albums = $wpdb->get_results( "SELECT `id`, `name` " .
14
- "FROM `" . WPPA_ALBUMS . "` " .
15
  "WHERE `owner` = '" . wppa_get_user() . "' " .
16
  "OR `owner` = '--- public ---' " .
17
  "ORDER BY `name` ",
@@ -333,7 +333,7 @@ global $wpdb;
333
 
334
  // Prepare photoinfo
335
  $my_photos = $wpdb->get_results( "SELECT `id`, `name`, `album`, `ext` " .
336
- "FROM `" . WPPA_PHOTOS . "` " .
337
  "WHERE `owner` = '" . wppa_get_user() . "' " .
338
  "ORDER BY `timestamp` DESC LIMIT 100",
339
  ARRAY_A );
@@ -399,7 +399,7 @@ global $wpdb;
399
 
400
  // Prepare photoinfo
401
  $all_photos = $wpdb->get_results( "SELECT `id`, `name`, `album`, `ext` " .
402
- "FROM `" . WPPA_PHOTOS . "` " .
403
  "ORDER BY `timestamp` DESC LIMIT 100",
404
  ARRAY_A );
405
 
2
  /* wppa-tinymce-common.php
3
  * Pachkage: wp-photo-album-plus
4
  *
5
+ * Version 6.9.14
6
  *
7
  */
8
 
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` ",
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 );
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
 
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.03
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 `".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 `".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.14
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.12
7
  */
8
 
9
  class TopTenWidget extends WP_Widget {
@@ -91,7 +91,7 @@ class TopTenWidget extends WP_Widget {
91
 
92
  // Albums of owner is current logged in user or public?
93
  if ( $album == '-3' ) {
94
- $temp = $wpdb->get_results( "SELECT `id` FROM `".WPPA_ALBUMS."` WHERE `owner` = '--- public ---' OR `owner` = '" . wppa_get_user() . "' ORDER BY `id`", ARRAY_A );
95
  $album = '';
96
  if ( $temp ) {
97
  foreach( $temp as $t ) {
@@ -110,35 +110,128 @@ class TopTenWidget extends WP_Widget {
110
 
111
  // Doit
112
  if ( $medalsonly ) {
113
- $thumbs = $wpdb->get_results( "SELECT * FROM `".WPPA_PHOTOS."` " .
114
- "WHERE `album` IN (".$album.") " .
115
- "AND `status` IN ( 'gold', 'silver', 'bronze' ) " .
116
- "ORDER BY " . $sortby . " " .
117
- "LIMIT " . $max, ARRAY_A );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  }
 
119
  else {
120
- $thumbs = $wpdb->get_results( "SELECT * FROM `".WPPA_PHOTOS."` " .
121
- "WHERE `album` IN (".$album.") " .
122
- "ORDER BY " . $sortby . " " .
123
- "LIMIT " . $max, ARRAY_A );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }
125
-
126
  }
127
 
128
  // No album specified
129
  else {
130
  if ( $medalsonly ) {
131
- $thumbs = $wpdb->get_results( "SELECT * FROM `".WPPA_PHOTOS."` " .
132
- "WHERE `status` IN ( 'gold', 'silver', 'bronze' ) " .
133
- "AND `album` > '0' " .
134
- "ORDER BY " . $sortby . " " .
135
- "LIMIT " . $max, ARRAY_A );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  }
 
137
  else {
138
- $thumbs = $wpdb->get_results( "SELECT * FROM `".WPPA_PHOTOS."` " .
139
- "WHERE `album` > '0' " .
140
- "ORDER BY " . $sortby . " " .
141
- "LIMIT " . $max, ARRAY_A );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  }
143
  }
144
 
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the top rated photos
6
+ * Version 6.9.14
7
  */
8
 
9
  class TopTenWidget extends WP_Widget {
91
 
92
  // Albums of owner is current logged in user or public?
93
  if ( $album == '-3' ) {
94
+ $temp = $wpdb->get_results( "SELECT `id` FROM $wpdb->wppa_albums WHERE `owner` = '--- public ---' OR `owner` = '" . wppa_get_user() . "' ORDER BY `id`", ARRAY_A );
95
  $album = '';
96
  if ( $temp ) {
97
  foreach( $temp as $t ) {
110
 
111
  // Doit
112
  if ( $medalsonly ) {
113
+ switch ( $instance['sortby'] ) {
114
+
115
+ case 'mean_rating':
116
+ $thumbs = $wpdb->get_results( $wpdb->prepare(
117
+ "SELECT * FROM $wpdb->wppa_photos " .
118
+ "WHERE `album` IN (" . $album . ") " .
119
+ "AND `status` IN ( 'gold', 'silver', 'bronze' ) " .
120
+ "ORDER BY `mean_rating` DESC, `rating_count` DESC, `views` DESC " .
121
+ "LIMIT %d", $max ), ARRAY_A );
122
+ break;
123
+
124
+ case 'rating_count':
125
+ $thumbs = $wpdb->get_results( $wpdb->prepare(
126
+ "SELECT * FROM $wpdb->wppa_photos " .
127
+ "WHERE `album` IN (" . $album . ") " .
128
+ "AND `status` IN ( 'gold', 'silver', 'bronze' ) " .
129
+ "ORDER BY `rating_count` DESC, `mean_rating` DESC, `views` DESC " .
130
+ "LIMIT %d", $max ), ARRAY_A );
131
+ break;
132
+
133
+ case 'views':
134
+ $thumbs = $wpdb->get_results( $wpdb->prepare(
135
+ "SELECT * FROM $wpdb->wppa_photos " .
136
+ "WHERE `album` IN (" . $album . ") " .
137
+ "AND `status` IN ( 'gold', 'silver', 'bronze' ) " .
138
+ "ORDER BY `views` DESC, `mean_rating` DESC, `rating_count` DESC " .
139
+ "LIMIT %d", $max ), ARRAY_A );
140
+ break;
141
+ }
142
  }
143
+
144
  else {
145
+ switch ( $instance['sortby'] ) {
146
+
147
+ case 'mean_rating':
148
+ $thumbs = $wpdb->get_results( $wpdb->prepare(
149
+ "SELECT * FROM $wpdb->wppa_photos " .
150
+ "WHERE `album` IN (" . $album . ") " .
151
+ "ORDER BY `mean_rating` DESC, `rating_count` DESC, `views` DESC " .
152
+ "LIMIT %d", $max ), ARRAY_A );
153
+ break;
154
+
155
+ case 'rating_count':
156
+ $thumbs = $wpdb->get_results( $wpdb->prepare(
157
+ "SELECT * FROM $wpdb->wppa_photos " .
158
+ "WHERE `album` IN (" . $album . ") " .
159
+ "ORDER BY `rating_count` DESC, `mean_rating` DESC, `views` DESC " .
160
+ "LIMIT %d", $max ), ARRAY_A );
161
+ break;
162
+
163
+ case 'views':
164
+ $thumbs = $wpdb->get_results( $wpdb->prepare(
165
+ "SELECT * FROM $wpdb->wppa_photos " .
166
+ "WHERE `album` IN (" . $album . ") " .
167
+ "ORDER BY `views` DESC, `mean_rating` DESC, `rating_count` DESC " .
168
+ "LIMIT %d", $max ), ARRAY_A );
169
+ break;
170
+ }
171
  }
 
172
  }
173
 
174
  // No album specified
175
  else {
176
  if ( $medalsonly ) {
177
+ switch ( $instance['sortby'] ) {
178
+
179
+ case 'mean_rating':
180
+ $thumbs = $wpdb->get_results( $wpdb->prepare(
181
+ "SELECT * FROM $wpdb->wppa_photos " .
182
+ "WHERE `album` > 0 " .
183
+ "AND `status` IN ( 'gold', 'silver', 'bronze' ) " .
184
+ "ORDER BY `mean_rating` DESC, `rating_count` DESC, `views` DESC " .
185
+ "LIMIT %d", $max ), ARRAY_A );
186
+ break;
187
+
188
+ case 'rating_count':
189
+ $thumbs = $wpdb->get_results( $wpdb->prepare(
190
+ "SELECT * FROM $wpdb->wppa_photos " .
191
+ "WHERE `album` > 0 " .
192
+ "AND `status` IN ( 'gold', 'silver', 'bronze' ) " .
193
+ "ORDER BY `rating_count` DESC, `mean_rating` DESC, `views` DESC " .
194
+ "LIMIT %d", $max ), ARRAY_A );
195
+ break;
196
+
197
+ case 'views':
198
+ $thumbs = $wpdb->get_results( $wpdb->prepare(
199
+ "SELECT * FROM $wpdb->wppa_photos " .
200
+ "WHERE `album` > 0 " .
201
+ "AND `status` IN ( 'gold', 'silver', 'bronze' ) " .
202
+ "ORDER BY `views` DESC, `mean_rating` DESC, `rating_count` DESC " .
203
+ "LIMIT %d", $max ), ARRAY_A );
204
+ break;
205
+ }
206
  }
207
+
208
  else {
209
+ switch ( $instance['sortby'] ) {
210
+
211
+ case 'mean_rating':
212
+ $thumbs = $wpdb->get_results( $wpdb->prepare(
213
+ "SELECT * FROM $wpdb->wppa_photos " .
214
+ "WHERE `album` > 0 " .
215
+ "ORDER BY `mean_rating` DESC, `rating_count` DESC, `views` DESC " .
216
+ "LIMIT %d", $max ), ARRAY_A );
217
+ break;
218
+
219
+ case 'rating_count':
220
+ $thumbs = $wpdb->get_results( $wpdb->prepare(
221
+ "SELECT * FROM $wpdb->wppa_photos " .
222
+ "WHERE `album` > 0 " .
223
+ "ORDER BY `rating_count` DESC, `mean_rating` DESC, `views` DESC " .
224
+ "LIMIT %d", $max ), ARRAY_A );
225
+ break;
226
+
227
+ case 'views':
228
+ $thumbs = $wpdb->get_results( $wpdb->prepare(
229
+ "SELECT * FROM $wpdb->wppa_photos " .
230
+ "WHERE `album` > 0 " .
231
+ "ORDER BY `views` DESC, `mean_rating` DESC, `rating_count` DESC " .
232
+ "LIMIT %d", $max ), ARRAY_A );
233
+ break;
234
+ }
235
  }
236
  }
237
 
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.12
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 `".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 `".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 `".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 `".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 `" . 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.14
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.12
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 `" . 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.14
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.02
7
  *
8
  */
9
 
@@ -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 `".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 `".WPPA_ALBUMS."` WHERE `owner` = %s", wppa_get_user() ) );
176
  $gmax = wppa_opt( 'max_albums' );
177
  if ( $gmax && $albs >= $gmax ) {
178
  return false;
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains user and capabilities related routines
6
+ * Version 6.9.14
7
  *
8
  */
9
 
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;
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.13
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 `" . 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 ) {
@@ -655,7 +655,7 @@ global $wpdb;
655
 
656
  // Get the chunk
657
  $photos = $wpdb->get_results( "SELECT `id`, `tags` " .
658
- "FROM `" . WPPA_PHOTOS . "` " .
659
  "WHERE `status` <> 'pending' " .
660
  "AND `status` <> 'scheduled' " .
661
  "AND `tags` <> '' " .
@@ -758,7 +758,7 @@ global $wpdb;
758
 
759
  $result = false;
760
  $total = '0';
761
- $albums = $wpdb->get_results("SELECT `id`, `cats` FROM `".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 ) {
@@ -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 `" . WPPA_ALBUMS . "`" );
831
  }
832
 
833
  return in_array( $id, $existing_albums, true );
@@ -839,12 +839,12 @@ global $wpdb;
839
  if ( ! wppa_is_int( $id ) ) {
840
  return false;
841
  }
842
- return $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM `".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 `".WPPA_PHOTOS."` WHERE `album` = %s AND `filename` = %s", $alb, $photo));
848
  }
849
 
850
  function wppa_dislike_check($photo) {
@@ -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 `".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);
@@ -893,7 +893,7 @@ function wppa_dislike_get( $id ) {
893
  global $wpdb;
894
 
895
  $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) " .
896
- "FROM `" . WPPA_RATING . "` " .
897
  "WHERE `photo` = %s " .
898
  "AND `value` = -1",
899
  $id
@@ -907,7 +907,7 @@ function wppa_pendrat_get( $id ) {
907
  global $wpdb;
908
 
909
  $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) " .
910
- "FROM `" . WPPA_RATING . "` " .
911
  "WHERE `photo` = %s AND " .
912
  "`status` = 'pending'",
913
  $id
@@ -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 `" . 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 `".WPPA_PHOTOS."` SET `modified` = %s WHERE `id` = %s", time(), $photo));
1154
  }
1155
 
1156
  function wppa_nl_to_txt($text) {
@@ -1288,7 +1288,7 @@ global $wpdb;
1288
  if ( $start == '-1' ) return; // Done!
1289
 
1290
  $photos = $wpdb->get_results( "SELECT `id`, `album`, `name`, `filename`" .
1291
- " FROM `".WPPA_PHOTOS."`" .
1292
  " WHERE `filename` <> '' AND `filename` <> `name` AND `id` > " . $start .
1293
  " ORDER BY `id`", ARRAY_A
1294
  );
@@ -1381,7 +1381,7 @@ global $wpdb;
1381
  }
1382
 
1383
  // If still a photo with the same name exists in the original album, do not delete tge source
1384
- $still_exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `filename` = %s AND `album` = %s", $photoinfo['filename'], $album ) );
1385
  if ( ! $still_exists ) {
1386
 
1387
  // Delete sourcefile
@@ -1851,7 +1851,7 @@ global $wpdb;
1851
  $page = wppa_create_page( $thumb['name'], '[wppa type="autopage"][/wppa]' );
1852
 
1853
  // Store with photo data
1854
- $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `page_id` = ".$page." WHERE `id` = %d", $photo ) );
1855
 
1856
  // Update cache
1857
  $thumb['page_id'] = $page;
@@ -2151,7 +2151,7 @@ global $wpdb;
2151
  break;
2152
  }
2153
  if ( ( $name && $name != $filename ) || $method == 'none' ) { // Update name
2154
- $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `name` = %s WHERE `id` = %s", $name, $id ) );
2155
  wppa_cache_thumb( 'invalidate', $id ); // Invalidate cache
2156
  }
2157
  if ( ! wppa_switch( 'save_iptc') ) { // He doesn't want to keep the iptc data, so...
@@ -2197,7 +2197,7 @@ global $wpdb;
2197
 
2198
  if ( $status != $thumb['status'] ) {
2199
  $thumb['status'] = $status; // Update cache
2200
- $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `status` = %s WHERE `id` = %s", $status, $id ) );
2201
  }
2202
  }
2203
 
@@ -2263,7 +2263,7 @@ global $wpdb;
2263
  foreach ( array_keys( $data ) as $key ) {
2264
  $thumb = wppa_cache_thumb( $key );
2265
  $data[$key]['meanrating'] = $data[$key]['totvalue'] / $data[$key]['ratingcount'];
2266
- $user = wppa_get_user_by( 'login', $thumb['owner'] );
2267
  if ( $user ) {
2268
  $data[$key]['user'] = $user->display_name;
2269
  }
@@ -2335,7 +2335,7 @@ function wppa_file_is_in_album( $filename, $alb ) {
2335
  global $wpdb;
2336
 
2337
  if ( ! $filename ) return false; // Copy/move very old photo, before filnametracking
2338
- $photo_id = $wpdb->get_var ( $wpdb->prepare ( "SELECT `id` FROM `".WPPA_PHOTOS."` " .
2339
  "WHERE ( `filename` = %s OR `filename` = %s ) AND `album` = %s LIMIT 1",
2340
  wppa_sanitize_file_name( $filename ), $filename, $alb
2341
  )
@@ -2354,7 +2354,7 @@ static $childcounts;
2354
  }
2355
  else {
2356
  $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) " .
2357
- "FROM `" . WPPA_ALBUMS . "` " .
2358
  "WHERE `a_parent` = %s", $alb) );
2359
 
2360
  // Save result
@@ -2394,7 +2394,7 @@ static $child_cache;
2394
 
2395
  // Get the data
2396
  $result = $alb;
2397
- $children = $wpdb->get_results( $wpdb->prepare( "SELECT `id` FROM `".WPPA_ALBUMS."` WHERE `a_parent` = %s " . wppa_get_album_order( $alb ), $alb ), ARRAY_A );
2398
  if ( $children ) foreach ( $children as $child ) {
2399
  $result .= '.' . _wppa_alb_to_enum_children( $child['id'] );
2400
  $result = trim( $result, '.' );
@@ -2466,10 +2466,10 @@ global $wpdb;
2466
  if ( wppa_opt( 'rating_display_type' ) == 'likes' ) {
2467
 
2468
  // Get rating(like)count
2469
- $count = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPPA_RATING . "` WHERE `photo` = $id" );
2470
 
2471
  // Update photo
2472
- $wpdb->query( "UPDATE `" . WPPA_PHOTOS . "` SET `rating_count` = '$count', `mean_rating` = '0' WHERE `id` = $id" );
2473
 
2474
  // Invalidate cache
2475
  wppa_cache_photo( 'invalidate', $id );
@@ -2494,7 +2494,7 @@ global $wpdb;
2494
  if ( $the_value == '10' ) $the_value = '9.9999999'; // mean_rating is a text field. for sort order reasons we make 10 into 9.99999
2495
 
2496
  // Update photo
2497
- $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `mean_rating` = %s, `rating_count` = %s WHERE `id` = $id", $the_value, $the_count ) );
2498
 
2499
  // Invalidate cache
2500
  wppa_cache_photo( 'invalidate', $id );
@@ -2562,7 +2562,7 @@ function wppa_force_numeric_else( $value, $default ) {
2562
  function wppa_sanitize_file_name( $file, $check_length = true ) {
2563
  $temp = explode( '/', $file );
2564
  $cnt = count( $temp );
2565
- $temp[$cnt - 1] = wppa_sima( strip_tags( stripslashes( $temp[$cnt - 1] ) ) );
2566
  $maxlen = wppa_opt( 'max_filename_length' );
2567
  if ( $maxlen && $check_length ) {
2568
  if ( strpos( $temp[$cnt - 1], '.' ) !== false ) {
@@ -3319,7 +3319,7 @@ static $usercache;
3319
  function wppa_get_my_last_vote( $id ) {
3320
  global $wpdb;
3321
 
3322
- $result = $wpdb->get_var( $wpdb->prepare( "SELECT `value` FROM `" . WPPA_RATING . "` " .
3323
  "WHERE `photo` = %s " .
3324
  "AND `user` = %s " .
3325
  "ORDER BY `id` DESC " .
@@ -3770,7 +3770,7 @@ global $wpdb;
3770
 
3771
  $me = wppa_get_user();
3772
  $likes = wppa_get_photo_item( $id, 'rating_count');
3773
- $mylike = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPPA_RATING . "` WHERE `photo` = $id AND `user` = '$me'" );
3774
 
3775
  if ( $mylike ) {
3776
  if ( $likes > 1 ) {
@@ -4738,7 +4738,7 @@ static $n_albums;
4738
 
4739
  // Find total number of albums, if not done before
4740
  if ( ! $n_albums ) {
4741
- $n_albums = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "`" );
4742
  }
4743
 
4744
  // Decide if many
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level utility routines
6
+ * Version 6.9.14
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 ) {
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` <> '' " .
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 ) {
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) {
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);
893
  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
907
  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
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) {
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
  );
1381
  }
1382
 
1383
  // If still a photo with the same name exists in the original album, do not delete tge source
1384
+ $still_exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE `filename` = %s AND `album` = %s", $photoinfo['filename'], $album ) );
1385
  if ( ! $still_exists ) {
1386
 
1387
  // Delete sourcefile
1851
  $page = wppa_create_page( $thumb['name'], '[wppa type="autopage"][/wppa]' );
1852
 
1853
  // Store with photo data
1854
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `page_id` = ".$page." WHERE `id` = %d", $photo ) );
1855
 
1856
  // Update cache
1857
  $thumb['page_id'] = $page;
2151
  break;
2152
  }
2153
  if ( ( $name && $name != $filename ) || $method == 'none' ) { // Update name
2154
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `name` = %s WHERE `id` = %s", $name, $id ) );
2155
  wppa_cache_thumb( 'invalidate', $id ); // Invalidate cache
2156
  }
2157
  if ( ! wppa_switch( 'save_iptc') ) { // He doesn't want to keep the iptc data, so...
2197
 
2198
  if ( $status != $thumb['status'] ) {
2199
  $thumb['status'] = $status; // Update cache
2200
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `status` = %s WHERE `id` = %s", $status, $id ) );
2201
  }
2202
  }
2203
 
2263
  foreach ( array_keys( $data ) as $key ) {
2264
  $thumb = wppa_cache_thumb( $key );
2265
  $data[$key]['meanrating'] = $data[$key]['totvalue'] / $data[$key]['ratingcount'];
2266
+ $user = wppa_get_user_by( 'login', sanitize_user( $thumb['owner'] ) );
2267
  if ( $user ) {
2268
  $data[$key]['user'] = $user->display_name;
2269
  }
2335
  global $wpdb;
2336
 
2337
  if ( ! $filename ) return false; // Copy/move very old photo, before filnametracking
2338
+ $photo_id = $wpdb->get_var ( $wpdb->prepare ( "SELECT `id` FROM $wpdb->wppa_photos " .
2339
  "WHERE ( `filename` = %s OR `filename` = %s ) AND `album` = %s LIMIT 1",
2340
  wppa_sanitize_file_name( $filename ), $filename, $alb
2341
  )
2354
  }
2355
  else {
2356
  $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) " .
2357
+ "FROM $wpdb->wppa_albums " .
2358
  "WHERE `a_parent` = %s", $alb) );
2359
 
2360
  // Save result
2394
 
2395
  // Get the data
2396
  $result = $alb;
2397
+ $children = $wpdb->get_results( $wpdb->prepare( "SELECT `id` FROM $wpdb->wppa_albums WHERE `a_parent` = %s " . wppa_get_album_order( $alb ), $alb ), ARRAY_A );
2398
  if ( $children ) foreach ( $children as $child ) {
2399
  $result .= '.' . _wppa_alb_to_enum_children( $child['id'] );
2400
  $result = trim( $result, '.' );
2466
  if ( wppa_opt( 'rating_display_type' ) == 'likes' ) {
2467
 
2468
  // Get rating(like)count
2469
+ $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_rating WHERE `photo` = %d", $id ) );
2470
 
2471
  // Update photo
2472
+ $wpdb->query( "UPDATE $wpdb->wppa_photos SET `rating_count` = '$count', `mean_rating` = '0' WHERE `id` = $id" );
2473
 
2474
  // Invalidate cache
2475
  wppa_cache_photo( 'invalidate', $id );
2494
  if ( $the_value == '10' ) $the_value = '9.9999999'; // mean_rating is a text field. for sort order reasons we make 10 into 9.99999
2495
 
2496
  // Update photo
2497
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->wppa_photos SET `mean_rating` = %s, `rating_count` = %s WHERE `id` = $id", $the_value, $the_count ) );
2498
 
2499
  // Invalidate cache
2500
  wppa_cache_photo( 'invalidate', $id );
2562
  function wppa_sanitize_file_name( $file, $check_length = true ) {
2563
  $temp = explode( '/', $file );
2564
  $cnt = count( $temp );
2565
+ $temp[$cnt - 1] = sanitize_file_name( $temp[$cnt - 1] );
2566
  $maxlen = wppa_opt( 'max_filename_length' );
2567
  if ( $maxlen && $check_length ) {
2568
  if ( strpos( $temp[$cnt - 1], '.' ) !== false ) {
3319
  function wppa_get_my_last_vote( $id ) {
3320
  global $wpdb;
3321
 
3322
+ $result = $wpdb->get_var( $wpdb->prepare( "SELECT `value` FROM $wpdb->wppa_rating " .
3323
  "WHERE `photo` = %s " .
3324
  "AND `user` = %s " .
3325
  "ORDER BY `id` DESC " .
3770
 
3771
  $me = wppa_get_user();
3772
  $likes = wppa_get_photo_item( $id, 'rating_count');
3773
+ $mylike = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->wppa_rating WHERE `photo` = %d AND `user` = %s", $id, $me ) );
3774
 
3775
  if ( $mylike ) {
3776
  if ( $likes > 1 ) {
4738
 
4739
  // Find total number of albums, if not done before
4740
  if ( ! $n_albums ) {
4741
+ $n_albums = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_albums" );
4742
  }
4743
 
4744
  // Decide if many
wppa-widget-functions.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-widget-functions.php
3
  /* Package: wp-photo-album-plus
4
  /*
5
- /* Version 6.8.03
6
  /*
7
  */
8
 
@@ -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 `" . WPPA_ALBUMS . "` " );
75
  $alb = implode( ',', array_diff( $all, $albs ) );
76
  }
77
 
@@ -82,7 +82,7 @@ global $wpdb;
82
  // Is it a single album?
83
  if ( wppa_is_int( $alb ) ) {
84
  $query = $wpdb->prepare( "SELECT `id`, `p_order` " .
85
- "FROM `" . WPPA_PHOTOS . "` " .
86
  "WHERE `album` = %s " .
87
  "AND " . $statusclause . $option,
88
  $alb );
@@ -93,7 +93,7 @@ global $wpdb;
93
  $alb = trim( $alb, ',' );
94
 
95
  $query = "SELECT `id`, `p_order` " .
96
- "FROM `" . WPPA_PHOTOS . "` " .
97
  "WHERE `album` IN ( " . $alb . " ) " .
98
  "AND " . $statusclause . $option;
99
  }
@@ -102,14 +102,14 @@ global $wpdb;
102
  // Is it ALL?
103
  elseif ( $alb == 'all' ) {
104
  $query = "SELECT `id`, `p_order` " .
105
- "FROM `" . 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 `" . WPPA_ALBUMS . "`", ARRAY_A );
112
- $query = "SELECT `id`, `p_order` FROM `" . WPPA_PHOTOS . "` WHERE ( `album` = '0' ";
113
  $first = true;
114
  foreach ( $albs as $a ) {
115
  if ( $a['a_parent'] == '-1' ) {
@@ -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 `" . WPPA_ALBUMS . "`", ARRAY_A );
125
- $query = "SELECT `id`, `p_order` FROM `" . WPPA_PHOTOS . "` WHERE ( `album` IN ('0'";
126
  foreach ( $albs as $a ) {
127
  if ( $a['a_parent'] != '-1' ) {
128
  $query .= ",'" . $a['id'] . "'";
@@ -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 `" . WPPA_PHOTOS . "` ORDER BY " . $sortby . " LIMIT " . wppa_opt( 'topten_count' );
156
  $query .= $option;
157
  }
158
 
@@ -294,7 +294,7 @@ static $potd;
294
  $ids[] = $photo['id'];
295
  }
296
  $photos = $wpdb->get_results( "SELECT `id`, `p_order` " .
297
- "FROM `".WPPA_PHOTOS."` " .
298
  "WHERE `id` IN (" . implode( ',', $ids ) . ") " .
299
  "ORDER BY RAND(".$idn.")",
300
  ARRAY_A );
2
  /* wppa-widget-functions.php
3
  /* Package: wp-photo-album-plus
4
  /*
5
+ /* Version 6.9.14
6
  /*
7
  */
8
 
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
 
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 );
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
  }
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' ) {
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'] . "'";
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
 
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 );
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.07
7
  *
8
  */
9
 
@@ -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 `" . WPPA_SESSION . "` WHERE `session` = %s ORDER BY `id` DESC LIMIT 1", wppa_get_session_id() ) );
52
  return $result;
53
  }
54
  else {
@@ -69,7 +69,7 @@ global $wpdb;
69
 
70
  // WPPA_INDEX is now AUTO_INCREMENT
71
 
72
- $query = $wpdb->prepare("INSERT INTO `" . WPPA_INDEX . "` (
73
  `slug`,
74
  `albums`,
75
  `photos`
@@ -104,7 +104,7 @@ global $wpdb;
104
  $args['description'] = sanitize_text_field( $args['description'] );
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 `" . WPPA_EXIF . "` (
108
  `photo`,
109
  `tag`,
110
  `description`,
@@ -143,7 +143,7 @@ global $wpdb;
143
  $args['description'] = sanitize_text_field( $args['description'] );
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 `" . WPPA_IPTC . "` (
147
  `photo`,
148
  `tag`,
149
  `description`,
@@ -178,7 +178,7 @@ 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 `" . WPPA_COMMENTS . "` ( `id`,
182
  `timestamp`,
183
  `photo`,
184
  `user`,
@@ -223,7 +223,7 @@ 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 `" . WPPA_RATING . "` ( `id`,
227
  `timestamp`,
228
  `photo`,
229
  `value`,
@@ -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 `".WPPA_ALBUMS."` WHERE `id` = %s", $args['album'] ) ) : '',
277
  'scheduledel' => '',
278
  'custom' => '',
279
  'crypt' => wppa_get_unique_photo_crypt(),
@@ -286,7 +286,7 @@ 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 `" . WPPA_PHOTOS . "` ( `id`,
290
  `album`,
291
  `ext`,
292
  `name`,
@@ -397,7 +397,7 @@ 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 `" . WPPA_ALBUMS . "` ( `id`,
401
  `name`,
402
  `description`,
403
  `a_order`,
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level wpdb routines that add new records
6
+ * Version 6.9.14
7
  *
8
  */
9
 
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 {
69
 
70
  // WPPA_INDEX is now AUTO_INCREMENT
71
 
72
+ $query = $wpdb->prepare("INSERT INTO $wpdb->wppa_index (
73
  `slug`,
74
  `albums`,
75
  `photos`
104
  $args['description'] = sanitize_text_field( $args['description'] );
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`,
143
  $args['description'] = sanitize_text_field( $args['description'] );
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`,
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`,
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`,
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`,
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`,
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.07
7
  *
8
  */
9
 
@@ -78,7 +78,7 @@ global $wpdb;
78
  }
79
 
80
  if ( $doit ) {
81
- if ( $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_ALBUMS."` SET `".$itemname."` = %s WHERE `id` = %s LIMIT 1", $itemvalue, $id ) ) ) {
82
  wppa_cache_album( 'invalidate' );
83
  }
84
  }
@@ -219,7 +219,7 @@ global $wpdb;
219
  }
220
 
221
  if ( $doit ) {
222
- if ( $wpdb->query( $wpdb->prepare( "UPDATE `".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.14
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
  }
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.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.13.002
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 = '6913'; // WPPA db version
26
- global $wppa_api_version; $wppa_api_version = '6-9-13-002'; // WPPA software version
27
 
28
  /* start timers */
29
  global $wppa_starttime; $wppa_starttime = microtime( true );
@@ -69,13 +69,21 @@ else {
69
 
70
  /* DB Tables */
71
  define( 'WPPA_ALBUMS', $wppa_prefix . 'wppa_albums' );
 
72
  define( 'WPPA_PHOTOS', $wppa_prefix . 'wppa_photos' );
 
73
  define( 'WPPA_RATING', $wppa_prefix . 'wppa_rating' );
 
74
  define( 'WPPA_COMMENTS', $wppa_prefix . 'wppa_comments' );
 
75
  define( 'WPPA_IPTC', $wppa_prefix . 'wppa_iptc' );
 
76
  define( 'WPPA_EXIF', $wppa_prefix . 'wppa_exif' );
 
77
  define( 'WPPA_INDEX', $wppa_prefix . 'wppa_index' );
 
78
  define( 'WPPA_SESSION', $wppa_prefix . 'wppa_session' );
 
79
 
80
  /* Paths and urls */ // Standard examples
81
  define( 'WPPA_FILE', basename( __FILE__ ) ); // wppa.php
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.14.002
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 = '6914'; // WPPA db version
26
+ global $wppa_api_version; $wppa_api_version = '6-9-14-002'; // WPPA software version
27
 
28
  /* start timers */
29
  global $wppa_starttime; $wppa_starttime = microtime( true );
69
 
70
  /* DB Tables */
71
  define( 'WPPA_ALBUMS', $wppa_prefix . 'wppa_albums' );
72
+ $wpdb->wppa_albums = WPPA_ALBUMS;
73
  define( 'WPPA_PHOTOS', $wppa_prefix . 'wppa_photos' );
74
+ $wpdb->wppa_photos = WPPA_PHOTOS;
75
  define( 'WPPA_RATING', $wppa_prefix . 'wppa_rating' );
76
+ $wpdb->wppa_rating = WPPA_RATING;
77
  define( 'WPPA_COMMENTS', $wppa_prefix . 'wppa_comments' );
78
+ $wpdb->wppa_comments = WPPA_COMMENTS;
79
  define( 'WPPA_IPTC', $wppa_prefix . 'wppa_iptc' );
80
+ $wpdb->wppa_iptc = WPPA_IPTC;
81
  define( 'WPPA_EXIF', $wppa_prefix . 'wppa_exif' );
82
+ $wpdb->wppa_exif = WPPA_EXIF;
83
  define( 'WPPA_INDEX', $wppa_prefix . 'wppa_index' );
84
+ $wpdb->wppa_index = WPPA_INDEX;
85
  define( 'WPPA_SESSION', $wppa_prefix . 'wppa_session' );
86
+ $wpdb->wppa_session = WPPA_SESSION;
87
 
88
  /* Paths and urls */ // Standard examples
89
  define( 'WPPA_FILE', basename( __FILE__ ) ); // wppa.php