WP Photo Album Plus - Version 6.6.12

Version Description

Download this release

Release Info

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

Code changes from version 6.6.11 to 6.6.12

js/wppa-admin-scripts.js CHANGED
@@ -1,7 +1,7 @@
1
  /* admin-scripts.js */
2
  /* Package: wp-photo-album-plus
3
  /*
4
- /* Version 6.6.11
5
  /* Various js routines used in admin pages
6
  */
7
 
@@ -1842,7 +1842,7 @@ function wppaAjaxPopupWindow( slug ) {
1842
  break;
1843
  }
1844
  var desc = '';
1845
- var width = 960;
1846
  var height = 512;
1847
 
1848
  if ( screen.availWidth < width ) width = screen.availWidth;
1
  /* admin-scripts.js */
2
  /* Package: wp-photo-album-plus
3
  /*
4
+ /* Version 6.6.12
5
  /* Various js routines used in admin pages
6
  */
7
 
1842
  break;
1843
  }
1844
  var desc = '';
1845
+ var width = 1024;
1846
  var height = 512;
1847
 
1848
  if ( screen.availWidth < width ) width = screen.availWidth;
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, gallery, slideshow, video, audio, lightbox, iptc, exif, cloudinary, fotomoto
5
- Version: 6.6.11
6
- Stable tag: 6.6.11
7
  Author: J.N. Breetvelt
8
  Author URI: http://www.opajaap.nl/
9
  Requires at least: 3.9
@@ -180,6 +180,26 @@ Oh, just Google on 'picture resizer' and you will find a bunch of free programs
180
 
181
  See for additional information: <a href="http://www.wppa.nl/changelog/" >The documentation website</a>
182
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  = 6.6.11 =
184
 
185
  = Bug Fixes =
2
  Contributors: opajaap
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=OpaJaap@OpaJaap.nl&item_name=WP-Photo-Album-Plus&item_number=Support-Open-Source&currency_code=USD&lc=US
4
  Tags: photo, album, gallery, slideshow, video, audio, lightbox, iptc, exif, cloudinary, fotomoto
5
+ Version: 6.6.12
6
+ Stable tag: 6.6.12
7
  Author: J.N. Breetvelt
8
  Author URI: http://www.opajaap.nl/
9
  Requires at least: 3.9
180
 
181
  See for additional information: <a href="http://www.wppa.nl/changelog/" >The documentation website</a>
182
 
183
+ = 6.6.12 =
184
+
185
+ = Bug Fixes =
186
+
187
+ * Under certain circumstances the close button of the new style frontend edit photo modal dialog box did not work. Fixed.
188
+ * Fixed the incorrectly working link 'Top of page' on the album admin screen.
189
+ * Fixed a missing '&lt;/table>' in wppa_get_multitag_html();
190
+ * Fixed a layout issue of the album multi selection box on the photo of the day admin page.
191
+
192
+ = New Features =
193
+
194
+ * Shortcode attribute cols="...", used with shortcode type="multitag" can now have two numbers; one for pc (1st) and one for mobile (2nd). Example: [wppa type="multitag" cols="6,2"]
195
+ * The maintenance of the search index db table as well as the actual deletion of photos is now performed at the background. To monitor this activity: Tick the box in Table IX-A9: Log Cron.
196
+ * Table IX-E18.x: Additional search engine settings.
197
+
198
+ = Other Changes =
199
+
200
+ * Crashed cron jobs are now automaticly re-animated. There is a check every hour.
201
+ * Significant performance enhancements, especially in editing album/photo info and photo deletion.
202
+
203
  = 6.6.11 =
204
 
205
  = Bug Fixes =
theme/wppa-style.css CHANGED
@@ -8,7 +8,7 @@
8
  /*
9
  /* You may always look into a newer version of this file to see what new classes and id's come with an upgrade
10
  /*
11
- /* This is version 6.6.07
12
  */
13
 
14
  .wppa-container, .wppa-cover-box, .wppa-thumb-area {
@@ -27,6 +27,9 @@
27
  clear: both;
28
  }
29
 
 
 
 
30
  .wppa-multitag-table tr td {
31
  padding-right:4px;
32
  }
8
  /*
9
  /* You may always look into a newer version of this file to see what new classes and id's come with an upgrade
10
  /*
11
+ /* This is version 6.6.12
12
  */
13
 
14
  .wppa-container, .wppa-cover-box, .wppa-thumb-area {
27
  clear: both;
28
  }
29
 
30
+ .wppa-multitag-table {
31
+ width:100%;
32
+ }
33
  .wppa-multitag-table tr td {
34
  padding-right:4px;
35
  }
wppa-ajax.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-ajax.php
3
  *
4
  * Functions used in ajax requests
5
- * Version 6.6.11
6
  *
7
  */
8
 
@@ -1151,7 +1151,7 @@ global $wppa_log_file;
1151
  break;
1152
  case 'owner':
1153
  $itemname = __( 'Owner' , 'wp-photo-album-plus');
1154
- if ( $value != '--- public ---' && ! get_user_by( 'login', $value ) ) {
1155
  echo '||4||'.sprintf( __( 'User %s does not exist' , 'wp-photo-album-plus'), $value );
1156
  wppa_exit();
1157
  }
@@ -1586,7 +1586,7 @@ global $wppa_log_file;
1586
  $itemname = __( 'Photo order #' , 'wp-photo-album-plus');
1587
  break;
1588
  case 'owner':
1589
- $usr = get_user_by( 'login', $value );
1590
  if ( ! $usr ) {
1591
  echo '||4||' . sprintf( __( 'User %s does not exists' , 'wp-photo-album-plus'), $value );
1592
  wppa_exit();
@@ -2456,7 +2456,7 @@ global $wppa_log_file;
2456
  case 'wppa_blacklist_user':
2457
  // Does user exist?
2458
  $value = trim ( $value );
2459
- $user = get_user_by ( 'login', $value ); // seems to be case insensitive
2460
  if ( $user && $user->user_login === $value ) {
2461
  $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `status` = 'pending' WHERE `owner` = %s", $value ) );
2462
  $black_listed_users = get_option( 'wppa_black_listed_users', array() );
@@ -2487,7 +2487,7 @@ global $wppa_log_file;
2487
  case 'wppa_superuser_user':
2488
  // Does user exist?
2489
  $value = trim ( $value );
2490
- $user = get_user_by ( 'login', $value ); // seems to be case insensitive
2491
  if ( $user && $user->user_login === $value ) {
2492
  $super_users = get_option( 'wppa_super_users', array() );
2493
  if ( ! in_array( $value, $super_users ) ) {
@@ -2648,6 +2648,25 @@ global $wppa_log_file;
2648
  }
2649
  break;
2650
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2651
  default:
2652
 
2653
  wppa( 'error', '0' );
@@ -2670,7 +2689,7 @@ global $wppa_log_file;
2670
  wppa_initialize_runtime( true ); // force reload new values
2671
 
2672
  // .htaccess
2673
- wppa_create_wppa_htaccess();
2674
 
2675
  // Thumbsize
2676
  $new_minisize = wppa_get_minisize();
@@ -2703,7 +2722,7 @@ global $wppa_log_file;
2703
 
2704
  // If cron request, schedule
2705
  if ( $cron ) {
2706
- echo wppa_schedule_maintenance_proc( $slug, 'first' );
2707
 
2708
  // Remove in case this is a re-start of a crashed cron job
2709
  delete_option( $slug . '_lasttimestamp' );
2
  /* wppa-ajax.php
3
  *
4
  * Functions used in ajax requests
5
+ * Version 6.6.12
6
  *
7
  */
8
 
1151
  break;
1152
  case 'owner':
1153
  $itemname = __( 'Owner' , 'wp-photo-album-plus');
1154
+ if ( $value != '--- public ---' && ! wppa_get_user_by( 'login', $value ) ) {
1155
  echo '||4||'.sprintf( __( 'User %s does not exist' , 'wp-photo-album-plus'), $value );
1156
  wppa_exit();
1157
  }
1586
  $itemname = __( 'Photo order #' , 'wp-photo-album-plus');
1587
  break;
1588
  case 'owner':
1589
+ $usr = wppa_get_user_by( 'login', $value );
1590
  if ( ! $usr ) {
1591
  echo '||4||' . sprintf( __( 'User %s does not exists' , 'wp-photo-album-plus'), $value );
1592
  wppa_exit();
2456
  case 'wppa_blacklist_user':
2457
  // Does user exist?
2458
  $value = trim ( $value );
2459
+ $user = wppa_get_user_by ( 'login', $value ); // seems to be case insensitive
2460
  if ( $user && $user->user_login === $value ) {
2461
  $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `status` = 'pending' WHERE `owner` = %s", $value ) );
2462
  $black_listed_users = get_option( 'wppa_black_listed_users', array() );
2487
  case 'wppa_superuser_user':
2488
  // Does user exist?
2489
  $value = trim ( $value );
2490
+ $user = wppa_get_user_by ( 'login', $value ); // seems to be case insensitive
2491
  if ( $user && $user->user_login === $value ) {
2492
  $super_users = get_option( 'wppa_super_users', array() );
2493
  if ( ! in_array( $value, $super_users ) ) {
2648
  }
2649
  break;
2650
 
2651
+ case 'wppa_cre_uploads_htaccess':
2652
+ wppa_create_wppa_htaccess();
2653
+ break;
2654
+
2655
+ case 'wppa_search_numbers_void':
2656
+ case 'wppa_index_ignore_slash':
2657
+ ob_start();
2658
+ if ( $value == 'yes' ) {
2659
+ // Cleanup index
2660
+ wppa_schedule_maintenance_proc( 'wppa_cleanup_index' );
2661
+ }
2662
+ else {
2663
+ // Remake index
2664
+ wppa_schedule_maintenance_proc( 'wppa_remake_index_albums' );
2665
+ wppa_schedule_maintenance_proc( 'wppa_remake_index_photos' );
2666
+ }
2667
+ ob_end_clean();
2668
+ break;
2669
+
2670
  default:
2671
 
2672
  wppa( 'error', '0' );
2689
  wppa_initialize_runtime( true ); // force reload new values
2690
 
2691
  // .htaccess
2692
+ // wppa_create_wppa_htaccess();
2693
 
2694
  // Thumbsize
2695
  $new_minisize = wppa_get_minisize();
2722
 
2723
  // If cron request, schedule
2724
  if ( $cron ) {
2725
+ echo wppa_schedule_maintenance_proc( $slug, 10 );
2726
 
2727
  // Remove in case this is a re-start of a crashed cron job
2728
  delete_option( $slug . '_lasttimestamp' );
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.6.11
7
  *
8
  */
9
 
@@ -88,7 +88,9 @@ function _wppa_admin() {
88
  if ( isset($_REQUEST['bulk']) ) wppa_album_photos_bulk($ei);
89
  else wppa_album_photos($ei);
90
  ?>
91
- <div style="position:fixed;right:30px;bottom:30px;background-color:lightblue;" >&nbsp;<a href="#manage-photos"><?php _e('Top of page', 'wp-photo-album-plus') ?></a>&nbsp;</div>
 
 
92
  <br /><a href="<?php echo $back_url ?>"><?php _e('Back to album table', 'wp-photo-album-plus') ?></a>
93
  <?php
94
  return;
@@ -1060,7 +1062,9 @@ function wppaTryScheduleAll( id ) {
1060
  elseif ( isset($_REQUEST['seq']) ) wppa_album_photos_sequence($edit_id);
1061
  else wppa_album_photos($edit_id)
1062
  ?>
1063
- <div style="position:fixed;right:30px;bottom:30px;background-color:lightblue;" >&nbsp;<a href="#manage-photos"><?php _e('Top of page', 'wp-photo-album-plus') ?></a>&nbsp;</div>
 
 
1064
  </div>
1065
  <?php }
1066
 
3
  * Package: wp-photo-album-plus
4
  *
5
  * create, edit and delete albums
6
+ * Version 6.6.12
7
  *
8
  */
9
 
88
  if ( isset($_REQUEST['bulk']) ) wppa_album_photos_bulk($ei);
89
  else wppa_album_photos($ei);
90
  ?>
91
+ <a href="#manage-photos">
92
+ <div style="position:fixed;right:30px;bottom:30px;background-color:lightblue;" >&nbsp;<?php _e('Top of page', 'wp-photo-album-plus') ?>&nbsp;</div>
93
+ </a>
94
  <br /><a href="<?php echo $back_url ?>"><?php _e('Back to album table', 'wp-photo-album-plus') ?></a>
95
  <?php
96
  return;
1062
  elseif ( isset($_REQUEST['seq']) ) wppa_album_photos_sequence($edit_id);
1063
  else wppa_album_photos($edit_id)
1064
  ?>
1065
+ <a href="#manage-photos">
1066
+ <div style="position:fixed;right:30px;bottom:30px;background-color:lightblue;" >&nbsp;<?php _e('Top of page', 'wp-photo-album-plus') ?>&nbsp;</div>
1067
+ </a>
1068
  </div>
1069
  <?php }
1070
 
wppa-boxes-html.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various wppa boxes
6
- * Version 6.6.11
7
  *
8
  */
9
 
@@ -1172,7 +1172,7 @@ function wppa_get_multitag_html( $nperline = '2', $seltags = '' ) {
1172
  '</td>' .
1173
  '</tr>';
1174
  }
1175
- // $result .= '</table><hr style="margin: 3px 0;" />';
1176
  }
1177
 
1178
  $count = '0';
@@ -3127,12 +3127,12 @@ global $wpdb;
3127
 
3128
  // First try to find the user by email address ( works only if email required on comments )
3129
  if ( $comment['email'] ) {
3130
- $usr = get_user_by( 'email', $comment['email'] );
3131
  }
3132
 
3133
  // If not found, try to find the user by login name ( works only if login name is equal to display name )
3134
  if ( ! $usr ) {
3135
- $usr = get_user_by( 'login', $comment['user'] );
3136
  }
3137
 
3138
  // Still no user, try to find him by display name
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various wppa boxes
6
+ * Version 6.6.12
7
  *
8
  */
9
 
1172
  '</td>' .
1173
  '</tr>';
1174
  }
1175
+ $result .= '</table>';//<hr style="margin: 3px 0;" />';
1176
  }
1177
 
1178
  $count = '0';
3127
 
3128
  // First try to find the user by email address ( works only if email required on comments )
3129
  if ( $comment['email'] ) {
3130
+ $usr = wppa_get_user_by( 'email', $comment['email'] );
3131
  }
3132
 
3133
  // If not found, try to find the user by login name ( works only if login name is equal to display name )
3134
  if ( ! $usr ) {
3135
+ $usr = wppa_get_user_by( 'login', $comment['user'] );
3136
  }
3137
 
3138
  // Still no user, try to find him by display name
wppa-breadcrumb.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for breadcrumbs
6
- * Version 6.6.08
7
  *
8
  */
9
 
@@ -280,7 +280,7 @@ global $wppa_session;
280
  wppa_bcitem( $value, $href, $title, 'b9' );
281
  }
282
  elseif ( wppa( 'is_upldr' ) ) {
283
- $usr = get_user_by( 'login', wppa( 'is_upldr' ) );
284
  if ( $usr ) $user = $usr->display_name; else $user = wppa( 'is_upldr' );
285
  if ( wppa( 'is_slide' ) ) {
286
  $value = sprintf( __( 'Photos by %s' , 'wp-photo-album-plus'), $user );
@@ -490,7 +490,7 @@ global $wppa_session;
490
  }
491
  else { // Maybe a simple normal standard album???
492
  if ( wppa( 'is_owner' ) ) {
493
- $usr = get_user_by( 'login', wppa( 'is_owner' ) );
494
  if ( $usr ) $dispname = $usr->display_name;
495
  else $dispname = wppa( 'is_owner' ); // User deleted
496
  $various = sprintf( __( 'Various albums by %s' , 'wp-photo-album-plus'), $dispname );
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for breadcrumbs
6
+ * Version 6.6.12
7
  *
8
  */
9
 
280
  wppa_bcitem( $value, $href, $title, 'b9' );
281
  }
282
  elseif ( wppa( 'is_upldr' ) ) {
283
+ $usr = wppa_get_user_by( 'login', wppa( 'is_upldr' ) );
284
  if ( $usr ) $user = $usr->display_name; else $user = wppa( 'is_upldr' );
285
  if ( wppa( 'is_slide' ) ) {
286
  $value = sprintf( __( 'Photos by %s' , 'wp-photo-album-plus'), $user );
490
  }
491
  else { // Maybe a simple normal standard album???
492
  if ( wppa( 'is_owner' ) ) {
493
+ $usr = wppa_get_user_by( 'login', wppa( 'is_owner' ) );
494
  if ( $usr ) $dispname = $usr->display_name;
495
  else $dispname = wppa( 'is_owner' ); // User deleted
496
  $various = sprintf( __( 'Various albums by %s' , 'wp-photo-album-plus'), $dispname );
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.6.11
6
  *
7
  */
8
 
@@ -23,7 +23,6 @@ global $wppa_defaults;
23
  if ( $force ) {
24
  $wppa = false; // destroy existing arrays
25
  $wppa_opt = false;
26
- // delete_option( 'wppa_cached_options' );
27
  }
28
 
29
  if ( is_array( $wppa ) && is_array( $wppa_opt ) && ! $force ) {
@@ -34,39 +33,7 @@ global $wppa_defaults;
34
  wppa_reset_occurrance();
35
  }
36
 
37
- /* Caching disabled due to MySql versions that do not allow fields > 64 kB
38
- // Get the cache version of all settings
39
- $wppa_opt = get_option( 'wppa_cached_options', false );
40
-
41
- // Check for validity, only on admin pages (due to qTranslate behaviour), non ajax (to keep performance at front-end ajax).
42
- if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
43
- if ( is_array( $wppa_opt ) && ( md5( serialize( $wppa_opt ) ) != get_option( 'wppa_md5_options', 'nil' ) ) ) {
44
-
45
- // Log hash error
46
- wppa_log('Obs', 'Read hash:'.get_option( 'wppa_md5_options', 'nil' ).', computed hash:'. md5( serialize( $wppa_opt )));
47
-
48
- // Something wrong. Let us see what, if not intentional!
49
- if ( ! $force ) {
50
- foreach( array_keys( $wppa_opt ) as $key ) {
51
- if ( $wppa_opt[$key] != get_option( $key ) ) {
52
- wppa_log( 'dbg', 'Corrupted setting found. Cached value=' . $wppa_opt[$key] . ', option value=' . get_option( $key ) );
53
- }
54
- }
55
- }
56
- $count = count( $wppa_opt );
57
-
58
- // Report fix only if not intentional, with stacktrace
59
- if ( ! $force ) {
60
- wppa_log( 'Fix', 'Option cache. Count=' . $count );
61
- }
62
-
63
- // Clear cached options to force rebuild
64
- $wppa_opt = false;
65
- }
66
- }
67
- */
68
-
69
- // Rebuild cached options if required, i.e. when not yet existing or deleted.
70
  if ( ! is_array( $wppa_opt ) ) {
71
  wppa_set_defaults();
72
  $wppa_opt = $wppa_defaults;
@@ -79,18 +46,6 @@ global $wppa_defaults;
79
  $wppa_opt[$option] = $optval;
80
  }
81
  }
82
-
83
- /*
84
- update_option( 'wppa_cached_options', $wppa_opt, true );
85
- update_option( 'wppa_md5_options', md5( serialize( $wppa_opt ) ), true );
86
-
87
- // Verify success
88
- $temp = get_option( 'wppa_cached_options' );
89
- $hash = get_option( 'wppa_md5_options' );
90
- if ( md5( serialize( $temp ) ) != $hash ) {
91
- wppa_log( 'Err', 'Discrepancy found. Count='.count($temp) );
92
- }
93
- */
94
  }
95
 
96
  if ( isset( $_GET['debug'] ) && wppa_switch( 'allow_debug' ) ) {
@@ -98,15 +53,6 @@ global $wppa_defaults;
98
  wppa( 'debug', $key );
99
  }
100
 
101
- // Delete obsolete spam
102
- $spammaxage = wppa_opt( 'spam_maxage' );
103
- if ( $spammaxage != 'none' ) {
104
- $time = time();
105
- $obsolete = $time - $spammaxage;
106
- $iret = $wpdb->query( $wpdb->prepare( "DELETE FROM `".WPPA_COMMENTS."` WHERE `status` = 'spam' AND `timestamp` < %s", $obsolete ) );
107
- if ( $iret ) wppa_update_option( 'wppa_spam_auto_delcount', get_option( 'wppa_spam_auto_delcount', '0' ) + $iret );
108
- }
109
-
110
  $wppa_initruntimetime += microtime( true );
111
  }
112
 
@@ -1913,7 +1859,7 @@ function wppa_add_credit_points( $amount, $reason = '', $id = '', $value = '', $
1913
  // Initialize
1914
  $bret = false;
1915
  if ( $user ) {
1916
- $usr = get_user_by( 'login', $user );
1917
  }
1918
  else {
1919
  $usr = wp_get_current_user();
2
  /* wppa-common-functions.php
3
  *
4
  * Functions used in admin and in themes
5
+ * Version 6.6.12
6
  *
7
  */
8
 
23
  if ( $force ) {
24
  $wppa = false; // destroy existing arrays
25
  $wppa_opt = false;
 
26
  }
27
 
28
  if ( is_array( $wppa ) && is_array( $wppa_opt ) && ! $force ) {
33
  wppa_reset_occurrance();
34
  }
35
 
36
+ // Rebuild options array if required, i.e. when not yet existing or deleted.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  if ( ! is_array( $wppa_opt ) ) {
38
  wppa_set_defaults();
39
  $wppa_opt = $wppa_defaults;
46
  $wppa_opt[$option] = $optval;
47
  }
48
  }
 
 
 
 
 
 
 
 
 
 
 
 
49
  }
50
 
51
  if ( isset( $_GET['debug'] ) && wppa_switch( 'allow_debug' ) ) {
53
  wppa( 'debug', $key );
54
  }
55
 
 
 
 
 
 
 
 
 
 
56
  $wppa_initruntimetime += microtime( true );
57
  }
58
 
1859
  // Initialize
1860
  $bret = false;
1861
  if ( $user ) {
1862
+ $usr = wppa_get_user_by( 'login', $user );
1863
  }
1864
  else {
1865
  $usr = wp_get_current_user();
wppa-cron.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all cron functions
6
- * Version 6.6.11
7
  *
8
  *
9
  */
@@ -18,26 +18,59 @@ function wppa_is_cron() {
18
  add_action( 'wppa_cron_event', 'wppa_do_maintenance_proc', 10, 1 );
19
 
20
  // Schedule maintenance proc
21
- function wppa_schedule_maintenance_proc( $slug, $first = false ) {
22
 
23
  // Schedule cron job
24
- wp_schedule_single_event( time() + ( $first ? 10 : 30 ), 'wppa_cron_event', array( $slug ) );
 
 
25
 
26
  // Update appropriate options
27
  update_option( $slug . '_status', 'Scheduled cron job' );
28
  update_option( $slug . '_user', 'cron-job' );
29
 
30
  // Inform calling Ajax proc about the results
31
- echo '||' . $slug . '||' . __( 'Scheduled cron job', 'wp-photo-album-plus' ) . '||0||reload';
 
 
32
 
33
  }
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  // Activate our cleanup session hook
36
  add_action( 'wppa_cleanup', 'wppa_do_cleanup' );
37
 
38
  // Schedule cleanup session database table
39
- function wppa_schedule_cleanup() {
40
 
 
 
 
 
41
  // Schedule cron job
42
  if ( ! wp_next_scheduled( 'wppa_cleanup' ) ) {
43
  wp_schedule_event( time(), 'hourly', 'wppa_cleanup' );
@@ -47,6 +80,7 @@ function wppa_schedule_cleanup() {
47
  // The actual cleaner
48
  function wppa_do_cleanup() {
49
  global $wpdb;
 
50
 
51
  // Cleanup session db table
52
  $lifetime = 3600; // Sessions expire after one hour
@@ -56,9 +90,37 @@ global $wpdb;
56
  $wpdb->query( $wpdb->prepare( "UPDATE `" . WPPA_SESSION . "` SET `status` = 'expired' WHERE `timestamp` < %s", $expire ) );
57
  $wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPPA_SESSION ."` WHERE `timestamp` < %s", $purge ) );
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  // Re-create permalink htaccess file
60
  wppa_create_pl_htaccess();
61
 
 
 
 
62
  }
63
 
64
  // Activate treecount update proc
@@ -68,7 +130,7 @@ function wppa_schedule_treecount_update() {
68
 
69
  // Schedule cron job
70
  if ( ! wp_next_scheduled( 'wppa_update_treecounts' ) ) {
71
- wp_schedule_single_event( time() + 30, 'wppa_update_treecounts' );
72
  }
73
  }
74
 
@@ -83,7 +145,7 @@ global $wpdb;
83
  $treecounts = wppa_get_treecounts_a( $alb );
84
  if ( $treecounts['needupdate'] ) {
85
  wppa_verify_treecounts_a( $alb );
86
- // wppa_log( 'Dbg', 'Cron fixed treecounts for ' . $alb );
87
  }
88
  if ( time() > $start + 30 ) {
89
  wppa_schedule_treecount_update();
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all cron functions
6
+ * Version 6.6.12
7
  *
8
  *
9
  */
18
  add_action( 'wppa_cron_event', 'wppa_do_maintenance_proc', 10, 1 );
19
 
20
  // Schedule maintenance proc
21
+ function wppa_schedule_maintenance_proc( $slug, $delay = 10 ) {
22
 
23
  // Schedule cron job
24
+ if ( ! wp_next_scheduled( 'wppa_cron_event', array( $slug ) ) ) {
25
+ wp_schedule_single_event( time() + $delay, 'wppa_cron_event', array( $slug ) );
26
+ }
27
 
28
  // Update appropriate options
29
  update_option( $slug . '_status', 'Scheduled cron job' );
30
  update_option( $slug . '_user', 'cron-job' );
31
 
32
  // Inform calling Ajax proc about the results
33
+ if ( is_admin() && defined( 'DOING_AJAX' ) ) {
34
+ echo '||' . $slug . '||' . __( 'Scheduled cron job', 'wp-photo-album-plus' ) . '||0||reload';
35
+ }
36
 
37
  }
38
 
39
+ // Is cronjob crashed?
40
+ function wppa_is_maintenance_cron_job_crashed( $slug ) {
41
+
42
+ // Asume not
43
+ $result = false;
44
+
45
+ // If there is a last timestamp longer than 15 minutes ago...
46
+ $last = get_option( $slug.'_lasttimestamp', '0' );
47
+ if ( $last && $last < ( time() - 900 ) ) {
48
+
49
+ // And the user is cron
50
+ if ( get_option( $slug . '_user' ) == 'cron-job' ){
51
+
52
+ // And proc is not scheduled
53
+ if ( ! wp_next_scheduled( 'wppa_cron_event', array( $slug ) ) ) {
54
+
55
+ // It is crashed
56
+ $result = true;
57
+ }
58
+ }
59
+ }
60
+
61
+ return $result;
62
+ }
63
+
64
  // Activate our cleanup session hook
65
  add_action( 'wppa_cleanup', 'wppa_do_cleanup' );
66
 
67
  // Schedule cleanup session database table
68
+ function wppa_schedule_cleanup( $now = false ) {
69
 
70
+ // Immediate action requested?
71
+ if ( $now ) {
72
+ wp_schedule_single_event( time() + 1, 'wppa_cleanup' );
73
+ }
74
  // Schedule cron job
75
  if ( ! wp_next_scheduled( 'wppa_cleanup' ) ) {
76
  wp_schedule_event( time(), 'hourly', 'wppa_cleanup' );
80
  // The actual cleaner
81
  function wppa_do_cleanup() {
82
  global $wpdb;
83
+ global $wppa_all_maintenance_slugs;
84
 
85
  // Cleanup session db table
86
  $lifetime = 3600; // Sessions expire after one hour
90
  $wpdb->query( $wpdb->prepare( "UPDATE `" . WPPA_SESSION . "` SET `status` = 'expired' WHERE `timestamp` < %s", $expire ) );
91
  $wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPPA_SESSION ."` WHERE `timestamp` < %s", $purge ) );
92
 
93
+ // Delete obsolete spam
94
+ $spammaxage = wppa_opt( 'spam_maxage' );
95
+ if ( $spammaxage != 'none' ) {
96
+ $time = time();
97
+ $obsolete = $time - $spammaxage;
98
+ $iret = $wpdb->query( $wpdb->prepare( "DELETE FROM `".WPPA_COMMENTS."` WHERE `status` = 'spam' AND `timestamp` < %s", $obsolete ) );
99
+ if ( $iret ) wppa_update_option( 'wppa_spam_auto_delcount', get_option( 'wppa_spam_auto_delcount', '0' ) + $iret );
100
+ }
101
+
102
+ // Re-animate crashed cronjobs
103
+ foreach ( $wppa_all_maintenance_slugs as $slug ) {
104
+ if ( wppa_is_maintenance_cron_job_crashed( $slug ) ) {
105
+ $last = get_option( $slug . '_last' );
106
+ update_option( $slug . '_last', $last + 1 );
107
+ wppa_schedule_maintenance_proc( $slug );
108
+ wppa_log( 'Cron', 'Crashed cron job {b}' . $slug . '{/b} re-animated at item {b}#' . $last . '{/b}' );
109
+ }
110
+ }
111
+
112
+ // Remove 'deleted' photos from system
113
+ $dels = $wpdb->get_col( "SELECT `id` FROM `".WPPA_PHOTOS."` WHERE `album` = '-9'" );
114
+ foreach( $dels as $del ) {
115
+ wppa_delete_photo( $del );
116
+ }
117
+
118
  // Re-create permalink htaccess file
119
  wppa_create_pl_htaccess();
120
 
121
+ // Cleanup index
122
+ wppa_schedule_maintenance_proc( 'wppa_cleanup_index' );
123
+
124
  }
125
 
126
  // Activate treecount update proc
130
 
131
  // Schedule cron job
132
  if ( ! wp_next_scheduled( 'wppa_update_treecounts' ) ) {
133
+ wp_schedule_single_event( time() + 10, 'wppa_update_treecounts' );
134
  }
135
  }
136
 
145
  $treecounts = wppa_get_treecounts_a( $alb );
146
  if ( $treecounts['needupdate'] ) {
147
  wppa_verify_treecounts_a( $alb );
148
+ wppa_log( 'Cron', 'Cron fixed treecounts for ' . $alb );
149
  }
150
  if ( time() > $start + 30 ) {
151
  wppa_schedule_treecount_update();
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.6.11
7
  *
8
  */
9
 
@@ -166,7 +166,15 @@ global $wppa_revno;
166
  case 'multitag':
167
  $wppa['taglist'] = wppa_sanitize_tags($atts['taglist']);
168
  $wppa['is_multitagbox'] = true;
169
- if ( $atts['cols'] ) $wppa['tagcols'] = $atts['cols'];
 
 
 
 
 
 
 
 
170
  break;
171
  case 'tagcloud':
172
  $wppa['taglist'] = wppa_sanitize_tags($atts['taglist']);
3
  * Package: wp-photo-album-plus
4
  *
5
  * get the albums via shortcode handler
6
+ * Version 6.6.12
7
  *
8
  */
9
 
166
  case 'multitag':
167
  $wppa['taglist'] = wppa_sanitize_tags($atts['taglist']);
168
  $wppa['is_multitagbox'] = true;
169
+ if ( $atts['cols'] ) {
170
+ $cols = explode( ',', $atts['cols'] );
171
+ $col = $cols[0];
172
+ if ( isset( $cols[1] ) && wppa_is_mobile() ) {
173
+ $col = $cols[1];
174
+ }
175
+ if ( ! wppa_is_int( $col ) || $col < '1' ) $col = '2'; // On error use default
176
+ $wppa['tagcols'] = $col;
177
+ }
178
  break;
179
  case 'tagcloud':
180
  $wppa['taglist'] = wppa_sanitize_tags($atts['taglist']);
wppa-functions.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various functions
6
- * Version 6.6.11
7
  *
8
  */
9
 
@@ -1601,12 +1601,12 @@ global $wppa_session;
1601
 
1602
  // all chunks
1603
  foreach ( $chunks as $chunk ) if ( strlen( trim( $chunk ) ) ) {
1604
- $words = wppa_index_raw_to_words( $chunk );
1605
  $photo_array = array();
1606
  // all words in the searchstring
1607
  foreach ( $words as $word ) {
1608
  $word = trim( $word );
1609
- if ( strlen( $word ) > 1 ) {
1610
  if ( strlen( $word ) > 20 ) $word = substr( $word, 0, 20 );
1611
  if ( wppa_switch( 'wild_front' ) ) {
1612
  $pidxs = $wpdb->get_results( "SELECT `slug`, `photos` FROM `".WPPA_INDEX."` WHERE `slug` LIKE '%".$word."%'", ARRAY_A );
@@ -2426,7 +2426,7 @@ global $wppa_done;
2426
  }
2427
  if ( wppa_opt( 'comment_notify' ) == 'admin' || wppa_opt( 'comment_notify' ) == 'both' || wppa_opt( 'comment_notify' ) == 'upadmin' ) {
2428
  // Mail admin
2429
- $moduser = get_user_by( 'id', '1' );
2430
  if ( ! in_array( $moduser->user_login, $sentto ) ) { // Already sent him?
2431
  $to = get_bloginfo( 'admin_email' );
2432
  $cont['3'] = $cont2;
@@ -2440,7 +2440,7 @@ global $wppa_done;
2440
  if ( wppa_opt( 'comment_notify' ) == 'upload' || wppa_opt( 'comment_notify' ) == 'upadmin' || wppa_opt( 'comment_notify' ) == 'upowner' ) {
2441
  // Mail uploader
2442
  $uploader = $wpdb->get_var( $wpdb->prepare( "SELECT `owner` FROM `".WPPA_PHOTOS."` WHERE `id` = %d", $id ) );
2443
- $moduser = get_user_by( 'login', $uploader );
2444
  if ( $moduser ) { // else it's an ip address ( anonymus uploader )
2445
  if ( ! in_array( $moduser->user_login, $sentto ) ) { // Already sent him?
2446
  $to = $moduser->user_email;
@@ -2460,7 +2460,7 @@ global $wppa_done;
2460
  $alb = $wpdb->get_var( $wpdb->prepare( "SELECT `album` FROM `".WPPA_PHOTOS."` WHERE `id` = %d", $id ) );
2461
  $owner = $wpdb->get_var( $wpdb->prepare( "SELECT `owner` FROM `".WPPA_ALBUMS."` WHERE `id` = %d", $alb ) );
2462
  if ( $owner == '--- public ---' ) $owner = 'admin';
2463
- $moduser = get_user_by( 'login', $owner );
2464
  if ( ! in_array( $moduser->user_login, $sentto ) ) { // Already sent him?
2465
  $to = $moduser->user_email;
2466
  if ( user_can( $moduser, 'wppa_comments' ) ) $cont['3'] = $cont2; else $cont['3'] = '';
@@ -2477,7 +2477,7 @@ global $wppa_done;
2477
  if ( $cmnts ) foreach( $cmnts as $cmnt ) {
2478
  $user = $cmnt['user'];
2479
  if ( ! in_array( $user, $sentto ) ) {
2480
- $cmuser = get_user_by( 'login', $user );
2481
  if ( $cmuser ) { // Not to an ip
2482
  $to = $cmuser->user_email;
2483
  $cont['3'] = '';
@@ -2846,9 +2846,16 @@ function wppa_get_thumb_frame_style( $glue = false, $film = '' ) {
2846
 
2847
  function wppa_get_thumb_frame_style_a( $glue = false, $film = '' ) {
2848
  static $wppaerrmsgxxx;
 
2849
 
2850
  // Init
2851
- $album = wppa( 'current_album' ) ? wppa_cache_album( wppa( 'current_album' ) ) : false;
 
 
 
 
 
 
2852
  $result = array( 'style'=> '', 'width' => '', 'height' => '' );
2853
 
2854
  // Comten alt display?
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various functions
6
+ * Version 6.6.12
7
  *
8
  */
9
 
1601
 
1602
  // all chunks
1603
  foreach ( $chunks as $chunk ) if ( strlen( trim( $chunk ) ) ) {
1604
+ $words = wppa_index_raw_to_words( $chunk, false, wppa_opt( 'search_min_length' ) );
1605
  $photo_array = array();
1606
  // all words in the searchstring
1607
  foreach ( $words as $word ) {
1608
  $word = trim( $word );
1609
+ if ( strlen( $word ) >= wppa_opt( 'search_min_length' ) ) {
1610
  if ( strlen( $word ) > 20 ) $word = substr( $word, 0, 20 );
1611
  if ( wppa_switch( 'wild_front' ) ) {
1612
  $pidxs = $wpdb->get_results( "SELECT `slug`, `photos` FROM `".WPPA_INDEX."` WHERE `slug` LIKE '%".$word."%'", ARRAY_A );
2426
  }
2427
  if ( wppa_opt( 'comment_notify' ) == 'admin' || wppa_opt( 'comment_notify' ) == 'both' || wppa_opt( 'comment_notify' ) == 'upadmin' ) {
2428
  // Mail admin
2429
+ $moduser = wppa_get_user_by( 'id', '1' );
2430
  if ( ! in_array( $moduser->user_login, $sentto ) ) { // Already sent him?
2431
  $to = get_bloginfo( 'admin_email' );
2432
  $cont['3'] = $cont2;
2440
  if ( wppa_opt( 'comment_notify' ) == 'upload' || wppa_opt( 'comment_notify' ) == 'upadmin' || wppa_opt( 'comment_notify' ) == 'upowner' ) {
2441
  // Mail uploader
2442
  $uploader = $wpdb->get_var( $wpdb->prepare( "SELECT `owner` FROM `".WPPA_PHOTOS."` WHERE `id` = %d", $id ) );
2443
+ $moduser = wppa_get_user_by( 'login', $uploader );
2444
  if ( $moduser ) { // else it's an ip address ( anonymus uploader )
2445
  if ( ! in_array( $moduser->user_login, $sentto ) ) { // Already sent him?
2446
  $to = $moduser->user_email;
2460
  $alb = $wpdb->get_var( $wpdb->prepare( "SELECT `album` FROM `".WPPA_PHOTOS."` WHERE `id` = %d", $id ) );
2461
  $owner = $wpdb->get_var( $wpdb->prepare( "SELECT `owner` FROM `".WPPA_ALBUMS."` WHERE `id` = %d", $alb ) );
2462
  if ( $owner == '--- public ---' ) $owner = 'admin';
2463
+ $moduser = wppa_get_user_by( 'login', $owner );
2464
  if ( ! in_array( $moduser->user_login, $sentto ) ) { // Already sent him?
2465
  $to = $moduser->user_email;
2466
  if ( user_can( $moduser, 'wppa_comments' ) ) $cont['3'] = $cont2; else $cont['3'] = '';
2477
  if ( $cmnts ) foreach( $cmnts as $cmnt ) {
2478
  $user = $cmnt['user'];
2479
  if ( ! in_array( $user, $sentto ) ) {
2480
+ $cmuser = wppa_get_user_by( 'login', $user );
2481
  if ( $cmuser ) { // Not to an ip
2482
  $to = $cmuser->user_email;
2483
  $cont['3'] = '';
2846
 
2847
  function wppa_get_thumb_frame_style_a( $glue = false, $film = '' ) {
2848
  static $wppaerrmsgxxx;
2849
+ global $wppa;
2850
 
2851
  // Init
2852
+ if ( isset( $wppa['current_album'] ) && wppa( 'current_album' ) > '0' ) {
2853
+ $album = wppa_cache_album( wppa( 'current_album' ) );
2854
+ }
2855
+ else {
2856
+ $album = false;
2857
+ }
2858
+
2859
  $result = array( 'style'=> '', 'width' => '', 'height' => '' );
2860
 
2861
  // Comten alt display?
wppa-htaccess.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various funcions
6
- * Version 6.6.01
7
  *
8
  */
9
 
@@ -96,41 +96,25 @@ global $wpdb;
96
  return false;
97
  }
98
 
99
- // If there are more than 200 albums, we do this as a cron job
100
- $n_albs = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "`" );
101
 
102
- // Big site?
103
- if ( $n_albs > 200 ) {
104
 
105
- // Are we a cron job?
106
- if ( wppa_is_cron() ) {
107
-
108
- // Remake required?
109
- if ( ! get_option( 'wppa_pl_htaccess_required' ) ) {
110
- return false;
111
- }
112
- }
113
-
114
- // Real time request
115
- else {
116
-
117
- // Tell cron it must be done
118
- update_option( 'wppa_pl_htaccess_required', true );
119
  return false;
120
  }
121
  }
122
 
123
- // Small
124
  else {
125
 
126
- // In cron?
127
- if ( wppa_is_cron() ) {
128
- return false;
129
- }
130
  }
131
 
132
- // Either big in cron and required, or small and realtime
133
-
134
  // Where are the photo source files?
135
  $source_root = str_replace( ABSPATH, '', wppa_opt( 'source_dir' ) );
136
 
@@ -179,7 +163,7 @@ global $wpdb;
179
  // Remove required flag
180
  delete_option( 'wppa_pl_htaccess_required' );
181
 
182
- wppa_log( 'Dbg', 'Create pl_htaccess took '.( time() - $tim ) . ' seconds.' );
183
  return true;
184
  }
185
 
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various funcions
6
+ * Version 6.6.12
7
  *
8
  */
9
 
96
  return false;
97
  }
98
 
99
+ // We do this as a cron job
 
100
 
101
+ // Are we a cron job?
102
+ if ( wppa_is_cron() ) {
103
 
104
+ // Remake required?
105
+ if ( ! get_option( 'wppa_pl_htaccess_required' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
106
  return false;
107
  }
108
  }
109
 
110
+ // Real time request
111
  else {
112
 
113
+ // Tell cron it must be done
114
+ update_option( 'wppa_pl_htaccess_required', true );
115
+ return false;
 
116
  }
117
 
 
 
118
  // Where are the photo source files?
119
  $source_root = str_replace( ABSPATH, '', wppa_opt( 'source_dir' ) );
120
 
163
  // Remove required flag
164
  delete_option( 'wppa_pl_htaccess_required' );
165
 
166
+ wppa_log( 'Cron', 'Create pl_htaccess took '.( time() - $tim ) . ' seconds.' );
167
  return true;
168
  }
169
 
wppa-index.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all indexing functions
6
- * Version 6.3.11
7
  *
8
  *
9
  */
@@ -16,27 +16,57 @@ global $pcount;
16
 
17
  if ( $type == 'album' ) {
18
 
 
 
 
 
 
 
 
 
 
 
 
19
  $album = wppa_cache_album( $id );
20
 
21
  // Find the raw text, all qTranslate languages
22
- $words = stripslashes($album['name']).' '.stripslashes($album['description']);
23
- if ( wppa_switch( 'search_cats' ) ) {
24
- $words .= ' '.$album['cats'];
25
- }
26
 
27
- $words = wppa_index_raw_to_words($words);
 
 
 
28
  foreach ( $words as $word ) {
 
 
29
  $indexline = $wpdb->get_row($wpdb->prepare("SELECT * FROM `".WPPA_INDEX."` WHERE `slug` = %s", $word), ARRAY_A);
30
- if ( ! $indexline ) { // create new entry
31
- $id = wppa_create_index_entry( array( 'slug' => $word, 'albums' => $album['id'] ) );
 
 
32
  }
33
- else { // Add to entry
34
- $oldalbums = wppa_index_string_to_array($indexline['albums']);
35
- if ( ! in_array($album['id'], $oldalbums) ) {
36
- $oldalbums[] = $album['id'];
37
- sort($oldalbums);
38
- $newalbums = wppa_index_array_to_string($oldalbums);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  $wpdb->query($wpdb->prepare( "UPDATE `".WPPA_INDEX."` SET `albums` = %s WHERE `id` = %s", $newalbums, $indexline['id']));
 
40
  }
41
  }
42
  }
@@ -45,46 +75,33 @@ global $pcount;
45
 
46
  elseif ( $type == 'photo' ) {
47
 
 
 
 
 
 
 
 
 
 
 
 
48
  $thumb = wppa_cache_thumb($id);
49
 
50
  // Find the raw text
51
- $desc = stripslashes($thumb['description']);
52
- $desc = wppa_filter_iptc( $desc, $thumb['id'] ); // Render IPTC tags
53
- $desc = wppa_filter_exif( $desc, $thumb['id'] ); // Render EXIF tags
54
- $custom = wppa_get_photo_item( $id, 'custom' );
55
- if ( $custom ) {
56
- $custom_data = unserialize( $custom );
57
- for ( $i = 0; $i < 10; $i++ ) {
58
- if ( wppa_switch( 'custom_visible_'.$i ) ) { // May be displayed
59
- $desc = str_replace( 'w#cd'.$i, __( stripslashes( $custom_data[$i] ) ), $desc ); // Data
60
- }
61
- else {
62
- $desc = str_replace( 'w#cd'.$i, '', $desc ); // Data
63
- }
64
- }
65
- }
66
- $words = stripslashes($thumb['name']).' '.$thumb['filename'].' '.$desc;
67
-
68
- if ( wppa_switch( 'search_tags' ) ) $words .= ' '.$thumb['tags']; // Tags
69
- if ( wppa_switch( 'search_comments' ) ) {
70
- $coms = $wpdb->get_results($wpdb->prepare( "SELECT `comment` FROM `" . WPPA_COMMENTS . "` WHERE `photo` = %s AND `status` = 'approved'", $thumb['id'] ), ARRAY_A );
71
- if ( $coms ) {
72
- foreach ( $coms as $com ) {
73
- $words .= ' '.stripslashes( $com['comment'] );
74
- }
75
- }
76
- }
77
 
78
  $words = wppa_index_raw_to_words($words); // convert raw string to sanitized array
79
  foreach ( $words as $word ) {
80
  $indexline = $wpdb->get_row($wpdb->prepare("SELECT * FROM `".WPPA_INDEX."` WHERE `slug` = %s", $word), ARRAY_A);
81
  if ( ! $indexline ) { // create new entry
82
- $id = wppa_create_index_entry( array( 'slug' => $word, 'photos' => $thumb['id'] ) );
83
  }
84
  else { // Add to entry
85
  $oldphotos = wppa_index_string_to_array($indexline['photos']);
86
- if ( ! in_array($thumb['id'], $oldphotos) ) {
87
- $oldphotos[] = $thumb['id'];
 
88
  sort($oldphotos);
89
  $newphotos = wppa_index_array_to_string($oldphotos);
90
  $wpdb->query($wpdb->prepare( "UPDATE `".WPPA_INDEX."` SET `photos` = %s WHERE `id` = %s", $newphotos, $indexline['id']));
@@ -99,15 +116,18 @@ global $pcount;
99
  }
100
 
101
  // Convert raw data string to indexable word array
102
- function wppa_index_raw_to_words($xtext, $noskips = false) {
103
 
104
  $ignore = array( '"', "'", '`', '\\', '>', '<', ',', ':', ';', '!', '?', '=', '_',
105
  '[', ']', '(', ')', '{', '}', '..', '...', '....', "\n", "\r",
106
  "\t", '.jpg', '.png', '.gif', '&#039', '&amp',
107
  'w#cc0', 'w#cc1', 'w#cc2', 'w#cc3', 'w#cc4', 'w#cc5', 'w#cc6', 'w#cc7', 'w#cc8', 'w#cc9'
108
  );
 
 
 
109
  if ( $noskips ) $skips = array();
110
- else $skips = get_option('wppa_index_skips', array());
111
 
112
  $result = array();
113
  if ( $xtext ) {
@@ -116,7 +136,14 @@ function wppa_index_raw_to_words($xtext, $noskips = false) {
116
  $text = wppa_strip_tags($text, 'script&style'); // strip style and script tags inclusive content
117
  $text = str_replace('>', '> ', $text); // Make sure <td>word1</td><td>word2</td> will not endup in 'word1word2', but in 'word1' 'word2'
118
  $text = strip_tags($text); // Now strip the tags
 
119
  $text = str_replace($ignore, ' ', $text); // Remove funny chars
 
 
 
 
 
 
120
  $text = trim($text);
121
  $text = trim($text, " ./-");
122
  while ( strpos($text, ' ') ) $text = str_replace(' ', ' ', $text); // Compress spaces
@@ -124,33 +151,31 @@ function wppa_index_raw_to_words($xtext, $noskips = false) {
124
  foreach ( $words as $word ) {
125
  $word = trim($word);
126
  $word = trim($word, " ./-");
127
- if ( strlen($word) > '1' && ! in_array($word, $skips) ) $result[] = $word;
128
  if ( strpos($word, '-') !== false ) {
129
  $fracts = explode('-', $word);
130
  foreach ( $fracts as $fract ) {
131
  $fract = trim($fract);
132
  $fract = trim($fract, " ./-");
133
- if ( strlen($fract) > '1' && ! in_array($fract, $skips) ) $result[] = $fract;
134
  }
135
  }
136
  }
137
  }
138
 
139
- // sort
140
- sort( $result );
141
-
142
- // Remove dups
143
- $start = 0;
144
- foreach ( array_keys( $result ) as $key ) {
145
- if ( $key > 0 ) {
146
- if ( $result[$key] == $result[$start] ) {
147
- unset ( $result[$key] );
148
- }
149
- else {
150
- $start = $key;
151
  }
152
  }
153
  }
 
 
 
 
154
  return $result;
155
  }
156
 
@@ -159,22 +184,33 @@ function wppa_index_string_to_array($string) {
159
  // Anything?
160
  if ( ! $string ) return array();
161
  // Any ranges?
162
- if ( ! strstr($string, '..') ) return explode(',', $string); // No
 
 
 
 
 
 
163
  // Yes
164
  $temp = explode(',', $string);
165
  $result = array();
166
  foreach ( $temp as $t ) {
167
- if ( ! strstr($t, '..') ) $result[] = $t;
168
  else {
169
  $range = explode('..', $t);
170
  $from = $range['0'];
171
  $to = $range['1'];
172
  while ( $from <= $to ) {
173
- $result[] = $from;
174
  $from++;
175
  }
176
  }
177
  }
 
 
 
 
 
178
  return $result;
179
  }
180
 
@@ -194,8 +230,16 @@ function wppa_index_array_remove_dups( $array ) {
194
  }
195
 
196
  // Compress array ranges and convert to string
197
- function wppa_index_array_to_string($array) {
198
- sort($array, SORT_NUMERIC);
 
 
 
 
 
 
 
 
199
  $result = '';
200
  $lastitem = '-1';
201
  $isrange = false;
@@ -225,7 +269,18 @@ function wppa_index_array_to_string($array) {
225
  function wppa_index_remove( $type, $id ) {
226
  global $wpdb;
227
 
228
- $iam_big = ( $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_INDEX."`" ) > '10000' ); // More than 100.000 index entries,
 
 
 
 
 
 
 
 
 
 
 
229
  if ( $iam_big && $id < '100' ) return; // Need at least 3 digits to match
230
 
231
  if ( $type == 'album' ) {
@@ -240,7 +295,7 @@ global $wpdb;
240
  if ( $indexes ) foreach ( $indexes as $indexline ) {
241
  $array = wppa_index_string_to_array($indexline['albums']);
242
  foreach ( array_keys($array) as $k ) {
243
- if ( $array[$k] == $id ) {
244
  unset ( $array[$k] );
245
  $string = wppa_index_array_to_string($array);
246
  $wpdb->query( "UPDATE `".WPPA_INDEX."` SET `albums` = '".$string."' WHERE `id` = ".$indexline['id'] );
@@ -260,7 +315,7 @@ global $wpdb;
260
  if ( $indexes ) foreach ( $indexes as $indexline ) {
261
  $array = wppa_index_string_to_array($indexline['photos']);
262
  foreach ( array_keys($array) as $k ) {
263
- if ( $array[$k] == $id ) {
264
  unset ( $array[$k] );
265
  $string = wppa_index_array_to_string($array);
266
  $wpdb->query( "UPDATE `".WPPA_INDEX."` SET `photos` = '".$string."' WHERE `id` = ".$indexline['id'] );
@@ -277,6 +332,17 @@ global $wpdb;
277
  function wppa_index_quick_remove($type, $id) {
278
  global $wpdb;
279
 
 
 
 
 
 
 
 
 
 
 
 
280
  if ( $type == 'album' ) {
281
 
282
  $album = wppa_cache_album($id);
@@ -342,8 +408,9 @@ function wppa_index_update($type, $id) {
342
  // The words in the new photo description should be left out
343
  function wppa_index_compute_skips() {
344
 
345
- $user_skips = '';
346
- $words = wppa_index_raw_to_words( wppa_opt( 'newphoto_description' ) . ' ' . $user_skips, 'noskips' );
 
347
  sort( $words );
348
 
349
  $result = array();
@@ -354,5 +421,54 @@ function wppa_index_compute_skips() {
354
  $last = $word;
355
  }
356
  }
357
- update_option('wppa_index_skips', $result);
358
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all indexing functions
6
+ * Version 6.6.12
7
  *
8
  *
9
  */
16
 
17
  if ( $type == 'album' ) {
18
 
19
+ // If there is a cron job running adding to the index and this is not that cron job, do nothing
20
+ if ( get_option( 'wppa_remake_index_albums_user' ) == 'cron-job' && ! wppa_is_cron() ) {
21
+ return;
22
+ }
23
+
24
+ // If no user runs the remake proc, start it as cron job
25
+ if ( ! get_option( 'wppa_remake_index_albums_user' ) ) {
26
+ wppa_schedule_maintenance_proc( 'wppa_remake_index_albums' );
27
+ return;
28
+ }
29
+
30
  $album = wppa_cache_album( $id );
31
 
32
  // Find the raw text, all qTranslate languages
33
+ $words = wppa_index_get_raw_album( $id );
 
 
 
34
 
35
+ // Convert to santized array of ndexable words
36
+ $words = wppa_index_raw_to_words( $words );
37
+
38
+ // Process all the words to see if they must be added to the index
39
  foreach ( $words as $word ) {
40
+
41
+ // Get the row of the index table where the word is registered.
42
  $indexline = $wpdb->get_row($wpdb->prepare("SELECT * FROM `".WPPA_INDEX."` WHERE `slug` = %s", $word), ARRAY_A);
43
+
44
+ // If this line does not exist yet, create it with only one album number as data
45
+ if ( ! $indexline ) {
46
+ wppa_create_index_entry( array( 'slug' => $word, 'albums' => $id ) );
47
  }
48
+
49
+ // Index line already exutst, process this album id for this word
50
+ else {
51
+
52
+ // Convert existing album ids to an array
53
+ $oldalbums = wppa_index_string_to_array( $indexline['albums'] );
54
+
55
+ // If not in yet...
56
+ if ( ! in_array( $id, $oldalbums ) ) {
57
+
58
+ // Add it
59
+ $oldalbums[] = $id;
60
+
61
+ // Report addition
62
+ wppa_log( 'Cron', 'Adding album # {b}'.$id.'{/b} to index slug {b}'.$word.'{/b}');
63
+
64
+ // Covert to string again
65
+ $newalbums = wppa_index_array_to_string( $oldalbums );
66
+
67
+ // Update db
68
  $wpdb->query($wpdb->prepare( "UPDATE `".WPPA_INDEX."` SET `albums` = %s WHERE `id` = %s", $newalbums, $indexline['id']));
69
+
70
  }
71
  }
72
  }
75
 
76
  elseif ( $type == 'photo' ) {
77
 
78
+ // If there is a cron job running adding to the index and this is not that cron job, do nothing
79
+ if ( get_option( 'wppa_remake_index_photos_user' ) == 'cron-job' && ! wppa_is_cron() ) {
80
+ return;
81
+ }
82
+
83
+ // If no user runs the remake proc, start it as cron job
84
+ if ( ! get_option( 'wppa_remake_index_photos_user' ) ) {
85
+ wppa_schedule_maintenance_proc( 'wppa_remake_index_photos' );
86
+ return;
87
+ }
88
+
89
  $thumb = wppa_cache_thumb($id);
90
 
91
  // Find the raw text
92
+ $words = wppa_index_get_raw_photo($id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
  $words = wppa_index_raw_to_words($words); // convert raw string to sanitized array
95
  foreach ( $words as $word ) {
96
  $indexline = $wpdb->get_row($wpdb->prepare("SELECT * FROM `".WPPA_INDEX."` WHERE `slug` = %s", $word), ARRAY_A);
97
  if ( ! $indexline ) { // create new entry
98
+ wppa_create_index_entry( array( 'slug' => $word, 'photos' => $id ) );
99
  }
100
  else { // Add to entry
101
  $oldphotos = wppa_index_string_to_array($indexline['photos']);
102
+ if ( ! in_array( $id, $oldphotos ) ) {
103
+ $oldphotos[] = $id;
104
+ wppa_log( 'Cron', 'Adding photo # {b}'.$id.'{/b} to index slug {b}'.$word.'{/b}');
105
  sort($oldphotos);
106
  $newphotos = wppa_index_array_to_string($oldphotos);
107
  $wpdb->query($wpdb->prepare( "UPDATE `".WPPA_INDEX."` SET `photos` = %s WHERE `id` = %s", $newphotos, $indexline['id']));
116
  }
117
 
118
  // Convert raw data string to indexable word array
119
+ function wppa_index_raw_to_words($xtext, $noskips = false, $minlen = '2' ) {
120
 
121
  $ignore = array( '"', "'", '`', '\\', '>', '<', ',', ':', ';', '!', '?', '=', '_',
122
  '[', ']', '(', ')', '{', '}', '..', '...', '....', "\n", "\r",
123
  "\t", '.jpg', '.png', '.gif', '&#039', '&amp',
124
  'w#cc0', 'w#cc1', 'w#cc2', 'w#cc3', 'w#cc4', 'w#cc5', 'w#cc6', 'w#cc7', 'w#cc8', 'w#cc9'
125
  );
126
+ if ( wppa_switch( 'index_ignore_slash' ) ) {
127
+ $ignore[] = '/';
128
+ }
129
  if ( $noskips ) $skips = array();
130
+ else $skips = get_option( 'wppa_index_skips', array() );
131
 
132
  $result = array();
133
  if ( $xtext ) {
136
  $text = wppa_strip_tags($text, 'script&style'); // strip style and script tags inclusive content
137
  $text = str_replace('>', '> ', $text); // Make sure <td>word1</td><td>word2</td> will not endup in 'word1word2', but in 'word1' 'word2'
138
  $text = strip_tags($text); // Now strip the tags
139
+ // Strip qTranslate language shortcodes: [:*]
140
  $text = str_replace($ignore, ' ', $text); // Remove funny chars
141
+ $text = str_replace(array('è', 'é', 'ë'), 'e', $text); // Remove accents
142
+ $text = str_replace(array('ò', 'ó', 'ö'), 'o', $text); //
143
+ $text = str_replace(array('à', 'á', 'ä'), 'a', $text); //
144
+ $text = str_replace(array('ù', 'ú', 'ü'), 'u', $text); //
145
+ $text = str_replace(array('ì', 'í', 'ï'), 'i', $text); //
146
+ $text = str_replace('ç', 'c', $text); // Remoce cédille
147
  $text = trim($text);
148
  $text = trim($text, " ./-");
149
  while ( strpos($text, ' ') ) $text = str_replace(' ', ' ', $text); // Compress spaces
151
  foreach ( $words as $word ) {
152
  $word = trim($word);
153
  $word = trim($word, " ./-");
154
+ if ( strlen($word) >= $minlen && ! in_array($word, $skips) ) $result[] = $word;
155
  if ( strpos($word, '-') !== false ) {
156
  $fracts = explode('-', $word);
157
  foreach ( $fracts as $fract ) {
158
  $fract = trim($fract);
159
  $fract = trim($fract, " ./-");
160
+ if ( strlen($fract) >= $minlen && ! in_array($fract, $skips) ) $result[] = $fract;
161
  }
162
  }
163
  }
164
  }
165
 
166
+ // Remove numbers optionaly
167
+ if ( wppa_switch( 'search_numbers_void' ) ) {
168
+ foreach ( array_keys( $result ) as $key ) {
169
+ $t = ltrim( $result[$key], '0' ); // Strip leading zeroes
170
+ if ( ! $t || is_numeric( $t ) ) {
171
+ unset( $result[$key] );
 
 
 
 
 
 
172
  }
173
  }
174
  }
175
+
176
+ // Remove dups and sort
177
+ $result = array_unique( $result );
178
+
179
  return $result;
180
  }
181
 
184
  // Anything?
185
  if ( ! $string ) return array();
186
  // Any ranges?
187
+ if ( ! strstr($string, '..') ) {
188
+ $result = explode(',', $string);
189
+ foreach( array_keys($result) as $key ) {
190
+ $result[$key] = strval($result[$key]);
191
+ }
192
+ return $result;
193
+ }
194
  // Yes
195
  $temp = explode(',', $string);
196
  $result = array();
197
  foreach ( $temp as $t ) {
198
+ if ( ! strstr($t, '..') ) $result[] = intval($t);
199
  else {
200
  $range = explode('..', $t);
201
  $from = $range['0'];
202
  $to = $range['1'];
203
  while ( $from <= $to ) {
204
+ $result[] = strval($from);
205
  $from++;
206
  }
207
  }
208
  }
209
+
210
+ foreach( array_keys($result) as $key ) {
211
+ $result[$key] = strval($result[$key]);
212
+ }
213
+
214
  return $result;
215
  }
216
 
230
  }
231
 
232
  // Compress array ranges and convert to string
233
+ function wppa_index_array_to_string( $array ) {
234
+
235
+ // Remove empty elements
236
+ foreach( array_keys( $array ) as $idx ) {
237
+ if ( ! $array[$idx] ) {
238
+ unset( $array[$idx] );
239
+ }
240
+ }
241
+
242
+ sort( $array, SORT_NUMERIC );
243
  $result = '';
244
  $lastitem = '-1';
245
  $isrange = false;
269
  function wppa_index_remove( $type, $id ) {
270
  global $wpdb;
271
 
272
+ // If there is a cron job running cleaning the index and this is not that cron job, do nothing
273
+ if ( get_option( 'wppa_cleanup_index_user' ) == 'cron-job' && ! wppa_is_cron() ) {
274
+ return;
275
+ }
276
+
277
+ // If no user runs the cleanup proc, start it as cron job
278
+ if ( ! get_option( 'wppa_cleanup_index_user' ) ) {
279
+ wppa_schedule_maintenance_proc( 'wppa_cleanup_index' );
280
+ return;
281
+ }
282
+
283
+ $iam_big = ( $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_INDEX."`" ) > '10000' ); // More than 10.000 index entries,
284
  if ( $iam_big && $id < '100' ) return; // Need at least 3 digits to match
285
 
286
  if ( $type == 'album' ) {
295
  if ( $indexes ) foreach ( $indexes as $indexline ) {
296
  $array = wppa_index_string_to_array($indexline['albums']);
297
  foreach ( array_keys($array) as $k ) {
298
+ if ( $array[$k] == intval($id) ) {
299
  unset ( $array[$k] );
300
  $string = wppa_index_array_to_string($array);
301
  $wpdb->query( "UPDATE `".WPPA_INDEX."` SET `albums` = '".$string."' WHERE `id` = ".$indexline['id'] );
315
  if ( $indexes ) foreach ( $indexes as $indexline ) {
316
  $array = wppa_index_string_to_array($indexline['photos']);
317
  foreach ( array_keys($array) as $k ) {
318
+ if ( $array[$k] == intval($id) ) {
319
  unset ( $array[$k] );
320
  $string = wppa_index_array_to_string($array);
321
  $wpdb->query( "UPDATE `".WPPA_INDEX."` SET `photos` = '".$string."' WHERE `id` = ".$indexline['id'] );
332
  function wppa_index_quick_remove($type, $id) {
333
  global $wpdb;
334
 
335
+ // If there is a cron job running cleaning the index and this is not that cron job, do nothing
336
+ if ( get_option( 'wppa_cleanup_index_user' ) == 'cron-job' && ! wppa_is_cron() ) {
337
+ return;
338
+ }
339
+
340
+ // If no user runs the cleanup proc, start it as cron job
341
+ if ( ! get_option( 'wppa_cleanup_index_user' ) ) {
342
+ wppa_schedule_maintenance_proc( 'wppa_cleanup_index' );
343
+ return;
344
+ }
345
+
346
  if ( $type == 'album' ) {
347
 
348
  $album = wppa_cache_album($id);
408
  // The words in the new photo description should be left out
409
  function wppa_index_compute_skips() {
410
 
411
+ $user_skips = wppa_opt( 'search_user_void' );
412
+ $system_skips = 'w#name,w#filename,w#owner,w#displayname,w#id,w#tags,w#cats,w#timestamp,w#modified,w#views,w#amx,w#amy,w#amfs,w#url,w#hrurl,w#tnurl,w#pl';
413
+ $words = wppa_index_raw_to_words( wppa_opt( 'newphoto_description' ) . ' ' . $user_skips . ' ' . $system_skips, 'noskips' );
414
  sort( $words );
415
 
416
  $result = array();
421
  $last = $word;
422
  }
423
  }
424
+ update_option( 'wppa_index_skips', $result );
425
  }
426
+
427
+ // Find the raw text for album, all qTranslate languages
428
+ function wppa_index_get_raw_album( $id ) {
429
+ $album = wppa_cache_album( $id );
430
+ $words = wppa_get_album_desc( $id ) . ' ' . wppa_get_album_name( $id );
431
+ // $words = stripslashes($album['name']).' '.stripslashes($album['description']);
432
+ if ( wppa_switch( 'search_cats' ) ) {
433
+ $words .= ' '.$album['cats'];
434
+ }
435
+ return $words;
436
+ }
437
+
438
+ function wppa_index_get_raw_photo( $id ) {
439
+ global $wpdb;
440
+
441
+ $thumb = wppa_cache_thumb( $id );
442
+ /*
443
+ $desc = stripslashes($thumb['description']);
444
+ $desc = wppa_filter_iptc( $desc, $thumb['id'] ); // Render IPTC tags
445
+ $desc = wppa_filter_exif( $desc, $thumb['id'] ); // Render EXIF tags
446
+
447
+ $custom = wppa_get_photo_item( $id, 'custom' );
448
+ if ( $custom ) {
449
+ $custom_data = unserialize( $custom );
450
+ for ( $i = 0; $i < 10; $i++ ) {
451
+ if ( wppa_switch( 'custom_visible_'.$i ) ) { // May be displayed
452
+ $desc = str_replace( 'w#cd'.$i, __( stripslashes( $custom_data[$i] ) ), $desc ); // Data
453
+ }
454
+ else {
455
+ $desc = str_replace( 'w#cd'.$i, '', $desc ); // Data
456
+ }
457
+ }
458
+ }
459
+ $words = stripslashes($thumb['name']).' '.$thumb['filename'].' '.$desc;
460
+ */
461
+ $words = wppa_get_photo_desc( $id ) . ' ' . wppa_get_photo_name( $id );
462
+
463
+ if ( wppa_switch( 'search_tags' ) ) $words .= ' '.$thumb['tags']; // Tags
464
+ if ( wppa_switch( 'search_comments' ) ) {
465
+ $coms = $wpdb->get_results($wpdb->prepare( "SELECT `comment` FROM `" . WPPA_COMMENTS . "` WHERE `photo` = %s AND `status` = 'approved'", $thumb['id'] ), ARRAY_A );
466
+ if ( $coms ) {
467
+ foreach ( $coms as $com ) {
468
+ $words .= ' '.stripslashes( $com['comment'] );
469
+ }
470
+ }
471
+ }
472
+
473
+ return $words;
474
+ }
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.6.04
8
  */
9
 
10
  /* LOAD SIDEBAR WIDGETS */
@@ -230,6 +230,7 @@ global $pagenow;
230
  return;
231
  }
232
 
 
233
  // Regen cron job crashed?
234
  if ( get_option( 'wppa_regen_thumbs_lasttimestamp' ) ) {
235
  if ( get_option( 'wppa_regen_thumbs_lasttimestamp' ) < ( time() - 900 ) ) {
@@ -257,11 +258,11 @@ global $pagenow;
257
  wppa_error_message( __( 'Please restart cron job: Remake index albums in Table VIII-A8', 'wp-photo-album-plus' ) );
258
  }
259
  }
260
-
261
  // Remake photo index required?
262
  if ( get_option( 'wppa_remake_index_photos_status' ) || get_option( 'wppa_index_need_remake', 'no') == 'yes' ) {
263
  if ( strpos( get_option( 'wppa_remake_index_photos_status' ), 'cron' ) === false ) {
264
- wppa_error_message( __('The photo index table needs to be rebuilt. Please run <i>Photo Albums -> Settings</i> admin page <i>Table VIII-A9</i>' , 'wp-photo-album-plus') );
265
  update_option( 'wppa_remake_index_photos_status', 'required' );
266
  }
267
  }
@@ -269,7 +270,7 @@ global $pagenow;
269
  // Remake album index required?
270
  if ( get_option( 'wppa_remake_index_albums_status' ) || get_option( 'wppa_index_need_remake', 'no') == 'yes' ) {
271
  if ( strpos( get_option( 'wppa_remake_index_albums_status' ), 'cron' ) === false ) {
272
- wppa_error_message( __('The album index table needs to be rebuilt. Please run <i>Photo Albums -> Settings</i> admin page <i>Table VIII-A8</i>' , 'wp-photo-album-plus') );
273
  update_option( 'wppa_remake_index_albums_status', 'required' );
274
  }
275
  }
4
  *
5
  * This file loads required php files and contains all functions used in init actions.
6
  *
7
+ * Version 6.6.12
8
  */
9
 
10
  /* LOAD SIDEBAR WIDGETS */
230
  return;
231
  }
232
 
233
+ /*
234
  // Regen cron job crashed?
235
  if ( get_option( 'wppa_regen_thumbs_lasttimestamp' ) ) {
236
  if ( get_option( 'wppa_regen_thumbs_lasttimestamp' ) < ( time() - 900 ) ) {
258
  wppa_error_message( __( 'Please restart cron job: Remake index albums in Table VIII-A8', 'wp-photo-album-plus' ) );
259
  }
260
  }
261
+ */
262
  // Remake photo index required?
263
  if ( get_option( 'wppa_remake_index_photos_status' ) || get_option( 'wppa_index_need_remake', 'no') == 'yes' ) {
264
  if ( strpos( get_option( 'wppa_remake_index_photos_status' ), 'cron' ) === false ) {
265
+ wppa_error_message( __('The photo index table needs to be rebuilt. Please run <i>Photo Albums -> Settings</i> admin page <i>Table VIII-A8.2</i>' , 'wp-photo-album-plus') );
266
  update_option( 'wppa_remake_index_photos_status', 'required' );
267
  }
268
  }
270
  // Remake album index required?
271
  if ( get_option( 'wppa_remake_index_albums_status' ) || get_option( 'wppa_index_need_remake', 'no') == 'yes' ) {
272
  if ( strpos( get_option( 'wppa_remake_index_albums_status' ), 'cron' ) === false ) {
273
+ wppa_error_message( __('The album index table needs to be rebuilt. Please run <i>Photo Albums -> Settings</i> admin page <i>Table VIII-A8.1</i>' , 'wp-photo-album-plus') );
274
  update_option( 'wppa_remake_index_albums_status', 'required' );
275
  }
276
  }
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.6.09
7
  *
8
  */
9
 
@@ -109,7 +109,7 @@ static $album_cache_2;
109
  }
110
  else {
111
  wppa_dbg_msg( 'Album '.$id.' does not exist (cache album)', 'red' );
112
- wppa_log( 'dbg', 'Album '.$id.' does not exist (cache album)' );
113
  return false;
114
  }
115
  }
@@ -236,7 +236,7 @@ function wppa_get_photo_name( $id, $add_owner = false, $add_medal = false, $esc_
236
 
237
  // Add owner?
238
  if ( $add_owner ) {
239
- $user = get_user_by( 'login', $thumb['owner'] );
240
  if ( $user ) {
241
  if ( $show_name ) {
242
  if ( wppa_switch( 'owner_on_new_line' ) ) {
@@ -351,7 +351,7 @@ function wppa_translate_photo_keywords( $id, $text ) {
351
  $result = str_replace( 'w#pl', wppa_get_source_pl( $id ), $result );
352
  $result = str_replace( 'w#rating', wppa_get_rating_by_id( $id, 'nolabel' ), $result );
353
 
354
- $user = get_user_by( 'login', $thumb['owner'] );
355
  if ( $user ) {
356
  $result = str_replace( 'w#displayname', $user->display_name, $result );
357
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains functions to retrieve album and photo items
6
+ * Version 6.6.12
7
  *
8
  */
9
 
109
  }
110
  else {
111
  wppa_dbg_msg( 'Album '.$id.' does not exist (cache album)', 'red' );
112
+ wppa_log( 'dbg', 'Album '.$id.' does not exist (cache album)', true );
113
  return false;
114
  }
115
  }
236
 
237
  // Add owner?
238
  if ( $add_owner ) {
239
+ $user = wppa_get_user_by( 'login', $thumb['owner'] );
240
  if ( $user ) {
241
  if ( $show_name ) {
242
  if ( wppa_switch( 'owner_on_new_line' ) ) {
351
  $result = str_replace( 'w#pl', wppa_get_source_pl( $id ), $result );
352
  $result = str_replace( 'w#rating', wppa_get_rating_by_id( $id, 'nolabel' ), $result );
353
 
354
+ $user = wppa_get_user_by( 'login', $thumb['owner'] );
355
  if ( $user ) {
356
  $result = str_replace( 'w#displayname', $user->display_name, $result );
357
  }
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.6.11
7
  *
8
  */
9
 
@@ -12,17 +12,8 @@ if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
12
  // For cron:
13
  require_once 'wppa-admin-functions.php';
14
 
15
- // Main maintenace module
16
- // Must return a string like: errormesssage||$slug||status||togo
17
- function wppa_do_maintenance_proc( $slug ) {
18
- global $wpdb;
19
- global $wppa_session;
20
- global $wppa_supported_video_extensions;
21
- global $wppa_supported_audio_extensions;
22
-
23
- // Check for multiple maintenance procs
24
- if ( ! wppa_switch( 'maint_ignore_concurrency_error' ) && ! wppa_is_cron() ) {
25
- $all_slugs = array( 'wppa_remake_index_albums',
26
  'wppa_remove_empty_albums',
27
  'wppa_remake_index_photos',
28
  'wppa_apply_new_photodesc_all',
@@ -62,12 +53,24 @@ global $wppa_supported_audio_extensions;
62
  'wppa_create_o1_files',
63
  'wppa_owner_to_name_proc',
64
  'wppa_move_all_photos',
 
 
65
 
 
 
 
 
 
 
 
 
66
 
67
- );
68
- foreach ( array_keys( $all_slugs ) as $key ) {
69
- if ( $all_slugs[$key] != $slug ) {
70
- if ( get_option( $all_slugs[$key].'_togo', '0') ) { // Process running
 
 
71
  return __('You can run only one maintenance procedure at a time', 'wp-photo-album-plus').'||'.$slug.'||'.__('Error', 'wp-photo-album-plus').'||'.''.'||'.'';
72
  }
73
  }
@@ -87,8 +90,9 @@ global $wppa_supported_audio_extensions;
87
  wppa_extend_session();
88
 
89
  // Initialize
90
- // Cron job: 30 sec, realtime: 5 sec
91
- $endtime = ( wppa_is_cron() ? time() + '30' : time() + '5' );
 
92
  $chunksize = '1000';
93
  $lastid = strval( intval ( get_option( $slug.'_last', '0' ) ) );
94
  $errtxt = '';
@@ -114,7 +118,7 @@ global $wppa_supported_audio_extensions;
114
  // Pre-processing needed?
115
  if ( $lastid == '0' ) {
116
  if ( wppa_is_cron() ) {
117
- wppa_log( 'Obs', 'Cron job ' . $slug . ' started.' );
118
  }
119
  else {
120
  wppa_log( 'Obs', 'Maintenance proc ' . $slug . ' started.' );
@@ -127,6 +131,7 @@ global $wppa_supported_audio_extensions;
127
  if ( ! wppa_is_cron() ) {
128
  $wpdb->query( "UPDATE `" . WPPA_INDEX . "` SET `albums` = ''" );
129
  }
 
130
  break;
131
 
132
  case 'wppa_remake_index_photos':
@@ -138,6 +143,10 @@ global $wppa_supported_audio_extensions;
138
  wppa_index_compute_skips();
139
  break;
140
 
 
 
 
 
141
  case 'wppa_recup':
142
 
143
  // Pre-Clear exif and iptc tables only if not cron
@@ -231,10 +240,6 @@ global $wppa_supported_audio_extensions;
231
 
232
  case 'wppa_remake_index_albums':
233
 
234
- // If done as cron job, no initial clear has been done
235
- if ( wppa_is_cron() ) {
236
- wppa_index_remove( 'album', $id );
237
- }
238
  wppa_index_add( 'album', $id );
239
  break;
240
 
@@ -344,10 +349,6 @@ global $wppa_supported_audio_extensions;
344
 
345
  case 'wppa_remake_index_photos':
346
 
347
- // If done as cron job, no initial clear has been done
348
- if ( wppa_is_cron() ) {
349
- wppa_index_remove( 'photo', $id );
350
- }
351
  wppa_index_add( 'photo', $id );
352
  break;
353
 
@@ -789,34 +790,133 @@ global $wppa_supported_audio_extensions;
789
  }
790
  break; // End process photos
791
 
792
- // Single action maintenance modules
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
793
 
794
- // case 'wppa_list_index':
795
- // break;
 
 
 
 
 
796
 
797
- // case 'wppa_blacklist_user':
798
- // break;
799
 
800
- // case 'wppa_un_blacklist_user':
801
- // break;
 
 
 
802
 
803
- // case 'wppa_rating_clear':
804
- // break;
 
 
 
 
 
 
 
 
 
 
 
 
805
 
806
- // case 'wppa_viewcount_clear':
807
- // break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
808
 
809
- // case 'wppa_iptc_clear':
810
- // break;
 
 
 
 
 
 
 
 
 
 
 
811
 
812
- // case 'wppa_exif_clear':
813
- // break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
814
 
815
  default:
816
  $errtxt = 'Unimplemented maintenance slug: '.strip_tags( $slug );
817
  }
818
 
819
- // either $albums / $photos has been exhousted ( for this try ) or time is up
820
 
821
  // Post proc this try:
822
  switch ( $slug ) {
@@ -828,6 +928,9 @@ global $wppa_supported_audio_extensions;
828
  break;
829
  }
830
 
 
 
 
831
  // Find togo
832
  if ( $slug == 'wppa_cleanup' ) {
833
  $togo = $topid - $lastid;
@@ -890,6 +993,7 @@ global $wppa_supported_audio_extensions;
890
  switch ( $slug ) {
891
  case 'wppa_remake_index_albums':
892
  case 'wppa_remake_index_photos':
 
893
  $wpdb->query( "DELETE FROM `".WPPA_INDEX."` WHERE `albums` = '' AND `photos` = ''" ); // Remove empty entries
894
  delete_option( 'wppa_index_need_remake' );
895
  break;
@@ -930,16 +1034,28 @@ global $wppa_supported_audio_extensions;
930
  break;
931
  }
932
 
933
- wppa_log( 'Obs', 'Maintenance proc '.$slug.' completed' );
 
 
 
 
 
934
 
935
  }
936
 
937
  wppa_save_session();
938
 
939
  if ( wppa_is_cron() ) {
940
- wppa_log( 'obs', $errtxt.'||'.$slug.'||'.$status.'||'.$togo.'||'.$reload );
941
  if ( get_option( $slug . '_ad_inf' ) == 'yes' ) {
942
- wppa_schedule_maintenance_proc( $slug );
 
 
 
 
 
 
 
943
  }
944
  }
945
  return $errtxt.'||'.$slug.'||'.$status.'||'.$togo.'||'.$reload;
@@ -1027,7 +1143,7 @@ global $wppa_log_file;
1027
  '<div style="float:left; clear:both; width:100%; overflow:auto; word-wrap:none;" >';
1028
 
1029
  if ( ! $file = @ fopen( $wppa_log_file, 'r' ) ) {
1030
- $result .= __( 'There are no error log messages', 'wp-photo-album-plus' );
1031
  }
1032
  else {
1033
  $size = filesize( $wppa_log_file );
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains (not yet, but in the future maybe) all the maintenance routines
6
+ * Version 6.6.12
7
  *
8
  */
9
 
12
  // For cron:
13
  require_once 'wppa-admin-functions.php';
14
 
15
+ global $wppa_all_maintenance_slugs;
16
+ $wppa_all_maintenance_slugs = array( 'wppa_remake_index_albums',
 
 
 
 
 
 
 
 
 
17
  'wppa_remove_empty_albums',
18
  'wppa_remake_index_photos',
19
  'wppa_apply_new_photodesc_all',
53
  'wppa_create_o1_files',
54
  'wppa_owner_to_name_proc',
55
  'wppa_move_all_photos',
56
+ 'wppa_cleanup_index',
57
+ );
58
 
59
+ // Main maintenace module
60
+ // Must return a string like: errormesssage||$slug||status||togo
61
+ function wppa_do_maintenance_proc( $slug ) {
62
+ global $wpdb;
63
+ global $wppa_session;
64
+ global $wppa_supported_video_extensions;
65
+ global $wppa_supported_audio_extensions;
66
+ global $wppa_all_maintenance_slugs;
67
 
68
+ // Check for multiple maintenance procs
69
+ if ( ! wppa_switch( 'maint_ignore_concurrency_error' ) && ! wppa_is_cron() ) {
70
+
71
+ foreach ( array_keys( $wppa_all_maintenance_slugs ) as $key ) {
72
+ if ( $wppa_all_maintenance_slugs[$key] != $slug ) {
73
+ if ( get_option( $wppa_all_maintenance_slugs[$key].'_togo', '0') ) { // Process running
74
  return __('You can run only one maintenance procedure at a time', 'wp-photo-album-plus').'||'.$slug.'||'.__('Error', 'wp-photo-album-plus').'||'.''.'||'.'';
75
  }
76
  }
90
  wppa_extend_session();
91
 
92
  // Initialize
93
+ // Cron job: limit-30 sec, realtime: 5 sec
94
+ $limit = min( 60, max( 30, ini_get( 'max_execution_time' ) ) );
95
+ $endtime = ( wppa_is_cron() ? time() + $limit - '30' : time() + '5' );
96
  $chunksize = '1000';
97
  $lastid = strval( intval ( get_option( $slug.'_last', '0' ) ) );
98
  $errtxt = '';
118
  // Pre-processing needed?
119
  if ( $lastid == '0' ) {
120
  if ( wppa_is_cron() ) {
121
+ wppa_log( 'Cron', 'Cron job ' . $slug . ' started.' );
122
  }
123
  else {
124
  wppa_log( 'Obs', 'Maintenance proc ' . $slug . ' started.' );
131
  if ( ! wppa_is_cron() ) {
132
  $wpdb->query( "UPDATE `" . WPPA_INDEX . "` SET `albums` = ''" );
133
  }
134
+ wppa_index_compute_skips();
135
  break;
136
 
137
  case 'wppa_remake_index_photos':
143
  wppa_index_compute_skips();
144
  break;
145
 
146
+ case 'wppa_cleanup_index':
147
+ wppa_index_compute_skips();
148
+ break;
149
+
150
  case 'wppa_recup':
151
 
152
  // Pre-Clear exif and iptc tables only if not cron
240
 
241
  case 'wppa_remake_index_albums':
242
 
 
 
 
 
243
  wppa_index_add( 'album', $id );
244
  break;
245
 
349
 
350
  case 'wppa_remake_index_photos':
351
 
 
 
 
 
352
  wppa_index_add( 'photo', $id );
353
  break;
354
 
790
  }
791
  break; // End process photos
792
 
793
+ case 'wppa_cleanup_index':
794
+ case 'wppa_something_else_for_index':
795
+
796
+ // Process index
797
+ $table = WPPA_INDEX;
798
+
799
+ $topid = $wpdb->get_var( "SELECT `id` FROM `".WPPA_INDEX."` ORDER BY `id` DESC LIMIT 1" );
800
+ $indexes = $wpdb->get_results( "SELECT * FROM `".WPPA_INDEX."` WHERE `id` > ".$lastid." ORDER BY `id` LIMIT ".$chunksize, ARRAY_A );
801
+
802
+ if ( $indexes ) foreach ( array_keys( $indexes ) as $idx ) {
803
+
804
+ switch ( $slug ) {
805
+
806
+ case 'wppa_cleanup_index':
807
+
808
+ $aborted = false;
809
+
810
+ $albums = wppa_index_string_to_array( $indexes[$idx]['albums'] );
811
+
812
+ if ( is_array( $albums ) ) foreach( array_keys( $albums ) as $aidx ) {
813
+
814
+ if ( time() < ( $endtime + 2 ) ) {
815
+ $alb = $albums[$aidx];
816
+
817
+ // If album gone, remove it from index
818
+ if ( ! wppa_album_exists( $alb ) ) {
819
+ unset( $albums[$aidx] );
820
+ }
821
+
822
+ // Check if keyword appears in album data
823
+ else {
824
+ $words = wppa_index_raw_to_words( wppa_index_get_raw_album( $alb ) );
825
+ if ( ! in_array( $indexes[$idx]['slug'], $words ) ) {
826
+ wppa_log( 'Cron', 'Removed index entry album {b}' . $albums[$aidx] . '{/b} from keyword {b}' . $indexes[$idx]['slug'] . '{/b}' );
827
 
828
+ unset( $albums[$aidx] );
829
+ }
830
+ wppa_cache_album( 'invalidate', $alb ); // Prevent cache overflow
831
+ }
832
+ }
833
+ else break;
834
+ }
835
 
 
 
836
 
837
+ $photos = wppa_index_string_to_array( $indexes[$idx]['photos'] );
838
+ $cp = is_array( $photos ) ? count( $photos ) : 0;
839
+ $pidx = 0;
840
+ $last = get_option( $slug.'_last_photo', 0 );
841
+ delete_option( $slug.'_last_photo' );
842
 
843
+ if ( is_array( $photos ) ) foreach( array_keys( $photos ) as $pidx ) {
844
+
845
+ if ( $pidx < $last ) continue;
846
+ if ( $last && $pidx == $last ) {
847
+ wppa_log('Cron', 'Continuing cleanup index at slug = {b}' . $indexes[$idx]['slug'] . '{/b}, element # = {b}' . $last . '{/b}' );
848
+ }
849
+
850
+ if ( time() < ( $endtime + 2 ) ) {
851
+ $pho = $photos[$pidx];
852
+
853
+ // If photo gone, remove it from index
854
+ if ( ! wppa_photo_exists( $pho ) ) {
855
+ unset( $photos[$pidx] );
856
+ }
857
 
858
+ // Check if keyword appears in photo data
859
+ else {
860
+ $words = wppa_index_raw_to_words( wppa_index_get_raw_photo( $pho ) );
861
+ if ( ! in_array( $indexes[$idx]['slug'], $words ) ) {
862
+ wppa_log( 'Cron', 'Removed index entry photo {b}' . $pho . '{/b} from slug {b}' . $indexes[$idx]['slug'] . '{/b}' );
863
+ unset( $photos[$pidx] );
864
+ }
865
+ wppa_cache_thumb( 'invalidate', $pho ); // Prevent cache overflow
866
+ }
867
+ }
868
+ else break;
869
+ }
870
+ if ( $cp && $pidx != ( $cp - 1 ) ) {
871
+ wppa_log( 'Cron', 'Could not complete scan of index item # {b}' . $indexes[$idx]['id'] . '{/b},' .
872
+ ' slug = {b}' . $indexes[$idx]['slug'] . '{/b},' .
873
+ ' count = {b}' . $cp . '{/b},' .
874
+ ' photo id = {b}' . $pho .'{/b},' .
875
+ ' next element # = {b}' . $pidx . '{/b},'
876
+ );
877
+ $aborted = true;
878
+ }
879
 
880
+ $lastid = $indexes[$idx]['id'];
881
+ if ( $aborted ) {
882
+ $lastid--;
883
+ update_option( $slug.'_last_photo', $pidx );
884
+ }
885
+ update_option( $slug.'_last', $lastid );
886
+ $albums = wppa_index_array_to_string( $albums );
887
+ $photos = wppa_index_array_to_string( $photos );
888
+ if ( $albums != $indexes[$idx]['albums'] || $photos != $indexes[$idx]['photos'] ) {
889
+ $query = $wpdb->prepare( "UPDATE `".WPPA_INDEX."` SET `albums` = %s, `photos` = %s WHERE `id` = %s", $albums, $photos, $indexes[$idx]['id'] );
890
+ $wpdb->query( $query );
891
+ }
892
+ break;
893
 
894
+ case 'wppa_something_else_for_index':
895
+ // Just example to make extensions easy
896
+ // So you know here to out the code
897
+ break;
898
+ }
899
+
900
+ // Test for timeout / ready
901
+ if ( wppa_is_cron() ) {
902
+ if ( time() > $endtime ) {
903
+ update_option( $slug.'_status', __('Scheduled cron job', 'wp-photo-album-plus'));
904
+ }
905
+ else {
906
+ update_option( $slug.'_status', __('Running cron job', 'wp-photo-album-plus'));
907
+ }
908
+ }
909
+
910
+ if ( time() > $endtime ) break; // Time out
911
+ }
912
+
913
+ break; // End process index
914
 
915
  default:
916
  $errtxt = 'Unimplemented maintenance slug: '.strip_tags( $slug );
917
  }
918
 
919
+ // either $albums / $photos / $indexes has been exhousted ( for this try ) or time is up
920
 
921
  // Post proc this try:
922
  switch ( $slug ) {
928
  break;
929
  }
930
 
931
+ // Register lastid
932
+ update_option( $slug.'_last', $lastid );
933
+
934
  // Find togo
935
  if ( $slug == 'wppa_cleanup' ) {
936
  $togo = $topid - $lastid;
993
  switch ( $slug ) {
994
  case 'wppa_remake_index_albums':
995
  case 'wppa_remake_index_photos':
996
+ case 'wppa_cleanup_index':
997
  $wpdb->query( "DELETE FROM `".WPPA_INDEX."` WHERE `albums` = '' AND `photos` = ''" ); // Remove empty entries
998
  delete_option( 'wppa_index_need_remake' );
999
  break;
1034
  break;
1035
  }
1036
 
1037
+ if ( wppa_is_cron() ) {
1038
+ wppa_log( 'Cron', 'Cron job ' . $slug . ' completed' );
1039
+ }
1040
+ else {
1041
+ wppa_log( 'Obs', 'Maintenance proc ' . $slug . ' completed' );
1042
+ }
1043
 
1044
  }
1045
 
1046
  wppa_save_session();
1047
 
1048
  if ( wppa_is_cron() ) {
1049
+ // wppa_log( 'obs', $errtxt.'||'.$slug.'||'.$status.'||'.$togo.'||'.$reload );
1050
  if ( get_option( $slug . '_ad_inf' ) == 'yes' ) {
1051
+ switch ( $slug ) {
1052
+ case 'wppa_remake_index_albums':
1053
+ $delay = 900; // 15 minutes
1054
+ break;
1055
+ default:
1056
+ $delay = 300; // 5 minutes
1057
+ }
1058
+ wppa_schedule_maintenance_proc( $slug, $delay );
1059
  }
1060
  }
1061
  return $errtxt.'||'.$slug.'||'.$status.'||'.$togo.'||'.$reload;
1143
  '<div style="float:left; clear:both; width:100%; overflow:auto; word-wrap:none;" >';
1144
 
1145
  if ( ! $file = @ fopen( $wppa_log_file, 'r' ) ) {
1146
+ $result .= __( 'There are no log messages', 'wp-photo-album-plus' );
1147
  }
1148
  else {
1149
  $size = filesize( $wppa_log_file );
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.6.11
7
  *
8
  */
9
 
@@ -2718,7 +2718,8 @@ function wppa_fe_edit_new_style( $photo ) {
2718
  ' type="button"' .
2719
  ' style="margin-top:8px;"' .
2720
  ' value="' . esc_attr( __( 'Cancel', 'wp-photo-album-plus' ) ) . '"' .
2721
- ' onclick="jQuery( \'.ui-button\' ).trigger(\'click\')"' .
 
2722
  ' />';
2723
 
2724
  // Close form
3
  * Package: wp-photo-album-plus
4
  *
5
  * edit and delete photos
6
+ * Version 6.6.12
7
  *
8
  */
9
 
2718
  ' type="button"' .
2719
  ' style="margin-top:8px;"' .
2720
  ' value="' . esc_attr( __( 'Cancel', 'wp-photo-album-plus' ) ) . '"' .
2721
+ // ' onclick="jQuery( \'.ui-button\' ).trigger(\'click\')"' .
2722
+ ' onclick="jQuery( \'#wppa-modal-container-' . strval( intval( $_REQUEST['moccur'] ) ) . '\').dialog(\'close\')"' .
2723
  ' />';
2724
 
2725
  // Close form
wppa-potd-admin.php CHANGED
@@ -3,7 +3,7 @@
3
  * Pachkage: wp-photo-album-plus
4
  *
5
  * admin photo of the day widget
6
- * version 6.6.00
7
  *
8
  */
9
 
@@ -175,7 +175,7 @@ global $wppa_defaults;
175
  $html = '<select' .
176
  ' id="wppa_potd_album"' .
177
  ' name="wppa_potd_album"' .
178
- ' style="float:left; max-width: 100%;"' .
179
  ' multiple="multiple"' .
180
  ' onchange="didsome=true;wppaAjaxUpdateOptionValue(\'potd_album\', this, true)"' .
181
  // ' onblur="document.location.reload(true);"' .
3
  * Pachkage: wp-photo-album-plus
4
  *
5
  * admin photo of the day widget
6
+ * version 6.6.12
7
  *
8
  */
9
 
175
  $html = '<select' .
176
  ' id="wppa_potd_album"' .
177
  ' name="wppa_potd_album"' .
178
+ ' style="float:left; max-width: 100%; height: auto !important;"' .
179
  ' multiple="multiple"' .
180
  ' onchange="didsome=true;wppaAjaxUpdateOptionValue(\'potd_album\', this, true)"' .
181
  // ' onblur="document.location.reload(true);"' .
wppa-potd-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the widget
6
- * Version 6.5.04
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
@@ -173,7 +173,7 @@ class PhotoOfTheDay extends WP_Widget {
173
  break;
174
  case 'owner':
175
  $owner = $image['owner'];
176
- $user = get_user_by('login', $owner);
177
  $owner = $user->display_name;
178
  $widget_content .= "\n".'<div class="wppa-widget-text wppa-potd-text" style="'.$align.'">'.__('By:', 'wp-photo-album-plus').' ' . $owner . '</div>';
179
  break;
3
  * Package: wp-photo-album-plus
4
  *
5
  * display the widget
6
+ * Version 6.6.12
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
173
  break;
174
  case 'owner':
175
  $owner = $image['owner'];
176
+ $user = wppa_get_user_by('login', $owner);
177
  $owner = $user->display_name;
178
  $widget_content .= "\n".'<div class="wppa-widget-text wppa-potd-text" style="'.$align.'">'.__('By:', 'wp-photo-album-plus').' ' . $owner . '</div>';
179
  break;
wppa-session.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all session routines
6
- * Version 6.6.04
7
  *
8
  * Firefox modifies data in the superglobal $_SESSION.
9
  * See https://bugzilla.mozilla.org/show_bug.cgi?id=991019
@@ -28,7 +28,7 @@ global $wpdb;
28
  global $wppa_session;
29
 
30
  // If the session table does not yet exist on activation
31
- if ( ! wppa_table_exists( WPPA_SESSION ) ) {
32
  $wppa_session['id'] = '0';
33
  return false;
34
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all session routines
6
+ * Version 6.6.12
7
  *
8
  * Firefox modifies data in the superglobal $_SESSION.
9
  * See https://bugzilla.mozilla.org/show_bug.cgi?id=991019
28
  global $wppa_session;
29
 
30
  // If the session table does not yet exist on activation
31
+ if ( is_admin() && ! wppa_table_exists( WPPA_SESSION ) ) {
32
  $wppa_session['id'] = '0';
33
  return false;
34
  }
wppa-settings-autosave.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all options
6
- * Version 6.6.11
7
  *
8
  */
9
 
@@ -6750,7 +6750,7 @@ global $wp_version;
6750
  $options = array( __('--- select a user to unblacklist ---', 'wp-photo-album-plus') );
6751
  $values = array( '0' );
6752
  foreach ( $blacklist as $usr ) {
6753
- $u = get_user_by( 'login', $usr );
6754
  $options[] = $u->display_name.' ('.$u->user_login.')';
6755
  $values[] = $u->user_login;
6756
  }
@@ -6814,7 +6814,7 @@ global $wp_version;
6814
  $options = array( __('--- select a user to unmake superuser ---', 'wp-photo-album-plus') );
6815
  $values = array( '0' );
6816
  foreach ( $superlist as $usr ) {
6817
- $u = get_user_by( 'login', $usr );
6818
  $options[] = $u->display_name.' ('.$u->user_login.')';
6819
  $values[] = $u->user_login;
6820
  }
@@ -6999,27 +6999,40 @@ global $wp_version;
6999
  $desc = __('Remakes the index database table for albums.', 'wp-photo-album-plus');
7000
  $help = '';
7001
  $slug2 = 'wppa_remake_index_albums';
7002
- $html1 = wppa_cronjob_button( $slug2 );
7003
  $html2 = wppa_maintenance_button( $slug2 );
7004
  $html3 = wppa_status_field( $slug2 );
7005
  $html4 = wppa_togo_field( $slug2 );
7006
  $html = array($html1, $html2, $html3, $html4);
7007
  $clas = '';
7008
  $tags = 'system,search';
7009
- wppa_setting(false, '8', $name, $desc, $html, $help, $clas, $tags);
7010
 
7011
  $name = __('Remake Index Photos', 'wp-photo-album-plus');
7012
  $desc = __('Remakes the index database table for photos.', 'wp-photo-album-plus');
7013
  $help = '';
7014
  $slug2 = 'wppa_remake_index_photos';
7015
- $html1 = wppa_cronjob_button( $slug2 );
7016
  $html2 = wppa_maintenance_button( $slug2 );
7017
  $html3 = wppa_status_field( $slug2 );
7018
  $html4 = wppa_togo_field( $slug2 );
7019
  $html = array($html1, $html2, $html3, $html4);
7020
  $clas = '';
7021
  $tags = 'system,search';
7022
- wppa_setting(false, '9', $name, $desc, $html, $help, $clas, $tags);
 
 
 
 
 
 
 
 
 
 
 
 
 
7023
 
7024
  $fs = get_option('wppa_file_system');
7025
  if ( ! $fs ) { // Fix for wp delete_option bug
@@ -7555,12 +7568,14 @@ global $wp_version;
7555
  wppa_setting(false, '19.2', $name, $desc, $html, $help, $clas, $tags);
7556
 
7557
  }
7558
- /*
 
 
7559
  $name = __('Test proc');
7560
  $desc = __('For OpaJaap only');
7561
  $help = '';
7562
  $slug2 = 'wppa_test_proc';
7563
- $html1 = wppa_cronjob_button( $slug2 ) . __('ad inf', 'wp-photo-album-plus') . wppa_checkbox( 'wppa_test_proc_ad_inf' );
7564
  $html2 = wppa_maintenance_button( $slug2 );
7565
  $html3 = wppa_status_field( $slug2 );
7566
  $html4 = wppa_togo_field( $slug2 );
@@ -7569,7 +7584,7 @@ global $wp_version;
7569
  $tags = 'system';
7570
  wppa_setting(false, '99', $name, $desc, $html, $help, $clas, $tags);
7571
 
7572
- /**/
7573
  wppa_setting_subheader('C', '4', __('Listings', 'wp-photo-album-plus'));
7574
 
7575
  $name = __('List Logfile', 'wp-photo-album-plus');
@@ -7792,6 +7807,15 @@ global $wp_version;
7792
  $tags = 'system';
7793
  wppa_setting($slug, '8', $name, $desc, $html, $help, $clas, $tags);
7794
 
 
 
 
 
 
 
 
 
 
7795
  }
7796
  wppa_setting_subheader( 'B', '1', __( 'WPPA+ Admin related miscellaneous settings' , 'wp-photo-album-plus') );
7797
  {
@@ -8663,6 +8687,41 @@ global $wp_version;
8663
  $tags = 'system,search';
8664
  wppa_setting($slug, '17', $name, $desc, $html, $help, $clas, $tags);
8665
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8666
  }
8667
  wppa_setting_subheader( 'F', '1', __( 'Watermark related settings' , 'wp-photo-album-plus') );
8668
  {
@@ -9994,6 +10053,24 @@ global $wppa_opt;
9994
  return $html;
9995
  }
9996
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9997
  function wppa_input_color($xslug, $width, $minwidth = '', $text = '', $onchange = '', $placeholder = '') {
9998
  global $wppa_opt;
9999
 
@@ -10379,15 +10456,12 @@ function wppa_cronjob_button( $slug ) {
10379
  }
10380
 
10381
  // Check for apparently crashed cron job
10382
- $last = get_option( $slug.'_lasttimestamp', '0' );
10383
- if ( $last && $last < ( time() - 1800 ) ) {
10384
  $label = __( 'Crashed!', 'wp-photo-album-plus' );
10385
- $crashed = true;
10386
- }
10387
- else {
10388
- $crashed = false;
10389
  }
10390
 
 
10391
  $result = '<input' .
10392
  ' id="' . $slug . '_cron_button"' .
10393
  ' type="button"' .
@@ -10437,8 +10511,9 @@ function wppa_status_field( $slug ) {
10437
  }
10438
  function wppa_togo_field( $slug ) {
10439
  $togo = get_option($slug.'_togo', '' );
 
10440
  $result = '<span id="'.$slug.'_togo" >' . $togo . '</span>';
10441
- if ( $togo ) {
10442
  $result .= '<script>wppaAjaxUpdateTogo(\'' . $slug . '\');</script>';
10443
  }
10444
  return $result;
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all options
6
+ * Version 6.6.12
7
  *
8
  */
9
 
6750
  $options = array( __('--- select a user to unblacklist ---', 'wp-photo-album-plus') );
6751
  $values = array( '0' );
6752
  foreach ( $blacklist as $usr ) {
6753
+ $u = wppa_get_user_by( 'login', $usr );
6754
  $options[] = $u->display_name.' ('.$u->user_login.')';
6755
  $values[] = $u->user_login;
6756
  }
6814
  $options = array( __('--- select a user to unmake superuser ---', 'wp-photo-album-plus') );
6815
  $values = array( '0' );
6816
  foreach ( $superlist as $usr ) {
6817
+ $u = wppa_get_user_by( 'login', $usr );
6818
  $options[] = $u->display_name.' ('.$u->user_login.')';
6819
  $values[] = $u->user_login;
6820
  }
6999
  $desc = __('Remakes the index database table for albums.', 'wp-photo-album-plus');
7000
  $help = '';
7001
  $slug2 = 'wppa_remake_index_albums';
7002
+ $html1 = wppa_cronjob_button( $slug2 );// . __('ad inf', 'wp-photo-album-plus') . wppa_checkbox( $slug2.'_ad_inf' );
7003
  $html2 = wppa_maintenance_button( $slug2 );
7004
  $html3 = wppa_status_field( $slug2 );
7005
  $html4 = wppa_togo_field( $slug2 );
7006
  $html = array($html1, $html2, $html3, $html4);
7007
  $clas = '';
7008
  $tags = 'system,search';
7009
+ wppa_setting(false, '8.1', $name, $desc, $html, $help, $clas, $tags);
7010
 
7011
  $name = __('Remake Index Photos', 'wp-photo-album-plus');
7012
  $desc = __('Remakes the index database table for photos.', 'wp-photo-album-plus');
7013
  $help = '';
7014
  $slug2 = 'wppa_remake_index_photos';
7015
+ $html1 = wppa_cronjob_button( $slug2 );// . __('ad inf', 'wp-photo-album-plus') . wppa_checkbox( $slug2.'_ad_inf' );
7016
  $html2 = wppa_maintenance_button( $slug2 );
7017
  $html3 = wppa_status_field( $slug2 );
7018
  $html4 = wppa_togo_field( $slug2 );
7019
  $html = array($html1, $html2, $html3, $html4);
7020
  $clas = '';
7021
  $tags = 'system,search';
7022
+ wppa_setting(false, '8.2', $name, $desc, $html, $help, $clas, $tags);
7023
+
7024
+ $name = __('Clean Index', 'wp-photo-album-plus');
7025
+ $desc = __('Remove obsolete entries from index db table.', 'wp-photo-album-plus');
7026
+ $help = '';
7027
+ $slug2 = 'wppa_cleanup_index';
7028
+ $html1 = wppa_cronjob_button( $slug2 );// . __('ad inf', 'wp-photo-album-plus') . wppa_checkbox( $slug2.'_ad_inf' );
7029
+ $html2 = wppa_maintenance_button( $slug2 );
7030
+ $html3 = wppa_status_field( $slug2 );
7031
+ $html4 = wppa_togo_field( $slug2 );
7032
+ $html = array($html1, $html2, $html3, $html4);
7033
+ $clas = '';
7034
+ $tags = 'system';
7035
+ wppa_setting(false, '8.3', $name, $desc, $html, $help, $clas, $tags);
7036
 
7037
  $fs = get_option('wppa_file_system');
7038
  if ( ! $fs ) { // Fix for wp delete_option bug
7568
  wppa_setting(false, '19.2', $name, $desc, $html, $help, $clas, $tags);
7569
 
7570
  }
7571
+ if ( strpos( $_SERVER['SERVER_NAME'], 'opajaap' ) !== false ) {
7572
+
7573
+
7574
  $name = __('Test proc');
7575
  $desc = __('For OpaJaap only');
7576
  $help = '';
7577
  $slug2 = 'wppa_test_proc';
7578
+ $html1 = wppa_cronjob_button( $slug2 );// . __('ad inf', 'wp-photo-album-plus') . wppa_checkbox( $slug2.'_ad_inf' );
7579
  $html2 = wppa_maintenance_button( $slug2 );
7580
  $html3 = wppa_status_field( $slug2 );
7581
  $html4 = wppa_togo_field( $slug2 );
7584
  $tags = 'system';
7585
  wppa_setting(false, '99', $name, $desc, $html, $help, $clas, $tags);
7586
 
7587
+ }
7588
  wppa_setting_subheader('C', '4', __('Listings', 'wp-photo-album-plus'));
7589
 
7590
  $name = __('List Logfile', 'wp-photo-album-plus');
7807
  $tags = 'system';
7808
  wppa_setting($slug, '8', $name, $desc, $html, $help, $clas, $tags);
7809
 
7810
+ $name = __('Log Cron', 'wp-photo-album-plus');
7811
+ $desc = __('Keep track of cron activity in the wppa logfile.', 'wp-photo-album-plus');
7812
+ $help = '';
7813
+ $slug = 'wppa_log_cron';
7814
+ $html = wppa_checkbox($slug);
7815
+ $clas = '';
7816
+ $tags = 'system';
7817
+ wppa_setting($slug, '9', $name, $desc, $html, $help, $clas, $tags);
7818
+
7819
  }
7820
  wppa_setting_subheader( 'B', '1', __( 'WPPA+ Admin related miscellaneous settings' , 'wp-photo-album-plus') );
7821
  {
8687
  $tags = 'system,search';
8688
  wppa_setting($slug, '17', $name, $desc, $html, $help, $clas, $tags);
8689
 
8690
+ $name = __('Minimum search token length', 'wp-photo-album-plus');
8691
+ $desc = __('The minmum number of chars in a search request.', 'wp-admin');
8692
+ $help = '';
8693
+ $slug = 'wppa_search_min_length';
8694
+ $html = wppa_number($slug, '1', '6');
8695
+ $clas = '';
8696
+ $tags = 'system,search';
8697
+ wppa_setting($slug, '18.1', $name, $desc, $html, $help, $clas, $tags);
8698
+
8699
+ $name = __('Exclude from search', 'wp-photo-album-plus');
8700
+ $desc = __('Exclude these words from search index.', 'wp-photo-album-plus');
8701
+ $help = esc_js(__('Enter words separated by commas (,)', 'wp-photo-album-plus'));
8702
+ $slug = 'wppa_search_user_void';
8703
+ $html = wppa_input($slug, '90%;');
8704
+ $clas = '';
8705
+ $tags = 'system,search';
8706
+ wppa_setting($slug, '18.2', $name, $desc, $html, $help, $clas, $tags);
8707
+
8708
+ $name = __('Exclude numbers', 'wp-photo-album-plus');
8709
+ $desc = __('Exclude numbers from search index.', 'wp-photo-album-plus');
8710
+ $help = esc_js(__('If ticked, photos and albums are not searcheable by numbers.', 'wp-photo-album-plus'));
8711
+ $slug = 'wppa_search_numbers_void';
8712
+ $html = wppa_checkbox($slug);
8713
+ $clas = '';
8714
+ $tags = 'system,search';
8715
+ wppa_setting($slug, '18.3', $name, $desc, $html, $help, $clas, $tags);
8716
+
8717
+ $name = __('Ignore slash', 'wp-photo-album-plus');
8718
+ $desc = __('Ignore slash chracter (/).', 'wp-photo-album-plus');
8719
+ $help = '';
8720
+ $slug = 'wppa_index_ignore_slash';
8721
+ $html = wppa_checkbox($slug);
8722
+ $clas = '';
8723
+ $tags = 'system,search';
8724
+ wppa_setting($slug, '18.4', $name, $desc, $html, $help, $clas, $tags);
8725
  }
8726
  wppa_setting_subheader( 'F', '1', __( 'Watermark related settings' , 'wp-photo-album-plus') );
8727
  {
10053
  return $html;
10054
  }
10055
 
10056
+ function wppa_number($xslug, $min, $max, $text = '', $onchange = '') {
10057
+ global $wppa_opt;
10058
+
10059
+ $slug = substr( $xslug, 5 );
10060
+ $tit = __('Slug =', 'wp-photo-album-plus').' '.$xslug;
10061
+ $title = wppa_switch( 'enable_shortcode_wppa_set' ) ? ' title="'.esc_attr( $tit ).'"' : '';
10062
+ $val = isset ( $wppa_opt[ $xslug ] ) ? esc_attr( $wppa_opt[ $xslug ] ) : get_option( $xslug, '' );
10063
+ $html = '<input'.$title.' style="float:left; height:20px; width:50px;';
10064
+ $html .= ' font-size: 11px; margin: 0px; padding: 0px;" type="number" id="'.$slug.'"';
10065
+ if ($onchange != '') $html .= ' onchange="'.$onchange.';wppaAjaxUpdateOptionValue(\''.$slug.'\', this)"';
10066
+ else $html .= ' onchange="wppaAjaxUpdateOptionValue(\''.$slug.'\', this)"';
10067
+ $html .= ' value="'.$val.'" min="'.$min.'" max="'.$max.'" />';
10068
+ $html .= '<img id="img_'.$slug.'" src="'.wppa_get_imgdir().'star.ico" title="'.__('Setting unmodified', 'wp-photo-album-plus').'" style="padding:0 4px; float:left; height:16px; width:16px;" />';
10069
+ $html .= '<span style="float:left">'.$text.'</span>';
10070
+
10071
+ return $html;
10072
+ }
10073
+
10074
  function wppa_input_color($xslug, $width, $minwidth = '', $text = '', $onchange = '', $placeholder = '') {
10075
  global $wppa_opt;
10076
 
10456
  }
10457
 
10458
  // Check for apparently crashed cron job
10459
+ $crashed = wppa_is_maintenance_cron_job_crashed( $slug );
10460
+ if ( $crashed ) {
10461
  $label = __( 'Crashed!', 'wp-photo-album-plus' );
 
 
 
 
10462
  }
10463
 
10464
+ // Make the html
10465
  $result = '<input' .
10466
  ' id="' . $slug . '_cron_button"' .
10467
  ' type="button"' .
10511
  }
10512
  function wppa_togo_field( $slug ) {
10513
  $togo = get_option($slug.'_togo', '' );
10514
+ $is_cron = get_option($slug.'_user', '' ) == 'cron-job';
10515
  $result = '<span id="'.$slug.'_togo" >' . $togo . '</span>';
10516
+ if ( $togo || $is_cron ) {
10517
  $result .= '<script>wppaAjaxUpdateTogo(\'' . $slug . '\');</script>';
10518
  }
10519
  return $result;
wppa-setup.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the setup stuff
6
- * Version 6.6.11
7
  *
8
  */
9
 
@@ -697,6 +697,7 @@ Hide Camera info
697
  'wppa_i_gpx' => '',
698
  'wppa_i_fotomoto' => '',
699
  'wppa_i_video' => '',
 
700
  'wppa_i_stereo' => '',
701
  'wppa_i_done' => '',
702
 
@@ -1425,7 +1426,8 @@ Hide Camera info
1425
 
1426
  // Table VIII: Actions
1427
  // A Harmless
1428
- 'wppa_setup' => '',
 
1429
  'wppa_backup' => '',
1430
  'wppa_load_skin' => '',
1431
  'wppa_skinfile' => 'default',
@@ -1453,8 +1455,12 @@ Hide Camera info
1453
  'wppa_iptc_clear' => '',
1454
  'wppa_exif_clear' => '',
1455
  'wppa_apply_new_photodesc_all' => '',
1456
- 'wppa_remake_index' => '',
1457
- 'wppa_extend_index' => '',
 
 
 
 
1458
  'wppa_list_index' => '',
1459
  'wppa_list_index_display_start' => '',
1460
  'wppa_list_comments_by' => 'name',
@@ -1478,13 +1484,13 @@ Hide Camera info
1478
  'wppa_sync_cloud' => '',
1479
  'wppa_sanitize_tags' => '',
1480
  'wppa_sanitize_cats' => '',
1481
- 'wppa_test_proc' => '',
1482
- 'wppa_test_proc_ad_inf' => 'no',
1483
  'wppa_move_all_photos' => '',
1484
  'wppa_move_all_photos_from' => '',
1485
  'wppa_move_all_photos_to' => '',
1486
 
1487
- 'wppa_maint_ignore_concurrency_error' => 'no',
 
 
1488
 
1489
 
1490
  // Table IX: Miscellaneous
@@ -1533,6 +1539,7 @@ Hide Camera info
1533
  'wppa_import_root' => ABSPATH . 'wp-content',
1534
  'wppa_allow_import_source' => 'no',
1535
  'wppa_enable_generator' => 'yes',
 
1536
 
1537
 
1538
  // IX D New
@@ -1598,6 +1605,11 @@ Hide Camera info
1598
  'wppa_search_toptext' => '',
1599
  'wppa_search_in_section' => __( 'Search in current section' , 'wp-photo-album-plus'),
1600
  'wppa_search_in_results' => __( 'Search in current results' , 'wp-photo-album-plus'),
 
 
 
 
 
1601
 
1602
  // F Watermark
1603
  'wppa_watermark_on' => 'no',
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the setup stuff
6
+ * Version 6.6.12
7
  *
8
  */
9
 
697
  'wppa_i_gpx' => '',
698
  'wppa_i_fotomoto' => '',
699
  'wppa_i_video' => '',
700
+ 'wppa_i_audio' => '',
701
  'wppa_i_stereo' => '',
702
  'wppa_i_done' => '',
703
 
1426
 
1427
  // Table VIII: Actions
1428
  // A Harmless
1429
+ 'wppa_maint_ignore_concurrency_error' => 'no', // 0
1430
+ 'wppa_setup' => '', // 1
1431
  'wppa_backup' => '',
1432
  'wppa_load_skin' => '',
1433
  'wppa_skinfile' => 'default',
1455
  'wppa_iptc_clear' => '',
1456
  'wppa_exif_clear' => '',
1457
  'wppa_apply_new_photodesc_all' => '',
1458
+ 'wppa_remake_index_albums' => '', // 8.1
1459
+ 'wppa_remake_index_albums_ad_inf' => 'no', // 8.1
1460
+ 'wppa_remake_index_photos' => '', // 8.2
1461
+ 'wppa_remake_index_photos_ad_inf' => 'no', // 8.2
1462
+ 'wppa_cleanup_index' => '', // 8.3
1463
+ 'wppa_cleanup_index_ad_inf' => 'no', // 8.3
1464
  'wppa_list_index' => '',
1465
  'wppa_list_index_display_start' => '',
1466
  'wppa_list_comments_by' => 'name',
1484
  'wppa_sync_cloud' => '',
1485
  'wppa_sanitize_tags' => '',
1486
  'wppa_sanitize_cats' => '',
 
 
1487
  'wppa_move_all_photos' => '',
1488
  'wppa_move_all_photos_from' => '',
1489
  'wppa_move_all_photos_to' => '',
1490
 
1491
+
1492
+ 'wppa_test_proc' => '', // 99
1493
+ 'wppa_test_proc_ad_inf' => 'no', // 99
1494
 
1495
 
1496
  // Table IX: Miscellaneous
1539
  'wppa_import_root' => ABSPATH . 'wp-content',
1540
  'wppa_allow_import_source' => 'no',
1541
  'wppa_enable_generator' => 'yes',
1542
+ 'wppa_log_cron' => 'no', // A9
1543
 
1544
 
1545
  // IX D New
1605
  'wppa_search_toptext' => '',
1606
  'wppa_search_in_section' => __( 'Search in current section' , 'wp-photo-album-plus'),
1607
  'wppa_search_in_results' => __( 'Search in current results' , 'wp-photo-album-plus'),
1608
+ 'wppa_search_min_length' => '2', // 18
1609
+ 'wppa_search_user_void' => '',
1610
+ 'wppa_search_numbers_void' => 'no',
1611
+ 'wppa_index_ignore_slash' => 'no',
1612
+ // 'wppa_index_skips' => '', // Do not add, this is an array
1613
 
1614
  // F Watermark
1615
  'wppa_watermark_on' => 'no',
wppa-thumbnails.php CHANGED
@@ -5,7 +5,7 @@
5
  * Various funcions to display a thumbnail image
6
  * Contains all possible frontend thumbnail types
7
  *
8
- * Version 6.6.10
9
  *
10
  */
11
 
@@ -36,7 +36,11 @@ global $wpdb;
36
 
37
  // Get the album info
38
  $album = wppa_cache_album( $thumb['album'] );
39
- wppa( 'current_album', $album['id'] );
 
 
 
 
40
 
41
  // Get photo info
42
  $is_video = wppa_is_video( $id );
5
  * Various funcions to display a thumbnail image
6
  * Contains all possible frontend thumbnail types
7
  *
8
+ * Version 6.6.12
9
  *
10
  */
11
 
36
 
37
  // Get the album info
38
  $album = wppa_cache_album( $thumb['album'] );
39
+
40
+ global $wppa;
41
+ if ( isset( $wppa['current_album'] ) ) {
42
+ wppa( 'current_album', $album['id'] );
43
+ }
44
 
45
  // Get photo info
46
  $is_video = wppa_is_video( $id );
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.6.00
7
  *
8
  */
9
 
@@ -38,12 +38,21 @@ static $users;
38
  return $users;
39
  }
40
 
 
 
 
 
 
 
41
  // Get user
42
  // If logged in, return userdata as specified in $type
43
  // If logged out, return IP
44
  function wppa_get_user( $type = 'login' ) {
45
  static $current_user;
46
 
 
 
 
47
  if ( ! $current_user ) {
48
  $current_user = wp_get_current_user();
49
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains user and capabilities related routines
6
+ * Version 6.6.12
7
  *
8
  */
9
 
38
  return $users;
39
  }
40
 
41
+ // Wrapper for get_user_by()
42
+ function wppa_get_user_by( $key, $user ) {
43
+ // wppa_log( 'Obs', 'wppa_get_user_by called with args ' . $key . ', ' . $user, true );
44
+ return get_user_by( $key, $user );
45
+ }
46
+
47
  // Get user
48
  // If logged in, return userdata as specified in $type
49
  // If logged out, return IP
50
  function wppa_get_user( $type = 'login' ) {
51
  static $current_user;
52
 
53
+ if ( wppa_is_cron() ) {
54
+ return 'cron-job';
55
+ }
56
  if ( ! $current_user ) {
57
  $current_user = wp_get_current_user();
58
  }
wppa-utils.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level utility routines
6
- * Version 6.6.11
7
  *
8
  */
9
 
@@ -740,6 +740,10 @@ function wppa_album_exists( $id ) {
740
  global $wpdb;
741
  static $existing_albums;
742
 
 
 
 
 
743
  // If existing albums cache not filled yet, fill it.
744
  if ( ! $existing_albums ) {
745
  $existing_albums = $wpdb->get_col( "SELECT `id` FROM `" . WPPA_ALBUMS . "`" );
@@ -750,6 +754,10 @@ static $existing_albums;
750
 
751
  function wppa_photo_exists( $id ) {
752
  global $wpdb;
 
 
 
 
753
  return $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $id ) );
754
  }
755
 
@@ -844,7 +852,7 @@ global $wpdb;
844
  if ( ! $owner ) return;
845
 
846
  // Get email
847
- $user = get_user_by( 'login', $owner );
848
  if ( ! $user ) return;
849
 
850
  // Custom content?
@@ -1249,6 +1257,13 @@ global $wpdb;
1249
  // Get album
1250
  $album = $photoinfo['album'];
1251
 
 
 
 
 
 
 
 
1252
  // Get filename
1253
  $filename = $photoinfo['filename'];
1254
 
@@ -1292,6 +1307,9 @@ global $wpdb;
1292
  if ( wppa_cdn( 'admin' ) == 'cloudinary' ) {
1293
  wppa_delete_from_cloudinary( $photo );
1294
  }
 
 
 
1295
  }
1296
 
1297
  function wppa_microtime($txt = '') {
@@ -1506,6 +1524,12 @@ global $wppa_log_file;
1506
  // Sanitize type
1507
  $t = strtolower( substr( $xtype, 0, 1 ) );
1508
  switch ( $t ) {
 
 
 
 
 
 
1509
  case 'd':
1510
  $type = 'Dbg';
1511
  break;
@@ -1557,7 +1581,9 @@ global $wppa_log_file;
1557
  if ( ! $file = fopen( $wppa_log_file, 'ab' ) ) return; // Unable to open log file
1558
 
1559
  // Write log message
1560
- @ fwrite( $file, '{b}'.$type.'{/b}: on:'.wppa_local_date(get_option('date_format', "F j, Y,").' '.get_option('time_format', "g:i a"), time()).': '.wppa_get_user().': '.strip_tags($msg)."\n" );
 
 
1561
 
1562
  // Log current url and stacktrace 12 levels if trace requested
1563
  if ( $trace || $type == 'Dbg' ) {
@@ -2077,7 +2103,7 @@ global $wpdb;
2077
  foreach ( array_keys( $data ) as $key ) {
2078
  $thumb = wppa_cache_thumb( $key );
2079
  $data[$key]['meanrating'] = $data[$key]['totvalue'] / $data[$key]['ratingcount'];
2080
- $user = get_user_by( 'login', $thumb['owner'] );
2081
  if ( $user ) {
2082
  $data[$key]['user'] = $user->display_name;
2083
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level utility routines
6
+ * Version 6.6.12
7
  *
8
  */
9
 
740
  global $wpdb;
741
  static $existing_albums;
742
 
743
+ if ( ! wppa_is_int( $id ) ) {
744
+ return false;
745
+ }
746
+
747
  // If existing albums cache not filled yet, fill it.
748
  if ( ! $existing_albums ) {
749
  $existing_albums = $wpdb->get_col( "SELECT `id` FROM `" . WPPA_ALBUMS . "`" );
754
 
755
  function wppa_photo_exists( $id ) {
756
  global $wpdb;
757
+
758
+ if ( ! wppa_is_int( $id ) ) {
759
+ return false;
760
+ }
761
  return $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $id ) );
762
  }
763
 
852
  if ( ! $owner ) return;
853
 
854
  // Get email
855
+ $user = wppa_get_user_by( 'login', $owner );
856
  if ( ! $user ) return;
857
 
858
  // Custom content?
1257
  // Get album
1258
  $album = $photoinfo['album'];
1259
 
1260
+ // Really delete only as cron job
1261
+ if ( ! wppa_is_cron() ) {
1262
+ wppa_update_photo( array( 'id' => $photo, 'album' => '-9' ) );
1263
+ wppa_schedule_cleanup( 'now' );
1264
+ return;
1265
+ }
1266
+
1267
  // Get filename
1268
  $filename = $photoinfo['filename'];
1269
 
1307
  if ( wppa_cdn( 'admin' ) == 'cloudinary' ) {
1308
  wppa_delete_from_cloudinary( $photo );
1309
  }
1310
+
1311
+ // Report
1312
+ wppa_log('Cron', 'Photo # {b}'.$photo.'{/b} removed from system');
1313
  }
1314
 
1315
  function wppa_microtime($txt = '') {
1524
  // Sanitize type
1525
  $t = strtolower( substr( $xtype, 0, 1 ) );
1526
  switch ( $t ) {
1527
+ case 'c':
1528
+ $type = 'Cron';
1529
+ if ( ! wppa_switch( 'log_cron' ) ) {
1530
+ return;
1531
+ }
1532
+ break;
1533
  case 'd':
1534
  $type = 'Dbg';
1535
  break;
1581
  if ( ! $file = fopen( $wppa_log_file, 'ab' ) ) return; // Unable to open log file
1582
 
1583
  // Write log message
1584
+ $msg = strip_tags( $msg );
1585
+
1586
+ @ fwrite( $file, '{b}'.$type.'{/b}: on:'.wppa_local_date(get_option('date_format', "F j, Y,").' '.get_option('time_format', "g:i a"), time()).': '.wppa_get_user().': '.$msg."\n" );
1587
 
1588
  // Log current url and stacktrace 12 levels if trace requested
1589
  if ( $trace || $type == 'Dbg' ) {
2103
  foreach ( array_keys( $data ) as $key ) {
2104
  $thumb = wppa_cache_thumb( $key );
2105
  $data[$key]['meanrating'] = $data[$key]['totvalue'] / $data[$key]['ratingcount'];
2106
+ $user = wppa_get_user_by( 'login', $thumb['owner'] );
2107
  if ( $user ) {
2108
  $data[$key]['user'] = $user->display_name;
2109
  }
wppa-watermark.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-watermark.php
3
  *
4
  * Functions used for the application of watermarks
5
- * Version 6.6.11
6
  *
7
  */
8
 
@@ -79,7 +79,7 @@ function wppa_create_textual_watermark_file( $args ) {
79
  }
80
  $text = html_entity_decode( $text );
81
  $text = str_replace( 'w#site', get_bloginfo( 'url' ), $text );
82
- $usr = get_user_by( 'login', wppa_get_photo_item( $id, 'owner' ) );
83
  $text = wppa_translate_photo_keywords( $id, $text );
84
  $text = wppa_translate_album_keywords( wppa_get_photo_item( $id, 'album' ), $text );
85
  $text = wppa_filter_iptc( $text, $id ); // Render IPTC tags
2
  /* wppa-watermark.php
3
  *
4
  * Functions used for the application of watermarks
5
+ * Version 6.6.12
6
  *
7
  */
8
 
79
  }
80
  $text = html_entity_decode( $text );
81
  $text = str_replace( 'w#site', get_bloginfo( 'url' ), $text );
82
+ $usr = wppa_get_user_by( 'login', wppa_get_photo_item( $id, 'owner' ) );
83
  $text = wppa_translate_photo_keywords( $id, $text );
84
  $text = wppa_translate_album_keywords( wppa_get_photo_item( $id, 'album' ), $text );
85
  $text = wppa_filter_iptc( $text, $id ); // Render IPTC tags
wppa-widget-functions.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-widget-functions.php
3
  /* Package: wp-photo-album-plus
4
  /*
5
- /* Version 6.5.04
6
  /*
7
  */
8
 
@@ -172,6 +172,10 @@ global $wpdb;
172
  // get the photo of the day
173
  function wppa_get_potd() {
174
  global $wpdb;
 
 
 
 
175
 
176
  $id = 0;
177
  switch ( wppa_opt( 'potd_method' ) ) {
@@ -313,5 +317,7 @@ global $wpdb;
313
  else {
314
  $result = false;
315
  }
 
 
316
  return $result;
317
  }
2
  /* wppa-widget-functions.php
3
  /* Package: wp-photo-album-plus
4
  /*
5
+ /* Version 6.6.12
6
  /*
7
  */
8
 
172
  // get the photo of the day
173
  function wppa_get_potd() {
174
  global $wpdb;
175
+ static $potd;
176
+
177
+ // Been here before?
178
+ if ( $potd ) return $potd;
179
 
180
  $id = 0;
181
  switch ( wppa_opt( 'potd_method' ) ) {
317
  else {
318
  $result = false;
319
  }
320
+
321
+ $potd = $result;
322
  return $result;
323
  }
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.5.00
7
  *
8
  */
9
 
@@ -169,7 +169,8 @@ global $wpdb;
169
  $doit = true;
170
  break;
171
  case 'album':
172
- if ( wppa_is_int($itemvalue) && $itemvalue > 0 ) {
 
173
  $doit = true;
174
  }
175
  else wppa_log('err', 'Invalid album id found in wppa_update_album(): '.$itemvalue);
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level wpdb routines that update records
6
+ * Version 6.6.12
7
  *
8
  */
9
 
169
  $doit = true;
170
  break;
171
  case 'album':
172
+ // Album id is > 0. -9 means: marked for deletion
173
+ if ( ( wppa_is_int($itemvalue) && $itemvalue > 0 ) || $itemvalue = '-9' ) {
174
  $doit = true;
175
  }
176
  else wppa_log('err', 'Invalid album id found in wppa_update_album(): '.$itemvalue);
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.6.11
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 = '6611'; // WPPA db version
26
- global $wppa_api_version; $wppa_api_version = '6-6-11-009'; // WPPA software version
27
 
28
  /* start timers */
29
  global $wppa_starttime; $wppa_starttime = microtime(true);
2
  /*
3
  * Plugin Name: WP Photo Album Plus
4
  * Description: Easily manage and display your photo albums and slideshows within your WordPress site.
5
+ * Version: 6.6.12
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 = '6612'; // WPPA db version
26
+ global $wppa_api_version; $wppa_api_version = '6-6-12-005'; // WPPA software version
27
 
28
  /* start timers */
29
  global $wppa_starttime; $wppa_starttime = microtime(true);