Version Description
= 7.1.02 =
- This version addresses various security issues.
- This version addresses various bug fixes and feature requests.
= 7.1.01 =
- This version addresses various bug fixes and feature requests.
= 7.1.00 =
- This version addresses various bug fixes and feature requests.
- The Photo Album -> Upload Photos and Import Photos admin pages have been substantially improved. Read the changelog for details.
= 7.0.11 =
- This version addresses various bug fixes and feature requests.
= 7.0.11 =
- This version addresses various bug fixes
= 7.0.10 =
- This version addresses various bug fixes
= 7.0.09 =
- This version addresses various security issues.
- This version addresses various bug fixes and feature requests.
= 7.0.08 =
- This version addresses various security issues.
- This version addresses various bug fixes
= 7.0.07 =
- This version addresses various security issues.
- This version addresses various bug fixes
= 7.0.06 =
- This version addresses various bug fixes
- This version addresses various security issues.
= 7.0.05 =
- This version addresses various minor bug fixes and feature requests.
- This version addresses various security issues.
= 7.0.04 =
- This version addresses various bug fixes
- This version addresses various security issues.
= 7.0.03 =
- This version addresses various minor bug fixes and feature requests.
= 7.0.02 =
- This version addresses various bug fixes
- This version addresses various security issues.
= 7.0.01 =
- This version addresses various minor bug fixes and feature requests.
= 7.0.00 =
- Shortcode generators for Gutenberg added.
- This version addresses various minor bug fixes and feature requests.
- This version addresses various security issues.
- To prevent spamming and give the users the opportunity to decide when they want us to email them, the mailing system has been revised. Configure Table IX-M to enable various mailing lists, and use the WPPA+ Notify widget for full user flexibility.
= 6.9.21 =
- This version addresses various bug fixes
- This version addresses various security issues.
= 6.9.20 =
- This version addresses various bug fixes
= 6.9.19 =
- This version addresses various minor bug fixes
= 6.9.18 =
- This version addresses various minor bug fixes
= 6.9.17 =
- This version addresses various minor bug fixes and feature requests.
- This version addresses various security issues.
= 6.9.16 =
- This version addresses various minor bug fixes and feature requests.
- This version addresses various security issues.
= 6.9.15 =
- This version addresses various minor bug fixes and feature requests.
- This version addresses various security issues.
= 6.9.14 =
- This version addresses various minor bug fixes and feature requests.
- This version addresses various security issues.
= 6.9.13 =
- Security release.
= 6.9.12 =
- This version addresses various minor bug fixes and performance improvements.
= 6.9.11 =
- This version addresses various minor bug fixes and performance improvements.
= 6.9.10 =
- This version addresses various minor bug fixes and performance improvements.
= 6.9.09 =
- Panorama support phase III.
= 6.9.08 =
- This version addresses various minor bug fixes and feature requests.
- Panorama support phase II.
= 6.9.07 =
- This version addresses various minor bug fixes and feature requests.
- Panorama support phase I.
= 6.9.06 =
- This version addresses various minor bug fixes and feature requests.
= 6.9.05 =
- This version addresses various minor bug fixes and feature requests.
= 6.9.04 =
- This version addresses various minor bug fixes and feature requests.
- Local CDN functionality has been added.
= 6.9.03 =
- This version addresses various minor bug fixes and feature requests.
= 6.9.02 =
- This version addresses various minor bug fixes and feature requests.
= 6.9.01 =
- This version addresses various minor bug fixes and feature requests.
= 6.9.00 =
- This version includes the code for the privacy policy requirements.
= 6.8.09
- This version addresses various bug fixes and code edits.
= 6.8.08 =
- This version addresses various minor bug fixes and feature requests.
- This version offers substantial performance improvements when the box in Table IV-A13: Defer Javascript is ticked. This setting is now recommended and set ticked as the default.
- For more info on performance improvements and compatibility with optimizers: see the changelog.txt
= 6.8.07 =
- This version addresses various minor bug fixes and enhancements, and a new widget: Statistics.
= 6.8.06 =
- This version addresses various minor bug fixes and improved cache handling.
= 6.8.05 =
- This version addresses various minor bug fixes and feture requests.
= 6.8.04 =
- This version addresses various display issues and a few fixes of bugs that seldom affected the plugins behaviour.
Download this release
Release Info
Developer | opajaap |
Plugin | WP Photo Album Plus |
Version | 7.1.02.005 |
Comparing to | |
See all releases |
Code changes from version 7.1.02.004 to 7.1.02.005
- changelog.txt +1 -0
- wppa-admin-functions.php +4 -7
- wppa-local-cdn.php +24 -10
- wppa-photo-files.php +13 -23
- wppa-setup.php +13 -16
- wppa-source.php +1 -4
- wppa-stereo.php +8 -9
- wppa-utils.php +4 -66
- wppa-watermark.php +5 -8
- wppa-wrappers.php +176 -45
- wppa.php +2 -2
changelog.txt
CHANGED
@@ -5,6 +5,7 @@ WP Photo Album Plus Changelog
|
|
5 |
* Added Table IX-A16: Load nicescroller js always.
|
6 |
* Table I-C10 (Thumbnail area max size) and Table I-C11 (Use nicescroller) have been moved to Table I-A12 and Table I-A13 and apply now also to the album cover area.
|
7 |
* The local cdn file list on the photo admin page now link to the images in a new window.
|
|
|
8 |
|
9 |
= 7.1.01 =
|
10 |
|
5 |
* Added Table IX-A16: Load nicescroller js always.
|
6 |
* Table I-C10 (Thumbnail area max size) and Table I-C11 (Use nicescroller) have been moved to Table I-A12 and Table I-A13 and apply now also to the album cover area.
|
7 |
* The local cdn file list on the photo admin page now link to the images in a new window.
|
8 |
+
* Fixed a filesystem credentials issue resulting in black local cdn images.
|
9 |
|
10 |
= 7.1.01 =
|
11 |
|
wppa-admin-functions.php
CHANGED
@@ -378,7 +378,7 @@ global $wpdb;
|
|
378 |
switch ( $img[2] ) {
|
379 |
case 1: // gif
|
380 |
$err = '5';
|
381 |
-
$source =
|
382 |
break;
|
383 |
case 2: // jpg
|
384 |
$err = '6';
|
@@ -434,15 +434,15 @@ global $wpdb;
|
|
434 |
switch ( $img[2] ) {
|
435 |
case 1:
|
436 |
$err = '15';
|
437 |
-
$bret =
|
438 |
break;
|
439 |
case 2:
|
440 |
$err = '16';
|
441 |
-
$bret =
|
442 |
break;
|
443 |
case 3:
|
444 |
$err = '17';
|
445 |
-
$bret =
|
446 |
break;
|
447 |
default:
|
448 |
$err = '20';
|
@@ -456,9 +456,6 @@ global $wpdb;
|
|
456 |
// Destroy the result
|
457 |
imagedestroy( $rotate );
|
458 |
|
459 |
-
// accessible
|
460 |
-
// wppa_chmod( $file );
|
461 |
-
|
462 |
// Optimized
|
463 |
wppa_optimize_image_file( $file );
|
464 |
|
378 |
switch ( $img[2] ) {
|
379 |
case 1: // gif
|
380 |
$err = '5';
|
381 |
+
$source = wppa_imagecreatefromgif( $file );
|
382 |
break;
|
383 |
case 2: // jpg
|
384 |
$err = '6';
|
434 |
switch ( $img[2] ) {
|
435 |
case 1:
|
436 |
$err = '15';
|
437 |
+
$bret = wppa_imagegif( $rotate, $file, 95 );
|
438 |
break;
|
439 |
case 2:
|
440 |
$err = '16';
|
441 |
+
$bret = wppa_imagejpeg( $rotate, $file );
|
442 |
break;
|
443 |
case 3:
|
444 |
$err = '17';
|
445 |
+
$bret = wppa_imagepng( $rotate, $file, 6 );
|
446 |
break;
|
447 |
default:
|
448 |
$err = '20';
|
456 |
// Destroy the result
|
457 |
imagedestroy( $rotate );
|
458 |
|
|
|
|
|
|
|
459 |
// Optimized
|
460 |
wppa_optimize_image_file( $file );
|
461 |
|
wppa-local-cdn.php
CHANGED
@@ -19,10 +19,10 @@ function wppa_cdn_path( $id, $x, $y ) {
|
|
19 |
function wppa_cdn_url( $id, $x, $y ) {
|
20 |
|
21 |
$path = wppa_cdn_path( $id, $x, $y );
|
22 |
-
if ( !
|
23 |
wppa_cdn_make( $id, $x, $y );
|
24 |
}
|
25 |
-
$url = (
|
26 |
return $url;
|
27 |
}
|
28 |
|
@@ -33,10 +33,10 @@ function wppa_cdn_make( $id, $x, $y ) {
|
|
33 |
$fmpath = wppa_get_photo_path( $id );
|
34 |
|
35 |
// Only continue if from path exists
|
36 |
-
if ( !
|
37 |
|
38 |
// From path exists, continue
|
39 |
-
$fmsize =
|
40 |
$topath = wppa_cdn_path( $id, $x, $y );
|
41 |
$tpshort = str_replace( WPPA_UPLOAD_PATH, '.../wppa', $topath );
|
42 |
|
@@ -83,7 +83,8 @@ function wppa_cdn_make( $id, $x, $y ) {
|
|
83 |
case 1: // gif
|
84 |
|
85 |
// Make source image
|
86 |
-
$tmp =
|
|
|
87 |
|
88 |
// Make empty intermediate full color image
|
89 |
$src = imagecreatetruecolor( $fmsize[0], $fmsize[1] );
|
@@ -98,7 +99,7 @@ function wppa_cdn_make( $id, $x, $y ) {
|
|
98 |
imagecopyresampled( $dst, $src, 0, 0, 0, 0, $x, $y, $fmsize[0], $fmsize[1] );
|
99 |
|
100 |
// Save new image
|
101 |
-
$bret =
|
102 |
|
103 |
break;
|
104 |
|
@@ -106,6 +107,7 @@ function wppa_cdn_make( $id, $x, $y ) {
|
|
106 |
|
107 |
// Make source image
|
108 |
$src = wppa_imagecreatefromjpeg( $fmpath );
|
|
|
109 |
|
110 |
// Make empty destination image
|
111 |
$dst = imagecreatetruecolor( $x, $y );
|
@@ -114,7 +116,7 @@ function wppa_cdn_make( $id, $x, $y ) {
|
|
114 |
imagecopyresampled( $dst, $src, 0, 0, 0, 0, $x, $y, $fmsize[0], $fmsize[1] );
|
115 |
|
116 |
// Save new image
|
117 |
-
$bret =
|
118 |
|
119 |
break;
|
120 |
|
@@ -122,6 +124,7 @@ function wppa_cdn_make( $id, $x, $y ) {
|
|
122 |
|
123 |
// Make source image
|
124 |
$src = wppa_imagecreatefrompng( $fmpath );
|
|
|
125 |
|
126 |
// Make empty destination image
|
127 |
$dst = imagecreatetruecolor( $x, $y );
|
@@ -130,7 +133,7 @@ function wppa_cdn_make( $id, $x, $y ) {
|
|
130 |
imagecopyresampled( $dst, $src, 0, 0, 0, 0, $x, $y, $fmsize[0], $fmsize[1] );
|
131 |
|
132 |
// Save new image
|
133 |
-
$bret =
|
134 |
|
135 |
break;
|
136 |
|
@@ -162,12 +165,11 @@ function wppa_cdn_files( $id ) {
|
|
162 |
$result = array();
|
163 |
if ( is_array( $files ) ) {
|
164 |
foreach( $files as $file ) {
|
165 |
-
if (
|
166 |
$result[] = $file;
|
167 |
}
|
168 |
}
|
169 |
}
|
170 |
-
|
171 |
return $result;
|
172 |
}
|
173 |
|
@@ -175,6 +177,8 @@ function wppa_cdn_files( $id ) {
|
|
175 |
function wppa_cdn_delete( $id ) {
|
176 |
|
177 |
$dir = dirname( wppa_cdn_path( $id, 1, 1 ) );
|
|
|
|
|
178 |
$files = wppa_glob( $dir . '/*' );
|
179 |
if ( is_array( $files ) ) {
|
180 |
foreach( $files as $file ) {
|
@@ -184,4 +188,14 @@ function wppa_cdn_delete( $id ) {
|
|
184 |
}
|
185 |
}
|
186 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
}
|
19 |
function wppa_cdn_url( $id, $x, $y ) {
|
20 |
|
21 |
$path = wppa_cdn_path( $id, $x, $y );
|
22 |
+
if ( ! wppa_is_file( $path ) ) {
|
23 |
wppa_cdn_make( $id, $x, $y );
|
24 |
}
|
25 |
+
$url = ( wppa_is_file( $path ) ? str_replace( WPPA_UPLOAD_PATH, WPPA_UPLOAD_URL, $path ) : false );
|
26 |
return $url;
|
27 |
}
|
28 |
|
33 |
$fmpath = wppa_get_photo_path( $id );
|
34 |
|
35 |
// Only continue if from path exists
|
36 |
+
if ( ! wppa_is_file( $fmpath ) ) return;
|
37 |
|
38 |
// From path exists, continue
|
39 |
+
$fmsize = wppa_getimagesize( $fmpath );
|
40 |
$topath = wppa_cdn_path( $id, $x, $y );
|
41 |
$tpshort = str_replace( WPPA_UPLOAD_PATH, '.../wppa', $topath );
|
42 |
|
83 |
case 1: // gif
|
84 |
|
85 |
// Make source image
|
86 |
+
$tmp = wppa_imagecreatefromgif( $fmpath );
|
87 |
+
if ( ! $tmp ) return false;
|
88 |
|
89 |
// Make empty intermediate full color image
|
90 |
$src = imagecreatetruecolor( $fmsize[0], $fmsize[1] );
|
99 |
imagecopyresampled( $dst, $src, 0, 0, 0, 0, $x, $y, $fmsize[0], $fmsize[1] );
|
100 |
|
101 |
// Save new image
|
102 |
+
$bret = wppa_imagegif( $dst, $topath );
|
103 |
|
104 |
break;
|
105 |
|
107 |
|
108 |
// Make source image
|
109 |
$src = wppa_imagecreatefromjpeg( $fmpath );
|
110 |
+
if ( ! $src ) return false;
|
111 |
|
112 |
// Make empty destination image
|
113 |
$dst = imagecreatetruecolor( $x, $y );
|
116 |
imagecopyresampled( $dst, $src, 0, 0, 0, 0, $x, $y, $fmsize[0], $fmsize[1] );
|
117 |
|
118 |
// Save new image
|
119 |
+
$bret = wppa_imagejpeg( $dst, $topath, wppa_opt( 'jpeg_quality' ) );
|
120 |
|
121 |
break;
|
122 |
|
124 |
|
125 |
// Make source image
|
126 |
$src = wppa_imagecreatefrompng( $fmpath );
|
127 |
+
if ( ! $src ) return false;
|
128 |
|
129 |
// Make empty destination image
|
130 |
$dst = imagecreatetruecolor( $x, $y );
|
133 |
imagecopyresampled( $dst, $src, 0, 0, 0, 0, $x, $y, $fmsize[0], $fmsize[1] );
|
134 |
|
135 |
// Save new image
|
136 |
+
$bret = wppa_imagepng( $dst, $topath, 6 );
|
137 |
|
138 |
break;
|
139 |
|
165 |
$result = array();
|
166 |
if ( is_array( $files ) ) {
|
167 |
foreach( $files as $file ) {
|
168 |
+
if ( wppa_is_file( $file ) ) {
|
169 |
$result[] = $file;
|
170 |
}
|
171 |
}
|
172 |
}
|
|
|
173 |
return $result;
|
174 |
}
|
175 |
|
177 |
function wppa_cdn_delete( $id ) {
|
178 |
|
179 |
$dir = dirname( wppa_cdn_path( $id, 1, 1 ) );
|
180 |
+
if ( ! wppa_is_dir( $dir ) ) return;
|
181 |
+
|
182 |
$files = wppa_glob( $dir . '/*' );
|
183 |
if ( is_array( $files ) ) {
|
184 |
foreach( $files as $file ) {
|
188 |
}
|
189 |
}
|
190 |
}
|
191 |
+
wppa_rmdir( $dir );
|
192 |
+
|
193 |
+
// Remove empty (grand)parent dirs
|
194 |
+
$parent = dirname( $dir );
|
195 |
+
$is_empty = count( wppa_glob( $parent . '/*' ) ) == 0;
|
196 |
+
while ( $is_empty && basename( $parent != 'wppa-cdn' ) ) {
|
197 |
+
wppa_rmdir( $parent );
|
198 |
+
$parent = dirname( $dir );
|
199 |
+
$is_empty = count( wppa_glob( $parent . '/*' ) ) == 0;
|
200 |
+
}
|
201 |
}
|
wppa-photo-files.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/* wppa-photo-files.php
|
3 |
*
|
4 |
* Functions used to create/manipulate photofiles
|
5 |
-
* Version 7.1.
|
6 |
*
|
7 |
*/
|
8 |
|
@@ -96,7 +96,6 @@ function wppa_orientate_image_file( $file, $ori ) {
|
|
96 |
// Load image
|
97 |
$source = wppa_imagecreatefromjpeg( $file );
|
98 |
if ( ! $source ) {
|
99 |
-
wppa_log( 'Err', 'Could not create memoryimage from jpg file ' . $file );
|
100 |
return false;
|
101 |
}
|
102 |
|
@@ -130,10 +129,7 @@ function wppa_orientate_image_file( $file, $ori ) {
|
|
130 |
}
|
131 |
|
132 |
// Output
|
133 |
-
|
134 |
-
|
135 |
-
// Accessable
|
136 |
-
// wppa_chmod( $file );
|
137 |
|
138 |
// Optimized
|
139 |
wppa_optimize_image_file( $file );
|
@@ -269,7 +265,7 @@ wppa_log('dbg', 'make called with'.$file.' '.$id.' '.$ext.' '.$do_thumb. ' exist
|
|
269 |
// Create the source image
|
270 |
switch ( $mime ) { // mime type
|
271 |
case 1: // gif
|
272 |
-
$temp = @
|
273 |
if ( $temp ) {
|
274 |
$src = imagecreatetruecolor( $src_width, $src_height );
|
275 |
imagecopy( $src, $temp, 0, 0, 0, 0, $src_width, $src_height );
|
@@ -284,12 +280,11 @@ wppa_log('dbg', 'make called with'.$file.' '.$id.' '.$ext.' '.$do_thumb. ' exist
|
|
284 |
$src = @ wppa_imagecreatefromjpeg( $file );
|
285 |
break;
|
286 |
case 3: // png
|
287 |
-
$src = @
|
288 |
break;
|
289 |
}
|
290 |
|
291 |
if ( ! $src ) {
|
292 |
-
wppa_log( 'Error', 'Image file '.$file.' is corrupt while downsizing photo' );
|
293 |
return false;
|
294 |
}
|
295 |
|
@@ -320,13 +315,13 @@ wppa_log('dbg', 'make called with'.$file.' '.$id.' '.$ext.' '.$do_thumb. ' exist
|
|
320 |
// Save the photo
|
321 |
switch ( $mime ) { // mime type
|
322 |
case 1:
|
323 |
-
|
324 |
break;
|
325 |
case 2:
|
326 |
-
|
327 |
break;
|
328 |
case 3:
|
329 |
-
|
330 |
break;
|
331 |
}
|
332 |
|
@@ -349,9 +344,6 @@ wppa_log('dbg', 'make called with'.$file.' '.$id.' '.$ext.' '.$do_thumb. ' exist
|
|
349 |
// File successfully created ?
|
350 |
if ( is_file ( $newimage ) ) {
|
351 |
|
352 |
-
// Make sure file is accessible
|
353 |
-
// wppa_chmod( $newimage );
|
354 |
-
|
355 |
// Optimize file
|
356 |
wppa_optimize_image_file( $newimage );
|
357 |
}
|
@@ -393,6 +385,7 @@ wppa_log('dbg', 'make called with'.$file.' '.$id.' '.$ext.' '.$do_thumb. ' exist
|
|
393 |
wppa_upload_to_cloudinary( $id );
|
394 |
break;
|
395 |
case 'local':
|
|
|
396 |
break;
|
397 |
default:
|
398 |
wppa_dbg_msg( 'Missing upload instructions for '.$cdn, 'red', 'force' );
|
@@ -501,7 +494,7 @@ function wppa_create_thumbnail( $id, $use_source = true ) {
|
|
501 |
// Create the source image
|
502 |
switch ( $mime ) { // mime type
|
503 |
case 1: // gif
|
504 |
-
$temp = @
|
505 |
if ( $temp ) {
|
506 |
$src = imagecreatetruecolor( $src_size_w, $src_size_h );
|
507 |
imagecopy( $src, $temp, 0, 0, 0, 0, $src_size_w, $src_size_h );
|
@@ -514,7 +507,7 @@ function wppa_create_thumbnail( $id, $use_source = true ) {
|
|
514 |
$src = @ wppa_imagecreatefromjpeg( $file );
|
515 |
break;
|
516 |
case 3: // png
|
517 |
-
$src = @
|
518 |
break;
|
519 |
}
|
520 |
if ( ! $src ) {
|
@@ -627,15 +620,15 @@ function wppa_create_thumbnail( $id, $use_source = true ) {
|
|
627 |
switch ( $mime ) { // mime type
|
628 |
case 1:
|
629 |
$full_thumbpath = $thumbpath . '.gif';
|
630 |
-
|
631 |
break;
|
632 |
case 2:
|
633 |
$full_thumbpath = $thumbpath . '.jpg';
|
634 |
-
|
635 |
break;
|
636 |
case 3:
|
637 |
$full_thumbpath = $thumbpath . '.png';
|
638 |
-
|
639 |
break;
|
640 |
}
|
641 |
$thumbpath = $full_thumbpath;
|
@@ -651,9 +644,6 @@ function wppa_create_thumbnail( $id, $use_source = true ) {
|
|
651 |
wppa_copy( $file, $thumbpath );
|
652 |
}
|
653 |
|
654 |
-
// Make sure file is accessible
|
655 |
-
// wppa_chmod( $thumbpath );
|
656 |
-
|
657 |
// Optimize
|
658 |
wppa_optimize_image_file( $thumbpath );
|
659 |
|
2 |
/* wppa-photo-files.php
|
3 |
*
|
4 |
* Functions used to create/manipulate photofiles
|
5 |
+
* Version 7.1.02
|
6 |
*
|
7 |
*/
|
8 |
|
96 |
// Load image
|
97 |
$source = wppa_imagecreatefromjpeg( $file );
|
98 |
if ( ! $source ) {
|
|
|
99 |
return false;
|
100 |
}
|
101 |
|
129 |
}
|
130 |
|
131 |
// Output
|
132 |
+
wppa_imagejpeg( $orientate, $file, wppa_opt( 'jpeg_quality' ) );
|
|
|
|
|
|
|
133 |
|
134 |
// Optimized
|
135 |
wppa_optimize_image_file( $file );
|
265 |
// Create the source image
|
266 |
switch ( $mime ) { // mime type
|
267 |
case 1: // gif
|
268 |
+
$temp = @ wppa_imagecreatefromgif( $file );
|
269 |
if ( $temp ) {
|
270 |
$src = imagecreatetruecolor( $src_width, $src_height );
|
271 |
imagecopy( $src, $temp, 0, 0, 0, 0, $src_width, $src_height );
|
280 |
$src = @ wppa_imagecreatefromjpeg( $file );
|
281 |
break;
|
282 |
case 3: // png
|
283 |
+
$src = @ wppa_imagecreatefrompng( $file );
|
284 |
break;
|
285 |
}
|
286 |
|
287 |
if ( ! $src ) {
|
|
|
288 |
return false;
|
289 |
}
|
290 |
|
315 |
// Save the photo
|
316 |
switch ( $mime ) { // mime type
|
317 |
case 1:
|
318 |
+
wppa_imagegif( $dst, $newimage );
|
319 |
break;
|
320 |
case 2:
|
321 |
+
wppa_imagejpeg( $dst, $newimage, wppa_opt( 'jpeg_quality' ) );
|
322 |
break;
|
323 |
case 3:
|
324 |
+
wppa_imagepng( $dst, $newimage, 6 );
|
325 |
break;
|
326 |
}
|
327 |
|
344 |
// File successfully created ?
|
345 |
if ( is_file ( $newimage ) ) {
|
346 |
|
|
|
|
|
|
|
347 |
// Optimize file
|
348 |
wppa_optimize_image_file( $newimage );
|
349 |
}
|
385 |
wppa_upload_to_cloudinary( $id );
|
386 |
break;
|
387 |
case 'local':
|
388 |
+
wppa_cdn_delete( $id ); // Remove existing local cdn files. They will be re-created automatically
|
389 |
break;
|
390 |
default:
|
391 |
wppa_dbg_msg( 'Missing upload instructions for '.$cdn, 'red', 'force' );
|
494 |
// Create the source image
|
495 |
switch ( $mime ) { // mime type
|
496 |
case 1: // gif
|
497 |
+
$temp = @ wppa_imagecreatefromgif( $file );
|
498 |
if ( $temp ) {
|
499 |
$src = imagecreatetruecolor( $src_size_w, $src_size_h );
|
500 |
imagecopy( $src, $temp, 0, 0, 0, 0, $src_size_w, $src_size_h );
|
507 |
$src = @ wppa_imagecreatefromjpeg( $file );
|
508 |
break;
|
509 |
case 3: // png
|
510 |
+
$src = @ wppa_imagecreatefrompng( $file );
|
511 |
break;
|
512 |
}
|
513 |
if ( ! $src ) {
|
620 |
switch ( $mime ) { // mime type
|
621 |
case 1:
|
622 |
$full_thumbpath = $thumbpath . '.gif';
|
623 |
+
wppa_imagegif( $dst, $full_thumbpath );
|
624 |
break;
|
625 |
case 2:
|
626 |
$full_thumbpath = $thumbpath . '.jpg';
|
627 |
+
wppa_imagejpeg( $dst, $full_thumbpath, wppa_opt( 'jpeg_quality' ) );
|
628 |
break;
|
629 |
case 3:
|
630 |
$full_thumbpath = $thumbpath . '.png';
|
631 |
+
wppa_imagepng( $dst, $full_thumbpath, 6 );
|
632 |
break;
|
633 |
}
|
634 |
$thumbpath = $full_thumbpath;
|
644 |
wppa_copy( $file, $thumbpath );
|
645 |
}
|
646 |
|
|
|
|
|
|
|
647 |
// Optimize
|
648 |
wppa_optimize_image_file( $thumbpath );
|
649 |
|
wppa-setup.php
CHANGED
@@ -191,17 +191,8 @@ global $wppa_error;
|
|
191 |
$tn = array( WPPA_ALBUMS, WPPA_PHOTOS, WPPA_RATING, WPPA_COMMENTS, WPPA_IPTC, WPPA_EXIF, WPPA_INDEX, WPPA_SESSION );
|
192 |
$tc = array( $create_albums, $create_photos, $create_rating, $create_comments, $create_iptc, $create_exif, $create_index, $create_session );
|
193 |
$idx = 0;
|
194 |
-
while ($idx < 8) {
|
195 |
-
|
196 |
-
dbDelta($tc[$idx]);
|
197 |
-
// $a1 = wppa_ table_exists($tn[$idx]);
|
198 |
-
// if ( WPPA_DEBUG ) {
|
199 |
-
// if ( ! $a0 ) {
|
200 |
-
// if ( $a1 ) wppa_log('dbg', 'Database table '.$tn[$idx].' created.');
|
201 |
-
// else wppa_log('dbg', 'Could not create database table '.$tn[$idx]);
|
202 |
-
// }
|
203 |
-
// else wppa_log('dbg', 'Database table '.$tn[$idx].' updated.');
|
204 |
-
// }
|
205 |
$idx++;
|
206 |
}
|
207 |
|
@@ -658,17 +649,15 @@ global $wppa_error;
|
|
658 |
// Copy audiostub.jpg, the default audiostub
|
659 |
$fromfile = WPPA_PATH . '/img/audiostub.jpg';
|
660 |
$tofile = WPPA_UPLOAD_PATH . '/audiostub.jpg';
|
661 |
-
wppa_log('obs',$fromfile.' '.is_file($fromfile).' '.$tofile.' '.is_file($tofile));
|
662 |
if ( ! wppa_is_file( $tofile ) ) {
|
663 |
-
|
664 |
}
|
665 |
|
666 |
// Copy documentstub.png, the default documentstub
|
667 |
$fromfile = WPPA_PATH . '/img/documentstub.png';
|
668 |
$tofile = WPPA_UPLOAD_PATH . '/documentstub.png';
|
669 |
-
wppa_log('obs',$fromfile.' '.is_file($fromfile).' '.$tofile.' '.is_file($tofile));
|
670 |
if ( ! wppa_is_file( $tofile ) ) {
|
671 |
-
|
672 |
}
|
673 |
|
674 |
// Copy factory supplied icons
|
@@ -676,7 +665,7 @@ global $wppa_error;
|
|
676 |
foreach ( $fromfiles as $file ) {
|
677 |
$from = WPPA_PATH . '/img/' . $file;
|
678 |
$to = WPPA_UPLOAD_PATH . '/icons/' . $file;
|
679 |
-
|
680 |
}
|
681 |
|
682 |
// Check if this update comes with a new wppa-theme.php and/or a new wppa-style.css
|
@@ -2001,30 +1990,35 @@ function wppa_check_dirs() {
|
|
2001 |
if ( ! wppa_is_dir( $dir ) ) {
|
2002 |
wppa_mktree( $dir );
|
2003 |
}
|
|
|
2004 |
|
2005 |
// check if thumbs dir exists
|
2006 |
$dir = WPPA_UPLOAD_PATH . '/thumbs';
|
2007 |
if ( ! wppa_is_dir( $dir ) ) {
|
2008 |
wppa_mktree( $dir );
|
2009 |
}
|
|
|
2010 |
|
2011 |
// check if watermarks dir exists
|
2012 |
$dir = WPPA_UPLOAD_PATH . '/watermarks';
|
2013 |
if ( ! wppa_is_dir( $dir ) ) {
|
2014 |
wppa_mktree( $dir );
|
2015 |
}
|
|
|
2016 |
|
2017 |
// check if fonts dir exists
|
2018 |
$dir = WPPA_UPLOAD_PATH . '/fonts';
|
2019 |
if ( ! wppa_is_dir( $dir ) ) {
|
2020 |
wppa_mktree( $dir );
|
2021 |
}
|
|
|
2022 |
|
2023 |
// The icons dir
|
2024 |
$dir = WPPA_UPLOAD_PATH . '/icons';
|
2025 |
if ( ! wppa_is_dir( $dir ) ) {
|
2026 |
wppa_mktree( $dir );
|
2027 |
}
|
|
|
2028 |
|
2029 |
// check if depot dir exists
|
2030 |
if ( ! is_multisite() ) {
|
@@ -2034,6 +2028,7 @@ function wppa_check_dirs() {
|
|
2034 |
if ( ! wppa_is_dir( $dir ) ) {
|
2035 |
wppa_mktree( $dir );
|
2036 |
}
|
|
|
2037 |
}
|
2038 |
|
2039 |
// check the user depot directory
|
@@ -2041,12 +2036,14 @@ function wppa_check_dirs() {
|
|
2041 |
if ( ! wppa_is_dir( $dir ) ) {
|
2042 |
wppa_mktree( $dir );
|
2043 |
}
|
|
|
2044 |
|
2045 |
// check the temp dir
|
2046 |
$dir = WPPA_UPLOAD_PATH . '/temp/';
|
2047 |
if ( ! wppa_is_dir( $dir ) ) {
|
2048 |
wppa_mktree( $dir );
|
2049 |
}
|
|
|
2050 |
|
2051 |
return true;
|
2052 |
}
|
191 |
$tn = array( WPPA_ALBUMS, WPPA_PHOTOS, WPPA_RATING, WPPA_COMMENTS, WPPA_IPTC, WPPA_EXIF, WPPA_INDEX, WPPA_SESSION );
|
192 |
$tc = array( $create_albums, $create_photos, $create_rating, $create_comments, $create_iptc, $create_exif, $create_index, $create_session );
|
193 |
$idx = 0;
|
194 |
+
while ( $idx < 8 ) {
|
195 |
+
dbDelta( $tc[$idx] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
$idx++;
|
197 |
}
|
198 |
|
649 |
// Copy audiostub.jpg, the default audiostub
|
650 |
$fromfile = WPPA_PATH . '/img/audiostub.jpg';
|
651 |
$tofile = WPPA_UPLOAD_PATH . '/audiostub.jpg';
|
|
|
652 |
if ( ! wppa_is_file( $tofile ) ) {
|
653 |
+
wppa_copy( $fromfile, $tofile );
|
654 |
}
|
655 |
|
656 |
// Copy documentstub.png, the default documentstub
|
657 |
$fromfile = WPPA_PATH . '/img/documentstub.png';
|
658 |
$tofile = WPPA_UPLOAD_PATH . '/documentstub.png';
|
|
|
659 |
if ( ! wppa_is_file( $tofile ) ) {
|
660 |
+
wppa_copy( $fromfile, $tofile );
|
661 |
}
|
662 |
|
663 |
// Copy factory supplied icons
|
665 |
foreach ( $fromfiles as $file ) {
|
666 |
$from = WPPA_PATH . '/img/' . $file;
|
667 |
$to = WPPA_UPLOAD_PATH . '/icons/' . $file;
|
668 |
+
wppa_copy( $from, $to );
|
669 |
}
|
670 |
|
671 |
// Check if this update comes with a new wppa-theme.php and/or a new wppa-style.css
|
1990 |
if ( ! wppa_is_dir( $dir ) ) {
|
1991 |
wppa_mktree( $dir );
|
1992 |
}
|
1993 |
+
wppa_chmod( $dir, true );
|
1994 |
|
1995 |
// check if thumbs dir exists
|
1996 |
$dir = WPPA_UPLOAD_PATH . '/thumbs';
|
1997 |
if ( ! wppa_is_dir( $dir ) ) {
|
1998 |
wppa_mktree( $dir );
|
1999 |
}
|
2000 |
+
wppa_chmod( $dir, true );
|
2001 |
|
2002 |
// check if watermarks dir exists
|
2003 |
$dir = WPPA_UPLOAD_PATH . '/watermarks';
|
2004 |
if ( ! wppa_is_dir( $dir ) ) {
|
2005 |
wppa_mktree( $dir );
|
2006 |
}
|
2007 |
+
wppa_chmod( $dir, true );
|
2008 |
|
2009 |
// check if fonts dir exists
|
2010 |
$dir = WPPA_UPLOAD_PATH . '/fonts';
|
2011 |
if ( ! wppa_is_dir( $dir ) ) {
|
2012 |
wppa_mktree( $dir );
|
2013 |
}
|
2014 |
+
wppa_chmod( $dir, true );
|
2015 |
|
2016 |
// The icons dir
|
2017 |
$dir = WPPA_UPLOAD_PATH . '/icons';
|
2018 |
if ( ! wppa_is_dir( $dir ) ) {
|
2019 |
wppa_mktree( $dir );
|
2020 |
}
|
2021 |
+
wppa_chmod( $dir, true );
|
2022 |
|
2023 |
// check if depot dir exists
|
2024 |
if ( ! is_multisite() ) {
|
2028 |
if ( ! wppa_is_dir( $dir ) ) {
|
2029 |
wppa_mktree( $dir );
|
2030 |
}
|
2031 |
+
wppa_chmod( $dir, true );
|
2032 |
}
|
2033 |
|
2034 |
// check the user depot directory
|
2036 |
if ( ! wppa_is_dir( $dir ) ) {
|
2037 |
wppa_mktree( $dir );
|
2038 |
}
|
2039 |
+
wppa_chmod( $dir, true );
|
2040 |
|
2041 |
// check the temp dir
|
2042 |
$dir = WPPA_UPLOAD_PATH . '/temp/';
|
2043 |
if ( ! wppa_is_dir( $dir ) ) {
|
2044 |
wppa_mktree( $dir );
|
2045 |
}
|
2046 |
+
wppa_chmod( $dir, true );
|
2047 |
|
2048 |
return true;
|
2049 |
}
|
wppa-source.php
CHANGED
@@ -47,10 +47,7 @@ function wppa_save_source( $file, $name, $alb ) {
|
|
47 |
wppa_copy( $file, $dest );
|
48 |
|
49 |
}
|
50 |
-
if (
|
51 |
-
// wppa_chmod( $dest );
|
52 |
-
}
|
53 |
-
else {
|
54 |
wppa_log( 'Err', 'Could not save ' . $dest, true );
|
55 |
}
|
56 |
}
|
47 |
wppa_copy( $file, $dest );
|
48 |
|
49 |
}
|
50 |
+
if ( ! wppa_is_file( $dest ) ) {
|
|
|
|
|
|
|
51 |
wppa_log( 'Err', 'Could not save ' . $dest, true );
|
52 |
}
|
53 |
}
|
wppa-stereo.php
CHANGED
@@ -101,6 +101,8 @@ static $f114;
|
|
101 |
$height = $sizes['1'];
|
102 |
|
103 |
$fromimage = wppa_imagecreatefromjpeg( $fromfile );
|
|
|
|
|
104 |
$toimage = imagecreatetruecolor( $width, $height );
|
105 |
if ( $is_stereo == 1 ) {
|
106 |
$offset1 = 0;
|
@@ -138,7 +140,7 @@ static $f114;
|
|
138 |
imagesetpixel($toimage, $x, $y, $newpix);
|
139 |
}
|
140 |
}
|
141 |
-
|
142 |
break;
|
143 |
|
144 |
case 'gray':
|
@@ -172,7 +174,7 @@ static $f114;
|
|
172 |
imagesetpixel($toimage, $x, $y, $newpix);
|
173 |
}
|
174 |
}
|
175 |
-
|
176 |
break;
|
177 |
|
178 |
case 'true':
|
@@ -206,7 +208,7 @@ static $f114;
|
|
206 |
imagesetpixel($toimage, $x, $y, $newpix);
|
207 |
}
|
208 |
}
|
209 |
-
|
210 |
break;
|
211 |
|
212 |
case 'halfcolor':
|
@@ -241,7 +243,7 @@ static $f114;
|
|
241 |
imagesetpixel($toimage, $x, $y, $newpix);
|
242 |
}
|
243 |
}
|
244 |
-
|
245 |
break;
|
246 |
|
247 |
case 'optimized':
|
@@ -277,21 +279,18 @@ static $f114;
|
|
277 |
imagesetpixel($toimage, $x, $y, $newpix);
|
278 |
}
|
279 |
}
|
280 |
-
|
281 |
break;
|
282 |
|
283 |
case '_flat':
|
284 |
imagecopy( $toimage, $fromimage, 0, 0, 0, 0, $width, $height );
|
285 |
-
|
286 |
break;
|
287 |
|
288 |
default:
|
289 |
break;
|
290 |
}
|
291 |
|
292 |
-
// accessible
|
293 |
-
// wppa_chmod( $tofile );
|
294 |
-
|
295 |
// Optimized
|
296 |
wppa_optimize_image_file( $tofile );
|
297 |
|
101 |
$height = $sizes['1'];
|
102 |
|
103 |
$fromimage = wppa_imagecreatefromjpeg( $fromfile );
|
104 |
+
if ( ! $fromimage ) return false;
|
105 |
+
|
106 |
$toimage = imagecreatetruecolor( $width, $height );
|
107 |
if ( $is_stereo == 1 ) {
|
108 |
$offset1 = 0;
|
140 |
imagesetpixel($toimage, $x, $y, $newpix);
|
141 |
}
|
142 |
}
|
143 |
+
wppa_imagejpeg( $toimage, $tofile, wppa_opt( 'jpeg_quality' ) );
|
144 |
break;
|
145 |
|
146 |
case 'gray':
|
174 |
imagesetpixel($toimage, $x, $y, $newpix);
|
175 |
}
|
176 |
}
|
177 |
+
wppa_imagejpeg( $toimage, $tofile, wppa_opt( 'jpeg_quality' ) );
|
178 |
break;
|
179 |
|
180 |
case 'true':
|
208 |
imagesetpixel($toimage, $x, $y, $newpix);
|
209 |
}
|
210 |
}
|
211 |
+
wppa_imagejpeg( $toimage, $tofile, wppa_opt( 'jpeg_quality' ) );
|
212 |
break;
|
213 |
|
214 |
case 'halfcolor':
|
243 |
imagesetpixel($toimage, $x, $y, $newpix);
|
244 |
}
|
245 |
}
|
246 |
+
wppa_imagejpeg( $toimage, $tofile, wppa_opt( 'jpeg_quality' ) );
|
247 |
break;
|
248 |
|
249 |
case 'optimized':
|
279 |
imagesetpixel($toimage, $x, $y, $newpix);
|
280 |
}
|
281 |
}
|
282 |
+
wppa_imagejpeg( $toimage, $tofile, wppa_opt( 'jpeg_quality' ) );
|
283 |
break;
|
284 |
|
285 |
case '_flat':
|
286 |
imagecopy( $toimage, $fromimage, 0, 0, 0, 0, $width, $height );
|
287 |
+
wppa_imagejpeg( $toimage, $tofile, wppa_opt( 'jpeg_quality' ) );
|
288 |
break;
|
289 |
|
290 |
default:
|
291 |
break;
|
292 |
}
|
293 |
|
|
|
|
|
|
|
294 |
// Optimized
|
295 |
wppa_optimize_image_file( $tofile );
|
296 |
|
wppa-utils.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* Contains low-level utility routines
|
6 |
-
* Version 7.1.
|
7 |
*
|
8 |
*/
|
9 |
|
@@ -2331,16 +2331,6 @@ function wppa_expand_enum( $enum ) {
|
|
2331 |
return $result;
|
2332 |
}
|
2333 |
|
2334 |
-
function wppa_mktree( $path ) {
|
2335 |
-
if ( is_dir( $path ) ) {
|
2336 |
-
return true;
|
2337 |
-
}
|
2338 |
-
$bret = wppa_mktree( dirname( $path ) );
|
2339 |
-
wppa_mkdir( $path );
|
2340 |
-
// wppa_chmod( $path );
|
2341 |
-
return ( wppa_is_dir( $path ) );
|
2342 |
-
}
|
2343 |
-
|
2344 |
// Compute avg rating and count and put it in photo data
|
2345 |
function wppa_rate_photo( $id ) {
|
2346 |
global $wpdb;
|
@@ -2839,7 +2829,7 @@ function wppa_fix_poster_ext( $fileorurl, $id ) {
|
|
2839 |
|
2840 |
// Is it a pdf?
|
2841 |
if ( wppa_is_pdf( $id ) ) {
|
2842 |
-
|
2843 |
// Url ?
|
2844 |
if ( strpos( $fileorurl, 'http://' ) !== false || strpos( $fileorurl, 'https://' ) !== false ) {
|
2845 |
return WPPA_UPLOAD_URL . '/'. 'documentstub.png';
|
@@ -2850,9 +2840,9 @@ function wppa_fix_poster_ext( $fileorurl, $id ) {
|
|
2850 |
return WPPA_UPLOAD_PATH . '/' . 'documentstub.png';
|
2851 |
}
|
2852 |
}
|
2853 |
-
|
2854 |
else {
|
2855 |
-
|
2856 |
// Get available ext
|
2857 |
$poster_ext = wppa_get_poster_ext( $id );
|
2858 |
|
@@ -3567,58 +3557,6 @@ function wppa_get_mime_type( $id ) {
|
|
3567 |
|
3568 |
return $result;
|
3569 |
}
|
3570 |
-
/*
|
3571 |
-
function wppa_chmod( $fso ) {
|
3572 |
-
|
3573 |
-
$fso = rtrim( $fso, '/' );
|
3574 |
-
|
3575 |
-
if ( ! wppa_is_path_safe( $fso ) ) {
|
3576 |
-
wppa_log( 'War', 'Unsafe path detected in wppa_chmod() ' . sanitize_text_field( $fso ), true );
|
3577 |
-
return;
|
3578 |
-
}
|
3579 |
-
|
3580 |
-
$perms = fileperms( $fso ) & 0777;
|
3581 |
-
|
3582 |
-
if ( wppa_is_dir( $fso ) ) {
|
3583 |
-
|
3584 |
-
// Check file permissions
|
3585 |
-
if ( 0755 !== ( $perms & 0755 ) ) {
|
3586 |
-
|
3587 |
-
// If not sufficient, try to change
|
3588 |
-
@ chmod( $fso, 0755 );
|
3589 |
-
clearstatcache();
|
3590 |
-
|
3591 |
-
// If still no luck
|
3592 |
-
if ( 0755 !== ( fileperms( $fso ) & 0755 ) ) {
|
3593 |
-
wppa_log( 'Fso', sprintf( 'Unable to set filepermissions on %s from %o to 0755', $fso, $perms ) );
|
3594 |
-
}
|
3595 |
-
else {
|
3596 |
-
wppa_log( 'Fso', sprintf( 'Successfully set filepermissions on %s from %o to 0755', $fso, $perms ) );
|
3597 |
-
}
|
3598 |
-
}
|
3599 |
-
}
|
3600 |
-
|
3601 |
-
if ( is_file( $fso ) ) {
|
3602 |
-
|
3603 |
-
// Check file permissions
|
3604 |
-
if ( 0644 !== ( fileperms( $fso ) & 0644 ) ) {
|
3605 |
-
|
3606 |
-
// If not sufficient, try to change
|
3607 |
-
@ chmod( $fso, 0644 );
|
3608 |
-
clearstatcache();
|
3609 |
-
|
3610 |
-
// If still no luck
|
3611 |
-
if ( 0644 !== ( fileperms( $fso ) & 0644 ) ) {
|
3612 |
-
wppa_log( 'Fso', sprintf( 'Unable to set filepermissions on %s from %o to 0644', $fso, $perms ) );
|
3613 |
-
}
|
3614 |
-
else {
|
3615 |
-
wppa_log( 'Fso', sprintf( 'Successfully set filepermissions on %s from %o to 0644', $fso, $perms ) );
|
3616 |
-
}
|
3617 |
-
}
|
3618 |
-
}
|
3619 |
-
|
3620 |
-
}
|
3621 |
-
*/
|
3622 |
|
3623 |
// Test if a given url is to a photo file
|
3624 |
function wppa_is_url_a_photo( $url ) {
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* Contains low-level utility routines
|
6 |
+
* Version 7.1.02
|
7 |
*
|
8 |
*/
|
9 |
|
2331 |
return $result;
|
2332 |
}
|
2333 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2334 |
// Compute avg rating and count and put it in photo data
|
2335 |
function wppa_rate_photo( $id ) {
|
2336 |
global $wpdb;
|
2829 |
|
2830 |
// Is it a pdf?
|
2831 |
if ( wppa_is_pdf( $id ) ) {
|
2832 |
+
|
2833 |
// Url ?
|
2834 |
if ( strpos( $fileorurl, 'http://' ) !== false || strpos( $fileorurl, 'https://' ) !== false ) {
|
2835 |
return WPPA_UPLOAD_URL . '/'. 'documentstub.png';
|
2840 |
return WPPA_UPLOAD_PATH . '/' . 'documentstub.png';
|
2841 |
}
|
2842 |
}
|
2843 |
+
|
2844 |
else {
|
2845 |
+
|
2846 |
// Get available ext
|
2847 |
$poster_ext = wppa_get_poster_ext( $id );
|
2848 |
|
3557 |
|
3558 |
return $result;
|
3559 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3560 |
|
3561 |
// Test if a given url is to a photo file
|
3562 |
function wppa_is_url_a_photo( $url ) {
|
wppa-watermark.php
CHANGED
@@ -298,7 +298,7 @@ function wppa_create_textual_watermark_file( $args ) {
|
|
298 |
}
|
299 |
}
|
300 |
imagesavealpha( $canvas, true );
|
301 |
-
|
302 |
imagedestroy( $canvas );
|
303 |
if ( $args['url'] ) {
|
304 |
$url = str_replace( WPPA_UPLOAD_PATH, WPPA_UPLOAD_URL, $filename );
|
@@ -465,7 +465,7 @@ function wppa_add_watermark( $id ) {
|
|
465 |
|
466 |
|
467 |
switch ( $photosize[2] ) {
|
468 |
-
case 1: $tempimage =
|
469 |
$photoimage = imagecreatetruecolor( $photosize[0], $photosize[1] );
|
470 |
imagecopy( $photoimage, $tempimage, 0, 0, 0, 0, $photosize[0], $photosize[1] );
|
471 |
break;
|
@@ -528,17 +528,14 @@ function wppa_add_watermark( $id ) {
|
|
528 |
|
529 |
// Save the result
|
530 |
switch ( $photosize[2] ) {
|
531 |
-
case 1:
|
532 |
break;
|
533 |
-
case 2:
|
534 |
break;
|
535 |
-
case 3:
|
536 |
break;
|
537 |
}
|
538 |
|
539 |
-
// accessible
|
540 |
-
// wppa_chmod( $file );
|
541 |
-
|
542 |
// Optimized
|
543 |
wppa_optimize_image_file( $file );
|
544 |
|
298 |
}
|
299 |
}
|
300 |
imagesavealpha( $canvas, true );
|
301 |
+
wppa_imagepng( $canvas, $filename );
|
302 |
imagedestroy( $canvas );
|
303 |
if ( $args['url'] ) {
|
304 |
$url = str_replace( WPPA_UPLOAD_PATH, WPPA_UPLOAD_URL, $filename );
|
465 |
|
466 |
|
467 |
switch ( $photosize[2] ) {
|
468 |
+
case 1: $tempimage = wppa_imagecreatefromgif( $file );
|
469 |
$photoimage = imagecreatetruecolor( $photosize[0], $photosize[1] );
|
470 |
imagecopy( $photoimage, $tempimage, 0, 0, 0, 0, $photosize[0], $photosize[1] );
|
471 |
break;
|
528 |
|
529 |
// Save the result
|
530 |
switch ( $photosize[2] ) {
|
531 |
+
case 1: wppa_imagegif( $photoimage, $file );
|
532 |
break;
|
533 |
+
case 2: wppa_imagejpeg( $photoimage, $file, wppa_opt( 'jpeg_quality' ) );
|
534 |
break;
|
535 |
+
case 3: wppa_imagepng( $photoimage, $file, 7 );
|
536 |
break;
|
537 |
}
|
538 |
|
|
|
|
|
|
|
539 |
// Optimized
|
540 |
wppa_optimize_image_file( $file );
|
541 |
|
wppa-wrappers.php
CHANGED
@@ -10,7 +10,6 @@
|
|
10 |
*/
|
11 |
|
12 |
require_once ABSPATH . 'wp-admin/includes/file.php';
|
13 |
-
// require_once ABSPATH . 'wp-admin/includes/template.php';
|
14 |
|
15 |
function wppa_init_fs() {
|
16 |
global $wp_filesystem;
|
@@ -28,7 +27,7 @@ global $wp_filesystem;
|
|
28 |
|
29 |
if ( ! WP_Filesystem( $creds, false, true ) ) {
|
30 |
|
31 |
-
wppa_log( '
|
32 |
return false;
|
33 |
}
|
34 |
}
|
@@ -39,33 +38,93 @@ global $wp_filesystem;
|
|
39 |
// erroneously cause the PHP warning 'is not a valid JPEG file' and cause imagecreatefromjpag crash.
|
40 |
function wppa_imagecreatefromjpeg( $file ) {
|
41 |
|
|
|
|
|
|
|
|
|
42 |
ini_set( 'gd.jpeg_ignore_warning', true );
|
|
|
43 |
$img = imagecreatefromjpeg( $file );
|
|
|
|
|
|
|
44 |
return $img;
|
45 |
}
|
46 |
|
47 |
-
// Wrapper for
|
48 |
-
function
|
49 |
|
50 |
if ( ! wppa_is_path_safe( $file ) ) {
|
51 |
-
wppa_log( '
|
52 |
return false;
|
53 |
}
|
54 |
|
55 |
-
|
|
|
|
|
|
|
|
|
56 |
}
|
57 |
|
58 |
// Wrapper for imagecreatefrompng( $file ), verifies safe pathnames
|
59 |
function wppa_imagecreatefrompng( $file ) {
|
60 |
|
61 |
if ( ! wppa_is_path_safe( $file ) ) {
|
62 |
-
wppa_log( '
|
63 |
return false;
|
64 |
}
|
65 |
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
}
|
68 |
|
|
|
|
|
69 |
// Wrapper for copy( $from, $to ) that verifies that the pathnames are safe for our application
|
70 |
// In case of unexpected operation: Generates a warning in the wppa log, and does not perform the copy.
|
71 |
function wppa_copy( $from, $to ) {
|
@@ -74,30 +133,31 @@ global $wp_filesystem;
|
|
74 |
// First test if we are uploading
|
75 |
if ( ! wppa_is_path_safe( $from ) && $_FILES ) {
|
76 |
if ( ! wppa_is_path_safe( $to ) ) {
|
77 |
-
wppa_log( '
|
78 |
return false;
|
79 |
}
|
80 |
return wppa_move_uploaded_file( $from, $to );
|
81 |
}
|
82 |
|
83 |
if ( ! wppa_is_path_safe( $from ) ) {
|
84 |
-
wppa_log( '
|
85 |
return false; // For diagnostic purposes, no return here yet
|
86 |
}
|
87 |
if ( ! wppa_is_path_safe( $to ) ) {
|
88 |
-
wppa_log( '
|
89 |
return false; // For diagnostic purposes, no return here yet
|
90 |
}
|
91 |
|
92 |
wppa_init_fs();
|
93 |
-
|
|
|
94 |
}
|
95 |
|
96 |
function wppa_filesize( $file ) {
|
97 |
global $wp_filesystem;
|
98 |
|
99 |
if ( ! wppa_is_path_safe( $ile ) ) {
|
100 |
-
wppa_log( '
|
101 |
return false; // For diagnostic purposes, no return here yet
|
102 |
}
|
103 |
|
@@ -110,7 +170,7 @@ function wppa_move_uploaded_file( $from, $to ) {
|
|
110 |
global $wp_filesystem;
|
111 |
|
112 |
if ( ! wppa_is_path_safe( $to ) ) {
|
113 |
-
wppa_log( '
|
114 |
return false; // For diagnostic purposes, no return here yet
|
115 |
}
|
116 |
if ( strpos( $from, '../' ) !== false ) {
|
@@ -124,7 +184,7 @@ global $wp_filesystem;
|
|
124 |
}
|
125 |
}
|
126 |
if ( ! $bret ) {
|
127 |
-
wppa_log( '
|
128 |
}
|
129 |
return $bret;
|
130 |
}
|
@@ -135,11 +195,11 @@ global $wp_filesystem;
|
|
135 |
|
136 |
$bret = false;
|
137 |
if ( ! wppa_is_path_safe( $from ) ) {
|
138 |
-
wppa_log( '
|
139 |
return false;
|
140 |
}
|
141 |
if ( ! wppa_is_path_safe( $to ) ) {
|
142 |
-
wppa_log( '
|
143 |
return false;
|
144 |
}
|
145 |
|
@@ -162,7 +222,7 @@ function wppa_fopen( $file, $mode ) {
|
|
162 |
|
163 |
// Is path safe?
|
164 |
if ( ! wppa_is_path_safe( $file ) ) {
|
165 |
-
wppa_log( '
|
166 |
return false; // For diagnostic purposes, no return here yet
|
167 |
}
|
168 |
|
@@ -185,14 +245,14 @@ global $wp_filesystem;
|
|
185 |
// Is path safe?
|
186 |
$dir = dirname( $pattern );
|
187 |
if ( ! wppa_is_path_safe( $dir, $wp_content ) ) {
|
188 |
-
wppa_log( '
|
189 |
return array();
|
190 |
}
|
191 |
-
|
192 |
// Get dirlist
|
193 |
wppa_init_fs();
|
194 |
$dirlist = $wp_filesystem->dirlist( dirname( $pattern ) );
|
195 |
-
|
196 |
// Convert glob pattern to preg_match pattern
|
197 |
$pregpat = str_replace( '.', '\.', basename( $pattern ) ); // Dot (.) to ecaped dot (\.)
|
198 |
$pregpat = str_replace( '*', '.*', $pregpat ); // Any chars (*) to any number of any chars (*.)
|
@@ -203,17 +263,17 @@ global $wp_filesystem;
|
|
203 |
|
204 |
// Process dirlist
|
205 |
if ( ! empty( $dirlist ) ) foreach( $dirlist as $item ) {
|
206 |
-
|
207 |
if ( ! $flags || // if never mnd
|
208 |
( ( $flags & WPPA_ONLYDIRS ) && $item['type'] == 'd' ) || // or must be dir and is dir
|
209 |
( ( $flags & WPPA_ONLYFILES ) && $item['type'] == 'f' ) ) { // or must be file and is file
|
210 |
-
|
211 |
if ( preg_match( $pregpat, $item['name'] ) ) { // and pattern matches
|
212 |
$result[] = $dir . '/' . $item['name'];
|
213 |
}
|
214 |
}
|
215 |
}
|
216 |
-
|
217 |
// wppa_log('obs', 'New = '.serialize($result));
|
218 |
// $result = glob( $pattern, $flags | GLOB_NOSORT );
|
219 |
// wppa_log('obs', 'Old = '.serialize($result));
|
@@ -226,7 +286,7 @@ function wppa_unlink( $file ) {
|
|
226 |
global $wp_filesystem;
|
227 |
|
228 |
if ( ! wppa_is_path_safe( $file ) ) {
|
229 |
-
wppa_log( '
|
230 |
return false;
|
231 |
}
|
232 |
|
@@ -235,55 +295,125 @@ global $wp_filesystem;
|
|
235 |
return true;
|
236 |
}
|
237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
// Wrapper for mkdir
|
239 |
function wppa_mkdir( $dir ) {
|
|
|
240 |
|
241 |
-
|
242 |
|
243 |
// Path safe?
|
244 |
if ( ! wppa_is_path_safe( $dir ) ) {
|
245 |
-
wppa_log( '
|
|
|
246 |
}
|
247 |
|
248 |
// Already exists?
|
249 |
-
elseif (
|
250 |
-
$
|
|
|
251 |
}
|
252 |
|
253 |
// Create dir
|
254 |
else {
|
255 |
-
$
|
256 |
|
257 |
-
if (
|
258 |
wppa_log( 'Fso', 'Created path: ' . $dir );
|
|
|
259 |
}
|
260 |
else {
|
261 |
wppa_log( 'Err', 'Could not create: ' . $dir );
|
|
|
262 |
}
|
263 |
}
|
264 |
-
|
265 |
-
return $bret;
|
266 |
}
|
267 |
|
268 |
-
/*
|
269 |
-
// Wrapper for rmdir
|
270 |
function wppa_rmdir( $dir ) {
|
|
|
271 |
|
272 |
-
if ( !
|
273 |
-
|
274 |
-
|
|
|
|
|
|
|
275 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
|
277 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
}
|
279 |
-
*/
|
280 |
|
281 |
// Wrapper for is_dir
|
282 |
function wppa_is_dir( $dir ) {
|
283 |
global $wp_filesystem;
|
284 |
|
285 |
if ( ! wppa_is_path_safe( $dir ) ) {
|
286 |
-
wppa_log( '
|
287 |
return false;
|
288 |
}
|
289 |
|
@@ -296,7 +426,7 @@ function wppa_is_file( $path ) {
|
|
296 |
global $wp_filesystem;
|
297 |
|
298 |
if ( ! wppa_is_path_safe( $path ) ) {
|
299 |
-
wppa_log( '
|
300 |
return false;
|
301 |
}
|
302 |
|
@@ -309,7 +439,7 @@ function wppa_put_contents( $path, $contents, $log = true ) {
|
|
309 |
global $wp_filesystem;
|
310 |
|
311 |
if ( ! wppa_is_path_safe( $path ) ) {
|
312 |
-
if ( $log ) wppa_log( '
|
313 |
return false;
|
314 |
}
|
315 |
|
@@ -322,7 +452,7 @@ function wppa_get_contents( $path ) {
|
|
322 |
global $wp_filesystem;
|
323 |
|
324 |
if ( ! wppa_is_path_safe( $path ) ) {
|
325 |
-
wppa_log( '
|
326 |
return false;
|
327 |
}
|
328 |
|
@@ -335,7 +465,7 @@ function wppa_get_contents_array( $path, $log = true ) {
|
|
335 |
global $wp_filesystem;
|
336 |
|
337 |
if ( ! wppa_is_path_safe( $path ) ) {
|
338 |
-
if ( $log ) wppa_log( '
|
339 |
return false;
|
340 |
}
|
341 |
|
@@ -376,6 +506,7 @@ global $wppa_log_file;
|
|
376 |
WPPA_PATH . '/wppa-dump.txt',
|
377 |
WPPA_PATH . '/dynamic',
|
378 |
WPPA_PATH . '/img',
|
|
|
379 |
WPPA_UPLOAD_PATH . '/temp',
|
380 |
WPPA_UPLOAD_PATH . '/zips',
|
381 |
WPPA_UPLOAD_PATH . '/qr',
|
10 |
*/
|
11 |
|
12 |
require_once ABSPATH . 'wp-admin/includes/file.php';
|
|
|
13 |
|
14 |
function wppa_init_fs() {
|
15 |
global $wp_filesystem;
|
27 |
|
28 |
if ( ! WP_Filesystem( $creds, false, true ) ) {
|
29 |
|
30 |
+
wppa_log( 'Err', 'WP_Filesystem initialisation error' );
|
31 |
return false;
|
32 |
}
|
33 |
}
|
38 |
// erroneously cause the PHP warning 'is not a valid JPEG file' and cause imagecreatefromjpag crash.
|
39 |
function wppa_imagecreatefromjpeg( $file ) {
|
40 |
|
41 |
+
if ( ! wppa_is_path_safe( $file ) ) {
|
42 |
+
wppa_log( 'Err', 'Unsafe from path detected in wppa_imagecreatefromjpeg(): ' . sanitize_text_field( str_replace( WPPA_CONTENT_PATH, '...', $file ) ) );
|
43 |
+
return false;
|
44 |
+
}
|
45 |
ini_set( 'gd.jpeg_ignore_warning', true );
|
46 |
+
|
47 |
$img = imagecreatefromjpeg( $file );
|
48 |
+
if ( ! $img ) {
|
49 |
+
wppa_log( 'Err', 'Could not create memoryimage from file ' . sanitize_text_field( str_replace( WPPA_CONTENT_PATH, '...', $file ) ) );
|
50 |
+
}
|
51 |
return $img;
|
52 |
}
|
53 |
|
54 |
+
// Wrapper for imagecreatefromgif( $file ), verifies safe pathnames
|
55 |
+
function wppa_imagecreatefromgif( $file ) {
|
56 |
|
57 |
if ( ! wppa_is_path_safe( $file ) ) {
|
58 |
+
wppa_log( 'Err', 'Unsafe from path detected in wppa_imagecreatefromgif(): ' . sanitize_text_field( str_replace( WPPA_CONTENT_PATH, '...', $file ) ) );
|
59 |
return false;
|
60 |
}
|
61 |
|
62 |
+
$img = imagecreatefromgif( $file );
|
63 |
+
if ( ! $img ) {
|
64 |
+
wppa_log( 'Err', 'Could not create memoryimage from file ' . sanitize_text_field( str_replace( WPPA_CONTENT_PATH, '...', $file ) ) );
|
65 |
+
}
|
66 |
+
return $img;
|
67 |
}
|
68 |
|
69 |
// Wrapper for imagecreatefrompng( $file ), verifies safe pathnames
|
70 |
function wppa_imagecreatefrompng( $file ) {
|
71 |
|
72 |
if ( ! wppa_is_path_safe( $file ) ) {
|
73 |
+
wppa_log( 'Err', 'Unsafe from path detected in wppa_imagecreatefrompng(): ' . sanitize_text_field( str_replace( WPPA_CONTENT_PATH, '...', $file ) ) );
|
74 |
return false;
|
75 |
}
|
76 |
|
77 |
+
$img = imagecreatefrompng( $file );
|
78 |
+
if ( ! $img ) {
|
79 |
+
wppa_log( 'Err', 'Could not create memoryimage from file ' . sanitize_text_field( str_replace( WPPA_CONTENT_PATH, '...', $file ) ) );
|
80 |
+
}
|
81 |
+
return $img;
|
82 |
+
}
|
83 |
+
|
84 |
+
// Wrapper for getimagesize( $file ), verifies safe pathnames
|
85 |
+
function wppa_getimagesize( $file ) {
|
86 |
+
|
87 |
+
if ( ! wppa_is_path_safe( $file ) ) {
|
88 |
+
wppa_log( 'Err', 'Unsafe from path detected in wppa_getimagesize(): ' . sanitize_text_field( str_replace( WPPA_CONTENT_PATH, '...', $file ) ) );
|
89 |
+
return false;
|
90 |
+
}
|
91 |
+
|
92 |
+
$result = getimagesize( $file );
|
93 |
+
if ( ! $result ) {
|
94 |
+
wppa_log( 'Err', 'Could not read image size from ' . sanitize_text_field( str_replace( WPPA_CONTENT_PATH, '...', $file ) ) );
|
95 |
+
}
|
96 |
+
return $result;
|
97 |
+
}
|
98 |
+
|
99 |
+
function wppa_imagegif( $image, $file ) {
|
100 |
+
|
101 |
+
$bret = imagegif( $image, $file );
|
102 |
+
wppa_chmod( $file );
|
103 |
+
return $bret;
|
104 |
+
}
|
105 |
+
|
106 |
+
function wppa_imagejpeg( $image, $file, $prec = 0 ) {
|
107 |
+
|
108 |
+
if ( ! $prec ) {
|
109 |
+
$prec = wppa_opt( 'jpeg_quality' );
|
110 |
+
}
|
111 |
+
$bret = imagejpeg( $image, $file, $prec );
|
112 |
+
wppa_chmod( $file );
|
113 |
+
return $bret;
|
114 |
+
}
|
115 |
+
|
116 |
+
function wppa_imagepng( $image, $file, $prec = 0 ) {
|
117 |
+
|
118 |
+
if ( ! $prec ) {
|
119 |
+
$prec = 6;
|
120 |
+
}
|
121 |
+
$bret = imagepng( $image, $file, $prec );
|
122 |
+
wppa_chmod( $file );
|
123 |
+
return $bret;
|
124 |
}
|
125 |
|
126 |
+
|
127 |
+
|
128 |
// Wrapper for copy( $from, $to ) that verifies that the pathnames are safe for our application
|
129 |
// In case of unexpected operation: Generates a warning in the wppa log, and does not perform the copy.
|
130 |
function wppa_copy( $from, $to ) {
|
133 |
// First test if we are uploading
|
134 |
if ( ! wppa_is_path_safe( $from ) && $_FILES ) {
|
135 |
if ( ! wppa_is_path_safe( $to ) ) {
|
136 |
+
wppa_log( 'Err', '1 Unsafe to path detected in wppa_copy(): ' . sanitize_text_field( $to ), true );
|
137 |
return false;
|
138 |
}
|
139 |
return wppa_move_uploaded_file( $from, $to );
|
140 |
}
|
141 |
|
142 |
if ( ! wppa_is_path_safe( $from ) ) {
|
143 |
+
wppa_log( 'Err', '2 Unsafe from path detected in wppa_copy(): ' . sanitize_text_field( $from ), true );
|
144 |
return false; // For diagnostic purposes, no return here yet
|
145 |
}
|
146 |
if ( ! wppa_is_path_safe( $to ) ) {
|
147 |
+
wppa_log( 'Err', '3 Unsafe to path detected in wppa_copy(): ' . sanitize_text_field( $to ), true );
|
148 |
return false; // For diagnostic purposes, no return here yet
|
149 |
}
|
150 |
|
151 |
wppa_init_fs();
|
152 |
+
$bret = @ $wp_filesystem->copy( $from, $to, true, 0644 );
|
153 |
+
return $bret;
|
154 |
}
|
155 |
|
156 |
function wppa_filesize( $file ) {
|
157 |
global $wp_filesystem;
|
158 |
|
159 |
if ( ! wppa_is_path_safe( $ile ) ) {
|
160 |
+
wppa_log( 'Err', 'Unsafe path detected in wppa_filesize(): ' . sanitize_text_field( $file ), true );
|
161 |
return false; // For diagnostic purposes, no return here yet
|
162 |
}
|
163 |
|
170 |
global $wp_filesystem;
|
171 |
|
172 |
if ( ! wppa_is_path_safe( $to ) ) {
|
173 |
+
wppa_log( 'Err', 'Unsafe to path detected in wppa_move_uploaded_file(): ' . sanitize_text_field( $to ), true );
|
174 |
return false; // For diagnostic purposes, no return here yet
|
175 |
}
|
176 |
if ( strpos( $from, '../' ) !== false ) {
|
184 |
}
|
185 |
}
|
186 |
if ( ! $bret ) {
|
187 |
+
wppa_log( 'Err', 'Could not move uploaded file ' . sanitize_text_field( $from ) . ' to ' . sanitize_text_field( $to ), true );
|
188 |
}
|
189 |
return $bret;
|
190 |
}
|
195 |
|
196 |
$bret = false;
|
197 |
if ( ! wppa_is_path_safe( $from ) ) {
|
198 |
+
wppa_log( 'Err', 'Unsafe from path detected in wppa_rename(): ' . sanitize_text_field( $from ), true );
|
199 |
return false;
|
200 |
}
|
201 |
if ( ! wppa_is_path_safe( $to ) ) {
|
202 |
+
wppa_log( 'Err', 'Unsafe to path detected in wppa_rename(): ' . sanitize_text_field( $to ), true );
|
203 |
return false;
|
204 |
}
|
205 |
|
222 |
|
223 |
// Is path safe?
|
224 |
if ( ! wppa_is_path_safe( $file ) ) {
|
225 |
+
wppa_log( 'Err', 'Unsafe to path detected in wppa_fopen(): ' . sanitize_text_field( $file ), true );
|
226 |
return false; // For diagnostic purposes, no return here yet
|
227 |
}
|
228 |
|
245 |
// Is path safe?
|
246 |
$dir = dirname( $pattern );
|
247 |
if ( ! wppa_is_path_safe( $dir, $wp_content ) ) {
|
248 |
+
wppa_log( 'Err', 'Unsafe path detected in wppa_glob(): ' . sanitize_text_field( $dir ), true );
|
249 |
return array();
|
250 |
}
|
251 |
+
|
252 |
// Get dirlist
|
253 |
wppa_init_fs();
|
254 |
$dirlist = $wp_filesystem->dirlist( dirname( $pattern ) );
|
255 |
+
|
256 |
// Convert glob pattern to preg_match pattern
|
257 |
$pregpat = str_replace( '.', '\.', basename( $pattern ) ); // Dot (.) to ecaped dot (\.)
|
258 |
$pregpat = str_replace( '*', '.*', $pregpat ); // Any chars (*) to any number of any chars (*.)
|
263 |
|
264 |
// Process dirlist
|
265 |
if ( ! empty( $dirlist ) ) foreach( $dirlist as $item ) {
|
266 |
+
|
267 |
if ( ! $flags || // if never mnd
|
268 |
( ( $flags & WPPA_ONLYDIRS ) && $item['type'] == 'd' ) || // or must be dir and is dir
|
269 |
( ( $flags & WPPA_ONLYFILES ) && $item['type'] == 'f' ) ) { // or must be file and is file
|
270 |
+
|
271 |
if ( preg_match( $pregpat, $item['name'] ) ) { // and pattern matches
|
272 |
$result[] = $dir . '/' . $item['name'];
|
273 |
}
|
274 |
}
|
275 |
}
|
276 |
+
|
277 |
// wppa_log('obs', 'New = '.serialize($result));
|
278 |
// $result = glob( $pattern, $flags | GLOB_NOSORT );
|
279 |
// wppa_log('obs', 'Old = '.serialize($result));
|
286 |
global $wp_filesystem;
|
287 |
|
288 |
if ( ! wppa_is_path_safe( $file ) ) {
|
289 |
+
wppa_log( 'Err', 'Unsafe path detected in wppa_unlink(): ' . sanitize_text_field( $file ), true );
|
290 |
return false;
|
291 |
}
|
292 |
|
295 |
return true;
|
296 |
}
|
297 |
|
298 |
+
function wppa_mktree( $path ) {
|
299 |
+
|
300 |
+
if ( wppa_is_dir( $path ) ) {
|
301 |
+
wppa_chmod( $path, true );
|
302 |
+
return true;
|
303 |
+
}
|
304 |
+
$bret = wppa_mktree( dirname( $path ) );
|
305 |
+
wppa_mkdir( $path );
|
306 |
+
|
307 |
+
return ( wppa_is_dir( $path ) );
|
308 |
+
}
|
309 |
+
|
310 |
// Wrapper for mkdir
|
311 |
function wppa_mkdir( $dir ) {
|
312 |
+
global $wp_filesystem;
|
313 |
|
314 |
+
wppa_init_fs();
|
315 |
|
316 |
// Path safe?
|
317 |
if ( ! wppa_is_path_safe( $dir ) ) {
|
318 |
+
wppa_log( 'Err', 'Unsafe path detected in wppa_mkdir(): ' . sanitize_text_field( $dir ), true );
|
319 |
+
return false;
|
320 |
}
|
321 |
|
322 |
// Already exists?
|
323 |
+
elseif ( wppa_is_dir( $dir ) ) {
|
324 |
+
wppa_chmod( $path );
|
325 |
+
return true;
|
326 |
}
|
327 |
|
328 |
// Create dir
|
329 |
else {
|
330 |
+
$wp_filesystem->mkdir( $dir, 0755 );
|
331 |
|
332 |
+
if ( wppa_is_dir( $dir ) ) {
|
333 |
wppa_log( 'Fso', 'Created path: ' . $dir );
|
334 |
+
return true;
|
335 |
}
|
336 |
else {
|
337 |
wppa_log( 'Err', 'Could not create: ' . $dir );
|
338 |
+
return false;
|
339 |
}
|
340 |
}
|
|
|
|
|
341 |
}
|
342 |
|
|
|
|
|
343 |
function wppa_rmdir( $dir ) {
|
344 |
+
global $wp_filesystem;
|
345 |
|
346 |
+
if ( ! wppa_is_dir( $dir ) ) return;
|
347 |
+
|
348 |
+
wppa_init_fs();
|
349 |
+
$wp_filesystem->rmdir( $dir );
|
350 |
+
if ( wppa_is_dir( $dir ) ) {
|
351 |
+
wppa_log( 'Err', 'Could not remove dir ' . sanitize_text_field( str_replace( WPPA_CONTENT_PATH, '...', $dir ) ) );
|
352 |
}
|
353 |
+
else {
|
354 |
+
wppa_log( 'Fso', 'Successfully removed dir ' . sanitize_text_field( str_replace( WPPA_CONTENT_PATH, '...', $dir ) ) );
|
355 |
+
}
|
356 |
+
}
|
357 |
+
|
358 |
+
function wppa_chmod( $fso, $recursive = false ) {
|
359 |
+
global $wp_filesystem;
|
360 |
|
361 |
+
$fso = rtrim( $fso, '/' );
|
362 |
+
|
363 |
+
if ( ! wppa_is_path_safe( $fso ) ) {
|
364 |
+
wppa_log( 'Err', 'Unsafe path detected in wppa_chmod() ' . sanitize_text_field( $fso ), true );
|
365 |
+
return;
|
366 |
+
}
|
367 |
+
|
368 |
+
wppa_init_fs();
|
369 |
+
|
370 |
+
$perms = fileperms( $fso ) & 0777;
|
371 |
+
|
372 |
+
if ( wppa_is_dir( $fso ) ) {
|
373 |
+
|
374 |
+
// Check file permissions
|
375 |
+
if ( 0755 !== ( $perms & 0755 ) ) {
|
376 |
+
|
377 |
+
// If not sufficient, try to change
|
378 |
+
@ $wp_filesystem->chmod( $fso, 0755, $recursive );
|
379 |
+
clearstatcache();
|
380 |
+
|
381 |
+
// If still no luck
|
382 |
+
if ( 0755 !== ( fileperms( $fso ) & 0755 ) ) {
|
383 |
+
wppa_log( 'Fso', sprintf( 'Unable to set filepermissions on %s from %o to 0755', $fso, $perms ) );
|
384 |
+
}
|
385 |
+
else {
|
386 |
+
wppa_log( 'Fso', sprintf( 'Successfully set filepermissions on %s from %o to 0755', $fso, $perms ) );
|
387 |
+
}
|
388 |
+
}
|
389 |
+
}
|
390 |
+
|
391 |
+
if ( is_file( $fso ) ) {
|
392 |
+
|
393 |
+
// Check file permissions
|
394 |
+
if ( 0644 !== ( fileperms( $fso ) & 0644 ) ) {
|
395 |
+
|
396 |
+
// If not sufficient, try to change
|
397 |
+
@ $wp_filesystem->chmod( $fso, 0644 );
|
398 |
+
clearstatcache();
|
399 |
+
|
400 |
+
// If still no luck
|
401 |
+
if ( 0644 !== ( fileperms( $fso ) & 0644 ) ) {
|
402 |
+
wppa_log( 'Fso', sprintf( 'Unable to set filepermissions on %s from %o to 0644', $fso, $perms ) );
|
403 |
+
}
|
404 |
+
else {
|
405 |
+
wppa_log( 'Fso', sprintf( 'Successfully set filepermissions on %s from %o to 0644', $fso, $perms ) );
|
406 |
+
}
|
407 |
+
}
|
408 |
+
}
|
409 |
}
|
|
|
410 |
|
411 |
// Wrapper for is_dir
|
412 |
function wppa_is_dir( $dir ) {
|
413 |
global $wp_filesystem;
|
414 |
|
415 |
if ( ! wppa_is_path_safe( $dir ) ) {
|
416 |
+
wppa_log( 'Err', 'Unsafe path detected in wppa_is_dir(): ' . sanitize_text_field( $dir ), true );
|
417 |
return false;
|
418 |
}
|
419 |
|
426 |
global $wp_filesystem;
|
427 |
|
428 |
if ( ! wppa_is_path_safe( $path ) ) {
|
429 |
+
wppa_log( 'Err', 'Unsafe path detected in wppa_is_file(): ' . sanitize_text_field( $path ), true );
|
430 |
return false;
|
431 |
}
|
432 |
|
439 |
global $wp_filesystem;
|
440 |
|
441 |
if ( ! wppa_is_path_safe( $path ) ) {
|
442 |
+
if ( $log ) wppa_log( 'Err', 'Unsafe path detected in wppa_put_contents(): ' . sanitize_text_field( $path ), true );
|
443 |
return false;
|
444 |
}
|
445 |
|
452 |
global $wp_filesystem;
|
453 |
|
454 |
if ( ! wppa_is_path_safe( $path ) ) {
|
455 |
+
wppa_log( 'Err', 'Unsafe path detected in wppa_get_contents(): ' . sanitize_text_field( $path ), true );
|
456 |
return false;
|
457 |
}
|
458 |
|
465 |
global $wp_filesystem;
|
466 |
|
467 |
if ( ! wppa_is_path_safe( $path ) ) {
|
468 |
+
if ( $log ) wppa_log( 'Err', 'Unsafe path detected in wppa_get_contents_array(): ' . sanitize_text_field( $path ), true );
|
469 |
return false;
|
470 |
}
|
471 |
|
506 |
WPPA_PATH . '/wppa-dump.txt',
|
507 |
WPPA_PATH . '/dynamic',
|
508 |
WPPA_PATH . '/img',
|
509 |
+
WPPA_PATH . '/theme',
|
510 |
WPPA_UPLOAD_PATH . '/temp',
|
511 |
WPPA_UPLOAD_PATH . '/zips',
|
512 |
WPPA_UPLOAD_PATH . '/qr',
|
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: 7.1.02.
|
6 |
* Author: J.N. Breetvelt a.k.a. OpaJaap
|
7 |
* Author URI: http://wppa.opajaap.nl/
|
8 |
* Plugin URI: http://wordpress.org/extend/plugins/wp-photo-album-plus/
|
@@ -23,7 +23,7 @@ global $wp_version;
|
|
23 |
|
24 |
/* WPPA GLOBALS */
|
25 |
global $wppa_revno; $wppa_revno = '7102'; // WPPA db version
|
26 |
-
global $wppa_api_version; $wppa_api_version = '7.1.02.
|
27 |
|
28 |
/* start timers */
|
29 |
add_action( 'plugins_loaded', 'wppa_init_timer' );
|
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: 7.1.02.005
|
6 |
* Author: J.N. Breetvelt a.k.a. OpaJaap
|
7 |
* Author URI: http://wppa.opajaap.nl/
|
8 |
* Plugin URI: http://wordpress.org/extend/plugins/wp-photo-album-plus/
|
23 |
|
24 |
/* WPPA GLOBALS */
|
25 |
global $wppa_revno; $wppa_revno = '7102'; // WPPA db version
|
26 |
+
global $wppa_api_version; $wppa_api_version = '7.1.02.005'; // WPPA software version
|
27 |
|
28 |
/* start timers */
|
29 |
add_action( 'plugins_loaded', 'wppa_init_timer' );
|