WP Photo Album Plus - Version 6.3.9

Version Description

Download this release

Release Info

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

Code changes from version 6.3.8 to 6.3.9

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.3.8
6
- Stable tag: 6.3.7
7
  Author: J.N. Breetvelt
8
  Author URI: http://www.opajaap.nl/
9
  Requires at least: 3.9
@@ -189,6 +189,21 @@ Oh, just Google on 'picture resizer' and you will find a bunch of free programs
189
 
190
  See for additional information: http://wppa.opajaap.nl/changelog/
191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  = 6.3.8 =
193
 
194
  = 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.3.9
6
+ Stable tag: 6.3.8
7
  Author: J.N. Breetvelt
8
  Author URI: http://www.opajaap.nl/
9
  Requires at least: 3.9
189
 
190
  See for additional information: http://wppa.opajaap.nl/changelog/
191
 
192
+ = 6.3.9 =
193
+
194
+ = Bug Fixes =
195
+
196
+ * IPTC data is now converted to utf8 to accomodate for iso characters in iptc data.
197
+ * Album names with quotes broke slideshow. Fixed: Search root ( album name ) is now properly escaped.
198
+ * Fixed an incompatibility issue of the wppa search widget when used in a Beaver Page Builder page module rather than in a sidebar.
199
+ * Fixed a page link and link back problem from slideshow to thumbnails during search when pretty links were enabled.
200
+ * Album view count stopped to be bumped. Fixed.
201
+
202
+ = Other Changes =
203
+
204
+ * Changed the default value for Table VII-D1.1: Owners only to TRUE.
205
+ * It is no longer possible to mis-configure Table VII so that logged out users can edit name and description of albums at the front-end.
206
+
207
  = 6.3.8 =
208
 
209
  = Bug Fixes =
wppa-adminbar.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * enhances the admin bar with wppa+ menu
6
- * version 6.3.0
7
  *
8
  */
9
 
@@ -12,28 +12,28 @@ add_action( 'admin_bar_menu', 'wppa_admin_bar_menu', 97 );
12
  function wppa_admin_bar_menu() {
13
  global $wp_admin_bar;
14
  global $wpdb;
15
-
16
  $wppaplus = 'wppa-admin-bar';
17
 
18
  $menu_items = false;
19
-
20
  // Pending comments
21
  $com_pend = $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_COMMENTS."` WHERE `status` = 'pending'" );
22
  if ( $com_pend ) $com_pending = '&nbsp;<span id="ab-awaiting-mod" class="pending-count">'.$com_pend.'</span>';
23
  else $com_pending = '';
24
-
25
  // Pending uploads
26
  $upl_pend = $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `status` = 'pending'" );
27
  if ( $upl_pend ) $upl_pending = '&nbsp;<span id="ab-awaiting-mod" class="pending-count">'.$upl_pend.'</span>';
28
  else $upl_pending = '';
29
-
30
  // Tot
31
  $tot_pend = '0';
32
  if ( current_user_can('administrator') ) $tot_pend += $com_pend;
33
- if ( current_user_can('wppa_admin') ) $tot_pend += $upl_pend;
34
  if ( $tot_pend ) $tot_pending = '&nbsp;<span id="ab-awaiting-mod" class="pending-count">'.$tot_pend.'</span>';
35
  else $tot_pending = '';
36
-
37
  if ( current_user_can( 'wppa_admin' ) ) {
38
  $menu_items['admin'] = array(
39
  'parent' => $wppaplus,
@@ -111,7 +111,7 @@ function wppa_admin_bar_menu() {
111
  'href' => 'http://wppa.opajaap.nl'
112
  );
113
  }
114
-
115
  // Add top-level item
116
  $wp_admin_bar->add_menu( array(
117
  'id' => $wppaplus,
@@ -121,12 +121,12 @@ function wppa_admin_bar_menu() {
121
 
122
  // Loop through menu items
123
  if ( $menu_items ) foreach ( $menu_items as $id => $menu_item ) {
124
-
125
  // Add in item ID
126
  $menu_item['id'] = 'wppa-' . $id;
127
 
128
  // Add meta target to each item where it's not already set, so links open in new tab
129
- if ( ! isset( $menu_item['meta']['target'] ) )
130
  $menu_item['meta']['target'] = '_self';
131
 
132
  // Add class to links that open up in a new tab
@@ -138,5 +138,5 @@ function wppa_admin_bar_menu() {
138
 
139
  // Add item
140
  $wp_admin_bar->add_menu( $menu_item );
141
- }
142
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * enhances the admin bar with wppa+ menu
6
+ * version 6.3.9
7
  *
8
  */
9
 
12
  function wppa_admin_bar_menu() {
13
  global $wp_admin_bar;
14
  global $wpdb;
15
+
16
  $wppaplus = 'wppa-admin-bar';
17
 
18
  $menu_items = false;
19
+
20
  // Pending comments
21
  $com_pend = $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_COMMENTS."` WHERE `status` = 'pending'" );
22
  if ( $com_pend ) $com_pending = '&nbsp;<span id="ab-awaiting-mod" class="pending-count">'.$com_pend.'</span>';
23
  else $com_pending = '';
24
+
25
  // Pending uploads
26
  $upl_pend = $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `status` = 'pending'" );
27
  if ( $upl_pend ) $upl_pending = '&nbsp;<span id="ab-awaiting-mod" class="pending-count">'.$upl_pend.'</span>';
28
  else $upl_pending = '';
29
+
30
  // Tot
31
  $tot_pend = '0';
32
  if ( current_user_can('administrator') ) $tot_pend += $com_pend;
33
+ if ( current_user_can('wppa_admin') ) $tot_pend += $upl_pend;
34
  if ( $tot_pend ) $tot_pending = '&nbsp;<span id="ab-awaiting-mod" class="pending-count">'.$tot_pend.'</span>';
35
  else $tot_pending = '';
36
+
37
  if ( current_user_can( 'wppa_admin' ) ) {
38
  $menu_items['admin'] = array(
39
  'parent' => $wppaplus,
111
  'href' => 'http://wppa.opajaap.nl'
112
  );
113
  }
114
+
115
  // Add top-level item
116
  $wp_admin_bar->add_menu( array(
117
  'id' => $wppaplus,
121
 
122
  // Loop through menu items
123
  if ( $menu_items ) foreach ( $menu_items as $id => $menu_item ) {
124
+
125
  // Add in item ID
126
  $menu_item['id'] = 'wppa-' . $id;
127
 
128
  // Add meta target to each item where it's not already set, so links open in new tab
129
+ if ( ! isset( $menu_item['meta']['target'] ) )
130
  $menu_item['meta']['target'] = '_self';
131
 
132
  // Add class to links that open up in a new tab
138
 
139
  // Add item
140
  $wp_admin_bar->add_menu( $menu_item );
141
+ }
142
  }
wppa-ajax.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-ajax.php
3
  *
4
  * Functions used in ajax requests
5
- * version 6.3.7
6
  *
7
  */
8
 
@@ -18,10 +18,9 @@ global $wppa_session;
18
  wppa( 'ajax', true );
19
  wppa( 'error', '0' );
20
  wppa( 'out', '' );
21
- if ( ! isset( $wppa_session['page'] ) ) $wppa_session['page'] = '0';
22
- else $wppa_session['page']--;
23
- if ( ! isset( $wppa_session['ajax'] ) ) $wppa_session['ajax'] = '1';
24
- else $wppa_session['ajax']++;
25
 
26
  // ALTHOUGH IF WE ARE HERE AS FRONT END VISITOR, is_admin() is true.
27
  // So, $wppa_opt switches are 'yes' or 'no' and not true or false.
@@ -53,7 +52,7 @@ global $wppa_session;
53
  $tag = str_replace( 'H', '#', $_REQUEST['tag'] );
54
  $mocc = $_REQUEST['moccur'];
55
  $oldvalue = '';
56
- if ( isset( $wppa_session['supersearch'] ) && strpos( $wppa_session['supersearch'], ',' ) !== false ) {
57
  $ss_data = explode( ',', $wppa_session['supersearch'] );
58
  if ( count( $ss_data ) == '4' ) {
59
  if ( $ss_data['0'] == 'p' ) {
@@ -92,14 +91,14 @@ global $wppa_session;
92
  $wpdb->query( $query );
93
  // wppa_log( 'dbg', $query );
94
  }
95
- exit;
96
  break;
97
 
98
  case 'getssexiflist':
99
  $tag = str_replace( 'H', '#', $_REQUEST['tag'] );
100
  $mocc = $_REQUEST['moccur'];
101
  $oldvalue = '';
102
- if ( isset( $wppa_session['supersearch'] ) && strpos( $wppa_session['supersearch'], ',' ) !== false ) {
103
  $ss_data = explode( ',', $wppa_session['supersearch'] );
104
  if ( count( $ss_data ) == '4' ) {
105
  if ( $ss_data['0'] == 'p' ) {
@@ -137,7 +136,7 @@ global $wppa_session;
137
  $wpdb->query( $query );
138
  // wppa_log( 'dbg', $query );
139
  }
140
- exit;
141
  break;
142
 
143
  case 'front-edit':
@@ -159,7 +158,7 @@ global $wppa_session;
159
  <div id="wppa-fe-count" style="float:right;" ></div>
160
  </div><div style="clear:both;"></div>';
161
  wppa_album_photos( '', $photo );
162
- exit;
163
  break;
164
 
165
  case 'do-comment':
@@ -168,7 +167,7 @@ global $wppa_session;
168
  $nonce = $_REQUEST['wppa-nonce'];
169
  if ( ! wp_verify_nonce( $nonce, 'wppa-nonce-'.$mocc ) ) {
170
  _e( 'Security check failure' , 'wp-photo-album-plus');
171
- exit;
172
  }
173
 
174
  // Correct the fact that this is a non-admin operation, if it is only
@@ -188,13 +187,13 @@ global $wppa_session;
188
  }
189
  wppa( 'no_esc', true );
190
  echo wppa_comment_html( $_REQUEST['photo-id'], $comment_allowed ); // Retrieve the new commentbox content
191
- exit;
192
  break;
193
 
194
  case 'import':
195
  require_once 'wppa-upload.php';
196
  _wppa_page_import();
197
- exit;
198
  break;
199
 
200
  case 'approve':
@@ -202,7 +201,7 @@ global $wppa_session;
202
 
203
  if ( ! current_user_can( 'wppa_moderate' ) && ! current_user_can( 'wppa_comments' ) ) {
204
  _e( 'You do not have the rights to moderate photos this way' , 'wp-photo-album-plus');
205
- exit;
206
  }
207
 
208
  if ( isset( $_REQUEST['photo-id'] ) && current_user_can( 'wppa_moderate' ) ) {
@@ -231,43 +230,43 @@ global $wppa_session;
231
  echo sprintf( __( 'Failed to update stutus of comment %s' , 'wp-photo-album-plus'), $_REQUEST['comment-id'] )."\n".__( 'Please refresh the page' , 'wp-photo-album-plus');
232
  }
233
  }
234
- exit;
235
 
236
  case 'remove':
237
  if ( isset( $_REQUEST['photo-id'] ) ) { // Remove photo
238
  if ( ( wppa_user_is( 'administrator' ) ) || ( current_user_can( 'wppa_moderate' ) ) || ( wppa_get_user() == wppa_get_photo_owner( $_REQUEST['photo-id'] ) && wppa_switch( 'wppa_upload_edit' ) ) ) { // Frontend delete?
239
  wppa_delete_photo( $_REQUEST['photo-id'] );
240
  echo 'OK||'.__( 'Photo removed' , 'wp-photo-album-plus');
241
- exit;
242
  }
243
  }
244
  if ( ! current_user_can( 'wppa_moderate' ) && ! current_user_can( 'wppa_comments' ) ) {
245
  _e( 'You do not have the rights to moderate photos this way' , 'wp-photo-album-plus');
246
- exit;
247
  }
248
  if ( isset( $_REQUEST['photo-id'] ) ) { // Remove photo
249
  if ( ! current_user_can( 'wppa_moderate' ) ) {
250
  _e( 'Security check failure' , 'wp-photo-album-plus');
251
- exit;
252
  }
253
  wppa_delete_photo( $_REQUEST['photo-id'] );
254
  echo 'OK||'.__( 'Photo removed' , 'wp-photo-album-plus');
255
- exit;
256
  }
257
  if ( isset( $_REQUEST['comment-id'] ) ) { // Remove comment
258
  $iret = $wpdb->query( $wpdb->prepare( "DELETE FROM `".WPPA_COMMENTS."` WHERE `id`= %s", $_REQUEST['comment-id'] ) );
259
  if ( $iret ) echo 'OK||'.__( 'Comment removed' , 'wp-photo-album-plus');
260
  else _e( 'Could not remove comment' , 'wp-photo-album-plus');
261
- exit;
262
  }
263
  _e( 'Unexpected error' , 'wp-photo-album-plus');
264
- exit;
265
 
266
  case 'downloadalbum':
267
  // Feature enabled?
268
  if ( ! wppa_switch( 'wppa_allow_download_album' ) ) {
269
  echo '||ER||'.__( 'This feature is not enabled on this website' , 'wp-photo-album-plus');
270
- exit;
271
  }
272
 
273
  // Validate args
@@ -279,7 +278,7 @@ global $wppa_session;
279
  $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `album` = %s AND ( ( ".$status." ) OR owner = %s ) ".wppa_get_photo_order( $alb ), $alb, wppa_get_user() ), ARRAY_A );
280
  if ( ! $photos ) {
281
  echo '||ER||'.__( 'The album is empty' , 'wp-photo-album-plus');
282
- exit;
283
  }
284
 
285
  // Remove obsolete files
@@ -288,7 +287,7 @@ global $wppa_session;
288
  // Open zipfile
289
  if ( ! class_exists( 'ZipArchive' ) ) {
290
  echo '||ER||'.__( 'Unable to create zip archive' , 'wp-photo-album-plus');
291
- exit;
292
  }
293
  $zipfilename = wppa_get_album_name( $alb );
294
  $zipfilename = wppa_sanitize_file_name( $zipfilename.'.zip' ); // Remove illegal chars
@@ -300,7 +299,7 @@ global $wppa_session;
300
  $iret = $wppa_zip->open( $zipfilepath, 1 );
301
  if ( $iret !== true ) {
302
  echo '||ER||'.sprintf( __( 'Unable to create zip archive. code = %s' , 'wp-photo-album-plus'), $iret );
303
- exit;
304
  }
305
 
306
  // Add photos to zip
@@ -322,7 +321,7 @@ global $wppa_session;
322
  // To prevent too may files open, and to have at least a file when there are too many photos, close and re-open
323
  $wppa_zip->close();
324
  $wppa_zip->open( $zipfilepath );
325
- wppa_log( 'dbg', 'Added ' . basename($source) . ' to ' . basename($zipfilepath));
326
  }
327
  }
328
  }
@@ -337,7 +336,7 @@ global $wppa_session;
337
  $desturl = WPPA_UPLOAD_URL.'/temp/'.$zipfilename;
338
  echo $desturl.'||OK||';
339
  if ( $zipcount != count( $photos ) ) echo sprintf( __( 'Only %s out of %s photos could be added to the zipfile' , 'wp-photo-album-plus'), $zipcount, count( $photos ) );
340
- exit;
341
  break;
342
 
343
  case 'getalbumzipurl':
@@ -352,7 +351,7 @@ global $wppa_session;
352
  else {
353
  echo 'ER';
354
  }
355
- exit;
356
  break;
357
 
358
  case 'makeorigname':
@@ -366,7 +365,7 @@ global $wppa_session;
366
  }
367
  else {
368
  echo '||7||'.__( 'Unknown source of request' , 'wp-photo-album-plus');
369
- exit;
370
  }
371
 
372
  $data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $photo ), ARRAY_A );
@@ -384,7 +383,7 @@ global $wppa_session;
384
  $name = preg_replace( '/\.[^.]*$/', '', $name ); // Remove file extension
385
  if ( strlen( $name ) == '0' ) {
386
  echo '||1||'.__( 'Empty filename' , 'wp-photo-album-plus');
387
- exit;
388
  }
389
 
390
  // Make the file
@@ -411,7 +410,7 @@ global $wppa_session;
411
  if ( ! is_dir( $tempdir ) ) @ mkdir( $tempdir );
412
  if ( ! is_dir( $tempdir ) ) {
413
  echo '||2||'.__( 'Unable to create tempdir' , 'wp-photo-album-plus');
414
- exit;
415
  }
416
 
417
  // Remove obsolete files
@@ -425,7 +424,7 @@ global $wppa_session;
425
  elseif ( $type == 'zip' ) {
426
  if ( ! class_exists( 'ZipArchive' ) ) {
427
  echo '||8||'.__( 'Unable to create zip archive' , 'wp-photo-album-plus');
428
- exit;
429
  }
430
  $ext = 'zip';
431
  $wppa_zip = new ZipArchive;
@@ -435,24 +434,24 @@ global $wppa_session;
435
  }
436
  else {
437
  echo '||6||'.__( 'Unknown type' , 'wp-photo-album-plus');
438
- exit;
439
  }
440
 
441
  $desturl = WPPA_UPLOAD_URL.'/temp/'.$name.'.'.$ext;
442
  echo '||0||'.$desturl; // No error: return url
443
- exit;
444
  }
445
  else {
446
  echo '||9||'.__( 'The photo does no longer exist' , 'wp-photo-album-plus');
447
- exit;
448
  }
449
- exit;
450
  break;
451
 
452
  case 'tinymcedialog':
453
  $result = wppa_make_tinymce_dialog();
454
  echo $result;
455
- exit;
456
  break;
457
 
458
  case 'bumpviewcount':
@@ -463,7 +462,7 @@ global $wppa_session;
463
  else {
464
  _e( 'Security check failure' , 'wp-photo-album-plus');
465
  }
466
- exit;
467
  break;
468
 
469
  case 'rate':
@@ -484,25 +483,25 @@ global $wppa_session;
484
  // Check on validity
485
  if ( ! wp_verify_nonce( $nonce, 'wppa-check' ) ) {
486
  echo '0||100||'.$errtxt;
487
- exit; // Nonce check failed
488
  }
489
  if ( wppa_opt( 'wppa_rating_max' ) == '1' && $rating != '1' ) {
490
  echo '0||106||'.$errtxt.':'.$rating;
491
- exit; // Value out of range
492
  }
493
  elseif ( wppa_opt( 'wppa_rating_max' ) == '5' && ! in_array( $rating, array( '-1', '1', '2', '3', '4', '5' ) ) ) {
494
  echo '0||106||'.$errtxt.':'.$rating;
495
- exit; // Value out of range
496
  }
497
  elseif ( wppa_opt( 'wppa_rating_max' ) == '10' && ! in_array( $rating, array( '-1', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10' ) ) ) {
498
  echo '0||106||'.$errtxt.':'.$rating;
499
- exit; // Value out of range
500
  }
501
 
502
  // Get other data
503
  if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $photo ) ) ) {
504
  echo '0||999||'.__( 'Photo has been removed.' , 'wp-photo-album-plus');
505
- exit;
506
  }
507
  $user = wppa_get_user();
508
  $mylast = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM `'.WPPA_RATING.'` WHERE `photo` = %s AND `user` = %s ORDER BY `id` DESC LIMIT 1', $photo, $user ), ARRAY_A );
@@ -511,7 +510,7 @@ global $wppa_session;
511
  // Rate own photo?
512
  if ( wppa_get_photo_item( $photo, 'owner' ) == $user && ! wppa_switch( 'wppa_allow_owner_votes' ) ) {
513
  echo '0||900||'.__( 'Sorry, you can not rate your own photos' , 'wp-photo-album-plus');
514
- exit;
515
  }
516
 
517
  // Already a pending one?
@@ -523,7 +522,7 @@ global $wppa_session;
523
  if ( $pending ) {
524
  if ( ! $hascommented ) {
525
  echo '0||900||'.__( 'Please enter a comment.' , 'wp-photo-album-plus');
526
- exit;
527
  }
528
  else {
529
  $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_RATING."` SET `status` = 'publish' WHERE `photo` = %s AND `user` = %s", $photo, $user ) );
@@ -548,7 +547,7 @@ global $wppa_session;
548
  )
549
  ) {
550
  echo '0||109||'.__( 'Security check failure.' , 'wp-photo-album-plus');
551
- exit;
552
  }
553
  // Case 1: value = -1 this is a legal dislike vote
554
  if ( $rating == '-1' ) {
@@ -556,14 +555,14 @@ global $wppa_session;
556
  $iret = wppa_create_rating_entry( array( 'photo' => $photo, 'value' => $rating, 'user' => $user, 'status' => $ratingstatus ) );
557
  if ( ! $iret ) {
558
  echo '0||101||'.$errtxt;
559
- exit; // Fail on storing vote
560
  }
561
  // Add points
562
  wppa_add_credit_points( wppa_opt( 'wppa_cp_points_rating' ), __( 'Photo rated' , 'wp-photo-album-plus'), $photo, $rating );
563
  wppa_dislike_check( $photo ); // Check for email to be sent every .. dislikes
564
  if ( ! is_file( wppa_get_thumb_path( $photo ) ) ) { // Photo is removed
565
  echo $occur.'||'.$photo.'||'.$index.'||-1||-1|0||'.wppa_opt( 'wppa_dislike_delete' );
566
- exit;
567
  }
568
  }
569
  // Case 2: This is my first vote for this photo
@@ -572,7 +571,7 @@ global $wppa_session;
572
  $iret = wppa_create_rating_entry( array( 'photo' => $photo, 'value' => $rating, 'user' => $user, 'status' => $ratingstatus ) );
573
  if ( ! $iret ) {
574
  echo '0||102||'.$errtxt;
575
- exit; // Fail on storing vote
576
  }
577
  // Add points
578
  wppa_add_credit_points( wppa_opt( 'wppa_cp_points_rating' ), __( 'Photo rated' , 'wp-photo-album-plus'), $photo, $rating );
@@ -582,7 +581,7 @@ global $wppa_session;
582
  $iret = $wpdb->query( $wpdb->prepare( 'UPDATE `'.WPPA_RATING.'` SET `value` = %s WHERE `photo` = %s AND `user` = %s LIMIT 1', $rating, $photo, $user ) );
583
  if ( $iret === false ) {
584
  echo '0||103||'.$errtxt;
585
- exit; // Fail on update
586
  }
587
  }
588
  // Case 4: Add another vote from me
@@ -590,12 +589,12 @@ global $wppa_session;
590
  $iret = wppa_create_rating_entry( array( 'photo' => $photo, 'value' => $rating, 'user' => $user, 'status' => $ratingstatus ) );
591
  if ( ! $iret ) {
592
  echo '0||104||'.$errtxt;
593
- exit; // Fail on storing vote
594
  }
595
  }
596
  else { // Should never get here....
597
  echo '0||110||'.__( 'Unexpected error' , 'wp-photo-album-plus');
598
- exit;
599
  }
600
 
601
  // Compute my avg rating
@@ -644,7 +643,7 @@ global $wppa_session;
644
  $iret = $wpdb->query( $wpdb->prepare( 'UPDATE `'.WPPA_PHOTOS. '` SET `mean_rating` = %s WHERE `id` = %s', $allavgrat, $photo ) );
645
  if ( $iret === false ) {
646
  echo '0||106||'.$wartxt;
647
- exit; // Fail on save
648
  }
649
 
650
  // Compute rating_count and store in the photo info
@@ -653,7 +652,7 @@ global $wppa_session;
653
  $iret = $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `rating_count` = %s WHERE `id` = %s", $ratcount, $photo ) );
654
  if ( $iret === false ) {
655
  echo '0||107||'.$wartxt;
656
- exit; // Fail on save
657
  }
658
  }
659
 
@@ -664,7 +663,7 @@ global $wppa_session;
664
  $discount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_RATING."` WHERE `photo` = %s AND `value` = -1 AND `status` = %s", $photo, 'publish' ) );
665
  if ( $discount === false ) {
666
  echo '0||108||'.$wartxt;
667
- exit; // Fail on save
668
  }
669
 
670
  // Test for possible medal
@@ -719,11 +718,11 @@ global $wppa_session;
719
  // Check validity
720
  if ( ! wp_verify_nonce( $nonce, 'wppa_nonce_'.$photo ) ) {
721
  echo '||0||'.__( 'You do not have the rights to delete a photo' , 'wp-photo-album-plus');
722
- exit; // Nonce check failed
723
  }
724
  if ( ! is_numeric( $photo ) ) {
725
  echo '||0||'.__( 'Security check failure' , 'wp-photo-album-plus');
726
- exit; // Nonce check failed
727
  }
728
  $album = $wpdb->get_var( $wpdb->prepare( 'SELECT `album` FROM `'.WPPA_PHOTOS.'` WHERE `id` = %s', $photo ) );
729
  wppa_delete_photo( $photo );
@@ -745,7 +744,7 @@ global $wppa_session;
745
  // Check validity
746
  if ( ! wp_verify_nonce( $nonce, 'wppa_nonce_'.$album ) ) {
747
  echo '||0||'.__( 'You do not have the rights to update album information' , 'wp-photo-album-plus').$nonce;
748
- exit; // Nonce check failed
749
  }
750
 
751
  switch ( $item ) {
@@ -764,7 +763,7 @@ global $wppa_session;
764
  else {
765
  echo '||97||'.__( '<b>No photos in this album</b>' , 'wp-photo-album-plus').'||'.__( 'No ratings for this photo.' , 'wp-photo-album-plus');
766
  }
767
- exit;
768
  break;
769
  case 'set_deftags': // to be changed for large albums
770
  $photos = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM `'.WPPA_PHOTOS.'` WHERE `album` = %s', $album ), ARRAY_A );
@@ -786,7 +785,7 @@ global $wppa_session;
786
  echo '||97||'.__( '<b>No photos in this album</b>' , 'wp-photo-album-plus');
787
  }
788
  wppa_clear_taglist();
789
- exit;
790
  break;
791
  case 'add_deftags':
792
  $photos = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM `'.WPPA_PHOTOS.'` WHERE `album` = %s', $album ), ARRAY_A );
@@ -808,7 +807,7 @@ global $wppa_session;
808
  echo '||97||'.__( '<b>No photos in this album</b>' , 'wp-photo-album-plus');
809
  }
810
  wppa_clear_taglist();
811
- exit;
812
  break;
813
  case 'name':
814
  $value = trim( strip_tags( $value ) );
@@ -824,7 +823,7 @@ global $wppa_session;
824
  $value = str_replace( array( '<br/>','<br>' ), '<br />', $value );
825
  if ( balanceTags( $value, true ) != $value ) {
826
  echo '||3||'.__( 'Unbalanced tags in album description!' , 'wp-photo-album-plus');
827
- exit;
828
  }
829
  }
830
  $value = trim( $value );
@@ -859,12 +858,12 @@ global $wppa_session;
859
  $itemname = __( 'Owner' , 'wp-photo-album-plus');
860
  if ( $value != '--- public ---' && ! get_user_by( 'login', $value ) ) {
861
  echo '||4||'.sprintf( __( 'User %s does not exist' , 'wp-photo-album-plus'), $value );
862
- exit;
863
  }
864
  break;
865
  case 'upload_limit_count':
866
  wppa_ajax_check_range( $value, false, '0', false, __( 'Upload limit count' , 'wp-photo-album-plus') );
867
- if ( wppa( 'error' ) ) exit;
868
  $oldval = $wpdb->get_var( $wpdb->prepare( 'SELECT `upload_limit` FROM '.WPPA_ALBUMS.' WHERE `id` = %s', $album ) );
869
  $temp = explode( '/', $oldval );
870
  $value = $value.'/'.$temp[1];
@@ -910,7 +909,7 @@ global $wppa_session;
910
  $scheduledtm = implode( ',', $temp );
911
  wppa_update_album( array( 'id' => $album, 'scheduledtm' => $scheduledtm ) );
912
  echo '||0||'.sprintf( __( '<b>%s</b> of album %s updated' , 'wp-photo-album-plus'), $itemname, $album );
913
- exit;
914
  break;
915
 
916
  case 'setallscheduled':
@@ -919,7 +918,7 @@ global $wppa_session;
919
  $iret = $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `status` = 'scheduled', `scheduledtm` = %s WHERE `album` = %s", $scheduledtm, $album ) );
920
  echo '||0||'.__( 'All photos set to scheduled per date' , 'wp-photo-album-plus').' ( '.$iret.' ) '.wppa_format_scheduledtm( $scheduledtm );
921
  }
922
- exit;
923
  break;
924
 
925
  default:
@@ -948,7 +947,7 @@ global $wppa_session;
948
  echo '<br>'.__( 'Press CTRL+F5 and try again.' , 'wp-photo-album-plus');
949
  }
950
  wppa_clear_cache();
951
- exit;
952
  break;
953
 
954
  case 'update-comment-status':
@@ -960,7 +959,7 @@ global $wppa_session;
960
  // Check validity
961
  if ( ! wp_verify_nonce( $nonce, 'wppa_nonce_'.$photo ) ) {
962
  echo '||0||'.__( 'You do not have the rights to update comment status' , 'wp-photo-album-plus').$nonce;
963
- exit; // Nonce check failed
964
  }
965
 
966
  // if ( wppa_switch( 'wppa_search_comments' ) ) wppa_index_remove( 'photo', $photo );
@@ -973,7 +972,7 @@ global $wppa_session;
973
  else {
974
  echo '||1||'.sprintf( __( 'Error updating status comment #%s' , 'wp-photo-album-plus'), $comid );
975
  }
976
- exit;
977
  break;
978
 
979
  case 'watermark-photo':
@@ -983,7 +982,7 @@ global $wppa_session;
983
  // Check validity
984
  if ( ! wp_verify_nonce( $nonce, 'wppa_nonce_'.$photo ) ) {
985
  echo '||1||'.__( 'You do not have the rights to change photos' , 'wp-photo-album-plus');
986
- exit; // Nonce check failed
987
  }
988
 
989
  wppa_cache_thumb( $photo );
@@ -992,11 +991,11 @@ global $wppa_session;
992
  wppa_create_thumbnail( $photo ); // create new thumb
993
  }
994
  echo '||0||'.__( 'Watermark applied' , 'wp-photo-album-plus');
995
- exit;
996
  }
997
  else {
998
  echo '||1||'.__( 'An error occured while trying to apply a watermark' , 'wp-photo-album-plus');
999
- exit;
1000
  }
1001
 
1002
  case 'update-photo':
@@ -1009,13 +1008,13 @@ global $wppa_session;
1009
  // Check validity
1010
  if ( ! wp_verify_nonce( $nonce, 'wppa_nonce_'.$photo ) ) {
1011
  echo '||0||'.__( 'You do not have the rights to update photo information' , 'wp-photo-album-plus');
1012
- exit; // Nonce check failed
1013
  }
1014
 
1015
  if ( substr( $item, 0, 20 ) == 'wppa_watermark_file_' || substr( $item, 0, 19 ) == 'wppa_watermark_pos_' ) {
1016
  wppa_update_option( $item, $value );
1017
  echo '||0||'.sprintf( __( '%s updated to %s.' , 'wp-photo-album-plus'), $item, $value );
1018
- exit;
1019
  }
1020
 
1021
  switch ( $item ) {
@@ -1070,12 +1069,12 @@ global $wppa_session;
1070
  wppa_update_photo( array( 'id' => $photo, 'exifdtm' => $value ) );
1071
  echo '||0||'.__( 'Exif date/time updated' , 'wp-photo-album-plus');
1072
  }
1073
- exit;
1074
  break;
1075
  case 'lat':
1076
  if ( ! is_numeric( $value ) || $value < '-90.0' || $value > '90.0' ) {
1077
  echo '||1||'.__( 'Enter a value > -90 and < 90' , 'wp-photo-album-plus');
1078
- exit;
1079
  }
1080
  $photodata = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM '.WPPA_PHOTOS.' WHERE `id` = %s', $photo ), ARRAY_A );
1081
  $geo = $photodata['location'] ? $photodata['location'] : '///';
@@ -1086,12 +1085,12 @@ global $wppa_session;
1086
  else {
1087
  echo '||1||'.__( 'Could not update lattitude' , 'wp-photo-album-plus');
1088
  }
1089
- exit;
1090
  break;
1091
  case 'lon':
1092
  if ( ! is_numeric( $value ) || $value < '-180.0' || $value > '180.0' ) {
1093
  echo '||1||'.__( 'Enter a value > -180 and < 180' , 'wp-photo-album-plus');
1094
- exit;
1095
  }
1096
  $photodata = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM '.WPPA_PHOTOS.' WHERE `id` = %s', $photo ), ARRAY_A );
1097
  $geo = $photodata['location'] ? $photodata['location'] : '///';
@@ -1102,7 +1101,7 @@ global $wppa_session;
1102
  else {
1103
  echo '||1||'.__( 'Could not update longitude' , 'wp-photo-album-plus');
1104
  }
1105
- exit;
1106
  break;
1107
  case 'remake':
1108
  if ( wppa_remake_files( '', $photo ) ) {
@@ -1113,7 +1112,7 @@ global $wppa_session;
1113
  else {
1114
  echo '||2||'.__( 'Could not remake files' , 'wp-photo-album-plus');
1115
  }
1116
- exit;
1117
  break;
1118
  case 'remakethumb':
1119
  if ( wppa_create_thumbnail( $photo ) ) {
@@ -1122,7 +1121,7 @@ global $wppa_session;
1122
  else {
1123
  echo '||0||'.__( 'Could not remake thumbnail' , 'wp-photo-album-plus');
1124
  }
1125
- exit;
1126
  break;
1127
  case 'rotright':
1128
  case 'rot180':
@@ -1151,7 +1150,7 @@ global $wppa_session;
1151
  else {
1152
  echo '||'.wppa( 'error' ).'||'.sprintf( __( 'An error occurred while trying to rotate photo %s' , 'wp-photo-album-plus'), $photo );
1153
  }
1154
- exit;
1155
  break;
1156
 
1157
  case 'moveto':
@@ -1160,7 +1159,7 @@ global $wppa_session;
1160
  $exists = wppa_file_is_in_album( $photodata['filename'], $value );
1161
  if ( $exists ) { // Already exists
1162
  echo '||3||' . sprintf ( __( 'A photo with filename %s already exists in album %s.' , 'wp-photo-album-plus'), $photodata['filename'], $value );
1163
- exit;
1164
  break;
1165
  }
1166
  }
@@ -1174,7 +1173,7 @@ global $wppa_session;
1174
  else {
1175
  echo '||3||'.sprintf( __( 'An error occurred while trying to move photo %s' , 'wp-photo-album-plus'), $photo );
1176
  }
1177
- exit;
1178
  break;
1179
 
1180
  case 'copyto':
@@ -1183,7 +1182,7 @@ global $wppa_session;
1183
  $exists = wppa_file_is_in_album( $photodata['filename'], $value );
1184
  if ( $exists ) { // Already exists
1185
  echo '||4||' . sprintf ( __( 'A photo with filename %s already exists in album %s.' , 'wp-photo-album-plus'), $photodata['filename'], $value );
1186
- exit;
1187
  break;
1188
  }
1189
  }
@@ -1196,7 +1195,7 @@ global $wppa_session;
1196
  echo '||4||'.sprintf( __( 'An error occurred while trying to copy photo %s' , 'wp-photo-album-plus'), $photo );
1197
  echo '<br>'.__( 'Press CTRL+F5 and try again.' , 'wp-photo-album-plus');
1198
  }
1199
- exit;
1200
  break;
1201
 
1202
  case 'status':
@@ -1224,7 +1223,7 @@ global $wppa_session;
1224
  $value = str_replace( array( '<br/>','<br>' ), '<br />', $value );
1225
  if ( balanceTags( $value, true ) != $value ) {
1226
  echo '||3||'.__( 'Unbalanced tags in photo description!' , 'wp-photo-album-plus');
1227
- exit;
1228
  }
1229
  }
1230
  break;
@@ -1235,7 +1234,7 @@ global $wppa_session;
1235
  $usr = get_user_by( 'login', $value );
1236
  if ( ! $usr ) {
1237
  echo '||4||' . sprintf( __( 'User %s does not exists' , 'wp-photo-album-plus'), $value );
1238
- exit;
1239
  }
1240
  $value = $usr->user_login; // Correct possible case mismatch
1241
  wppa_flush_upldr_cache( 'photoid', $photo ); // Current owner
@@ -1270,14 +1269,14 @@ global $wppa_session;
1270
  $itemname = __( 'Video width' , 'wp-photo-album-plus');
1271
  if ( ! wppa_is_int( $value ) || $value < '0' ) {
1272
  echo '||3||'.__( 'Please enter an integer value >= 0' , 'wp-photo-album-plus');
1273
- exit;
1274
  }
1275
  break;
1276
  case 'videoy':
1277
  $itemname = __( 'Video height', 'wp-photo-album-plus');
1278
  if ( ! wppa_is_int( $value ) || $value < '0' ) {
1279
  echo '||3||'.__( 'Please enter an integer value >= 0' , 'wp-photo-album-plus');
1280
- exit;
1281
  }
1282
  break;
1283
 
@@ -1301,7 +1300,7 @@ global $wppa_session;
1301
  else {
1302
  echo '||2||'.sprintf( __( 'An error occurred while trying to update <b>%s</b> of photo %s' , 'wp-photo-album-plus'), $itemname, $photo );
1303
  echo '<br>'.__( 'Press CTRL+F5 and try again.' , 'wp-photo-album-plus');
1304
- exit;
1305
  }
1306
  break;
1307
 
@@ -1363,7 +1362,7 @@ global $wppa_session;
1363
  // Check on upload error
1364
  if ( $_FILES['photo']['error'] ) {
1365
  echo '||'.$_FILES['photo']['error'].'||'.__( '<b>Error during upload.</b>', 'wp-photo-album-plus');
1366
- exit;
1367
  }
1368
 
1369
  // Save new source
@@ -1394,7 +1393,7 @@ global $wppa_session;
1394
  // Report fail
1395
  echo '||1||'.__( 'Could not update files.' , 'wp-photo-album-plus');
1396
  }
1397
- exit;
1398
  break;
1399
 
1400
  case 'stereo':
@@ -1404,12 +1403,12 @@ global $wppa_session;
1404
  wppa_create_thumbnail( $photo );
1405
  $t = microtime(true) - $t;
1406
  echo '||0||' . sprintf( __( 'Stereo mode updated in %d milliseconds', 'wp-photo-album-plus'), floor( $t * 1000 ) );
1407
- exit;
1408
  break;
1409
 
1410
  default:
1411
  echo '||98||This update action is not implemented yet( '.$item.' )';
1412
- exit;
1413
  }
1414
  wppa_clear_cache();
1415
  break;
@@ -1420,7 +1419,7 @@ global $wppa_session;
1420
  $nonce = $_REQUEST['wppa-nonce'];
1421
  if ( ! wp_verify_nonce( $nonce, 'wppa-nonce' ) ) {
1422
  echo '||1||'.__( 'You do not have the rights to update settings' , 'wp-photo-album-plus');
1423
- exit; // Nonce check failed
1424
  }
1425
 
1426
  // Initialize
@@ -1450,7 +1449,7 @@ global $wppa_session;
1450
  $output = '||1||Failed to update '.$tag.'||';
1451
  }
1452
  echo $output;
1453
- exit;
1454
  }
1455
  elseif ( substr( $option, 0, 17 ) == 'wppa_iptc_status_' ) {
1456
  $tag = substr( $option, 17 );
@@ -1464,7 +1463,7 @@ global $wppa_session;
1464
  $output = '||1||Failed to update '.$tag.'||';
1465
  }
1466
  echo $output;
1467
- exit;
1468
  }
1469
  elseif ( substr( $option, 0, 16 ) == 'wppa_exif_label_' ) {
1470
  $tag = substr( $option, 16 );
@@ -1478,7 +1477,7 @@ global $wppa_session;
1478
  $output = '||1||Failed to update '.$tag.'||';
1479
  }
1480
  echo $output;
1481
- exit;
1482
  }
1483
  elseif ( substr( $option, 0, 17 ) == 'wppa_exif_status_' ) {
1484
  $tag = substr( $option, 17 );
@@ -1492,7 +1491,7 @@ global $wppa_session;
1492
  $output = '||1||Failed to update '.$tag.'||';
1493
  }
1494
  echo $output;
1495
- exit;
1496
  }
1497
  elseif ( substr( $option, 0, 5 ) == 'caps-' ) { // Is capability setting
1498
  global $wp_roles;
@@ -1501,16 +1500,16 @@ global $wppa_session;
1501
  if ( $value == 'yes' ) {
1502
  $wp_roles->add_cap( $setting[2], $setting[1] );
1503
  echo '||0||'.__( 'Capability granted' , 'wp-photo-album-plus').'||';
1504
- exit;
1505
  }
1506
  elseif ( $value == 'no' ) {
1507
  $wp_roles->remove_cap( $setting[2], $setting[1] );
1508
  echo '||0||'.__( 'Capability withdrawn' , 'wp-photo-album-plus').'||';
1509
- exit;
1510
  }
1511
  else {
1512
  echo '||1||Invalid value: '.$value.'||';
1513
- exit;
1514
  }
1515
  }
1516
  else switch ( $option ) {
@@ -1723,7 +1722,7 @@ global $wppa_session;
1723
  case 'wppa_recup':
1724
  $result = wppa_recuperate_iptc_exif();
1725
  echo '||0||'.__( 'Recuperation performed' , 'wp-photo-album-plus').'||'.$result;
1726
- exit;
1727
  break;
1728
 
1729
  case 'wppa_bgcolor_thumbnail':
@@ -2140,7 +2139,7 @@ global $wppa_session;
2140
 
2141
  echo $output;
2142
  wppa_clear_cache();
2143
- exit;
2144
  break; // End update-option
2145
 
2146
  case 'maintenance':
@@ -2148,10 +2147,10 @@ global $wppa_session;
2148
  $nonce = $_REQUEST['wppa-nonce'];
2149
  if ( ! wp_verify_nonce( $nonce, 'wppa-nonce' ) ) {
2150
  echo 'Security check failure||'.$slug.'||Error||0';
2151
- exit;
2152
  }
2153
  echo wppa_do_maintenance_proc( $slug );
2154
- exit;
2155
  break;
2156
 
2157
  case 'maintenancepopup':
@@ -2159,10 +2158,10 @@ global $wppa_session;
2159
  $nonce = $_REQUEST['wppa-nonce'];
2160
  if ( ! wp_verify_nonce( $nonce, 'wppa-nonce' ) ) {
2161
  echo 'Security check failure||'.$slug.'||Error||0';
2162
- exit;
2163
  }
2164
  echo wppa_do_maintenance_popup( $slug );
2165
- exit;
2166
  break;
2167
 
2168
  case 'do-fe-upload':
@@ -2171,7 +2170,7 @@ global $wppa_session;
2171
  }
2172
  wppa_user_upload();
2173
  echo wppa( 'out' );
2174
- exit;
2175
  break;
2176
 
2177
  case 'sanitizetags':
@@ -2180,19 +2179,19 @@ global $wppa_session;
2180
  $deftags = $album ? wppa_get_album_item( $album, 'default_tags' ) : '';
2181
  $tags = $deftags ? $tags . ',' . $deftags : $tags;
2182
  echo wppa_sanitize_tags( $tags, false, true );
2183
- exit;
2184
  break;
2185
 
2186
  case 'destroyalbum':
2187
  $album = isset( $_GET['album'] ) ? $_GET['album'] : '0';
2188
  if ( ! $album ) {
2189
  _e('Missing album id', 'wp-photo-album-plus');
2190
- exit;
2191
  }
2192
  $nonce = isset( $_GET['nonce'] ) ? $_GET['nonce'] : '';
2193
  if ( ! $nonce || ! wp_verify_nonce( $nonce, 'wppa_nonce_'.$album ) ) {
2194
  echo 'Security check failure #798';
2195
- exit;
2196
  }
2197
 
2198
  // May I?
@@ -2207,20 +2206,20 @@ global $wppa_session;
2207
  if ( wppa_is_user_blacklisted() ) $may = false;
2208
  if ( ! $imay ) {
2209
  _e('You do not have the rights to delete this album', 'wp-photo-album-plus');
2210
- exit;
2211
  }
2212
 
2213
  // I may
2214
  require_once 'wppa-album-admin-autosave.php';
2215
  wppa_del_album( $album, '' );
2216
- exit;
2217
  break;
2218
 
2219
 
2220
  default: // Unimplemented $wppa-action
2221
  die( '-1' );
2222
  }
2223
- exit;
2224
  }
2225
 
2226
  function wppa_decode( $string ) {
@@ -2235,13 +2234,13 @@ function wppa_decode( $string ) {
2235
  }
2236
 
2237
  function wppa_ajax_check_range( $value, $fixed, $low, $high, $title ) {
2238
- global $wppa;
2239
  if ( $fixed !== false && $fixed == $value ) return; // User enetred special value correctly
2240
  if ( !is_numeric( $value ) ) wppa( 'error', true ); // Must be numeric if not specaial value
2241
  if ( $low !== false && $value < $low ) wppa( 'error', true ); // Must be >= given min value
2242
  if ( $high !== false && $value > $high ) wppa( 'error' , true ); // Must be <= given max value
2243
 
2244
- if ( !$wppa ['error'] ) return; // Still no error, ok
2245
 
2246
  // Compose error message
2247
  if ( $low !== false && $high === false ) { // Only Minimum given
2
  /* wppa-ajax.php
3
  *
4
  * Functions used in ajax requests
5
+ * version 6.3.9
6
  *
7
  */
8
 
18
  wppa( 'ajax', true );
19
  wppa( 'error', '0' );
20
  wppa( 'out', '' );
21
+ $wppa_session['page']--;
22
+ $wppa_session['ajax']++;
23
+ wppa_save_session();
 
24
 
25
  // ALTHOUGH IF WE ARE HERE AS FRONT END VISITOR, is_admin() is true.
26
  // So, $wppa_opt switches are 'yes' or 'no' and not true or false.
52
  $tag = str_replace( 'H', '#', $_REQUEST['tag'] );
53
  $mocc = $_REQUEST['moccur'];
54
  $oldvalue = '';
55
+ if ( strpos( $wppa_session['supersearch'], ',' ) !== false ) {
56
  $ss_data = explode( ',', $wppa_session['supersearch'] );
57
  if ( count( $ss_data ) == '4' ) {
58
  if ( $ss_data['0'] == 'p' ) {
91
  $wpdb->query( $query );
92
  // wppa_log( 'dbg', $query );
93
  }
94
+ wppa_exit();
95
  break;
96
 
97
  case 'getssexiflist':
98
  $tag = str_replace( 'H', '#', $_REQUEST['tag'] );
99
  $mocc = $_REQUEST['moccur'];
100
  $oldvalue = '';
101
+ if ( strpos( $wppa_session['supersearch'], ',' ) !== false ) {
102
  $ss_data = explode( ',', $wppa_session['supersearch'] );
103
  if ( count( $ss_data ) == '4' ) {
104
  if ( $ss_data['0'] == 'p' ) {
136
  $wpdb->query( $query );
137
  // wppa_log( 'dbg', $query );
138
  }
139
+ wppa_exit();
140
  break;
141
 
142
  case 'front-edit':
158
  <div id="wppa-fe-count" style="float:right;" ></div>
159
  </div><div style="clear:both;"></div>';
160
  wppa_album_photos( '', $photo );
161
+ wppa_exit();
162
  break;
163
 
164
  case 'do-comment':
167
  $nonce = $_REQUEST['wppa-nonce'];
168
  if ( ! wp_verify_nonce( $nonce, 'wppa-nonce-'.$mocc ) ) {
169
  _e( 'Security check failure' , 'wp-photo-album-plus');
170
+ wppa_exit();
171
  }
172
 
173
  // Correct the fact that this is a non-admin operation, if it is only
187
  }
188
  wppa( 'no_esc', true );
189
  echo wppa_comment_html( $_REQUEST['photo-id'], $comment_allowed ); // Retrieve the new commentbox content
190
+ wppa_exit();
191
  break;
192
 
193
  case 'import':
194
  require_once 'wppa-upload.php';
195
  _wppa_page_import();
196
+ wppa_exit();
197
  break;
198
 
199
  case 'approve':
201
 
202
  if ( ! current_user_can( 'wppa_moderate' ) && ! current_user_can( 'wppa_comments' ) ) {
203
  _e( 'You do not have the rights to moderate photos this way' , 'wp-photo-album-plus');
204
+ wppa_exit();
205
  }
206
 
207
  if ( isset( $_REQUEST['photo-id'] ) && current_user_can( 'wppa_moderate' ) ) {
230
  echo sprintf( __( 'Failed to update stutus of comment %s' , 'wp-photo-album-plus'), $_REQUEST['comment-id'] )."\n".__( 'Please refresh the page' , 'wp-photo-album-plus');
231
  }
232
  }
233
+ wppa_exit();
234
 
235
  case 'remove':
236
  if ( isset( $_REQUEST['photo-id'] ) ) { // Remove photo
237
  if ( ( wppa_user_is( 'administrator' ) ) || ( current_user_can( 'wppa_moderate' ) ) || ( wppa_get_user() == wppa_get_photo_owner( $_REQUEST['photo-id'] ) && wppa_switch( 'wppa_upload_edit' ) ) ) { // Frontend delete?
238
  wppa_delete_photo( $_REQUEST['photo-id'] );
239
  echo 'OK||'.__( 'Photo removed' , 'wp-photo-album-plus');
240
+ wppa_exit();
241
  }
242
  }
243
  if ( ! current_user_can( 'wppa_moderate' ) && ! current_user_can( 'wppa_comments' ) ) {
244
  _e( 'You do not have the rights to moderate photos this way' , 'wp-photo-album-plus');
245
+ wppa_exit();
246
  }
247
  if ( isset( $_REQUEST['photo-id'] ) ) { // Remove photo
248
  if ( ! current_user_can( 'wppa_moderate' ) ) {
249
  _e( 'Security check failure' , 'wp-photo-album-plus');
250
+ wppa_exit();
251
  }
252
  wppa_delete_photo( $_REQUEST['photo-id'] );
253
  echo 'OK||'.__( 'Photo removed' , 'wp-photo-album-plus');
254
+ wppa_exit();
255
  }
256
  if ( isset( $_REQUEST['comment-id'] ) ) { // Remove comment
257
  $iret = $wpdb->query( $wpdb->prepare( "DELETE FROM `".WPPA_COMMENTS."` WHERE `id`= %s", $_REQUEST['comment-id'] ) );
258
  if ( $iret ) echo 'OK||'.__( 'Comment removed' , 'wp-photo-album-plus');
259
  else _e( 'Could not remove comment' , 'wp-photo-album-plus');
260
+ wppa_exit();
261
  }
262
  _e( 'Unexpected error' , 'wp-photo-album-plus');
263
+ wppa_exit();
264
 
265
  case 'downloadalbum':
266
  // Feature enabled?
267
  if ( ! wppa_switch( 'wppa_allow_download_album' ) ) {
268
  echo '||ER||'.__( 'This feature is not enabled on this website' , 'wp-photo-album-plus');
269
+ wppa_exit();
270
  }
271
 
272
  // Validate args
278
  $photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `album` = %s AND ( ( ".$status." ) OR owner = %s ) ".wppa_get_photo_order( $alb ), $alb, wppa_get_user() ), ARRAY_A );
279
  if ( ! $photos ) {
280
  echo '||ER||'.__( 'The album is empty' , 'wp-photo-album-plus');
281
+ wppa_exit();
282
  }
283
 
284
  // Remove obsolete files
287
  // Open zipfile
288
  if ( ! class_exists( 'ZipArchive' ) ) {
289
  echo '||ER||'.__( 'Unable to create zip archive' , 'wp-photo-album-plus');
290
+ wppa_exit();
291
  }
292
  $zipfilename = wppa_get_album_name( $alb );
293
  $zipfilename = wppa_sanitize_file_name( $zipfilename.'.zip' ); // Remove illegal chars
299
  $iret = $wppa_zip->open( $zipfilepath, 1 );
300
  if ( $iret !== true ) {
301
  echo '||ER||'.sprintf( __( 'Unable to create zip archive. code = %s' , 'wp-photo-album-plus'), $iret );
302
+ wppa_exit();
303
  }
304
 
305
  // Add photos to zip
321
  // To prevent too may files open, and to have at least a file when there are too many photos, close and re-open
322
  $wppa_zip->close();
323
  $wppa_zip->open( $zipfilepath );
324
+ // wppa_log( 'dbg', 'Added ' . basename($source) . ' to ' . basename($zipfilepath));
325
  }
326
  }
327
  }
336
  $desturl = WPPA_UPLOAD_URL.'/temp/'.$zipfilename;
337
  echo $desturl.'||OK||';
338
  if ( $zipcount != count( $photos ) ) echo sprintf( __( 'Only %s out of %s photos could be added to the zipfile' , 'wp-photo-album-plus'), $zipcount, count( $photos ) );
339
+ wppa_exit();
340
  break;
341
 
342
  case 'getalbumzipurl':
351
  else {
352
  echo 'ER';
353
  }
354
+ wppa_exit();
355
  break;
356
 
357
  case 'makeorigname':
365
  }
366
  else {
367
  echo '||7||'.__( 'Unknown source of request' , 'wp-photo-album-plus');
368
+ wppa_exit();
369
  }
370
 
371
  $data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $photo ), ARRAY_A );
383
  $name = preg_replace( '/\.[^.]*$/', '', $name ); // Remove file extension
384
  if ( strlen( $name ) == '0' ) {
385
  echo '||1||'.__( 'Empty filename' , 'wp-photo-album-plus');
386
+ wppa_exit();
387
  }
388
 
389
  // Make the file
410
  if ( ! is_dir( $tempdir ) ) @ mkdir( $tempdir );
411
  if ( ! is_dir( $tempdir ) ) {
412
  echo '||2||'.__( 'Unable to create tempdir' , 'wp-photo-album-plus');
413
+ wppa_exit();
414
  }
415
 
416
  // Remove obsolete files
424
  elseif ( $type == 'zip' ) {
425
  if ( ! class_exists( 'ZipArchive' ) ) {
426
  echo '||8||'.__( 'Unable to create zip archive' , 'wp-photo-album-plus');
427
+ wppa_exit();
428
  }
429
  $ext = 'zip';
430
  $wppa_zip = new ZipArchive;
434
  }
435
  else {
436
  echo '||6||'.__( 'Unknown type' , 'wp-photo-album-plus');
437
+ wppa_exit();
438
  }
439
 
440
  $desturl = WPPA_UPLOAD_URL.'/temp/'.$name.'.'.$ext;
441
  echo '||0||'.$desturl; // No error: return url
442
+ wppa_exit();
443
  }
444
  else {
445
  echo '||9||'.__( 'The photo does no longer exist' , 'wp-photo-album-plus');
446
+ wppa_exit();
447
  }
448
+ wppa_exit();
449
  break;
450
 
451
  case 'tinymcedialog':
452
  $result = wppa_make_tinymce_dialog();
453
  echo $result;
454
+ wppa_exit();
455
  break;
456
 
457
  case 'bumpviewcount':
462
  else {
463
  _e( 'Security check failure' , 'wp-photo-album-plus');
464
  }
465
+ wppa_exit();
466
  break;
467
 
468
  case 'rate':
483
  // Check on validity
484
  if ( ! wp_verify_nonce( $nonce, 'wppa-check' ) ) {
485
  echo '0||100||'.$errtxt;
486
+ wppa_exit(); // Nonce check failed
487
  }
488
  if ( wppa_opt( 'wppa_rating_max' ) == '1' && $rating != '1' ) {
489
  echo '0||106||'.$errtxt.':'.$rating;
490
+ wppa_exit(); // Value out of range
491
  }
492
  elseif ( wppa_opt( 'wppa_rating_max' ) == '5' && ! in_array( $rating, array( '-1', '1', '2', '3', '4', '5' ) ) ) {
493
  echo '0||106||'.$errtxt.':'.$rating;
494
+ wppa_exit(); // Value out of range
495
  }
496
  elseif ( wppa_opt( 'wppa_rating_max' ) == '10' && ! in_array( $rating, array( '-1', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10' ) ) ) {
497
  echo '0||106||'.$errtxt.':'.$rating;
498
+ wppa_exit(); // Value out of range
499
  }
500
 
501
  // Get other data
502
  if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $photo ) ) ) {
503
  echo '0||999||'.__( 'Photo has been removed.' , 'wp-photo-album-plus');
504
+ wppa_exit();
505
  }
506
  $user = wppa_get_user();
507
  $mylast = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM `'.WPPA_RATING.'` WHERE `photo` = %s AND `user` = %s ORDER BY `id` DESC LIMIT 1', $photo, $user ), ARRAY_A );
510
  // Rate own photo?
511
  if ( wppa_get_photo_item( $photo, 'owner' ) == $user && ! wppa_switch( 'wppa_allow_owner_votes' ) ) {
512
  echo '0||900||'.__( 'Sorry, you can not rate your own photos' , 'wp-photo-album-plus');
513
+ wppa_exit();
514
  }
515
 
516
  // Already a pending one?
522
  if ( $pending ) {
523
  if ( ! $hascommented ) {
524
  echo '0||900||'.__( 'Please enter a comment.' , 'wp-photo-album-plus');
525
+ wppa_exit();
526
  }
527
  else {
528
  $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_RATING."` SET `status` = 'publish' WHERE `photo` = %s AND `user` = %s", $photo, $user ) );
547
  )
548
  ) {
549
  echo '0||109||'.__( 'Security check failure.' , 'wp-photo-album-plus');
550
+ wppa_exit();
551
  }
552
  // Case 1: value = -1 this is a legal dislike vote
553
  if ( $rating == '-1' ) {
555
  $iret = wppa_create_rating_entry( array( 'photo' => $photo, 'value' => $rating, 'user' => $user, 'status' => $ratingstatus ) );
556
  if ( ! $iret ) {
557
  echo '0||101||'.$errtxt;
558
+ wppa_exit(); // Fail on storing vote
559
  }
560
  // Add points
561
  wppa_add_credit_points( wppa_opt( 'wppa_cp_points_rating' ), __( 'Photo rated' , 'wp-photo-album-plus'), $photo, $rating );
562
  wppa_dislike_check( $photo ); // Check for email to be sent every .. dislikes
563
  if ( ! is_file( wppa_get_thumb_path( $photo ) ) ) { // Photo is removed
564
  echo $occur.'||'.$photo.'||'.$index.'||-1||-1|0||'.wppa_opt( 'wppa_dislike_delete' );
565
+ wppa_exit();
566
  }
567
  }
568
  // Case 2: This is my first vote for this photo
571
  $iret = wppa_create_rating_entry( array( 'photo' => $photo, 'value' => $rating, 'user' => $user, 'status' => $ratingstatus ) );
572
  if ( ! $iret ) {
573
  echo '0||102||'.$errtxt;
574
+ wppa_exit(); // Fail on storing vote
575
  }
576
  // Add points
577
  wppa_add_credit_points( wppa_opt( 'wppa_cp_points_rating' ), __( 'Photo rated' , 'wp-photo-album-plus'), $photo, $rating );
581
  $iret = $wpdb->query( $wpdb->prepare( 'UPDATE `'.WPPA_RATING.'` SET `value` = %s WHERE `photo` = %s AND `user` = %s LIMIT 1', $rating, $photo, $user ) );
582
  if ( $iret === false ) {
583
  echo '0||103||'.$errtxt;
584
+ wppa_exit(); // Fail on update
585
  }
586
  }
587
  // Case 4: Add another vote from me
589
  $iret = wppa_create_rating_entry( array( 'photo' => $photo, 'value' => $rating, 'user' => $user, 'status' => $ratingstatus ) );
590
  if ( ! $iret ) {
591
  echo '0||104||'.$errtxt;
592
+ wppa_exit(); // Fail on storing vote
593
  }
594
  }
595
  else { // Should never get here....
596
  echo '0||110||'.__( 'Unexpected error' , 'wp-photo-album-plus');
597
+ wppa_exit();
598
  }
599
 
600
  // Compute my avg rating
643
  $iret = $wpdb->query( $wpdb->prepare( 'UPDATE `'.WPPA_PHOTOS. '` SET `mean_rating` = %s WHERE `id` = %s', $allavgrat, $photo ) );
644
  if ( $iret === false ) {
645
  echo '0||106||'.$wartxt;
646
+ wppa_exit(); // Fail on save
647
  }
648
 
649
  // Compute rating_count and store in the photo info
652
  $iret = $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `rating_count` = %s WHERE `id` = %s", $ratcount, $photo ) );
653
  if ( $iret === false ) {
654
  echo '0||107||'.$wartxt;
655
+ wppa_exit(); // Fail on save
656
  }
657
  }
658
 
663
  $discount = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `".WPPA_RATING."` WHERE `photo` = %s AND `value` = -1 AND `status` = %s", $photo, 'publish' ) );
664
  if ( $discount === false ) {
665
  echo '0||108||'.$wartxt;
666
+ wppa_exit(); // Fail on save
667
  }
668
 
669
  // Test for possible medal
718
  // Check validity
719
  if ( ! wp_verify_nonce( $nonce, 'wppa_nonce_'.$photo ) ) {
720
  echo '||0||'.__( 'You do not have the rights to delete a photo' , 'wp-photo-album-plus');
721
+ wppa_exit(); // Nonce check failed
722
  }
723
  if ( ! is_numeric( $photo ) ) {
724
  echo '||0||'.__( 'Security check failure' , 'wp-photo-album-plus');
725
+ wppa_exit(); // Nonce check failed
726
  }
727
  $album = $wpdb->get_var( $wpdb->prepare( 'SELECT `album` FROM `'.WPPA_PHOTOS.'` WHERE `id` = %s', $photo ) );
728
  wppa_delete_photo( $photo );
744
  // Check validity
745
  if ( ! wp_verify_nonce( $nonce, 'wppa_nonce_'.$album ) ) {
746
  echo '||0||'.__( 'You do not have the rights to update album information' , 'wp-photo-album-plus').$nonce;
747
+ wppa_exit(); // Nonce check failed
748
  }
749
 
750
  switch ( $item ) {
763
  else {
764
  echo '||97||'.__( '<b>No photos in this album</b>' , 'wp-photo-album-plus').'||'.__( 'No ratings for this photo.' , 'wp-photo-album-plus');
765
  }
766
+ wppa_exit();
767
  break;
768
  case 'set_deftags': // to be changed for large albums
769
  $photos = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM `'.WPPA_PHOTOS.'` WHERE `album` = %s', $album ), ARRAY_A );
785
  echo '||97||'.__( '<b>No photos in this album</b>' , 'wp-photo-album-plus');
786
  }
787
  wppa_clear_taglist();
788
+ wppa_exit();
789
  break;
790
  case 'add_deftags':
791
  $photos = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM `'.WPPA_PHOTOS.'` WHERE `album` = %s', $album ), ARRAY_A );
807
  echo '||97||'.__( '<b>No photos in this album</b>' , 'wp-photo-album-plus');
808
  }
809
  wppa_clear_taglist();
810
+ wppa_exit();
811
  break;
812
  case 'name':
813
  $value = trim( strip_tags( $value ) );
823
  $value = str_replace( array( '<br/>','<br>' ), '<br />', $value );
824
  if ( balanceTags( $value, true ) != $value ) {
825
  echo '||3||'.__( 'Unbalanced tags in album description!' , 'wp-photo-album-plus');
826
+ wppa_exit();
827
  }
828
  }
829
  $value = trim( $value );
858
  $itemname = __( 'Owner' , 'wp-photo-album-plus');
859
  if ( $value != '--- public ---' && ! get_user_by( 'login', $value ) ) {
860
  echo '||4||'.sprintf( __( 'User %s does not exist' , 'wp-photo-album-plus'), $value );
861
+ wppa_exit();
862
  }
863
  break;
864
  case 'upload_limit_count':
865
  wppa_ajax_check_range( $value, false, '0', false, __( 'Upload limit count' , 'wp-photo-album-plus') );
866
+ if ( wppa( 'error' ) ) wppa_exit();
867
  $oldval = $wpdb->get_var( $wpdb->prepare( 'SELECT `upload_limit` FROM '.WPPA_ALBUMS.' WHERE `id` = %s', $album ) );
868
  $temp = explode( '/', $oldval );
869
  $value = $value.'/'.$temp[1];
909
  $scheduledtm = implode( ',', $temp );
910
  wppa_update_album( array( 'id' => $album, 'scheduledtm' => $scheduledtm ) );
911
  echo '||0||'.sprintf( __( '<b>%s</b> of album %s updated' , 'wp-photo-album-plus'), $itemname, $album );
912
+ wppa_exit();
913
  break;
914
 
915
  case 'setallscheduled':
918
  $iret = $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_PHOTOS."` SET `status` = 'scheduled', `scheduledtm` = %s WHERE `album` = %s", $scheduledtm, $album ) );
919
  echo '||0||'.__( 'All photos set to scheduled per date' , 'wp-photo-album-plus').' ( '.$iret.' ) '.wppa_format_scheduledtm( $scheduledtm );
920
  }
921
+ wppa_exit();
922
  break;
923
 
924
  default:
947
  echo '<br>'.__( 'Press CTRL+F5 and try again.' , 'wp-photo-album-plus');
948
  }
949
  wppa_clear_cache();
950
+ wppa_exit();
951
  break;
952
 
953
  case 'update-comment-status':
959
  // Check validity
960
  if ( ! wp_verify_nonce( $nonce, 'wppa_nonce_'.$photo ) ) {
961
  echo '||0||'.__( 'You do not have the rights to update comment status' , 'wp-photo-album-plus').$nonce;
962
+ wppa_exit(); // Nonce check failed
963
  }
964
 
965
  // if ( wppa_switch( 'wppa_search_comments' ) ) wppa_index_remove( 'photo', $photo );
972
  else {
973
  echo '||1||'.sprintf( __( 'Error updating status comment #%s' , 'wp-photo-album-plus'), $comid );
974
  }
975
+ wppa_exit();
976
  break;
977
 
978
  case 'watermark-photo':
982
  // Check validity
983
  if ( ! wp_verify_nonce( $nonce, 'wppa_nonce_'.$photo ) ) {
984
  echo '||1||'.__( 'You do not have the rights to change photos' , 'wp-photo-album-plus');
985
+ wppa_exit(); // Nonce check failed
986
  }
987
 
988
  wppa_cache_thumb( $photo );
991
  wppa_create_thumbnail( $photo ); // create new thumb
992
  }
993
  echo '||0||'.__( 'Watermark applied' , 'wp-photo-album-plus');
994
+ wppa_exit();
995
  }
996
  else {
997
  echo '||1||'.__( 'An error occured while trying to apply a watermark' , 'wp-photo-album-plus');
998
+ wppa_exit();
999
  }
1000
 
1001
  case 'update-photo':
1008
  // Check validity
1009
  if ( ! wp_verify_nonce( $nonce, 'wppa_nonce_'.$photo ) ) {
1010
  echo '||0||'.__( 'You do not have the rights to update photo information' , 'wp-photo-album-plus');
1011
+ wppa_exit(); // Nonce check failed
1012
  }
1013
 
1014
  if ( substr( $item, 0, 20 ) == 'wppa_watermark_file_' || substr( $item, 0, 19 ) == 'wppa_watermark_pos_' ) {
1015
  wppa_update_option( $item, $value );
1016
  echo '||0||'.sprintf( __( '%s updated to %s.' , 'wp-photo-album-plus'), $item, $value );
1017
+ wppa_exit();
1018
  }
1019
 
1020
  switch ( $item ) {
1069
  wppa_update_photo( array( 'id' => $photo, 'exifdtm' => $value ) );
1070
  echo '||0||'.__( 'Exif date/time updated' , 'wp-photo-album-plus');
1071
  }
1072
+ wppa_exit();
1073
  break;
1074
  case 'lat':
1075
  if ( ! is_numeric( $value ) || $value < '-90.0' || $value > '90.0' ) {
1076
  echo '||1||'.__( 'Enter a value > -90 and < 90' , 'wp-photo-album-plus');
1077
+ wppa_exit();
1078
  }
1079
  $photodata = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM '.WPPA_PHOTOS.' WHERE `id` = %s', $photo ), ARRAY_A );
1080
  $geo = $photodata['location'] ? $photodata['location'] : '///';
1085
  else {
1086
  echo '||1||'.__( 'Could not update lattitude' , 'wp-photo-album-plus');
1087
  }
1088
+ wppa_exit();
1089
  break;
1090
  case 'lon':
1091
  if ( ! is_numeric( $value ) || $value < '-180.0' || $value > '180.0' ) {
1092
  echo '||1||'.__( 'Enter a value > -180 and < 180' , 'wp-photo-album-plus');
1093
+ wppa_exit();
1094
  }
1095
  $photodata = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM '.WPPA_PHOTOS.' WHERE `id` = %s', $photo ), ARRAY_A );
1096
  $geo = $photodata['location'] ? $photodata['location'] : '///';
1101
  else {
1102
  echo '||1||'.__( 'Could not update longitude' , 'wp-photo-album-plus');
1103
  }
1104
+ wppa_exit();
1105
  break;
1106
  case 'remake':
1107
  if ( wppa_remake_files( '', $photo ) ) {
1112
  else {
1113
  echo '||2||'.__( 'Could not remake files' , 'wp-photo-album-plus');
1114
  }
1115
+ wppa_exit();
1116
  break;
1117
  case 'remakethumb':
1118
  if ( wppa_create_thumbnail( $photo ) ) {
1121
  else {
1122
  echo '||0||'.__( 'Could not remake thumbnail' , 'wp-photo-album-plus');
1123
  }
1124
+ wppa_exit();
1125
  break;
1126
  case 'rotright':
1127
  case 'rot180':
1150
  else {
1151
  echo '||'.wppa( 'error' ).'||'.sprintf( __( 'An error occurred while trying to rotate photo %s' , 'wp-photo-album-plus'), $photo );
1152
  }
1153
+ wppa_exit();
1154
  break;
1155
 
1156
  case 'moveto':
1159
  $exists = wppa_file_is_in_album( $photodata['filename'], $value );
1160
  if ( $exists ) { // Already exists
1161
  echo '||3||' . sprintf ( __( 'A photo with filename %s already exists in album %s.' , 'wp-photo-album-plus'), $photodata['filename'], $value );
1162
+ wppa_exit();
1163
  break;
1164
  }
1165
  }
1173
  else {
1174
  echo '||3||'.sprintf( __( 'An error occurred while trying to move photo %s' , 'wp-photo-album-plus'), $photo );
1175
  }
1176
+ wppa_exit();
1177
  break;
1178
 
1179
  case 'copyto':
1182
  $exists = wppa_file_is_in_album( $photodata['filename'], $value );
1183
  if ( $exists ) { // Already exists
1184
  echo '||4||' . sprintf ( __( 'A photo with filename %s already exists in album %s.' , 'wp-photo-album-plus'), $photodata['filename'], $value );
1185
+ wppa_exit();
1186
  break;
1187
  }
1188
  }
1195
  echo '||4||'.sprintf( __( 'An error occurred while trying to copy photo %s' , 'wp-photo-album-plus'), $photo );
1196
  echo '<br>'.__( 'Press CTRL+F5 and try again.' , 'wp-photo-album-plus');
1197
  }
1198
+ wppa_exit();
1199
  break;
1200
 
1201
  case 'status':
1223
  $value = str_replace( array( '<br/>','<br>' ), '<br />', $value );
1224
  if ( balanceTags( $value, true ) != $value ) {
1225
  echo '||3||'.__( 'Unbalanced tags in photo description!' , 'wp-photo-album-plus');
1226
+ wppa_exit();
1227
  }
1228
  }
1229
  break;
1234
  $usr = get_user_by( 'login', $value );
1235
  if ( ! $usr ) {
1236
  echo '||4||' . sprintf( __( 'User %s does not exists' , 'wp-photo-album-plus'), $value );
1237
+ wppa_exit();
1238
  }
1239
  $value = $usr->user_login; // Correct possible case mismatch
1240
  wppa_flush_upldr_cache( 'photoid', $photo ); // Current owner
1269
  $itemname = __( 'Video width' , 'wp-photo-album-plus');
1270
  if ( ! wppa_is_int( $value ) || $value < '0' ) {
1271
  echo '||3||'.__( 'Please enter an integer value >= 0' , 'wp-photo-album-plus');
1272
+ wppa_exit();
1273
  }
1274
  break;
1275
  case 'videoy':
1276
  $itemname = __( 'Video height', 'wp-photo-album-plus');
1277
  if ( ! wppa_is_int( $value ) || $value < '0' ) {
1278
  echo '||3||'.__( 'Please enter an integer value >= 0' , 'wp-photo-album-plus');
1279
+ wppa_exit();
1280
  }
1281
  break;
1282
 
1300
  else {
1301
  echo '||2||'.sprintf( __( 'An error occurred while trying to update <b>%s</b> of photo %s' , 'wp-photo-album-plus'), $itemname, $photo );
1302
  echo '<br>'.__( 'Press CTRL+F5 and try again.' , 'wp-photo-album-plus');
1303
+ wppa_exit();
1304
  }
1305
  break;
1306
 
1362
  // Check on upload error
1363
  if ( $_FILES['photo']['error'] ) {
1364
  echo '||'.$_FILES['photo']['error'].'||'.__( '<b>Error during upload.</b>', 'wp-photo-album-plus');
1365
+ wppa_exit();
1366
  }
1367
 
1368
  // Save new source
1393
  // Report fail
1394
  echo '||1||'.__( 'Could not update files.' , 'wp-photo-album-plus');
1395
  }
1396
+ wppa_exit();
1397
  break;
1398
 
1399
  case 'stereo':
1403
  wppa_create_thumbnail( $photo );
1404
  $t = microtime(true) - $t;
1405
  echo '||0||' . sprintf( __( 'Stereo mode updated in %d milliseconds', 'wp-photo-album-plus'), floor( $t * 1000 ) );
1406
+ wppa_exit();
1407
  break;
1408
 
1409
  default:
1410
  echo '||98||This update action is not implemented yet( '.$item.' )';
1411
+ wppa_exit();
1412
  }
1413
  wppa_clear_cache();
1414
  break;
1419
  $nonce = $_REQUEST['wppa-nonce'];
1420
  if ( ! wp_verify_nonce( $nonce, 'wppa-nonce' ) ) {
1421
  echo '||1||'.__( 'You do not have the rights to update settings' , 'wp-photo-album-plus');
1422
+ wppa_exit(); // Nonce check failed
1423
  }
1424
 
1425
  // Initialize
1449
  $output = '||1||Failed to update '.$tag.'||';
1450
  }
1451
  echo $output;
1452
+ wppa_exit();
1453
  }
1454
  elseif ( substr( $option, 0, 17 ) == 'wppa_iptc_status_' ) {
1455
  $tag = substr( $option, 17 );
1463
  $output = '||1||Failed to update '.$tag.'||';
1464
  }
1465
  echo $output;
1466
+ wppa_exit();
1467
  }
1468
  elseif ( substr( $option, 0, 16 ) == 'wppa_exif_label_' ) {
1469
  $tag = substr( $option, 16 );
1477
  $output = '||1||Failed to update '.$tag.'||';
1478
  }
1479
  echo $output;
1480
+ wppa_exit();
1481
  }
1482
  elseif ( substr( $option, 0, 17 ) == 'wppa_exif_status_' ) {
1483
  $tag = substr( $option, 17 );
1491
  $output = '||1||Failed to update '.$tag.'||';
1492
  }
1493
  echo $output;
1494
+ wppa_exit();
1495
  }
1496
  elseif ( substr( $option, 0, 5 ) == 'caps-' ) { // Is capability setting
1497
  global $wp_roles;
1500
  if ( $value == 'yes' ) {
1501
  $wp_roles->add_cap( $setting[2], $setting[1] );
1502
  echo '||0||'.__( 'Capability granted' , 'wp-photo-album-plus').'||';
1503
+ wppa_exit();
1504
  }
1505
  elseif ( $value == 'no' ) {
1506
  $wp_roles->remove_cap( $setting[2], $setting[1] );
1507
  echo '||0||'.__( 'Capability withdrawn' , 'wp-photo-album-plus').'||';
1508
+ wppa_exit();
1509
  }
1510
  else {
1511
  echo '||1||Invalid value: '.$value.'||';
1512
+ wppa_exit();
1513
  }
1514
  }
1515
  else switch ( $option ) {
1722
  case 'wppa_recup':
1723
  $result = wppa_recuperate_iptc_exif();
1724
  echo '||0||'.__( 'Recuperation performed' , 'wp-photo-album-plus').'||'.$result;
1725
+ wppa_exit();
1726
  break;
1727
 
1728
  case 'wppa_bgcolor_thumbnail':
2139
 
2140
  echo $output;
2141
  wppa_clear_cache();
2142
+ wppa_exit();
2143
  break; // End update-option
2144
 
2145
  case 'maintenance':
2147
  $nonce = $_REQUEST['wppa-nonce'];
2148
  if ( ! wp_verify_nonce( $nonce, 'wppa-nonce' ) ) {
2149
  echo 'Security check failure||'.$slug.'||Error||0';
2150
+ wppa_exit();
2151
  }
2152
  echo wppa_do_maintenance_proc( $slug );
2153
+ wppa_exit();
2154
  break;
2155
 
2156
  case 'maintenancepopup':
2158
  $nonce = $_REQUEST['wppa-nonce'];
2159
  if ( ! wp_verify_nonce( $nonce, 'wppa-nonce' ) ) {
2160
  echo 'Security check failure||'.$slug.'||Error||0';
2161
+ wppa_exit();
2162
  }
2163
  echo wppa_do_maintenance_popup( $slug );
2164
+ wppa_exit();
2165
  break;
2166
 
2167
  case 'do-fe-upload':
2170
  }
2171
  wppa_user_upload();
2172
  echo wppa( 'out' );
2173
+ wppa_exit();
2174
  break;
2175
 
2176
  case 'sanitizetags':
2179
  $deftags = $album ? wppa_get_album_item( $album, 'default_tags' ) : '';
2180
  $tags = $deftags ? $tags . ',' . $deftags : $tags;
2181
  echo wppa_sanitize_tags( $tags, false, true );
2182
+ wppa_exit();
2183
  break;
2184
 
2185
  case 'destroyalbum':
2186
  $album = isset( $_GET['album'] ) ? $_GET['album'] : '0';
2187
  if ( ! $album ) {
2188
  _e('Missing album id', 'wp-photo-album-plus');
2189
+ wppa_exit();
2190
  }
2191
  $nonce = isset( $_GET['nonce'] ) ? $_GET['nonce'] : '';
2192
  if ( ! $nonce || ! wp_verify_nonce( $nonce, 'wppa_nonce_'.$album ) ) {
2193
  echo 'Security check failure #798';
2194
+ wppa_exit();
2195
  }
2196
 
2197
  // May I?
2206
  if ( wppa_is_user_blacklisted() ) $may = false;
2207
  if ( ! $imay ) {
2208
  _e('You do not have the rights to delete this album', 'wp-photo-album-plus');
2209
+ wppa_exit();
2210
  }
2211
 
2212
  // I may
2213
  require_once 'wppa-album-admin-autosave.php';
2214
  wppa_del_album( $album, '' );
2215
+ wppa_exit();
2216
  break;
2217
 
2218
 
2219
  default: // Unimplemented $wppa-action
2220
  die( '-1' );
2221
  }
2222
+ wppa_exit();
2223
  }
2224
 
2225
  function wppa_decode( $string ) {
2234
  }
2235
 
2236
  function wppa_ajax_check_range( $value, $fixed, $low, $high, $title ) {
2237
+
2238
  if ( $fixed !== false && $fixed == $value ) return; // User enetred special value correctly
2239
  if ( !is_numeric( $value ) ) wppa( 'error', true ); // Must be numeric if not specaial value
2240
  if ( $low !== false && $value < $low ) wppa( 'error', true ); // Must be >= given min value
2241
  if ( $high !== false && $value > $high ) wppa( 'error' , true ); // Must be <= given max value
2242
 
2243
+ if ( wppa( 'error' ) ) return; // Still no error, ok
2244
 
2245
  // Compose error message
2246
  if ( $low !== false && $high === false ) { // Only Minimum given
wppa-audio.php CHANGED
@@ -3,10 +3,10 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all audio routines
6
- * Version 6.3.0
7
  *
8
  */
9
-
10
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
11
 
12
  // Audio files support. Define supported filetypes.
@@ -20,10 +20,10 @@ function wppa_has_audio( $id ) {
20
  global $wppa_supported_audio_extensions;
21
 
22
  if ( ! $id ) return false; // No id
23
-
24
- $ext = wppa_get_photo_item( $id, 'ext' );
25
  if ( $ext != 'xxx' ) return false; // This is not a audio
26
-
27
  $result = array();
28
  $path = wppa_get_photo_path( $id );
29
  $raw_path = wppa_strip_ext( $path );
@@ -35,19 +35,18 @@ global $wppa_supported_audio_extensions;
35
  if ( empty( $result ) ) {
36
  return false; // Its multimedia but not audio
37
  }
38
-
39
  return $result;
40
  }
41
 
42
  // Return the html for audio display
43
  function wppa_get_audio_html( $args ) {
44
- global $wppa;
45
 
46
  // Audio enabled?
47
  if ( ! wppa_switch( 'enable_audio' ) ) {
48
  return '';
49
  }
50
-
51
  extract( wp_parse_args( (array) $args, array (
52
  'id' => '0',
53
  'width' => '0',
@@ -55,7 +54,7 @@ global $wppa;
55
  'controls' => true,
56
  'margin_top' => '0',
57
  'margin_bottom' => '0',
58
- 'tagid' => 'audio-'.$wppa['mocc'],
59
  'cursor' => '',
60
  'events' => '',
61
  'title' => '',
@@ -67,13 +66,13 @@ global $wppa;
67
  'use_thumb' => false,
68
  'autoplay' => false
69
  ) ) );
70
-
71
  // No id? no go
72
  if ( ! $id ) return '';
73
-
74
  // Not a audio? no go
75
  if ( ! wppa_has_audio( $id ) ) return '';
76
-
77
  extract( wp_parse_args( (array) wppa_has_audio( $id ), array (
78
  'mp3' => false,
79
  'wav' => false,
@@ -94,7 +93,7 @@ global $wppa;
94
 
95
  // Do we have html5 audio tag supported filetypes on board?
96
  if ( $mp3 || $wav || $ogg ) {
97
-
98
  // Assume the browser supports html5
99
  $result = '<audio' .
100
  ' id="'.$tagid.'"' .
@@ -125,31 +124,31 @@ function wppa_get_audio_body( $id, $for_lb = false, $w = '0', $h = '0' ) {
125
  }
126
 
127
  $is_audio = wppa_has_audio( $id, true );
128
-
129
  // Not a audio? no go
130
  if ( ! $is_audio ) return '';
131
-
132
  // See what file types are present
133
  extract( wp_parse_args( $is_audio, array( 'mp3' => false,
134
  'wav' => false,
135
  'ogg' => false
136
- )
137
- )
138
  );
139
-
140
  // Collect other data
141
  $width = $w ? $w : wppa_get_photox( $id );
142
  $height = $h ? $h : wppa_get_photoy( $id );
143
  $source = wppa_get_photo_url( $id );
144
  $source = substr( $source, 0, strrpos( $source, '.' ) );
145
  $class = $for_lb ? ' class="wppa-overlay-img"' : '';
146
-
147
  $is_opera = strpos( $_SERVER["HTTP_USER_AGENT"], 'OPR' );
148
  $is_ie = strpos( $_SERVER["HTTP_USER_AGENT"], 'Trident' );
149
  $is_safari = strpos( $_SERVER["HTTP_USER_AGENT"], 'Safari' );
150
-
151
- wppa_dbg_msg('Mp3:'.$mp3.', Opera:'.$is_opera.', Ie:'.$is_ie.', Saf:'.$is_safari);
152
-
153
  // Assume the browser supports html5
154
  $ext = '';
155
  if ( $is_ie ) {
@@ -176,13 +175,13 @@ function wppa_get_audio_body( $id, $for_lb = false, $w = '0', $h = '0' ) {
176
  $ext = 'ogg';
177
  }
178
  }
179
-
180
  if ( $ext ) {
181
  $mime = str_replace( 'mp3', 'mpeg', 'audio/'.$ext );
182
  $result = '<source src="'.$source.'.'.$ext.'" type="'.$mime.'">';
183
  }
184
  $result .= __('There is no filetype available for your browser, or your browser does not support html5 audio', 'wp-photo-album-plus');
185
-
186
  return $result;
187
  }
188
 
@@ -198,29 +197,29 @@ global $wppa_supported_audio_extensions;
198
  $raw_from_path = wppa_strip_ext( $from_path );
199
  $to_path = wppa_get_photo_path( $toid );
200
  $raw_to_path = wppa_strip_ext( $to_path );
201
-
202
  // Copy the media files
203
  foreach ( $wppa_supported_audio_extensions as $ext ) {
204
  $file = $raw_from_path . '.' . $ext;
205
  if ( is_file( $file ) ) {
206
  if ( ! copy( $file, $raw_to_path . '.' . $ext ) ) return false;
207
- }
208
  }
209
-
210
  /*
211
  // Copy the poster file
212
  $poster = wppa_fix_poster_ext( $from_path, $fromid );
213
  if ( is_file( $poster ) ) {
214
  if ( ! copy( $poster, $raw_to_path . '.' . wppa_get_ext( $from_path ) ) ) return false;
215
  }
216
-
217
  // Copy the poster thumb
218
  $poster_thumb = wppa_fix_poster_ext( wppa_get_thumb_path( $fromid ) );
219
  $poster_thumb_to = wppa_strip_ext( wppa_get_thumb_path( $toid ) ) . '.' . wppa_get_ext( $poster_thumb );
220
  if ( is_file( $poster_thumb ) ) {
221
  if ( ! copy( $poster_thumb, $poster_thumb_to ) ) return false;
222
  }
223
- */
224
  // Done!
225
  return true;
226
  }
@@ -233,6 +232,6 @@ function wppa_get_audio_control_height() {
233
  else {
234
  $result = '28';
235
  }
236
-
237
  return $result;
238
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all audio routines
6
+ * Version 6.3.9
7
  *
8
  */
9
+
10
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
11
 
12
  // Audio files support. Define supported filetypes.
20
  global $wppa_supported_audio_extensions;
21
 
22
  if ( ! $id ) return false; // No id
23
+
24
+ $ext = wppa_get_photo_item( $id, 'ext' );
25
  if ( $ext != 'xxx' ) return false; // This is not a audio
26
+
27
  $result = array();
28
  $path = wppa_get_photo_path( $id );
29
  $raw_path = wppa_strip_ext( $path );
35
  if ( empty( $result ) ) {
36
  return false; // Its multimedia but not audio
37
  }
38
+
39
  return $result;
40
  }
41
 
42
  // Return the html for audio display
43
  function wppa_get_audio_html( $args ) {
 
44
 
45
  // Audio enabled?
46
  if ( ! wppa_switch( 'enable_audio' ) ) {
47
  return '';
48
  }
49
+
50
  extract( wp_parse_args( (array) $args, array (
51
  'id' => '0',
52
  'width' => '0',
54
  'controls' => true,
55
  'margin_top' => '0',
56
  'margin_bottom' => '0',
57
+ 'tagid' => 'audio-' . wppa ( 'mocc' ),
58
  'cursor' => '',
59
  'events' => '',
60
  'title' => '',
66
  'use_thumb' => false,
67
  'autoplay' => false
68
  ) ) );
69
+
70
  // No id? no go
71
  if ( ! $id ) return '';
72
+
73
  // Not a audio? no go
74
  if ( ! wppa_has_audio( $id ) ) return '';
75
+
76
  extract( wp_parse_args( (array) wppa_has_audio( $id ), array (
77
  'mp3' => false,
78
  'wav' => false,
93
 
94
  // Do we have html5 audio tag supported filetypes on board?
95
  if ( $mp3 || $wav || $ogg ) {
96
+
97
  // Assume the browser supports html5
98
  $result = '<audio' .
99
  ' id="'.$tagid.'"' .
124
  }
125
 
126
  $is_audio = wppa_has_audio( $id, true );
127
+
128
  // Not a audio? no go
129
  if ( ! $is_audio ) return '';
130
+
131
  // See what file types are present
132
  extract( wp_parse_args( $is_audio, array( 'mp3' => false,
133
  'wav' => false,
134
  'ogg' => false
135
+ )
136
+ )
137
  );
138
+
139
  // Collect other data
140
  $width = $w ? $w : wppa_get_photox( $id );
141
  $height = $h ? $h : wppa_get_photoy( $id );
142
  $source = wppa_get_photo_url( $id );
143
  $source = substr( $source, 0, strrpos( $source, '.' ) );
144
  $class = $for_lb ? ' class="wppa-overlay-img"' : '';
145
+
146
  $is_opera = strpos( $_SERVER["HTTP_USER_AGENT"], 'OPR' );
147
  $is_ie = strpos( $_SERVER["HTTP_USER_AGENT"], 'Trident' );
148
  $is_safari = strpos( $_SERVER["HTTP_USER_AGENT"], 'Safari' );
149
+
150
+ wppa_dbg_msg('Mp3:'.$mp3.', Opera:'.$is_opera.', Ie:'.$is_ie.', Saf:'.$is_safari);
151
+
152
  // Assume the browser supports html5
153
  $ext = '';
154
  if ( $is_ie ) {
175
  $ext = 'ogg';
176
  }
177
  }
178
+
179
  if ( $ext ) {
180
  $mime = str_replace( 'mp3', 'mpeg', 'audio/'.$ext );
181
  $result = '<source src="'.$source.'.'.$ext.'" type="'.$mime.'">';
182
  }
183
  $result .= __('There is no filetype available for your browser, or your browser does not support html5 audio', 'wp-photo-album-plus');
184
+
185
  return $result;
186
  }
187
 
197
  $raw_from_path = wppa_strip_ext( $from_path );
198
  $to_path = wppa_get_photo_path( $toid );
199
  $raw_to_path = wppa_strip_ext( $to_path );
200
+
201
  // Copy the media files
202
  foreach ( $wppa_supported_audio_extensions as $ext ) {
203
  $file = $raw_from_path . '.' . $ext;
204
  if ( is_file( $file ) ) {
205
  if ( ! copy( $file, $raw_to_path . '.' . $ext ) ) return false;
206
+ }
207
  }
208
+
209
  /*
210
  // Copy the poster file
211
  $poster = wppa_fix_poster_ext( $from_path, $fromid );
212
  if ( is_file( $poster ) ) {
213
  if ( ! copy( $poster, $raw_to_path . '.' . wppa_get_ext( $from_path ) ) ) return false;
214
  }
215
+
216
  // Copy the poster thumb
217
  $poster_thumb = wppa_fix_poster_ext( wppa_get_thumb_path( $fromid ) );
218
  $poster_thumb_to = wppa_strip_ext( wppa_get_thumb_path( $toid ) ) . '.' . wppa_get_ext( $poster_thumb );
219
  if ( is_file( $poster_thumb ) ) {
220
  if ( ! copy( $poster_thumb, $poster_thumb_to ) ) return false;
221
  }
222
+ */
223
  // Done!
224
  return true;
225
  }
232
  else {
233
  $result = '28';
234
  }
235
+
236
  return $result;
237
  }
wppa-boxes-html.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various wppa boxes
6
- * Version 6.3.8
7
  *
8
  *
9
  */
@@ -43,8 +43,8 @@ function wppa_thumb_area( $action ) {
43
  '"' .
44
  ' >';
45
 
46
- if ( wppa( 'current_album' ) ) {
47
- wppa_bump_viewcount( 'album', wppa( 'current_album') );
48
  }
49
  }
50
 
@@ -127,19 +127,18 @@ function wppa_get_search_html( $label = '', $sub = false, $rt = false ) {
127
  global $wppa_session;
128
 
129
  $wppa_session['has_searchbox'] = true;
 
130
 
131
  $page = wppa_get_the_landing_page( 'wppa_search_linkpage',
132
  __( 'Photo search results' ,
133
  'wp-photo-album-plus' )
134
  );
135
  $pagelink = wppa_dbg_url( get_page_link( $page ) );
136
- $cansubsearch = $sub &&
137
- isset ( $wppa_session['use_searchstring'] ) &&
138
- $wppa_session['use_searchstring'];
139
  // $subboxset = '';
140
  // $rootboxset =
141
  $value = $cansubsearch ? '' : wppa_test_for_search( true );
142
- $root = isset( $wppa_session['search_root'] ) ? $wppa_session['search_root'] : '';
143
  $rootboxset = $root ? '' : 'checked="checked" disabled="disabled"';
144
  $fontsize = wppa_in_widget() ? 'font-size: 9px;' : '';
145
  $mocc = wppa( 'mocc' );
@@ -204,7 +203,7 @@ global $wppa_session;
204
  '</div>' : '' ) .
205
  '</div>' .
206
  '</form>';
207
- //$result .= serialize($wppa_session);
208
  return $result;
209
  }
210
 
@@ -250,9 +249,7 @@ global $wppa_session;
250
  $ownerlist = $wpdb->get_results( $query, ARRAY_A );
251
  $catlist = wppa_get_catlist();
252
  $taglist = wppa_get_taglist();
253
- $ss_data = isset( $wppa_session['supersearch'] ) ?
254
- explode( ',', $wppa_session['supersearch'] ) :
255
- array( '', '', '', '' );
256
  if ( count( $ss_data ) < '4' ) {
257
  $ss_data = array( '', '', '', '' );
258
  }
@@ -802,12 +799,6 @@ global $wppa_session;
802
  );
803
  $url = get_permalink( $page );
804
 
805
- if ( ! isset ( $wppa_session ) ) $wppa_session = array();
806
- if ( ! isset ( $wppa_session['superview'] ) ) {
807
- $wppa_session['superview'] = 'thumbs';
808
- $wppa_session['superalbum'] = '0';
809
- }
810
-
811
  $checked = 'checked="checked"';
812
 
813
  $result = '
@@ -2290,8 +2281,9 @@ function wppa_user_albumedit_html( $alb, $width, $where = '', $mcr = false ) {
2290
  $album = wppa_cache_album( $alb );
2291
 
2292
  if ( ! wppa_switch( 'user_album_edit_on' ) ) return; // Feature not enabled
2293
- if ( ! $alb ) return; // No album given
2294
- if ( ! wppa_have_access( $alb ) ) return; // No rights
 
2295
  if ( $album['owner'] == '--- public ---' && ! current_user_can( 'wppa_admin' ) ) return; // Public albums are not publicly editable
2296
 
2297
  $t = $mcr ? 'mcr-' : '';
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various wppa boxes
6
+ * Version 6.3.9
7
  *
8
  *
9
  */
43
  '"' .
44
  ' >';
45
 
46
+ if ( wppa_is_int( wppa( 'start_album' ) ) ) {
47
+ wppa_bump_viewcount( 'album', wppa( 'start_album') );
48
  }
49
  }
50
 
127
  global $wppa_session;
128
 
129
  $wppa_session['has_searchbox'] = true;
130
+ wppa_save_session();
131
 
132
  $page = wppa_get_the_landing_page( 'wppa_search_linkpage',
133
  __( 'Photo search results' ,
134
  'wp-photo-album-plus' )
135
  );
136
  $pagelink = wppa_dbg_url( get_page_link( $page ) );
137
+ $cansubsearch = $sub && $wppa_session['use_searchstring'];
 
 
138
  // $subboxset = '';
139
  // $rootboxset =
140
  $value = $cansubsearch ? '' : wppa_test_for_search( true );
141
+ $root = $wppa_session['search_root'];
142
  $rootboxset = $root ? '' : 'checked="checked" disabled="disabled"';
143
  $fontsize = wppa_in_widget() ? 'font-size: 9px;' : '';
144
  $mocc = wppa( 'mocc' );
203
  '</div>' : '' ) .
204
  '</div>' .
205
  '</form>';
206
+
207
  return $result;
208
  }
209
 
249
  $ownerlist = $wpdb->get_results( $query, ARRAY_A );
250
  $catlist = wppa_get_catlist();
251
  $taglist = wppa_get_taglist();
252
+ $ss_data = explode( ',', $wppa_session['supersearch'] );
 
 
253
  if ( count( $ss_data ) < '4' ) {
254
  $ss_data = array( '', '', '', '' );
255
  }
799
  );
800
  $url = get_permalink( $page );
801
 
 
 
 
 
 
 
802
  $checked = 'checked="checked"';
803
 
804
  $result = '
2281
  $album = wppa_cache_album( $alb );
2282
 
2283
  if ( ! wppa_switch( 'user_album_edit_on' ) ) return; // Feature not enabled
2284
+ if ( ! $alb ) return; // No album given
2285
+ if ( ! wppa_have_access( $alb ) ) return; // No rights
2286
+ if ( ! is_user_logged_in() ) return; // Must login
2287
  if ( $album['owner'] == '--- public ---' && ! current_user_can( 'wppa_admin' ) ) return; // Public albums are not publicly editable
2288
 
2289
  $t = $mcr ? 'mcr-' : '';
wppa-breadcrumb.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for breadcrumbs
6
- * Version 6.3.8
7
  *
8
  */
9
 
@@ -120,10 +120,10 @@ global $wppa_session;
120
  wppa_bcitem( $value, $href, $title, 'b3' );
121
  }
122
 
123
- // The album ( grant )parents if not separate
124
- if ( ! $separate ) {
125
  wppa_crumb_ancestors( $alb, $to_cover );
126
- }
127
 
128
  // The album and optionall placeholder for photo
129
 
@@ -192,20 +192,18 @@ global $wppa_session;
192
  // Search ?
193
  elseif ( wppa( 'src' ) && ! wppa( 'is_related' ) ) {
194
 
195
- if ( isset( $wppa_session['search_root'] ) ) {
196
- $searchroot = $wppa_session['search_root'];
197
- }
198
- else {
199
- $searchroot = '-2';
200
  }
201
  $albtxt = wppa( 'is_rootsearch' ) ?
202
  ' <span style="cursor:pointer;" title="'.
203
  esc_attr( sprintf( __( 'Searchresults from album %s and its subalbums' , 'wp-photo-album-plus'),
204
- wppa_get_album_name( $searchroot ) ) ).'">*</span> ' :
205
  '';
206
  if ( wppa( 'is_slide' ) ) {
207
  $value = __( 'Searchstring:' , 'wp-photo-album-plus') . ' ' . ( isset ( $wppa_session['display_searchstring'] ) ? $wppa_session['display_searchstring'] : stripslashes( wppa( 'searchstring' ) ) ) . $albtxt;
208
- $thumbhref = wppa_get_permalink().'wppa-cover=0&amp;wppa-occur='.wppa( 'occur' ).'&amp;wppa-searchstring='.stripslashes( wppa( 'searchstring' ) );
209
  $title = __( 'View the thumbnails' , 'wp-photo-album-plus');
210
  wppa_bcitem( $value, $thumbhref, $title, 'b8' );
211
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * Functions for breadcrumbs
6
+ * Version 6.3.9
7
  *
8
  */
9
 
120
  wppa_bcitem( $value, $href, $title, 'b3' );
121
  }
122
 
123
+ // The album ( grand ) parents if not separate
124
+ // if ( ! $separate ) {
125
  wppa_crumb_ancestors( $alb, $to_cover );
126
+ // }
127
 
128
  // The album and optionall placeholder for photo
129
 
192
  // Search ?
193
  elseif ( wppa( 'src' ) && ! wppa( 'is_related' ) ) {
194
 
195
+ $searchroot = $wppa_session['search_root'];
196
+ if ( ! $searchroot ) {
197
+ $searchroot = '-2'; // To get 'All albums'
 
 
198
  }
199
  $albtxt = wppa( 'is_rootsearch' ) ?
200
  ' <span style="cursor:pointer;" title="'.
201
  esc_attr( sprintf( __( 'Searchresults from album %s and its subalbums' , 'wp-photo-album-plus'),
202
+ wppa_display_root( $searchroot ) ) ).'">*</span> ' :
203
  '';
204
  if ( wppa( 'is_slide' ) ) {
205
  $value = __( 'Searchstring:' , 'wp-photo-album-plus') . ' ' . ( isset ( $wppa_session['display_searchstring'] ) ? $wppa_session['display_searchstring'] : stripslashes( wppa( 'searchstring' ) ) ) . $albtxt;
206
+ $thumbhref = wppa_get_permalink().'wppa-cover=0&amp;wppa-occur='.wppa( 'occur' ).'&amp;wppa-searchstring='.stripslashes( str_replace( ' ', '+', $wppa_session['use_searchstring'] ) );
207
  $title = __( 'View the thumbnails' , 'wp-photo-album-plus');
208
  wppa_bcitem( $value, $thumbhref, $title, 'b8' );
209
  }
wppa-cart.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains the interface to SCABN
6
- * Version 6.3.0
7
  *
8
  */
9
 
@@ -15,12 +15,11 @@ if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
15
  // $thumb MUST contain the current photo info
16
  function wppa_add_to_cart( $atts ) {
17
  global $post;
18
- global $wppa;
19
 
20
- $thumb = $wppa['current_photo'];
21
 
22
  extract( shortcode_atts( array(
23
- 'name' => wppa_get_photo_name($thumb['id']),
24
  'price' => 0.01,
25
  'qty_field' => '',
26
  'b_title' => __('Buy now', 'wp-photo-album-plus'),
@@ -36,19 +35,19 @@ global $wppa;
36
  $currency = apply_filters('scabn_display_currency_symbol',NULL);
37
 
38
  // Slideshow?
39
- if ( $wppa['is_slide'] ) {
40
- $action_url = wppa_get_slide_callback_url($thumb['id']);
41
- $item_url = $action_url.'&wppa-single=1';
42
- $action_url = wppa_convert_to_pretty($action_url);
43
- $item_url = wppa_convert_to_pretty($item_url);
44
  }
45
  // Thumbnail vieuw?
46
  else {
47
  $action_url = wppa_get_thumb_callback_url();
48
- if ( ! strpos($action_url, '&amp;') ) $action_url = str_replace('&', '&amp;', $action_url);
49
- $item_url = wppa_get_slide_callback_url($thumb['id']).'&wppa-single=1';
50
- $action_url = wppa_convert_to_pretty($action_url);
51
- $item_url = wppa_convert_to_pretty($item_url);
52
  }
53
 
54
  $output = '
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains the interface to SCABN
6
+ * Version 6.3.9
7
  *
8
  */
9
 
15
  // $thumb MUST contain the current photo info
16
  function wppa_add_to_cart( $atts ) {
17
  global $post;
 
18
 
19
+ $thumb = wppa( 'current_photo' );
20
 
21
  extract( shortcode_atts( array(
22
+ 'name' => wppa_get_photo_name( $thumb['id'] ),
23
  'price' => 0.01,
24
  'qty_field' => '',
25
  'b_title' => __('Buy now', 'wp-photo-album-plus'),
35
  $currency = apply_filters('scabn_display_currency_symbol',NULL);
36
 
37
  // Slideshow?
38
+ if ( wppa( 'is_slide' ) ) {
39
+ $action_url = wppa_get_slide_callback_url( $thumb['id'] );
40
+ $item_url = $action_url . '&wppa-single=1';
41
+ $action_url = wppa_convert_to_pretty( $action_url );
42
+ $item_url = wppa_convert_to_pretty( $item_url );
43
  }
44
  // Thumbnail vieuw?
45
  else {
46
  $action_url = wppa_get_thumb_callback_url();
47
+ if ( ! strpos( $action_url, '&amp;' ) ) $action_url = str_replace( '&', '&amp;', $action_url );
48
+ $item_url = wppa_get_slide_callback_url( $thumb['id'] ) . '&wppa-single=1';
49
+ $action_url = wppa_convert_to_pretty( $action_url );
50
+ $item_url = wppa_convert_to_pretty( $item_url );
51
  }
52
 
53
  $output = '
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.3.8
6
  *
7
  */
8
 
@@ -103,9 +103,10 @@ global $thumbs;
103
  $occ = isset( $wppa['occur'] ) ? $wppa['occur'] : '0';
104
  $wocc = isset( $wppa['widget_occur'] ) ? $wppa['widget_occur'] : '0';
105
  $rend = isset( $wppa['rendering_enabled'] ) ? $wppa['rendering_enabled'] : false;
 
106
 
107
  $wppa = array (
108
- 'debug' => false,
109
  'revno' => $wppa_revno, // set in wppa.php
110
  'api_version' => $wppa_api_version, // set in wppa.php
111
  'fullsize' => '',
@@ -149,7 +150,7 @@ global $thumbs;
149
  'no_default' => false,
150
  'in_widget_frame_height' => '',
151
  'in_widget_frame_width' => '',
152
- 'user_uploaded' => false,
153
  'current_album' => '0',
154
  'searchstring' => wppa_test_for_search(),
155
  'searchresults' => '',
@@ -273,6 +274,8 @@ static $randseed_modified;
273
  }
274
  }
275
 
 
 
276
  return $randseed;
277
  }
278
 
@@ -316,12 +319,14 @@ function wppa_errorlog() {
316
  $messages = explode( "\n", $data );
317
  $count = count( $messages );
318
  $idx = $count - '2';
319
- while ( $idx >= '0' ) {
320
- $msg = $messages[$idx];
321
- $msg = htmlspecialchars( strip_tags( $msg ) ); // Security fix
322
- echo $msg.'<br />';
323
- $idx--;
324
- }
 
 
325
  wppa_dbg_msg( 'dbg', 'End errorlog' );
326
  fclose( $file );
327
  }
@@ -1341,6 +1346,7 @@ static $labels;
1341
  $photo = $id;
1342
  $tag = $s;
1343
  $desc = $iptc[$s][$i];
 
1344
  $status = 'default';
1345
  $iret = wppa_create_iptc_entry( array( 'photo' => $photo, 'tag' => $tag, 'description' => $desc, 'status' => $status ) );
1346
  if ( ! $iret ) wppa_log( 'Warning', 'Could not add IPTC tag '.$tag.' for photo '.$photo );
2
  /* wppa-common-functions.php
3
  *
4
  * Functions used in admin and in themes
5
+ * version 6.3.9
6
  *
7
  */
8
 
103
  $occ = isset( $wppa['occur'] ) ? $wppa['occur'] : '0';
104
  $wocc = isset( $wppa['widget_occur'] ) ? $wppa['widget_occur'] : '0';
105
  $rend = isset( $wppa['rendering_enabled'] ) ? $wppa['rendering_enabled'] : false;
106
+ $debug = isset( $wppa['debug'] ) ? $wppa['debug'] : false;
107
 
108
  $wppa = array (
109
+ 'debug' => $debug,
110
  'revno' => $wppa_revno, // set in wppa.php
111
  'api_version' => $wppa_api_version, // set in wppa.php
112
  'fullsize' => '',
150
  'no_default' => false,
151
  'in_widget_frame_height' => '',
152
  'in_widget_frame_width' => '',
153
+ // 'user_uploaded' => false,
154
  'current_album' => '0',
155
  'searchstring' => wppa_test_for_search(),
156
  'searchresults' => '',
274
  }
275
  }
276
 
277
+ wppa_save_session();
278
+
279
  return $randseed;
280
  }
281
 
319
  $messages = explode( "\n", $data );
320
  $count = count( $messages );
321
  $idx = $count - '2';
322
+
323
+ echo str_replace( "\n", '<br />', $data );
324
+ // while ( $idx >= '0' ) {
325
+ // $msg = $messages[$idx];
326
+ // $msg = htmlspecialchars( strip_tags( $msg ) ); // Security fix
327
+ // echo $msg.'<br />';
328
+ // $idx--;
329
+ // }
330
  wppa_dbg_msg( 'dbg', 'End errorlog' );
331
  fclose( $file );
332
  }
1346
  $photo = $id;
1347
  $tag = $s;
1348
  $desc = $iptc[$s][$i];
1349
+ $desc = utf8_encode( $desc );
1350
  $status = 'default';
1351
  $iret = wppa_create_iptc_entry( array( 'photo' => $photo, 'tag' => $tag, 'description' => $desc, 'status' => $status ) );
1352
  if ( ! $iret ) wppa_log( 'Warning', 'Could not add IPTC tag '.$tag.' for photo '.$photo );
wppa-functions.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various funcions
6
- * Version 6.3.8
7
  *
8
  */
9
 
@@ -13,7 +13,6 @@ if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
13
  // This is the main entrypoint for the wppa+ invocation, either 'by hand' or through the filter.
14
  // As of version 3.0.0 this routine returns the entire html created by the invocation.
15
  function wppa_albums( $id = '', $type = '', $size = '', $align = '' ) {
16
- global $wppa;
17
  global $wppa_lang;
18
  global $wppa_locale;
19
  global $wpdb;
@@ -22,8 +21,8 @@ global $wppa_session;
22
 
23
  // Diagnostics
24
  wppa_dbg_msg( 'Entering wppa_albums' );
25
- wppa_dbg_msg( 'Lang='.$wppa_lang.', Locale='.$wppa_locale.', Ajax='.wppa( 'ajax' ) );
26
- wppa_dbg_msg( '$wppa_session = '.serialize( $wppa_session ) );
27
 
28
  // List content filters
29
  // Data struct: $wp_filter[$tag][$priority][$idx] = array( 'function' => $function_to_add, 'accepted_args' => $accepted_args );
@@ -130,23 +129,24 @@ global $wppa_session;
130
  }
131
  if ( wppa( 'is_related' ) == 'desc' ) {
132
  wppa( 'src', true );
133
- if ( $wppa['related_count'] == '0' ) $wppa['related_count'] = wppa_opt( 'related_count' );
134
- $wppa['searchstring'] = str_replace( ';', ',', wppa_get_related_data() );
135
- $wppa['photos_only'] = true;
136
  }
137
- if ( $wppa['is_tag'] ) wppa_dbg_msg( 'Is Tag: '.$wppa['is_tag'] );
138
  else wppa_dbg_msg( 'Is NOT Tag' );
139
- $wppa['page'] = wppa_get_get( 'page' );
140
  if ( wppa_get_get( 'superview' ) ) {
141
- $wppa_session['superview'] = $wppa['is_slide'] ? 'slide': 'thumbs';
142
- $wppa_session['superalbum'] = $wppa['start_album'];
143
- $wppa['photos_only'] = true;
144
- }
145
- $wppa['is_upldr'] = wppa_get_get( 'upldr' );
146
- if ( $wppa['is_upldr'] ) $wppa['photos_only'] = true;
147
- $wppa['is_owner'] = wppa_get_get( 'owner' );
148
- if ( $wppa['is_owner'] ) {
149
- $albs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_ALBUMS."` WHERE `owner` = %s ", $wppa['is_owner'] ), ARRAY_A );
 
150
  wppa_dbg_q( 'Q-Main-1' );
151
  wppa_cache_album( 'add', $albs );
152
  $id = '';
@@ -154,21 +154,22 @@ global $wppa_session;
154
  $id .= $alb['id'].'.';
155
  }
156
  $id = rtrim( $id, '.' );
157
- $wppa['start_album'] = $id;
158
  }
159
- $wppa['supersearch'] = strip_tags( wppa_get_get( 'supersearch' ) );
160
- $wppa_session['supersearch'] = $wppa['supersearch'];
161
- if ( $wppa['supersearch'] ) {
162
- $ss_info = explode( ',', $wppa['supersearch'] );
 
163
  if ( $ss_info['0'] == 'a' ) {
164
- $wppa['albums_only'] = true;
165
  }
166
  else {
167
- $wppa['photos_only'] = true;
168
  }
169
  }
170
- $wppa['calendar'] = strip_tags( wppa_get_get( 'calendar' ) );
171
- $wppa['caldate'] = strip_tags( wppa_get_get( 'caldate' ) );
172
  }
173
 
174
  // 2. wppa_albums is called directly. Assume any arg. If not, no worry, system defaults are used == generic
@@ -179,42 +180,42 @@ global $wppa_session;
179
  if ( $type == 'album' ) {
180
  }
181
  elseif ( $type == 'cover' ) {
182
- $wppa['is_cover'] = '1';
183
  }
184
  elseif ( $type == 'slide' ) {
185
- $wppa['is_slide'] = '1';
186
  }
187
  elseif ( $type == 'slideonly' ) {
188
- $wppa['is_slideonly'] = '1';
189
  }
190
 
191
  if ( $type == 'photo' || $type == 'mphoto' || $type == 'slphoto' ) { // Any type of single photo? id given is photo id
192
- if ( $id ) $wppa['single_photo'] = $id;
193
  }
194
  else { // Not single photo: id given is album id
195
- if ( $id ) $wppa['start_album'] = $id;
196
  }
197
  }
198
 
199
  // 3. The filter supplied the data
200
  else {
201
- if ( $wppa['bestof'] ) {
202
- $args = $wppa['bestof_args'];
203
  wppa_bestof_box ( $args );
204
- $out = $wppa['out'];
205
- $wppa['out'] = '';
206
  wppa_reset_occurrance();
207
  return $out;
208
  }
209
- elseif ( $wppa['is_landing'] && ! $wppa['src'] ) {
210
  wppa_dbg_msg( 'Nothing to do...' );
211
  wppa_reset_occurrance();
212
  return ''; // Do nothing on a landing page without a querystring while it is also not a search operation
213
  }
214
- elseif ( $wppa['is_autopage'] ) {
215
- $wppa['single_photo'] = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `".WPPA_PHOTOS."` WHERE `page_id` = %d LIMIT 1", get_the_ID() ) );
 
216
  wppa_dbg_q( 'Q-main-2' );
217
- if ( ! $wppa['single_photo'] ) {
218
  wppa_dbg_msg( 'No photo found for page '.get_the_ID(), 'red', 'force' );
219
  wppa_reset_occurrance();
220
  return ''; // Give up
@@ -224,12 +225,12 @@ global $wppa_session;
224
  case 'photo':
225
  break;
226
  case 'mphoto':
227
- $wppa['is_mphoto'] = true;
228
  break;
229
  case 'slphoto':
230
- $wppa['is_slide'] = '1';
231
- $wppa['start_photo'] = $wppa['single_photo'];
232
- $wppa['is_single'] = '1';
233
  break;
234
  default:
235
  wppa_dbg_msg( 'Unimplemented type autopage display: '.$type, 'red', 'force' );
@@ -239,22 +240,22 @@ global $wppa_session;
239
 
240
  // Convert any keywords and / or names to numbers
241
  // Search for album keyword
242
- if ( $wppa['start_album'] && ! wppa_is_int( $wppa['start_album'] ) ) {
243
- if ( substr( $wppa['start_album'], 0, 1 ) == '#' ) { // Keyword
244
- $keyword = $wppa['start_album'];
245
  if ( strpos( $keyword, ',' ) ) $keyword = substr( $keyword, 0, strpos( $keyword, ',' ) );
246
- switch ( $keyword ) { // ( substr( $wppa['start_album'], 0, 5 ) ) {
247
  case '#last': // Last upload
248
  $id = wppa_get_youngest_album_id();
249
- if ( $wppa['is_cover'] ) { // To make sure the ordering sequence is ok.
250
- $temp = explode( ',',$wppa['start_album'] );
251
- if ( isset( $temp['1'] ) ) $wppa['last_albums_parent'] = $temp['1'];
252
- else $wppa['last_albums_parent'] = '0';
253
- if ( isset( $temp['2'] ) ) $wppa['last_albums'] = $temp['2'];
254
- else $wppa['last_albums'] = false;
255
  }
256
  else { // Ordering seq is not important, convert to album enum
257
- $temp = explode( ',',$wppa['start_album'] );
258
  if ( isset( $temp['1'] ) ) $parent = wppa_album_name_to_number( $temp['1'] );
259
  else $parent = '0';
260
  if ( $parent === false ) return;
@@ -286,80 +287,80 @@ global $wppa_session;
286
  }
287
  break;
288
  case '#topten':
289
- $temp = explode( ',',$wppa['start_album'] );
290
  $id = isset( $temp[1] ) ? $temp[1] : '0';
291
- $wppa['topten_count'] = isset( $temp[2] ) ? $temp[2] : wppa_opt( 'topten_count' );
292
- $wppa['is_topten'] = true;
293
- if ( $wppa['is_cover'] ) {
294
- wppa_dbg_msg( 'A topten album has no cover. '.$wppa['start_album'], 'red', 'force' );
295
  wppa_reset_occurrance();
296
  return; // Give up this occurence
297
  }
298
  break;
299
  case '#lasten':
300
- $temp = explode( ',',$wppa['start_album'] );
301
  $id = isset( $temp[1] ) ? $temp[1] : '0';
302
- $wppa['lasten_count'] = isset( $temp[2] ) ? $temp[2] : wppa_opt( 'lasten_count' );
303
- $wppa['is_lasten'] = true;
304
- if ( $wppa['is_cover'] ) {
305
- wppa_dbg_msg( 'A lasten album has no cover. '.$wppa['start_album'], 'red', 'force' );
306
  wppa_reset_occurrance();
307
  return; // Give up this occurence
308
  }
309
  break;
310
  case '#comten':
311
- $temp = explode( ',',$wppa['start_album'] );
312
  $id = isset( $temp[1] ) ? $temp[1] : '0';
313
- $wppa['comten_count'] = isset( $temp[2] ) ? $temp[2] : wppa_opt( 'comten_count' );
314
- $wppa['is_comten'] = true;
315
- if ( $wppa['is_cover'] ) {
316
- wppa_dbg_msg( 'A comten album has no cover. '.$wppa['start_album'], 'red', 'force' );
317
  wppa_reset_occurrance();
318
  return; // Give up this occurence
319
  }
320
  break;
321
  case '#featen':
322
- $temp = explode( ',',$wppa['start_album'] );
323
  $id = isset( $temp[1] ) ? $temp[1] : '0';
324
- $wppa['featen_count'] = isset( $temp[2] ) ? $temp[2] : wppa_opt( 'featen_count' );
325
- $wppa['is_featen'] = true;
326
- if ( $wppa['is_cover'] ) {
327
- wppa_dbg_msg( 'A featen album has no cover. '.$wppa['start_album'], 'red', 'force' );
328
  wppa_reset_occurrance();
329
  return; // Give up this occurence
330
  }
331
  break;
332
  case '#related':
333
- $temp = explode( ',',$wppa['start_album'] );
334
  $type = isset( $temp[1] ) ? $temp[1] : 'tags'; // tags is default type
335
- $wppa['related_count'] = isset( $temp[2] ) ? $temp[2] : wppa_opt( 'related_count' );
336
- $wppa['is_related'] = $type;
337
 
338
  $data = wppa_get_related_data();
339
 
340
  if ( $type == 'tags' ) {
341
- $wppa['is_tag'] = $data;
342
  }
343
  if ( $type == 'desc' ) {
344
- $wppa['src'] = true;
345
- $wppa['searchstring'] = str_replace( ';', ',', $data );
346
- $wppa['photos_only'] = true;
347
  }
348
- $wppa['photos_only'] = true;
349
- $id = '0'; //$wppa['start_album'] = '';
350
  break;
351
  case '#tags':
352
- $wppa['is_tag'] = wppa_sanitize_tags( substr( $wppa['start_album'], 6 ), true );
353
- $id = '0'; //$wppa['start_album'] = '';
354
- $wppa['photos_only'] = true;
355
  break;
356
  case '#cat':
357
- $temp = explode( ',',$wppa['start_album'] );
358
  $cat = isset( $temp[1] ) ? $temp[1] : '';
359
  $cat = trim( wppa_sanitize_tags( $cat ), ',' );
360
- $wppa['is_cat'] = $cat;
361
  if ( ! $cat ) {
362
- wppa_dbg_msg( 'Missing cat #cat album spec: '.$wppa['start_album'], 'red', 'force' );
363
  wppa_reset_occurrance();
364
  return; // Forget this occurrance
365
  }
@@ -376,7 +377,7 @@ global $wppa_session;
376
  $id = rtrim( $id, '.' );
377
  break;
378
  case '#owner':
379
- $temp = explode( ',',$wppa['start_album'] );
380
  $owner = isset( $temp[1] ) ? $temp[1] : '';
381
  if ( $owner == '#me' ) {
382
  if ( is_user_logged_in() ) $owner = wppa_get_user();
@@ -386,7 +387,7 @@ global $wppa_session;
386
  }
387
  }
388
  if ( ! $owner ) {
389
- wppa_dbg_msg( 'Missing owner in #owner album spec: '.$wppa['start_album'], 'red', 'force' );
390
  wppa_reset_occurrance();
391
  return; // Forget this occurrance
392
  }
@@ -415,10 +416,10 @@ global $wppa_session;
415
  // return; // No children found
416
  }
417
  }
418
- $wppa['is_owner'] = $owner;
419
  break;
420
  case '#upldr':
421
- $temp = explode( ',',$wppa['start_album'] );
422
  $owner = isset( $temp[1] ) ? $temp[1] : '';
423
  if ( $owner == '#me' ) {
424
  if ( is_user_logged_in() ) $owner = wppa_get_user();
@@ -428,14 +429,13 @@ global $wppa_session;
428
  }
429
  }
430
  if ( ! $owner ) {
431
- wppa_dbg_msg( 'Missing owner in #upldr album spec: '.$wppa['start_album'], 'red', 'force' );
432
  wppa_reset_occurrance();
433
  return; // Forget this occurrance
434
  }
435
  $parent = isset( $temp[2] ) ? wppa_album_name_to_number( $temp[2] ) : '0';
436
  if ( $parent === false ) return; // parent specified but not a valid value
437
  if ( $parent ) { // Valid parent spec
438
- // $id = wppa_alb_to_enum_children( $parent );
439
  $id = wppa_alb_to_enum_children( wppa_expand_enum( $parent ) );
440
  if ( ! $id ) {
441
  wppa_reset_occurrance();
@@ -445,56 +445,63 @@ global $wppa_session;
445
  else { // No parent spec
446
  $id = '0';
447
  }
448
- $wppa['is_upldr'] = $owner;
449
- $wppa['photos_only'] = true;
450
  break;
451
  case '#all':
452
  $id = '-2';
453
  break;
454
  default:
455
- wppa_dbg_msg( 'Unrecognized album keyword found: '.$wppa['start_album'], 'red', 'force' );
456
  wppa_reset_occurrance();
457
  return; // Forget this occurrance
458
  }
459
- $wppa['start_album'] = $id;
460
  }
461
  }
462
 
463
  // See if the album id is a name and convert it if possible
464
- $wppa['start_album'] = wppa_album_name_to_number( $wppa['start_album'] );
465
- if ( $wppa['start_album'] === false ) return;
 
 
 
 
466
  // Also for parents
467
- $wppa['last_albums_parent'] = wppa_album_name_to_number( $wppa['last_albums_parent'] );
468
- if ( $wppa['last_albums_parent'] === false ) return;
 
 
 
469
 
470
  // Check if album is valid
471
- if ( strpos( $wppa['start_album'], '.' ) !== false ) { // Album may be enum
472
- if ( ! wppa_series_to_array( $wppa['start_album'] ) ) { // Syntax error
473
  wppa_reset_occurrance();
474
  return;
475
  }
476
  }
477
 
478
  // Album must be numeric
479
- elseif ( $wppa['start_album'] && ! is_numeric( $wppa['start_album'] ) ) {
480
- wppa_stx_err( 'Unrecognized Album identification found: '.$wppa['start_album'] );
481
  wppa_reset_occurrance();
482
  return; // Forget this occurrance
483
  }
484
 
485
  // Album must exist
486
- elseif ( $wppa['start_album'] > '0' ) { // -2 is #all
487
- if ( ! wppa_album_exists( $wppa['start_album'] ) ) {
488
- wppa_stx_err( 'Album does not exist: '.$wppa['start_album'] );
489
  wppa_reset_occurrance();
490
  return; // Forget this occurrance
491
  }
492
  }
493
 
494
  // See if the photo id is a keyword and convert it if possible
495
- if ( $wppa['single_photo'] && !is_numeric( $wppa['single_photo'] ) ) {
496
- if ( substr( $wppa['single_photo'], 0, 1 ) == '#' ) { // Keyword
497
- switch ( $wppa['single_photo'] ) {
498
  case '#potd': // Photo of the day
499
  $t = wppa_get_potd();
500
  if ( is_array( $t ) ) $id = $t['id'];
@@ -504,21 +511,21 @@ global $wppa_session;
504
  $id = wppa_get_youngest_photo_id();
505
  break;
506
  default:
507
- wppa_dbg_msg( 'Unrecognized photo keyword found: '.$wppa['single_photo'], 'red', 'force' );
508
  wppa_reset_occurrance();
509
  return; // Forget this occurrance
510
  }
511
- $wppa['single_photo'] = $id;
512
  }
513
  }
514
 
515
  // See if the photo id is a name and convert it if possible
516
- if ( $wppa['single_photo'] && !is_numeric( $wppa['single_photo'] ) ) {
517
- if ( substr( $wppa['single_photo'], 0, 1 ) == '$' ) { // Name
518
- $id = wppa_get_photo_id_by_name( substr( $wppa['single_photo'], 1 ) );
519
- if ( $id > '0' ) $wppa['single_photo'] = $id;
520
  else {
521
- wppa_dbg_msg( 'Photo name not found: '.$wppa['single_photo'], 'red', 'force' );
522
  wppa_reset_occurrance();
523
  return; // Forget this occurrance
524
  }
@@ -527,41 +534,42 @@ global $wppa_session;
527
 
528
  // Size and align
529
  if ( is_numeric( $size ) ) {
530
- $wppa['fullsize'] = $size;
531
  }
532
  elseif ( $size == 'auto' ) {
533
- $wppa['auto_colwidth'] = true;
534
  }
535
  if ( $align == 'left' || $align == 'center' || $align == 'right' ) {
536
- $wppa['align'] = $align;
537
  }
538
 
539
  // Empty related shortcode?
540
- if ( $wppa['is_related'] ) {
541
  $thumbs = wppa_get_thumbs();
542
  if ( empty( $thumbs ) ) {
543
  wppa_errorbox( __( 'No related photos found.', 'wp-photo-album-plus') );
544
- $result = $wppa['out'];
545
  wppa_reset_occurrance(); // Forget this occurrance
546
  return $result;
547
  }
548
  }
549
 
550
  // Subsearch or rootsearch?
551
- if ( wppa( 'occur' ) == '1' && $wppa_session['has_searchbox'] ) {
552
 
553
  // Is it a search now?
554
- if ( $wppa['src'] ) {
555
 
556
  // Is the subsearch box checked?
557
- $wppa['is_subsearch'] = wppa_get_get( 'subsearch' ) || wppa_get_post( 'subsearch' );
558
 
559
  // Is the rootsearch box checked?
560
- $wppa['is_rootsearch'] = wppa_get_get( 'rootsearch' ) || wppa_get_post( 'rootsearch' );
561
 
562
  // No rootsearch, forget previous root
563
- if ( ! $wppa['is_rootsearch'] ) {
564
  $wppa_session['search_root'] = '0';
 
565
  }
566
 
567
  }
@@ -571,135 +579,95 @@ global $wppa_session;
571
 
572
  // Find new potential searchroot
573
  if ( isset( $_REQUEST['wppa-searchroot'] ) ) {
574
- $wppa['start_album'] = strval( intval( $_REQUEST['wppa-searchroot'] ) );
575
  }
576
 
577
  // Update session with new searchroot
578
- $wppa_session['search_root'] = $wppa['start_album'];
 
579
 
580
  }
581
 
582
  // Update searchroot in search boxes
583
  $rt = $wppa_session['search_root'];
584
  if ( ! $rt ) $rt = '0'; // must be non-empty string
585
- $wppa['src_script'] .= 'wppaUpdateSearchRoot(\''.wppa_display_root( $rt ).'\', '.$rt.' );';
586
- // wppa_out( '<script type="text/javascript" >' .
587
- // 'wppaUpdateSearchRoot(\''.wppa_display_root( $rt ).'\', '.$rt.' )' .
588
- // '</script>'
589
- // );
590
 
591
  // If not search forget previous results
592
- if ( ! $wppa['src'] ) {
593
  $wppa_session['use_searchstring'] = '';
594
  $wppa_session['display_searchstring'] = '';
595
- $wppa['src_script'] .= 'wppaClearSubsearch();';
596
- // wppa_out( '<script type="text/javascript" >' .
597
- // 'wppaClearSubsearch()' .
598
- // '</script>'
599
- // );
600
  }
601
  else { // Enable subbox
602
- $wppa['src_script'] .= 'wppaEnableSubsearch();';
603
- // wppa_out( '<script type="text/javascript" >' .
604
- // 'wppaEnableSubsearch()' .
605
- // '</script>'
606
- // );
607
  }
608
  }
609
 
610
  // Is is a stereo settings box?
611
- if ( $wppa['is_stereobox'] ) {
612
  wppa_stereo_box();
613
  }
614
  // Is it the search box?
615
- elseif ( $wppa['is_searchbox'] ) {
616
- wppa_search_box( '', $wppa['may_sub'], $wppa['may_root'] );
617
  }
618
  // Is it the superview box?
619
- elseif ( $wppa['is_superviewbox'] ) {
620
- wppa_superview_box( $wppa['start_album'] );
621
  }
622
  // Is it the multitag box?
623
- elseif ( $wppa['is_multitagbox'] ) {
624
- wppa_multitag_box( $wppa['tagcols'], $wppa['taglist'] );
625
  }
626
  // Is it the tagcloud box?
627
- elseif ( $wppa['is_tagcloudbox'] ) {
628
- wppa_tagcloud_box( $wppa['taglist'], wppa_opt( 'tagcloud_min' ), wppa_opt( 'tagcloud_max' ) );
629
  }
630
  // Is it an upload box?
631
- elseif ( $wppa['is_upload'] ) {
632
  wppa_upload_box();
633
  }
634
  // Is it a supersearch box?
635
- elseif ( $wppa['is_supersearch'] ) {
636
  wppa_supersearch_box();
637
  }
638
  // Is it newstyle single photo mediastyle?
639
- elseif ( $wppa['is_mphoto'] == '1' ) {
640
- if ( $wppa['is_autopage'] ) wppa_auto_page_links( 'top' );
641
  wppa_mphoto();
642
- if ( $wppa['is_autopage'] ) wppa_auto_page_links( 'bottom' );
643
  }
644
  // Is it newstyle single photo plain?
645
  elseif ( wppa_page( 'oneofone' ) ) {
646
- if ( $wppa['is_autopage'] ) wppa_auto_page_links( 'top' );
647
  wppa_sphoto();
648
- if ( $wppa['is_autopage'] ) wppa_auto_page_links( 'bottom' );
649
  }
650
  // Is it the calendar?
651
- elseif ( $wppa['is_calendar'] ) {
652
  wppa_calendar_box();
653
  }
654
  // The normal case
655
  else {
656
  if ( function_exists( 'wppa_theme' ) ) {
657
- if ( $wppa['is_autopage'] ) wppa_auto_page_links( 'top' );
658
  wppa_theme(); // Call the theme module
659
- if ( $wppa['is_autopage'] ) wppa_auto_page_links( 'bottom' );
660
  }
661
- else $wppa['out'] = '<span style="color:red">ERROR: Missing function wppa_theme(), check the installation of WPPA+. Remove customized wppa_theme.php</span>';
662
  global $wppa_version;
663
  $expected_version = '6-2-7-000';
664
  if ( $wppa_version != $expected_version ) {
665
- wppa_dbg_msg( 'WARNING: customized wppa-theme.php is out of rev. Expected version: '.$expected_version.' found: '.$wppa_version, 'red' );
666
  }
667
  }
668
- /*
669
- // Subsearch or rootsearch?
670
- if ( wppa( 'occur' ) == '1' && $wppa_session['has_searchbox'] ) {
671
 
672
- // Update searchroot in search boxes
673
- $rt = $wppa_session['search_root'];
674
- if ( ! $rt ) $rt = '0'; // must be non-empty string
675
- wppa_out( '<script type="text/javascript" >' .
676
- 'wppaUpdateSearchRoot(\''.wppa_display_root( $rt ).'\', '.$rt.' )' .
677
- '</script>'
678
- );
679
-
680
- // If no root ( is all albums ), forget previous results
681
- if ( ! wppa( 'start_album' ) && ! $wppa['src'] ) {
682
- $wppa_session['use_searchstring'] = '';
683
- $wppa_session['display_searchstring'] = '';
684
- wppa_out( '<script type="text/javascript" >' .
685
- 'wppaClearSubsearch()' .
686
- '</script>'
687
- );
688
- }
689
- else { // Enable subbox
690
- wppa_out( '<script type="text/javascript" >' .
691
- 'wppaEnableSubsearch()' .
692
- '</script>'
693
- );
694
- }
695
- }
696
- */
697
  // Done
698
- $out = str_replace( 'w#location', $wppa['geo'], $wppa['out'] );
699
 
700
  // Reset
701
- $wppa['out'] = '';
702
- $wppa['geo'] = '';
703
  wppa_reset_occurrance();
704
  return $out;
705
  }
@@ -739,83 +707,8 @@ global $wpdb;
739
  return $data;
740
  }
741
 
742
- // Prepare for next occurance by resetting runtime vars
743
- /*
744
- function wppa_reset_occurrance() {
745
- global $wppa;
746
-
747
- global $thumbs;
748
-
749
- $thumbs = false;
750
-
751
- wppa_cache_thumb( 'invalidate' );
752
- wppa_cache_album( 'invalidate' );
753
-
754
- $wppa['src'] = false;
755
- $wppa['searchstring'] = '';
756
- $wppa['topten_count'] = '0';
757
- $wppa['is_topten'] = false;
758
- $wppa['lasten_count'] = '0';
759
- $wppa['is_lasten'] = false;
760
- $wppa['comten_count'] = '0';
761
- $wppa['is_comten'] = false;
762
- $wppa['is_featen'] = false;
763
- $wppa['featen_count'] = '0';
764
- $wppa['is_tag'] = false;
765
- $wppa['is_single'] = false;
766
- $wppa['is_mphoto'] = '0';
767
- $wppa['single_photo'] = '';
768
- $wppa['start_album'] = '';
769
- $wppa['is_cover'] = '0';
770
- $wppa['is_slide'] = '0';
771
- $wppa['is_slideonly'] = '0';
772
- $wppa['is_slideonlyf'] = '0';
773
- $wppa['film_on'] = '0';
774
- $wppa['is_landing'] = '0';
775
- $wppa['start_photo'] = '0';
776
- $wppa['photos_only'] = false;
777
- $wppa['albums_only'] = false;
778
- $wppa['page'] = '';
779
- $wppa['is_upload'] = false;
780
- $wppa['last_albums'] = false;
781
- $wppa['last_albums_parent'] = '0';
782
- $wppa['is_multitagbox'] = false;
783
- $wppa['is_tagcloudbox'] = false;
784
- $wppa['taglist'] = '';
785
- $wppa['tagcols'] = '2';
786
- $wppa['is_related'] = false;
787
- $wppa['related_count'] = '0';
788
- $wppa['is_owner'] = '';
789
- $wppa['is_upldr'] = '';
790
- $wppa['is_cat'] = false;
791
- $wppa['bestof'] = false;
792
- $wppa['is_subsearch'] = false;
793
- $wppa['is_rootsearch'] = false;
794
- $wppa['is_superviewbox'] = false;
795
- $wppa['is_searchbox'] = false;
796
- $wppa['may_sub'] = false;
797
- $wppa['may_root'] = false;
798
- $wppa['portrait_only'] = false;
799
- $wppa['is_supersearch'] = false;
800
- $wppa['supersearch'] = '';
801
- $wppa['is_calendar'] = false;
802
- $wppa['calendar'] = '';
803
- $wppa['caldate'] = '';
804
- $wppa['calendarall'] = false;
805
- $wppa['reverse'] = false;
806
- $wppa['current_photo'] = false;
807
- $wppa['is_stereobox'] = false;
808
- $wppa['npages'] = '';
809
- $wppa['curpage'] = '';
810
- $wppa['ss_pag'] = false;
811
-
812
-
813
- }
814
- */
815
-
816
  // Determine in wich theme page we are, Album covers, Thumbnails or slideshow
817
  function wppa_page( $page ) {
818
- global $wppa;
819
 
820
  if ( wppa_in_widget() ) {
821
  $occur = wppa_get_get( 'woccur' );
@@ -824,11 +717,11 @@ global $wppa;
824
  $occur = wppa_get_get( 'occur' );
825
  }
826
 
827
- $ref_occur = wppa_in_widget() ? wppa( 'widget_occur' ) : $wppa['occur'];
828
 
829
- if ( $wppa['is_slide'] == '1' ) $cur_page = 'slide'; // Do slide or single when explixitly on
830
- elseif ( $wppa['is_slideonly'] == '1' ) $cur_page = 'slide'; // Slideonly is a subset of slide
831
- elseif ( is_numeric( $wppa['single_photo'] ) ) $cur_page = 'oneofone';
832
  else $cur_page = 'albums';
833
 
834
  if ( $cur_page == $page ) return true; else return false;
@@ -837,28 +730,27 @@ global $wppa;
837
  // loop album
838
  function wppa_get_albums() {
839
  global $wpdb;
840
- global $wppa;
841
  global $wppa_session;
842
 
843
- wppa_dbg_msg( 'get_albums entered: '.wppa( 'mocc' ).' Start_album='.$wppa['start_album'].', Cover='.$wppa['is_cover'] );
844
 
845
- if ( $wppa['is_topten'] ) return false;
846
- if ( $wppa['is_lasten'] ) return false;
847
- if ( $wppa['is_comten'] ) return false;
848
- if ( $wppa['is_featen'] ) return false;
849
- if ( $wppa['is_tag'] ) return false;
850
- if ( $wppa['photos_only'] ) return false;
851
 
852
- if ( $wppa['src'] && wppa_switch( 'photos_only' ) ) return false;
853
- if ( $wppa['is_owner'] && ! $wppa['start_album'] ) return false; // No owner album( s )
854
 
855
- if ( $wppa['calendar'] == 'exifdtm' ) return false;
856
- if ( $wppa['calendar'] == 'timestamp' ) return false;
857
- if ( $wppa['calendar'] == 'modified' ) return false;
858
 
859
  // Supersearch?
860
- if ( $wppa['supersearch'] ) {
861
- $ss_data = explode( ',', $wppa['supersearch'] );
862
  $data = $ss_data['3'];
863
  switch ( $ss_data['1'] ) {
864
 
@@ -926,9 +818,9 @@ global $wppa_session;
926
  }
927
 
928
  // Search?
929
- elseif ( $wppa['src'] ) {
930
  $final_array = array();
931
- $chunks = explode( ',', stripslashes( strtolower( $wppa['searchstring'] ) ) );
932
  // all chunks
933
  foreach ( $chunks as $chunk ) if ( strlen( trim( $chunk ) ) ) {
934
  $words = wppa_index_raw_to_words( $chunk );
@@ -981,7 +873,7 @@ global $wppa_session;
981
  }
982
 
983
  // Rootsearch?
984
- if ( $wppa['is_rootsearch'] && isset ( $wppa_session['search_root'] ) ) {
985
  $root = $wppa_session['search_root'];
986
  if ( is_array( $albums ) ) {
987
  $c1=count( $albums );
@@ -1005,33 +897,33 @@ global $wppa_session;
1005
  }
1006
  }
1007
 
1008
- if ( is_array( $albums ) ) $wppa['any'] = true;
1009
  }
1010
  else { // Its not search
1011
- $id = $wppa['start_album'];
1012
  if ( ! $id ) $id = '0';
1013
 
1014
  // Do the query
1015
  if ( $id == '-2' ) { // All albums
1016
- if ( $wppa['is_cover'] ) {
1017
  $q = "SELECT * FROM `".WPPA_ALBUMS."` ".wppa_get_album_order();
1018
  wppa_dbg_q( 'Q11d' );
1019
  $albums = $wpdb->get_results( $q, ARRAY_A );
1020
  }
1021
  else $albums = false;
1022
  }
1023
- elseif ( $wppa['last_albums'] ) { // is_cover = true. For the order sequence, see remark in wppa_albums()
1024
- if ( $wppa['last_albums_parent'] ) {
1025
- $q = $wpdb->prepare( "SELECT * FROM `".WPPA_ALBUMS."` WHERE `a_parent` = %s ORDER BY `timestamp` DESC LIMIT %d", $wppa['last_albums_parent'], $wppa['last_albums'] );
1026
  }
1027
  else {
1028
- $q = $wpdb->prepare( "SELECT * FROM `".WPPA_ALBUMS."` ORDER BY `timestamp` DESC LIMIT %d", $wppa['last_albums'] );
1029
  }
1030
  wppa_dbg_q( 'Q11a' );
1031
  $albums = $wpdb->get_results( $q, ARRAY_A );
1032
  }
1033
  elseif ( wppa_is_int( $id ) ) {
1034
- if ( $wppa['is_cover'] ) {
1035
  $q = $wpdb->prepare( 'SELECT * FROM ' . WPPA_ALBUMS . ' WHERE `id` = %s', $id );
1036
  }
1037
  else {
@@ -1039,13 +931,13 @@ global $wppa_session;
1039
  }
1040
  wppa_dbg_q( 'Q11b' );
1041
  $albums = $wpdb->get_results( $q, ARRAY_A );
1042
- if ( ! $wppa['is_cover'] ) {
1043
  wppa_verify_treecounts( $id, 'albums', count( $albums ) );
1044
  }
1045
  }
1046
  elseif ( strpos( $id, '.' ) !== false ) { // Album enum
1047
  $ids = wppa_series_to_array( $id );
1048
- if ( $wppa['is_cover'] ) {
1049
  $q = "SELECT * FROM `".WPPA_ALBUMS."` WHERE `id` = ".implode( " OR `id` = ", $ids )." ".wppa_get_album_order();
1050
  }
1051
  else {
@@ -1075,7 +967,7 @@ global $wppa_session;
1075
  wppa_cache_album( 'add', $albums );
1076
  }
1077
 
1078
- $wppa['album_count'] = count( $albums );
1079
  return $albums;
1080
  }
1081
 
@@ -1498,7 +1390,7 @@ global $wppa_session;
1498
  if ( ! is_user_logged_in() ) $status .= " AND `status` <> 'private'";
1499
 
1500
  $searchstring = wppa( 'searchstring' );
1501
- if ( isset ( $wppa_session['use_searchstring'] ) && ! empty ( $wppa_session['use_searchstring'] ) ) $searchstring = $wppa_session['use_searchstring'];
1502
 
1503
  $final_array = array();
1504
  $chunks = explode( ',', stripslashes( strtolower( $searchstring ) ) );
@@ -1791,7 +1683,6 @@ global $wpdb;
1791
  // get slide info
1792
  function wppa_get_slide_info( $index, $id, $callbackid = '' ) {
1793
  global $wpdb;
1794
- global $wppa;
1795
  static $user;
1796
 
1797
  // Make sure $thumb contains our image data
@@ -1811,7 +1702,7 @@ static $user;
1811
  }
1812
 
1813
  // Find rating
1814
- if ( wppa_switch( 'rating_on' ) && ! $wppa['is_slideonly'] && ! $wppa['is_filmonly'] ) {
1815
 
1816
  // Find my ( avg ) rating
1817
  $rats = $wpdb->get_results( $wpdb->prepare( "SELECT `value` FROM `".WPPA_RATING."` " .
@@ -1846,7 +1737,7 @@ static $user;
1846
  }
1847
 
1848
  // Find comments
1849
- $comment = ( wppa_switch( 'show_comments' ) && ! $wppa['is_filmonly'] && ! $wppa['is_slideonly'] ) ? wppa_comment_html( $id, $comment_allowed ) : '';
1850
 
1851
  // Get the callback url.
1852
  if ( wppa_switch( 'rating_on' ) ) {
@@ -1869,7 +1760,7 @@ static $user;
1869
  $linktarget = $link['target'];
1870
 
1871
  // Find full image style and size
1872
- if ( $wppa['is_filmonly'] ) {
1873
  $style_a['style'] = '';
1874
  $style_a['width'] = '';
1875
  $style_a['height'] = '';
@@ -1894,17 +1785,17 @@ static $user;
1894
  }
1895
 
1896
  // Find iptc data
1897
- $iptc = ( wppa_switch( 'show_iptc' ) && ! $wppa['is_slideonly'] && ! $wppa['is_filmonly'] ) ? wppa_iptc_html( $id ) : '';
1898
 
1899
  // Find EXIF data
1900
- $exif = ( wppa_switch( 'show_exif' ) && ! $wppa['is_slideonly'] && ! $wppa['is_filmonly'] ) ? wppa_exif_html( $id ) : '';
1901
 
1902
  // Lightbox subtitle
1903
  $doit = false;
1904
  if ( wppa_opt( 'slideshow_linktype' ) == 'lightbox' || wppa_opt( 'slideshow_linktype' ) == 'lightboxsingle' ) $doit = true; // For fullsize
1905
  if ( wppa_switch( 'filmstrip' ) && wppa_opt( 'film_linktype' ) == 'lightbox' ) { // For filmstrip?
1906
- if ( ! $wppa['is_slideonly'] ) $doit = true; // Film below fullsize
1907
- if ( $wppa['film_on'] ) $doit = true; // Film explicitly on ( slideonlyf )
1908
  }
1909
  if ( $doit ) {
1910
  $lbtitle = wppa_get_lbtitle( 'slide', $id );
@@ -1912,7 +1803,7 @@ static $user;
1912
  else $lbtitle = '';
1913
 
1914
  // Name
1915
- if ( $wppa['is_filmonly'] ) {
1916
  $name = '';
1917
  $fullname = '';
1918
  }
@@ -1924,18 +1815,18 @@ static $user;
1924
  }
1925
 
1926
  // Shareurl
1927
- if ( $wppa['is_filmonly'] || $wppa['is_slideonly'] ) {
1928
  $shareurl = '';
1929
  }
1930
  else {
1931
- $shareurl = wppa_get_image_page_url_by_id( $id, false, $wppa['start_album'] );
1932
  $shareurl = wppa_convert_to_pretty( $shareurl );
1933
  $shareurl = str_replace( '&amp;', '&', $shareurl );
1934
  }
1935
 
1936
  // Make photo desc, filtered
1937
  $desc = '';
1938
- if ( ( ! $wppa['is_slideonly'] || $wppa['desc_on'] ) && ! $wppa['is_filmonly'] ) {
1939
 
1940
  $desc .= wppa_get_photo_desc( $id, wppa_switch( 'allow_foreign_shortcodes' ), 'do_geo' ); // Foreign shortcodes is handled here
1941
 
@@ -1958,7 +1849,7 @@ static $user;
1958
  // Edit photo link
1959
  $editlink = '';
1960
  $dellink = '';
1961
- if ( ! $wppa['is_filmonly'] && ! $wppa['is_slideonly'] ) {
1962
  if ( ! wppa_is_user_blacklisted() ) {
1963
  if ( ( wppa_user_is( 'administrator' ) ) ||
1964
  ( current_user_can( 'wppa_moderate' ) ) ||
@@ -1995,7 +1886,7 @@ static $user;
1995
  }
1996
 
1997
  // Share HTML
1998
- $sharehtml = ( $wppa['is_filmonly'] || $wppa['is_slideonly'] ) ? '' : wppa_get_share_html( $id );
1999
 
2000
  // Og Description
2001
  $ogdsc = ( wppa_switch( 'facebook_comments' ) && ! wppa_in_widget() ) ? strip_shortcodes( wppa_strip_tags( wppa_html( wppa_get_photo_desc( $id ) ), 'all' ) ) : '';
@@ -2026,7 +1917,7 @@ static $user;
2026
  $result .= $myrat."','";
2027
  $result .= $url."','";
2028
  $result .= $linkurl."','".$linktitle."','".$linktarget."','";
2029
- $result .= $wppa['in_widget_timeout']."','";
2030
  $result .= $comment."','";
2031
  $result .= $iptc."','";
2032
  $result .= $exif."','";
@@ -2049,7 +1940,6 @@ static $user;
2049
  // Process a comment request
2050
  function wppa_do_comment( $id ) {
2051
  global $wpdb;
2052
- global $wppa;
2053
  global $wppa_done;
2054
 
2055
  if ( $wppa_done ) return; // Prevent multiple
@@ -2122,7 +2012,7 @@ global $wppa_done;
2122
  wppa_dbg_q( 'Q44' );
2123
  $iret = $wpdb->query( $query );
2124
  if ( $iret !== false ) {
2125
- $wppa['comment_id'] = $cedit;
2126
  }
2127
  }
2128
  else {
@@ -2130,11 +2020,11 @@ global $wppa_done;
2130
  $old_entry = $wpdb->prepare( 'SELECT * FROM `'.WPPA_COMMENTS.'` WHERE `photo` = %s AND `user` = %s AND `comment` = %s LIMIT 1', $photo, $user, $save_comment );
2131
  $iret = $wpdb->query( $old_entry );
2132
  if ( $iret ) {
2133
- if ( $wppa['debug'] ) echo( '<script type="text/javascript">alert( "Duplicate comment ignored" )</script>' );
2134
  return;
2135
  }
2136
  $key = wppa_create_comments_entry( array( 'photo' => $photo, 'user' => $user, 'email' => $email, 'comment' => $save_comment, 'status' => $status ) );
2137
- if ( $key ) $wppa['comment_id'] = $key;
2138
  }
2139
  if ( $iret !== false ) {
2140
  if ( $status != 'spam' ) {
@@ -2280,8 +2170,8 @@ global $wppa_done;
2280
  '</script>';
2281
  }
2282
 
2283
- $wppa['comment_photo'] = $id;
2284
- $wppa['comment_text'] = $comment;
2285
 
2286
  // Clear ( super )cache
2287
  wppa_clear_cache();
@@ -2330,7 +2220,6 @@ function wppa_ll_captcha( $id ) {
2330
  }
2331
 
2332
  function wppa_get_imgevents( $type = '', $id = '', $no_popup = false, $idx = '' ) {
2333
- global $wppa;
2334
  global $wpdb;
2335
 
2336
  $result = '';
@@ -2452,7 +2341,6 @@ global $wpdb;
2452
  }
2453
 
2454
  function wppa_onpage( $type = '', $counter, $curpage ) {
2455
- global $wppa;
2456
 
2457
  $pagesize = wppa_get_pagesize( $type );
2458
  if ( $pagesize == '0' ) { // Pagination off
@@ -2518,37 +2406,36 @@ function wppa_and_stristr( $string, $branch ) {
2518
  }
2519
 
2520
  function wppa_get_slide_frame_style() {
2521
- global $wppa;
2522
 
2523
  $fs = wppa_opt( 'fullsize' );
2524
  $cs = wppa_opt( 'colwidth' );
2525
  if ( $cs == 'auto' ) {
2526
  $cs = $fs;
2527
- $wppa['auto_colwidth'] = true;
2528
  }
2529
  $result = '';
2530
- $gfs = ( is_numeric( $wppa['fullsize'] ) && $wppa['fullsize'] > '1' ) ? $wppa['fullsize'] : $fs;
2531
 
2532
  $gfh = floor( $gfs * wppa_opt( 'maxheight' ) / wppa_opt( 'fullsize' ) );
2533
 
2534
- if ( wppa_in_widget() == 'ss' && $wppa['in_widget_frame_height'] > '0' ) $gfh = $wppa['in_widget_frame_height'];
2535
 
2536
- // for bbb:
2537
- $wppa['slideframewidth'] = $gfs;
2538
- $wppa['slideframeheight'] = $gfh;
2539
 
2540
- if ( $wppa['portrait_only'] ) {
2541
  $result = 'width: ' . $gfs . 'px;'; // No height
2542
  }
2543
  else {
2544
  if ( wppa_page( 'oneofone' ) ) {
2545
- $h = floor( $gfs * wppa_get_photoy( $wppa['single_photo'] ) / wppa_get_photox( $wppa['single_photo'] ) );
2546
  $result .= 'height: ' . $h . 'px;';
2547
  }
2548
- elseif ( $wppa['auto_colwidth'] ) {
2549
  $result .= ' height: ' . $gfh . 'px;';
2550
  }
2551
- elseif ( $wppa['ss_widget_valign'] != '' && $wppa['ss_widget_valign'] != 'fit' ) {
2552
  $result .= ' height: ' . $gfh . 'px;';
2553
  }
2554
  elseif ( wppa_opt( 'fullvalign' ) == 'default' ) {
@@ -2591,15 +2478,14 @@ function wppa_get_thumb_frame_style( $glue = false, $film = '' ) {
2591
  }
2592
 
2593
  function wppa_get_thumb_frame_style_a( $glue = false, $film = '' ) {
2594
- global $wppa;
2595
- global $wppaerrmsgxxx;
2596
 
2597
- $album = $wppa['current_album'] ? wppa_cache_album( $wppa['current_album'] ) : false;
2598
 
2599
  $result = array( 'style'=> '', 'width' => '', 'height' => '' );
2600
 
2601
  // Comten alt display?
2602
- $com_alt = $wppa['is_comten'] && wppa_switch( 'comten_alt_display' ) && ! wppa_in_widget() && ! $film;
2603
 
2604
  $alt = ! $film && is_array( $album ) && $album['alt_thumbsize'] == 'yes' ? '_alt' : '';
2605
 
@@ -2646,15 +2532,15 @@ global $wppaerrmsgxxx;
2646
  }
2647
 
2648
  function wppa_get_container_width( $netto = false ) {
2649
- global $wppa;
2650
- if ( is_numeric( $wppa['fullsize'] ) && $wppa['fullsize'] > '0' ) {
2651
- $result = $wppa['fullsize'];
2652
  }
2653
  else {
2654
  $result = wppa_opt( 'colwidth' );
2655
  if ( $result == 'auto' ) {
2656
  $result = wppa_opt( 'initial_colwidth' ); //'640';
2657
- $wppa['auto_colwidth'] = true;
2658
  }
2659
  }
2660
  if ( $netto ) {
@@ -2678,32 +2564,31 @@ function wppa_get_thumbnail_area_delta() {
2678
  }
2679
 
2680
  function wppa_get_container_style() {
2681
- global $wppa;
2682
 
2683
  $result = '';
2684
 
2685
  // See if there is space for a margin
2686
  $marg = false;
2687
- if ( is_numeric( $wppa['fullsize'] ) ) {
2688
  $cw = wppa_opt( 'colwidth' );
2689
  if ( is_numeric( $cw ) ) {
2690
- if ( $cw > ( $wppa['fullsize'] + 10 ) ) {
2691
  $marg = '10px;';
2692
  }
2693
  }
2694
  }
2695
 
2696
  if ( ! wppa_in_widget() ) {
2697
- if ( $wppa['align'] == 'left' ) {
2698
  $result .= 'clear: left; ';
2699
  }
2700
- if ( $wppa['align'] == 'right' ) {
2701
  $result .= 'clear: right; ';
2702
  }
2703
  }
2704
 
2705
  $ctw = wppa_get_container_width();
2706
- if ( $wppa['auto_colwidth'] ) {
2707
  if ( is_feed() ) {
2708
  $result .= 'width:'.$ctw.'px;';
2709
  }
@@ -2712,13 +2597,13 @@ global $wppa;
2712
  $result .= 'width:'.$ctw.'px;';
2713
  }
2714
 
2715
- // if ( $wppa['align'] == '' ||
2716
- if ( $wppa['align'] == 'left' ) {
2717
  $result .= 'float: left;';
2718
  if ( $marg ) $result .= 'margin-right: '.$marg;
2719
  }
2720
- elseif ( $wppa['align'] == 'center' ) $result .= 'display: block; margin-left: auto; margin-right: auto;';
2721
- elseif ( $wppa['align'] == 'right' ) {
2722
  $result .= 'float: right;';
2723
  if ( $marg ) $result .= 'margin-left: '.$marg;
2724
  }
@@ -2729,7 +2614,6 @@ global $wppa;
2729
  }
2730
 
2731
  function wppa_get_curpage() {
2732
- global $wppa;
2733
 
2734
  if ( wppa_get_get( 'page' ) ) {
2735
  if ( wppa_in_widget() ) {
@@ -2748,7 +2632,6 @@ global $wppa;
2748
  }
2749
 
2750
  function wppa_container( $action ) {
2751
- global $wppa;
2752
  global $wppa_version; // The theme version ( wppa_theme.php )
2753
  global $wppa_microtime;
2754
  global $wppa_microtime_cum;
@@ -2766,47 +2649,49 @@ global $blog_id;
2766
 
2767
  // Open the container
2768
  if ( ! wppa( 'ajax' ) ) {
2769
- // $wppa['out'] .= '<!-- Start WPPA+ generated code'.( is_multisite() ? ', Multi site, id='.$blog_id : ', Single site' ).' -->';
2770
- // if ( $wppa['shortcode_content'] ) {
2771
- // $wppa['out'] .= '<!-- ' . $wppa['shortcode_content'] . ' -->';
2772
  // }
2773
- $wppa['out'] .= '<div' .
2774
- ' id="wppa-container-'.wppa( 'mocc' ).'"' .
2775
- ' style="'.wppa_get_container_style().'"' .
2776
- ' class="' .
2777
- 'wppa-container' . ' ' .
2778
- 'wppa-container-' . wppa( 'mocc' ) . ' ' .
2779
- 'wppa-rev-' . $wppa['revno'] . ' ' .
2780
- 'wppa-prevrev-' . wppa_opt( 'prevrev' ) . ' ' .
2781
- 'wppa-theme-' . $wppa_version . ' ' .
2782
- 'wppa-api-' . $wppa['api_version'] .
2783
- '"' .
2784
- ' >';
 
2785
  }
2786
 
2787
  // Spinner for Ajax
2788
  if ( wppa_switch( 'allow_ajax' ) ) {
2789
  if ( ! wppa_in_widget() ) {
2790
- $wppa['out'] .= '<img' .
2791
- ' id="wppa-ajax-spin-' . wppa( 'mocc' ) . '"' .
2792
- ' src="'.wppa_get_imgdir().'loader.gif"' .
2793
- ' alt="spinner"' .
2794
- ' style="' .
2795
- 'box-shadow:none;' .
2796
- 'z-index:1010;' .
2797
- 'position:fixed;' .
2798
- 'top:50%;' .
2799
- 'margin-top:-32px;' .
2800
- 'left:50%;' .
2801
- 'margin-left:-32px;' .
2802
- 'display:none;' .
2803
- '"' .
2804
- ' />' ;
 
2805
  }
2806
  }
2807
 
2808
  // Start timer if in debug mode
2809
- if ( $wppa['debug'] ) {
2810
  $wppa_microtime = - microtime( true );
2811
  wppa_dbg_q( 'init' );
2812
  }
@@ -2818,22 +2703,22 @@ global $blog_id;
2818
 
2819
  /* Check if wppa.js and jQuery are present */
2820
  if ( ! $wppa_err_displayed && ( WPPA_DEBUG || wppa_get_get( 'debug' ) || WP_DEBUG ) && ! wppa_switch( 'defer_javascript' ) ) {
2821
- $wppa['out'] .= '<script type="text/javascript">/* <![CDATA[ */';
2822
- $wppa['out'] .= "if ( typeof( _wppaSlides ) == 'undefined' ) " .
2823
- "alert( 'There is a problem with your theme. The file wppa.js is not loaded when it is expected ( Errloc = wppa_container ).' );";
2824
- $wppa['out'] .= "if ( typeof( jQuery ) == 'undefined' ) " .
2825
- "alert( 'There is a problem with your theme. The jQuery library is not loaded when it is expected ( Errloc = wppa_container ).' );";
2826
- $wppa['out'] .= "/* ]]> */</script>";
2827
  $wppa_err_displayed = true;
2828
  }
2829
 
2830
  /* Check if init is properly done */
2831
  if ( ! wppa_opt( 'fullsize' ) ) {
2832
- $wppa['out'] .= '<script type="text/javascript">/* <![CDATA[ */';
2833
- $wppa['out'] .= "alert( 'The initialisation of wppa+ is not complete yet. " .
2834
  "You will probably see division by zero errors. " .
2835
- "Please run Photo Albums -> Settings admin page Table VIII-A1. ( Errloc = wppa_container ).' );";
2836
- $wppa['out'] .= "/* ]]> */</script>";
2837
  }
2838
 
2839
  // Nonce field check for rating security
@@ -2862,20 +2747,20 @@ global $blog_id;
2862
  }
2863
  }
2864
 
2865
- $wppa['out'] .= wppa_nonce_field( 'wppa-check' , 'wppa-nonce', false, false );
2866
 
2867
- if ( wppa_page( 'oneofone' ) ) $wppa['portrait_only'] = true;
2868
  wppa( 'alt', 'alt' );
2869
 
2870
  // Javascript occurrence dependant stuff
2871
  wppa_add_js_page_data( "\n" . '<script type="text/javascript">' );
2872
- // $wppa['auto_colwidth'] is set by the filter or by wppa_albums in case called directly
2873
  // wppa_opt( 'colwidth' ) is the option setting
2874
  // script or call has precedence over option setting
2875
  // so: if set by script or call: auto, else if set by option: auto
2876
  $auto = false;
2877
  $contw = wppa_get_container_width();
2878
- if ( $wppa['auto_colwidth'] ) $auto = true;
2879
  elseif ( wppa_opt( 'colwidth' ) == 'auto' ) $auto = true;
2880
  elseif ( $contw > 0 && $contw <= 1.0 ) $auto = true;
2881
 
@@ -2904,9 +2789,9 @@ global $blog_id;
2904
  }
2905
 
2906
  // Aspect ratio and fullsize
2907
- if ( wppa_in_widget() == 'ss' && is_numeric( $wppa['in_widget_frame_width'] ) && $wppa['in_widget_frame_width'] > '0' ) {
2908
- $asp = $wppa['in_widget_frame_height'] / $wppa['in_widget_frame_width'];
2909
- $fls = $wppa['in_widget_frame_width'];
2910
  }
2911
  else {
2912
  $asp = wppa_opt( 'maxheight' ) / wppa_opt( 'fullsize' );
@@ -2956,7 +2841,7 @@ global $blog_id;
2956
  wppa_add_js_page_data( "\n" . 'wppaLightBox['.wppa( 'mocc' ).'] = "xxx";' );
2957
 
2958
  // If this occur is a slideshow, determine if its link is to lightbox. This may differ between normal slideshow or ss widget
2959
- $is_slphoto = $wppa['is_slide'] && $wppa['start_photo'] && $wppa['is_single'];
2960
  if ( 'ss' == wppa_in_widget() || wppa_page( 'slide' ) || $is_slphoto ) {
2961
  $ss_linktype = ( 'ss' == wppa_in_widget() ) ? wppa_opt( 'slideonly_widget_linktype' ) : wppa_opt( 'slideshow_linktype' );
2962
  switch ( $ss_linktype ) {
@@ -2981,75 +2866,71 @@ global $blog_id;
2981
  }
2982
  elseif ( $action == 'close' ) {
2983
 
2984
- if ( wppa_page( 'oneofone' ) ) $wppa['portrait_only'] = false;
2985
- if ( ! wppa_in_widget() ) $wppa['out'] .= ( '<div style="clear:both;"></div>' );
2986
 
2987
  // Add diagnostic <p> if debug is 1
2988
- if ( $wppa['debug'] == '1' && wppa( 'mocc' ) == '1' ) $wppa['out'] .= '<p id="wppa-debug-'.wppa( 'mocc' ).'" style="font-size:9px; color:#070; line-size:12px;" ></p>';
2989
 
2990
  // Init lightbox intermediate to facillitate premature clicks to lightbox when not yet document.complete
2991
- $wppa['out'] .= "\n" . '<script type="text/javascript" >if ( typeof(wppaInitOverlay) != "undefined" ) { wppaInitOverlay(); }</script>';
2992
 
2993
  if ( ! wppa( 'ajax' ) ) {
2994
- $wppa['out'] .= '<div id="wppa-container-' . wppa( 'mocc' ) . '-end" ></div>';
2995
- $wppa['out'] .= '</div>';
2996
- // $wppa['out'] .= "\n" . '<!-- End WPPA+ generated code -->';
2997
  }
2998
 
2999
- if ( $wppa['debug'] ) {
3000
  $laptim = $wppa_microtime + microtime( true );
3001
  $wppa_numqueries = get_num_queries() - $wppa_numqueries;
3002
  if ( !is_numeric( $wppa_microtime_cum ) ) $wppa_mcrotime_cum = '0';
3003
  $wppa_microtime_cum += $laptim;
3004
  wppa_dbg_msg( 'Time elapsed occ '.wppa( 'mocc' ).':'.substr( $laptim, 0, 5 ).'s. Tot:'.substr( $wppa_microtime_cum, 0, 5 ).'s.' );
3005
- wppa_dbg_msg( 'Number of queries occ '.wppa( 'mocc' ).':'.$wppa_numqueries, 'green' );
3006
  wppa_dbg_q( 'print' );
3007
  }
3008
  }
3009
  else {
3010
- $wppa['out'] .= "\n".'<span style="color:red;">Error, wppa_container() called with wrong argument: '.$action.'. Possible values: \'open\' or \'close\'</span>';
3011
  }
3012
  }
3013
 
3014
  function wppa_album_list( $action ) {
3015
- global $wppa;
3016
  global $cover_count;
3017
  global $cover_count_key;
3018
 
3019
  if ( $action == 'open' ) {
3020
  $cover_count = '0';
3021
  $cover_count_key = 'l';
3022
- $wppa['out'] .= '<div id="wppa-albumlist-'.wppa( 'mocc' ).'" class="albumlist">';
3023
  }
3024
  elseif ( $action == 'close' ) {
3025
- $wppa['out'] .= '</div>';
3026
  }
3027
  else {
3028
- $wppa['out'] .= '<span style="color:red;">Error, wppa_albumlist() called with wrong argument: '.$action.'. Possible values: \'open\' or \'close\'</span>';
3029
  }
3030
  }
3031
 
3032
  function wppa_thumb_list( $action ) {
3033
- global $wppa;
3034
  global $cover_count;
3035
  global $cover_count_key;
3036
 
3037
  if ( $action == 'open' ) {
3038
  $cover_count = '0';
3039
  $cover_count_key = 'l';
3040
- $wppa['out'] .= '<div id="wppa-thumblist-'.wppa( 'mocc' ).'" class="thumblist">';
3041
- if ( $wppa['current_album'] ) wppa_bump_viewcount( 'album', $wppa['current_album'] );
3042
  }
3043
  elseif ( $action == 'close' ) {
3044
- $wppa['out'] .= '</div>';
3045
  }
3046
  else {
3047
- $wppa['out'] .= '<span style="color:red;">Error, wppa_thumblist() called with wrong argument: '.$action.'. Possible values: \'open\' or \'close\'</span>';
3048
  }
3049
  }
3050
 
3051
  function wppa_get_npages( $type, $array ) {
3052
- global $wppa;
3053
 
3054
  $aps = wppa_get_pagesize( 'albums' );
3055
  $tps = wppa_get_pagesize( 'thumbs' );
@@ -3065,7 +2946,7 @@ global $wppa;
3065
  }
3066
  }
3067
  elseif ( $type == 'thumbs' ) {
3068
- if ( $wppa['is_cover'] == '1' ) { // Cover has no thumbs: 0 pages
3069
  $result = '0';
3070
  }
3071
  elseif ( $arraycount <= wppa_get_mincount() ) {
@@ -3103,29 +2984,29 @@ function wppa_popup() {
3103
  }
3104
 
3105
  function wppa_run_slidecontainer( $type = '' ) {
3106
- global $wppa;
3107
  global $thumbs;
3108
 
3109
- // if ( $wppa['is_filmonly'] ) return;
3110
 
3111
  $c = is_array( $thumbs ) ? count( $thumbs ) : '0';
3112
- wppa_dbg_msg( 'Running slidecontainer type '.$type.' with '.$c.' elements in thumbs, is_single='.$wppa['is_single'] );
3113
 
3114
- if ( $wppa['is_single'] && is_feed() ) { // process feed for single image slideshow here, normal slideshow uses filmthumbs
3115
- $style_a = wppa_get_fullimgstyle_a( $wppa['start_photo'] );
3116
  $style = $style_a['style'];
3117
  $width = $style_a['width'];
3118
  $height = $style_a['height'];
3119
- $imgalt = wppa_get_imgalt( $wppa['start_photo'] );
3120
- $wppa['out'] .= '<a href="' . get_permalink() . '">' .
3121
- '<img' .
3122
- ' src="' . wppa_get_photo_url( $wppa['start_photo'], '', $width, $height ) . '"' .
3123
- ' style="' . $style . '"' .
3124
- ' width="' . $width . '"' .
3125
- ' height="' . $height . '" ' .
3126
- $imgalt .
3127
- ' />' .
3128
- '</a>';
 
3129
  return;
3130
  }
3131
  elseif ( $type == 'slideshow' ) {
@@ -3146,7 +3027,7 @@ global $thumbs;
3146
  }
3147
 
3148
  // A requested photo id overrules the method. $startid >0 is requested photo id, -1 means: no id requested
3149
- if ( $wppa['start_photo'] ) $startid = $wppa['start_photo'];
3150
  else $startid = -1;
3151
 
3152
  // Create next ids
@@ -3165,11 +3046,9 @@ global $thumbs;
3165
 
3166
  foreach ( $thumbs as $thumb ) {
3167
  if ( wppa_switch( 'next_on_callback' ) ) {
3168
- // $wppa['out'] .=
3169
  wppa_add_js_page_data( "\n" . 'wppaStoreSlideInfo( ' . wppa_get_slide_info( $index, $thumb['id'], $thumb['next_id'] ) . ' );' );
3170
  }
3171
  else {
3172
- $wppa['out'] .=
3173
  wppa_add_js_page_data( "\n" . 'wppaStoreSlideInfo( ' . wppa_get_slide_info( $index, $thumb['id'] ) . ' );' );
3174
  }
3175
  if ( $startid == $thumb['id'] ) $startindex = $index; // Found the requested id, put the corresponding index in $startindex
@@ -3184,7 +3063,7 @@ global $thumbs;
3184
  wppa_add_js_page_data( "\n" . '<script type="text/javascript">' );
3185
 
3186
  // How to start if slideonly
3187
- if ( $wppa['is_slideonly'] ) {
3188
  if ( wppa_switch( 'start_slideonly' ) ) {
3189
  $startindex = -1; // There are no navigations, so start running, overrule everything
3190
  }
@@ -3194,8 +3073,8 @@ global $thumbs;
3194
  }
3195
 
3196
  // Vertical align
3197
- if ( $wppa['is_slideonly'] ) {
3198
- $ali = $wppa['ss_widget_valign'] ? $wppa['ss_widget_valign'] : $ali = 'fit';
3199
  wppa_add_js_page_data( "\n" . 'wppaFullValign['.wppa( 'mocc' ).'] = "'.$ali.'";' );
3200
  }
3201
  else {
@@ -3206,7 +3085,7 @@ global $thumbs;
3206
  wppa_add_js_page_data( "\n" . 'wppaFullHalign['.wppa( 'mocc' ).'] = "'.wppa_opt( 'fullhalign' ).'";' );
3207
 
3208
  // Portrait only ?
3209
- if ( $wppa['portrait_only'] ) {
3210
  wppa_add_js_page_data( "\n" . 'wppaPortraitOnly['.wppa( 'mocc' ).'] = true;' );
3211
  }
3212
 
@@ -3223,16 +3102,16 @@ global $thumbs;
3223
 
3224
  }
3225
  else {
3226
- $wppa['out'] .= '<span style="color:red;">' .
3227
- 'Error, wppa_run_slidecontainer() called with wrong argument: ' . $type . '. Possible values: \'single\' or \'slideshow\'' .
3228
- '</span>';
 
3229
  }
3230
  }
3231
 
3232
  function wppa_is_pagination() {
3233
- global $wppa;
3234
 
3235
- if ( ( wppa_get_pagesize( 'albums' ) == '0' && wppa_get_pagesize( 'thumbs' ) == '0' ) /* || $wppa['src'] */ ) return false;
3236
  else return true;
3237
  }
3238
 
@@ -3246,21 +3125,18 @@ function wppa_get_preambule() {
3246
  }
3247
 
3248
  function wppa_dummy_bar( $msg = '' ) {
3249
- global $wppa;
3250
 
3251
- $wppa['out'] .= '<div style="margin:4px 0; '.__wcs( 'wppa-box' ).__wcs( 'wppa-nav' ).'text-align:center;">'.$msg.'</div>';
3252
  }
3253
 
3254
  function wppa_rating_count_by_id( $id = '' ) {
3255
- global $wppa;
3256
 
3257
- $wppa['out'] .= wppa_get_rating_count_by_id( $id );
3258
  }
3259
 
3260
  function wppa_rating_by_id( $id = '', $opt = '' ) {
3261
- global $wppa;
3262
 
3263
- $wppa['out'] .= wppa_get_rating_by_id( $id, $opt );
3264
  }
3265
 
3266
  function wppa_get_cover_width( $type ) {
@@ -3275,7 +3151,6 @@ function wppa_get_cover_width( $type ) {
3275
  }
3276
 
3277
  function wppa_get_text_frame_style( $photo_left, $type ) {
3278
- global $wppa;
3279
 
3280
  if ( wppa_in_widget() ) {
3281
  $result = '';
@@ -3352,16 +3227,15 @@ global $cover_count_key;
3352
  }
3353
 
3354
  function wppa_get_cover_cols( $type ) {
3355
- global $wppa;
3356
 
3357
  $conwidth = wppa_get_container_width();
3358
 
3359
  $cols = ceil( $conwidth / wppa_opt( 'max_cover_width' ) );
3360
 
3361
  // Exceptions
3362
- if ( $wppa['auto_colwidth'] ) $cols = '1';
3363
- if ( ( $type == 'cover' ) && ( $wppa['album_count'] < '2' ) ) $cols = '1';
3364
- if ( ( $type == 'thumb' ) && ( $wppa['thumb_count'] < '2' ) ) $cols = '1';
3365
  return $cols;
3366
  }
3367
 
@@ -3406,9 +3280,8 @@ function wppa_force_balance_pee( $xtext ) {
3406
  }
3407
 
3408
  function wppa_mphoto() {
3409
- global $wppa;
3410
 
3411
- $id = $wppa['single_photo'];
3412
  $width = wppa_get_container_width();
3413
  $height = floor( $width / wppa_get_ratio( $id ) );
3414
  $usethumb = wppa_use_thumb_file( $id, $width, $height );
@@ -3419,7 +3292,7 @@ global $wppa;
3419
 
3420
  if ( ! wppa_in_widget() ) wppa_bump_viewcount( 'photo', $id );
3421
 
3422
- $autocol = $wppa['auto_colwidth'] || ( $width > 0 && $width <= 1.0 );
3423
 
3424
  // The initial width is $width if not autocol, else it should default to initial column width when auto
3425
  // or initial column width * fraction
@@ -3437,9 +3310,9 @@ global $wppa;
3437
 
3438
  // Open the pseudo container
3439
  $captwidth = $contwidth + '10';
3440
- $wppa['out'] .= '<div id="wppa-container-'.wppa( 'mocc' ).'" class="wppa-mphoto-'.wppa( 'mocc' ).' wp-caption';
3441
- if ( $wppa['align'] != '' ) $wppa['out'] .= ' align'.$wppa['align'];
3442
- $wppa['out'] .='" style="width: '.$captwidth.'px; position:relative;">';
3443
 
3444
  // The script for responsive
3445
  wppa_add_js_page_data( "\n" . '<script type="text/javascript">' );
@@ -3465,27 +3338,29 @@ global $wppa;
3465
  $audiohtml = esc_attr( wppa_get_audio_body( $id ) );
3466
  $videox = wppa_get_videox( $id );
3467
  $videoy = wppa_get_videoy( $id );
3468
- $wppa['out'] .= '<a' .
3469
- ' href="' . $link['url'] . '"' .
3470
- ( $lbtitle ? ' ' . wppa( 'lbtitle' ) . '="' . $lbtitle . '"' : '' ) .
3471
- ( $videohtml ? ' data-videohtml="' . $videohtml . '"' : '' ) .
3472
- ( $audiohtml ? ' data-audiohtml="' . $audiohtml . '"' : '' ) .
3473
- ( $videox ? ' data-videonatwidth="' . $videox . '"' : '' ) .
3474
- ( $videoy ? ' data-videonatheight="' . $videoy . '"' : '' ) .
3475
- ' ' . wppa( 'rel' ) . '="' . wppa_opt( 'lightbox_name' ) . '"' .
3476
- ( $link['target'] ? ' target="' . $link['target'] . '"' : '' ) .
3477
- ' class="thumb-img"' .
3478
- ' id="a-' . $id . '-' . wppa( 'mocc' ) . '"' .
3479
- ' >';
 
3480
  }
3481
  else {
3482
- $wppa['out'] .= '<a' .
3483
- ' href="' . $link['url'] . '"' .
3484
- ( $link['title'] ? ' title="' . $link['title'] . '"' : '' ) .
3485
- ( $link['target'] ? ' target="' . $link['target'] . '"' : '' ) .
3486
- ' class="thumb-img"' .
3487
- ' id="a-' . $id . '-' . wppa( 'mocc' ) . '"' .
3488
- ' >';
 
3489
  }
3490
  }
3491
 
@@ -3502,76 +3377,80 @@ global $wppa;
3502
 
3503
  if ( wppa_is_video( $id ) ) {
3504
  if ( $autocol ) {
3505
- $wppa['out'] .= wppa_get_video_html( array( 'id' => $id,
3506
- 'controls' => ! $link['is_lightbox'],
3507
- 'style' => $style,
3508
- 'class' => 'size-medium wppa-mphoto wppa-mimg-'.wppa( 'mocc' )
3509
- )
3510
- );
 
3511
  }
3512
  else {
3513
- $wppa['out'] .= wppa_get_video_html( array( 'id' => $id,
3514
- 'width' => $width,
3515
- 'height' => $height,
3516
- 'controls' => ! $link['is_lightbox'],
3517
- 'style' => $style,
3518
- 'class' => 'size-medium wppa-mphoto wppa-mimg-'.wppa( 'mocc' )
3519
- )
3520
- );
 
3521
  }
3522
  }
3523
  else {
3524
- $wppa['out'] .= '<img' .
3525
- ' src="' . $src . '"' .
3526
- ' ' . wppa_get_imgalt( $id ) .
3527
- ' style="' . $style . '"' .
3528
- ' class="size-medium wppa-mphoto wppa-mimg-' . wppa( 'mocc' ) . '"' .
3529
- ( $title ? ' title="' . $title . '"' : '' ) .
3530
- ' width="' . $width . '"' .
3531
- ' height="' . $height . '"' .
3532
- ' />';
 
3533
  }
3534
  if ( $link ) {
3535
- $wppa['out'] .= '</a>';
3536
  }
3537
 
3538
  // Add audio? mphoto
3539
  if ( wppa_has_audio( $id ) ) {
3540
- $wppa['out'] .= '<div style="position:relative;z-index:11;" >';
3541
-
3542
- $wppa['out'] .= wppa_get_audio_html( array(
3543
- 'id' => $id,
3544
- 'cursor' => 'cursor:pointer;',
3545
- 'style' => $style .
3546
- 'position:relative;' .
3547
- 'padding-top:0;' .
3548
- 'padding-bottom:0;' .
3549
- 'background-color:transparent;' .
3550
- 'border:none;' .
3551
- 'margin:0;' .
3552
- 'width:98%;',
3553
- 'class' => 'size-medium wp-caption wppa-mphoto_ wppa-mimg-' . wppa( 'mocc' ),
3554
- )
3555
- );
3556
- $wppa['out'] .= '</div>';
 
 
3557
  }
3558
 
3559
  // The subtitle
3560
- $wppa['out'] .= '<p class="wp-caption-text">' . wppa_get_photo_desc( $id ) . '</p>';
3561
 
3562
  // The share buttons
3563
  if ( wppa_switch( 'share_on_mphoto' ) ) {
3564
- $wppa['out'] .= wppa_get_share_html( $id, 'mphoto', false );
3565
  }
3566
 
3567
- $wppa['out'] .= '</div>';
3568
  }
3569
 
3570
  // Like mphoto but without the caption and with the fullsize background/border
3571
  function wppa_sphoto() {
3572
- global $wppa;
3573
 
3574
- $id = $wppa['single_photo'];
3575
  $width = wppa_get_container_width();
3576
  $height = floor( $width / wppa_get_ratio( $id ) );
3577
  $usethumb = wppa_use_thumb_file( $id, $width, $height );
@@ -3582,7 +3461,7 @@ global $wppa;
3582
 
3583
  if ( ! wppa_in_widget() ) wppa_bump_viewcount( 'photo', $id );
3584
 
3585
- $autocol = $wppa['auto_colwidth'] || ( $width > 0 && $width <= 1.0 );
3586
 
3587
  // The initial width is $width if not autocol, else it should default to initial column width when auto
3588
  // or initial column width * fraction
@@ -3599,10 +3478,15 @@ global $wppa;
3599
  }
3600
 
3601
  // Open the pseudo container
3602
- $wppa['out'] .= '<div id="wppa-container-'.wppa( 'mocc' ).'" class="';
3603
- if ( $wppa['align'] != '' ) $wppa['out'] .= ' align'.$wppa['align'];
3604
- $wppa['out'] .= ' wppa-sphoto-'.wppa( 'mocc' );
3605
- $wppa['out'] .='" style="width: '.$contwidth.'px; position:relative;">';
 
 
 
 
 
3606
 
3607
  // The script for responsive
3608
  wppa_add_js_page_data( "\n" . '<script type="text/javascript">' );
@@ -3619,7 +3503,7 @@ global $wppa;
3619
  wppa_add_js_page_data( "\n" . 'wppaTopMoc = '.wppa( 'mocc' ).';' );
3620
  wppa_add_js_page_data( "\n" . '</script>' );
3621
 
3622
- $wppa['portrait_only'] = true;
3623
  $fis = wppa_get_fullimgstyle_a( $id );
3624
  $width = $fis['width'];
3625
  $height = $fis['height'];
@@ -3635,27 +3519,29 @@ global $wppa;
3635
  $audiobody = esc_attr( wppa_get_audio_body( $id ) );
3636
  $videox = wppa_get_videox( $id );
3637
  $videoy = wppa_get_videoy( $id );
3638
- $wppa['out'] .= '<a' .
3639
- ' href="' . $link['url'] . '"' .
3640
- ( $lbtitle ? ' ' . wppa( 'lbtitle' ) . '="'.$lbtitle.'"' : '' ) .
3641
- ( $videobody ? ' data-videohtml="' . $videobody . '"' : '' ) .
3642
- ( $audiobody ? ' data-audiohtml="' . $audiobody . '"' : '' ) .
3643
- ( $videox ? ' data-videonatwidth="' . $videox . '"' : '' ) .
3644
- ( $videoy ? ' data-videonatheight="' . $videoy . '"' : '' ) .
3645
- ' ' . wppa( 'rel' ) . '="'.wppa_opt( 'lightbox_name' ).'"' .
3646
- ( $link['target'] ? ' target="' . $link['target'] . '"' : '' ) .
3647
- ' class="thumb-img"' .
3648
- ' id="a-' . $id . '-' . wppa( 'mocc' ) . '"' .
3649
- ' >';
 
3650
  }
3651
  else {
3652
- $wppa['out'] .= '<a' .
3653
- ' href="' . $link['url'] . '"' .
3654
- ' title="' . $link['title'] . '"' .
3655
- ' target="' . $link['target'] . '"' .
3656
- ' class="thumb-img"' .
3657
- ' id="a-' . $id . '-' . wppa( 'mocc' ) . '"' .
3658
- ' >';
 
3659
  }
3660
  }
3661
 
@@ -3668,68 +3554,71 @@ global $wppa;
3668
 
3669
  if ( wppa_is_video( $id ) ) {
3670
  if ( $autocol ) {
3671
- $wppa['out'] .= wppa_get_video_html( array( 'id' => $id,
3672
- 'controls' => ! $link['is_lightbox'],
3673
- 'style' => $style,
3674
- 'class' => 'size-medium wppa-sphoto wppa-simg-'.wppa( 'mocc' )
3675
- )
3676
- );
 
3677
  }
3678
  else {
3679
- $wppa['out'] .= wppa_get_video_html( array(
3680
- 'id' => $id,
3681
- 'width' => $width,
3682
- 'height' => $height,
3683
- 'controls' => ! $link['is_lightbox'],
3684
- 'style' => $style,
3685
- 'class' => 'size-medium wppa-sphoto wppa-simg-'.wppa( 'mocc' )
3686
- )
3687
- );
3688
  }
3689
  }
3690
  else {
3691
- $wppa['out'] .= '<img' .
3692
- ' src="' . $src . '"' .
3693
- ' ' . wppa_get_imgalt( $id ) .
3694
- ' class="size-medium wppa-sphoto wppa-simg-' . wppa( 'mocc' ) . '"' .
3695
- ' ' . wppa_get_imgalt( $id ) .
3696
- ( $title ? ' title="' . $title . '" ' : '' ) .
3697
- ' style="' . $style . '"' .
3698
- ( $autocol ? '' : ' width="' . $width . '" height="' . $height . '" ' ) .
3699
- '/>';
 
3700
  }
3701
 
3702
  // Close the link
3703
  if ( $link ) {
3704
- $wppa['out'] .= '</a>';
3705
  }
3706
 
3707
  // Add audio? sphoto
3708
  if ( wppa_has_audio( $id ) ) {
3709
- $wppa['out'] .= '<div style="position:relative;z-index:11;" >';
3710
  $margl = ( wppa_opt( 'wppa_fullimage_border_width' ) === '' ) ? 0 : wppa_opt( 'wppa_fullimage_border_width' ) + 1;
3711
  $margb = $margl;
3712
 
3713
- $wppa['out'] .= wppa_get_audio_html( array(
3714
- 'id' => $id,
3715
- 'cursor' => 'cursor:pointer;',
3716
- 'style' => $style .
3717
- 'position:absolute;' .
3718
- 'left:' . $margl . 'px;' .
3719
- 'bottom:' . $margb . 'px;' .
3720
- 'padding:0;' .
3721
- 'margin:0;' .
3722
- 'border:none;' .
3723
- 'height:' . wppa_get_audio_control_height() . 'px;' .
3724
- 'border-radius:0;',
3725
- 'class' => 'size-medium wppa-sphoto wppa-simg-'.wppa( 'mocc' ),
3726
- )
3727
- );
3728
- $wppa['out'] .= '</div>';
 
3729
  }
3730
 
3731
  // The pseudo container
3732
- $wppa['out'] .= '</div>';
3733
  }
3734
 
3735
  // returns aspect ratio ( w/h ), or 1 on error
@@ -3873,12 +3762,12 @@ global $allalbums;
3873
  // wppa_user_upload_on must be on for any of these functions to be enabled
3874
  function wppa_user_upload() {
3875
  global $wpdb;
3876
- global $wppa;
3877
 
3878
  wppa_dbg_msg( 'Usr_upl entered' );
3879
 
3880
- if ( $wppa['user_uploaded'] ) return; // Already done
3881
- $wppa['user_uploaded'] = true; // Mark as done
3882
 
3883
  // Upload possible?
3884
  $may_upload = wppa_switch( 'user_upload_on' );
@@ -4215,26 +4104,23 @@ function wppa_normalize_quotes( $xtext ) {
4215
 
4216
  // Find the search results. For use in a page template to show the search results. See ./theme/search.php
4217
  function wppa_have_photos( $xwidth = '0' ) {
4218
- global $wppa;
4219
 
4220
  if ( !is_search() ) return false;
4221
  $width = $xwidth ? $xwidth : wppa_get_container_width();
4222
 
4223
- $wppa['searchresults'] = wppa_albums( '', '', $width );
4224
 
4225
- return $wppa['any'];
4226
  }
4227
 
4228
  // Display the searchresults. For use in a page template to show the search results. See ./theme/search.php
4229
  function wppa_the_photos() {
4230
- global $wppa;
4231
 
4232
- if ( $wppa['any'] ) echo $wppa['searchresults'];
4233
  }
4234
 
4235
  // Decide if a thumbnail photo file can be used for a requested display
4236
  function wppa_use_thumb_file( $id, $width = '0', $height = '0' ) {
4237
- global $wpdb;
4238
 
4239
  if ( ! wppa_switch( 'use_thumbs_if_fit' ) ) return false;
4240
  if ( $width <= 1.0 && $height <= 1.0 ) return false; // should give at least one dimension and not when fractional
@@ -4242,8 +4128,6 @@ global $wpdb;
4242
  $file = wppa_get_thumb_path( $id );
4243
  if ( file_exists( $file ) ) {
4244
  $size = wppa_get_imagexy( $id, 'thumb' );
4245
- // $size['0'] = wppa_get_thumbx( $id );
4246
- // $size['1'] = wppa_get_thumby( $id );
4247
  }
4248
  else return false;
4249
 
@@ -4316,7 +4200,6 @@ global $wpdb;
4316
 
4317
  // Get the title to be used for lightbox links == thext under the lightbox image
4318
  function wppa_get_lbtitle( $type, $id ) {
4319
- global $wppa;
4320
 
4321
  if ( ! is_numeric( $id ) || $id < '1' ) wppa_dbg_msg( 'Invalid arg wppa_get_lbtitle( '.$id.' )', 'red' );
4322
 
3
  * Package: wp-photo-album-plus
4
  *
5
  * Various funcions
6
+ * Version 6.3.9
7
  *
8
  */
9
 
13
  // This is the main entrypoint for the wppa+ invocation, either 'by hand' or through the filter.
14
  // As of version 3.0.0 this routine returns the entire html created by the invocation.
15
  function wppa_albums( $id = '', $type = '', $size = '', $align = '' ) {
 
16
  global $wppa_lang;
17
  global $wppa_locale;
18
  global $wpdb;
21
 
22
  // Diagnostics
23
  wppa_dbg_msg( 'Entering wppa_albums' );
24
+ wppa_dbg_msg( 'Lang=' . $wppa_lang . ', Locale=' . $wppa_locale . ', Ajax=' . wppa( 'ajax' ) );
25
+ wppa_dbg_msg( '$wppa_session = ' . serialize( $wppa_session ) );
26
 
27
  // List content filters
28
  // Data struct: $wp_filter[$tag][$priority][$idx] = array( 'function' => $function_to_add, 'accepted_args' => $accepted_args );
129
  }
130
  if ( wppa( 'is_related' ) == 'desc' ) {
131
  wppa( 'src', true );
132
+ if ( wppa( 'related_count' ) == '0' ) wppa( 'related_count', wppa_opt( 'related_count' ) );
133
+ wppa( 'searchstring', str_replace( ';', ',', wppa_get_related_data() ) );
134
+ wppa( 'photos_only', true );
135
  }
136
+ if ( wppa( 'is_tag' ) ) wppa_dbg_msg( 'Is Tag: ' . wppa( 'is_tag' ) );
137
  else wppa_dbg_msg( 'Is NOT Tag' );
138
+ wppa( 'page', wppa_get_get( 'page' ) );
139
  if ( wppa_get_get( 'superview' ) ) {
140
+ $wppa_session['superview'] = wppa( 'is_slide' ) ? 'slide': 'thumbs';
141
+ $wppa_session['superalbum'] = wppa( 'start_album' );
142
+ wppa_save_session();
143
+ wppa( 'photos_only', true );
144
+ }
145
+ wppa( 'is_upldr', wppa_get_get( 'upldr' ) );
146
+ if ( wppa( 'is_upldr' ) ) wppa( 'photos_only', true );
147
+ wppa( 'is_owner', wppa_get_get( 'owner' ) );
148
+ if ( wppa( 'is_owner' ) ) {
149
+ $albs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_ALBUMS."` WHERE `owner` = %s ", wppa( 'is_owner' ) ), ARRAY_A );
150
  wppa_dbg_q( 'Q-Main-1' );
151
  wppa_cache_album( 'add', $albs );
152
  $id = '';
154
  $id .= $alb['id'].'.';
155
  }
156
  $id = rtrim( $id, '.' );
157
+ wppa( 'start_album', $id );
158
  }
159
+ wppa( 'supersearch', strip_tags( wppa_get_get( 'supersearch' ) ) );
160
+ $wppa_session['supersearch'] = wppa( 'supersearch' );
161
+ wppa_save_session();
162
+ if ( wppa( 'supersearch' ) ) {
163
+ $ss_info = explode( ',', wppa( 'supersearch' ) );
164
  if ( $ss_info['0'] == 'a' ) {
165
+ wppa( 'albums_only', true );
166
  }
167
  else {
168
+ wppa( 'photos_only', true );
169
  }
170
  }
171
+ wppa( 'calendar', strip_tags( wppa_get_get( 'calendar' ) ) );
172
+ wppa( 'caldate', strip_tags( wppa_get_get( 'caldate' ) ) );
173
  }
174
 
175
  // 2. wppa_albums is called directly. Assume any arg. If not, no worry, system defaults are used == generic
180
  if ( $type == 'album' ) {
181
  }
182
  elseif ( $type == 'cover' ) {
183
+ wppa( 'is_cover', true );
184
  }
185
  elseif ( $type == 'slide' ) {
186
+ wppa( 'is_slide', true );
187
  }
188
  elseif ( $type == 'slideonly' ) {
189
+ wppa( 'is_slideonly', true );
190
  }
191
 
192
  if ( $type == 'photo' || $type == 'mphoto' || $type == 'slphoto' ) { // Any type of single photo? id given is photo id
193
+ if ( $id ) wppa( 'single_photo', $id );
194
  }
195
  else { // Not single photo: id given is album id
196
+ if ( $id ) wppa( 'start_album', $id );
197
  }
198
  }
199
 
200
  // 3. The filter supplied the data
201
  else {
202
+ if ( wppa( 'bestof' ) ) {
203
+ $args = wppa( 'bestof_args' );
204
  wppa_bestof_box ( $args );
205
+ $out = wppa( 'out' );
 
206
  wppa_reset_occurrance();
207
  return $out;
208
  }
209
+ elseif ( wppa( 'is_landing' ) && ! wppa( 'src' ) ) {
210
  wppa_dbg_msg( 'Nothing to do...' );
211
  wppa_reset_occurrance();
212
  return ''; // Do nothing on a landing page without a querystring while it is also not a search operation
213
  }
214
+ elseif ( wppa( 'is_autopage' ) ) {
215
+ $photo = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `".WPPA_PHOTOS."` WHERE `page_id` = %d LIMIT 1", get_the_ID() ) );
216
+ wppa( 'single_photo', $photo );
217
  wppa_dbg_q( 'Q-main-2' );
218
+ if ( ! wppa( 'single_photo' ) ) {
219
  wppa_dbg_msg( 'No photo found for page '.get_the_ID(), 'red', 'force' );
220
  wppa_reset_occurrance();
221
  return ''; // Give up
225
  case 'photo':
226
  break;
227
  case 'mphoto':
228
+ wppa( 'is_mphoto', true );
229
  break;
230
  case 'slphoto':
231
+ wppa( 'is_slide', true );
232
+ wppa( 'start_photo', wppa( 'single_photo' ) );
233
+ wppa( 'is_single', true );
234
  break;
235
  default:
236
  wppa_dbg_msg( 'Unimplemented type autopage display: '.$type, 'red', 'force' );
240
 
241
  // Convert any keywords and / or names to numbers
242
  // Search for album keyword
243
+ if ( wppa( 'start_album' ) && ! wppa_is_int( wppa( 'start_album' ) ) ) {
244
+ if ( substr( wppa( 'start_album' ), 0, 1 ) == '#' ) { // Keyword
245
+ $keyword = wppa( 'start_album' );
246
  if ( strpos( $keyword, ',' ) ) $keyword = substr( $keyword, 0, strpos( $keyword, ',' ) );
247
+ switch ( $keyword ) { // ( substr( wppa( 'start_album'], 0, 5 ) ) {
248
  case '#last': // Last upload
249
  $id = wppa_get_youngest_album_id();
250
+ if ( wppa( 'is_cover' ) ) { // To make sure the ordering sequence is ok.
251
+ $temp = explode( ',', wppa( 'start_album' ) );
252
+ if ( isset( $temp['1'] ) ) wppa( 'last_albums_parent', $temp['1'] );
253
+ else wppa( 'last_albums_parent', '0' );
254
+ if ( isset( $temp['2'] ) ) wppa( 'last_albums', $temp['2'] );
255
+ else wppa( 'last_albums', false );
256
  }
257
  else { // Ordering seq is not important, convert to album enum
258
+ $temp = explode( ',', wppa( 'start_album' ) );
259
  if ( isset( $temp['1'] ) ) $parent = wppa_album_name_to_number( $temp['1'] );
260
  else $parent = '0';
261
  if ( $parent === false ) return;
287
  }
288
  break;
289
  case '#topten':
290
+ $temp = explode( ',', wppa( 'start_album' ) );
291
  $id = isset( $temp[1] ) ? $temp[1] : '0';
292
+ wppa( 'topten_count', isset( $temp[2] ) ? $temp[2] : wppa_opt( 'topten_count' ) );
293
+ wppa( 'is_topten', true );
294
+ if ( wppa( 'is_cover' ) ) {
295
+ wppa_dbg_msg( 'A topten album has no cover. ' . wppa( 'start_album' ), 'red', 'force' );
296
  wppa_reset_occurrance();
297
  return; // Give up this occurence
298
  }
299
  break;
300
  case '#lasten':
301
+ $temp = explode( ',', wppa( 'start_album' ) );
302
  $id = isset( $temp[1] ) ? $temp[1] : '0';
303
+ wppa( 'lasten_count', isset( $temp[2] ) ? $temp[2] : wppa_opt( 'lasten_count' ) );
304
+ wppa( 'is_lasten', true );
305
+ if ( wppa( 'is_cover' ) ) {
306
+ wppa_dbg_msg( 'A lasten album has no cover. ' . wppa( 'start_album' ), 'red', 'force' );
307
  wppa_reset_occurrance();
308
  return; // Give up this occurence
309
  }
310
  break;
311
  case '#comten':
312
+ $temp = explode( ',', wppa( 'start_album' ) );
313
  $id = isset( $temp[1] ) ? $temp[1] : '0';
314
+ wppa( 'comten_count', isset( $temp[2] ) ? $temp[2] : wppa_opt( 'comten_count' ) );
315
+ wppa( 'is_comten', true );
316
+ if ( wppa( 'is_cover' ) ) {
317
+ wppa_dbg_msg( 'A comten album has no cover. ' . wppa( 'start_album' ), 'red', 'force' );
318
  wppa_reset_occurrance();
319
  return; // Give up this occurence
320
  }
321
  break;
322
  case '#featen':
323
+ $temp = explode( ',', wppa( 'start_album' ) );
324
  $id = isset( $temp[1] ) ? $temp[1] : '0';
325
+ wppa( 'featen_count', isset( $temp[2] ) ? $temp[2] : wppa_opt( 'featen_count' ) );
326
+ wppa( 'is_featen', true );
327
+ if ( wppa( 'is_cover' ) ) {
328
+ wppa_dbg_msg( 'A featen album has no cover. ' . wppa( 'start_album' ), 'red', 'force' );
329
  wppa_reset_occurrance();
330
  return; // Give up this occurence
331
  }
332
  break;
333
  case '#related':
334
+ $temp = explode( ',', wppa( 'start_album' ) );
335
  $type = isset( $temp[1] ) ? $temp[1] : 'tags'; // tags is default type
336
+ wppa( 'related_count', isset( $temp[2] ) ? $temp[2] : wppa_opt( 'related_count' ) );
337
+ wppa( 'is_related', $type );
338
 
339
  $data = wppa_get_related_data();
340
 
341
  if ( $type == 'tags' ) {
342
+ wppa( 'is_tag', $data );
343
  }
344
  if ( $type == 'desc' ) {
345
+ wppa( 'src', true );
346
+ wppa( 'searchstring', str_replace( ';', ',', $data ) );
347
+ wppa( 'photos_only', true );
348
  }
349
+ wppa( 'photos_only', true );
350
+ $id = '0';
351
  break;
352
  case '#tags':
353
+ wppa( 'is_tag', wppa_sanitize_tags( substr( wppa( 'start_album' ), 6 ), true ) );
354
+ $id = '0';
355
+ wppa( 'photos_only', true );
356
  break;
357
  case '#cat':
358
+ $temp = explode( ',', wppa( 'start_album' ) );
359
  $cat = isset( $temp[1] ) ? $temp[1] : '';
360
  $cat = trim( wppa_sanitize_tags( $cat ), ',' );
361
+ wppa( 'is_cat', $cat );
362
  if ( ! $cat ) {
363
+ wppa_dbg_msg( 'Missing cat #cat album spec: ' . wppa( 'start_album' ), 'red', 'force' );
364
  wppa_reset_occurrance();
365
  return; // Forget this occurrance
366
  }
377
  $id = rtrim( $id, '.' );
378
  break;
379
  case '#owner':
380
+ $temp = explode( ',', wppa( 'start_album' ) );
381
  $owner = isset( $temp[1] ) ? $temp[1] : '';
382
  if ( $owner == '#me' ) {
383
  if ( is_user_logged_in() ) $owner = wppa_get_user();
387
  }
388
  }
389
  if ( ! $owner ) {
390
+ wppa_dbg_msg( 'Missing owner in #owner album spec: ' . wppa( 'start_album' ), 'red', 'force' );
391
  wppa_reset_occurrance();
392
  return; // Forget this occurrance
393
  }
416
  // return; // No children found
417
  }
418
  }
419
+ wppa( 'is_owner', $owner );
420
  break;
421
  case '#upldr':
422
+ $temp = explode( ',', wppa( 'start_album' ) );
423
  $owner = isset( $temp[1] ) ? $temp[1] : '';
424
  if ( $owner == '#me' ) {
425
  if ( is_user_logged_in() ) $owner = wppa_get_user();
429
  }
430
  }
431
  if ( ! $owner ) {
432
+ wppa_dbg_msg( 'Missing owner in #upldr album spec: ' . wppa( 'start_album' ), 'red', 'force' );
433
  wppa_reset_occurrance();
434
  return; // Forget this occurrance
435
  }
436
  $parent = isset( $temp[2] ) ? wppa_album_name_to_number( $temp[2] ) : '0';
437
  if ( $parent === false ) return; // parent specified but not a valid value
438
  if ( $parent ) { // Valid parent spec
 
439
  $id = wppa_alb_to_enum_children( wppa_expand_enum( $parent ) );
440
  if ( ! $id ) {
441
  wppa_reset_occurrance();
445
  else { // No parent spec
446
  $id = '0';
447
  }
448
+ wppa( 'is_upldr', $owner );
449
+ wppa( 'photos_only', true );
450
  break;
451
  case '#all':
452
  $id = '-2';
453
  break;
454
  default:
455
+ wppa_dbg_msg( 'Unrecognized album keyword found: ' . wppa( 'start_album' ), 'red', 'force' );
456
  wppa_reset_occurrance();
457
  return; // Forget this occurrance
458
  }
459
+ wppa( 'start_album', $id );
460
  }
461
  }
462
 
463
  // See if the album id is a name and convert it if possible
464
+ wppa( 'start_album', wppa_album_name_to_number( wppa( 'start_album' ) ) );
465
+ if ( wppa( 'start_album' ) === false ) {
466
+ wppa_reset_occurrance();
467
+ return;
468
+ }
469
+
470
  // Also for parents
471
+ wppa( 'last_albums_parent', wppa_album_name_to_number( wppa( 'last_albums_parent' ) ) );
472
+ if ( wppa( 'last_albums_parent' ) === false ) {
473
+ wppa_reset_occurrance();
474
+ return;
475
+ }
476
 
477
  // Check if album is valid
478
+ if ( strpos( wppa( 'start_album' ), '.' ) !== false ) { // Album may be enum
479
+ if ( ! wppa_series_to_array( wppa( 'start_album' ) ) ) { // Syntax error
480
  wppa_reset_occurrance();
481
  return;
482
  }
483
  }
484
 
485
  // Album must be numeric
486
+ elseif ( wppa( 'start_album' ) && ! is_numeric( wppa( 'start_album' ) ) ) {
487
+ wppa_stx_err( 'Unrecognized Album identification found: ' . wppa( 'start_album' ) );
488
  wppa_reset_occurrance();
489
  return; // Forget this occurrance
490
  }
491
 
492
  // Album must exist
493
+ elseif ( wppa( 'start_album' ) > '0' ) { // -2 is #all
494
+ if ( ! wppa_album_exists( wppa( 'start_album' ) ) ) {
495
+ wppa_stx_err( 'Album does not exist: ' . wppa( 'start_album' ) );
496
  wppa_reset_occurrance();
497
  return; // Forget this occurrance
498
  }
499
  }
500
 
501
  // See if the photo id is a keyword and convert it if possible
502
+ if ( wppa( 'single_photo' ) && ! is_numeric( wppa( 'single_photo' ) ) ) {
503
+ if ( substr( wppa( 'single_photo' ), 0, 1 ) == '#' ) { // Keyword
504
+ switch ( wppa( 'single_photo' ) ) {
505
  case '#potd': // Photo of the day
506
  $t = wppa_get_potd();
507
  if ( is_array( $t ) ) $id = $t['id'];
511
  $id = wppa_get_youngest_photo_id();
512
  break;
513
  default:
514
+ wppa_dbg_msg( 'Unrecognized photo keyword found: ' . wppa( 'single_photo' ), 'red', 'force' );
515
  wppa_reset_occurrance();
516
  return; // Forget this occurrance
517
  }
518
+ wppa( 'single_photo', $id );
519
  }
520
  }
521
 
522
  // See if the photo id is a name and convert it if possible
523
+ if ( wppa( 'single_photo' ) && ! is_numeric( wppa( 'single_photo' ) ) ) {
524
+ if ( substr( wppa( 'single_photo' ), 0, 1 ) == '$' ) { // Name
525
+ $id = wppa_get_photo_id_by_name( substr( wppa( 'single_photo' ), 1 ) );
526
+ if ( $id > '0' ) wppa( 'single_photo', $id );
527
  else {
528
+ wppa_dbg_msg( 'Photo name not found: ' . wppa( 'single_photo' ), 'red', 'force' );
529
  wppa_reset_occurrance();
530
  return; // Forget this occurrance
531
  }
534
 
535
  // Size and align
536
  if ( is_numeric( $size ) ) {
537
+ wppa( 'fullsize', $size );
538
  }
539
  elseif ( $size == 'auto' ) {
540
+ wppa( 'auto_colwidth', true );
541
  }
542
  if ( $align == 'left' || $align == 'center' || $align == 'right' ) {
543
+ wppa( 'align', $align );
544
  }
545
 
546
  // Empty related shortcode?
547
+ if ( wppa( 'is_related' ) ) {
548
  $thumbs = wppa_get_thumbs();
549
  if ( empty( $thumbs ) ) {
550
  wppa_errorbox( __( 'No related photos found.', 'wp-photo-album-plus') );
551
+ $result = wppa( 'out' );
552
  wppa_reset_occurrance(); // Forget this occurrance
553
  return $result;
554
  }
555
  }
556
 
557
  // Subsearch or rootsearch?
558
+ if ( wppa( 'occur' ) == '1' && $wppa_session['has_searchbox'] && ! wppa( 'in_widget' ) ) {
559
 
560
  // Is it a search now?
561
+ if ( wppa( 'src' ) ) {
562
 
563
  // Is the subsearch box checked?
564
+ wppa( 'is_subsearch', wppa_get_get( 'subsearch' ) || wppa_get_post( 'subsearch' ) );
565
 
566
  // Is the rootsearch box checked?
567
+ wppa( 'is_rootsearch', wppa_get_get( 'rootsearch' ) || wppa_get_post( 'rootsearch' ) );
568
 
569
  // No rootsearch, forget previous root
570
+ if ( ! wppa( 'is_rootsearch' ) ) {
571
  $wppa_session['search_root'] = '0';
572
+ wppa_save_session();
573
  }
574
 
575
  }
579
 
580
  // Find new potential searchroot
581
  if ( isset( $_REQUEST['wppa-searchroot'] ) ) {
582
+ wppa( 'start_album', strval( intval( $_REQUEST['wppa-searchroot'] ) ) );
583
  }
584
 
585
  // Update session with new searchroot
586
+ $wppa_session['search_root'] = wppa( 'start_album' );
587
+ wppa_save_session();
588
 
589
  }
590
 
591
  // Update searchroot in search boxes
592
  $rt = $wppa_session['search_root'];
593
  if ( ! $rt ) $rt = '0'; // must be non-empty string
594
+ wppa_add( 'src_script', 'jQuery(document).ready(function(){wppaUpdateSearchRoot( \'' . esc_js( wppa_display_root( $rt ) ) . '\', ' . $rt . ' )});' );
 
 
 
 
595
 
596
  // If not search forget previous results
597
+ if ( ! wppa( 'src' ) ) {
598
  $wppa_session['use_searchstring'] = '';
599
  $wppa_session['display_searchstring'] = '';
600
+ wppa_save_session();
601
+ wppa_add( 'src_script', "\n" . 'jQuery(document).ready(function(){wppaClearSubsearch()});' );
 
 
 
602
  }
603
  else { // Enable subbox
604
+ wppa_add( 'src_script', 'jQuery(document).ready(function(){wppaEnableSubsearch()});' );
 
 
 
 
605
  }
606
  }
607
 
608
  // Is is a stereo settings box?
609
+ if ( wppa( 'is_stereobox' ) ) {
610
  wppa_stereo_box();
611
  }
612
  // Is it the search box?
613
+ elseif ( wppa( 'is_searchbox' ) ) {
614
+ wppa_search_box( '', wppa( 'may_sub' ), wppa( 'may_root' ) );
615
  }
616
  // Is it the superview box?
617
+ elseif ( wppa( 'is_superviewbox' ) ) {
618
+ wppa_superview_box( wppa( 'start_album' ) );
619
  }
620
  // Is it the multitag box?
621
+ elseif ( wppa( 'is_multitagbox' ) ) {
622
+ wppa_multitag_box( wppa( 'tagcols' ), wppa( 'taglist' ) );
623
  }
624
  // Is it the tagcloud box?
625
+ elseif ( wppa( 'is_tagcloudbox' ) ) {
626
+ wppa_tagcloud_box( wppa( 'taglist' ), wppa_opt( 'tagcloud_min' ), wppa_opt( 'tagcloud_max' ) );
627
  }
628
  // Is it an upload box?
629
+ elseif ( wppa( 'is_upload' ) ) {
630
  wppa_upload_box();
631
  }
632
  // Is it a supersearch box?
633
+ elseif ( wppa( 'is_supersearch' ) ) {
634
  wppa_supersearch_box();
635
  }
636
  // Is it newstyle single photo mediastyle?
637
+ elseif ( wppa( 'is_mphoto' ) == '1' ) {
638
+ if ( wppa( 'is_autopage' ) ) wppa_auto_page_links( 'top' );
639
  wppa_mphoto();
640
+ if ( wppa( 'is_autopage' ) ) wppa_auto_page_links( 'bottom' );
641
  }
642
  // Is it newstyle single photo plain?
643
  elseif ( wppa_page( 'oneofone' ) ) {
644
+ if ( wppa( 'is_autopage' ) ) wppa_auto_page_links( 'top' );
645
  wppa_sphoto();
646
+ if ( wppa( 'is_autopage' ) ) wppa_auto_page_links( 'bottom' );
647
  }
648
  // Is it the calendar?
649
+ elseif ( wppa( 'is_calendar' ) ) {
650
  wppa_calendar_box();
651
  }
652
  // The normal case
653
  else {
654
  if ( function_exists( 'wppa_theme' ) ) {
655
+ if ( wppa( 'is_autopage' ) ) wppa_auto_page_links( 'top' );
656
  wppa_theme(); // Call the theme module
657
+ if ( wppa( 'is_autopage' ) ) wppa_auto_page_links( 'bottom' );
658
  }
659
+ else wppa_out( '<span style="color:red">ERROR: Missing function wppa_theme(), check the installation of WPPA+. Remove customized wppa_theme.php</span>' );
660
  global $wppa_version;
661
  $expected_version = '6-2-7-000';
662
  if ( $wppa_version != $expected_version ) {
663
+ wppa_dbg_msg( 'WARNING: customized wppa-theme.php is out of rev. Expected version: ' . $expected_version . ' found: ' . $wppa_version, 'red' );
664
  }
665
  }
 
 
 
666
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
667
  // Done
668
+ $out = str_replace( 'w#location', wppa( 'geo' ), wppa( 'out' ) );
669
 
670
  // Reset
 
 
671
  wppa_reset_occurrance();
672
  return $out;
673
  }
707
  return $data;
708
  }
709
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
710
  // Determine in wich theme page we are, Album covers, Thumbnails or slideshow
711
  function wppa_page( $page ) {
 
712
 
713
  if ( wppa_in_widget() ) {
714
  $occur = wppa_get_get( 'woccur' );
717
  $occur = wppa_get_get( 'occur' );
718
  }
719
 
720
+ $ref_occur = wppa_in_widget() ? wppa( 'widget_occur' ) : wppa( 'occur' );
721
 
722
+ if ( wppa( 'is_slide' ) ) $cur_page = 'slide'; // Do slide or single when explixitly on
723
+ elseif ( wppa( 'is_slideonly' ) ) $cur_page = 'slide'; // Slideonly is a subset of slide
724
+ elseif ( is_numeric( wppa( 'single_photo' ) ) ) $cur_page = 'oneofone';
725
  else $cur_page = 'albums';
726
 
727
  if ( $cur_page == $page ) return true; else return false;
730
  // loop album
731
  function wppa_get_albums() {
732
  global $wpdb;
 
733
  global $wppa_session;
734
 
735
+ wppa_dbg_msg( 'get_albums entered: ' . wppa( 'mocc' ) . ' Start_album=' . wppa('start_album') . ', Cover=' . wppa( 'is_cover' ) );
736
 
737
+ if ( wppa( 'is_topten' ) ) return false;
738
+ if ( wppa( 'is_lasten' ) ) return false;
739
+ if ( wppa( 'is_comten' ) ) return false;
740
+ if ( wppa( 'is_featen' ) ) return false;
741
+ if ( wppa( 'is_tag' ) ) return false;
742
+ if ( wppa( 'photos_only' ) ) return false;
743
 
744
+ if ( wppa( 'src' ) && wppa_switch( 'photos_only' ) ) return false;
745
+ if ( wppa( 'is_owner' ) && ! wppa( 'start_album' ) ) return false; // No owner album( s )
746
 
747
+ if ( wppa( 'calendar' ) == 'exifdtm' ) return false;
748
+ if ( wppa( 'calendar' ) == 'timestamp' ) return false;
749
+ if ( wppa( 'calendar' ) == 'modified' ) return false;
750
 
751
  // Supersearch?
752
+ if ( wppa( 'supersearch' ) ) {
753
+ $ss_data = explode( ',', wppa( 'supersearch' ) );
754
  $data = $ss_data['3'];
755
  switch ( $ss_data['1'] ) {
756
 
818
  }
819
 
820
  // Search?
821
+ elseif ( wppa( 'src' ) ) {
822
  $final_array = array();
823
+ $chunks = explode( ',', stripslashes( strtolower( wppa( 'searchstring' ) ) ) );
824
  // all chunks
825
  foreach ( $chunks as $chunk ) if ( strlen( trim( $chunk ) ) ) {
826
  $words = wppa_index_raw_to_words( $chunk );
873
  }
874
 
875
  // Rootsearch?
876
+ if ( wppa( 'is_rootsearch' ) ) {
877
  $root = $wppa_session['search_root'];
878
  if ( is_array( $albums ) ) {
879
  $c1=count( $albums );
897
  }
898
  }
899
 
900
+ if ( is_array( $albums ) ) wppa( 'any', true );
901
  }
902
  else { // Its not search
903
+ $id = wppa( 'start_album' );
904
  if ( ! $id ) $id = '0';
905
 
906
  // Do the query
907
  if ( $id == '-2' ) { // All albums
908
+ if ( wppa( 'is_cover' ) ) {
909
  $q = "SELECT * FROM `".WPPA_ALBUMS."` ".wppa_get_album_order();
910
  wppa_dbg_q( 'Q11d' );
911
  $albums = $wpdb->get_results( $q, ARRAY_A );
912
  }
913
  else $albums = false;
914
  }
915
+ elseif ( wppa( 'last_albums' ) ) { // is_cover = true. For the order sequence, see remark in wppa_albums()
916
+ if ( wppa( 'last_albums_parent' ) ) {
917
+ $q = $wpdb->prepare( "SELECT * FROM `".WPPA_ALBUMS."` WHERE `a_parent` = %s ORDER BY `timestamp` DESC LIMIT %d", wppa( 'last_albums_parent' ), wppa( 'last_albums' ) );
918
  }
919
  else {
920
+ $q = $wpdb->prepare( "SELECT * FROM `".WPPA_ALBUMS."` ORDER BY `timestamp` DESC LIMIT %d", wppa( 'last_albums' ) );
921
  }
922
  wppa_dbg_q( 'Q11a' );
923
  $albums = $wpdb->get_results( $q, ARRAY_A );
924
  }
925
  elseif ( wppa_is_int( $id ) ) {
926
+ if ( wppa( 'is_cover' ) ) {
927
  $q = $wpdb->prepare( 'SELECT * FROM ' . WPPA_ALBUMS . ' WHERE `id` = %s', $id );
928
  }
929
  else {
931
  }
932
  wppa_dbg_q( 'Q11b' );
933
  $albums = $wpdb->get_results( $q, ARRAY_A );
934
+ if ( ! wppa( 'is_cover' ) ) {
935
  wppa_verify_treecounts( $id, 'albums', count( $albums ) );
936
  }
937
  }
938
  elseif ( strpos( $id, '.' ) !== false ) { // Album enum
939
  $ids = wppa_series_to_array( $id );
940
+ if ( wppa( 'is_cover' ) ) {
941
  $q = "SELECT * FROM `".WPPA_ALBUMS."` WHERE `id` = ".implode( " OR `id` = ", $ids )." ".wppa_get_album_order();
942
  }
943
  else {
967
  wppa_cache_album( 'add', $albums );
968
  }
969
 
970
+ wppa( 'album_count', count( $albums ) );
971
  return $albums;
972
  }
973
 
1390
  if ( ! is_user_logged_in() ) $status .= " AND `status` <> 'private'";
1391
 
1392
  $searchstring = wppa( 'searchstring' );
1393
+ if ( ! empty ( $wppa_session['use_searchstring'] ) ) $searchstring = $wppa_session['use_searchstring'];
1394
 
1395
  $final_array = array();
1396
  $chunks = explode( ',', stripslashes( strtolower( $searchstring ) ) );
1683
  // get slide info
1684
  function wppa_get_slide_info( $index, $id, $callbackid = '' ) {
1685
  global $wpdb;
 
1686
  static $user;
1687
 
1688
  // Make sure $thumb contains our image data
1702
  }
1703
 
1704
  // Find rating
1705
+ if ( wppa_switch( 'rating_on' ) && ! wppa( 'is_slideonly' ) && ! wppa( 'is_filmonly' ) ) {
1706
 
1707
  // Find my ( avg ) rating
1708
  $rats = $wpdb->get_results( $wpdb->prepare( "SELECT `value` FROM `".WPPA_RATING."` " .
1737
  }
1738
 
1739
  // Find comments
1740
+ $comment = ( wppa_switch( 'show_comments' ) && ! wppa( 'is_filmonly' ) && ! wppa( 'is_slideonly' ) ) ? wppa_comment_html( $id, $comment_allowed ) : '';
1741
 
1742
  // Get the callback url.
1743
  if ( wppa_switch( 'rating_on' ) ) {
1760
  $linktarget = $link['target'];
1761
 
1762
  // Find full image style and size
1763
+ if ( wppa( 'is_filmonly' ) ) {
1764
  $style_a['style'] = '';
1765
  $style_a['width'] = '';
1766
  $style_a['height'] = '';
1785
  }
1786
 
1787
  // Find iptc data
1788
+ $iptc = ( wppa_switch( 'show_iptc' ) && ! wppa( 'is_slideonly' ) && ! wppa( 'is_filmonly' ) ) ? wppa_iptc_html( $id ) : '';
1789
 
1790
  // Find EXIF data
1791
+ $exif = ( wppa_switch( 'show_exif' ) && ! wppa( 'is_slideonly' ) && ! wppa( 'is_filmonly' ) ) ? wppa_exif_html( $id ) : '';
1792
 
1793
  // Lightbox subtitle
1794
  $doit = false;
1795
  if ( wppa_opt( 'slideshow_linktype' ) == 'lightbox' || wppa_opt( 'slideshow_linktype' ) == 'lightboxsingle' ) $doit = true; // For fullsize
1796
  if ( wppa_switch( 'filmstrip' ) && wppa_opt( 'film_linktype' ) == 'lightbox' ) { // For filmstrip?
1797
+ if ( ! wppa( 'is_slideonly' ) ) $doit = true; // Film below fullsize
1798
+ if ( wppa( 'film_on' ) ) $doit = true; // Film explicitly on ( slideonlyf )
1799
  }
1800
  if ( $doit ) {
1801
  $lbtitle = wppa_get_lbtitle( 'slide', $id );
1803
  else $lbtitle = '';
1804
 
1805
  // Name
1806
+ if ( wppa( 'is_filmonly' ) ) {
1807
  $name = '';
1808
  $fullname = '';
1809
  }
1815
  }
1816
 
1817
  // Shareurl
1818
+ if ( wppa( 'is_filmonly' ) || wppa( 'is_slideonly' ) ) {
1819
  $shareurl = '';
1820
  }
1821
  else {
1822
+ $shareurl = wppa_get_image_page_url_by_id( $id, false, wppa( 'start_album' ) );
1823
  $shareurl = wppa_convert_to_pretty( $shareurl );
1824
  $shareurl = str_replace( '&amp;', '&', $shareurl );
1825
  }
1826
 
1827
  // Make photo desc, filtered
1828
  $desc = '';
1829
+ if ( ( ! wppa( 'is_slideonly' ) || wppa( 'desc_on' ) ) && ! wppa( 'is_filmonly' ) ) {
1830
 
1831
  $desc .= wppa_get_photo_desc( $id, wppa_switch( 'allow_foreign_shortcodes' ), 'do_geo' ); // Foreign shortcodes is handled here
1832
 
1849
  // Edit photo link
1850
  $editlink = '';
1851
  $dellink = '';
1852
+ if ( ! wppa( 'is_filmonly' ) && ! wppa( 'is_slideonly' ) ) {
1853
  if ( ! wppa_is_user_blacklisted() ) {
1854
  if ( ( wppa_user_is( 'administrator' ) ) ||
1855
  ( current_user_can( 'wppa_moderate' ) ) ||
1886
  }
1887
 
1888
  // Share HTML
1889
+ $sharehtml = ( wppa( 'is_filmonly' ) || wppa( 'is_slideonly' ) ) ? '' : wppa_get_share_html( $id );
1890
 
1891
  // Og Description
1892
  $ogdsc = ( wppa_switch( 'facebook_comments' ) && ! wppa_in_widget() ) ? strip_shortcodes( wppa_strip_tags( wppa_html( wppa_get_photo_desc( $id ) ), 'all' ) ) : '';
1917
  $result .= $myrat."','";
1918
  $result .= $url."','";
1919
  $result .= $linkurl."','".$linktitle."','".$linktarget."','";
1920
+ $result .= wppa( 'in_widget_timeout' )."','";
1921
  $result .= $comment."','";
1922
  $result .= $iptc."','";
1923
  $result .= $exif."','";
1940
  // Process a comment request
1941
  function wppa_do_comment( $id ) {
1942
  global $wpdb;
 
1943
  global $wppa_done;
1944
 
1945
  if ( $wppa_done ) return; // Prevent multiple
2012
  wppa_dbg_q( 'Q44' );
2013
  $iret = $wpdb->query( $query );
2014
  if ( $iret !== false ) {
2015
+ wppa( 'comment_id', $cedit );
2016
  }
2017
  }
2018
  else {
2020
  $old_entry = $wpdb->prepare( 'SELECT * FROM `'.WPPA_COMMENTS.'` WHERE `photo` = %s AND `user` = %s AND `comment` = %s LIMIT 1', $photo, $user, $save_comment );
2021
  $iret = $wpdb->query( $old_entry );
2022
  if ( $iret ) {
2023
+ if ( wppa( 'debug' ) ) echo( '<script type="text/javascript">alert( "Duplicate comment ignored" )</script>' );
2024
  return;
2025
  }
2026
  $key = wppa_create_comments_entry( array( 'photo' => $photo, 'user' => $user, 'email' => $email, 'comment' => $save_comment, 'status' => $status ) );
2027
+ if ( $key ) wppa( 'comment_id', $key );
2028
  }
2029
  if ( $iret !== false ) {
2030
  if ( $status != 'spam' ) {
2170
  '</script>';
2171
  }
2172
 
2173
+ wppa( 'comment_photo', $id );
2174
+ wppa( 'comment_text', $comment );
2175
 
2176
  // Clear ( super )cache
2177
  wppa_clear_cache();
2220
  }
2221
 
2222
  function wppa_get_imgevents( $type = '', $id = '', $no_popup = false, $idx = '' ) {
 
2223
  global $wpdb;
2224
 
2225
  $result = '';
2341
  }
2342
 
2343
  function wppa_onpage( $type = '', $counter, $curpage ) {
 
2344
 
2345
  $pagesize = wppa_get_pagesize( $type );
2346
  if ( $pagesize == '0' ) { // Pagination off
2406
  }
2407
 
2408
  function wppa_get_slide_frame_style() {
 
2409
 
2410
  $fs = wppa_opt( 'fullsize' );
2411
  $cs = wppa_opt( 'colwidth' );
2412
  if ( $cs == 'auto' ) {
2413
  $cs = $fs;
2414
+ wppa( 'auto_colwidth', true );
2415
  }
2416
  $result = '';
2417
+ $gfs = ( is_numeric( wppa( 'fullsize' ) ) && wppa( 'fullsize' ) > '1' ) ? wppa( 'fullsize' ) : $fs;
2418
 
2419
  $gfh = floor( $gfs * wppa_opt( 'maxheight' ) / wppa_opt( 'fullsize' ) );
2420
 
2421
+ if ( wppa_in_widget() == 'ss' && wppa( 'in_widget_frame_height' ) > '0' ) $gfh = wppa( 'in_widget_frame_height' );
2422
 
2423
+ // for bbb:
2424
+ wppa( 'slideframewidth', $gfs );
2425
+ wppa( 'slideframeheight', $gfh );
2426
 
2427
+ if ( wppa( 'portrait_only' ) ) {
2428
  $result = 'width: ' . $gfs . 'px;'; // No height
2429
  }
2430
  else {
2431
  if ( wppa_page( 'oneofone' ) ) {
2432
+ $h = floor( $gfs * wppa_get_photoy( wppa( 'single_photo' ) ) / wppa_get_photox( wppa( 'single_photo' ) ) );
2433
  $result .= 'height: ' . $h . 'px;';
2434
  }
2435
+ elseif ( wppa( 'auto_colwidth' ) ) {
2436
  $result .= ' height: ' . $gfh . 'px;';
2437
  }
2438
+ elseif ( wppa( 'ss_widget_valign' ) != '' && wppa( 'ss_widget_valign' ) != 'fit' ) {
2439
  $result .= ' height: ' . $gfh . 'px;';
2440
  }
2441
  elseif ( wppa_opt( 'fullvalign' ) == 'default' ) {
2478
  }
2479
 
2480
  function wppa_get_thumb_frame_style_a( $glue = false, $film = '' ) {
2481
+ static $wppaerrmsgxxx;
 
2482
 
2483
+ $album = wppa( 'current_album' ) ? wppa_cache_album( wppa( 'current_album' ) ) : false;
2484
 
2485
  $result = array( 'style'=> '', 'width' => '', 'height' => '' );
2486
 
2487
  // Comten alt display?
2488
+ $com_alt = wppa( 'is_comten' ) && wppa_switch( 'comten_alt_display' ) && ! wppa_in_widget() && ! $film;
2489
 
2490
  $alt = ! $film && is_array( $album ) && $album['alt_thumbsize'] == 'yes' ? '_alt' : '';
2491
 
2532
  }
2533
 
2534
  function wppa_get_container_width( $netto = false ) {
2535
+
2536
+ if ( is_numeric( wppa( 'fullsize' ) ) && wppa( 'fullsize' ) > '0' ) {
2537
+ $result = wppa( 'fullsize' );
2538
  }
2539
  else {
2540
  $result = wppa_opt( 'colwidth' );
2541
  if ( $result == 'auto' ) {
2542
  $result = wppa_opt( 'initial_colwidth' ); //'640';
2543
+ wppa( 'auto_colwidth', true );
2544
  }
2545
  }
2546
  if ( $netto ) {
2564
  }
2565
 
2566
  function wppa_get_container_style() {
 
2567
 
2568
  $result = '';
2569
 
2570
  // See if there is space for a margin
2571
  $marg = false;
2572
+ if ( is_numeric( wppa( 'fullsize' ) ) ) {
2573
  $cw = wppa_opt( 'colwidth' );
2574
  if ( is_numeric( $cw ) ) {
2575
+ if ( $cw > ( wppa( 'fullsize' ) + 10 ) ) {
2576
  $marg = '10px;';
2577
  }
2578
  }
2579
  }
2580
 
2581
  if ( ! wppa_in_widget() ) {
2582
+ if ( wppa( 'align' ) == 'left' ) {
2583
  $result .= 'clear: left; ';
2584
  }
2585
+ if ( wppa( 'align' ) == 'right' ) {
2586
  $result .= 'clear: right; ';
2587
  }
2588
  }
2589
 
2590
  $ctw = wppa_get_container_width();
2591
+ if ( wppa( 'auto_colwidth' ) ) {
2592
  if ( is_feed() ) {
2593
  $result .= 'width:'.$ctw.'px;';
2594
  }
2597
  $result .= 'width:'.$ctw.'px;';
2598
  }
2599
 
2600
+ // if ( wppa( 'align' ) == '' ||
2601
+ if ( wppa( 'align' ) == 'left' ) {
2602
  $result .= 'float: left;';
2603
  if ( $marg ) $result .= 'margin-right: '.$marg;
2604
  }
2605
+ elseif ( wppa( 'align' ) == 'center' ) $result .= 'display: block; margin-left: auto; margin-right: auto;';
2606
+ elseif ( wppa( 'align' ) == 'right' ) {
2607
  $result .= 'float: right;';
2608
  if ( $marg ) $result .= 'margin-left: '.$marg;
2609
  }
2614
  }
2615
 
2616
  function wppa_get_curpage() {
 
2617
 
2618
  if ( wppa_get_get( 'page' ) ) {
2619
  if ( wppa_in_widget() ) {
2632
  }
2633
 
2634
  function wppa_container( $action ) {
 
2635
  global $wppa_version; // The theme version ( wppa_theme.php )
2636
  global $wppa_microtime;
2637
  global $wppa_microtime_cum;
2649
 
2650
  // Open the container
2651
  if ( ! wppa( 'ajax' ) ) {
2652
+ // wppa( 'out' ) .= '<!-- Start WPPA+ generated code'.( is_multisite() ? ', Multi site, id='.$blog_id : ', Single site' ).' -->';
2653
+ // if ( wppa( 'shortcode_content' ) ) {
2654
+ // wppa( 'out' ) .= '<!-- ' . wppa( 'shortcode_content' ) . ' -->';
2655
  // }
2656
+ wppa_out( '<div' .
2657
+ ' id="wppa-container-'.wppa( 'mocc' ).'"' .
2658
+ ' style="'.wppa_get_container_style().'"' .
2659
+ ' class="' .
2660
+ 'wppa-container' . ' ' .
2661
+ 'wppa-container-' . wppa( 'mocc' ) . ' ' .
2662
+ 'wppa-rev-' . wppa( 'revno' ) . ' ' .
2663
+ 'wppa-prevrev-' . wppa_opt( 'prevrev' ) . ' ' .
2664
+ 'wppa-theme-' . $wppa_version . ' ' .
2665
+ 'wppa-api-' . wppa( 'api_version' ) .
2666
+ '"' .
2667
+ ' >'
2668
+ );
2669
  }
2670
 
2671
  // Spinner for Ajax
2672
  if ( wppa_switch( 'allow_ajax' ) ) {
2673
  if ( ! wppa_in_widget() ) {
2674
+ wppa_out( '<img' .
2675
+ ' id="wppa-ajax-spin-' . wppa( 'mocc' ) . '"' .
2676
+ ' src="'.wppa_get_imgdir().'loader.gif"' .
2677
+ ' alt="spinner"' .
2678
+ ' style="' .
2679
+ 'box-shadow:none;' .
2680
+ 'z-index:1010;' .
2681
+ 'position:fixed;' .
2682
+ 'top:50%;' .
2683
+ 'margin-top:-32px;' .
2684
+ 'left:50%;' .
2685
+ 'margin-left:-32px;' .
2686
+ 'display:none;' .
2687
+ '"' .
2688
+ ' />'
2689
+ );
2690
  }
2691
  }
2692
 
2693
  // Start timer if in debug mode
2694
+ if ( wppa( 'debug' ) ) {
2695
  $wppa_microtime = - microtime( true );
2696
  wppa_dbg_q( 'init' );
2697
  }
2703
 
2704
  /* Check if wppa.js and jQuery are present */
2705
  if ( ! $wppa_err_displayed && ( WPPA_DEBUG || wppa_get_get( 'debug' ) || WP_DEBUG ) && ! wppa_switch( 'defer_javascript' ) ) {
2706
+ wppa_out( '<script type="text/javascript">/* <![CDATA[ */' );
2707
+ wppa_out( "if ( typeof( _wppaSlides ) == 'undefined' ) " .
2708
+ "alert( 'There is a problem with your theme. The file wppa.js is not loaded when it is expected ( Errloc = wppa_container ).' );" );
2709
+ wppa_out( "if ( typeof( jQuery ) == 'undefined' ) " .
2710
+ "alert( 'There is a problem with your theme. The jQuery library is not loaded when it is expected ( Errloc = wppa_container ).' );" );
2711
+ wppa_out( "/* ]]> */</script>" );
2712
  $wppa_err_displayed = true;
2713
  }
2714
 
2715
  /* Check if init is properly done */
2716
  if ( ! wppa_opt( 'fullsize' ) ) {
2717
+ wppa_out( '<script type="text/javascript">/* <![CDATA[ */' );
2718
+ wppa_out( "alert( 'The initialisation of wppa+ is not complete yet. " .
2719
  "You will probably see division by zero errors. " .
2720
+ "Please run Photo Albums -> Settings admin page Table VIII-A1. ( Errloc = wppa_container ).' );" );
2721
+ wppa_out( "/* ]]> */</script>" );
2722
  }
2723
 
2724
  // Nonce field check for rating security
2747
  }
2748
  }
2749
 
2750
+ wppa_out( wppa_nonce_field( 'wppa-check' , 'wppa-nonce', false, false ) );
2751
 
2752
+ if ( wppa_page( 'oneofone' ) ) wppa( 'portrait_only', true );
2753
  wppa( 'alt', 'alt' );
2754
 
2755
  // Javascript occurrence dependant stuff
2756
  wppa_add_js_page_data( "\n" . '<script type="text/javascript">' );
2757
+ // wppa( 'auto_colwidth' ) is set by the filter or by wppa_albums in case called directly
2758
  // wppa_opt( 'colwidth' ) is the option setting
2759
  // script or call has precedence over option setting
2760
  // so: if set by script or call: auto, else if set by option: auto
2761
  $auto = false;
2762
  $contw = wppa_get_container_width();
2763
+ if ( wppa( 'auto_colwidth' ) ) $auto = true;
2764
  elseif ( wppa_opt( 'colwidth' ) == 'auto' ) $auto = true;
2765
  elseif ( $contw > 0 && $contw <= 1.0 ) $auto = true;
2766
 
2789
  }
2790
 
2791
  // Aspect ratio and fullsize
2792
+ if ( wppa_in_widget() == 'ss' && is_numeric( wppa( 'in_widget_frame_width' ) ) && wppa( 'in_widget_frame_width' ) > '0' ) {
2793
+ $asp = wppa( 'in_widget_frame_height' ) / wppa( 'in_widget_frame_width' );
2794
+ $fls = wppa( 'in_widget_frame_width' );
2795
  }
2796
  else {
2797
  $asp = wppa_opt( 'maxheight' ) / wppa_opt( 'fullsize' );
2841
  wppa_add_js_page_data( "\n" . 'wppaLightBox['.wppa( 'mocc' ).'] = "xxx";' );
2842
 
2843
  // If this occur is a slideshow, determine if its link is to lightbox. This may differ between normal slideshow or ss widget
2844
+ $is_slphoto = wppa( 'is_slide' ) && wppa( 'start_photo' ) && wppa( 'is_single' );
2845
  if ( 'ss' == wppa_in_widget() || wppa_page( 'slide' ) || $is_slphoto ) {
2846
  $ss_linktype = ( 'ss' == wppa_in_widget() ) ? wppa_opt( 'slideonly_widget_linktype' ) : wppa_opt( 'slideshow_linktype' );
2847
  switch ( $ss_linktype ) {
2866
  }
2867
  elseif ( $action == 'close' ) {
2868
 
2869
+ if ( wppa_page( 'oneofone' ) ) wppa( 'portrait_only', false );
2870
+ if ( ! wppa_in_widget() ) wppa_out( '<div style="clear:both;"></div>' );
2871
 
2872
  // Add diagnostic <p> if debug is 1
2873
+ if ( wppa( 'debug' ) == '1' && wppa( 'mocc' ) == '1' ) wppa_out( '<p id="wppa-debug-'.wppa( 'mocc' ).'" style="font-size:9px; color:#070; line-size:12px;" ></p>' );
2874
 
2875
  // Init lightbox intermediate to facillitate premature clicks to lightbox when not yet document.complete
2876
+ wppa_out( "\n" . '<script type="text/javascript" >if ( typeof(wppaInitOverlay) != "undefined" ) { wppaInitOverlay(); }</script>' );
2877
 
2878
  if ( ! wppa( 'ajax' ) ) {
2879
+ wppa_out( '<div id="wppa-container-' . wppa( 'mocc' ) . '-end" ></div>' );
2880
+ wppa_out( '</div>' );
 
2881
  }
2882
 
2883
+ if ( wppa( 'debug' ) ) {
2884
  $laptim = $wppa_microtime + microtime( true );
2885
  $wppa_numqueries = get_num_queries() - $wppa_numqueries;
2886
  if ( !is_numeric( $wppa_microtime_cum ) ) $wppa_mcrotime_cum = '0';
2887
  $wppa_microtime_cum += $laptim;
2888
  wppa_dbg_msg( 'Time elapsed occ '.wppa( 'mocc' ).':'.substr( $laptim, 0, 5 ).'s. Tot:'.substr( $wppa_microtime_cum, 0, 5 ).'s.' );
2889
+ wppa_dbg_msg( 'Number of queries occ '.wppa( 'mocc' ).':' . $wppa_numqueries, 'green' );
2890
  wppa_dbg_q( 'print' );
2891
  }
2892
  }
2893
  else {
2894
+ wppa_out( "\n".'<span style="color:red;">Error, wppa_container() called with wrong argument: '.$action.'. Possible values: \'open\' or \'close\'</span>' );
2895
  }
2896
  }
2897
 
2898
  function wppa_album_list( $action ) {
 
2899
  global $cover_count;
2900
  global $cover_count_key;
2901
 
2902
  if ( $action == 'open' ) {
2903
  $cover_count = '0';
2904
  $cover_count_key = 'l';
2905
+ wppa_out( '<div id="wppa-albumlist-'.wppa( 'mocc' ).'" class="albumlist">' );
2906
  }
2907
  elseif ( $action == 'close' ) {
2908
+ wppa_out( '</div>' );
2909
  }
2910
  else {
2911
+ wppa_out( '<span style="color:red;">Error, wppa_albumlist() called with wrong argument: '.$action.'. Possible values: \'open\' or \'close\'</span>' );
2912
  }
2913
  }
2914
 
2915
  function wppa_thumb_list( $action ) {
 
2916
  global $cover_count;
2917
  global $cover_count_key;
2918
 
2919
  if ( $action == 'open' ) {
2920
  $cover_count = '0';
2921
  $cover_count_key = 'l';
2922
+ wppa_out( '<div id="wppa-thumblist-'.wppa( 'mocc' ).'" class="thumblist">' );
2923
+ if ( wppa( 'current_album' ) ) wppa_bump_viewcount( 'album', wppa( 'current_album' ) );
2924
  }
2925
  elseif ( $action == 'close' ) {
2926
+ wppa_out( '</div>' );
2927
  }
2928
  else {
2929
+ wppa_out( '<span style="color:red;">Error, wppa_thumblist() called with wrong argument: '.$action.'. Possible values: \'open\' or \'close\'</span>' );
2930
  }
2931
  }
2932
 
2933
  function wppa_get_npages( $type, $array ) {
 
2934
 
2935
  $aps = wppa_get_pagesize( 'albums' );
2936
  $tps = wppa_get_pagesize( 'thumbs' );
2946
  }
2947
  }
2948
  elseif ( $type == 'thumbs' ) {
2949
+ if ( wppa( 'is_cover' ) == '1' ) { // Cover has no thumbs: 0 pages
2950
  $result = '0';
2951
  }
2952
  elseif ( $arraycount <= wppa_get_mincount() ) {
2984
  }
2985
 
2986
  function wppa_run_slidecontainer( $type = '' ) {
 
2987
  global $thumbs;
2988
 
2989
+ // if ( wppa( 'is_filmonly' ) ) return;
2990
 
2991
  $c = is_array( $thumbs ) ? count( $thumbs ) : '0';
2992
+ wppa_dbg_msg( 'Running slidecontainer type '.$type.' with '.$c.' elements in thumbs, is_single=' . wppa( 'is_single' ) );
2993
 
2994
+ if ( wppa( 'is_single' ) && is_feed() ) { // process feed for single image slideshow here, normal slideshow uses filmthumbs
2995
+ $style_a = wppa_get_fullimgstyle_a( wppa( 'start_photo' ) );
2996
  $style = $style_a['style'];
2997
  $width = $style_a['width'];
2998
  $height = $style_a['height'];
2999
+ $imgalt = wppa_get_imgalt( wppa( 'start_photo' ) );
3000
+ wppa_out( '<a href="' . get_permalink() . '">' .
3001
+ '<img' .
3002
+ ' src="' . wppa_get_photo_url( wppa( 'start_photo' ), '', $width, $height ) . '"' .
3003
+ ' style="' . $style . '"' .
3004
+ ' width="' . $width . '"' .
3005
+ ' height="' . $height . '" ' .
3006
+ $imgalt .
3007
+ ' />' .
3008
+ '</a>'
3009
+ );
3010
  return;
3011
  }
3012
  elseif ( $type == 'slideshow' ) {
3027
  }
3028
 
3029
  // A requested photo id overrules the method. $startid >0 is requested photo id, -1 means: no id requested
3030
+ if ( wppa( 'start_photo' ) ) $startid = wppa( 'start_photo' );
3031
  else $startid = -1;
3032
 
3033
  // Create next ids
3046
 
3047
  foreach ( $thumbs as $thumb ) {
3048
  if ( wppa_switch( 'next_on_callback' ) ) {
 
3049
  wppa_add_js_page_data( "\n" . 'wppaStoreSlideInfo( ' . wppa_get_slide_info( $index, $thumb['id'], $thumb['next_id'] ) . ' );' );
3050
  }
3051
  else {
 
3052
  wppa_add_js_page_data( "\n" . 'wppaStoreSlideInfo( ' . wppa_get_slide_info( $index, $thumb['id'] ) . ' );' );
3053
  }
3054
  if ( $startid == $thumb['id'] ) $startindex = $index; // Found the requested id, put the corresponding index in $startindex
3063
  wppa_add_js_page_data( "\n" . '<script type="text/javascript">' );
3064
 
3065
  // How to start if slideonly
3066
+ if ( wppa( 'is_slideonly' ) ) {
3067
  if ( wppa_switch( 'start_slideonly' ) ) {
3068
  $startindex = -1; // There are no navigations, so start running, overrule everything
3069
  }
3073
  }
3074
 
3075
  // Vertical align
3076
+ if ( wppa( 'is_slideonly' ) ) {
3077
+ $ali = wppa( 'ss_widget_valign' ) ? wppa( 'ss_widget_valign' ) : $ali = 'fit';
3078
  wppa_add_js_page_data( "\n" . 'wppaFullValign['.wppa( 'mocc' ).'] = "'.$ali.'";' );
3079
  }
3080
  else {
3085
  wppa_add_js_page_data( "\n" . 'wppaFullHalign['.wppa( 'mocc' ).'] = "'.wppa_opt( 'fullhalign' ).'";' );
3086
 
3087
  // Portrait only ?
3088
+ if ( wppa( 'portrait_only' ) ) {
3089
  wppa_add_js_page_data( "\n" . 'wppaPortraitOnly['.wppa( 'mocc' ).'] = true;' );
3090
  }
3091
 
3102
 
3103
  }
3104
  else {
3105
+ wppa_out( '<span style="color:red;">' .
3106
+ 'Error, wppa_run_slidecontainer() called with wrong argument: ' . $type . '. Possible values: \'single\' or \'slideshow\'' .
3107
+ '</span>'
3108
+ );
3109
  }
3110
  }
3111
 
3112
  function wppa_is_pagination() {
 
3113
 
3114
+ if ( ( wppa_get_pagesize( 'albums' ) == '0' && wppa_get_pagesize( 'thumbs' ) == '0' ) ) return false;
3115
  else return true;
3116
  }
3117
 
3125
  }
3126
 
3127
  function wppa_dummy_bar( $msg = '' ) {
 
3128
 
3129
+ wppa_out( '<div style="margin:4px 0; '.__wcs( 'wppa-box' ).__wcs( 'wppa-nav' ).'text-align:center;">'.$msg.'</div>' );
3130
  }
3131
 
3132
  function wppa_rating_count_by_id( $id = '' ) {
 
3133
 
3134
+ wppa_out( wppa_get_rating_count_by_id( $id ) );
3135
  }
3136
 
3137
  function wppa_rating_by_id( $id = '', $opt = '' ) {
 
3138
 
3139
+ wppa_out( wppa_get_rating_by_id( $id, $opt ) );
3140
  }
3141
 
3142
  function wppa_get_cover_width( $type ) {
3151
  }
3152
 
3153
  function wppa_get_text_frame_style( $photo_left, $type ) {
 
3154
 
3155
  if ( wppa_in_widget() ) {
3156
  $result = '';
3227
  }
3228
 
3229
  function wppa_get_cover_cols( $type ) {
 
3230
 
3231
  $conwidth = wppa_get_container_width();
3232
 
3233
  $cols = ceil( $conwidth / wppa_opt( 'max_cover_width' ) );
3234
 
3235
  // Exceptions
3236
+ if ( wppa( 'auto_colwidth' ) ) $cols = '1';
3237
+ if ( ( $type == 'cover' ) && ( wppa( 'album_count' ) < '2' ) ) $cols = '1';
3238
+ if ( ( $type == 'thumb' ) && ( wppa( 'thumb_count' ) < '2' ) ) $cols = '1';
3239
  return $cols;
3240
  }
3241
 
3280
  }
3281
 
3282
  function wppa_mphoto() {
 
3283
 
3284
+ $id = wppa( 'single_photo' );
3285
  $width = wppa_get_container_width();
3286
  $height = floor( $width / wppa_get_ratio( $id ) );
3287
  $usethumb = wppa_use_thumb_file( $id, $width, $height );
3292
 
3293
  if ( ! wppa_in_widget() ) wppa_bump_viewcount( 'photo', $id );
3294
 
3295
+ $autocol = wppa( 'auto_colwidth' ) || ( $width > 0 && $width <= 1.0 );
3296
 
3297
  // The initial width is $width if not autocol, else it should default to initial column width when auto
3298
  // or initial column width * fraction
3310
 
3311
  // Open the pseudo container
3312
  $captwidth = $contwidth + '10';
3313
+ wppa_out( '<div id="wppa-container-'.wppa( 'mocc' ).'" class="wppa-mphoto-'.wppa( 'mocc' ).' wp-caption' );
3314
+ if ( wppa( 'align' ) != '' ) wppa_out( ' align' . wppa( 'align' ) );
3315
+ wppa_out( '" style="width: '.$captwidth.'px; position:relative;">' );
3316
 
3317
  // The script for responsive
3318
  wppa_add_js_page_data( "\n" . '<script type="text/javascript">' );
3338
  $audiohtml = esc_attr( wppa_get_audio_body( $id ) );
3339
  $videox = wppa_get_videox( $id );
3340
  $videoy = wppa_get_videoy( $id );
3341
+ wppa_out( '<a' .
3342
+ ' href="' . $link['url'] . '"' .
3343
+ ( $lbtitle ? ' ' . wppa( 'lbtitle' ) . '="' . $lbtitle . '"' : '' ) .
3344
+ ( $videohtml ? ' data-videohtml="' . $videohtml . '"' : '' ) .
3345
+ ( $audiohtml ? ' data-audiohtml="' . $audiohtml . '"' : '' ) .
3346
+ ( $videox ? ' data-videonatwidth="' . $videox . '"' : '' ) .
3347
+ ( $videoy ? ' data-videonatheight="' . $videoy . '"' : '' ) .
3348
+ ' ' . wppa( 'rel' ) . '="' . wppa_opt( 'lightbox_name' ) . '"' .
3349
+ ( $link['target'] ? ' target="' . $link['target'] . '"' : '' ) .
3350
+ ' class="thumb-img"' .
3351
+ ' id="a-' . $id . '-' . wppa( 'mocc' ) . '"' .
3352
+ ' >'
3353
+ );
3354
  }
3355
  else {
3356
+ wppa_out( '<a' .
3357
+ ' href="' . $link['url'] . '"' .
3358
+ ( $link['title'] ? ' title="' . $link['title'] . '"' : '' ) .
3359
+ ( $link['target'] ? ' target="' . $link['target'] . '"' : '' ) .
3360
+ ' class="thumb-img"' .
3361
+ ' id="a-' . $id . '-' . wppa( 'mocc' ) . '"' .
3362
+ ' >'
3363
+ );
3364
  }
3365
  }
3366
 
3377
 
3378
  if ( wppa_is_video( $id ) ) {
3379
  if ( $autocol ) {
3380
+ wppa_out( wppa_get_video_html( array( 'id' => $id,
3381
+ 'controls' => ! $link['is_lightbox'],
3382
+ 'style' => $style,
3383
+ 'class' => 'size-medium wppa-mphoto wppa-mimg-'.wppa( 'mocc' )
3384
+ )
3385
+ )
3386
+ );
3387
  }
3388
  else {
3389
+ wppa_out( wppa_get_video_html( array( 'id' => $id,
3390
+ 'width' => $width,
3391
+ 'height' => $height,
3392
+ 'controls' => ! $link['is_lightbox'],
3393
+ 'style' => $style,
3394
+ 'class' => 'size-medium wppa-mphoto wppa-mimg-'.wppa( 'mocc' )
3395
+ )
3396
+ )
3397
+ );
3398
  }
3399
  }
3400
  else {
3401
+ wppa_out( '<img' .
3402
+ ' src="' . $src . '"' .
3403
+ ' ' . wppa_get_imgalt( $id ) .
3404
+ ' style="' . $style . '"' .
3405
+ ' class="size-medium wppa-mphoto wppa-mimg-' . wppa( 'mocc' ) . '"' .
3406
+ ( $title ? ' title="' . $title . '"' : '' ) .
3407
+ ' width="' . $width . '"' .
3408
+ ' height="' . $height . '"' .
3409
+ ' />'
3410
+ );
3411
  }
3412
  if ( $link ) {
3413
+ wppa_out( '</a>' );
3414
  }
3415
 
3416
  // Add audio? mphoto
3417
  if ( wppa_has_audio( $id ) ) {
3418
+ wppa_out( '<div style="position:relative;z-index:11;" >' );
3419
+
3420
+ wppa_out( wppa_get_audio_html( array(
3421
+ 'id' => $id,
3422
+ 'cursor' => 'cursor:pointer;',
3423
+ 'style' => $style .
3424
+ 'position:relative;' .
3425
+ 'padding-top:0;' .
3426
+ 'padding-bottom:0;' .
3427
+ 'background-color:transparent;' .
3428
+ 'border:none;' .
3429
+ 'margin:0;' .
3430
+ 'width:98%;',
3431
+ 'class' => 'size-medium wp-caption wppa-mphoto_ wppa-mimg-' . wppa( 'mocc' ),
3432
+ )
3433
+ )
3434
+ );
3435
+
3436
+ wppa_out( '</div>' );
3437
  }
3438
 
3439
  // The subtitle
3440
+ wppa_out( '<p class="wp-caption-text">' . wppa_get_photo_desc( $id ) . '</p>' );
3441
 
3442
  // The share buttons
3443
  if ( wppa_switch( 'share_on_mphoto' ) ) {
3444
+ wppa_out( wppa_get_share_html( $id, 'mphoto', false ) );
3445
  }
3446
 
3447
+ wppa_out( '</div>' );
3448
  }
3449
 
3450
  // Like mphoto but without the caption and with the fullsize background/border
3451
  function wppa_sphoto() {
 
3452
 
3453
+ $id = wppa( 'single_photo' );
3454
  $width = wppa_get_container_width();
3455
  $height = floor( $width / wppa_get_ratio( $id ) );
3456
  $usethumb = wppa_use_thumb_file( $id, $width, $height );
3461
 
3462
  if ( ! wppa_in_widget() ) wppa_bump_viewcount( 'photo', $id );
3463
 
3464
+ $autocol = wppa( 'auto_colwidth' ) || ( $width > 0 && $width <= 1.0 );
3465
 
3466
  // The initial width is $width if not autocol, else it should default to initial column width when auto
3467
  // or initial column width * fraction
3478
  }
3479
 
3480
  // Open the pseudo container
3481
+ wppa_out( '<div' .
3482
+ ' id="wppa-container-' . wppa( 'mocc' ) . '"' .
3483
+ ' class="' .
3484
+ ( wppa( 'align' ) ? 'align' . wppa( 'align' ) : '' ) .
3485
+ ' wppa-sphoto-' . wppa( 'mocc' ) .
3486
+ '"' .
3487
+ ' style="width:' . $contwidth . 'px;position:relative;"' .
3488
+ ' >'
3489
+ );
3490
 
3491
  // The script for responsive
3492
  wppa_add_js_page_data( "\n" . '<script type="text/javascript">' );
3503
  wppa_add_js_page_data( "\n" . 'wppaTopMoc = '.wppa( 'mocc' ).';' );
3504
  wppa_add_js_page_data( "\n" . '</script>' );
3505
 
3506
+ wppa( 'portrait_only', true );
3507
  $fis = wppa_get_fullimgstyle_a( $id );
3508
  $width = $fis['width'];
3509
  $height = $fis['height'];
3519
  $audiobody = esc_attr( wppa_get_audio_body( $id ) );
3520
  $videox = wppa_get_videox( $id );
3521
  $videoy = wppa_get_videoy( $id );
3522
+ wppa_out( '<a' .
3523
+ ' href="' . $link['url'] . '"' .
3524
+ ( $lbtitle ? ' ' . wppa( 'lbtitle' ) . '="'.$lbtitle.'"' : '' ) .
3525
+ ( $videobody ? ' data-videohtml="' . $videobody . '"' : '' ) .
3526
+ ( $audiobody ? ' data-audiohtml="' . $audiobody . '"' : '' ) .
3527
+ ( $videox ? ' data-videonatwidth="' . $videox . '"' : '' ) .
3528
+ ( $videoy ? ' data-videonatheight="' . $videoy . '"' : '' ) .
3529
+ ' ' . wppa( 'rel' ) . '="'.wppa_opt( 'lightbox_name' ).'"' .
3530
+ ( $link['target'] ? ' target="' . $link['target'] . '"' : '' ) .
3531
+ ' class="thumb-img"' .
3532
+ ' id="a-' . $id . '-' . wppa( 'mocc' ) . '"' .
3533
+ ' >'
3534
+ );
3535
  }
3536
  else {
3537
+ wppa_out( '<a' .
3538
+ ' href="' . $link['url'] . '"' .
3539
+ ' title="' . $link['title'] . '"' .
3540
+ ' target="' . $link['target'] . '"' .
3541
+ ' class="thumb-img"' .
3542
+ ' id="a-' . $id . '-' . wppa( 'mocc' ) . '"' .
3543
+ ' >'
3544
+ );
3545
  }
3546
  }
3547
 
3554
 
3555
  if ( wppa_is_video( $id ) ) {
3556
  if ( $autocol ) {
3557
+ wppa_out( wppa_get_video_html( array( 'id' => $id,
3558
+ 'controls' => ! $link['is_lightbox'],
3559
+ 'style' => $style,
3560
+ 'class' => 'size-medium wppa-sphoto wppa-simg-'.wppa( 'mocc' ),
3561
+ )
3562
+ )
3563
+ );
3564
  }
3565
  else {
3566
+ wppa_out( wppa_get_video_html( array( 'id' => $id,
3567
+ 'width' => $width,
3568
+ 'height' => $height,
3569
+ 'controls' => ! $link['is_lightbox'],
3570
+ 'style' => $style,
3571
+ 'class' => 'size-medium wppa-sphoto wppa-simg-'.wppa( 'mocc' ),
3572
+ )
3573
+ )
3574
+ );
3575
  }
3576
  }
3577
  else {
3578
+ wppa_out( '<img' .
3579
+ ' src="' . $src . '"' .
3580
+ ' ' . wppa_get_imgalt( $id ) .
3581
+ ' class="size-medium wppa-sphoto wppa-simg-' . wppa( 'mocc' ) . '"' .
3582
+ ' ' . wppa_get_imgalt( $id ) .
3583
+ ( $title ? ' title="' . $title . '" ' : '' ) .
3584
+ ' style="' . $style . '"' .
3585
+ ( $autocol ? '' : ' width="' . $width . '" height="' . $height . '" ' ) .
3586
+ '/ >'
3587
+ );
3588
  }
3589
 
3590
  // Close the link
3591
  if ( $link ) {
3592
+ wppa_out( '</a>' );
3593
  }
3594
 
3595
  // Add audio? sphoto
3596
  if ( wppa_has_audio( $id ) ) {
3597
+ wppa_out( '<div style="position:relative;z-index:11;" >' );
3598
  $margl = ( wppa_opt( 'wppa_fullimage_border_width' ) === '' ) ? 0 : wppa_opt( 'wppa_fullimage_border_width' ) + 1;
3599
  $margb = $margl;
3600
 
3601
+ wppa_out( wppa_get_audio_html( array( 'id' => $id,
3602
+ 'cursor' => 'cursor:pointer;',
3603
+ 'style' => $style .
3604
+ 'position:absolute;' .
3605
+ 'left:' . $margl . 'px;' .
3606
+ 'bottom:' . $margb . 'px;' .
3607
+ 'padding:0;' .
3608
+ 'margin:0;' .
3609
+ 'border:none;' .
3610
+ 'height:' . wppa_get_audio_control_height() . 'px;' .
3611
+ 'border-radius:0;',
3612
+ 'class' => 'size-medium wppa-sphoto wppa-simg-'.wppa( 'mocc' ),
3613
+ )
3614
+ )
3615
+ );
3616
+
3617
+ wppa_out( '</div>' );
3618
  }
3619
 
3620
  // The pseudo container
3621
+ wppa_out( '</div>' );
3622
  }
3623
 
3624
  // returns aspect ratio ( w/h ), or 1 on error
3762
  // wppa_user_upload_on must be on for any of these functions to be enabled
3763
  function wppa_user_upload() {
3764
  global $wpdb;
3765
+ static $done;
3766
 
3767
  wppa_dbg_msg( 'Usr_upl entered' );
3768
 
3769
+ if ( $done ) return; // Already done
3770
+ $done = true; // Mark as done
3771
 
3772
  // Upload possible?
3773
  $may_upload = wppa_switch( 'user_upload_on' );
4104
 
4105
  // Find the search results. For use in a page template to show the search results. See ./theme/search.php
4106
  function wppa_have_photos( $xwidth = '0' ) {
 
4107
 
4108
  if ( !is_search() ) return false;
4109
  $width = $xwidth ? $xwidth : wppa_get_container_width();
4110
 
4111
+ wppa( 'searchresults', wppa_albums( '', '', $width ) );
4112
 
4113
+ return wppa( 'any' );
4114
  }
4115
 
4116
  // Display the searchresults. For use in a page template to show the search results. See ./theme/search.php
4117
  function wppa_the_photos() {
 
4118
 
4119
+ if ( wppa( 'any' ) ) echo wppa( 'searchresults' );
4120
  }
4121
 
4122
  // Decide if a thumbnail photo file can be used for a requested display
4123
  function wppa_use_thumb_file( $id, $width = '0', $height = '0' ) {
 
4124
 
4125
  if ( ! wppa_switch( 'use_thumbs_if_fit' ) ) return false;
4126
  if ( $width <= 1.0 && $height <= 1.0 ) return false; // should give at least one dimension and not when fractional
4128
  $file = wppa_get_thumb_path( $id );
4129
  if ( file_exists( $file ) ) {
4130
  $size = wppa_get_imagexy( $id, 'thumb' );
 
 
4131
  }
4132
  else return false;
4133
 
4200
 
4201
  // Get the title to be used for lightbox links == thext under the lightbox image
4202
  function wppa_get_lbtitle( $type, $id ) {
 
4203
 
4204
  if ( ! is_numeric( $id ) || $id < '1' ) wppa_dbg_msg( 'Invalid arg wppa_get_lbtitle( '.$id.' )', 'red' );
4205
 
wppa-index.php CHANGED
@@ -3,28 +3,27 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all indexing functions
6
- * version 6.3.0
 
7
  *
8
- *
9
  */
10
 
11
  // Add an item to the index
12
- function wppa_index_add($type, $id) {
13
  global $wpdb;
14
  global $acount;
15
  global $pcount;
16
- global $wppa;
17
 
18
  if ( $type == 'album' ) {
19
-
20
- $album = wppa_cache_album($id);
21
-
22
  // Find the raw text, all qTranslate languages
23
  $words = stripslashes($album['name']).' '.stripslashes($album['description']);
24
  if ( wppa_switch( 'wppa_search_cats' ) ) {
25
  $words .= ' '.$album['cats'];
26
  }
27
-
28
  $words = wppa_index_raw_to_words($words);
29
  foreach ( $words as $word ) {
30
  $indexline = $wpdb->get_row($wpdb->prepare("SELECT * FROM `".WPPA_INDEX."` WHERE `slug` = %s", $word), ARRAY_A);
@@ -43,11 +42,11 @@ global $wppa;
43
  }
44
  $acount ++;
45
  }
46
-
47
  elseif ( $type == 'photo' ) {
48
-
49
  $thumb = wppa_cache_thumb($id);
50
-
51
  // Find the raw text
52
  $desc = stripslashes($thumb['description']);
53
  $desc = wppa_filter_iptc( $desc, $thumb['id'] ); // Render IPTC tags
@@ -75,7 +74,7 @@ global $wppa;
75
  }
76
  }
77
  }
78
-
79
  $words = wppa_index_raw_to_words($words); // convert raw string to sanitized array
80
  foreach ( $words as $word ) {
81
  $indexline = $wpdb->get_row($wpdb->prepare("SELECT * FROM `".WPPA_INDEX."` WHERE `slug` = %s", $word), ARRAY_A);
@@ -91,25 +90,25 @@ global $wppa;
91
  $wpdb->query($wpdb->prepare( "UPDATE `".WPPA_INDEX."` SET `photos` = %s WHERE `id` = %s", $newphotos, $indexline['id']));
92
  }
93
  }
94
-
95
  }
96
  $pcount ++;
97
  }
98
-
99
  else wppa_dbg_msg('Error, unimplemented type in wppa_index_add().', 'red', 'force');
100
  }
101
 
102
  // Convert raw data string to indexable word array
103
  function wppa_index_raw_to_words($xtext, $noskips = false) {
104
 
105
- $ignore = array( '"', "'", '`', '\\', '>', '<', ',', ':', ';', '!', '?', '=', '_',
106
- '[', ']', '(', ')', '{', '}', '..', '...', '....', "\n", "\r",
107
  "\t", '.jpg', '.png', '.gif', '&#039', '&amp',
108
  'w#cc0', 'w#cc1', 'w#cc2', 'w#cc3', 'w#cc4', 'w#cc5', 'w#cc6', 'w#cc7', 'w#cc8', 'w#cc9'
109
  );
110
  if ( $noskips ) $skips = array();
111
  else $skips = get_option('wppa_index_skips', array());
112
-
113
  $result = array();
114
  if ( $xtext ) {
115
  $text = strtolower($xtext);
@@ -136,10 +135,10 @@ function wppa_index_raw_to_words($xtext, $noskips = false) {
136
  }
137
  }
138
  }
139
-
140
  // sort
141
  sort( $result );
142
-
143
  // Remove dups
144
  $start = 0;
145
  foreach ( array_keys( $result ) as $key ) {
@@ -270,7 +269,7 @@ global $wpdb;
270
  }
271
  }
272
  else wppa_dbg_msg('Error, unimplemented type in wppa_index_remove().', 'red', 'force');
273
-
274
  $wpdb->query( "DELETE FROM `".WPPA_INDEX."` WHERE `albums` = '' AND `photos` = ''" ); // Cleanup empty entries
275
  }
276
 
@@ -279,12 +278,12 @@ function wppa_index_quick_remove($type, $id) {
279
  global $wpdb;
280
 
281
  if ( $type == 'album' ) {
282
-
283
  $album = wppa_cache_album($id);
284
-
285
  $words = stripslashes( $album['name'] ).' '.stripslashes( $album['description'] ).' '.$album['cats'];
286
  $words = wppa_index_raw_to_words($words);
287
-
288
  foreach ( $words as $word ) {
289
  $indexline = $wpdb->get_row("SELECT * FROM `".WPPA_INDEX."` WHERE `slug` = '".$word."'", ARRAY_A);
290
  $array = wppa_index_string_to_array($indexline['albums']);
@@ -301,10 +300,10 @@ global $wpdb;
301
  }
302
  }
303
  }
304
-
305
  }
306
  elseif ( $type == 'photo') {
307
-
308
  $thumb = wppa_cache_thumb($id);
309
 
310
  // Find the raw text
@@ -314,7 +313,7 @@ global $wpdb;
314
  $words .= ' '.stripslashes( $com['comment'] );
315
  }
316
  $words = wppa_index_raw_to_words($words, 'noskips');
317
-
318
  foreach ( $words as $word ) {
319
  $indexline = $wpdb->get_row("SELECT * FROM `".WPPA_INDEX."` WHERE `slug` = '".$word."'", ARRAY_A);
320
  $array = wppa_index_string_to_array($indexline['photos']);
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all indexing functions
6
+ * version 6.3.9
7
+ *
8
  *
 
9
  */
10
 
11
  // Add an item to the index
12
+ function wppa_index_add( $type, $id ) {
13
  global $wpdb;
14
  global $acount;
15
  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( 'wppa_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);
42
  }
43
  $acount ++;
44
  }
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
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);
90
  $wpdb->query($wpdb->prepare( "UPDATE `".WPPA_INDEX."` SET `photos` = %s WHERE `id` = %s", $newphotos, $indexline['id']));
91
  }
92
  }
93
+
94
  }
95
  $pcount ++;
96
  }
97
+
98
  else wppa_dbg_msg('Error, unimplemented type in wppa_index_add().', 'red', 'force');
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 ) {
114
  $text = strtolower($xtext);
135
  }
136
  }
137
  }
138
+
139
  // sort
140
  sort( $result );
141
+
142
  // Remove dups
143
  $start = 0;
144
  foreach ( array_keys( $result ) as $key ) {
269
  }
270
  }
271
  else wppa_dbg_msg('Error, unimplemented type in wppa_index_remove().', 'red', 'force');
272
+
273
  $wpdb->query( "DELETE FROM `".WPPA_INDEX."` WHERE `albums` = '' AND `photos` = ''" ); // Cleanup empty entries
274
  }
275
 
278
  global $wpdb;
279
 
280
  if ( $type == 'album' ) {
281
+
282
  $album = wppa_cache_album($id);
283
+
284
  $words = stripslashes( $album['name'] ).' '.stripslashes( $album['description'] ).' '.$album['cats'];
285
  $words = wppa_index_raw_to_words($words);
286
+
287
  foreach ( $words as $word ) {
288
  $indexline = $wpdb->get_row("SELECT * FROM `".WPPA_INDEX."` WHERE `slug` = '".$word."'", ARRAY_A);
289
  $array = wppa_index_string_to_array($indexline['albums']);
300
  }
301
  }
302
  }
303
+
304
  }
305
  elseif ( $type == 'photo') {
306
+
307
  $thumb = wppa_cache_thumb($id);
308
 
309
  // Find the raw text
313
  $words .= ' '.stripslashes( $com['comment'] );
314
  }
315
  $words = wppa_index_raw_to_words($words, 'noskips');
316
+
317
  foreach ( $words as $word ) {
318
  $indexline = $wpdb->get_row("SELECT * FROM `".WPPA_INDEX."` WHERE `slug` = '".$word."'", ARRAY_A);
319
  $array = wppa_index_string_to_array($indexline['photos']);
wppa-links.php CHANGED
@@ -422,6 +422,13 @@ function wppa_convert_to_pretty( $xuri ) {
422
  return $uri;
423
  }
424
 
 
 
 
 
 
 
 
425
  // Re-order
426
  if ( strpos( $uri, '&amp;' ) !== false ) {
427
  $amps = true;
422
  return $uri;
423
  }
424
 
425
+ // Not during search. Otherwise wppa_test_for_search('at_session_start') returns '';
426
+ // and this will destroy use and display searchstrings in wppa_session_start()
427
+ // Fix in 6.3.9
428
+ if ( strpos( $uri, 'searchstring' ) ) {
429
+ return $uri;
430
+ }
431
+
432
  // Re-order
433
  if ( strpos( $uri, '&amp;' ) !== false ) {
434
  $amps = true;
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.3.8
7
  *
8
  */
9
 
@@ -92,6 +92,8 @@ global $wppa_supported_audio_extensions;
92
  $wppa_session[$slug.'_skipped'] = '0';
93
  }
94
 
 
 
95
  // Pre-processing needed?
96
  if ( $lastid == '0' ) {
97
  wppa_log( 'Obs', 'Maintenance proc '.$slug.' started.' );
@@ -132,11 +134,12 @@ global $wppa_supported_audio_extensions;
132
  $togo = 'all';
133
  $reload = false;
134
  echo '||'.$slug.'||'.$status.'||'.$togo.'||'.$reload;
135
- exit;
136
  }
137
  break;
138
 
139
  }
 
140
  }
141
 
142
  // Dispatch on albums / photos / single actions
@@ -697,6 +700,9 @@ global $wppa_supported_audio_extensions;
697
  wppa_log( 'Obs', 'Maintenance proc '.$slug.' completed' );
698
 
699
  }
 
 
 
700
  return $errtxt.'||'.$slug.'||'.$status.'||'.$togo.'||'.$reload;
701
  }
702
 
@@ -845,39 +851,34 @@ global $wpdb;
845
  <th>Id</th>
846
  <th>Session id</th>
847
  <th>User</th>
848
-
849
  <th>Started</th>
850
  <th>Count</th>
851
- <th>Page</th>
852
- <th>Ajax</th>
853
- <th>Albums viewed</th>
854
- <th>Photos viewed</th>
855
- <th>Search string</th>
856
- <th>root</th>
857
- <th>sub</th>
858
- <th>Superview</th>
859
  </tr>
860
  <tr><td colspan="14"><hr /></td></tr>
861
  </thead>
862
  <tbody>';
863
- foreach( $sessions as $session ) {
864
  $data = unserialize( $session['data'] );
865
  $result .= '
866
  <tr>
867
  <td>'.$session['id'].'</td>
868
  <td>'.$session['session'].'</td>
869
  <td>'.$session['user'].'</td>
870
-
871
- <td style="text-wrap:none;" >'.wppa_local_date(get_option('date_format', "F j, Y,").' '.get_option('time_format', "g:i a"), $session['timestamp']).'</td>
872
- <td>'.$session['count'].'</td>
873
- <td>'.( isset( $data['page'] ) ? $data['page'] : '' ).'</td>
874
- <td>'.( isset( $data['ajax'] ) ? $data['ajax'] : '' ).'</td>
875
- <td>'.( isset( $data['album'] ) ? wppa_index_array_to_string( array_keys( $data['album'] ) ) : '' ).'</td>
876
- <td>'.( isset( $data['photo'] ) ? wppa_index_array_to_string( array_keys( $data['photo'] ) ) : '' ).'</td>
877
- <td>'.( isset( $data['use_searchstring'] ) ? $data['use_searchstring'] : '' ).'</td>
878
- <td style="max-width:200px;overflow:hidden;" >'.( isset( $data['search_root'] ) ? $data['search_root'].' ' : '' ).( isset( $data['rootbox'] ) ? ( $data['rootbox'] ? 'on' : 'off' ) : '' ).'</td>
879
- <td>'.( isset( $data['subbox'] ) ? ( $data['subbox'] ? 'Y' : 'N' ) : '' ).'</td>
880
- <td>'.( isset( $data['superalbum'] ) ? $data['superalbum'].' ' : '' ).( isset( $data['superview'] ) ? $data['superview'] : '' ).'</td>
 
 
 
881
  </tr>';
882
  }
883
  $result .= '
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains (not yet, but in the future maybe) all the maintenance routines
6
+ * Version 6.3.9
7
  *
8
  */
9
 
92
  $wppa_session[$slug.'_skipped'] = '0';
93
  }
94
 
95
+ wppa_save_session();
96
+
97
  // Pre-processing needed?
98
  if ( $lastid == '0' ) {
99
  wppa_log( 'Obs', 'Maintenance proc '.$slug.' started.' );
134
  $togo = 'all';
135
  $reload = false;
136
  echo '||'.$slug.'||'.$status.'||'.$togo.'||'.$reload;
137
+ wppa_exit();
138
  }
139
  break;
140
 
141
  }
142
+ wppa_save_session();
143
  }
144
 
145
  // Dispatch on albums / photos / single actions
700
  wppa_log( 'Obs', 'Maintenance proc '.$slug.' completed' );
701
 
702
  }
703
+
704
+ wppa_save_session();
705
+
706
  return $errtxt.'||'.$slug.'||'.$status.'||'.$togo.'||'.$reload;
707
  }
708
 
851
  <th>Id</th>
852
  <th>Session id</th>
853
  <th>User</th>
 
854
  <th>Started</th>
855
  <th>Count</th>
856
+ <th>Data</th>
 
 
 
 
 
 
 
857
  </tr>
858
  <tr><td colspan="14"><hr /></td></tr>
859
  </thead>
860
  <tbody>';
861
+ foreach ( $sessions as $session ) {
862
  $data = unserialize( $session['data'] );
863
  $result .= '
864
  <tr>
865
  <td>'.$session['id'].'</td>
866
  <td>'.$session['session'].'</td>
867
  <td>'.$session['user'].'</td>
868
+ <td style="width:150px;" >'.wppa_local_date(get_option('date_format', "F j, Y,").' '.get_option('time_format', "g:i a"), $session['timestamp']).'</td>
869
+ <td>'.$session['count'].'</td>' .
870
+ '<td style="border-bottom:1px solid gray;" >';
871
+ foreach ( array_keys( $data ) as $key ) {
872
+ if ( is_array( $data[$key] ) ) {
873
+ $result .= '['.$key.'] => Array('.
874
+ implode( ',', array_keys($data[$key]) ) .
875
+ ')<br />';
876
+ }
877
+ else {
878
+ $result .= '['.$key.'] => '.$data[$key].'<br />';
879
+ }
880
+ }
881
+ '</td>
882
  </tr>';
883
  }
884
  $result .= '
wppa-session.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all session routines
6
- * Version 6.3.8
7
  *
8
  * Firefox modifies data in the superglobal $_SESSION.
9
  * See https://bugzilla.mozilla.org/show_bug.cgi?id=991019
@@ -27,7 +27,7 @@ function wppa_session_start() {
27
  global $wpdb;
28
  global $wppa_session;
29
 
30
- if ( is_array( $wppa_session ) ) return true; // To prevent dup opens
31
 
32
  // If the session table does not yet exist on activation
33
  if ( ! wppa_table_exists( WPPA_SESSION ) ) {
@@ -45,7 +45,7 @@ global $wppa_session;
45
 
46
  // Is session already started?
47
  $session = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".WPPA_SESSION."` WHERE `session` = %s AND `status` = 'valid' LIMIT 1", wppa_get_session_id() ), ARRAY_A );
48
- $data = isset( $session['data'] ) ? $session['data'] : false;
49
 
50
  // Not started yet, setup session
51
  if ( $data === false ) {
@@ -65,23 +65,22 @@ global $wppa_session;
65
  wppa_log( 'Error', 'Unable to create session.' );
66
  return false;
67
  }
68
- $wppa_session['page'] = '1';
 
69
  $wppa_session['ajax'] = '0';
70
  $wppa_session['id'] = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `".WPPA_SESSION."` WHERE `session` = %s LIMIT 1", wppa_get_session_id() ) );
71
- $wppa_session['has_searchbox'] = false;
72
- $wppa_session['rootbox'] = false;
73
- $wppa_session['search_root'] = '';
74
- $wppa_session['subbox'] = false;
75
- $wppa_session['use_searchstring'] = '';
76
- $wppa_session['display_searchstring'] = '';
77
  }
78
 
79
  // Session exists, Update counter
80
  else {
81
  $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_SESSION."` SET `count` = %s WHERE `id` = %s", $session['count'] + '1', $session['id'] ) );
82
- $wppa_session = unserialize( $data );
83
- $wppa_session['page'] = isset ( $wppa_session['page'] ) ? $wppa_session['page'] + '1' : '1';
84
- $wppa_session['id'] = $session['id'];
 
 
 
 
85
  }
86
 
87
  // Get info for root and sub search
@@ -111,24 +110,38 @@ global $wppa_session;
111
  $wppa_session['display_searchstring'] = str_replace ( ',', ' &#8746 ', str_replace ( ' ', ' &#8745 ', $wppa_session['use_searchstring'] ) );
112
  }
113
  }
114
- /*
115
- else {
116
- if ( is_home() || is_front_page() ) { // does not work
117
- $wppa_session['rootbox'] = false;
118
- $wppa_session['subbox'] = false;
119
- $wppa_session['use_searchstring'] = '';
120
- $wppa_session['display_searchstring'] = '';
121
- }
122
- }
123
- */
124
 
125
- // print_r($_REQUEST);
126
- // print_r($wppa_session);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  return true;
128
  }
129
 
130
  // Saves the session data. To be called at shutdown
131
  function wppa_session_end() {
 
 
 
 
132
  global $wpdb;
133
  global $wppa_session;
134
 
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all session routines
6
+ * Version 6.3.9
7
  *
8
  * Firefox modifies data in the superglobal $_SESSION.
9
  * See https://bugzilla.mozilla.org/show_bug.cgi?id=991019
27
  global $wpdb;
28
  global $wppa_session;
29
 
30
+ // if ( is_array( $wppa_session ) ) return true; // To prevent dup opens
31
 
32
  // If the session table does not yet exist on activation
33
  if ( ! wppa_table_exists( WPPA_SESSION ) ) {
45
 
46
  // Is session already started?
47
  $session = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".WPPA_SESSION."` WHERE `session` = %s AND `status` = 'valid' LIMIT 1", wppa_get_session_id() ), ARRAY_A );
48
+ $data = $session ? $session['data'] : false;
49
 
50
  // Not started yet, setup session
51
  if ( $data === false ) {
65
  wppa_log( 'Error', 'Unable to create session.' );
66
  return false;
67
  }
68
+ $wppa_session = array();
69
+ $wppa_session['page'] = '0';
70
  $wppa_session['ajax'] = '0';
71
  $wppa_session['id'] = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `".WPPA_SESSION."` WHERE `session` = %s LIMIT 1", wppa_get_session_id() ) );
 
 
 
 
 
 
72
  }
73
 
74
  // Session exists, Update counter
75
  else {
76
  $wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_SESSION."` SET `count` = %s WHERE `id` = %s", $session['count'] + '1', $session['id'] ) );
77
+ $data_arr = unserialize( $data );
78
+ if ( is_array( $data_arr ) ) {
79
+ $wppa_session = $data_arr;
80
+ }
81
+ else {
82
+ $wppa_session = array();
83
+ }
84
  }
85
 
86
  // Get info for root and sub search
110
  $wppa_session['display_searchstring'] = str_replace ( ',', ' &#8746 ', str_replace ( ' ', ' &#8745 ', $wppa_session['use_searchstring'] ) );
111
  }
112
  }
 
 
 
 
 
 
 
 
 
 
113
 
114
+ // Add missing defaults
115
+ $defaults = array(
116
+ 'has_searchbox' => false,
117
+ 'rootbox' => false,
118
+ 'search_root' => '',
119
+ 'subbox' => false,
120
+ 'use_searchstring' => '',
121
+ 'display_searchstring' => '',
122
+ 'supersearch' => '',
123
+ 'superview' => 'thumbs',
124
+ 'superalbum' => '0',
125
+ 'page' => '0',
126
+ 'ajax' => '0',
127
+ );
128
+
129
+ $wppa_session = wp_parse_args( $wppa_session, $defaults );
130
+ ksort( $wppa_session );
131
+
132
+ $wppa_session['page']++;
133
+
134
+ wppa_save_session();
135
+
136
  return true;
137
  }
138
 
139
  // Saves the session data. To be called at shutdown
140
  function wppa_session_end() {
141
+ wppa_save_session();
142
+ }
143
+
144
+ function wppa_save_session() {
145
  global $wpdb;
146
  global $wppa_session;
147
 
wppa-settings-autosave.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all options
6
- * Version 6.3.8
7
  *
8
  */
9
 
@@ -7251,6 +7251,7 @@ global $wppa_tags;
7251
  $name = __('Exclude separate', 'wp-photo-album-plus');
7252
  $desc = __('Do not search \'separate\' albums.', 'wp-photo-album-plus');
7253
  $help = esc_js(__('When checked, albums (and photos in them) that have the parent set to --- separate --- will be excluded from being searched.', 'wp-photo-album-plus'));
 
7254
  $slug = 'wppa_excl_sep';
7255
  $html = wppa_checkbox($slug);
7256
  $clas = '';
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all options
6
+ * Version 6.3.9
7
  *
8
  */
9
 
7251
  $name = __('Exclude separate', 'wp-photo-album-plus');
7252
  $desc = __('Do not search \'separate\' albums.', 'wp-photo-album-plus');
7253
  $help = esc_js(__('When checked, albums (and photos in them) that have the parent set to --- separate --- will be excluded from being searched.', 'wp-photo-album-plus'));
7254
+ $help .= '\n'.esc_js(__('Except when you start searching in a \'saparate\' album, with the "search in current section" box ticked.', 'wp-photo-album-plus'));
7255
  $slug = 'wppa_excl_sep';
7256
  $html = wppa_checkbox($slug);
7257
  $clas = '';
wppa-setup.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the setup stuff
6
- * Version 6.3.8
7
  *
8
  */
9
 
@@ -189,6 +189,10 @@ global $silent;
189
  // Although we do not rely om auto increment, it may help avoiding concurrency conflicts
190
  $wpdb->query( "ALTER TABLE `".WPPA_SESSION."` MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT" );
191
 
 
 
 
 
192
  // Convert any changed and remove obsolete setting options
193
  if ( $old_rev > '100' ) { // On update only
194
  if ( $old_rev <= '402' ) {
@@ -1111,7 +1115,7 @@ Hide Camera info
1111
 
1112
  // Table VII: Security
1113
  // B
1114
- 'wppa_owner_only' => 'no',
1115
  'wppa_upload_owner_only' => 'no',
1116
  'wppa_user_album_edit_on' => 'no',
1117
  'wppa_upload_moderate' => 'no',
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the setup stuff
6
+ * Version 6.3.9
7
  *
8
  */
9
 
189
  // Although we do not rely om auto increment, it may help avoiding concurrency conflicts
190
  $wpdb->query( "ALTER TABLE `".WPPA_SESSION."` MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT" );
191
 
192
+ // Clear Session
193
+ $wpdb->query( "TRUNCATE TABLE `".WPPA_SESSION."`" );
194
+ wppa_session_start();
195
+
196
  // Convert any changed and remove obsolete setting options
197
  if ( $old_rev > '100' ) { // On update only
198
  if ( $old_rev <= '402' ) {
1115
 
1116
  // Table VII: Security
1117
  // B
1118
+ 'wppa_owner_only' => 'yes',
1119
  'wppa_upload_owner_only' => 'no',
1120
  'wppa_user_album_edit_on' => 'no',
1121
  'wppa_upload_moderate' => 'no',
wppa-source.php CHANGED
@@ -3,41 +3,40 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains photo source file management routines
6
- * Version 6.3.0
7
  *
8
  */
9
-
10
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
11
-
12
  function wppa_save_source( $file, $name, $alb ) {
13
- global $wppa_opt;
14
 
15
  $doit = true;
16
-
17
  // Frontend not enabled and not ajax ?
18
  if ( ! is_admin() && ! wppa_switch('wppa_keep_source_frontend') ) {
19
- $doit = false;
20
  }
21
-
22
  // Frontend not enabled and ajax ?
23
  if ( isset( $_REQUEST['wppa-action'] ) &&
24
  $_REQUEST['wppa-action'] == 'do-fe-upload' &&
25
  ! wppa_switch('wppa_keep_source_frontend') ) {
26
- $doit = false;
27
  }
28
-
29
  // Backend not enabled ?
30
  if ( ( ! isset( $_REQUEST['wppa-action'] ) || $_REQUEST['wppa-action'] != 'do-fe-upload' ) &&
31
  is_admin() &&
32
  ! wppa_switch('wppa_keep_source_admin') ) {
33
- $doit = false;
34
  }
35
-
36
- if ( $doit ) {
37
- if ( ! is_dir( $wppa_opt['wppa_source_dir'] ) ) @ wppa_mktree( $wppa_opt['wppa_source_dir'] );
38
  $sourcedir = wppa_get_source_dir();
39
  if ( ! is_dir( $sourcedir ) ) @ wppa_mktree( $sourcedir );
40
- $albdir = wppa_get_source_album_dir( $alb );
41
  if ( ! is_dir( $albdir ) ) @ wppa_mktree( $albdir );
42
  if ( ! is_dir( $albdir ) ) {
43
  wppa_log( 'Err', 'Could not create source directory ' . $albdir );
@@ -51,25 +50,23 @@ global $wppa_opt;
51
  }
52
 
53
  function wppa_delete_source( $name, $alb ) {
54
- global $wppa_opt;
55
 
56
  if ( wppa_switch('wppa_keep_sync') ) {
57
  $path = wppa_get_source_album_dir( $alb ).'/'.$name;
58
  $path = wppa_strip_ext( $path );
59
  $all_paths = glob( $path . '.*' );
60
-
61
  // Delete all possible file-extensions
62
  foreach( $all_paths as $p ) if ( is_file( $p ) ) {
63
  @ unlink( $p ); // Ignore error
64
  }
65
-
66
  // Remove album if empty
67
  @ rmdir( wppa_get_source_album_dir( $alb ) ); // Ignore error
68
  }
69
  }
70
 
71
  function wppa_move_source( $name, $from, $to ) {
72
- global $wppa_opt;
73
  global $wppa_supported_photo_extensions;
74
 
75
  // Source files can have uppercase extensions.
@@ -84,7 +81,7 @@ global $wppa_supported_photo_extensions;
84
  $todir = wppa_get_source_album_dir( $to );
85
  $topath = wppa_get_source_album_dir( $to ).'/'.wppa_strip_ext($name);
86
  if ( ! is_dir( $todir ) ) @ wppa_mktree( $todir );
87
-
88
  foreach( $supext as $ext ) {
89
  if ( is_file( $frompath.'.'.$ext ) ) {
90
  @ rename( $frompath.'.'.$ext, $topath.'.'.$ext ); // will fail if target already exists
@@ -96,7 +93,6 @@ global $wppa_supported_photo_extensions;
96
  }
97
 
98
  function wppa_copy_source( $name, $from, $to ) {
99
- global $wppa_opt;
100
  global $wppa_supported_photo_extensions;
101
 
102
  // Source files can have uppercase extensions.
@@ -111,7 +107,7 @@ global $wppa_supported_photo_extensions;
111
  $todir = wppa_get_source_album_dir( $to );
112
  $topath = wppa_get_source_album_dir( $to ).'/'.wppa_strip_ext($name);
113
  if ( ! is_dir( $todir ) ) @ wppa_mktree( $todir );
114
-
115
  foreach( $supext as $ext ) {
116
  if ( is_file( $frompath.'.'.$ext ) ) {
117
  @ copy( $frompath.'.'.$ext, $topath.'.'.$ext ); // !
@@ -121,7 +117,6 @@ global $wppa_supported_photo_extensions;
121
  }
122
 
123
  function wppa_delete_album_source( $album ) {
124
- global $wppa_opt;
125
  if ( wppa_switch('wppa_keep_sync') ) {
126
  @ rmdir( wppa_get_source_album_dir( $album ) );
127
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains photo source file management routines
6
+ * Version 6.3.9
7
  *
8
  */
9
+
10
  if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
11
+
12
  function wppa_save_source( $file, $name, $alb ) {
 
13
 
14
  $doit = true;
15
+
16
  // Frontend not enabled and not ajax ?
17
  if ( ! is_admin() && ! wppa_switch('wppa_keep_source_frontend') ) {
18
+ $doit = false;
19
  }
20
+
21
  // Frontend not enabled and ajax ?
22
  if ( isset( $_REQUEST['wppa-action'] ) &&
23
  $_REQUEST['wppa-action'] == 'do-fe-upload' &&
24
  ! wppa_switch('wppa_keep_source_frontend') ) {
25
+ $doit = false;
26
  }
27
+
28
  // Backend not enabled ?
29
  if ( ( ! isset( $_REQUEST['wppa-action'] ) || $_REQUEST['wppa-action'] != 'do-fe-upload' ) &&
30
  is_admin() &&
31
  ! wppa_switch('wppa_keep_source_admin') ) {
32
+ $doit = false;
33
  }
34
+
35
+ if ( $doit ) {
36
+ if ( ! is_dir( wppa_opt( 'wppa_source_dir' ) ) ) @ wppa_mktree( wppa_opt( 'wppa_source_dir' ) );
37
  $sourcedir = wppa_get_source_dir();
38
  if ( ! is_dir( $sourcedir ) ) @ wppa_mktree( $sourcedir );
39
+ $albdir = wppa_get_source_album_dir( $alb );
40
  if ( ! is_dir( $albdir ) ) @ wppa_mktree( $albdir );
41
  if ( ! is_dir( $albdir ) ) {
42
  wppa_log( 'Err', 'Could not create source directory ' . $albdir );
50
  }
51
 
52
  function wppa_delete_source( $name, $alb ) {
 
53
 
54
  if ( wppa_switch('wppa_keep_sync') ) {
55
  $path = wppa_get_source_album_dir( $alb ).'/'.$name;
56
  $path = wppa_strip_ext( $path );
57
  $all_paths = glob( $path . '.*' );
58
+
59
  // Delete all possible file-extensions
60
  foreach( $all_paths as $p ) if ( is_file( $p ) ) {
61
  @ unlink( $p ); // Ignore error
62
  }
63
+
64
  // Remove album if empty
65
  @ rmdir( wppa_get_source_album_dir( $alb ) ); // Ignore error
66
  }
67
  }
68
 
69
  function wppa_move_source( $name, $from, $to ) {
 
70
  global $wppa_supported_photo_extensions;
71
 
72
  // Source files can have uppercase extensions.
81
  $todir = wppa_get_source_album_dir( $to );
82
  $topath = wppa_get_source_album_dir( $to ).'/'.wppa_strip_ext($name);
83
  if ( ! is_dir( $todir ) ) @ wppa_mktree( $todir );
84
+
85
  foreach( $supext as $ext ) {
86
  if ( is_file( $frompath.'.'.$ext ) ) {
87
  @ rename( $frompath.'.'.$ext, $topath.'.'.$ext ); // will fail if target already exists
93
  }
94
 
95
  function wppa_copy_source( $name, $from, $to ) {
 
96
  global $wppa_supported_photo_extensions;
97
 
98
  // Source files can have uppercase extensions.
107
  $todir = wppa_get_source_album_dir( $to );
108
  $topath = wppa_get_source_album_dir( $to ).'/'.wppa_strip_ext($name);
109
  if ( ! is_dir( $todir ) ) @ wppa_mktree( $todir );
110
+
111
  foreach( $supext as $ext ) {
112
  if ( is_file( $frompath.'.'.$ext ) ) {
113
  @ copy( $frompath.'.'.$ext, $topath.'.'.$ext ); // !
117
  }
118
 
119
  function wppa_delete_album_source( $album ) {
 
120
  if ( wppa_switch('wppa_keep_sync') ) {
121
  @ rmdir( wppa_get_source_album_dir( $album ) );
122
  }
wppa-statistics.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * Functions for counts etc
6
  * Common use front and admin
7
- * Version 6.3.8
8
  *
9
  */
10
 
@@ -12,9 +12,8 @@ if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
12
 
13
  // show system statistics
14
  function wppa_statistics() {
15
- global $wppa;
16
 
17
- $wppa['out'] .= wppa_get_statistics();
18
  }
19
  function wppa_get_statistics() {
20
 
@@ -172,6 +171,8 @@ global $wppa_session;
172
  $wpdb->query("UPDATE `".$table."` SET `views` = ".$count." WHERE `id` = ".$id);
173
  wppa_dbg_msg('Bumped viewcount for '.$type.' '.$id.' to '.$count, 'red');
174
  }
 
 
175
  }
176
 
177
  function wppa_get_upldr_cache() {
4
  *
5
  * Functions for counts etc
6
  * Common use front and admin
7
+ * Version 6.3.9
8
  *
9
  */
10
 
12
 
13
  // show system statistics
14
  function wppa_statistics() {
 
15
 
16
+ wppa_out( wppa_get_statistics() );
17
  }
18
  function wppa_get_statistics() {
19
 
171
  $wpdb->query("UPDATE `".$table."` SET `views` = ".$count." WHERE `id` = ".$id);
172
  wppa_dbg_msg('Bumped viewcount for '.$type.' '.$id.' to '.$count, 'red');
173
  }
174
+
175
+ wppa_save_session();
176
  }
177
 
178
  function wppa_get_upldr_cache() {
wppa-upload.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the upload/import pages and functions
6
- * Version 6.3.8
7
  *
8
  */
9
 
@@ -326,13 +326,12 @@ global $wppa_revno;
326
  // import images admin page
327
  function _wppa_page_import() {
328
  global $wppa_revno;
329
- global $wppa;
330
  global $wpdb;
331
  global $wppa_supported_photo_extensions;
332
  global $wppa_supported_video_extensions;
333
  global $wppa_supported_audio_extensions;
334
 
335
- if ( $wppa['ajax'] ) ob_start(); // Suppress output if ajax operation
336
 
337
  // Init
338
  $ngg_opts = get_option( 'ngg_options', false );
@@ -410,10 +409,10 @@ global $wppa_supported_audio_extensions;
410
 
411
  // Hit the submit button
412
  if ( isset( $_POST['wppa-import-submit'] ) ) {
413
- if ( $wppa['ajax'] ) {
414
  if ( ! wp_verify_nonce( $_POST['wppa-update-check'], '$wppa_nonce' ) ) {
415
  echo $_POST['wppa-update-check'].' Security check failure';
416
- exit;
417
  }
418
  }
419
  else {
@@ -435,18 +434,18 @@ global $wppa_supported_audio_extensions;
435
  }
436
 
437
  // If we did this by ajax, setup reporting results for it
438
- if ( $wppa['ajax'] ) {
439
  ob_end_clean();
440
- if ( $wppa['ajax_import_files_done'] ) {
441
- echo '<span style="color:green" >'.$wppa['ajax_import_files'].' '.__( 'Done!' , 'wp-photo-album-plus').'</span>';
442
  }
443
- elseif ( $wppa['ajax_import_files_error'] ) {
444
- echo '<span style="color:red" >'.$wppa['ajax_import_files'].' '.$wppa['ajax_import_files_error'].'</span>';
445
  }
446
  else {
447
- echo '<span style="color:red" >'.$wppa['ajax_import_files'].' '.__( 'Failed!' , 'wp-photo-album-plus').'</span>';
448
  }
449
- exit;
450
  }
451
 
452
  // Sanitize again
@@ -500,8 +499,8 @@ global $wppa_supported_audio_extensions;
500
  else $is_ngg = false;
501
  }
502
  if ( $source_type == 'remote' ) {
503
- $wppa['is_remote'] = true;
504
- $source = get_option( 'wppa_import_source_url_'.$user, 'http://' );
505
  $source_path = $source;
506
  $source_url = $source;
507
  $is_depot = false;
@@ -780,7 +779,7 @@ global $wppa_supported_audio_extensions;
780
  </span>
781
  <?php
782
  if ( wppa_switch( 'wppa_import_preview' ) ) {
783
- if ( $wppa['is_remote'] ) {
784
  if ( strpos( $file, '//res.cloudinary.com/' ) !== false ) {
785
  $img_url = dirname( $file ) . '/h_144/' . basename( $file );
786
  }
@@ -1200,7 +1199,7 @@ global $wppa_supported_audio_extensions;
1200
  <?php $url = wppa_dbg_url( get_admin_url().'admin.php?page=wppa_admin_menu' ); ?>
1201
  <p><?php _e( 'No albums exist. You must' , 'wp-photo-album-plus'); ?> <a href="<?php echo( $url ) ?>"><?php _e( 'create one' , 'wp-photo-album-plus'); ?></a> <?php _e( 'beofre you can upload your photos.' , 'wp-photo-album-plus'); ?></p><?php
1202
  }
1203
- if ( $wppa['continue'] ) {
1204
  wppa_warning_message( __( 'Trying to continue...' , 'wp-photo-album-plus') );
1205
  echo '<script type="text/javascript">document.location=\''.get_admin_url().'admin.php?page=wppa_import_photos&continue&nonce='.wp_create_nonce( 'dirimport' ).'\';</script>';
1206
  } ?>
@@ -1237,16 +1236,14 @@ function wppa_get_import_files() {
1237
 
1238
  // assume not
1239
  if ( is_array( @ getimagesize( $setting ) ) ) {
1240
- global $wppa;
1241
- $wppa['is_wppa_tree'] = false;
1242
  }
1243
 
1244
  // though?
1245
  else {
1246
  $setting = wppa_expand_tree_path( $old_setting );
1247
  if ( is_array( @ getimagesize( $setting ) ) ) {
1248
- global $wppa;
1249
- $wppa['is_wppa_tree'] = true;
1250
  }
1251
  }
1252
 
@@ -1458,7 +1455,6 @@ global $target;
1458
  function wppa_import_photos( $delp = false, $dela = false, $delz = false, $delv = false, $delu = false, $delc = false ) {
1459
  global $wpdb;
1460
  global $warning_given;
1461
- global $wppa;
1462
  global $wppa_supported_photo_extensions;
1463
  global $wppa_supported_video_extensions;
1464
  global $wppa_supported_audio_extensions;
@@ -1468,7 +1464,7 @@ global $wppa_supported_audio_extensions;
1468
  // Get this users current source directory setting
1469
  $user = wppa_get_user();
1470
  $source_type = get_option( 'wppa_import_source_type_'.$user, 'local' );
1471
- if ( $source_type == 'remote' ) $wppa['is_remote'] = true;
1472
  $source = get_option( 'wppa_import_source_'.$user, WPPA_DEPOT );
1473
 
1474
  $depot = WPPA_ABSPATH . $source; // Filesystem
@@ -1623,12 +1619,12 @@ global $wppa_supported_audio_extensions;
1623
  $file = $file.'_backup';
1624
  }
1625
  $file = wppa_sanitize_file_name( $file );
1626
- if ( isset( $_POST['file-'.$idx] ) || $wppa['ajax'] ) {
1627
  if ( wppa( 'is_wppa_tree' ) ) {
1628
- if ( $wppa['ajax'] ) $wppa['ajax_import_files'] = basename( wppa_compress_tree_path( $file ) );
1629
  }
1630
  else {
1631
- if ( $wppa['ajax'] ) $wppa['ajax_import_files'] = basename( $file ); /* */
1632
  }
1633
  $ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
1634
  $ext = str_replace( '_backup', '', $ext );
@@ -1684,7 +1680,7 @@ global $wppa_supported_audio_extensions;
1684
  // Make new files
1685
  $bret = wppa_make_the_photo_files( $file, $is_poster, strtolower( wppa_get_ext( basename( $file ) ) ) );
1686
  if ( $bret ) { // Success
1687
- if ( $wppa['ajax'] ) $wppa['ajax_import_files_done'] = true;
1688
  wppa_save_source( $file, basename( $file ), $alb );
1689
  $pcount++;
1690
  $totpcount += $bret;
@@ -1693,7 +1689,7 @@ global $wppa_supported_audio_extensions;
1693
  }
1694
  }
1695
  else { // Failed
1696
- if ( ! $wppa['ajax'] ) {
1697
  wppa_error_message('Failed to add poster for item '.$is_poster);
1698
  }
1699
  }
@@ -1709,7 +1705,7 @@ global $wppa_supported_audio_extensions;
1709
 
1710
  $iret = wppa_update_photo_files( $unsanitized_path_name, $name );
1711
  if ( $iret ) {
1712
- if ( $wppa['ajax'] ) $wppa['ajax_import_files_done'] = true;
1713
  $pcount++;
1714
  $totpcount += $iret;
1715
  if ( $delp ) {
@@ -1731,14 +1727,14 @@ global $wppa_supported_audio_extensions;
1731
  }
1732
  if ( wppa_switch( 'wppa_void_dups' ) && wppa_file_is_in_album( $id, $alb ) ) {
1733
  wppa_error_message( sprintf( __( 'Photo %s already exists in album %s. (1)' , 'wp-photo-album-plus'), $id, $alb ) );
1734
- $wppa['ajax_import_files_error'] = __( 'Duplicate' , 'wp-photo-album-plus');
1735
  }
1736
  else {
1737
  $id = substr( $id, 0, strpos( $id, '.' ) );
1738
  if ( !is_numeric( $id ) || ! wppa_is_id_free( 'photo', $id ) ) $id = 0;
1739
  if ( wppa_insert_photo( $unsanitized_path_name, $alb, stripslashes( $name ), stripslashes( $desc ), $porder, $id, stripslashes( $linkurl ), stripslashes( $linktitle ) ) ) {
1740
- if ( $wppa['ajax'] ) {
1741
- $wppa['ajax_import_files_done'] = true;
1742
  }
1743
  $pcount++;
1744
  if ( $delp ) {
@@ -1747,7 +1743,6 @@ global $wppa_supported_audio_extensions;
1747
  }
1748
  }
1749
  else {
1750
- // $wppa['ajax_import_files_error'] = __( 'Insert err', 'wp-photo-album-plus');
1751
  wppa_error_message( __( 'Error inserting photo' , 'wp-photo-album-plus') . ' ' . basename( $file ) . '.' );
1752
  }
1753
  }
@@ -1782,7 +1777,7 @@ global $wppa_supported_audio_extensions;
1782
  if ( is_dir( $file ) ) {
1783
  $iret = wppa_import_dir_to_album( $file, '0' );
1784
  if ( wppa_is_time_up() && wppa_switch( 'wppa_auto_continue' ) ) {
1785
- $wppa['continue'] = 'continue';
1786
  }
1787
  $dircount++;
1788
  }
@@ -1794,13 +1789,13 @@ global $wppa_supported_audio_extensions;
1794
  // Now the video files
1795
  $videocount = '0';
1796
  $alb = isset( $_POST['wppa-video-album'] ) ? $_POST['wppa-video-album'] : '0';
1797
- if ( $wppa['ajax'] && ! $alb ) {
1798
- $wppa['ajax_import_files_error'] = __( 'Unknown album' , 'wp-photo-album-plus');
1799
  }
1800
  else foreach ( array_keys( $files ) as $idx ) {
1801
  $file = $files[$idx];
1802
- if ( isset( $_POST['file-'.$idx] ) || $wppa['ajax'] ) {
1803
- if ( $wppa['ajax'] ) $wppa['ajax_import_files'] = wppa_sanitize_file_name( basename( $file ) ); /* */
1804
  $ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
1805
  if ( in_array( $ext, $wppa_supported_video_extensions ) ) {
1806
  if ( is_numeric( $alb ) && $alb != '0' ) {
@@ -1835,8 +1830,8 @@ global $wppa_supported_audio_extensions;
1835
  $newpath = wppa_strip_ext( wppa_get_photo_path( $id ) ).'.'.$ext;
1836
  copy( $file, $newpath );
1837
  if ( $delv ) unlink( $file );
1838
- if ( $wppa['ajax'] ) {
1839
- $wppa['ajax_import_files_done'] = true;
1840
  }
1841
 
1842
  // Make sure ext is set to xxx after adding video to an existing poster
@@ -1855,13 +1850,13 @@ global $wppa_supported_audio_extensions;
1855
  // Now the audio files
1856
  $audiocount = '0';
1857
  $alb = isset( $_POST['wppa-audio-album'] ) ? $_POST['wppa-audio-album'] : '0';
1858
- if ( $wppa['ajax'] && ! $alb ) {
1859
- $wppa['ajax_import_files_error'] = __( 'Unknown album' , 'wp-photo-album-plus');
1860
  }
1861
  else foreach ( array_keys( $files ) as $idx ) {
1862
  $file = $files[$idx];
1863
- if ( isset( $_POST['file-'.$idx] ) || $wppa['ajax'] ) {
1864
- if ( $wppa['ajax'] ) $wppa['ajax_import_files'] = wppa_sanitize_file_name( basename( $file ) ); /* */
1865
  $ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
1866
  if ( in_array( $ext, $wppa_supported_audio_extensions ) ) {
1867
  if ( is_numeric( $alb ) && $alb != '0' ) {
@@ -1896,8 +1891,8 @@ global $wppa_supported_audio_extensions;
1896
  $newpath = wppa_strip_ext( wppa_get_photo_path( $id ) ).'.'.$ext;
1897
  copy( $file, $newpath );
1898
  if ( $delu ) unlink( $file );
1899
- if ( $wppa['ajax'] ) {
1900
- $wppa['ajax_import_files_done'] = true;
1901
  }
1902
 
1903
  // Make sure ext is set to xxx after adding audio to an existing poster
@@ -1917,7 +1912,7 @@ global $wppa_supported_audio_extensions;
1917
  $csvcount = wppa_get_csvcount( $files );
1918
  if ( $csvcount ) {
1919
  $csvcount = '0';
1920
- if ( ! $wppa['ajax'] ) {
1921
  if ( is_array( $files ) ) {
1922
 
1923
  // Make sure the feature is on
@@ -2069,7 +2064,7 @@ global $wppa_supported_audio_extensions;
2069
 
2070
  // Time up?
2071
  if ( wppa_is_time_up() && wppa_switch( 'wppa_auto_continue' ) ) {
2072
- $wppa['continue'] = 'continue';
2073
 
2074
  // Copy rest of file back to original
2075
  while ( ! feof( $handle ) ) {
@@ -2334,7 +2329,14 @@ global $wpdb;
2334
  // see if album exists
2335
  if ( is_dir( $file ) ) {
2336
  $alb = wppa_get_album_id( basename( $file ), $parent );
2337
- if ( !$alb ) { // Album must be created
 
 
 
 
 
 
 
2338
  $name = basename( $file );
2339
  $uplim = wppa_opt( 'wppa_upload_limit_count' ). '/' . wppa_opt( 'wppa_upload_limit_time' );
2340
  $alb = wppa_create_album_entry( array ( 'name' => $name,
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the upload/import pages and functions
6
+ * Version 6.3.9
7
  *
8
  */
9
 
326
  // import images admin page
327
  function _wppa_page_import() {
328
  global $wppa_revno;
 
329
  global $wpdb;
330
  global $wppa_supported_photo_extensions;
331
  global $wppa_supported_video_extensions;
332
  global $wppa_supported_audio_extensions;
333
 
334
+ if ( wppa( 'ajax' ) ) ob_start(); // Suppress output if ajax operation
335
 
336
  // Init
337
  $ngg_opts = get_option( 'ngg_options', false );
409
 
410
  // Hit the submit button
411
  if ( isset( $_POST['wppa-import-submit'] ) ) {
412
+ if ( wppa( 'ajax' ) ) {
413
  if ( ! wp_verify_nonce( $_POST['wppa-update-check'], '$wppa_nonce' ) ) {
414
  echo $_POST['wppa-update-check'].' Security check failure';
415
+ wppa_exit();
416
  }
417
  }
418
  else {
434
  }
435
 
436
  // If we did this by ajax, setup reporting results for it
437
+ if ( wppa( 'ajax' ) ) {
438
  ob_end_clean();
439
+ if ( wppa( 'ajax_import_files_done' ) ) {
440
+ echo '<span style="color:green" >' . wppa( 'ajax_import_files' ) . ' ' . __( 'Done!', 'wp-photo-album-plus' ) . '</span>';
441
  }
442
+ elseif ( wppa( 'ajax_import_files_error' ) ) {
443
+ echo '<span style="color:red" >' . wppa( 'ajax_import_files' ) . ' ' . wppa( 'ajax_import_files_error' ) . '</span>';
444
  }
445
  else {
446
+ echo '<span style="color:red" >' . wppa( 'ajax_import_files' ) . ' ' . __( 'Failed!', 'wp-photo-album-plus' ) . '</span>';
447
  }
448
+ wppa_exit();
449
  }
450
 
451
  // Sanitize again
499
  else $is_ngg = false;
500
  }
501
  if ( $source_type == 'remote' ) {
502
+ wppa( 'is_remote', true );
503
+ $source = get_option( 'wppa_import_source_url_' . $user, 'http://' );
504
  $source_path = $source;
505
  $source_url = $source;
506
  $is_depot = false;
779
  </span>
780
  <?php
781
  if ( wppa_switch( 'wppa_import_preview' ) ) {
782
+ if ( wppa( 'is_remote' ) ) {
783
  if ( strpos( $file, '//res.cloudinary.com/' ) !== false ) {
784
  $img_url = dirname( $file ) . '/h_144/' . basename( $file );
785
  }
1199
  <?php $url = wppa_dbg_url( get_admin_url().'admin.php?page=wppa_admin_menu' ); ?>
1200
  <p><?php _e( 'No albums exist. You must' , 'wp-photo-album-plus'); ?> <a href="<?php echo( $url ) ?>"><?php _e( 'create one' , 'wp-photo-album-plus'); ?></a> <?php _e( 'beofre you can upload your photos.' , 'wp-photo-album-plus'); ?></p><?php
1201
  }
1202
+ if ( wppa( 'continue' ) ) {
1203
  wppa_warning_message( __( 'Trying to continue...' , 'wp-photo-album-plus') );
1204
  echo '<script type="text/javascript">document.location=\''.get_admin_url().'admin.php?page=wppa_import_photos&continue&nonce='.wp_create_nonce( 'dirimport' ).'\';</script>';
1205
  } ?>
1236
 
1237
  // assume not
1238
  if ( is_array( @ getimagesize( $setting ) ) ) {
1239
+ wppa( 'is_wppa_tree', false );
 
1240
  }
1241
 
1242
  // though?
1243
  else {
1244
  $setting = wppa_expand_tree_path( $old_setting );
1245
  if ( is_array( @ getimagesize( $setting ) ) ) {
1246
+ wppa( 'is_wppa_tree', true );
 
1247
  }
1248
  }
1249
 
1455
  function wppa_import_photos( $delp = false, $dela = false, $delz = false, $delv = false, $delu = false, $delc = false ) {
1456
  global $wpdb;
1457
  global $warning_given;
 
1458
  global $wppa_supported_photo_extensions;
1459
  global $wppa_supported_video_extensions;
1460
  global $wppa_supported_audio_extensions;
1464
  // Get this users current source directory setting
1465
  $user = wppa_get_user();
1466
  $source_type = get_option( 'wppa_import_source_type_'.$user, 'local' );
1467
+ if ( $source_type == 'remote' ) wppa( 'is_remote', true );
1468
  $source = get_option( 'wppa_import_source_'.$user, WPPA_DEPOT );
1469
 
1470
  $depot = WPPA_ABSPATH . $source; // Filesystem
1619
  $file = $file.'_backup';
1620
  }
1621
  $file = wppa_sanitize_file_name( $file );
1622
+ if ( isset( $_POST['file-'.$idx] ) || wppa( 'ajax' ) ) {
1623
  if ( wppa( 'is_wppa_tree' ) ) {
1624
+ if ( wppa( 'ajax' ) ) wppa( 'ajax_import_files', basename( wppa_compress_tree_path( $file ) ) );
1625
  }
1626
  else {
1627
+ if ( wppa( 'ajax' ) ) wppa( 'ajax_import_files', basename( $file ) );
1628
  }
1629
  $ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
1630
  $ext = str_replace( '_backup', '', $ext );
1680
  // Make new files
1681
  $bret = wppa_make_the_photo_files( $file, $is_poster, strtolower( wppa_get_ext( basename( $file ) ) ) );
1682
  if ( $bret ) { // Success
1683
+ if ( wppa( 'ajax' ) ) wppa( 'ajax_import_files_done', true );
1684
  wppa_save_source( $file, basename( $file ), $alb );
1685
  $pcount++;
1686
  $totpcount += $bret;
1689
  }
1690
  }
1691
  else { // Failed
1692
+ if ( ! wppa( 'ajax' ) ) {
1693
  wppa_error_message('Failed to add poster for item '.$is_poster);
1694
  }
1695
  }
1705
 
1706
  $iret = wppa_update_photo_files( $unsanitized_path_name, $name );
1707
  if ( $iret ) {
1708
+ if ( wppa( 'ajax' ) ) wppa( 'ajax_import_files_done', true );
1709
  $pcount++;
1710
  $totpcount += $iret;
1711
  if ( $delp ) {
1727
  }
1728
  if ( wppa_switch( 'wppa_void_dups' ) && wppa_file_is_in_album( $id, $alb ) ) {
1729
  wppa_error_message( sprintf( __( 'Photo %s already exists in album %s. (1)' , 'wp-photo-album-plus'), $id, $alb ) );
1730
+ wppa( 'ajax_import_files_error', __( 'Duplicate', 'wp-photo-album-plus') );
1731
  }
1732
  else {
1733
  $id = substr( $id, 0, strpos( $id, '.' ) );
1734
  if ( !is_numeric( $id ) || ! wppa_is_id_free( 'photo', $id ) ) $id = 0;
1735
  if ( wppa_insert_photo( $unsanitized_path_name, $alb, stripslashes( $name ), stripslashes( $desc ), $porder, $id, stripslashes( $linkurl ), stripslashes( $linktitle ) ) ) {
1736
+ if ( wppa( 'ajax' ) ) {
1737
+ wppa( 'ajax_import_files_done', true );
1738
  }
1739
  $pcount++;
1740
  if ( $delp ) {
1743
  }
1744
  }
1745
  else {
 
1746
  wppa_error_message( __( 'Error inserting photo' , 'wp-photo-album-plus') . ' ' . basename( $file ) . '.' );
1747
  }
1748
  }
1777
  if ( is_dir( $file ) ) {
1778
  $iret = wppa_import_dir_to_album( $file, '0' );
1779
  if ( wppa_is_time_up() && wppa_switch( 'wppa_auto_continue' ) ) {
1780
+ wppa( 'continue', 'continue' );
1781
  }
1782
  $dircount++;
1783
  }
1789
  // Now the video files
1790
  $videocount = '0';
1791
  $alb = isset( $_POST['wppa-video-album'] ) ? $_POST['wppa-video-album'] : '0';
1792
+ if ( wppa( 'ajax' ) && ! $alb ) {
1793
+ wppa( 'ajax_import_files_error', __( 'Unknown album' , 'wp-photo-album-plus' ) );
1794
  }
1795
  else foreach ( array_keys( $files ) as $idx ) {
1796
  $file = $files[$idx];
1797
+ if ( isset( $_POST['file-'.$idx] ) || wppa( 'ajax' ) ) {
1798
+ if ( wppa( 'ajax' ) ) wppa( 'ajax_import_files', wppa_sanitize_file_name( basename( $file ) ) ); /* */
1799
  $ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
1800
  if ( in_array( $ext, $wppa_supported_video_extensions ) ) {
1801
  if ( is_numeric( $alb ) && $alb != '0' ) {
1830
  $newpath = wppa_strip_ext( wppa_get_photo_path( $id ) ).'.'.$ext;
1831
  copy( $file, $newpath );
1832
  if ( $delv ) unlink( $file );
1833
+ if ( wppa( 'ajax' ) ) {
1834
+ wppa( 'ajax_import_files_done', true );
1835
  }
1836
 
1837
  // Make sure ext is set to xxx after adding video to an existing poster
1850
  // Now the audio files
1851
  $audiocount = '0';
1852
  $alb = isset( $_POST['wppa-audio-album'] ) ? $_POST['wppa-audio-album'] : '0';
1853
+ if ( wppa( 'ajax' ) && ! $alb ) {
1854
+ wppa( 'ajax_import_files_error', __( 'Unknown album', 'wp-photo-album-plus' ) );
1855
  }
1856
  else foreach ( array_keys( $files ) as $idx ) {
1857
  $file = $files[$idx];
1858
+ if ( isset( $_POST['file-'.$idx] ) || wppa( 'ajax' ) ) {
1859
+ if ( wppa( 'ajax' ) ) wppa( 'ajax_import_files', wppa_sanitize_file_name( basename( $file ) ) );
1860
  $ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
1861
  if ( in_array( $ext, $wppa_supported_audio_extensions ) ) {
1862
  if ( is_numeric( $alb ) && $alb != '0' ) {
1891
  $newpath = wppa_strip_ext( wppa_get_photo_path( $id ) ).'.'.$ext;
1892
  copy( $file, $newpath );
1893
  if ( $delu ) unlink( $file );
1894
+ if ( wppa( 'ajax' ) ) {
1895
+ wppa( 'ajax_import_files_done', true );
1896
  }
1897
 
1898
  // Make sure ext is set to xxx after adding audio to an existing poster
1912
  $csvcount = wppa_get_csvcount( $files );
1913
  if ( $csvcount ) {
1914
  $csvcount = '0';
1915
+ if ( ! wppa( 'ajax' ) ) {
1916
  if ( is_array( $files ) ) {
1917
 
1918
  // Make sure the feature is on
2064
 
2065
  // Time up?
2066
  if ( wppa_is_time_up() && wppa_switch( 'wppa_auto_continue' ) ) {
2067
+ wppa( 'continue', 'continue' );
2068
 
2069
  // Copy rest of file back to original
2070
  while ( ! feof( $handle ) ) {
2329
  // see if album exists
2330
  if ( is_dir( $file ) ) {
2331
  $alb = wppa_get_album_id( basename( $file ), $parent );
2332
+
2333
+ // If parent = 0 ( top-level album ) and album not found,
2334
+ // try a 'separate' album ( i.e. parent = -1 ) with this name
2335
+ if ( ! $alb && $parent == '0' ) {
2336
+ $alb = wppa_get_album_id( basename( $file ), '-1' );
2337
+ }
2338
+
2339
+ if ( ! $alb ) { // Album must be created
2340
  $name = basename( $file );
2341
  $uplim = wppa_opt( 'wppa_upload_limit_count' ). '/' . wppa_opt( 'wppa_upload_limit_time' );
2342
  $alb = wppa_create_album_entry( array ( 'name' => $name,
wppa-utils.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level utility routines
6
- * Version 6.3.8
7
  *
8
  */
9
 
@@ -368,7 +368,10 @@ global $wppa;
368
 
369
  // Invalid key
370
  else {
371
- wppa_log( 'Error', '$wppa[\''.$key.'\'] is not defined' );
 
 
 
372
  return false;
373
  }
374
  }
@@ -382,6 +385,34 @@ global $wppa;
382
  return $oldval;
383
  }
384
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
385
  function wppa_display_root( $id ) {
386
  $all = __('All albums', 'wp-photo-album-plus' );
387
  if ( ! $id ) return $all;
@@ -1603,7 +1634,7 @@ function wppa_is_enum( $var ) {
1603
  return '' === str_replace( array( '0','1','2','3','4','5','6','7','8','9','.' ), '', $var );
1604
  }
1605
 
1606
- function wppa_log( $xtype, $msg ) {
1607
 
1608
  // Sanitize type
1609
  $t = strtolower( substr( $xtype, 0, 1 ) );
@@ -1660,10 +1691,10 @@ function wppa_log( $xtype, $msg ) {
1660
  if ( ! $file = fopen( $filename, 'ab' ) ) return; // Unable to open log file
1661
 
1662
  // Write log message
1663
- @ 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" );
1664
 
1665
- // Trace 3 levels for error logs
1666
- if ( $type == 'Err' || $type == 'Dbg' ) {
1667
  ob_start();
1668
  debug_print_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 4 );
1669
  $trace = ob_get_contents();
@@ -2917,4 +2948,9 @@ global $wppa;
2917
 
2918
  $wppa['out'] .= $txt;
2919
  return;
 
 
 
 
 
2920
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level utility routines
6
+ * Version 6.3.9
7
  *
8
  */
9
 
368
 
369
  // Invalid key
370
  else {
371
+ wppa_log( 'Obs', '$wppa[\''.$key.'\'] is not defined in reset_occurrance' );
372
+ if ( $newval != 'nil' ) {
373
+ $wppa[$key] = $newval;
374
+ }
375
  return false;
376
  }
377
  }
385
  return $oldval;
386
  }
387
 
388
+ // Add value to runtime parameter
389
+ function wppa_add( $key, $newval ) {
390
+ global $wppa;
391
+
392
+ // Array defined?
393
+ if ( is_array( $wppa ) ) {
394
+
395
+ // Valid key?
396
+ if ( isset( $wppa[$key] ) ) {
397
+
398
+ // Add new value
399
+ $wppa[$key] .= $newval;
400
+ }
401
+
402
+ // Invalid key
403
+ else {
404
+ wppa_log( 'Error', '$wppa[\''.$key.'\'] is not defined' );
405
+ return false;
406
+ }
407
+ }
408
+
409
+ // Array not defined
410
+ else {
411
+ wppa_log( 'Error', '$wppa[] is not initialized while testing \''.$key.'\'' );
412
+ return false;
413
+ }
414
+ }
415
+
416
  function wppa_display_root( $id ) {
417
  $all = __('All albums', 'wp-photo-album-plus' );
418
  if ( ! $id ) return $all;
1634
  return '' === str_replace( array( '0','1','2','3','4','5','6','7','8','9','.' ), '', $var );
1635
  }
1636
 
1637
+ function wppa_log( $xtype, $msg, $trace = false ) {
1638
 
1639
  // Sanitize type
1640
  $t = strtolower( substr( $xtype, 0, 1 ) );
1691
  if ( ! $file = fopen( $filename, 'ab' ) ) return; // Unable to open log file
1692
 
1693
  // Write log message
1694
+ @ 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" );
1695
 
1696
+ // Trace 4 levels if trace requested
1697
+ if ( $trace ) {
1698
  ob_start();
1699
  debug_print_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 4 );
1700
  $trace = ob_get_contents();
2948
 
2949
  $wppa['out'] .= $txt;
2950
  return;
2951
+ }
2952
+
2953
+ function wppa_exit() {
2954
+ wppa_session_end();
2955
+ exit;
2956
  }
wppa-video.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all video routines
6
- * Version 6.3.0
7
  *
8
  */
9
 
@@ -40,7 +40,6 @@ global $wppa_supported_video_extensions;
40
 
41
  // Return the html for video display
42
  function wppa_get_video_html( $args ) {
43
- global $wppa;
44
 
45
  extract( wp_parse_args( (array) $args, array (
46
  'id' => '0',
@@ -49,7 +48,7 @@ global $wppa;
49
  'controls' => true,
50
  'margin_top' => '0',
51
  'margin_bottom' => '0',
52
- 'tagid' => 'video-'.$wppa['mocc'],
53
  'cursor' => '',
54
  'events' => '',
55
  'title' => '',
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all video routines
6
+ * Version 6.3.9
7
  *
8
  */
9
 
40
 
41
  // Return the html for video display
42
  function wppa_get_video_html( $args ) {
 
43
 
44
  extract( wp_parse_args( (array) $args, array (
45
  'id' => '0',
48
  'controls' => true,
49
  'margin_top' => '0',
50
  'margin_bottom' => '0',
51
+ 'tagid' => 'video-' . wppa( 'mocc' ),
52
  'cursor' => '',
53
  'events' => '',
54
  'title' => '',
wppa-watermark.php CHANGED
@@ -2,7 +2,7 @@
2
  /* wppa-watermark.php
3
  *
4
  * Functions used for the application of watermarks
5
- * version 6.3.0
6
  *
7
  */
8
 
@@ -11,11 +11,11 @@ if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
11
  function wppa_create_textual_watermark_file( $args ) {
12
 
13
  // See what we have
14
- $args = wp_parse_args( ( array ) $args, array( 'content' => '---preview---',
15
  'pos' => 'cencen',
16
  'id' => '',
17
- 'font' => wppa_opt( 'wppa_textual_watermark_font' ),
18
- 'text' => '',
19
  'style' => wppa_opt( 'wppa_textual_watermark_type' ),
20
  'filebasename' => 'dummy',
21
  'url' => false,
@@ -33,7 +33,7 @@ function wppa_create_textual_watermark_file( $args ) {
33
  if ( $id && wppa_is_video( $id ) ) {
34
  // return false;
35
  }
36
-
37
  // Set special values in case of preview
38
  if ( $args['content'] == '---preview---' ) {
39
  $preview = true;
@@ -48,10 +48,10 @@ function wppa_create_textual_watermark_file( $args ) {
48
  $padding = 12;
49
  $linespacing = ceil( $fontsize * 2 / 3 );
50
  }
51
-
52
  // Set font specific vars
53
  $fontfile = $args['font'] == 'system' ? '' : WPPA_UPLOAD_PATH.'/fonts/'.$args['font'].'.ttf';
54
-
55
  // Output file
56
  if ( $preview ) $filename = WPPA_UPLOAD_PATH.'/fonts/wmf'.$args['filebasename'].'.png';
57
  else $filename = WPPA_UPLOAD_PATH.'/temp/wmf'.$args['filebasename'].'.png';
@@ -87,7 +87,7 @@ function wppa_create_textual_watermark_file( $args ) {
87
 
88
  $text = trim( $text );
89
  break;
90
-
91
  default:
92
  wppa_log( 'Error', 'Unimplemented arg '.$arg.' in wppa_create_textual_watermark_file()' );
93
  return false;
@@ -102,11 +102,11 @@ function wppa_create_textual_watermark_file( $args ) {
102
  wppa_log( 'Error', 'No text for textual watermark. photo='.$id );
103
  return false; // No text -> no watermark
104
  }
105
-
106
  // Split text on linebreaks
107
  $text = str_replace( "\n", '\n', $text );
108
  $lines = explode( '\n', $text );
109
-
110
  // Trim and remove empty lines
111
  $temp = $lines;
112
  $lines = array();
@@ -118,7 +118,7 @@ function wppa_create_textual_watermark_file( $args ) {
118
  // Find image width
119
  if ( $args['width'] ) $image_width = $args['width']; else $image_width = '';
120
  if ( $args['height'] ) $image_height = $args['height']; else $image_height = '';
121
-
122
  if ( $preview ) {
123
  if ( ! $image_width ) $image_width = 2000;
124
  if ( ! $image_height ) $image_height = 1000;
@@ -135,7 +135,7 @@ function wppa_create_textual_watermark_file( $args ) {
135
  }
136
 
137
  $width_fits = false;
138
-
139
  while ( ! $width_fits ) {
140
  // Find pixel linelengths
141
  foreach ( array_keys( $lines ) as $key ) {
@@ -190,7 +190,7 @@ function wppa_create_textual_watermark_file( $args ) {
190
  return false; // too wide
191
  }
192
  $lines[$j] = substr( $temp[$i], 0, $spos );
193
- $lines[$j+1] = trim( str_replace( $lines[$j], '', $temp[$i] ) );
194
  $i++;
195
  //
196
  $j = $i + 1;
@@ -207,7 +207,7 @@ function wppa_create_textual_watermark_file( $args ) {
207
  return false; // not an image
208
  }
209
  }
210
-
211
  // Create canvas
212
  $canvas = imagecreatetruecolor( $canvas_width, $canvas_height );
213
  $bgcolor = imagecolorallocatealpha( $canvas, 0, 0, 0, 127 ); // Transparent
@@ -267,15 +267,15 @@ function wppa_create_textual_watermark_file( $args ) {
267
  case 'blackonwhite':
268
  case 'whiteonblack':
269
  case 'white':
270
- case 'black':
271
  $lft = $padding + $indent;
272
  $rht = 3 * $padding + $indent + $lengths[$lineno];
273
  $top = $lineno * ( $lineheight + $linespacing ) + $padding;
274
  $bot = ( $lineno + 1 ) * ( $lineheight + $linespacing ) + $padding;
275
-
276
  imagefilledrectangle( $canvas, $lft, $top+1, $rht, $bot, $bg );
277
  // imagerectangle( $canvas, $lft, $top, $rht, $bot, $fg ); // debug
278
-
279
  $top = $padding + $lineno * ( $lineheight + $linespacing ) + floor( $linespacing/2 );
280
  $lft = 2 * $padding + $indent;
281
  $bot = $padding + ( $lineno + 1 ) * ( $lineheight + $linespacing ) - ceil( $linespacing/2 );
@@ -313,7 +313,7 @@ function wppa_get_water_file_and_pos( $id ) {
313
  $result['pos'] = wppa_opt( 'wppa_watermark_pos' ); // default
314
 
315
  $user = wppa_get_user();
316
-
317
  if ( wppa_switch( 'wppa_watermark_user' ) || current_user_can( 'wppa_settings' ) ) { // user overrule?
318
  if ( isset( $_POST['wppa-watermark-file'] ) ) {
319
  $result['file'] = $_POST['wppa-watermark-file'];
@@ -341,7 +341,7 @@ function wppa_get_water_file_and_pos( $id ) {
341
  return $result;
342
  }
343
 
344
-
345
  function wppa_add_watermark( $id ) {
346
 
347
  // Init
@@ -352,9 +352,9 @@ function wppa_add_watermark( $id ) {
352
  $temp = wppa_get_water_file_and_pos( $id );
353
  $waterfile = $temp['file'];
354
  if ( ! $waterfile ) return false; // an error has occurred
355
-
356
  $waterpos = $temp['pos']; // default
357
-
358
  if ( basename( $waterfile ) == '--- none ---' ) {
359
  return false; // No watermark this time
360
  }
@@ -369,7 +369,7 @@ function wppa_add_watermark( $id ) {
369
  imagealphablending( $waterimage, false );
370
  imagesavealpha( $waterimage, true );
371
 
372
-
373
  // Open the photo file
374
  $file = wppa_get_photo_path( $id );
375
  if ( wppa_is_video( $id ) ) {
@@ -401,12 +401,12 @@ function wppa_add_watermark( $id ) {
401
  if ( $ws_x > $ps_x ) {
402
  $src_x = ( $ws_x - $ps_x ) / 2;
403
  $ws_x = $ps_x;
404
- }
405
  if ( $ws_y > $ps_y ) {
406
  $src_y = ( $ws_y - $ps_y ) / 2;
407
  $ws_y = $ps_y;
408
  }
409
-
410
  $loy = substr( $waterpos, 0, 3 );
411
  switch( $loy ) {
412
  case 'top': $dest_y = 0;
@@ -505,24 +505,24 @@ function wppa_watermark_file_select( $default = false ) {
505
  // Init
506
  $result = '';
507
  $user = wppa_get_user();
508
-
509
  // See what's in there
510
  $paths = WPPA_UPLOAD_PATH . '/watermarks/*.png';
511
  $files = glob( $paths );
512
-
513
  // Find current selection
514
  $select = wppa_opt( 'wppa_watermark_file' ); // default
515
  if ( ! $default && ( wppa_switch( 'wppa_watermark_user' ) || current_user_can( 'wppa_settings' ) ) && get_option( 'wppa_watermark_file_' . $user, 'nil' ) !== 'nil' ) {
516
  $select = get_option( 'wppa_watermark_file_' . $user );
517
  }
518
-
519
  // Produce the html
520
  $result .= '<option value="--- none ---">'.__( '--- none ---' , 'wp-photo-album-plus' ).'</option>';
521
  if ( $files ) foreach ( $files as $file ) {
522
  $sel = $select == basename( $file ) ? 'selected="selected"' : '';
523
  $result .= '<option value="'.basename( $file ).'" '.$sel.'>'.basename( $file ).'</option>';
524
  }
525
-
526
  // Text based watermarks
527
  $sel = $select == '---name---' ? 'selected="selected"' : '';
528
  $result .= '<option value="---name---" '.$sel.'>'.__( '--- text: name ---' , 'wp-photo-album-plus' ).'</option>';
@@ -532,7 +532,7 @@ function wppa_watermark_file_select( $default = false ) {
532
  $result .= '<option value="---description---" '.$sel.'>'.__( '--- text: description ---' , 'wp-photo-album-plus' ).'</option>';
533
  $sel = $select == '---predef---' ? 'selected="selected"' : '';
534
  $result .= '<option value="---predef---" '.$sel.'>'.__( '--- text: pre-defined ---' , 'wp-photo-album-plus' ).'</option>';
535
-
536
  return $result;
537
  }
538
 
@@ -541,8 +541,8 @@ function wppa_watermark_pos_select( $default = false ) {
541
  // Init
542
  $user = wppa_get_user();
543
  $result = '';
544
- $opt = array( __( 'top - left' , 'wp-photo-album-plus' ), __( 'top - center' , 'wp-photo-album-plus' ), __( 'top - right' , 'wp-photo-album-plus' ),
545
- __( 'center - left' , 'wp-photo-album-plus' ), __( 'center - center' , 'wp-photo-album-plus' ), __( 'center - right' , 'wp-photo-album-plus' ),
546
  __( 'bottom - left' , 'wp-photo-album-plus' ), __( 'bottom - center' , 'wp-photo-album-plus' ), __( 'bottom - right' , 'wp-photo-album-plus' ), );
547
  $val = array( 'toplft', 'topcen', 'toprht',
548
  'cenlft', 'cencen', 'cenrht',
@@ -554,13 +554,13 @@ function wppa_watermark_pos_select( $default = false ) {
554
  if ( ! $default && ( wppa_switch( 'wppa_watermark_user' ) || current_user_can( 'wppa_settings' ) ) && get_option( 'wppa_watermark_pos_' . $user, 'nil' ) !== 'nil' ) {
555
  $select = get_option( 'wppa_watermark_pos_' . $user );
556
  }
557
-
558
  // Produce the html
559
  while ( $idx < 9 ) {
560
  $sel = $select == $val[$idx] ? 'selected="selected"' : '';
561
  $result .= '<option value="'.$val[$idx].'" '.$sel.'>'.$opt[$idx].'</option>';
562
  $idx++;
563
  }
564
-
565
  return $result;
566
  }
2
  /* wppa-watermark.php
3
  *
4
  * Functions used for the application of watermarks
5
+ * version 6.3.9
6
  *
7
  */
8
 
11
  function wppa_create_textual_watermark_file( $args ) {
12
 
13
  // See what we have
14
+ $args = wp_parse_args( ( array ) $args, array( 'content' => '---preview---',
15
  'pos' => 'cencen',
16
  'id' => '',
17
+ 'font' => wppa_opt( 'wppa_textual_watermark_font' ),
18
+ 'text' => '',
19
  'style' => wppa_opt( 'wppa_textual_watermark_type' ),
20
  'filebasename' => 'dummy',
21
  'url' => false,
33
  if ( $id && wppa_is_video( $id ) ) {
34
  // return false;
35
  }
36
+
37
  // Set special values in case of preview
38
  if ( $args['content'] == '---preview---' ) {
39
  $preview = true;
48
  $padding = 12;
49
  $linespacing = ceil( $fontsize * 2 / 3 );
50
  }
51
+
52
  // Set font specific vars
53
  $fontfile = $args['font'] == 'system' ? '' : WPPA_UPLOAD_PATH.'/fonts/'.$args['font'].'.ttf';
54
+
55
  // Output file
56
  if ( $preview ) $filename = WPPA_UPLOAD_PATH.'/fonts/wmf'.$args['filebasename'].'.png';
57
  else $filename = WPPA_UPLOAD_PATH.'/temp/wmf'.$args['filebasename'].'.png';
87
 
88
  $text = trim( $text );
89
  break;
90
+
91
  default:
92
  wppa_log( 'Error', 'Unimplemented arg '.$arg.' in wppa_create_textual_watermark_file()' );
93
  return false;
102
  wppa_log( 'Error', 'No text for textual watermark. photo='.$id );
103
  return false; // No text -> no watermark
104
  }
105
+
106
  // Split text on linebreaks
107
  $text = str_replace( "\n", '\n', $text );
108
  $lines = explode( '\n', $text );
109
+
110
  // Trim and remove empty lines
111
  $temp = $lines;
112
  $lines = array();
118
  // Find image width
119
  if ( $args['width'] ) $image_width = $args['width']; else $image_width = '';
120
  if ( $args['height'] ) $image_height = $args['height']; else $image_height = '';
121
+
122
  if ( $preview ) {
123
  if ( ! $image_width ) $image_width = 2000;
124
  if ( ! $image_height ) $image_height = 1000;
135
  }
136
 
137
  $width_fits = false;
138
+
139
  while ( ! $width_fits ) {
140
  // Find pixel linelengths
141
  foreach ( array_keys( $lines ) as $key ) {
190
  return false; // too wide
191
  }
192
  $lines[$j] = substr( $temp[$i], 0, $spos );
193
+ $lines[$j+1] = trim( str_replace( $lines[$j], '', $temp[$i] ) );
194
  $i++;
195
  //
196
  $j = $i + 1;
207
  return false; // not an image
208
  }
209
  }
210
+
211
  // Create canvas
212
  $canvas = imagecreatetruecolor( $canvas_width, $canvas_height );
213
  $bgcolor = imagecolorallocatealpha( $canvas, 0, 0, 0, 127 ); // Transparent
267
  case 'blackonwhite':
268
  case 'whiteonblack':
269
  case 'white':
270
+ case 'black':
271
  $lft = $padding + $indent;
272
  $rht = 3 * $padding + $indent + $lengths[$lineno];
273
  $top = $lineno * ( $lineheight + $linespacing ) + $padding;
274
  $bot = ( $lineno + 1 ) * ( $lineheight + $linespacing ) + $padding;
275
+
276
  imagefilledrectangle( $canvas, $lft, $top+1, $rht, $bot, $bg );
277
  // imagerectangle( $canvas, $lft, $top, $rht, $bot, $fg ); // debug
278
+
279
  $top = $padding + $lineno * ( $lineheight + $linespacing ) + floor( $linespacing/2 );
280
  $lft = 2 * $padding + $indent;
281
  $bot = $padding + ( $lineno + 1 ) * ( $lineheight + $linespacing ) - ceil( $linespacing/2 );
313
  $result['pos'] = wppa_opt( 'wppa_watermark_pos' ); // default
314
 
315
  $user = wppa_get_user();
316
+
317
  if ( wppa_switch( 'wppa_watermark_user' ) || current_user_can( 'wppa_settings' ) ) { // user overrule?
318
  if ( isset( $_POST['wppa-watermark-file'] ) ) {
319
  $result['file'] = $_POST['wppa-watermark-file'];
341
  return $result;
342
  }
343
 
344
+
345
  function wppa_add_watermark( $id ) {
346
 
347
  // Init
352
  $temp = wppa_get_water_file_and_pos( $id );
353
  $waterfile = $temp['file'];
354
  if ( ! $waterfile ) return false; // an error has occurred
355
+
356
  $waterpos = $temp['pos']; // default
357
+
358
  if ( basename( $waterfile ) == '--- none ---' ) {
359
  return false; // No watermark this time
360
  }
369
  imagealphablending( $waterimage, false );
370
  imagesavealpha( $waterimage, true );
371
 
372
+
373
  // Open the photo file
374
  $file = wppa_get_photo_path( $id );
375
  if ( wppa_is_video( $id ) ) {
401
  if ( $ws_x > $ps_x ) {
402
  $src_x = ( $ws_x - $ps_x ) / 2;
403
  $ws_x = $ps_x;
404
+ }
405
  if ( $ws_y > $ps_y ) {
406
  $src_y = ( $ws_y - $ps_y ) / 2;
407
  $ws_y = $ps_y;
408
  }
409
+
410
  $loy = substr( $waterpos, 0, 3 );
411
  switch( $loy ) {
412
  case 'top': $dest_y = 0;
505
  // Init
506
  $result = '';
507
  $user = wppa_get_user();
508
+
509
  // See what's in there
510
  $paths = WPPA_UPLOAD_PATH . '/watermarks/*.png';
511
  $files = glob( $paths );
512
+
513
  // Find current selection
514
  $select = wppa_opt( 'wppa_watermark_file' ); // default
515
  if ( ! $default && ( wppa_switch( 'wppa_watermark_user' ) || current_user_can( 'wppa_settings' ) ) && get_option( 'wppa_watermark_file_' . $user, 'nil' ) !== 'nil' ) {
516
  $select = get_option( 'wppa_watermark_file_' . $user );
517
  }
518
+
519
  // Produce the html
520
  $result .= '<option value="--- none ---">'.__( '--- none ---' , 'wp-photo-album-plus' ).'</option>';
521
  if ( $files ) foreach ( $files as $file ) {
522
  $sel = $select == basename( $file ) ? 'selected="selected"' : '';
523
  $result .= '<option value="'.basename( $file ).'" '.$sel.'>'.basename( $file ).'</option>';
524
  }
525
+
526
  // Text based watermarks
527
  $sel = $select == '---name---' ? 'selected="selected"' : '';
528
  $result .= '<option value="---name---" '.$sel.'>'.__( '--- text: name ---' , 'wp-photo-album-plus' ).'</option>';
532
  $result .= '<option value="---description---" '.$sel.'>'.__( '--- text: description ---' , 'wp-photo-album-plus' ).'</option>';
533
  $sel = $select == '---predef---' ? 'selected="selected"' : '';
534
  $result .= '<option value="---predef---" '.$sel.'>'.__( '--- text: pre-defined ---' , 'wp-photo-album-plus' ).'</option>';
535
+
536
  return $result;
537
  }
538
 
541
  // Init
542
  $user = wppa_get_user();
543
  $result = '';
544
+ $opt = array( __( 'top - left' , 'wp-photo-album-plus' ), __( 'top - center' , 'wp-photo-album-plus' ), __( 'top - right' , 'wp-photo-album-plus' ),
545
+ __( 'center - left' , 'wp-photo-album-plus' ), __( 'center - center' , 'wp-photo-album-plus' ), __( 'center - right' , 'wp-photo-album-plus' ),
546
  __( 'bottom - left' , 'wp-photo-album-plus' ), __( 'bottom - center' , 'wp-photo-album-plus' ), __( 'bottom - right' , 'wp-photo-album-plus' ), );
547
  $val = array( 'toplft', 'topcen', 'toprht',
548
  'cenlft', 'cencen', 'cenrht',
554
  if ( ! $default && ( wppa_switch( 'wppa_watermark_user' ) || current_user_can( 'wppa_settings' ) ) && get_option( 'wppa_watermark_pos_' . $user, 'nil' ) !== 'nil' ) {
555
  $select = get_option( 'wppa_watermark_pos_' . $user );
556
  }
557
+
558
  // Produce the html
559
  while ( $idx < 9 ) {
560
  $sel = $select == $val[$idx] ? 'selected="selected"' : '';
561
  $result .= '<option value="'.$val[$idx].'" '.$sel.'>'.$opt[$idx].'</option>';
562
  $idx++;
563
  }
564
+
565
  return $result;
566
  }
wppa-wpdb-insert.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level wpdb routines that add new records
6
- * Version 6.3.0
7
  *
8
  */
9
 
@@ -23,8 +23,8 @@ global $wpdb;
23
  'data' => false,
24
  'count' => '1'
25
  ) );
26
-
27
- $query = $wpdb->prepare("INSERT INTO `" . WPPA_SESSION ."` (
28
  `session`,
29
  `timestamp`,
30
  `user`,
@@ -34,7 +34,7 @@ global $wpdb;
34
  `count`
35
  )
36
  VALUES ( %s, %s, %s, %s, %s, %s, %s )",
37
-
38
  $args['session'],
39
  $args['timestamp'],
40
  $args['user'],
@@ -44,10 +44,10 @@ global $wpdb;
44
  $args['count']
45
  );
46
  $iret = @ $wpdb->query($query);
47
-
48
  return $iret;
49
- }
50
-
51
  // Index
52
  function wppa_create_index_entry( $args ) {
53
  global $wpdb;
@@ -58,9 +58,9 @@ global $wpdb;
58
  'albums' => '',
59
  'photos' => ''
60
  ) );
61
-
62
  if ( ! wppa_is_id_free( WPPA_INDEX, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_INDEX );
63
-
64
  $query = $wpdb->prepare("INSERT INTO `" . WPPA_INDEX . "` ( `id`,
65
  `slug`,
66
  `albums`,
@@ -73,11 +73,11 @@ global $wpdb;
73
  $args['photos']
74
  );
75
  $iret = $wpdb->query($query);
76
-
77
  if ( $iret ) return $args['id'];
78
  else return false;
79
- }
80
-
81
  // EXIF
82
  function wppa_create_exif_entry( $args ) {
83
  global $wpdb;
@@ -89,9 +89,9 @@ global $wpdb;
89
  'description' => '',
90
  'status' => ''
91
  ) );
92
-
93
  if ( ! wppa_is_id_free( WPPA_EXIF, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_EXIF );
94
-
95
  $query = $wpdb->prepare("INSERT INTO `" . WPPA_EXIF . "` ( `id`,
96
  `photo`,
97
  `tag`,
@@ -106,11 +106,11 @@ global $wpdb;
106
  $args['status']
107
  );
108
  $iret = $wpdb->query($query);
109
-
110
  if ( $iret ) return $args['id'];
111
  else return false;
112
- }
113
-
114
  // IPTC
115
  function wppa_create_iptc_entry( $args ) {
116
  global $wpdb;
@@ -122,9 +122,9 @@ global $wpdb;
122
  'description' => '',
123
  'status' => ''
124
  ) );
125
-
126
  if ( ! wppa_is_id_free( WPPA_IPTC, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_IPTC );
127
-
128
  $query = $wpdb->prepare("INSERT INTO `" . WPPA_IPTC . "` ( `id`,
129
  `photo`,
130
  `tag`,
@@ -139,11 +139,11 @@ global $wpdb;
139
  $args['status']
140
  );
141
  $iret = $wpdb->query($query);
142
-
143
  if ( $iret ) return $args['id'];
144
  else return false;
145
- }
146
-
147
  // Comments
148
  function wppa_create_comments_entry( $args ) {
149
  global $wpdb;
@@ -158,9 +158,9 @@ global $wpdb;
158
  'comment' => '',
159
  'status' => ''
160
  ) );
161
-
162
  if ( ! wppa_is_id_free( WPPA_COMMENTS, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_COMMENTS );
163
-
164
  $query = $wpdb->prepare("INSERT INTO `" . WPPA_COMMENTS . "` ( `id`,
165
  `timestamp`,
166
  `photo`,
@@ -181,10 +181,10 @@ global $wpdb;
181
  $args['status']
182
  );
183
  $iret = $wpdb->query($query);
184
-
185
  if ( $iret ) return $args['id'];
186
  else return false;
187
- }
188
 
189
  // Rating
190
  function wppa_create_rating_entry( $args ) {
@@ -198,9 +198,9 @@ global $wpdb;
198
  'user' => '',
199
  'status' => 'publish'
200
  ) );
201
-
202
  if ( ! wppa_is_id_free( WPPA_RATING, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_RATING );
203
-
204
  $query = $wpdb->prepare("INSERT INTO `" . WPPA_RATING . "` ( `id`,
205
  `timestamp`,
206
  `photo`,
@@ -217,7 +217,7 @@ global $wpdb;
217
  $args['status']
218
  );
219
  $iret = $wpdb->query($query);
220
-
221
  if ( $iret ) return $args['id'];
222
  else return false;
223
  }
@@ -227,11 +227,11 @@ function wppa_create_photo_entry( $args ) {
227
  global $wpdb;
228
 
229
  $args = wp_parse_args( (array) $args, array (
230
- 'id' => '0',
231
  'album' => '0',
232
  'ext' => 'jpg',
233
- 'name' => '',
234
- 'description' => '',
235
  'p_order' => '0',
236
  'mean_rating' => '',
237
  'linkurl' => '',
@@ -256,14 +256,14 @@ global $wpdb;
256
  ) );
257
 
258
  if ( $args['scheduledtm'] ) $args['status'] = 'scheduled';
259
-
260
  if ( ! wppa_is_id_free( WPPA_PHOTOS, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_PHOTOS );
261
-
262
- $query = $wpdb->prepare("INSERT INTO `" . WPPA_PHOTOS . "` ( `id`,
263
  `album`,
264
  `ext`,
265
- `name`,
266
- `description`,
267
  `p_order`,
268
  `mean_rating`,
269
  `linkurl`,
@@ -290,8 +290,8 @@ global $wpdb;
290
  $args['id'],
291
  $args['album'],
292
  $args['ext'],
293
- trim( $args['name'] ),
294
- trim( $args['description'] ),
295
  $args['p_order'],
296
  $args['mean_rating'],
297
  $args['linkurl'],
@@ -315,7 +315,7 @@ global $wpdb;
315
  $args['custom']
316
  );
317
  $iret = $wpdb->query($query);
318
-
319
  if ( $iret ) return $args['id'];
320
  else return false;
321
  }
@@ -324,7 +324,7 @@ global $wpdb;
324
  function wppa_create_album_entry( $args ) {
325
  global $wpdb;
326
 
327
- $args = wp_parse_args( (array) $args, array (
328
  'id' => '0',
329
  'name' => __( 'New Album', 'wp-photo-album-plus' ),
330
  'description' => '',
@@ -345,31 +345,31 @@ global $wpdb;
345
  'cats' => '',
346
  'scheduledtm' => ''
347
  ) );
348
-
349
  if ( ! wppa_is_id_free( WPPA_ALBUMS, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_ALBUMS );
350
-
351
- $query = $wpdb->prepare("INSERT INTO `" . WPPA_ALBUMS . "` ( `id`,
352
- `name`,
353
- `description`,
354
- `a_order`,
355
- `main_photo`,
356
- `a_parent`,
357
- `p_order_by`,
358
- `cover_linktype`,
359
- `cover_linkpage`,
360
- `owner`,
361
- `timestamp`,
362
- `upload_limit`,
363
- `alt_thumbsize`,
364
- `default_tags`,
365
- `cover_type`,
366
  `suba_order_by`,
367
  `views`,
368
  `cats`,
369
  `scheduledtm`
370
- )
371
- VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )",
372
- $args['id'],
373
  trim( $args['name'] ),
374
  trim( $args['description'] ),
375
  $args['a_order'],
@@ -390,7 +390,7 @@ global $wpdb;
390
  $args['scheduledtm']
391
  );
392
  $iret = $wpdb->query($query);
393
-
394
  if ( $iret ) return $args['id'];
395
  else return false;
396
  }
@@ -407,7 +407,7 @@ global $wpdb;
407
 
408
  $name = 'wppa_'.$table.'_lastkey';
409
  $lastkey = get_option( $name, 'nil' );
410
-
411
  if ( $lastkey == 'nil' ) { // Init option
412
  $lastkey = $wpdb->get_var( "SELECT `id` FROM `".$table."` WHERE `id` < '9223372036854775806' ORDER BY `id` DESC LIMIT 1" );
413
  wppa_dbg_q('Q207');
@@ -415,7 +415,7 @@ global $wpdb;
415
  add_option( $name, $lastkey, '', 'no');
416
  }
417
  wppa_dbg_msg('Lastkey in '.$table.' = '.$lastkey);
418
-
419
  $result = $lastkey + '1';
420
  while ( ! wppa_is_id_free( $table, $result ) ) {
421
  $result++;
@@ -430,17 +430,17 @@ global $wpdb;
430
 
431
  if ( ! is_numeric($id) ) return false;
432
  if ( $id == '0' ) return false;
433
-
434
  $table = '';
435
  if ( $type == 'album' ) $table = WPPA_ALBUMS;
436
  elseif ( $type == 'photo' ) $table = WPPA_PHOTOS;
437
  else $table = $type; // $type may be the tablename itsself
438
-
439
  if ( $table == '' ) {
440
  echo 'Unexpected error in wppa_is_id_free()';
441
  return false;
442
  }
443
-
444
  $exists = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".$table."` WHERE `id` = %s", $id ), ARRAY_A );
445
  wppa_dbg_q('Q208');
446
  if ( $exists ) return false;
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level wpdb routines that add new records
6
+ * Version 6.3.9
7
  *
8
  */
9
 
23
  'data' => false,
24
  'count' => '1'
25
  ) );
26
+
27
+ $query = $wpdb->prepare("INSERT INTO `" . WPPA_SESSION ."` (
28
  `session`,
29
  `timestamp`,
30
  `user`,
34
  `count`
35
  )
36
  VALUES ( %s, %s, %s, %s, %s, %s, %s )",
37
+
38
  $args['session'],
39
  $args['timestamp'],
40
  $args['user'],
44
  $args['count']
45
  );
46
  $iret = @ $wpdb->query($query);
47
+
48
  return $iret;
49
+ }
50
+
51
  // Index
52
  function wppa_create_index_entry( $args ) {
53
  global $wpdb;
58
  'albums' => '',
59
  'photos' => ''
60
  ) );
61
+
62
  if ( ! wppa_is_id_free( WPPA_INDEX, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_INDEX );
63
+
64
  $query = $wpdb->prepare("INSERT INTO `" . WPPA_INDEX . "` ( `id`,
65
  `slug`,
66
  `albums`,
73
  $args['photos']
74
  );
75
  $iret = $wpdb->query($query);
76
+
77
  if ( $iret ) return $args['id'];
78
  else return false;
79
+ }
80
+
81
  // EXIF
82
  function wppa_create_exif_entry( $args ) {
83
  global $wpdb;
89
  'description' => '',
90
  'status' => ''
91
  ) );
92
+
93
  if ( ! wppa_is_id_free( WPPA_EXIF, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_EXIF );
94
+
95
  $query = $wpdb->prepare("INSERT INTO `" . WPPA_EXIF . "` ( `id`,
96
  `photo`,
97
  `tag`,
106
  $args['status']
107
  );
108
  $iret = $wpdb->query($query);
109
+
110
  if ( $iret ) return $args['id'];
111
  else return false;
112
+ }
113
+
114
  // IPTC
115
  function wppa_create_iptc_entry( $args ) {
116
  global $wpdb;
122
  'description' => '',
123
  'status' => ''
124
  ) );
125
+
126
  if ( ! wppa_is_id_free( WPPA_IPTC, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_IPTC );
127
+
128
  $query = $wpdb->prepare("INSERT INTO `" . WPPA_IPTC . "` ( `id`,
129
  `photo`,
130
  `tag`,
139
  $args['status']
140
  );
141
  $iret = $wpdb->query($query);
142
+
143
  if ( $iret ) return $args['id'];
144
  else return false;
145
+ }
146
+
147
  // Comments
148
  function wppa_create_comments_entry( $args ) {
149
  global $wpdb;
158
  'comment' => '',
159
  'status' => ''
160
  ) );
161
+
162
  if ( ! wppa_is_id_free( WPPA_COMMENTS, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_COMMENTS );
163
+
164
  $query = $wpdb->prepare("INSERT INTO `" . WPPA_COMMENTS . "` ( `id`,
165
  `timestamp`,
166
  `photo`,
181
  $args['status']
182
  );
183
  $iret = $wpdb->query($query);
184
+
185
  if ( $iret ) return $args['id'];
186
  else return false;
187
+ }
188
 
189
  // Rating
190
  function wppa_create_rating_entry( $args ) {
198
  'user' => '',
199
  'status' => 'publish'
200
  ) );
201
+
202
  if ( ! wppa_is_id_free( WPPA_RATING, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_RATING );
203
+
204
  $query = $wpdb->prepare("INSERT INTO `" . WPPA_RATING . "` ( `id`,
205
  `timestamp`,
206
  `photo`,
217
  $args['status']
218
  );
219
  $iret = $wpdb->query($query);
220
+
221
  if ( $iret ) return $args['id'];
222
  else return false;
223
  }
227
  global $wpdb;
228
 
229
  $args = wp_parse_args( (array) $args, array (
230
+ 'id' => '0',
231
  'album' => '0',
232
  'ext' => 'jpg',
233
+ 'name' => '',
234
+ 'description' => '',
235
  'p_order' => '0',
236
  'mean_rating' => '',
237
  'linkurl' => '',
256
  ) );
257
 
258
  if ( $args['scheduledtm'] ) $args['status'] = 'scheduled';
259
+
260
  if ( ! wppa_is_id_free( WPPA_PHOTOS, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_PHOTOS );
261
+
262
+ $query = $wpdb->prepare("INSERT INTO `" . WPPA_PHOTOS . "` ( `id`,
263
  `album`,
264
  `ext`,
265
+ `name`,
266
+ `description`,
267
  `p_order`,
268
  `mean_rating`,
269
  `linkurl`,
290
  $args['id'],
291
  $args['album'],
292
  $args['ext'],
293
+ trim( $args['name'] ),
294
+ trim( $args['description'] ),
295
  $args['p_order'],
296
  $args['mean_rating'],
297
  $args['linkurl'],
315
  $args['custom']
316
  );
317
  $iret = $wpdb->query($query);
318
+
319
  if ( $iret ) return $args['id'];
320
  else return false;
321
  }
324
  function wppa_create_album_entry( $args ) {
325
  global $wpdb;
326
 
327
+ $args = wp_parse_args( (array) $args, array (
328
  'id' => '0',
329
  'name' => __( 'New Album', 'wp-photo-album-plus' ),
330
  'description' => '',
345
  'cats' => '',
346
  'scheduledtm' => ''
347
  ) );
348
+
349
  if ( ! wppa_is_id_free( WPPA_ALBUMS, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_ALBUMS );
350
+
351
+ $query = $wpdb->prepare("INSERT INTO `" . WPPA_ALBUMS . "` ( `id`,
352
+ `name`,
353
+ `description`,
354
+ `a_order`,
355
+ `main_photo`,
356
+ `a_parent`,
357
+ `p_order_by`,
358
+ `cover_linktype`,
359
+ `cover_linkpage`,
360
+ `owner`,
361
+ `timestamp`,
362
+ `upload_limit`,
363
+ `alt_thumbsize`,
364
+ `default_tags`,
365
+ `cover_type`,
366
  `suba_order_by`,
367
  `views`,
368
  `cats`,
369
  `scheduledtm`
370
+ )
371
+ VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )",
372
+ $args['id'],
373
  trim( $args['name'] ),
374
  trim( $args['description'] ),
375
  $args['a_order'],
390
  $args['scheduledtm']
391
  );
392
  $iret = $wpdb->query($query);
393
+
394
  if ( $iret ) return $args['id'];
395
  else return false;
396
  }
407
 
408
  $name = 'wppa_'.$table.'_lastkey';
409
  $lastkey = get_option( $name, 'nil' );
410
+
411
  if ( $lastkey == 'nil' ) { // Init option
412
  $lastkey = $wpdb->get_var( "SELECT `id` FROM `".$table."` WHERE `id` < '9223372036854775806' ORDER BY `id` DESC LIMIT 1" );
413
  wppa_dbg_q('Q207');
415
  add_option( $name, $lastkey, '', 'no');
416
  }
417
  wppa_dbg_msg('Lastkey in '.$table.' = '.$lastkey);
418
+
419
  $result = $lastkey + '1';
420
  while ( ! wppa_is_id_free( $table, $result ) ) {
421
  $result++;
430
 
431
  if ( ! is_numeric($id) ) return false;
432
  if ( $id == '0' ) return false;
433
+
434
  $table = '';
435
  if ( $type == 'album' ) $table = WPPA_ALBUMS;
436
  elseif ( $type == 'photo' ) $table = WPPA_PHOTOS;
437
  else $table = $type; // $type may be the tablename itsself
438
+
439
  if ( $table == '' ) {
440
  echo 'Unexpected error in wppa_is_id_free()';
441
  return false;
442
  }
443
+
444
  $exists = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".$table."` WHERE `id` = %s", $id ), ARRAY_A );
445
  wppa_dbg_q('Q208');
446
  if ( $exists ) return false;
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.3.8
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/
@@ -19,7 +19,7 @@ if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
19
  // add_filter( 'run_wptexturize', '__return_false' );
20
 
21
  /* See explanation on activation hook in wppa-setup.php */
22
- register_activation_hook(__FILE__, 'wppa_activate_plugin');
23
 
24
  /* GLOBALS */
25
  global $wpdb;
@@ -29,12 +29,12 @@ global $wpdb;
29
  /* when new options are added and when the wppa_setup() routine
30
  /* must be called right after update for any other reason.
31
  */
32
- global $wppa_revno; $wppa_revno = '6308';
33
 
34
  /* This is the api interface version number
35
  /* It is incremented at any code change.
36
  */
37
- global $wppa_api_version; $wppa_api_version = '6-3-08-000';
38
 
39
  /* start timers */
40
  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.3.9
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/
19
  // add_filter( 'run_wptexturize', '__return_false' );
20
 
21
  /* See explanation on activation hook in wppa-setup.php */
22
+ register_activation_hook( __FILE__, 'wppa_activate_plugin' );
23
 
24
  /* GLOBALS */
25
  global $wpdb;
29
  /* when new options are added and when the wppa_setup() routine
30
  /* must be called right after update for any other reason.
31
  */
32
+ global $wppa_revno; $wppa_revno = '6309';
33
 
34
  /* This is the api interface version number
35
  /* It is incremented at any code change.
36
  */
37
+ global $wppa_api_version; $wppa_api_version = '6-3-09-000';
38
 
39
  /* start timers */
40
  global $wppa_starttime; $wppa_starttime = microtime(true);