Version Description
Download this release
Release Info
Developer | opajaap |
Plugin | WP Photo Album Plus |
Version | 6.5.02 |
Comparing to | |
See all releases |
Code changes from version 6.5.01 to 6.5.02
- js/wppa-admin-scripts.js +15 -8
- js/wppa-slideshow.js +20 -3
- js/wppa-slideshow.min.js +8 -4
- js/wppa-tinymce-shortcodes.js +24 -8
- readme.txt +18 -3
- wppa-admin-functions.php +15 -1
- wppa-admin.php +7 -2
- wppa-ajax.php +1 -1
- wppa-album-covers.php +24 -7
- wppa-boxes-html.php +82 -14
- wppa-common-functions.php +2 -1
- wppa-date-time.php +34 -33
- wppa-filter.php +3 -1
- wppa-functions.php +114 -16
- wppa-import.php +2640 -0
- wppa-init.php +40 -1
- wppa-mobile.php +89 -89
- wppa-photo-admin-autosave.php +17 -2
- wppa-settings-autosave.php +30 -1
- wppa-setup.php +8 -1
- wppa-source.php +3 -1
- wppa-tinymce-shortcodes.php +5 -3
- wppa-upload.php +412 -2376
- wppa-users.php +1 -4
- wppa-utils.php +2 -2
- wppa.php +4 -4
js/wppa-admin-scripts.js
CHANGED
@@ -1515,7 +1515,7 @@ function wppaAjaxUpdateOptionCheckBox(slug, elem) {
|
|
1515 |
case 1:
|
1516 |
case 2:
|
1517 |
case 3:
|
1518 |
-
|
1519 |
break;
|
1520 |
case 4:
|
1521 |
var str = wppaTrim(xmlhttp.responseText);
|
@@ -1527,8 +1527,8 @@ function wppaAjaxUpdateOptionCheckBox(slug, elem) {
|
|
1527 |
if (xmlhttp.status!=404) {
|
1528 |
switch (ArrValues[1]) {
|
1529 |
case '0': // No error
|
1530 |
-
|
1531 |
-
|
1532 |
if ( ArrValues[3] != '' ) alert(ArrValues[3]);
|
1533 |
if ( _wppaRefreshAfter ) {
|
1534 |
_wppaRefreshAfter = false;
|
@@ -1536,8 +1536,8 @@ function wppaAjaxUpdateOptionCheckBox(slug, elem) {
|
|
1536 |
}
|
1537 |
break;
|
1538 |
default:
|
1539 |
-
|
1540 |
-
|
1541 |
if ( ArrValues[3] != '' ) alert(ArrValues[3]);
|
1542 |
if ( _wppaRefreshAfter ) {
|
1543 |
_wppaRefreshAfter = false;
|
@@ -1547,8 +1547,8 @@ function wppaAjaxUpdateOptionCheckBox(slug, elem) {
|
|
1547 |
|
1548 |
}
|
1549 |
else {
|
1550 |
-
|
1551 |
-
|
1552 |
}
|
1553 |
wppaCheckInconsistencies();
|
1554 |
}
|
@@ -1835,7 +1835,7 @@ function wppaEncode(xtext) {
|
|
1835 |
function wppaCheckInconsistencies() {
|
1836 |
|
1837 |
// Uses thumb popup and thumb lightbox?
|
1838 |
-
if (
|
1839 |
jQuery('.popup-lightbox-err').css('display', '');
|
1840 |
}
|
1841 |
else {
|
@@ -2119,4 +2119,11 @@ function wppaExportDbTable( table ) {
|
|
2119 |
}
|
2120 |
} );
|
2121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2122 |
}
|
1515 |
case 1:
|
1516 |
case 2:
|
1517 |
case 3:
|
1518 |
+
jQuery('#img_'+slug).attr('src',wppaImageDirectory+'clock.png');
|
1519 |
break;
|
1520 |
case 4:
|
1521 |
var str = wppaTrim(xmlhttp.responseText);
|
1527 |
if (xmlhttp.status!=404) {
|
1528 |
switch (ArrValues[1]) {
|
1529 |
case '0': // No error
|
1530 |
+
jQuery('#img_'+slug).attr('src',wppaImageDirectory+'tick.png');
|
1531 |
+
jQuery('#img_'+slug).attr('title',ArrValues[2]);
|
1532 |
if ( ArrValues[3] != '' ) alert(ArrValues[3]);
|
1533 |
if ( _wppaRefreshAfter ) {
|
1534 |
_wppaRefreshAfter = false;
|
1536 |
}
|
1537 |
break;
|
1538 |
default:
|
1539 |
+
jQuery('#img_'+slug).attr('src',wppaImageDirectory+'cross.png');
|
1540 |
+
jQuery('#img_'+slug).attr('title','Error #'+ArrValues[1]+', message: '+ArrValues[2]+', status: '+xmlhttp.status);
|
1541 |
if ( ArrValues[3] != '' ) alert(ArrValues[3]);
|
1542 |
if ( _wppaRefreshAfter ) {
|
1543 |
_wppaRefreshAfter = false;
|
1547 |
|
1548 |
}
|
1549 |
else {
|
1550 |
+
jQuery('#img_'+slug).attr('src',wppaImageDirectory+'cross.png');
|
1551 |
+
jQuery('#img_'+slug).attr('title','Communication error, status = '+xmlhttp.status);
|
1552 |
}
|
1553 |
wppaCheckInconsistencies();
|
1554 |
}
|
1835 |
function wppaCheckInconsistencies() {
|
1836 |
|
1837 |
// Uses thumb popup and thumb lightbox?
|
1838 |
+
if ( jQuery('#use_thumb_popup').attr('checked') && jQuery('#thumb_linktype').val() == 'lightbox' ) {
|
1839 |
jQuery('.popup-lightbox-err').css('display', '');
|
1840 |
}
|
1841 |
else {
|
2119 |
}
|
2120 |
} );
|
2121 |
|
2122 |
+
}
|
2123 |
+
|
2124 |
+
function wppaDismissAdminNotice(notice, elm) {
|
2125 |
+
|
2126 |
+
wppaAjaxUpdateOptionCheckBox(notice, elm);
|
2127 |
+
jQuery('#wppa-wr-').css('display','none');
|
2128 |
+
|
2129 |
}
|
js/wppa-slideshow.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
// Contains slideshow modules
|
4 |
// Dependancies: wppa.js and default wp jQuery library
|
5 |
//
|
6 |
-
var wppaJsSlideshowVersion = '6.5.
|
7 |
|
8 |
// This is an entrypoint to load the slide data
|
9 |
function wppaStoreSlideInfo(
|
@@ -781,7 +781,7 @@ function _wppaNextSlide_5( mocc ) {
|
|
781 |
|
782 |
// If running: Wait for next slide
|
783 |
if ( _wppaSSRuns[mocc] ) {
|
784 |
-
setTimeout( '_wppaNextSlide( '+mocc+', "auto" )',
|
785 |
}
|
786 |
}
|
787 |
|
@@ -1281,7 +1281,7 @@ function _wppaGotoContinue( mocc ) {
|
|
1281 |
setTimeout( '_wppaGotoContinue( '+mocc+' )', 10 ); // Try again after 10 ms
|
1282 |
return;
|
1283 |
}
|
1284 |
-
setTimeout( '_wppaNextSlide( '+mocc+', "reset" )',
|
1285 |
}
|
1286 |
|
1287 |
function _wppaStart( mocc, idx ) {
|
@@ -1333,6 +1333,9 @@ function _wppaStop( mocc ) {
|
|
1333 |
|
1334 |
function _wppaSpeed( mocc, faster ) {
|
1335 |
|
|
|
|
|
|
|
1336 |
if ( faster ) {
|
1337 |
if ( _wppaTimeOut[mocc] > 500 ) _wppaTimeOut[mocc] /= 1.5;
|
1338 |
}
|
@@ -1786,4 +1789,18 @@ function _wppaShowMetaData( mocc, key ) {
|
|
1786 |
}
|
1787 |
}
|
1788 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1789 |
wppaConsoleLog( 'wppa-slideshow.js version '+wppaJsSlideshowVersion+' loaded.', 'force' );
|
3 |
// Contains slideshow modules
|
4 |
// Dependancies: wppa.js and default wp jQuery library
|
5 |
//
|
6 |
+
var wppaJsSlideshowVersion = '6.5.02';
|
7 |
|
8 |
// This is an entrypoint to load the slide data
|
9 |
function wppaStoreSlideInfo(
|
781 |
|
782 |
// If running: Wait for next slide
|
783 |
if ( _wppaSSRuns[mocc] ) {
|
784 |
+
setTimeout( '_wppaNextSlide( '+mocc+', "auto" )', wppaGetSlideshowTimeout( mocc ) );
|
785 |
}
|
786 |
}
|
787 |
|
1281 |
setTimeout( '_wppaGotoContinue( '+mocc+' )', 10 ); // Try again after 10 ms
|
1282 |
return;
|
1283 |
}
|
1284 |
+
setTimeout( '_wppaNextSlide( '+mocc+', "reset" )', wppaGetSlideshowTimeout( mocc ) + 10 ); //restart slideshow after new timeout
|
1285 |
}
|
1286 |
|
1287 |
function _wppaStart( mocc, idx ) {
|
1333 |
|
1334 |
function _wppaSpeed( mocc, faster ) {
|
1335 |
|
1336 |
+
if ( _wppaTimeOut[mocc] == 'random' ) {
|
1337 |
+
return;
|
1338 |
+
}
|
1339 |
if ( faster ) {
|
1340 |
if ( _wppaTimeOut[mocc] > 500 ) _wppaTimeOut[mocc] /= 1.5;
|
1341 |
}
|
1789 |
}
|
1790 |
}
|
1791 |
|
1792 |
+
function wppaGetSlideshowTimeout( mocc ) {
|
1793 |
+
|
1794 |
+
var time;
|
1795 |
+
if ( _wppaTimeOut[mocc] == 'random' ) {
|
1796 |
+
var min = 2 * wppaAnimationSpeed;
|
1797 |
+
var max = 7 * wppaAnimationSpeed;
|
1798 |
+
time = Math.floor(Math.random() * (max - min + 1)) + min;
|
1799 |
+
}
|
1800 |
+
else {
|
1801 |
+
time = _wppaTimeOut[mocc];
|
1802 |
+
}
|
1803 |
+
return time;
|
1804 |
+
}
|
1805 |
+
|
1806 |
wppaConsoleLog( 'wppa-slideshow.js version '+wppaJsSlideshowVersion+' loaded.', 'force' );
|
js/wppa-slideshow.min.js
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
// Dependancies: wppa.js and default wp jQuery library
|
5 |
//
|
6 |
|
7 |
-
var wppaJsSlideshowVersion='6.5.
|
8 |
cursor='default';if(linkurl!=''){cursor='pointer';}
|
9 |
else if(wppaLightBox[mocc]!=''){cursor='url( '+wppaImageDirectory+wppaMagnifierCursor+' ),pointer';}
|
10 |
_wppaIsVideo[mocc][id]=(''!=videohtml);if(_wppaIsVideo[mocc][id]){_wppaSlides[mocc][id]=' alt="'+wppaTrimAlt(name)+'" class="theimg theimg-'+mocc+' big" ';if(wppaSlideVideoStart&&wppaLightBox[mocc]==''){_wppaSlides[mocc][id]+=' autoplay ';}}
|
@@ -74,7 +74,7 @@ _wppaDoAutocol(mocc);wppaStartStop(mocc,index);return;}
|
|
74 |
else{wppaUpdateLightboxes();if(!wppaIsMini[mocc]){var visurl=wppaGetCurrentFullUrl(mocc,_wppaCurIdx[mocc]);if(''==visurl){visurl=_wppaShareUrl[mocc][_wppaCurIdx[mocc]];}
|
75 |
if(typeof(wppaQRUpdate)!='undefined'){wppaQRUpdate(_wppaShareUrl[mocc][_wppaCurIdx[mocc]]);}
|
76 |
if(!_wppaSSRuns[mocc]){if(_wppaSlides[mocc].length>1){wppaPushStateSlide(mocc,_wppaCurIdx[mocc],visurl);}}}
|
77 |
-
if(_wppaSSRuns[mocc]){setTimeout('_wppaNextSlide( '+mocc+', "auto" )',
|
78 |
jQuery(document).trigger('glossaryTooltipReady');_wppaDidGoto[mocc]=false;_wppaIsBusy[mocc]=false;if(!wppaIsMini[mocc]){_bumpViewCount(_wppaId[mocc][_wppaCurIdx[mocc]]);}
|
79 |
_wppaDoAutocol(mocc);wppaStopAudio();if(wppaSlideAudioStart){var elms=jQuery('.wppa-audio-'+_wppaId[mocc][_wppaCurIdx[mocc]]+'-'+mocc);if(elms.length>0){var audio=elms[elms.length-1];if(audio){if(!wppaAudioPlaying[mocc]){audio.play();}}}}}
|
80 |
function wppaFormatSlide(mocc){var imgid='theimg'+_wppaFg[mocc]+'-'+mocc;var slideid='theslide'+_wppaFg[mocc]+'-'+mocc;var frameid='slide_frame-'+mocc;var contw=wppaColWidth[mocc];var elm=document.getElementById(imgid);var audios=jQuery('.wppa-audio-'+mocc);if(!elm)return;if(typeof(contw)=='undefined'||contw==0){contw=wppaGetContainerWidth(mocc);wppaColWidth[mocc]=contw;}
|
@@ -136,13 +136,14 @@ function _wppaGoto(mocc,idx){_wppaToTheSame=(_wppaNxtIdx[mocc]==idx);_wppaNxtIdx
|
|
136 |
function _wppaGotoRunning(mocc,idx){if(_wppaIsBusy[mocc]){setTimeout('_wppaGotoRunning( '+mocc+','+idx+' )',10);return;}
|
137 |
wppaConsoleLog('GotoRunning '+mocc);_wppaSSRuns[mocc]=false;_wppaToTheSame=(_wppaNxtIdx[mocc]==idx);_wppaNxtIdx[mocc]=idx;__wppaOverruleRun=true;_wppaNextSlide(mocc,"manual");_wppaGotoContinue(mocc);}
|
138 |
function _wppaGotoContinue(mocc){if(_wppaIsBusy[mocc]){setTimeout('_wppaGotoContinue( '+mocc+' )',10);return;}
|
139 |
-
setTimeout('_wppaNextSlide( '+mocc+', "reset" )',
|
140 |
function _wppaStart(mocc,idx){if(idx==-2){var i=0;idx=0;_wppaSkipRated[mocc]=true;if(_wppaMyr[mocc][i]!=0){while(i<_wppaSlides[mocc].length){if(idx==0&&_wppaMyr[mocc][i]==0)idx=i;i++;}}}
|
141 |
if(idx>-1){jQuery('#startstop-'+mocc).html(wppaStart+' '+wppaSlideShow);jQuery('#speed0-'+mocc).css('display','none');jQuery('#speed1-'+mocc).css('display','none');_wppaNxtIdx[mocc]=idx;_wppaCurIdx[mocc]=idx;_wppaNextSlide(mocc,0);_wppaShowMetaData(mocc,'show');}
|
142 |
else{_wppaSSRuns[mocc]=true;_wppaNextSlide(mocc,0);jQuery('#startstop-'+mocc).html(wppaStop);jQuery('#speed0-'+mocc).css('display','inline');jQuery('#speed1-'+mocc).css('display','inline');_wppaShowMetaData(mocc,'hide');jQuery('#bc-pname-'+mocc).html(wppaSlideShow);}
|
143 |
_wppaSetRatingDisplay(mocc);}
|
144 |
function _wppaStop(mocc){_wppaSSRuns[mocc]=false;jQuery('#startstop-'+mocc).html(wppaStart+' '+wppaSlideShow);jQuery('#speed0-'+mocc).css('display','none');jQuery('#speed1-'+mocc).css('display','none');_wppaShowMetaData(mocc,'show');jQuery('#bc-pname-'+mocc).html(_wppaNames[mocc][_wppaCurIdx[mocc]]);}
|
145 |
-
function _wppaSpeed(mocc,faster){if(
|
|
|
146 |
else{if(_wppaTimeOut[mocc]<60000)_wppaTimeOut[mocc]*=1.5;}}
|
147 |
function _wppaLoadSpinner(mocc){if(!document.getElementById('slide_frame-'+mocc))return;var top;var lft;var elm;var flag=true;if(document.getElementById('theimg0-'+mocc)){if(document.getElementById('theimg0-'+mocc).complete)flag=false;}
|
148 |
if(document.getElementById('theimg1-'+mocc)){if(document.getElementById('theimg1-'+mocc).complete)flag=false;}
|
@@ -194,4 +195,7 @@ else{if(key=='show'){if(!wppaFotomotoHideWhenRunning)wppaFotomotoToolbar(mocc,_w
|
|
194 |
else{if(wppaShareHideWhenRunning){jQuery('#wppa-share-'+mocc).css('display','none');}}}
|
195 |
if(key=='show'){jQuery("#imagedesc-"+mocc).css('visibility','visible');jQuery("#imagetitle-"+mocc).css('visibility','visible');jQuery("#counter-"+mocc).css('visibility','visible');jQuery("#iptccontent-"+mocc).css('visibility','visible');jQuery("#exifcontent-"+mocc).css('visibility','visible');}
|
196 |
else{jQuery("#counter-"+mocc).css('visibility','hidden');jQuery('.wppa-prev-'+mocc).css('visibility','hidden');jQuery('.wppa-next-'+mocc).css('visibility','hidden');jQuery("#iptccontent-"+mocc).css('visibility','hidden');jQuery("#exifcontent-"+mocc).css('visibility','hidden');}}
|
|
|
|
|
|
|
197 |
wppaConsoleLog('wppa-slideshow.js version '+wppaJsSlideshowVersion+' loaded.','force');
|
4 |
// Dependancies: wppa.js and default wp jQuery library
|
5 |
//
|
6 |
|
7 |
+
var wppaJsSlideshowVersion='6.5.02';function wppaStoreSlideInfo(mocc,id,url,size,width,height,fullname,name,desc,photoid,avgrat,discount,myrat,rateurl,linkurl,linktitle,linktarget,iwtimeout,commenthtml,iptchtml,exifhtml,lbtitle,shareurl,smhtml,ogdsc,hiresurl,videohtml,audiohtml,waittext){var cursor;desc=wppaRepairScriptTags(desc);if(!_wppaSlides[mocc]||'0'==id){_wppaSlides[mocc]=[];_wppaNames[mocc]=[];_wppaFullNames[mocc]=[];_wppaDsc[mocc]=[];_wppaOgDsc[mocc]=[];_wppaCurIdx[mocc]=-1;_wppaNxtIdx[mocc]=0;if(parseInt(iwtimeout)>0)_wppaTimeOut[mocc]=parseInt(iwtimeout);else _wppaTimeOut[mocc]=wppaSlideShowTimeOut;_wppaSSRuns[mocc]=false;_wppaTP[mocc]=-2;_wppaFg[mocc]=0;_wppaIsBusy[mocc]=false;_wppaFirst[mocc]=true;_wppaId[mocc]=[];_wppaAvg[mocc]=[];_wppaDisc[mocc]=[];_wppaMyr[mocc]=[];_wppaVRU[mocc]=[];_wppaLinkUrl[mocc]=[];_wppaLinkTitle[mocc]=[];_wppaLinkTarget[mocc]=[];_wppaCommentHtml[mocc]=[];_wppaIptcHtml[mocc]=[];_wppaExifHtml[mocc]=[];_wppaUrl[mocc]=[];_wppaSkipRated[mocc]=false;_wppaLbTitle[mocc]=[];_wppaDidGoto[mocc]=false;wppaSlidePause[mocc]=false;_wppaShareUrl[mocc]=[];_wppaShareHtml[mocc]=[];_wppaFilmNoMove[mocc]=false;_wppaHiresUrl[mocc]=[];_wppaIsVideo[mocc]=[];_wppaVideoHtml[mocc]=[];_wppaAudioHtml[mocc]=[];_wppaVideoNatWidth[mocc]=[];_wppaVideoNatHeight[mocc]=[];wppaVideoPlaying[mocc]=false;wppaAudioPlaying[mocc]=false;_wppaWaitTexts[mocc]=[];}
|
8 |
cursor='default';if(linkurl!=''){cursor='pointer';}
|
9 |
else if(wppaLightBox[mocc]!=''){cursor='url( '+wppaImageDirectory+wppaMagnifierCursor+' ),pointer';}
|
10 |
_wppaIsVideo[mocc][id]=(''!=videohtml);if(_wppaIsVideo[mocc][id]){_wppaSlides[mocc][id]=' alt="'+wppaTrimAlt(name)+'" class="theimg theimg-'+mocc+' big" ';if(wppaSlideVideoStart&&wppaLightBox[mocc]==''){_wppaSlides[mocc][id]+=' autoplay ';}}
|
74 |
else{wppaUpdateLightboxes();if(!wppaIsMini[mocc]){var visurl=wppaGetCurrentFullUrl(mocc,_wppaCurIdx[mocc]);if(''==visurl){visurl=_wppaShareUrl[mocc][_wppaCurIdx[mocc]];}
|
75 |
if(typeof(wppaQRUpdate)!='undefined'){wppaQRUpdate(_wppaShareUrl[mocc][_wppaCurIdx[mocc]]);}
|
76 |
if(!_wppaSSRuns[mocc]){if(_wppaSlides[mocc].length>1){wppaPushStateSlide(mocc,_wppaCurIdx[mocc],visurl);}}}
|
77 |
+
if(_wppaSSRuns[mocc]){setTimeout('_wppaNextSlide( '+mocc+', "auto" )',wppaGetSlideshowTimeout(mocc));}}
|
78 |
jQuery(document).trigger('glossaryTooltipReady');_wppaDidGoto[mocc]=false;_wppaIsBusy[mocc]=false;if(!wppaIsMini[mocc]){_bumpViewCount(_wppaId[mocc][_wppaCurIdx[mocc]]);}
|
79 |
_wppaDoAutocol(mocc);wppaStopAudio();if(wppaSlideAudioStart){var elms=jQuery('.wppa-audio-'+_wppaId[mocc][_wppaCurIdx[mocc]]+'-'+mocc);if(elms.length>0){var audio=elms[elms.length-1];if(audio){if(!wppaAudioPlaying[mocc]){audio.play();}}}}}
|
80 |
function wppaFormatSlide(mocc){var imgid='theimg'+_wppaFg[mocc]+'-'+mocc;var slideid='theslide'+_wppaFg[mocc]+'-'+mocc;var frameid='slide_frame-'+mocc;var contw=wppaColWidth[mocc];var elm=document.getElementById(imgid);var audios=jQuery('.wppa-audio-'+mocc);if(!elm)return;if(typeof(contw)=='undefined'||contw==0){contw=wppaGetContainerWidth(mocc);wppaColWidth[mocc]=contw;}
|
136 |
function _wppaGotoRunning(mocc,idx){if(_wppaIsBusy[mocc]){setTimeout('_wppaGotoRunning( '+mocc+','+idx+' )',10);return;}
|
137 |
wppaConsoleLog('GotoRunning '+mocc);_wppaSSRuns[mocc]=false;_wppaToTheSame=(_wppaNxtIdx[mocc]==idx);_wppaNxtIdx[mocc]=idx;__wppaOverruleRun=true;_wppaNextSlide(mocc,"manual");_wppaGotoContinue(mocc);}
|
138 |
function _wppaGotoContinue(mocc){if(_wppaIsBusy[mocc]){setTimeout('_wppaGotoContinue( '+mocc+' )',10);return;}
|
139 |
+
setTimeout('_wppaNextSlide( '+mocc+', "reset" )',wppaGetSlideshowTimeout(mocc)+10);}
|
140 |
function _wppaStart(mocc,idx){if(idx==-2){var i=0;idx=0;_wppaSkipRated[mocc]=true;if(_wppaMyr[mocc][i]!=0){while(i<_wppaSlides[mocc].length){if(idx==0&&_wppaMyr[mocc][i]==0)idx=i;i++;}}}
|
141 |
if(idx>-1){jQuery('#startstop-'+mocc).html(wppaStart+' '+wppaSlideShow);jQuery('#speed0-'+mocc).css('display','none');jQuery('#speed1-'+mocc).css('display','none');_wppaNxtIdx[mocc]=idx;_wppaCurIdx[mocc]=idx;_wppaNextSlide(mocc,0);_wppaShowMetaData(mocc,'show');}
|
142 |
else{_wppaSSRuns[mocc]=true;_wppaNextSlide(mocc,0);jQuery('#startstop-'+mocc).html(wppaStop);jQuery('#speed0-'+mocc).css('display','inline');jQuery('#speed1-'+mocc).css('display','inline');_wppaShowMetaData(mocc,'hide');jQuery('#bc-pname-'+mocc).html(wppaSlideShow);}
|
143 |
_wppaSetRatingDisplay(mocc);}
|
144 |
function _wppaStop(mocc){_wppaSSRuns[mocc]=false;jQuery('#startstop-'+mocc).html(wppaStart+' '+wppaSlideShow);jQuery('#speed0-'+mocc).css('display','none');jQuery('#speed1-'+mocc).css('display','none');_wppaShowMetaData(mocc,'show');jQuery('#bc-pname-'+mocc).html(_wppaNames[mocc][_wppaCurIdx[mocc]]);}
|
145 |
+
function _wppaSpeed(mocc,faster){if(_wppaTimeOut[mocc]=='random'){return;}
|
146 |
+
if(faster){if(_wppaTimeOut[mocc]>500)_wppaTimeOut[mocc]/=1.5;}
|
147 |
else{if(_wppaTimeOut[mocc]<60000)_wppaTimeOut[mocc]*=1.5;}}
|
148 |
function _wppaLoadSpinner(mocc){if(!document.getElementById('slide_frame-'+mocc))return;var top;var lft;var elm;var flag=true;if(document.getElementById('theimg0-'+mocc)){if(document.getElementById('theimg0-'+mocc).complete)flag=false;}
|
149 |
if(document.getElementById('theimg1-'+mocc)){if(document.getElementById('theimg1-'+mocc).complete)flag=false;}
|
195 |
else{if(wppaShareHideWhenRunning){jQuery('#wppa-share-'+mocc).css('display','none');}}}
|
196 |
if(key=='show'){jQuery("#imagedesc-"+mocc).css('visibility','visible');jQuery("#imagetitle-"+mocc).css('visibility','visible');jQuery("#counter-"+mocc).css('visibility','visible');jQuery("#iptccontent-"+mocc).css('visibility','visible');jQuery("#exifcontent-"+mocc).css('visibility','visible');}
|
197 |
else{jQuery("#counter-"+mocc).css('visibility','hidden');jQuery('.wppa-prev-'+mocc).css('visibility','hidden');jQuery('.wppa-next-'+mocc).css('visibility','hidden');jQuery("#iptccontent-"+mocc).css('visibility','hidden');jQuery("#exifcontent-"+mocc).css('visibility','hidden');}}
|
198 |
+
function wppaGetSlideshowTimeout(mocc){var time;if(_wppaTimeOut[mocc]=='random'){var min=2*wppaAnimationSpeed;var max=7*wppaAnimationSpeed;time=Math.floor(Math.random()*(max-min+1))+min;}
|
199 |
+
else{time=_wppaTimeOut[mocc];}
|
200 |
+
return time;}
|
201 |
wppaConsoleLog('wppa-slideshow.js version '+wppaJsSlideshowVersion+' loaded.','force');
|
js/wppa-tinymce-shortcodes.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* Pachkage: wp-photo-album-plus
|
3 |
*
|
4 |
*
|
5 |
-
* Version 6.
|
6 |
*
|
7 |
*/
|
8 |
|
@@ -492,16 +492,32 @@ function wppaGalleryEvaluate() {
|
|
492 |
|
493 |
// Size
|
494 |
var size = document.getElementById('wppagallery-size').value;
|
495 |
-
|
496 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
497 |
size = 0;
|
|
|
498 |
}
|
499 |
}
|
500 |
-
|
501 |
-
size
|
502 |
-
|
503 |
-
|
504 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
505 |
}
|
506 |
if ( size != 0 ) {
|
507 |
shortcode += ' size="'+size+'"';
|
2 |
* Pachkage: wp-photo-album-plus
|
3 |
*
|
4 |
*
|
5 |
+
* Version 6.5.02
|
6 |
*
|
7 |
*/
|
8 |
|
492 |
|
493 |
// Size
|
494 |
var size = document.getElementById('wppagallery-size').value;
|
495 |
+
// Assume valid imput
|
496 |
+
jQuery('#wppagallery-size').css('color', '#070');
|
497 |
+
// See if auto with fixed max
|
498 |
+
var temp = size.split(',');
|
499 |
+
if ( temp[1] ) {
|
500 |
+
if ( temp[0] == 'auto' && parseInt( temp[1] ) == temp[1] && temp[1] > 100 ) {
|
501 |
+
// its ok, auto with a static max of size temp[1]
|
502 |
+
}
|
503 |
+
else {
|
504 |
size = 0;
|
505 |
+
jQuery('#wppagallery-size').css('color', '#700');
|
506 |
}
|
507 |
}
|
508 |
+
else {
|
509 |
+
if ( size != '' && size != 'auto' ) {
|
510 |
+
if ( parseInt(size) != size ) {
|
511 |
+
size = 0;
|
512 |
+
jQuery('#wppagallery-size').css('color', '#700');
|
513 |
+
}
|
514 |
+
}
|
515 |
+
if ( size < 0 ) {
|
516 |
+
size = -size;
|
517 |
+
}
|
518 |
+
if ( size < 100 ) {
|
519 |
+
size = size / 100;
|
520 |
+
}
|
521 |
}
|
522 |
if ( size != 0 ) {
|
523 |
shortcode += ' size="'+size+'"';
|
readme.txt
CHANGED
@@ -2,12 +2,12 @@
|
|
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¤cy_code=USD&lc=US
|
4 |
Tags: photo, album, gallery, slideshow, video, audio, lightbox, iptc, exif, cloudinary, fotomoto
|
5 |
-
Version: 6.5.
|
6 |
-
Stable tag: 6.5.
|
7 |
Author: J.N. Breetvelt
|
8 |
Author URI: http://www.opajaap.nl/
|
9 |
Requires at least: 3.9
|
10 |
-
Tested up to: 4.
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
@@ -180,6 +180,21 @@ Oh, just Google on 'picture resizer' and you will find a bunch of free programs
|
|
180 |
|
181 |
See for additional information: http://www.wppa.nl/changelog/
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
= 6.5.01 =
|
184 |
|
185 |
= Bug Fixes =
|
2 |
Contributors: opajaap
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=OpaJaap@OpaJaap.nl&item_name=WP-Photo-Album-Plus&item_number=Support-Open-Source¤cy_code=USD&lc=US
|
4 |
Tags: photo, album, gallery, slideshow, video, audio, lightbox, iptc, exif, cloudinary, fotomoto
|
5 |
+
Version: 6.5.02
|
6 |
+
Stable tag: 6.5.01
|
7 |
Author: J.N. Breetvelt
|
8 |
Author URI: http://www.opajaap.nl/
|
9 |
Requires at least: 3.9
|
10 |
+
Tested up to: 4.6
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
180 |
|
181 |
See for additional information: http://www.wppa.nl/changelog/
|
182 |
|
183 |
+
= 6.5.02 =
|
184 |
+
|
185 |
+
= Bug Fixes =
|
186 |
+
|
187 |
+
= New Features =
|
188 |
+
|
189 |
+
* Shortcode attribute size"auto" can now be extended with a maximum value in pixels. Example: size="auto,550"
|
190 |
+
* Blog It!. If you enable it in Table II-H16,17, users with edit_post rigths can send a post with one or more photos and text directly from the upload widget/box.
|
191 |
+
|
192 |
+
= Other Changes =
|
193 |
+
|
194 |
+
* Viewlink div on imagefactory covers have class .wppa-viewlink-sym as opposed to .wppa-viewlink for other cover types.
|
195 |
+
* Potential security fixes by improved input data sanitizations.
|
196 |
+
* Captcha question for album create can now be switched off in Table VII-B3.
|
197 |
+
|
198 |
= 6.5.01 =
|
199 |
|
200 |
= Bug Fixes =
|
wppa-admin-functions.php
CHANGED
@@ -457,11 +457,25 @@ global $wppa_supported_audio_extensions;
|
|
457 |
if ( $files ) foreach ( $files as $file ) {
|
458 |
if ( is_file( $file ) ) {
|
459 |
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
460 |
-
if ( !in_array( $ext, $allowed_types ) ) {
|
461 |
unlink( $file );
|
462 |
wppa_error_message( sprintf( __( 'File %s is of an unsupported filetype and has been removed.' , 'wp-photo-album-plus'), basename( wppa_sanitize_file_name( $file ) ) ) );
|
463 |
$count++;
|
464 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
}
|
466 |
elseif ( is_dir( $file ) ) {
|
467 |
$entry = basename( $file );
|
457 |
if ( $files ) foreach ( $files as $file ) {
|
458 |
if ( is_file( $file ) ) {
|
459 |
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
460 |
+
if ( ! in_array( $ext, $allowed_types ) ) {
|
461 |
unlink( $file );
|
462 |
wppa_error_message( sprintf( __( 'File %s is of an unsupported filetype and has been removed.' , 'wp-photo-album-plus'), basename( wppa_sanitize_file_name( $file ) ) ) );
|
463 |
$count++;
|
464 |
}
|
465 |
+
|
466 |
+
// Sanitize filename
|
467 |
+
$dirname = dirname( $file );
|
468 |
+
$filename = basename( $file );
|
469 |
+
|
470 |
+
// Can not use sanitize_file_name() because it removes spaces that are not illegal in most servers.
|
471 |
+
$filename = strip_tags( stripslashes( $filename ) ); //sanitize_text_field( $filename );
|
472 |
+
if ( ! seems_utf8( $filename ) ) {
|
473 |
+
$filename = utf8_encode( $filename );
|
474 |
+
}
|
475 |
+
$newname = $dirname . '/' . $filename;
|
476 |
+
if ( $newname != $file ) {
|
477 |
+
rename( $file, $newname );
|
478 |
+
}
|
479 |
}
|
480 |
elseif ( is_dir( $file ) ) {
|
481 |
$entry = basename( $file );
|
wppa-admin.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* Contains the admin menu and startups the admin pages
|
6 |
-
* Version 6.
|
7 |
*
|
8 |
*/
|
9 |
|
@@ -37,10 +37,12 @@ function wppa_add_admin() {
|
|
37 |
$com_pending = '';
|
38 |
$com_pending_count = $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_COMMENTS."` WHERE `status` = 'pending'" );
|
39 |
if ( $com_pending_count ) $com_pending = '<span class="update-plugins"><span class="plugin-count">'.$com_pending_count.'</span></span>';
|
|
|
40 |
// See if there are uploads pending moderation
|
41 |
$upl_pending = '';
|
42 |
$upl_pending_count = $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `status` = 'pending'" );
|
43 |
if ( $upl_pending_count ) $upl_pending = '<span class="update-plugins"><span class="plugin-count">'.$upl_pending_count.'</span></span>';
|
|
|
44 |
// Compute total pending moderation
|
45 |
$tot_pending = '';
|
46 |
$tot_pending_count = '0';
|
@@ -118,7 +120,7 @@ function wppa_edit_photo() {
|
|
118 |
// Import admin page
|
119 |
function wppa_page_import() {
|
120 |
if ( wppa_is_user_blacklisted() ) wp_die(__( 'Importing is temporary diabled for you' , 'wp-photo-album-plus') );
|
121 |
-
require_once 'wppa-
|
122 |
echo '<script type="text/javascript">/* <![CDATA[ */wppa_import = "'.__('Import', 'wp-photo-album-plus').'"; wppa_update = "'.__('Update', 'wp-photo-album-plus').'";/* ]]> */</script>';
|
123 |
_wppa_page_import();
|
124 |
}
|
@@ -199,6 +201,9 @@ add_action('admin_notices', 'wppa_verify_multisite_config');
|
|
199 |
/* Check for pending maintenance procs */
|
200 |
add_action('admin_notices', 'wppa_maintenance_messages');
|
201 |
|
|
|
|
|
|
|
202 |
// Check if tags system needs conversion
|
203 |
add_action( 'admin_init', 'wppa_check_tag_system' );
|
204 |
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* Contains the admin menu and startups the admin pages
|
6 |
+
* Version 6.5.02
|
7 |
*
|
8 |
*/
|
9 |
|
37 |
$com_pending = '';
|
38 |
$com_pending_count = $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_COMMENTS."` WHERE `status` = 'pending'" );
|
39 |
if ( $com_pending_count ) $com_pending = '<span class="update-plugins"><span class="plugin-count">'.$com_pending_count.'</span></span>';
|
40 |
+
|
41 |
// See if there are uploads pending moderation
|
42 |
$upl_pending = '';
|
43 |
$upl_pending_count = $wpdb->get_var( "SELECT COUNT(*) FROM `".WPPA_PHOTOS."` WHERE `status` = 'pending'" );
|
44 |
if ( $upl_pending_count ) $upl_pending = '<span class="update-plugins"><span class="plugin-count">'.$upl_pending_count.'</span></span>';
|
45 |
+
|
46 |
// Compute total pending moderation
|
47 |
$tot_pending = '';
|
48 |
$tot_pending_count = '0';
|
120 |
// Import admin page
|
121 |
function wppa_page_import() {
|
122 |
if ( wppa_is_user_blacklisted() ) wp_die(__( 'Importing is temporary diabled for you' , 'wp-photo-album-plus') );
|
123 |
+
require_once 'wppa-import.php';
|
124 |
echo '<script type="text/javascript">/* <![CDATA[ */wppa_import = "'.__('Import', 'wp-photo-album-plus').'"; wppa_update = "'.__('Update', 'wp-photo-album-plus').'";/* ]]> */</script>';
|
125 |
_wppa_page_import();
|
126 |
}
|
201 |
/* Check for pending maintenance procs */
|
202 |
add_action('admin_notices', 'wppa_maintenance_messages');
|
203 |
|
204 |
+
/* Check for old style scripting */
|
205 |
+
add_action('admin_notices', 'wppa_scripts_are_obssolete');
|
206 |
+
|
207 |
// Check if tags system needs conversion
|
208 |
add_action( 'admin_init', 'wppa_check_tag_system' );
|
209 |
|
wppa-ajax.php
CHANGED
@@ -272,7 +272,7 @@ global $wppa_log_file;
|
|
272 |
break;
|
273 |
|
274 |
case 'import':
|
275 |
-
require_once 'wppa-
|
276 |
_wppa_page_import();
|
277 |
wppa_exit();
|
278 |
break;
|
272 |
break;
|
273 |
|
274 |
case 'import':
|
275 |
+
require_once 'wppa-import.php';
|
276 |
_wppa_page_import();
|
277 |
wppa_exit();
|
278 |
break;
|
wppa-album-covers.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* Functions for album covers
|
6 |
-
* Version 6.5.
|
7 |
*
|
8 |
*/
|
9 |
|
@@ -1044,7 +1044,7 @@ global $wpdb;
|
|
1044 |
wppa_out(
|
1045 |
'<a' .
|
1046 |
' href="' . $link . '"' .
|
1047 |
-
' style="border:0;"' .
|
1048 |
( $is_video ? ' data-videohtml="' . esc_attr( wppa_get_video_body( $thumb['id'] ) ) . '"' .
|
1049 |
' data-videonatwidth="' . wppa_get_videox( $thumb['id'] ) . '"' .
|
1050 |
' data-videonatheight="' . wppa_get_videoy( $thumb['id'] ) . '"' : '' ) .
|
@@ -1084,7 +1084,7 @@ global $wpdb;
|
|
1084 |
wppa_out(
|
1085 |
'<a ' .
|
1086 |
$href .
|
1087 |
-
' style="border:0;"' .
|
1088 |
' target="' . $photolink['target'] . '"' .
|
1089 |
' title="' . $photolink['title'] . '"' .
|
1090 |
' onclick="' . $photolink['onclick'] . '"' .
|
@@ -1168,8 +1168,8 @@ static $cached_cover_photo_ids;
|
|
1168 |
// no album, no coverphoto
|
1169 |
if ( ! $alb ) return false;
|
1170 |
|
1171 |
-
// Did we do this before?
|
1172 |
-
if ( isset( $cached_cover_photo_ids[$alb] ) ) {
|
1173 |
return $cached_cover_photo_ids[$alb];
|
1174 |
}
|
1175 |
|
@@ -1369,8 +1369,25 @@ function wppa_album_cover_view_link(
|
|
1369 |
$album = wppa_cache_album( $albumid );
|
1370 |
|
1371 |
if ( wppa_switch( 'show_viewlink' ) ) {
|
1372 |
-
|
1373 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1374 |
if ( $has_content ) {
|
1375 |
|
1376 |
// Fake photocount to prevent link to empty page
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* Functions for album covers
|
6 |
+
* Version 6.5.02
|
7 |
*
|
8 |
*/
|
9 |
|
1044 |
wppa_out(
|
1045 |
'<a' .
|
1046 |
' href="' . $link . '"' .
|
1047 |
+
' style="border:0;color:transparent;"' .
|
1048 |
( $is_video ? ' data-videohtml="' . esc_attr( wppa_get_video_body( $thumb['id'] ) ) . '"' .
|
1049 |
' data-videonatwidth="' . wppa_get_videox( $thumb['id'] ) . '"' .
|
1050 |
' data-videonatheight="' . wppa_get_videoy( $thumb['id'] ) . '"' : '' ) .
|
1084 |
wppa_out(
|
1085 |
'<a ' .
|
1086 |
$href .
|
1087 |
+
' style="border:0;color:transparent;"' .
|
1088 |
' target="' . $photolink['target'] . '"' .
|
1089 |
' title="' . $photolink['title'] . '"' .
|
1090 |
' onclick="' . $photolink['onclick'] . '"' .
|
1168 |
// no album, no coverphoto
|
1169 |
if ( ! $alb ) return false;
|
1170 |
|
1171 |
+
// Did we do this before? ( for non-imgfact only )
|
1172 |
+
if ( $count == '1' && isset( $cached_cover_photo_ids[$alb] ) ) {
|
1173 |
return $cached_cover_photo_ids[$alb];
|
1174 |
}
|
1175 |
|
1369 |
$album = wppa_cache_album( $albumid );
|
1370 |
|
1371 |
if ( wppa_switch( 'show_viewlink' ) ) {
|
1372 |
+
|
1373 |
+
// Find the album specific cover type
|
1374 |
+
$cover_type = wppa_get_album_item( $albumid, 'cover_type' );
|
1375 |
+
|
1376 |
+
// No type specified (0), use default
|
1377 |
+
if ( ! $cover_type ) {
|
1378 |
+
$cover_type = wppa_opt( 'cover_type' );
|
1379 |
+
}
|
1380 |
+
|
1381 |
+
// For imgfakt, class .wppa-viewlink-sym
|
1382 |
+
if ( $cover_type == 'imagefactory' || $cover_type == 'imagefactory-mcr' ) {
|
1383 |
+
wppa_out( '<div class="wppa-box-text wppa-black wppa-info wppa-viewlink-sym wppa-album-cover-link">' );
|
1384 |
+
}
|
1385 |
+
|
1386 |
+
// Normal: class .wppa-viewlink
|
1387 |
+
else {
|
1388 |
+
wppa_out( '<div class="wppa-box-text wppa-black wppa-info wppa-viewlink wppa-album-cover-link">' );
|
1389 |
+
}
|
1390 |
+
|
1391 |
if ( $has_content ) {
|
1392 |
|
1393 |
// Fake photocount to prevent link to empty page
|
wppa-boxes-html.php
CHANGED
@@ -1781,6 +1781,7 @@ function wppa_get_user_create_html( $alb, $width, $where = '', $mcr = false ) {
|
|
1781 |
wppa_nonce_field( 'wppa-album-check' , 'wppa-nonce', false, false, $alb ) .
|
1782 |
'<input type="hidden" name="wppa-album-parent" value="'.$parent.'" />' .
|
1783 |
'<input type="hidden" name="wppa-fe-create" value="yes" />' .
|
|
|
1784 |
// Name
|
1785 |
'<div'.
|
1786 |
' class="wppa-box-text wppa-td"' .
|
@@ -1803,6 +1804,7 @@ function wppa_get_user_create_html( $alb, $width, $where = '', $mcr = false ) {
|
|
1803 |
' style="padding:0; width:100%; '.__wcs( 'wppa-box-text' ).'"' .
|
1804 |
' name="wppa-album-name"' .
|
1805 |
' />' .
|
|
|
1806 |
// Description
|
1807 |
'<div' .
|
1808 |
' class="wppa-box-text wppa-td"' .
|
@@ -1821,18 +1823,24 @@ function wppa_get_user_create_html( $alb, $width, $where = '', $mcr = false ) {
|
|
1821 |
' class="wppa-user-textarea wppa-box-text"' .
|
1822 |
' style="padding:0;height:120px; width:100%; '.__wcs( 'wppa-box-text' ).'"' .
|
1823 |
' name="wppa-album-desc" >' .
|
1824 |
-
'</textarea>'
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
'
|
1829 |
-
|
1830 |
-
|
1831 |
-
'
|
1832 |
-
'
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1836 |
'<input' .
|
1837 |
' type="submit"' .
|
1838 |
' class="wppa-user-submit"' .
|
@@ -2241,7 +2249,7 @@ static $seqno;
|
|
2241 |
__( 'Photo description', 'wp-photo-album-plus' ) .
|
2242 |
'</h6>' .
|
2243 |
'<textarea' .
|
2244 |
-
' class="wppa-user-textarea wppa-box-text
|
2245 |
' style="border:1 px solid '.wppa_opt( 'bcolor_upload' ).';clear:left; padding:0; height:120px; width:100%; '.__wcs( 'wppa-box-text' ).'"' .
|
2246 |
' name="wppa-user-desc"' .
|
2247 |
' >' .
|
@@ -2345,6 +2353,65 @@ static $seqno;
|
|
2345 |
// Close tag enter area
|
2346 |
$result .= '</div>';
|
2347 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2348 |
|
2349 |
/* start submit section */
|
2350 |
|
@@ -2359,6 +2426,7 @@ static $seqno;
|
|
2359 |
|
2360 |
// The submit button
|
2361 |
$result .=
|
|
|
2362 |
'<input' .
|
2363 |
' type="submit"' .
|
2364 |
' id="wppa-user-submit-' . $alb . '-' . $mocc . '"' .
|
@@ -2367,7 +2435,7 @@ static $seqno;
|
|
2367 |
' class="wppa-user-submit"' .
|
2368 |
' name="wppa-user-submit-'.$alb.'-'.$mocc.'" value="'.__( 'Upload photo', 'wp-photo-album-plus' ).'"' .
|
2369 |
' />' .
|
2370 |
-
'<div style="clear:both"></div>';
|
2371 |
|
2372 |
// if ajax: progression bar
|
2373 |
if ( $ajax_upload ) {
|
1781 |
wppa_nonce_field( 'wppa-album-check' , 'wppa-nonce', false, false, $alb ) .
|
1782 |
'<input type="hidden" name="wppa-album-parent" value="'.$parent.'" />' .
|
1783 |
'<input type="hidden" name="wppa-fe-create" value="yes" />' .
|
1784 |
+
|
1785 |
// Name
|
1786 |
'<div'.
|
1787 |
' class="wppa-box-text wppa-td"' .
|
1804 |
' style="padding:0; width:100%; '.__wcs( 'wppa-box-text' ).'"' .
|
1805 |
' name="wppa-album-name"' .
|
1806 |
' />' .
|
1807 |
+
|
1808 |
// Description
|
1809 |
'<div' .
|
1810 |
' class="wppa-box-text wppa-td"' .
|
1823 |
' class="wppa-user-textarea wppa-box-text"' .
|
1824 |
' style="padding:0;height:120px; width:100%; '.__wcs( 'wppa-box-text' ).'"' .
|
1825 |
' name="wppa-album-desc" >' .
|
1826 |
+
'</textarea>';
|
1827 |
+
|
1828 |
+
if ( wppa_switch( 'user_create_captcha' ) ) {
|
1829 |
+
$result .=
|
1830 |
+
'<div style="float:left; margin: 6px 0;" >' .
|
1831 |
+
'<div style="float:left;">' .
|
1832 |
+
wppa_make_captcha( wppa_get_randseed( 'session' ) ) .
|
1833 |
+
'</div>' .
|
1834 |
+
'<input' .
|
1835 |
+
' type="text"' .
|
1836 |
+
' id="wppa-captcha-'.$mocc.'"' .
|
1837 |
+
' name="wppa-captcha"' .
|
1838 |
+
' style="margin-left: 6px; width:50px; '.__wcs( 'wppa-box-text' ).__wcs( 'wppa-td' ).'"' .
|
1839 |
+
' />' .
|
1840 |
+
'</div>';
|
1841 |
+
}
|
1842 |
+
|
1843 |
+
$result .=
|
1844 |
'<input' .
|
1845 |
' type="submit"' .
|
1846 |
' class="wppa-user-submit"' .
|
2249 |
__( 'Photo description', 'wp-photo-album-plus' ) .
|
2250 |
'</h6>' .
|
2251 |
'<textarea' .
|
2252 |
+
' class="wppa-user-textarea wppa-box-text"' .
|
2253 |
' style="border:1 px solid '.wppa_opt( 'bcolor_upload' ).';clear:left; padding:0; height:120px; width:100%; '.__wcs( 'wppa-box-text' ).'"' .
|
2254 |
' name="wppa-user-desc"' .
|
2255 |
' >' .
|
2353 |
// Close tag enter area
|
2354 |
$result .= '</div>';
|
2355 |
}
|
2356 |
+
|
2357 |
+
/* The Blogit section */
|
2358 |
+
|
2359 |
+
if ( current_user_can( 'edit_posts' ) && wppa_switch( 'blog_it' ) ) {
|
2360 |
+
$result .=
|
2361 |
+
'<div>' .
|
2362 |
+
'<h6>' .
|
2363 |
+
__( 'Blog it?', 'wp-photo-album-plus' ) .
|
2364 |
+
' <input' .
|
2365 |
+
' type="checkbox"' .
|
2366 |
+
' id="wppa-blogit-'.$alb.'-'.$mocc.'"' .
|
2367 |
+
' name="wppa-blogit"' .
|
2368 |
+
' onchange="if ( jQuery(this).attr(\'checked\') ) { ' .
|
2369 |
+
'jQuery(\'#blog-div-'.$alb.'-'.$mocc.'\').css(\'display\',\'block\'); ' .
|
2370 |
+
'} ' .
|
2371 |
+
'else { ' .
|
2372 |
+
'jQuery(\'#blog-div-'.$alb.'-'.$mocc.'\').css(\'display\',\'none\'); ' .
|
2373 |
+
'} "' .
|
2374 |
+
' />' .
|
2375 |
+
'</h6>' .
|
2376 |
+
'<div' .
|
2377 |
+
' id="blog-div-'.$alb.'-'.$mocc.'"' .
|
2378 |
+
' style="display:none;"' .
|
2379 |
+
' />' .
|
2380 |
+
'<h6>' .
|
2381 |
+
__( 'Post title:', 'wp-photo-album-plus' ) .
|
2382 |
+
'</h6>' .
|
2383 |
+
'<input' .
|
2384 |
+
' id="wppa-blogit-title-'.$alb.'-'.$mocc.'"' .
|
2385 |
+
' type="text"' .
|
2386 |
+
' class="wppa-box-text "' .
|
2387 |
+
' style="padding:0; width:100%; '.__wcs( 'wppa-box-text' ).'"' .
|
2388 |
+
' name="wppa-post-title"' .
|
2389 |
+
' />' .
|
2390 |
+
'<h6>' .
|
2391 |
+
__( 'Text BEFORE the image:', 'wp-photo-album-plus' ) .
|
2392 |
+
'</h6>' .
|
2393 |
+
'<textarea' .
|
2394 |
+
' id="wppa-blogit-pretext-'.$alb.'-'.$mocc.'"' .
|
2395 |
+
' name="wppa-blogit-pretext"' .
|
2396 |
+
' class=wppa-user-textarea wppa-box-text"' .
|
2397 |
+
' style="border:1 px solid '.wppa_opt( 'bcolor_upload' ).';clear:left; padding:0; height:120px; width:100%; '.__wcs( 'wppa-box-text' ).'"' .
|
2398 |
+
' >' .
|
2399 |
+
'</textarea>' .
|
2400 |
+
'<h6>' .
|
2401 |
+
__( 'Text AFTER the image:', 'wp-photo-album-plus' ) .
|
2402 |
+
'</h6>' .
|
2403 |
+
'<textarea' .
|
2404 |
+
' id="wppa-blogit-posttext-'.$alb.'-'.$mocc.'"' .
|
2405 |
+
' name="wppa-blogit-posttext"' .
|
2406 |
+
' class=wppa-user-textarea wppa-box-text"' .
|
2407 |
+
' style="border:1 px solid '.wppa_opt( 'bcolor_upload' ).';clear:left; padding:0; height:120px; width:100%; '.__wcs( 'wppa-box-text' ).'"' .
|
2408 |
+
'>' .
|
2409 |
+
'</textarea>' .
|
2410 |
+
'</div>' .
|
2411 |
+
'</div>';
|
2412 |
+
|
2413 |
+
}
|
2414 |
+
|
2415 |
|
2416 |
/* start submit section */
|
2417 |
|
2426 |
|
2427 |
// The submit button
|
2428 |
$result .=
|
2429 |
+
'<div style="height:6px;;clear:both;" ></div>' .
|
2430 |
'<input' .
|
2431 |
' type="submit"' .
|
2432 |
' id="wppa-user-submit-' . $alb . '-' . $mocc . '"' .
|
2435 |
' class="wppa-user-submit"' .
|
2436 |
' name="wppa-user-submit-'.$alb.'-'.$mocc.'" value="'.__( 'Upload photo', 'wp-photo-album-plus' ).'"' .
|
2437 |
' />' .
|
2438 |
+
'<div style="height:6px;clear:both;"></div>';
|
2439 |
|
2440 |
// if ajax: progression bar
|
2441 |
if ( $ajax_upload ) {
|
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.5.
|
6 |
*
|
7 |
*/
|
8 |
|
@@ -271,6 +271,7 @@ global $thumbs;
|
|
271 |
'is_admins_choice' => false,
|
272 |
'admins_choice_users' => '',
|
273 |
'for_sm' => false,
|
|
|
274 |
|
275 |
);
|
276 |
}
|
2 |
/* wppa-common-functions.php
|
3 |
*
|
4 |
* Functions used in admin and in themes
|
5 |
+
* Version 6.5.02
|
6 |
*
|
7 |
*/
|
8 |
|
271 |
'is_admins_choice' => false,
|
272 |
'admins_choice_users' => '',
|
273 |
'for_sm' => false,
|
274 |
+
'max_width' => false,
|
275 |
|
276 |
);
|
277 |
}
|
wppa-date-time.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* date and time related functions
|
6 |
-
* Version 6.
|
7 |
*
|
8 |
*/
|
9 |
|
10 |
function wppa_get_timestamp( $key = false ) {
|
11 |
-
|
12 |
$timnow = time();
|
13 |
$format = 'Y:z:n:j:W:w:G:i:s';
|
14 |
// 0 1 2 3 4 5 6 7 8
|
@@ -17,37 +17,37 @@ function wppa_get_timestamp( $key = false ) {
|
|
17 |
|
18 |
$data = explode( ':', $local_date_time );
|
19 |
$data[4] = ltrim( '0', $data[4] );
|
20 |
-
|
21 |
$today_start = $timnow - $data[8] - 60 * $data[7] - 3600 * $data[6];
|
22 |
if ( $key == 'todaystart' ) return $today_start;
|
23 |
-
|
24 |
$daysec = 24 * 3600;
|
25 |
-
|
26 |
if ( ! $data[5] ) $data[5] = 7; // Sunday
|
27 |
$thisweek_start = $today_start - $daysec * ( $data[5] - 1 ); // Week starts on monday
|
28 |
if ( $key == 'thisweekstart' ) return $thisweek_start;
|
29 |
if ( $key == 'lastweekend' ) return $thisweek_start;
|
30 |
-
|
31 |
$thisweek_end = $thisweek_start + 7 * $daysec;
|
32 |
if ( $key == 'thisweekend' ) return $thisweek_end;
|
33 |
-
|
34 |
$lastweek_start = $thisweek_start - 7 * $daysec;
|
35 |
if ( $key == 'lastweekstart' ) return $lastweek_start;
|
36 |
-
|
37 |
$thismonth_start = $today_start - ( $data[3] - 1 ) * $daysec;
|
38 |
if ( $key == 'thismonthstart' ) return $thismonth_start;
|
39 |
if ( $key == 'lastmonthend' ) return $thismonth_start;
|
40 |
-
|
41 |
$monthdays = array ( '0', '31', '28', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31' );
|
42 |
$monthdays[2] += wppa_local_date('L', $timnow ); // Leap year correction
|
43 |
|
44 |
$thismonth_end = $thismonth_start + $monthdays[$data[2]] * $daysec;
|
45 |
if ( $key == 'thismonthend' ) return $thismonth_end;
|
46 |
-
|
47 |
$lm = $data[2] > 1 ? $data[2] - 1 : 12;
|
48 |
$lastmonth_start = $thismonth_start - $monthdays[$lm] * $daysec;
|
49 |
if ( $key == 'lastmonthstart' ) return $lastmonth_start;
|
50 |
-
|
51 |
$thisyear_start = $thismonth_start;
|
52 |
$idx = $data[2];
|
53 |
while ( $idx > 1 ) {
|
@@ -56,22 +56,22 @@ function wppa_get_timestamp( $key = false ) {
|
|
56 |
}
|
57 |
if ( $key == 'thisyearstart' ) return $thisyear_start;
|
58 |
if ( $key == 'lastyearend' ) return $thisyear_start;
|
59 |
-
|
60 |
$thisyear_end = $thisyear_start;
|
61 |
foreach ( $monthdays as $month ) $thisyear_end += $month * $daysec;
|
62 |
if ( $key == 'thisyearend' ) return $thisyear_end;
|
63 |
-
|
64 |
$lastyear_start = $thisyear_start - 365 * $daysec;
|
65 |
if ( wppa_local_date('L', $thisyear_start - $daysec) ) $lastyear_start -= $daysec; // Last year was a leap year
|
66 |
if ( $key == 'lastyearstart' ) return $lastyear_start;
|
67 |
-
|
68 |
return $timnow;
|
69 |
}
|
70 |
|
71 |
function wppa_get_date_time_select_html( $type, $id, $selectable = true ) {
|
72 |
|
73 |
$type = strtoupper( substr( $type, 0, 1 ) ).strtolower( substr( $type, 1 ) );
|
74 |
-
|
75 |
if ( $type == 'Photo' ) {
|
76 |
$thumb = wppa_cache_thumb( $id );
|
77 |
}
|
@@ -81,7 +81,7 @@ function wppa_get_date_time_select_html( $type, $id, $selectable = true ) {
|
|
81 |
else {
|
82 |
wppa_error_message('Uniplemented type: '.$type.' in wppa_get_date_time_select_html()');
|
83 |
}
|
84 |
-
|
85 |
$opt_months = array( '1' => __('Jan', 'wp-photo-album-plus'), '2' => __('Feb', 'wp-photo-album-plus'), '3' => __('Mar', 'wp-photo-album-plus'), '4' => __('Apr', 'wp-photo-album-plus'), '5' => __('May', 'wp-photo-album-plus'), '6' => __('Jun', 'wp-photo-album-plus'), '7' => __('Jul', 'wp-photo-album-plus'), '8' =>__('Aug', 'wp-photo-album-plus'), '9' => __('Sep', 'wp-photo-album-plus'), '10' => __('Oct', 'wp-photo-album-plus'), '11' => __('Nov', 'wp-photo-album-plus'), '12' => __('Dec', 'wp-photo-album-plus') );
|
86 |
$val_months = array( '1' => '01', '2' => '02', '3' => '03', '4' => '04', '5' => '05', '6' => '06', '7' => '07', '8' => '08', '9' => '09', '10' => '10', '11' => '11', '12' =>'12' );
|
87 |
$opt_years = array( '2014', '2015', '2016', '2017', '2018', '2019', '2020' );
|
@@ -90,27 +90,27 @@ function wppa_get_date_time_select_html( $type, $id, $selectable = true ) {
|
|
90 |
$val_days = $opt_days;
|
91 |
$opt_hours = array( '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23' );
|
92 |
$val_hours = $opt_hours;
|
93 |
-
$opt_mins = array( '00', '01', '02', '03', '04', '05', '06', '07', '08', '09',
|
94 |
'10', '11', '12', '13', '14', '15', '16', '17', '18', '19',
|
95 |
'20', '21', '22', '23', '24', '25', '26', '27', '28', '29',
|
96 |
'30', '31', '32', '33', '34', '35', '36', '37', '38', '39',
|
97 |
'40', '41', '42', '43', '44', '45', '46', '47', '48', '49',
|
98 |
'50', '51', '52', '53', '54', '55', '56', '57', '58', '59' );
|
99 |
$val_mins = $opt_mins;
|
100 |
-
|
101 |
$curval = $type == 'Photo' ? $thumb['scheduledtm'] : $album['scheduledtm'];
|
102 |
|
103 |
if ( ! $curval ) $curval = wppa_get_default_scheduledtm();
|
104 |
-
|
105 |
$temp = explode( ',', $curval );
|
106 |
$cur_day = $temp[2];
|
107 |
$cur_month = $temp[1];
|
108 |
$cur_year = $temp[0];
|
109 |
$cur_hour = $temp[3];
|
110 |
$cur_min = $temp[4];
|
111 |
-
|
112 |
$result = '';
|
113 |
-
|
114 |
if ( $selectable ) {
|
115 |
|
116 |
$result .= '<select name="wppa-day" id="wppa-day-'.$id.'" class="wppa-datetime-'.$id.'" onchange="wppaAjaxUpdate'.$type.'('.$id.', \'day\', this);" >';
|
@@ -119,51 +119,51 @@ function wppa_get_date_time_select_html( $type, $id, $selectable = true ) {
|
|
119 |
$result .= '<option value="'.$val_days[$key].'" '.$sel.' >'.$opt_days[$key].'</option>';
|
120 |
}
|
121 |
$result .= '</select >';
|
122 |
-
|
123 |
$result .= '<select name="wppa-month" id="wppa-month-'.$id.'" class="wppa-datetime-'.$id.'" onchange="wppaAjaxUpdate'.$type.'('.$id.', \'month\', this);" >';
|
124 |
foreach ( array_keys( $opt_months ) as $key ) {
|
125 |
$sel = $val_months[$key] == $cur_month ? 'selected="selected"' : '';
|
126 |
$result .= '<option value="'.$val_months[$key].'" '.$sel.' >'.$opt_months[$key].'</option>';
|
127 |
}
|
128 |
$result .= '</select >';
|
129 |
-
|
130 |
$result .= '<select name="wppa-year" id="wppa-year-'.$id.'" class="wppa-datetime-'.$id.'" onchange="wppaAjaxUpdate'.$type.'('.$id.', \'year\', this);" >';
|
131 |
foreach ( array_keys( $opt_years ) as $key ) {
|
132 |
$sel = $val_years[$key] == $cur_year ? 'selected="selected"' : '';
|
133 |
$result .= '<option value="'.$val_years[$key].'" '.$sel.' >'.$opt_years[$key].'</option>';
|
134 |
}
|
135 |
$result .= '</select >@';
|
136 |
-
|
137 |
$result .= '<select name="wppa-hour" id="wppa-hour-'.$id.'" class="wppa-datetime-'.$id.'" onchange="wppaAjaxUpdate'.$type.'('.$id.', \'hour\', this);" >';
|
138 |
foreach ( array_keys( $opt_hours ) as $key ) {
|
139 |
$sel = $val_hours[$key] == $cur_hour ? 'selected="selected"' : '';
|
140 |
$result .= '<option value="'.$val_hours[$key].'" '.$sel.' >'.$opt_hours[$key].'</option>';
|
141 |
}
|
142 |
$result .= '</select >:';
|
143 |
-
|
144 |
$result .= '<select name="wppa-min" id="wppa-min-'.$id.'" class="wppa-datetime-'.$id.'" onchange="wppaAjaxUpdate'.$type.'('.$id.', \'min\', this);">';
|
145 |
foreach ( array_keys( $opt_mins ) as $key ) {
|
146 |
$sel = $val_mins[$key] == $cur_min ? 'selected="selected"' : '';
|
147 |
$result .= '<option value="'.$val_mins[$key].'" '.$sel.' >'.$opt_mins[$key].'</option>';
|
148 |
}
|
149 |
$result .= '</select >';
|
150 |
-
|
151 |
}
|
152 |
else {
|
153 |
$result .= '<span class="wppa-datetime-'.$id.'" >'.$cur_day.' '.$opt_months[strval(intval($cur_month))].' '.$cur_year.'@'.$cur_hour.':'.$cur_min.'</span>';
|
154 |
}
|
155 |
-
|
156 |
return $result;
|
157 |
}
|
158 |
|
159 |
// Exactly like php's date(), but corrected for wp's timezone
|
160 |
function wppa_local_date( $format, $timestamp = false ) {
|
161 |
-
|
162 |
// Fill in default format if not supplied
|
163 |
if ( ! $format ) {
|
164 |
$format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
|
165 |
}
|
166 |
-
|
167 |
// Fill in default timestamp if not suplied
|
168 |
if ( $timestamp ) {
|
169 |
$time = $timestamp;
|
@@ -177,8 +177,9 @@ function wppa_local_date( $format, $timestamp = false ) {
|
|
177 |
if ( empty( $tzstring ) ) {
|
178 |
|
179 |
// Create a UTC+- zone if no timezone string exists
|
|
|
180 |
if ( 0 == $current_offset ) {
|
181 |
-
$tzstring = 'UTC
|
182 |
}
|
183 |
elseif ($current_offset < 0 ) {
|
184 |
$tzstring = 'UTC' . $current_offset;
|
@@ -200,7 +201,7 @@ function wppa_local_date( $format, $timestamp = false ) {
|
|
200 |
function wppa_get_default_scheduledtm() {
|
201 |
|
202 |
$result = wppa_local_date( 'Y,m,d,H,i' );
|
203 |
-
|
204 |
return $result;
|
205 |
}
|
206 |
|
@@ -214,8 +215,8 @@ function wppa_format_scheduledtm( $sdtm ) {
|
|
214 |
$cur_year = $temp[0];
|
215 |
$cur_hour = $temp[3];
|
216 |
$cur_min = $temp[4];
|
217 |
-
|
218 |
$result = $cur_day.' '.$opt_months[strval(intval($cur_month))].' '.$cur_year.'@'.$cur_hour.':'.$cur_min;
|
219 |
-
|
220 |
return $result;
|
221 |
}
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* date and time related functions
|
6 |
+
* Version 6.5.02
|
7 |
*
|
8 |
*/
|
9 |
|
10 |
function wppa_get_timestamp( $key = false ) {
|
11 |
+
|
12 |
$timnow = time();
|
13 |
$format = 'Y:z:n:j:W:w:G:i:s';
|
14 |
// 0 1 2 3 4 5 6 7 8
|
17 |
|
18 |
$data = explode( ':', $local_date_time );
|
19 |
$data[4] = ltrim( '0', $data[4] );
|
20 |
+
|
21 |
$today_start = $timnow - $data[8] - 60 * $data[7] - 3600 * $data[6];
|
22 |
if ( $key == 'todaystart' ) return $today_start;
|
23 |
+
|
24 |
$daysec = 24 * 3600;
|
25 |
+
|
26 |
if ( ! $data[5] ) $data[5] = 7; // Sunday
|
27 |
$thisweek_start = $today_start - $daysec * ( $data[5] - 1 ); // Week starts on monday
|
28 |
if ( $key == 'thisweekstart' ) return $thisweek_start;
|
29 |
if ( $key == 'lastweekend' ) return $thisweek_start;
|
30 |
+
|
31 |
$thisweek_end = $thisweek_start + 7 * $daysec;
|
32 |
if ( $key == 'thisweekend' ) return $thisweek_end;
|
33 |
+
|
34 |
$lastweek_start = $thisweek_start - 7 * $daysec;
|
35 |
if ( $key == 'lastweekstart' ) return $lastweek_start;
|
36 |
+
|
37 |
$thismonth_start = $today_start - ( $data[3] - 1 ) * $daysec;
|
38 |
if ( $key == 'thismonthstart' ) return $thismonth_start;
|
39 |
if ( $key == 'lastmonthend' ) return $thismonth_start;
|
40 |
+
|
41 |
$monthdays = array ( '0', '31', '28', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31' );
|
42 |
$monthdays[2] += wppa_local_date('L', $timnow ); // Leap year correction
|
43 |
|
44 |
$thismonth_end = $thismonth_start + $monthdays[$data[2]] * $daysec;
|
45 |
if ( $key == 'thismonthend' ) return $thismonth_end;
|
46 |
+
|
47 |
$lm = $data[2] > 1 ? $data[2] - 1 : 12;
|
48 |
$lastmonth_start = $thismonth_start - $monthdays[$lm] * $daysec;
|
49 |
if ( $key == 'lastmonthstart' ) return $lastmonth_start;
|
50 |
+
|
51 |
$thisyear_start = $thismonth_start;
|
52 |
$idx = $data[2];
|
53 |
while ( $idx > 1 ) {
|
56 |
}
|
57 |
if ( $key == 'thisyearstart' ) return $thisyear_start;
|
58 |
if ( $key == 'lastyearend' ) return $thisyear_start;
|
59 |
+
|
60 |
$thisyear_end = $thisyear_start;
|
61 |
foreach ( $monthdays as $month ) $thisyear_end += $month * $daysec;
|
62 |
if ( $key == 'thisyearend' ) return $thisyear_end;
|
63 |
+
|
64 |
$lastyear_start = $thisyear_start - 365 * $daysec;
|
65 |
if ( wppa_local_date('L', $thisyear_start - $daysec) ) $lastyear_start -= $daysec; // Last year was a leap year
|
66 |
if ( $key == 'lastyearstart' ) return $lastyear_start;
|
67 |
+
|
68 |
return $timnow;
|
69 |
}
|
70 |
|
71 |
function wppa_get_date_time_select_html( $type, $id, $selectable = true ) {
|
72 |
|
73 |
$type = strtoupper( substr( $type, 0, 1 ) ).strtolower( substr( $type, 1 ) );
|
74 |
+
|
75 |
if ( $type == 'Photo' ) {
|
76 |
$thumb = wppa_cache_thumb( $id );
|
77 |
}
|
81 |
else {
|
82 |
wppa_error_message('Uniplemented type: '.$type.' in wppa_get_date_time_select_html()');
|
83 |
}
|
84 |
+
|
85 |
$opt_months = array( '1' => __('Jan', 'wp-photo-album-plus'), '2' => __('Feb', 'wp-photo-album-plus'), '3' => __('Mar', 'wp-photo-album-plus'), '4' => __('Apr', 'wp-photo-album-plus'), '5' => __('May', 'wp-photo-album-plus'), '6' => __('Jun', 'wp-photo-album-plus'), '7' => __('Jul', 'wp-photo-album-plus'), '8' =>__('Aug', 'wp-photo-album-plus'), '9' => __('Sep', 'wp-photo-album-plus'), '10' => __('Oct', 'wp-photo-album-plus'), '11' => __('Nov', 'wp-photo-album-plus'), '12' => __('Dec', 'wp-photo-album-plus') );
|
86 |
$val_months = array( '1' => '01', '2' => '02', '3' => '03', '4' => '04', '5' => '05', '6' => '06', '7' => '07', '8' => '08', '9' => '09', '10' => '10', '11' => '11', '12' =>'12' );
|
87 |
$opt_years = array( '2014', '2015', '2016', '2017', '2018', '2019', '2020' );
|
90 |
$val_days = $opt_days;
|
91 |
$opt_hours = array( '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23' );
|
92 |
$val_hours = $opt_hours;
|
93 |
+
$opt_mins = array( '00', '01', '02', '03', '04', '05', '06', '07', '08', '09',
|
94 |
'10', '11', '12', '13', '14', '15', '16', '17', '18', '19',
|
95 |
'20', '21', '22', '23', '24', '25', '26', '27', '28', '29',
|
96 |
'30', '31', '32', '33', '34', '35', '36', '37', '38', '39',
|
97 |
'40', '41', '42', '43', '44', '45', '46', '47', '48', '49',
|
98 |
'50', '51', '52', '53', '54', '55', '56', '57', '58', '59' );
|
99 |
$val_mins = $opt_mins;
|
100 |
+
|
101 |
$curval = $type == 'Photo' ? $thumb['scheduledtm'] : $album['scheduledtm'];
|
102 |
|
103 |
if ( ! $curval ) $curval = wppa_get_default_scheduledtm();
|
104 |
+
|
105 |
$temp = explode( ',', $curval );
|
106 |
$cur_day = $temp[2];
|
107 |
$cur_month = $temp[1];
|
108 |
$cur_year = $temp[0];
|
109 |
$cur_hour = $temp[3];
|
110 |
$cur_min = $temp[4];
|
111 |
+
|
112 |
$result = '';
|
113 |
+
|
114 |
if ( $selectable ) {
|
115 |
|
116 |
$result .= '<select name="wppa-day" id="wppa-day-'.$id.'" class="wppa-datetime-'.$id.'" onchange="wppaAjaxUpdate'.$type.'('.$id.', \'day\', this);" >';
|
119 |
$result .= '<option value="'.$val_days[$key].'" '.$sel.' >'.$opt_days[$key].'</option>';
|
120 |
}
|
121 |
$result .= '</select >';
|
122 |
+
|
123 |
$result .= '<select name="wppa-month" id="wppa-month-'.$id.'" class="wppa-datetime-'.$id.'" onchange="wppaAjaxUpdate'.$type.'('.$id.', \'month\', this);" >';
|
124 |
foreach ( array_keys( $opt_months ) as $key ) {
|
125 |
$sel = $val_months[$key] == $cur_month ? 'selected="selected"' : '';
|
126 |
$result .= '<option value="'.$val_months[$key].'" '.$sel.' >'.$opt_months[$key].'</option>';
|
127 |
}
|
128 |
$result .= '</select >';
|
129 |
+
|
130 |
$result .= '<select name="wppa-year" id="wppa-year-'.$id.'" class="wppa-datetime-'.$id.'" onchange="wppaAjaxUpdate'.$type.'('.$id.', \'year\', this);" >';
|
131 |
foreach ( array_keys( $opt_years ) as $key ) {
|
132 |
$sel = $val_years[$key] == $cur_year ? 'selected="selected"' : '';
|
133 |
$result .= '<option value="'.$val_years[$key].'" '.$sel.' >'.$opt_years[$key].'</option>';
|
134 |
}
|
135 |
$result .= '</select >@';
|
136 |
+
|
137 |
$result .= '<select name="wppa-hour" id="wppa-hour-'.$id.'" class="wppa-datetime-'.$id.'" onchange="wppaAjaxUpdate'.$type.'('.$id.', \'hour\', this);" >';
|
138 |
foreach ( array_keys( $opt_hours ) as $key ) {
|
139 |
$sel = $val_hours[$key] == $cur_hour ? 'selected="selected"' : '';
|
140 |
$result .= '<option value="'.$val_hours[$key].'" '.$sel.' >'.$opt_hours[$key].'</option>';
|
141 |
}
|
142 |
$result .= '</select >:';
|
143 |
+
|
144 |
$result .= '<select name="wppa-min" id="wppa-min-'.$id.'" class="wppa-datetime-'.$id.'" onchange="wppaAjaxUpdate'.$type.'('.$id.', \'min\', this);">';
|
145 |
foreach ( array_keys( $opt_mins ) as $key ) {
|
146 |
$sel = $val_mins[$key] == $cur_min ? 'selected="selected"' : '';
|
147 |
$result .= '<option value="'.$val_mins[$key].'" '.$sel.' >'.$opt_mins[$key].'</option>';
|
148 |
}
|
149 |
$result .= '</select >';
|
150 |
+
|
151 |
}
|
152 |
else {
|
153 |
$result .= '<span class="wppa-datetime-'.$id.'" >'.$cur_day.' '.$opt_months[strval(intval($cur_month))].' '.$cur_year.'@'.$cur_hour.':'.$cur_min.'</span>';
|
154 |
}
|
155 |
+
|
156 |
return $result;
|
157 |
}
|
158 |
|
159 |
// Exactly like php's date(), but corrected for wp's timezone
|
160 |
function wppa_local_date( $format, $timestamp = false ) {
|
161 |
+
|
162 |
// Fill in default format if not supplied
|
163 |
if ( ! $format ) {
|
164 |
$format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
|
165 |
}
|
166 |
+
|
167 |
// Fill in default timestamp if not suplied
|
168 |
if ( $timestamp ) {
|
169 |
$time = $timestamp;
|
177 |
if ( empty( $tzstring ) ) {
|
178 |
|
179 |
// Create a UTC+- zone if no timezone string exists
|
180 |
+
$current_offset = get_option( 'gmt_offset', 0 );
|
181 |
if ( 0 == $current_offset ) {
|
182 |
+
$tzstring = 'UTC';
|
183 |
}
|
184 |
elseif ($current_offset < 0 ) {
|
185 |
$tzstring = 'UTC' . $current_offset;
|
201 |
function wppa_get_default_scheduledtm() {
|
202 |
|
203 |
$result = wppa_local_date( 'Y,m,d,H,i' );
|
204 |
+
|
205 |
return $result;
|
206 |
}
|
207 |
|
215 |
$cur_year = $temp[0];
|
216 |
$cur_hour = $temp[3];
|
217 |
$cur_min = $temp[4];
|
218 |
+
|
219 |
$result = $cur_day.' '.$opt_months[strval(intval($cur_month))].' '.$cur_year.'@'.$cur_hour.':'.$cur_min;
|
220 |
+
|
221 |
return $result;
|
222 |
}
|
wppa-filter.php
CHANGED
@@ -301,6 +301,7 @@ global $wppa_revno;
|
|
301 |
$wppa['is_admins_choice'] = false;
|
302 |
$wppa['admins_choice_users'] = '';
|
303 |
$wppa['albums_only'] = false;
|
|
|
304 |
|
305 |
// Find type
|
306 |
switch ( $atts['type'] ) {
|
@@ -444,9 +445,10 @@ global $wppa_revno;
|
|
444 |
// Count (internally to wppa_albums)
|
445 |
|
446 |
// Find size
|
447 |
-
if ( $atts['size'] == 'auto' ) {
|
448 |
$wppa['auto_colwidth'] = true;
|
449 |
$wppa['fullsize'] = '';
|
|
|
450 |
}
|
451 |
else {
|
452 |
$wppa['auto_colwidth'] = false;
|
301 |
$wppa['is_admins_choice'] = false;
|
302 |
$wppa['admins_choice_users'] = '';
|
303 |
$wppa['albums_only'] = false;
|
304 |
+
$wppa['max_width'] = false;
|
305 |
|
306 |
// Find type
|
307 |
switch ( $atts['type'] ) {
|
445 |
// Count (internally to wppa_albums)
|
446 |
|
447 |
// Find size
|
448 |
+
if ( substr( $atts['size'], 0, 4 ) == 'auto' ) {
|
449 |
$wppa['auto_colwidth'] = true;
|
450 |
$wppa['fullsize'] = '';
|
451 |
+
$wppa['max_width'] = substr( $atts['size'], 5 );
|
452 |
}
|
453 |
else {
|
454 |
$wppa['auto_colwidth'] = false;
|
wppa-functions.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* Various functions
|
6 |
-
* Version 6.5.
|
7 |
*
|
8 |
*/
|
9 |
|
@@ -2948,6 +2948,9 @@ global $blog_id;
|
|
2948 |
// if ( wppa( 'shortcode_content' ) ) {
|
2949 |
// wppa( 'out' ) .= '<!-- ' . wppa( 'shortcode_content' ) . ' -->';
|
2950 |
// }
|
|
|
|
|
|
|
2951 |
wppa_out( '<div' .
|
2952 |
' id="wppa-container-'.wppa( 'mocc' ).'"' .
|
2953 |
' style="'.wppa_get_container_style().'"' .
|
@@ -2960,7 +2963,7 @@ global $blog_id;
|
|
2960 |
'wppa-api-' . wppa( 'api_version' ) .
|
2961 |
'"' .
|
2962 |
' >'
|
2963 |
-
|
2964 |
}
|
2965 |
|
2966 |
// Spinner for Ajax
|
@@ -3183,6 +3186,9 @@ global $blog_id;
|
|
3183 |
if ( ! wppa( 'ajax' ) ) {
|
3184 |
wppa_out( '<div id="wppa-container-' . wppa( 'mocc' ) . '-end" ></div>' );
|
3185 |
wppa_out( '</div>' );
|
|
|
|
|
|
|
3186 |
}
|
3187 |
|
3188 |
if ( wppa( 'debug' ) ) {
|
@@ -3199,6 +3205,43 @@ global $blog_id;
|
|
3199 |
}
|
3200 |
}
|
3201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3202 |
function wppa_album_list( $action ) {
|
3203 |
global $cover_count;
|
3204 |
global $cover_count_key;
|
@@ -3605,6 +3648,9 @@ function wppa_mphoto() {
|
|
3605 |
$contwidth = $width;
|
3606 |
}
|
3607 |
|
|
|
|
|
|
|
3608 |
// Open the pseudo container
|
3609 |
$captwidth = $contwidth + '10';
|
3610 |
wppa_out( '<div id="wppa-container-'.wppa( 'mocc' ).'" class="wppa-mphoto-'.wppa( 'mocc' ).' wp-caption' );
|
@@ -3742,6 +3788,9 @@ function wppa_mphoto() {
|
|
3742 |
}
|
3743 |
|
3744 |
wppa_out( '</div>' );
|
|
|
|
|
|
|
3745 |
}
|
3746 |
|
3747 |
// Like mphoto but without the caption and with the fullsize background/border
|
@@ -3774,6 +3823,9 @@ function wppa_sphoto() {
|
|
3774 |
$contwidth = $width;
|
3775 |
}
|
3776 |
|
|
|
|
|
|
|
3777 |
// Open the pseudo container
|
3778 |
wppa_out( '<div' .
|
3779 |
' id="wppa-container-' . wppa( 'mocc' ) . '"' .
|
@@ -3917,6 +3969,9 @@ function wppa_sphoto() {
|
|
3917 |
|
3918 |
// The pseudo container
|
3919 |
wppa_out( '</div>' );
|
|
|
|
|
|
|
3920 |
}
|
3921 |
|
3922 |
// returns aspect ratio ( w/h ), or 1 on error
|
@@ -4184,12 +4239,18 @@ static $done;
|
|
4184 |
}
|
4185 |
$ok = wp_verify_nonce( $nonce, 'wppa-album-check' );
|
4186 |
if ( ! $ok ) die( '<b>' . __( 'ERROR: Illegal attempt to create an album.' , 'wp-photo-album-plus') . '</b>' );
|
|
|
4187 |
// Check captcha
|
4188 |
-
|
4189 |
-
|
4190 |
-
|
4191 |
-
|
|
|
|
|
|
|
|
|
4192 |
}
|
|
|
4193 |
$parent = strval( intval( wppa_get_post( 'wppa-album-parent' ) ) );
|
4194 |
if ( ! wppa_user_is( 'administrator' ) && wppa_switch( 'default_parent_always' ) ) {
|
4195 |
$parent = wppa_opt( 'default_parent' );
|
@@ -4222,29 +4283,36 @@ static $done;
|
|
4222 |
}
|
4223 |
|
4224 |
$alb = wppa_get_post( 'wppa-upload-album' );
|
|
|
4225 |
|
4226 |
if ( is_array( $_FILES ) ) {
|
4227 |
-
$
|
4228 |
$filecount = '1';
|
4229 |
$done = '0';
|
4230 |
$fail = '0';
|
4231 |
foreach ( $_FILES as $file ) {
|
4232 |
if ( ! is_array( $file['error'] ) ) {
|
4233 |
-
$
|
4234 |
-
if ( $
|
|
|
|
|
|
|
4235 |
else $fail++;
|
4236 |
}
|
4237 |
else {
|
4238 |
$filecount = count( $file['error'] );
|
4239 |
for ( $i = '0'; $i < $filecount; $i++ ) {
|
4240 |
-
if ( $
|
4241 |
$f['error'] = $file['error'][$i];
|
4242 |
$f['tmp_name'] = $file['tmp_name'][$i];
|
4243 |
$f['name'] = $file['name'][$i];
|
4244 |
$f['type'] = $file['type'][$i];
|
4245 |
$f['size'] = $file['size'][$i];
|
4246 |
-
$
|
4247 |
-
if ( $
|
|
|
|
|
|
|
4248 |
else $fail++;
|
4249 |
}
|
4250 |
}
|
@@ -4256,7 +4324,30 @@ static $done;
|
|
4256 |
|
4257 |
if ( $done ) {
|
4258 |
|
4259 |
-
//SUCCESSFUL UPLOAD,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4260 |
$points = wppa_opt( 'cp_points_upload' ) * $done;
|
4261 |
$bret = wppa_add_credit_points( $points, __( 'Photo upload' ,'wp-photo-album-plus' ) );
|
4262 |
$alert .= sprintf( _n( '%d photo successfully uploaded', '%d photos successfully uploaded', $done, 'wp-photo-album-plus' ), $done );
|
@@ -4438,7 +4529,7 @@ global $wppa_supported_audio_extensions;
|
|
4438 |
wppa_fe_add_custom( $id );
|
4439 |
|
4440 |
// Done!
|
4441 |
-
return
|
4442 |
|
4443 |
}
|
4444 |
|
@@ -4502,9 +4593,16 @@ global $wppa_supported_audio_extensions;
|
|
4502 |
$name = $file['name'];
|
4503 |
}
|
4504 |
|
4505 |
-
// Sanitize input
|
4506 |
$name = wppa_sanitize_photo_name( $name );
|
4507 |
$desc = balanceTags( wppa_get_post( 'user-desc' ), true );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4508 |
$linktarget = '_self';
|
4509 |
$status = ( wppa_switch( 'upload_moderate' ) && ! current_user_can( 'wppa_admin' ) ) ? 'pending' : 'publish';
|
4510 |
$filename = wppa_sanitize_file_name( $file['name'] );
|
@@ -4564,7 +4662,7 @@ global $wppa_supported_audio_extensions;
|
|
4564 |
}
|
4565 |
wppa_send_mail( $to, $subj, $cont, $id );
|
4566 |
}
|
4567 |
-
return
|
4568 |
}
|
4569 |
|
4570 |
return false;
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* Various functions
|
6 |
+
* Version 6.5.02
|
7 |
*
|
8 |
*/
|
9 |
|
2948 |
// if ( wppa( 'shortcode_content' ) ) {
|
2949 |
// wppa( 'out' ) .= '<!-- ' . wppa( 'shortcode_content' ) . ' -->';
|
2950 |
// }
|
2951 |
+
// If static maximum in responsive theme, add wrapper
|
2952 |
+
wppa_container_wrapper( 'open' );
|
2953 |
+
|
2954 |
wppa_out( '<div' .
|
2955 |
' id="wppa-container-'.wppa( 'mocc' ).'"' .
|
2956 |
' style="'.wppa_get_container_style().'"' .
|
2963 |
'wppa-api-' . wppa( 'api_version' ) .
|
2964 |
'"' .
|
2965 |
' >'
|
2966 |
+
);
|
2967 |
}
|
2968 |
|
2969 |
// Spinner for Ajax
|
3186 |
if ( ! wppa( 'ajax' ) ) {
|
3187 |
wppa_out( '<div id="wppa-container-' . wppa( 'mocc' ) . '-end" ></div>' );
|
3188 |
wppa_out( '</div>' );
|
3189 |
+
|
3190 |
+
// Static max in responsive? close wrapper
|
3191 |
+
wppa_container_wrapper( 'close' );
|
3192 |
}
|
3193 |
|
3194 |
if ( wppa( 'debug' ) ) {
|
3205 |
}
|
3206 |
}
|
3207 |
|
3208 |
+
function wppa_container_wrapper( $key ) {
|
3209 |
+
switch( $key ) {
|
3210 |
+
case 'open':
|
3211 |
+
if ( wppa( 'max_width' ) ) {
|
3212 |
+
wppa_out( '<div' .
|
3213 |
+
' id="wppa-container-wrapper-' . wppa( 'mocc' ) . '"' .
|
3214 |
+
' style="' .
|
3215 |
+
'max-width:' . wppa( 'max_width' ) . 'px;'
|
3216 |
+
);
|
3217 |
+
switch( wppa( 'align' ) ) {
|
3218 |
+
case '':
|
3219 |
+
case 'center':
|
3220 |
+
wppa_out( 'clear:both;margin:auto;' );
|
3221 |
+
break;
|
3222 |
+
case 'left':
|
3223 |
+
wppa_out( 'clear:left;float:left;' );
|
3224 |
+
break;
|
3225 |
+
case 'right':
|
3226 |
+
wppa_out( 'clear:right;float:right;' );
|
3227 |
+
break;
|
3228 |
+
}
|
3229 |
+
|
3230 |
+
wppa_out( '"' .
|
3231 |
+
' >'
|
3232 |
+
);
|
3233 |
+
}
|
3234 |
+
break;
|
3235 |
+
case 'close':
|
3236 |
+
if ( wppa( 'max_width' ) ) {
|
3237 |
+
wppa_out( '</div>' );
|
3238 |
+
}
|
3239 |
+
break;
|
3240 |
+
default:
|
3241 |
+
wppa_dbg_msg( 'Missing or wrong arg in wppa_container_wrapper()', 'red', 'force' );
|
3242 |
+
}
|
3243 |
+
}
|
3244 |
+
|
3245 |
function wppa_album_list( $action ) {
|
3246 |
global $cover_count;
|
3247 |
global $cover_count_key;
|
3648 |
$contwidth = $width;
|
3649 |
}
|
3650 |
|
3651 |
+
// Auto with fixed max?
|
3652 |
+
wppa_container_wrapper( 'open' );
|
3653 |
+
|
3654 |
// Open the pseudo container
|
3655 |
$captwidth = $contwidth + '10';
|
3656 |
wppa_out( '<div id="wppa-container-'.wppa( 'mocc' ).'" class="wppa-mphoto-'.wppa( 'mocc' ).' wp-caption' );
|
3788 |
}
|
3789 |
|
3790 |
wppa_out( '</div>' );
|
3791 |
+
|
3792 |
+
// Maximized auto
|
3793 |
+
wppa_container_wrapper( 'close' );
|
3794 |
}
|
3795 |
|
3796 |
// Like mphoto but without the caption and with the fullsize background/border
|
3823 |
$contwidth = $width;
|
3824 |
}
|
3825 |
|
3826 |
+
// wrapper for maximized auto
|
3827 |
+
wppa_container_wrapper( 'open' );
|
3828 |
+
|
3829 |
// Open the pseudo container
|
3830 |
wppa_out( '<div' .
|
3831 |
' id="wppa-container-' . wppa( 'mocc' ) . '"' .
|
3969 |
|
3970 |
// The pseudo container
|
3971 |
wppa_out( '</div>' );
|
3972 |
+
|
3973 |
+
// Wrapper for maximized auto
|
3974 |
+
wppa_container_wrapper( 'close' );
|
3975 |
}
|
3976 |
|
3977 |
// returns aspect ratio ( w/h ), or 1 on error
|
4239 |
}
|
4240 |
$ok = wp_verify_nonce( $nonce, 'wppa-album-check' );
|
4241 |
if ( ! $ok ) die( '<b>' . __( 'ERROR: Illegal attempt to create an album.' , 'wp-photo-album-plus') . '</b>' );
|
4242 |
+
|
4243 |
// Check captcha
|
4244 |
+
if ( wppa_switch( 'user_create_captcha' ) ) {
|
4245 |
+
|
4246 |
+
$captkey = wppa_get_randseed( 'session' );
|
4247 |
+
|
4248 |
+
if ( ! wppa_check_captcha( $captkey ) ) {
|
4249 |
+
wppa_alert( __( 'Wrong captcha, please try again' , 'wp-photo-album-plus') );
|
4250 |
+
return;
|
4251 |
+
}
|
4252 |
}
|
4253 |
+
|
4254 |
$parent = strval( intval( wppa_get_post( 'wppa-album-parent' ) ) );
|
4255 |
if ( ! wppa_user_is( 'administrator' ) && wppa_switch( 'default_parent_always' ) ) {
|
4256 |
$parent = wppa_opt( 'default_parent' );
|
4283 |
}
|
4284 |
|
4285 |
$alb = wppa_get_post( 'wppa-upload-album' );
|
4286 |
+
$uploaded_ids = array();
|
4287 |
|
4288 |
if ( is_array( $_FILES ) ) {
|
4289 |
+
$iret = true;
|
4290 |
$filecount = '1';
|
4291 |
$done = '0';
|
4292 |
$fail = '0';
|
4293 |
foreach ( $_FILES as $file ) {
|
4294 |
if ( ! is_array( $file['error'] ) ) {
|
4295 |
+
$iret = wppa_do_frontend_file_upload( $file, $alb ); // this should no longer happen since the name is incl []
|
4296 |
+
if ( $iret ) {
|
4297 |
+
$uploaded_ids[] = $iret;
|
4298 |
+
$done++;
|
4299 |
+
}
|
4300 |
else $fail++;
|
4301 |
}
|
4302 |
else {
|
4303 |
$filecount = count( $file['error'] );
|
4304 |
for ( $i = '0'; $i < $filecount; $i++ ) {
|
4305 |
+
if ( $iret ) {
|
4306 |
$f['error'] = $file['error'][$i];
|
4307 |
$f['tmp_name'] = $file['tmp_name'][$i];
|
4308 |
$f['name'] = $file['name'][$i];
|
4309 |
$f['type'] = $file['type'][$i];
|
4310 |
$f['size'] = $file['size'][$i];
|
4311 |
+
$iret = wppa_do_frontend_file_upload( $f, $alb );
|
4312 |
+
if ( $iret ) {
|
4313 |
+
$uploaded_ids[] = $iret;
|
4314 |
+
$done++;
|
4315 |
+
}
|
4316 |
else $fail++;
|
4317 |
}
|
4318 |
}
|
4324 |
|
4325 |
if ( $done ) {
|
4326 |
|
4327 |
+
// SUCCESSFUL UPLOAD, Blog It?
|
4328 |
+
if ( current_user_can( 'edit_posts' ) && isset( $_POST['wppa-blogit'] ) ) {
|
4329 |
+
|
4330 |
+
$title = $_POST['wppa-post-title'];
|
4331 |
+
if ( ! $title ) {
|
4332 |
+
$title = wppa_local_date();
|
4333 |
+
}
|
4334 |
+
$pretxt = $_POST['wppa-blogit-pretext'];
|
4335 |
+
$posttxt = $_POST['wppa-blogit-posttext'];
|
4336 |
+
$status = wppa_switch( 'blog_it_moderate' ) ? 'pending' : 'publish';
|
4337 |
+
|
4338 |
+
$post_content = $pretxt;
|
4339 |
+
foreach( $uploaded_ids as $id ) {
|
4340 |
+
$post_content .= '[wppa type="mphoto" photo="' . $id . '"][/wppa]';
|
4341 |
+
}
|
4342 |
+
$post_content .= $posttxt;
|
4343 |
+
|
4344 |
+
$post = array( 'post_title' => $title, 'post_content' => $post_content, 'post_status' => $status );
|
4345 |
+
$post = sanitize_post( $post, 'db' );
|
4346 |
+
|
4347 |
+
$iret = wp_insert_post( $post );
|
4348 |
+
}
|
4349 |
+
|
4350 |
+
// ADD POINTS
|
4351 |
$points = wppa_opt( 'cp_points_upload' ) * $done;
|
4352 |
$bret = wppa_add_credit_points( $points, __( 'Photo upload' ,'wp-photo-album-plus' ) );
|
4353 |
$alert .= sprintf( _n( '%d photo successfully uploaded', '%d photos successfully uploaded', $done, 'wp-photo-album-plus' ), $done );
|
4529 |
wppa_fe_add_custom( $id );
|
4530 |
|
4531 |
// Done!
|
4532 |
+
return $id;
|
4533 |
|
4534 |
}
|
4535 |
|
4593 |
$name = $file['name'];
|
4594 |
}
|
4595 |
|
4596 |
+
// Sanitize input
|
4597 |
$name = wppa_sanitize_photo_name( $name );
|
4598 |
$desc = balanceTags( wppa_get_post( 'user-desc' ), true );
|
4599 |
+
|
4600 |
+
// If BlogIt! and no descrption given, use name field - this is for the shortcode used: typ"mphoto"
|
4601 |
+
if ( ! $desc && isset( $_POST['wppa-blogit'] ) ) {
|
4602 |
+
$desc = 'w#name';
|
4603 |
+
}
|
4604 |
+
|
4605 |
+
// Find status and other needed data
|
4606 |
$linktarget = '_self';
|
4607 |
$status = ( wppa_switch( 'upload_moderate' ) && ! current_user_can( 'wppa_admin' ) ) ? 'pending' : 'publish';
|
4608 |
$filename = wppa_sanitize_file_name( $file['name'] );
|
4662 |
}
|
4663 |
wppa_send_mail( $to, $subj, $cont, $id );
|
4664 |
}
|
4665 |
+
return $id;
|
4666 |
}
|
4667 |
|
4668 |
return false;
|
wppa-import.php
ADDED
@@ -0,0 +1,2640 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* wppa-upload.php
|
3 |
+
* Package: wp-photo-album-plus
|
4 |
+
*
|
5 |
+
* Contains all the import pages and functions
|
6 |
+
* Version 6.5.02
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
|
11 |
+
|
12 |
+
// import images admin page
|
13 |
+
function _wppa_page_import() {
|
14 |
+
global $wppa_revno;
|
15 |
+
global $wpdb;
|
16 |
+
global $wppa_supported_photo_extensions;
|
17 |
+
global $wppa_supported_video_extensions;
|
18 |
+
global $wppa_supported_audio_extensions;
|
19 |
+
global $wppa_session;
|
20 |
+
|
21 |
+
if ( wppa( 'ajax' ) ) ob_start(); // Suppress output if ajax operation
|
22 |
+
|
23 |
+
// Init
|
24 |
+
$ngg_opts = get_option( 'ngg_options', false );
|
25 |
+
$user = wppa_get_user();
|
26 |
+
|
27 |
+
// Check database
|
28 |
+
wppa_check_database( true );
|
29 |
+
|
30 |
+
// Update watermark settings for the user if new values supplied
|
31 |
+
if ( wppa_switch( 'watermark_on' ) && ( wppa_switch( 'watermark_user' ) || current_user_can( 'wppa_settings' ) ) ) {
|
32 |
+
|
33 |
+
// File
|
34 |
+
if ( isset( $_POST['wppa-watermark-file'] ) ) {
|
35 |
+
|
36 |
+
// Sanitize input
|
37 |
+
$watermark_file = $_POST['wppa-watermark-file'];
|
38 |
+
if ( stripos( $watermark_file, '.png' ) !== false ) {
|
39 |
+
$watermark_file = sanitize_file_name( $watermark_file );
|
40 |
+
}
|
41 |
+
else {
|
42 |
+
if ( ! in_array( $watermark_file, array( '--- none ---', '---name---', '---filename---', '---description---', '---predef---' ) ) ) {
|
43 |
+
$watermark_file = 'nil';
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
// Update setting
|
48 |
+
update_option( 'wppa_watermark_file_'.$user, $watermark_file );
|
49 |
+
}
|
50 |
+
|
51 |
+
// Position
|
52 |
+
if ( isset( $_POST['wppa-watermark-pos'] ) ) {
|
53 |
+
|
54 |
+
// Sanitize input
|
55 |
+
$watermark_pos = $_POST['wppa-watermark-pos'];
|
56 |
+
if ( ! in_array( $watermark_pos, array( 'toplft', 'topcen', 'toprht', 'cenlft', 'cencen', 'cenrht', 'botlft', 'botcen', 'botrht' ) ) ) {
|
57 |
+
$watermark_pos = 'nil';
|
58 |
+
}
|
59 |
+
|
60 |
+
// Update setting
|
61 |
+
update_option( 'wppa_watermark_pos_'.$user, $watermark_pos );
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
// Update last used albums
|
66 |
+
if ( isset( $_POST['wppa-photo-album'] ) ) {
|
67 |
+
update_option( 'wppa-photo-album-import-'.wppa_get_user(), strval( intval( $_POST['wppa-photo-album'] ) ) );
|
68 |
+
}
|
69 |
+
if ( isset( $_POST['wppa-video-album'] ) ) {
|
70 |
+
update_option( 'wppa-video-album-import-'.wppa_get_user(), strval( intval( $_POST['wppa-video-album'] ) ) );
|
71 |
+
}
|
72 |
+
if ( isset( $_POST['wppa-audio-album'] ) ) {
|
73 |
+
update_option( 'wppa-audio-album-import-'.wppa_get_user(), strval( intval( $_POST['wppa-audio-album'] ) ) );
|
74 |
+
}
|
75 |
+
|
76 |
+
// Verify last albums still exist
|
77 |
+
$alb = get_option( 'wppa-photo-album-import-'.wppa_get_user(), '0' );
|
78 |
+
if ( $alb ) {
|
79 |
+
$exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $alb ) );
|
80 |
+
if ( ! $exists ) update_option( 'wppa-photo-album-import-'.wppa_get_user(), '0' );
|
81 |
+
}
|
82 |
+
$alb = get_option( 'wppa-video-album-import-'.wppa_get_user(), '0' );
|
83 |
+
if ( $alb ) {
|
84 |
+
$exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $alb ) );
|
85 |
+
if ( ! $exists ) update_option( 'wppa-video-album-import-'.wppa_get_user(), '0' );
|
86 |
+
}
|
87 |
+
$alb = get_option( 'wppa-audio-album-import-'.wppa_get_user(), '0' );
|
88 |
+
if ( $alb ) {
|
89 |
+
$exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $alb ) );
|
90 |
+
if ( ! $exists ) update_option( 'wppa-audio-album-import-'.wppa_get_user(), '0' );
|
91 |
+
}
|
92 |
+
|
93 |
+
// Extract zip
|
94 |
+
if ( isset( $_GET['zip'] ) ) {
|
95 |
+
wppa_extract( $_GET['zip'], true );
|
96 |
+
}
|
97 |
+
|
98 |
+
// Set local / remote
|
99 |
+
if ( isset( $_POST['wppa-local-remote'] ) && in_array( $_POST['wppa-local-remote'], array( 'local', 'remote' ) ) ) {
|
100 |
+
check_admin_referer( '$wppa_nonce', WPPA_NONCE );
|
101 |
+
update_option( 'wppa_import_source_type_'.$user, $_POST['wppa-local-remote'] );
|
102 |
+
}
|
103 |
+
|
104 |
+
// Set import source dir ( when local )
|
105 |
+
if ( isset( $_POST['wppa-import-set-source-dir'] ) && is_dir( $_POST['wppa-source'] ) ) {
|
106 |
+
check_admin_referer( '$wppa_nonce', WPPA_NONCE );
|
107 |
+
if ( isset( $_POST['wppa-source'] ) ) {
|
108 |
+
update_option( 'wppa_import_source_'.$user, $_POST['wppa-source'] );
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
// Set import source url ( when remote )
|
113 |
+
if ( isset( $_POST['wppa-import-set-source-url'] ) ) {
|
114 |
+
check_admin_referer( '$wppa_nonce', WPPA_NONCE );
|
115 |
+
if ( isset( $_POST['wppa-source-remote'] ) ) {
|
116 |
+
update_option( 'wppa_import_source_url_'.$user, esc_url( $_POST['wppa-source-remote'] ) );
|
117 |
+
update_option( 'wppa_import_source_url_found_'.$user, false );
|
118 |
+
update_option( 'wppa_import_remote_max_'.$user, strval( intval( $_POST['wppa-import-remote-max'] ) ) );
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
// Hit the submit button
|
123 |
+
if ( isset( $_POST['wppa-import-submit'] ) ) {
|
124 |
+
if ( wppa( 'ajax' ) ) {
|
125 |
+
if ( ! wp_verify_nonce( $_POST['wppa-update-check'], '$wppa_nonce' ) ) {
|
126 |
+
echo $_POST['wppa-update-check'].' Security check failure';
|
127 |
+
wppa_exit();
|
128 |
+
}
|
129 |
+
}
|
130 |
+
else {
|
131 |
+
check_admin_referer( '$wppa_nonce', WPPA_NONCE );
|
132 |
+
}
|
133 |
+
$delp = isset( $_POST['del-after-p'] );
|
134 |
+
$delf = isset( $_POST['del-after-f'] );
|
135 |
+
$dela = isset( $_POST['del-after-a'] );
|
136 |
+
$delz = isset( $_POST['del-after-z'] );
|
137 |
+
$delv = isset( $_POST['del-after-v'] );
|
138 |
+
$delu = isset( $_POST['del-after-u'] );
|
139 |
+
$delc = isset( $_POST['del-after-c'] );
|
140 |
+
|
141 |
+
wppa_import_photos( $delp, $dela, $delz, $delv, $delu, $delc, $delf );
|
142 |
+
}
|
143 |
+
|
144 |
+
// Continue dirimport after timeout
|
145 |
+
elseif ( isset( $_GET['continue'] ) ) {
|
146 |
+
if ( wp_verify_nonce( $_GET['nonce'], 'dirimport' ) ) wppa_import_photos();
|
147 |
+
}
|
148 |
+
|
149 |
+
// If we did this by ajax, setup reporting results for it
|
150 |
+
if ( wppa( 'ajax' ) ) {
|
151 |
+
ob_end_clean();
|
152 |
+
if ( wppa( 'ajax_import_files_done' ) ) {
|
153 |
+
echo '<span style="color:green" >' . wppa( 'ajax_import_files' ) . ' ' . __( 'Done!', 'wp-photo-album-plus' ) . '</span>';
|
154 |
+
}
|
155 |
+
elseif ( wppa( 'ajax_import_files_error' ) ) {
|
156 |
+
echo '<span style="color:red" >' . wppa( 'ajax_import_files' ) . ' ' . wppa( 'ajax_import_files_error' ) . '</span>';
|
157 |
+
}
|
158 |
+
else {
|
159 |
+
echo '<span style="color:red" >' . wppa( 'ajax_import_files' ) . ' ' . __( 'Failed!', 'wp-photo-album-plus' ) . '</span>';
|
160 |
+
}
|
161 |
+
wppa_exit();
|
162 |
+
}
|
163 |
+
|
164 |
+
// Open the Form
|
165 |
+
echo
|
166 |
+
'<div class="wrap">' .
|
167 |
+
'<h2>' .
|
168 |
+
__( 'Import Photos', 'wp-photo-album-plus') .
|
169 |
+
'</h2>';
|
170 |
+
|
171 |
+
// See if remote is possible
|
172 |
+
$can_remote = ini_get( 'allow_url_fopen' ) && function_exists( 'curl_init' );
|
173 |
+
if ( ! $can_remote ) {
|
174 |
+
update_option( 'wppa_import_source_type_'.$user, 'local' );
|
175 |
+
}
|
176 |
+
|
177 |
+
// Get this users current source type setting ( local/remote )
|
178 |
+
$source_type = get_option( 'wppa_import_source_type_'.$user, 'local' );
|
179 |
+
|
180 |
+
// Local. Find data we will going to need
|
181 |
+
if ( $source_type == 'local' ) {
|
182 |
+
|
183 |
+
// Get curren local dir setting
|
184 |
+
$source = get_option( 'wppa_import_source_'.$user, WPPA_DEPOT_PATH );
|
185 |
+
if ( ! $source || ! is_dir( $source ) ) {
|
186 |
+
$source = WPPA_DEPOT_PATH;
|
187 |
+
update_option( 'wppa_import_source_'.$user, WPPA_DEPOT_PATH );
|
188 |
+
}
|
189 |
+
|
190 |
+
// See if the current source is the 'home' directory
|
191 |
+
$is_depot = ( $source == WPPA_DEPOT_PATH );
|
192 |
+
|
193 |
+
// See if the current source is a subdir of my depot
|
194 |
+
$is_sub_depot = ( substr( $source, 0, strlen( WPPA_DEPOT_PATH ) ) == WPPA_DEPOT_PATH );
|
195 |
+
|
196 |
+
// Sanitize system, removes illegal files
|
197 |
+
if ( $is_sub_depot ) {
|
198 |
+
wppa_sanitize_files();
|
199 |
+
}
|
200 |
+
|
201 |
+
// See what's in there
|
202 |
+
$files = wppa_get_import_files();
|
203 |
+
$zipcount = wppa_get_zipcount( $files );
|
204 |
+
$albumcount = wppa_get_albumcount( $files );
|
205 |
+
$photocount = wppa_get_photocount( $files );
|
206 |
+
$videocount = wppa_get_video_count( $files );
|
207 |
+
$audiocount = wppa_get_audio_count( $files );
|
208 |
+
$dircount = $is_depot ? wppa_get_dircount( $files ) : '0';
|
209 |
+
$csvcount = $is_depot ? wppa_get_csvcount( $files ) : '0';
|
210 |
+
|
211 |
+
if ( $ngg_opts ) {
|
212 |
+
$is_ngg = strpos( $source, $ngg_opts['gallerypath'] ) !== false; // this is false for the ngg root !!
|
213 |
+
}
|
214 |
+
else $is_ngg = false;
|
215 |
+
}
|
216 |
+
|
217 |
+
// Remote. Find data we will going to need
|
218 |
+
if ( $source_type == 'remote' ) {
|
219 |
+
wppa( 'is_remote', true );
|
220 |
+
$source = get_option( 'wppa_import_source_url_' . $user, 'http://' );
|
221 |
+
$source_path = $source;
|
222 |
+
$source_url = $source;
|
223 |
+
$is_depot = false;
|
224 |
+
$is_sub_depot = false;
|
225 |
+
$files = wppa_get_import_files();
|
226 |
+
$zipcount = '0';
|
227 |
+
$albumcount = '0';
|
228 |
+
$photocount = $files ? count( $files ) : '0';
|
229 |
+
$videocount = '0';
|
230 |
+
$audiocount = '0';
|
231 |
+
$dircount = '0';
|
232 |
+
$csvcount = '0';
|
233 |
+
$is_ngg = false;
|
234 |
+
$remote_max = get_option( 'wppa_import_remote_max_'.$user, '10' );
|
235 |
+
}
|
236 |
+
|
237 |
+
// The form
|
238 |
+
echo
|
239 |
+
'<form' .
|
240 |
+
' action="' . wppa_dbg_url( get_admin_url() . 'admin.php?page=wppa_import_photos' ) . '"' .
|
241 |
+
' method="post"' .
|
242 |
+
' >';
|
243 |
+
|
244 |
+
// Admin and superuser can change import source, other users only if change source not is restricted
|
245 |
+
if ( wppa_user_is( 'administrator' ) || ! wppa_switch( 'chgsrc_is_restricted' ) ) {
|
246 |
+
|
247 |
+
// Local / Remote
|
248 |
+
echo
|
249 |
+
'<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >' .
|
250 |
+
wp_nonce_field( '$wppa_nonce', WPPA_NONCE, true, false ) .
|
251 |
+
__( 'Select Local or Remote', 'wp-photo-album-plus' ) .
|
252 |
+
( $disabled = $can_remote ? '' : 'disabled="disabled"' ) .
|
253 |
+
'<select name="wppa-local-remote" >' .
|
254 |
+
'<option value="local" ' . ( $source_type == 'local' ? 'selected="selected"' : '' ) . '>' . __( 'Local', 'wp-photo-album-plus') . '</option>' .
|
255 |
+
'<option value="remote" ' . $disabled . ( $source_type == 'remote' ? 'selected="selected"' : '' ) . '>' . __( 'Remote' ,'wp-photo-album-plus' ) . '</option>' .
|
256 |
+
'</select>';
|
257 |
+
if ( $can_remote ) {
|
258 |
+
echo
|
259 |
+
'<input' .
|
260 |
+
' type="submit"' .
|
261 |
+
' class="button-secundary"' .
|
262 |
+
' name="wppa-import-set-source"' .
|
263 |
+
' value="' . __( 'Set Local/Remote' ,'wp-photo-album-plus') . '"' .
|
264 |
+
'/>';
|
265 |
+
}
|
266 |
+
else {
|
267 |
+
if ( ! ini_get( 'allow_url_fopen' ) ) {
|
268 |
+
_e( 'The server does not allow you to import from remote locations. ( The php directive allow_url_fopen is not set to 1 )', 'wp-photo-album-plus' );
|
269 |
+
}
|
270 |
+
if ( ! function_exists( 'curl_init' ) ) {
|
271 |
+
_e( 'The server does not allow you to import from remote locations. ( The curl functions are not set up )', 'wp-photo-album-plus' );
|
272 |
+
}
|
273 |
+
}
|
274 |
+
echo
|
275 |
+
'</div>';
|
276 |
+
|
277 |
+
// Source dir / url
|
278 |
+
echo
|
279 |
+
'<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >' .
|
280 |
+
wp_nonce_field( '$wppa_nonce', WPPA_NONCE, true, false ) .
|
281 |
+
__( 'Import photos from:' ,'wp-photo-album-plus');
|
282 |
+
|
283 |
+
// Local: dir
|
284 |
+
if ( $source_type == 'local' ) {
|
285 |
+
echo
|
286 |
+
'<select name="wppa-source" >' .
|
287 |
+
wppa_abs_walktree( wppa_opt( 'import_root'), $source ) .
|
288 |
+
'</select>' .
|
289 |
+
'<input' .
|
290 |
+
' type="submit"' .
|
291 |
+
' class="button-secundary"' .
|
292 |
+
' name="wppa-import-set-source-dir"' .
|
293 |
+
' value="' . __( 'Set source directory', 'wp-photo-album-plus') . '"' .
|
294 |
+
' />';
|
295 |
+
}
|
296 |
+
|
297 |
+
// Remote: url
|
298 |
+
else {
|
299 |
+
echo
|
300 |
+
'<input' .
|
301 |
+
' type="text"' .
|
302 |
+
' style="width:50%"' .
|
303 |
+
' name="wppa-source-remote"' .
|
304 |
+
' value="' . $source . '"' .
|
305 |
+
' />' .
|
306 |
+
__( 'Max:', 'wp-photo-album-plus' ) .
|
307 |
+
'<input' .
|
308 |
+
' type="text"' .
|
309 |
+
' style="width:50px;"' .
|
310 |
+
' name="wppa-import-remote-max"' .
|
311 |
+
' value="' . $remote_max . '"' .
|
312 |
+
' />' .
|
313 |
+
'<input' .
|
314 |
+
' type="submit"' .
|
315 |
+
' onclick="jQuery( \'#rem-rem\' ).css( \'display\',\'inline\' ); return true;"' .
|
316 |
+
' class="button-secundary"' .
|
317 |
+
' name="wppa-import-set-source-url"' .
|
318 |
+
' value="' . __( 'Find remote photos', 'wp-photo-album-plus' ) . '"' .
|
319 |
+
' />' .
|
320 |
+
'<span id="rem-rem" style="display:none;" >' .
|
321 |
+
__( 'Working, please wait...', 'wp-photo-album-plus') .
|
322 |
+
'</span>' .
|
323 |
+
'<br />' .
|
324 |
+
__( 'You can enter either a web page address like <i>http://mysite.com/mypage/</i> or a full url to an image file like <i>http://mysite.com/wp-content/uploads/wppa/4711.jpg</i>', 'wp-photo-album-plus' );
|
325 |
+
}
|
326 |
+
echo
|
327 |
+
'</div>';
|
328 |
+
}
|
329 |
+
echo
|
330 |
+
'</form>';
|
331 |
+
|
332 |
+
// check if albums exist or will be made before allowing upload
|
333 |
+
if ( ! wppa_has_albums() && ! $albumcount && ! $dircount ) {
|
334 |
+
$url = wppa_dbg_url( get_admin_url() . 'admin.php?page=wppa_admin_menu' );
|
335 |
+
echo
|
336 |
+
'<p>' .
|
337 |
+
__( 'No albums exist. You must', 'wp-photo-album-plus' ) . ' ' .
|
338 |
+
'<a href="' . $url . '" >' .
|
339 |
+
__( 'create one', 'wp-photo-album-plus' ) . ' ' .
|
340 |
+
'</a> ' .
|
341 |
+
__( 'beofre you can upload your photos.', 'wp-photo-album-plus' ) .
|
342 |
+
'</p>';
|
343 |
+
return;
|
344 |
+
}
|
345 |
+
|
346 |
+
// Something to import?
|
347 |
+
if ( $photocount || $albumcount || $zipcount || $dircount || $videocount || $audiocount || $csvcount ) {
|
348 |
+
|
349 |
+
// Open the form
|
350 |
+
echo
|
351 |
+
'<form' .
|
352 |
+
' action="' . wppa_dbg_url( get_admin_url() . 'admin.php?page=wppa_import_photos' ) . '"' .
|
353 |
+
' method="post"' .
|
354 |
+
' >' .
|
355 |
+
wp_nonce_field( '$wppa_nonce', WPPA_NONCE, true, false );
|
356 |
+
|
357 |
+
// Display the zips
|
358 |
+
if ( PHP_VERSION_ID >= 50207 && $zipcount > '0' ) {
|
359 |
+
echo
|
360 |
+
'<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >' .
|
361 |
+
'<p><b>' .
|
362 |
+
sprintf( _n( 'There is %d zipfile in the depot', 'There are %d zipfiles in the depot', $zipcount, 'wp-photo-album-plus' ), $zipcount ) .
|
363 |
+
'</b></p>' .
|
364 |
+
'<table class="form-table wppa-table widefat" style="margin-bottom:0;" >' .
|
365 |
+
'<thead>' .
|
366 |
+
'<tr>' .
|
367 |
+
'<td>' .
|
368 |
+
'<input' .
|
369 |
+
' type="checkbox"' .
|
370 |
+
' id="all-zip"' .
|
371 |
+
' checked="checked"' .
|
372 |
+
' onchange="checkAll( \'all-zip\', \'.wppa-zip\' )"' .
|
373 |
+
' />' .
|
374 |
+
'<b> ' .
|
375 |
+
__( 'Check/uncheck all', 'wp-photo-album-plus' ) .
|
376 |
+
'</b>' .
|
377 |
+
'</td>';
|
378 |
+
if ( $is_sub_depot ) {
|
379 |
+
echo
|
380 |
+
'<td>' .
|
381 |
+
'<input' .
|
382 |
+
' type="checkbox"' .
|
383 |
+
' id="del-after-z"' .
|
384 |
+
' name="del-after-z"' .
|
385 |
+
' checked="checked"' .
|
386 |
+
' />' .
|
387 |
+
'<b> ' .
|
388 |
+
__( 'Delete after successful extraction.', 'wp-photo-album-plus' ) .
|
389 |
+
'</b>' .
|
390 |
+
'</td>';
|
391 |
+
}
|
392 |
+
echo
|
393 |
+
'</tr>' .
|
394 |
+
'</thead>' .
|
395 |
+
'</table>' .
|
396 |
+
'<table' .
|
397 |
+
' class="form-table wppa-table widefat"' .
|
398 |
+
' style="margin-top:0;"' .
|
399 |
+
' >' .
|
400 |
+
'<tr>';
|
401 |
+
$ct = 0;
|
402 |
+
$idx = '0';
|
403 |
+
foreach ( $files as $file ) {
|
404 |
+
|
405 |
+
$ext = wppa_get_ext( $file );
|
406 |
+
if ( $ext == 'zip' ) {
|
407 |
+
echo
|
408 |
+
'<td>' .
|
409 |
+
'<input' .
|
410 |
+
' type="checkbox"' .
|
411 |
+
' id="file-' . $idx . '"' .
|
412 |
+
' name="file-' . $idx . '"' .
|
413 |
+
' class="wppa-zip"' .
|
414 |
+
' checked="checked"' .
|
415 |
+
' /> ' .
|
416 |
+
wppa_sanitize_file_name( basename( $file ) ) .
|
417 |
+
'</td>';
|
418 |
+
if ( $ct == 3 ) {
|
419 |
+
echo( '</tr><tr>' );
|
420 |
+
$ct = 0;
|
421 |
+
}
|
422 |
+
else {
|
423 |
+
$ct++;
|
424 |
+
}
|
425 |
+
}
|
426 |
+
$idx++;
|
427 |
+
}
|
428 |
+
echo
|
429 |
+
'</tr>' .
|
430 |
+
'</table>' .
|
431 |
+
'</div>';
|
432 |
+
}
|
433 |
+
|
434 |
+
// Dispay the albums ( .amf files )
|
435 |
+
if ( $albumcount ) {
|
436 |
+
echo
|
437 |
+
'<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >' .
|
438 |
+
'<p><b>' .
|
439 |
+
sprintf( _n( 'There is %d albumdefinition in the depot', 'There are %d albumdefinitions in the depot', $albumcount, 'wp-photo-album-plus' ), $albumcount ) .
|
440 |
+
'</b></p>' .
|
441 |
+
'<table class="form-table wppa-table widefat" style="margin-bottom:0;" >' .
|
442 |
+
'<thead>' .
|
443 |
+
'<tr>' .
|
444 |
+
'<td>' .
|
445 |
+
'<input' .
|
446 |
+
' type="checkbox"' .
|
447 |
+
' id="all-amf"' .
|
448 |
+
' checked="checked"' .
|
449 |
+
' onchange="checkAll( \'all-amf\', \'.wppa-amf\' )"' .
|
450 |
+
' />' .
|
451 |
+
'<b> ' .
|
452 |
+
__( 'Check/uncheck all', 'wp-photo-album-plus' ) .
|
453 |
+
'</b>' .
|
454 |
+
'</td>';
|
455 |
+
if ( $is_sub_depot ) {
|
456 |
+
echo
|
457 |
+
'<td>' .
|
458 |
+
'<input' .
|
459 |
+
' type="checkbox"' .
|
460 |
+
' id="del-after-a"' .
|
461 |
+
' name="del-after-a"' .
|
462 |
+
' checked="checked"' .
|
463 |
+
' />' .
|
464 |
+
'<b> ' .
|
465 |
+
__( 'Remove from depot after successful import, or if the album already exists.', 'wp-photo-album-plus' ) .
|
466 |
+
'</b>' .
|
467 |
+
'</td>';
|
468 |
+
}
|
469 |
+
echo
|
470 |
+
'</tr>' .
|
471 |
+
'</thead>' .
|
472 |
+
'</table>' .
|
473 |
+
'<table' .
|
474 |
+
' class="form-table wppa-table widefat"' .
|
475 |
+
' style="margin-top:0;"' .
|
476 |
+
' >' .
|
477 |
+
'<tr>';
|
478 |
+
$ct = 0;
|
479 |
+
$idx = '0';
|
480 |
+
foreach ( $files as $file ) {
|
481 |
+
$ext = wppa_get_ext( $file );
|
482 |
+
if ( $ext == 'amf' ) {
|
483 |
+
echo
|
484 |
+
'<td>' .
|
485 |
+
'<input' .
|
486 |
+
' type="checkbox"' .
|
487 |
+
' id="file-' . $idx . '"' .
|
488 |
+
' name="file-' . $idx . '"' .
|
489 |
+
' class="wppa-amf"' .
|
490 |
+
' checked="checked"' .
|
491 |
+
' />' .
|
492 |
+
' ' .
|
493 |
+
basename( $file ) . ' ' . stripslashes( wppa_get_meta_name( $file, '( ' ) ) .
|
494 |
+
'</td>';
|
495 |
+
if ( $ct == 3 ) {
|
496 |
+
echo( '</tr><tr>' );
|
497 |
+
$ct = 0;
|
498 |
+
}
|
499 |
+
else {
|
500 |
+
$ct++;
|
501 |
+
}
|
502 |
+
}
|
503 |
+
$idx++;
|
504 |
+
}
|
505 |
+
echo
|
506 |
+
'</tr>' .
|
507 |
+
'</table>' .
|
508 |
+
'</div>';
|
509 |
+
}
|
510 |
+
|
511 |
+
// Display the single photos
|
512 |
+
if ( $photocount ) {
|
513 |
+
echo
|
514 |
+
'<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >';
|
515 |
+
|
516 |
+
// Display the number of photos
|
517 |
+
'<p><b>';
|
518 |
+
|
519 |
+
// Local
|
520 |
+
if ( $source_type == 'local' ) {
|
521 |
+
if ( $is_ngg ) {
|
522 |
+
printf( _n( 'There is %d photo in the ngg gallery', 'There are %d photos in the ngg gallery', $photocount, 'wp-photo-album-plus' ), $photocount );
|
523 |
+
}
|
524 |
+
else {
|
525 |
+
printf( _n( 'There is %d photo in the depot', 'There are %d photos in the depot', $photocount, 'wp-photo-album-plus' ), $photocount );
|
526 |
+
}
|
527 |
+
}
|
528 |
+
|
529 |
+
// Remote
|
530 |
+
else {
|
531 |
+
printf( _n( 'There is %d possible photo found remote', 'There are %d possible photos found remote', $photocount, 'wp-photo-album-plus' ), $photocount );
|
532 |
+
}
|
533 |
+
|
534 |
+
// Tell if downsize on
|
535 |
+
if ( wppa_switch( 'resize_on_upload' ) ) {
|
536 |
+
echo ' ' . __( 'Photos will be downsized during import.', 'wp-photo-album-plus' );
|
537 |
+
}
|
538 |
+
|
539 |
+
echo
|
540 |
+
'</b></p>';
|
541 |
+
|
542 |
+
// The album selection
|
543 |
+
echo
|
544 |
+
'<p class="hideifupdate" >' .
|
545 |
+
__( 'Default album for import:', 'wp-photo-album-plus') .
|
546 |
+
'<select name="wppa-photo-album" id="wppa-photo-album" >' .
|
547 |
+
wppa_album_select_a( array( 'path' => wppa_switch( 'hier_albsel' ),
|
548 |
+
'selected' => get_option( 'wppa-photo-album-import-'.wppa_get_user(), '0' ),
|
549 |
+
'addpleaseselect' => true,
|
550 |
+
'checkowner' => true,
|
551 |
+
'checkupload' => true
|
552 |
+
) ) .
|
553 |
+
'</select>' .
|
554 |
+
__( 'Photos that have (<em>name</em>)[<em>album</em>] will be imported by that <em>name</em> in that <em>album</em>.', 'wp-photo-album-plus') .
|
555 |
+
'</p>';
|
556 |
+
|
557 |
+
// Watermark
|
558 |
+
if ( wppa_switch( 'watermark_on' ) && ( wppa_switch( 'watermark_user' ) || current_user_can( 'wppa_settings' ) ) ) {
|
559 |
+
echo
|
560 |
+
'<p>' .
|
561 |
+
__( 'Apply watermark file:', 'wp-photo-album-plus') .
|
562 |
+
'<select name="wppa-watermark-file" id="wppa-watermark-file" >' .
|
563 |
+
wppa_watermark_file_select() .
|
564 |
+
'</select>' .
|
565 |
+
__( 'Position:', 'wp-photo-album-plus') .
|
566 |
+
'<select name="wppa-watermark-pos" id="wppa-watermark-pos" >' .
|
567 |
+
wppa_watermark_pos_select() .
|
568 |
+
'</select>' .
|
569 |
+
'</p>';
|
570 |
+
}
|
571 |
+
|
572 |
+
// Header of photo list
|
573 |
+
echo
|
574 |
+
'<table class="form-table wppa-table widefat" style="margin-bottom:0;" >' .
|
575 |
+
'<thead>' .
|
576 |
+
'<tr>' .
|
577 |
+
'<td>' .
|
578 |
+
'<input' .
|
579 |
+
' type="checkbox"' .
|
580 |
+
' id="all-pho"' .
|
581 |
+
( $is_sub_depot ? 'checked="checked"' : '' ) .
|
582 |
+
' onchange="checkAll( \'all-pho\', \'.wppa-pho\' )"' .
|
583 |
+
' />' .
|
584 |
+
'<b>' .
|
585 |
+
' ' .
|
586 |
+
__( 'Check/uncheck all', 'wp-photo-album-plus') .
|
587 |
+
'</b>' .
|
588 |
+
'</td>';
|
589 |
+
|
590 |
+
// Depot specific switches
|
591 |
+
if ( $is_sub_depot ) {
|
592 |
+
echo
|
593 |
+
'<td>' .
|
594 |
+
'<input' .
|
595 |
+
' type="checkbox"' .
|
596 |
+
' id="del-after-p"' .
|
597 |
+
' name="del-after-p"' .
|
598 |
+
' checked="checked"' .
|
599 |
+
' />' .
|
600 |
+
'<b>' .
|
601 |
+
' ' .
|
602 |
+
__( 'Remove from depot after successful import.', 'wp-photo-album-plus' ) .
|
603 |
+
'</b>' .
|
604 |
+
'</td>' .
|
605 |
+
'<td>' .
|
606 |
+
'<input' .
|
607 |
+
' type="checkbox"' .
|
608 |
+
' id="del-after-f"' .
|
609 |
+
' name="del-after-f"' .
|
610 |
+
' />' .
|
611 |
+
'<b>' .
|
612 |
+
' ' .
|
613 |
+
__( 'Remove from depot after failed import.', 'wp-photo-album-plus' ) .
|
614 |
+
'</b>' .
|
615 |
+
'</td>';
|
616 |
+
}
|
617 |
+
|
618 |
+
// Nextgen import specific switches
|
619 |
+
if ( $is_ngg ) {
|
620 |
+
echo
|
621 |
+
'<td>' .
|
622 |
+
'<input' .
|
623 |
+
' type="checkbox"' .
|
624 |
+
' id="cre-album"' .
|
625 |
+
' name="cre-album"' .
|
626 |
+
' checked="checked"' .
|
627 |
+
' value="' . esc_attr( basename( $source ) ) .'"' .
|
628 |
+
' />' .
|
629 |
+
'<b>' .
|
630 |
+
' ' .
|
631 |
+
__( 'Import into album', 'wp-photo-album-plus' ) . ' ' . basename( $source ) .
|
632 |
+
'</b>' .
|
633 |
+
'<small>' .
|
634 |
+
__( 'The album will be created if it does not exist', 'wp-photo-album-plus') .
|
635 |
+
'</small>' .
|
636 |
+
'</td>' .
|
637 |
+
'<td>' .
|
638 |
+
'<input' .
|
639 |
+
' type="checkbox"' .
|
640 |
+
' id="use-backup"' .
|
641 |
+
' name="use-backup"' .
|
642 |
+
' checked="checked"' .
|
643 |
+
' />' .
|
644 |
+
'<b>' .
|
645 |
+
' ' .
|
646 |
+
__( 'Use backup if available', 'wp-photo-album-plus') .
|
647 |
+
'</b>' .
|
648 |
+
'</td>';
|
649 |
+
}
|
650 |
+
|
651 |
+
// Update existing switch
|
652 |
+
echo
|
653 |
+
'<td>' .
|
654 |
+
'<input' .
|
655 |
+
' type="checkbox"' .
|
656 |
+
' id="wppa-update"' .
|
657 |
+
' onchange="impUpd( this, \'#submit\' )"' .
|
658 |
+
' name="wppa-update"' .
|
659 |
+
' />' .
|
660 |
+
'<b>' .
|
661 |
+
' ' .
|
662 |
+
__( 'Update existing photos', 'wp-photo-album-plus') .
|
663 |
+
'</b>' .
|
664 |
+
'</td>';
|
665 |
+
|
666 |
+
// Void dups switch
|
667 |
+
echo '<td>';
|
668 |
+
if ( wppa_switch( 'void_dups' ) ) {
|
669 |
+
echo
|
670 |
+
'<input' .
|
671 |
+
' type="hidden"' .
|
672 |
+
' id="wppa-nodups"' .
|
673 |
+
' name="wppa-nodups"' .
|
674 |
+
' value="true"' .
|
675 |
+
' />';
|
676 |
+
}
|
677 |
+
else {
|
678 |
+
echo
|
679 |
+
'<input' .
|
680 |
+
' type="checkbox"' .
|
681 |
+
' id="wppa-nodups"' .
|
682 |
+
' name="wppa-nodups"' .
|
683 |
+
' checked="checked"' .
|
684 |
+
' />' .
|
685 |
+
'<b>' .
|
686 |
+
' ' .
|
687 |
+
__( 'Do not create duplicates', 'wp-photo-album-plus' ) .
|
688 |
+
'</b>';
|
689 |
+
}
|
690 |
+
echo '</td>';
|
691 |
+
|
692 |
+
// Import preview zoomable switch
|
693 |
+
if ( wppa_switch( 'import_preview' ) ) {
|
694 |
+
echo
|
695 |
+
'<td>' .
|
696 |
+
'<input' .
|
697 |
+
' type="checkbox"' .
|
698 |
+
' id="wppa-zoom"' .
|
699 |
+
' onclick="wppa_setCookie(\'zoompreview\', this.checked, \'365\')"' .
|
700 |
+
' />' .
|
701 |
+
'<b>' .
|
702 |
+
' ' .
|
703 |
+
__( 'Zoom previews', 'wp-photo-album-plus' ) .
|
704 |
+
'</b>' .
|
705 |
+
'<script type="text/javascript">if ( wppa_getCookie(\'zoompreview\') == true ) { jQuery(\'#wppa-zoom\').attr(\'checked\', \'checked\') }</script>' .
|
706 |
+
'</td>';
|
707 |
+
}
|
708 |
+
echo
|
709 |
+
'</tr>' .
|
710 |
+
'</thead>' .
|
711 |
+
'</table>';
|
712 |
+
|
713 |
+
// Photo list
|
714 |
+
echo
|
715 |
+
'<table class="form-table wppa-table widefat" style="margin-top:0;" >' .
|
716 |
+
'<tr>';
|
717 |
+
$ct = 0;
|
718 |
+
$idx = '0';
|
719 |
+
if ( is_array( $files ) ) foreach ( $files as $file ) {
|
720 |
+
$ext = wppa_get_ext( $file );
|
721 |
+
$meta = wppa_strip_ext( $file ).'.PMF';
|
722 |
+
if ( ! is_file( $meta ) ) {
|
723 |
+
$meta = wppa_strip_ext( $file ).'.pmf';
|
724 |
+
}
|
725 |
+
if ( ! is_file( $meta ) ) {
|
726 |
+
$meta = false;
|
727 |
+
}
|
728 |
+
if ( in_array( strtolower($ext), $wppa_supported_photo_extensions ) ) {
|
729 |
+
echo
|
730 |
+
'<td id="td-file-' . $idx . '" >' .
|
731 |
+
'<input' .
|
732 |
+
' type="checkbox"' .
|
733 |
+
' id="file-' . $idx . '"' .
|
734 |
+
' name="file-' . $idx . '"' .
|
735 |
+
' title="' . esc_attr( $file ) . '"' .
|
736 |
+
' class="wppa-pho"' .
|
737 |
+
( $is_sub_depot ? 'checked="checked"' : '' ) .
|
738 |
+
'/ >' .
|
739 |
+
'<span' .
|
740 |
+
' id="name-file-' . $idx . '"' .
|
741 |
+
' >' .
|
742 |
+
' ';
|
743 |
+
|
744 |
+
if ( wppa( 'is_wppa_tree' ) ) {
|
745 |
+
$t = explode( 'uploads/wppa/', $file );
|
746 |
+
echo $t[1];
|
747 |
+
}
|
748 |
+
else {
|
749 |
+
echo( wppa_sanitize_file_name( basename( $file ) ) );
|
750 |
+
}
|
751 |
+
|
752 |
+
if ( $meta ) {
|
753 |
+
echo
|
754 |
+
' ' .
|
755 |
+
stripslashes( wppa_get_meta_name( $meta, '( ' ) ) .
|
756 |
+
stripslashes( wppa_get_meta_album( $meta, '[' ) );
|
757 |
+
}
|
758 |
+
echo
|
759 |
+
'</span>';
|
760 |
+
|
761 |
+
if ( wppa_switch( 'import_preview' ) ) {
|
762 |
+
if ( wppa( 'is_remote' ) ) {
|
763 |
+
if ( strpos( $file, '//res.cloudinary.com/' ) !== false ) {
|
764 |
+
$img_url = dirname( $file ) . '/h_144/' . basename( $file );
|
765 |
+
}
|
766 |
+
else {
|
767 |
+
$img_url = $file;
|
768 |
+
}
|
769 |
+
}
|
770 |
+
else {
|
771 |
+
$img_url = str_replace( ABSPATH, home_url().'/', $file );
|
772 |
+
}
|
773 |
+
echo
|
774 |
+
'<img src="' . $img_url . '"' .
|
775 |
+
' alt="N.A."' .
|
776 |
+
' style="max-height:48px;"' .
|
777 |
+
' onmouseover="if (jQuery(\'#wppa-zoom\').attr(\'checked\')) jQuery(this).css(\'max-height\', \'144px\')"' .
|
778 |
+
' onmouseout="if (jQuery(\'#wppa-zoom\').attr(\'checked\')) jQuery(this).css(\'max-height\', \'48px\')"' .
|
779 |
+
' />';
|
780 |
+
}
|
781 |
+
|
782 |
+
echo
|
783 |
+
'</td>';
|
784 |
+
|
785 |
+
if ( $ct == 3 ) {
|
786 |
+
echo( '</tr><tr>' );
|
787 |
+
$ct = 0;
|
788 |
+
}
|
789 |
+
else {
|
790 |
+
$ct++;
|
791 |
+
}
|
792 |
+
}
|
793 |
+
$idx++;
|
794 |
+
}
|
795 |
+
echo
|
796 |
+
'</tr>' .
|
797 |
+
'</table>' .
|
798 |
+
'</div>';
|
799 |
+
}
|
800 |
+
|
801 |
+
// Display the videos
|
802 |
+
if ( $videocount && wppa_switch( 'enable_video' ) ) {
|
803 |
+
echo
|
804 |
+
'<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >';
|
805 |
+
|
806 |
+
// Display available files
|
807 |
+
echo
|
808 |
+
'<p><b>' .
|
809 |
+
sprintf( _n( 'There is %d video in the depot', 'There are %d videos in the depot', $videocount, 'wp-photo-album-plus' ), $videocount ) .
|
810 |
+
'</b></p>';
|
811 |
+
|
812 |
+
// Album to import to
|
813 |
+
echo
|
814 |
+
'<p class="hideifupdate" >' .
|
815 |
+
__( 'Album to import to:', 'wp-photo-album-plus') .
|
816 |
+
'<select name="wppa-video-album" id="wppa-video-album">' .
|
817 |
+
wppa_album_select_a( array( 'path' => wppa_switch( 'hier_albsel' ),
|
818 |
+
'selected' => get_option( 'wppa-video-album-import-'.wppa_get_user(), '0' ),
|
819 |
+
'addpleaseselect' => true,
|
820 |
+
'checkowner' => true,
|
821 |
+
'checkupload' => true
|
822 |
+
) ) .
|
823 |
+
'</select>' .
|
824 |
+
'</p>';
|
825 |
+
|
826 |
+
// Header of video list
|
827 |
+
echo
|
828 |
+
'<table class="form-table wppa-table widefat" style="margin-bottom:0;" >' .
|
829 |
+
'<thead>' .
|
830 |
+
'<tr>' .
|
831 |
+
'<td>' .
|
832 |
+
'<input' .
|
833 |
+
' type="checkbox"' .
|
834 |
+
' id="all-video"' .
|
835 |
+
' checked="checked"' .
|
836 |
+
' onchange="checkAll( \'all-video\', \'.wppa-video\' )"' .
|
837 |
+
' />' .
|
838 |
+
'<b>' .
|
839 |
+
' ' .
|
840 |
+
__( 'Check/uncheck all', 'wp-photo-album-plus') .
|
841 |
+
'</b>' .
|
842 |
+
'</td>';
|
843 |
+
if ( $is_sub_depot ) {
|
844 |
+
echo
|
845 |
+
'<td>' .
|
846 |
+
'<input' .
|
847 |
+
' type="checkbox"' .
|
848 |
+
' id="del-after-v"' .
|
849 |
+
' name="del-after-v"' .
|
850 |
+
' checked="checked"' .
|
851 |
+
' />' .
|
852 |
+
'<b>' .
|
853 |
+
' ' .
|
854 |
+
__( 'Remove from depot after successful import.', 'wp-photo-album-plus' ) .
|
855 |
+
'</b>' .
|
856 |
+
'</td>';
|
857 |
+
}
|
858 |
+
echo
|
859 |
+
'</tr>' .
|
860 |
+
'</thead>' .
|
861 |
+
'</table>';
|
862 |
+
|
863 |
+
// Video list
|
864 |
+
echo
|
865 |
+
'<table class="form-table wppa-table widefat" style="margin-top:0;" >' .
|
866 |
+
'<tr>';
|
867 |
+
$ct = 0;
|
868 |
+
$idx = '0';
|
869 |
+
if ( is_array( $files ) ) foreach ( $files as $file ) {
|
870 |
+
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
871 |
+
if ( in_array( strtolower($ext), $wppa_supported_video_extensions ) ) {
|
872 |
+
echo
|
873 |
+
'<td>' .
|
874 |
+
'<input' .
|
875 |
+
' type="checkbox"' .
|
876 |
+
' id="file-' . $idx . '"' .
|
877 |
+
' name="file-' . $idx . '"' .
|
878 |
+
' title="' . $file . '"' .
|
879 |
+
' class="wppa-video"' .
|
880 |
+
' checked="checked"' .
|
881 |
+
' />' .
|
882 |
+
'<span' .
|
883 |
+
' id="name-file-' . $idx . '"' .
|
884 |
+
' >' .
|
885 |
+
' ' .
|
886 |
+
wppa_sanitize_file_name( basename( $file ) ) .
|
887 |
+
'</span>' .
|
888 |
+
'</td>';
|
889 |
+
if ( $ct == 3 ) {
|
890 |
+
echo( '</tr><tr>' );
|
891 |
+
$ct = 0;
|
892 |
+
}
|
893 |
+
else {
|
894 |
+
$ct++;
|
895 |
+
}
|
896 |
+
}
|
897 |
+
$idx++;
|
898 |
+
}
|
899 |
+
echo
|
900 |
+
'</tr>' .
|
901 |
+
'</table>' .
|
902 |
+
'</div>';
|
903 |
+
}
|
904 |
+
|
905 |
+
// Display the audios
|
906 |
+
if ( $audiocount && wppa_switch( 'enable_audio' ) ) {
|
907 |
+
echo
|
908 |
+
'<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >';
|
909 |
+
|
910 |
+
// Display available files
|
911 |
+
echo
|
912 |
+
'<p><b>' .
|
913 |
+
sprintf( _n( 'There is %d audio in the depot', 'There are %d audios in the depot', $audiocount, 'wp-photo-album-plus' ), $audiocount ) .
|
914 |
+
'</b></p>';
|
915 |
+
|
916 |
+
// Album to import to
|
917 |
+
echo
|
918 |
+
'<p class="hideifupdate" >' .
|
919 |
+
__( 'Album to import to:', 'wp-photo-album-plus') .
|
920 |
+
'<select name="wppa-audio-album" id="wppa-audio-album" >' .
|
921 |
+
wppa_album_select_a( array( 'path' => wppa_switch( 'hier_albsel' ),
|
922 |
+
'selected' => get_option( 'wppa-audio-album-import-'.wppa_get_user(), '0' ),
|
923 |
+
'addpleaseselect' => true,
|
924 |
+
'checkowner' => true,
|
925 |
+
'checkupload' => true
|
926 |
+
) ) .
|
927 |
+
'</select>' .
|
928 |
+
'</p>';
|
929 |
+
|
930 |
+
// Header of audio list
|
931 |
+
echo
|
932 |
+
'<table class="form-table wppa-table widefat" style="margin-bottom:0;" >' .
|
933 |
+
'<thead>' .
|
934 |
+
'<tr>' .
|
935 |
+
'<td>' .
|
936 |
+
'<input' .
|
937 |
+
' type="checkbox"' .
|
938 |
+
' id="all-audio"' .
|
939 |
+
' checked="checked"' .
|
940 |
+
' onchange="checkAll( \'all-audio\', \'.wppa-audio\' )"' .
|
941 |
+
' />' .
|
942 |
+
'<b>' .
|
943 |
+
' ' .
|
944 |
+
__( 'Check/uncheck all', 'wp-photo-album-plus') .
|
945 |
+
'</b>' .
|
946 |
+
'</td>';
|
947 |
+
|
948 |
+
// The remove box
|
949 |
+
if ( $is_sub_depot ) {
|
950 |
+
echo
|
951 |
+
'<td>' .
|
952 |
+
'<input' .
|
953 |
+
' type="checkbox"' .
|
954 |
+
' id="del-after-u"' .
|
955 |
+
' name="del-after-u"' .
|
956 |
+
' checked="checked"' .
|
957 |
+
' />' .
|
958 |
+
'<b>' .
|
959 |
+
' ' .
|
960 |
+
__( 'Remove from depot after successful import.', 'wp-photo-album-plus' ) .
|
961 |
+
'</b>' .
|
962 |
+
'</td>';
|
963 |
+
}
|
964 |
+
echo
|
965 |
+
'</tr>' .
|
966 |
+
'</thead>' .
|
967 |
+
'</table>';
|
968 |
+
|
969 |
+
// Audio list
|
970 |
+
echo
|
971 |
+
'<table class="form-table wppa-table widefat" style="margin-top:0;" >' .
|
972 |
+
'<tr>';
|
973 |
+
$ct = 0;
|
974 |
+
$idx = '0';
|
975 |
+
if ( is_array( $files ) ) foreach ( $files as $file ) {
|
976 |
+
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
977 |
+
if ( in_array( strtolower($ext), $wppa_supported_audio_extensions ) ) {
|
978 |
+
echo
|
979 |
+
'<td>' .
|
980 |
+
'<input' .
|
981 |
+
' type="checkbox"' .
|
982 |
+
' id="file-' . $idx . '"' .
|
983 |
+
' name="file-' . $idx . '"' .
|
984 |
+
' title="' . $file . '"' .
|
985 |
+
' class="wppa-audio"' .
|
986 |
+
' checked="checked"' .
|
987 |
+
' />' .
|
988 |
+
'<span' .
|
989 |
+
' id="name-file-' . $idx . '"' .
|
990 |
+
' >' .
|
991 |
+
' ' .
|
992 |
+
wppa_sanitize_file_name( basename( $file ) ) .
|
993 |
+
'</span>' .
|
994 |
+
'</td>';
|
995 |
+
if ( $ct == 3 ) {
|
996 |
+
echo '</tr><tr>';
|
997 |
+
$ct = 0;
|
998 |
+
}
|
999 |
+
else {
|
1000 |
+
$ct++;
|
1001 |
+
}
|
1002 |
+
}
|
1003 |
+
$idx++;
|
1004 |
+
}
|
1005 |
+
echo
|
1006 |
+
'</tr>' .
|
1007 |
+
'</table>' .
|
1008 |
+
'</div>';
|
1009 |
+
}
|
1010 |
+
|
1011 |
+
// Display the directories to be imported as albums. Do this in the depot only!!
|
1012 |
+
if ( $is_depot && $dircount ) {
|
1013 |
+
echo
|
1014 |
+
'<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >';
|
1015 |
+
|
1016 |
+
// Display number of dirs
|
1017 |
+
echo
|
1018 |
+
'<p><b>' .
|
1019 |
+
sprintf( _n( 'There is %d albumdirectory in the depot', 'There are %d albumdirectories in the depot', $dircount, 'wp-photo-album-plus' ), $dircount ) .
|
1020 |
+
'</b></p>';
|
1021 |
+
|
1022 |
+
// Header of dirlist
|
1023 |
+
echo
|
1024 |
+
'<table class="form-table wppa-table widefat" style="margin-bottom:0;" >' .
|
1025 |
+
'<thead>' .
|
1026 |
+
'<tr>' .
|
1027 |
+
'<td>' .
|
1028 |
+
'<input' .
|
1029 |
+
' type="checkbox"' .
|
1030 |
+
' id="all-dir"' .
|
1031 |
+
' checked="checked"' .
|
1032 |
+
' onchange="checkAll( \'all-dir\', \'.wppa-dir\' )"' .
|
1033 |
+
' />' .
|
1034 |
+
'<b>' .
|
1035 |
+
' ' .
|
1036 |
+
__( 'Check/uncheck all', 'wp-photo-album-plus') .
|
1037 |
+
'</b>' .
|
1038 |
+
'</td>' .
|
1039 |
+
'</tr>' .
|
1040 |
+
'</thead>' .
|
1041 |
+
'</table>';
|
1042 |
+
|
1043 |
+
// Dirlist
|
1044 |
+
echo
|
1045 |
+
'<table class="form-table wppa-table widefat" style="margin-top:0;" >';
|
1046 |
+
$ct = 0;
|
1047 |
+
$idx = '0';
|
1048 |
+
foreach( $files as $dir ) {
|
1049 |
+
if ( basename( $dir ) == '.' ) {}
|
1050 |
+
elseif ( basename( $dir ) == '..' ) {}
|
1051 |
+
elseif ( is_dir( $dir ) ) {
|
1052 |
+
echo
|
1053 |
+
'<tr>' .
|
1054 |
+
'<td>' .
|
1055 |
+
'<input' .
|
1056 |
+
' type="checkbox"' .
|
1057 |
+
' id="file-' . $idx . '"' .
|
1058 |
+
' name="file-' . $idx .'"' .
|
1059 |
+
' class= "wppa-dir"' .
|
1060 |
+
' checked="checked"' .
|
1061 |
+
' />' .
|
1062 |
+
' ' .
|
1063 |
+
'<b>' .
|
1064 |
+
wppa_sanitize_file_name( basename( $dir ) ) .
|
1065 |
+
'</b>';
|
1066 |
+
$subfiles = glob( $dir.'/*' );
|
1067 |
+
$subdircount = '0';
|
1068 |
+
if ( $subfiles ) {
|
1069 |
+
foreach ( $subfiles as $subfile ) {
|
1070 |
+
if ( is_dir( $subfile ) && basename( $subfile ) != '.' && basename( $subfile ) != '..' ) {
|
1071 |
+
$subdircount++;
|
1072 |
+
}
|
1073 |
+
}
|
1074 |
+
}
|
1075 |
+
$sfcount = empty( $subfiles ) ? '0' : wppa_get_photocount( $subfiles );
|
1076 |
+
echo ' ' .
|
1077 |
+
sprintf( _n( 'Contains %d file', 'Contains %d files', $sfcount, 'wp-photo-album-plus' ), $sfcount );
|
1078 |
+
if ( $subdircount ) {
|
1079 |
+
echo ' ' .
|
1080 |
+
sprintf( _n( 'and %d subdirectory', 'and %d subdirectories', $subdircount, 'wp-photo-album-plus' ), $subdircount );
|
1081 |
+
}
|
1082 |
+
'</td>' .
|
1083 |
+
'</tr>';
|
1084 |
+
}
|
1085 |
+
$idx++;
|
1086 |
+
}
|
1087 |
+
echo
|
1088 |
+
'</table>' .
|
1089 |
+
'</div>';
|
1090 |
+
}
|
1091 |
+
|
1092 |
+
// Display the csv files
|
1093 |
+
if ( $is_depot && $csvcount ) {
|
1094 |
+
echo
|
1095 |
+
'<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >';
|
1096 |
+
|
1097 |
+
// Display number of files
|
1098 |
+
echo
|
1099 |
+
'<p><b>' .
|
1100 |
+
sprintf( _n( 'There is %d .csv file in the depot', 'There are %d .csv files in the depot', $csvcount, 'wp-photo-album-plus' ), $csvcount ) .
|
1101 |
+
'</b></p>';
|
1102 |
+
|
1103 |
+
// Header of .csv file list
|
1104 |
+
echo
|
1105 |
+
'<table class="form-table wppa-table widefat" style="margin-bottom:0;" >' .
|
1106 |
+
'<thead>' .
|
1107 |
+
'<tr>' .
|
1108 |
+
'<td>' .
|
1109 |
+
'<input' .
|
1110 |
+
' type="checkbox"' .
|
1111 |
+
' id="all-csv"' .
|
1112 |
+
' checked="checked"' .
|
1113 |
+
' onchange="checkAll( \'all-csv\', \'.wppa-csv\' )"' .
|
1114 |
+
' />' .
|
1115 |
+
'<b>' .
|
1116 |
+
' ' .
|
1117 |
+
__( 'Check/uncheck all', 'wp-photo-album-plus') .
|
1118 |
+
'</b>' .
|
1119 |
+
'</td>' .
|
1120 |
+
'<td>' .
|
1121 |
+
'<input' .
|
1122 |
+
' type="checkbox"' .
|
1123 |
+
' id="del-after-c"' .
|
1124 |
+
' name="del-after-c"' .
|
1125 |
+
' checked="checked"' .
|
1126 |
+
' disabled="disabled"' .
|
1127 |
+
' />' .
|
1128 |
+
'<b>' .
|
1129 |
+
' ' .
|
1130 |
+
__( 'Remove from depot after successful import.', 'wp-photo-album-plus' ) .
|
1131 |
+
'</b>' .
|
1132 |
+
'</td>' .
|
1133 |
+
'</tr>' .
|
1134 |
+
'</thead>' .
|
1135 |
+
'</table>';
|
1136 |
+
|
1137 |
+
// CSV file list
|
1138 |
+
echo
|
1139 |
+
'<table class="form-table wppa-table widefat" style="margin-top:0;" >';
|
1140 |
+
$ct = 0;
|
1141 |
+
$idx = '0';
|
1142 |
+
foreach( $files as $csv ) {
|
1143 |
+
if ( is_file( $csv ) && strtolower( wppa_get_ext( $csv ) ) == 'csv' ) {
|
1144 |
+
echo
|
1145 |
+
'<tr>' .
|
1146 |
+
'<td>' .
|
1147 |
+
'<input' .
|
1148 |
+
' type="checkbox"' .
|
1149 |
+
' id="file-' . $idx . '"' .
|
1150 |
+
' name="file-' . $idx . '"' .
|
1151 |
+
' class="wppa-csv"' .
|
1152 |
+
' checked="checked"' .
|
1153 |
+
' />' .
|
1154 |
+
' ' .
|
1155 |
+
'<b>' .
|
1156 |
+
wppa_sanitize_file_name( basename( $csv ) ) .
|
1157 |
+
' (' . sprintf( '%5.1f', filesize( $csv ) / 1024 ) . ' kb)' .
|
1158 |
+
'</b>' .
|
1159 |
+
'</td>' .
|
1160 |
+
'</tr>';
|
1161 |
+
}
|
1162 |
+
$idx++;
|
1163 |
+
}
|
1164 |
+
echo
|
1165 |
+
'</table>' .
|
1166 |
+
'</div>';
|
1167 |
+
}
|
1168 |
+
|
1169 |
+
// The submit button
|
1170 |
+
?>
|
1171 |
+
<p>
|
1172 |
+
<script type="text/javascript">
|
1173 |
+
function wppaVfyAlbum() {
|
1174 |
+
var csvs = jQuery( '.wppa-csv' );
|
1175 |
+
if ( jQuery( '#wppa-update' ).attr( 'checked' ) != 'checked' ) {
|
1176 |
+
if ( ! parseInt( jQuery( '#wppa-photo-album' ).attr( 'value' ) ) &&
|
1177 |
+
! parseInt( jQuery( '#wppa-video-album' ).attr( 'value' ) ) &&
|
1178 |
+
! parseInt( jQuery( '#wppa-audio-album' ).attr( 'value' ) ) &&
|
1179 |
+
csvs.length == 0
|
1180 |
+
) {
|
1181 |
+
alert( 'Please select an album first' );
|
1182 |
+
return false;
|
1183 |
+
}
|
1184 |
+
}
|
1185 |
+
return true;
|
1186 |
+
}
|
1187 |
+
function wppaCheckInputVars() {
|
1188 |
+
var checks = jQuery( ':checked' );
|
1189 |
+
var nChecks = checks.length;
|
1190 |
+
var nMax = <?php echo ini_get( 'max_input_vars' ) ?>;
|
1191 |
+
if ( nMax == 0 ) nMax = 100;
|
1192 |
+
if ( nChecks > nMax ) {
|
1193 |
+
alert ( 'There are '+nChecks+' boxes checked or selected, that is more than the maximum allowed number of '+nMax );
|
1194 |
+
return false;
|
1195 |
+
}
|
1196 |
+
var dirs = jQuery( '.wppa-dir' );
|
1197 |
+
var nDirsChecked = 0;
|
1198 |
+
if ( dirs.length > 0 ) {
|
1199 |
+
var i = 0;
|
1200 |
+
while ( i < dirs.length ) {
|
1201 |
+
if ( jQuery( dirs[i] ).attr( 'checked' ) == 'checked' ) {
|
1202 |
+
nDirsChecked++;
|
1203 |
+
}
|
1204 |
+
i++;
|
1205 |
+
}
|
1206 |
+
}
|
1207 |
+
var zips = jQuery( '.wppa-zip' );
|
1208 |
+
var nZipsChecked = 0;
|
1209 |
+
if ( zips.length > 0 ) {
|
1210 |
+
var i = 0;
|
1211 |
+
while ( i < zips.length ) {
|
1212 |
+
if ( jQuery( zips[i] ).attr( 'checked' ) == 'checked' ) {
|
1213 |
+
nZipsChecked++;
|
1214 |
+
}
|
1215 |
+
i++;
|
1216 |
+
}
|
1217 |
+
}
|
1218 |
+
// If no dirs to import checked, there must be an album selected
|
1219 |
+
if ( 0 == nDirsChecked && 0 == nZipsChecked && ! wppaVfyAlbum() ) return false;
|
1220 |
+
return true;
|
1221 |
+
}
|
1222 |
+
</script>
|
1223 |
+
<input type="submit" onclick="return wppaCheckInputVars()" class="button-primary" id="submit" name="wppa-import-submit" value="<?php _e( 'Import', 'wp-photo-album-plus' ); ?>" />
|
1224 |
+
<script type="text/javascript" >
|
1225 |
+
var wppaImportRuns = false;
|
1226 |
+
function wppaDoAjaxImport() {
|
1227 |
+
wppaImportRuns = true;
|
1228 |
+
var data = '';
|
1229 |
+
data += 'wppa-update-check='+jQuery( '#wppa-update-check' ).attr( 'value' );
|
1230 |
+
data += '&wppa-photo-album='+jQuery( '#wppa-photo-album' ).attr( 'value' );
|
1231 |
+
data += '&wppa-video-album='+jQuery( '#wppa-video-album' ).attr( 'value' );
|
1232 |
+
data += '&wppa-audio-album='+jQuery( '#wppa-audio-album' ).attr( 'value' );
|
1233 |
+
data += '&wppa-watermark-file='+jQuery( '#wppa-watermark-file' ).attr( 'value' );
|
1234 |
+
data += '&wppa-watermark-pos='+jQuery( '#wppa-watermark-pos' ).attr( 'value' );
|
1235 |
+
if ( jQuery( '#cre-album' ).attr( 'checked' ) ) data += '&cre-album='+jQuery( '#cre-album' ).attr( 'value' );
|
1236 |
+
if ( jQuery( '#use-backup' ).attr( 'checked' ) ) data += '&use-backup=on'; //+jQuery( '#use-backup' ).attr( 'value' );
|
1237 |
+
if ( jQuery( '#wppa-update' ).attr( 'checked' ) ) data += '&wppa-update=on'; //+jQuery( '#wppa-update' ).attr( 'value' );
|
1238 |
+
if ( jQuery( '#wppa-nodups' ).attr( 'checked' ) ) data += '&wppa-nodups=on'; //+jQuery( '#wppa-nudups' ).attr( 'value' );
|
1239 |
+
if ( jQuery( '#del-after-p' ).attr( 'checked' ) ) data += '&del-after-p=on';
|
1240 |
+
if ( jQuery( '#del-after-f' ).attr( 'checked' ) ) data += '&del-after-f=on';
|
1241 |
+
if ( jQuery( '#del-after-v' ).attr( 'checked' ) ) data += '&del-after-v=on';
|
1242 |
+
if ( jQuery( '#del-after-u' ).attr( 'checked' ) ) data += '&del-after-u=on';
|
1243 |
+
data += '&wppa-import-submit=ajax';
|
1244 |
+
|
1245 |
+
var files = jQuery( ':checked' );
|
1246 |
+
var found = false;
|
1247 |
+
var i=0;
|
1248 |
+
var elm;
|
1249 |
+
var fulldata;
|
1250 |
+
for ( i=0; i<files.length; i++ ) {
|
1251 |
+
found = false; // assume done
|
1252 |
+
elm = files[i];
|
1253 |
+
// Is it a file checkbox?
|
1254 |
+
var temp = elm.id.split( '-' );
|
1255 |
+
if ( temp[0] != 'file' ) continue; // no
|
1256 |
+
fulldata = data+'&import-ajax-file='+elm.title;
|
1257 |
+
found = true;
|
1258 |
+
break;
|
1259 |
+
}
|
1260 |
+
// alert( data );
|
1261 |
+
if ( ! found ) {
|
1262 |
+
wppaStopAjaxImport();
|
1263 |
+
return; // nothing left
|
1264 |
+
}
|
1265 |
+
// found one, do it
|
1266 |
+
var oldhtml=jQuery( '#name-'+elm.id ).html();
|
1267 |
+
var xmlhttp = wppaGetXmlHttp();
|
1268 |
+
xmlhttp.onreadystatechange = function() {
|
1269 |
+
if ( xmlhttp.readyState == 4 ) {
|
1270 |
+
if ( xmlhttp.status!=404 ) {
|
1271 |
+
var resp = xmlhttp.responseText;
|
1272 |
+
//
|
1273 |
+
if ( resp.length == 0 ) {
|
1274 |
+
jQuery( '#name-'+elm.id ).html('<span style="color:red" >Timeout</span>' );
|
1275 |
+
wppaStopAjaxImport();
|
1276 |
+
return;
|
1277 |
+
}
|
1278 |
+
//
|
1279 |
+
if ( resp.indexOf( 'Server' ) != -1 && resp.indexOf( 'Error' ) != -1 ) {
|
1280 |
+
resp = '<span style="color:red" >Server error</span>';
|
1281 |
+
}
|
1282 |
+
jQuery( '#name-'+elm.id ).html( ' <b>'+resp+'</b>' );
|
1283 |
+
elm.checked = '';
|
1284 |
+
if ( jQuery( '#del-after-p' ).attr( 'checked' ) ||
|
1285 |
+
jQuery( '#del-after-f' ).attr( 'checked' ) ) {
|
1286 |
+
elm.disabled = 'disabled';
|
1287 |
+
elm.title = '';
|
1288 |
+
}
|
1289 |
+
if ( wppaImportRuns ) {
|
1290 |
+
setTimeout( 'wppaDoAjaxImport()', 100 );
|
1291 |
+
}
|
1292 |
+
}
|
1293 |
+
else {
|
1294 |
+
jQuery( '#name-'+elm.id ).html( ' <b>Not found</b>' );
|
1295 |
+
}
|
1296 |
+
}
|
1297 |
+
}
|
1298 |
+
var url = wppaAjaxUrl+'?action=wppa&wppa-action=import';
|
1299 |
+
xmlhttp.open( 'POST',url,true );
|
1300 |
+
xmlhttp.setRequestHeader( "Content-type","application/x-www-form-urlencoded" );
|
1301 |
+
xmlhttp.send( fulldata );
|
1302 |
+
jQuery( '#name-'+elm.id ).html( ' <b style="color:blue" >' + '<?php _e( 'Working...', 'wp-photo-album-plus' ) ?>' + '</b>' );
|
1303 |
+
jQuery( '#wppa-start-ajax' ).css( 'display', 'none' );
|
1304 |
+
jQuery( '#wppa-stop-ajax' ).css( 'display', 'inline' );
|
1305 |
+
}
|
1306 |
+
function wppaStopAjaxImport() {
|
1307 |
+
wppaImportRuns = false;
|
1308 |
+
jQuery( '#wppa-start-ajax' ).css( 'display', 'inline' );
|
1309 |
+
jQuery( '#wppa-stop-ajax' ).css( 'display', 'none' );
|
1310 |
+
}
|
1311 |
+
</script>
|
1312 |
+
<?php if ( ( $photocount || $videocount || $audiocount ) && ! $albumcount && ! $dircount && ! $zipcount ) { ?>
|
1313 |
+
<input id="wppa-start-ajax" type="button" onclick="if ( wppaVfyAlbum() ) { wppaDoAjaxImport() }" class="button-secundary" value="<?php esc_attr( _e( 'Start Ajax Import', 'wp-photo-album-plus' ) ) ?>" />
|
1314 |
+
<input id="wppa-stop-ajax" style="display:none;" type="button" onclick="wppaStopAjaxImport()" class="button-secundary" value="<?php esc_attr( _e( 'Stop Ajax Import', 'wp-photo-album-plus' ) ) ?>" />
|
1315 |
+
<?php } ?>
|
1316 |
+
</p>
|
1317 |
+
</form>
|
1318 |
+
|
1319 |
+
<?php }
|
1320 |
+
else {
|
1321 |
+
if ( $source_type == 'local' ) {
|
1322 |
+
wppa_ok_message( __( 'There are no importable files found in directory:', 'wp-photo-album-plus').' '.$source );
|
1323 |
+
}
|
1324 |
+
else {
|
1325 |
+
wppa_ok_message( __( 'There are no photos found or left to process at url:', 'wp-photo-album-plus').' '.$source_url );
|
1326 |
+
}
|
1327 |
+
}
|
1328 |
+
echo '<br /><b>';
|
1329 |
+
_e( 'You can import the following file types:', 'wp-photo-album-plus' );
|
1330 |
+
echo '</b><br />';
|
1331 |
+
if ( PHP_VERSION_ID >= 50207 ) {
|
1332 |
+
echo '<br />';
|
1333 |
+
_e( 'Compressed file types: .zip', 'wp-photo-album-plus' );
|
1334 |
+
}
|
1335 |
+
if ( true ) {
|
1336 |
+
echo '<br />';
|
1337 |
+
_e( 'Photo file types:', 'wp-photo-album-plus' );
|
1338 |
+
foreach ( $wppa_supported_photo_extensions as $ext ) {
|
1339 |
+
echo ' .'.$ext;
|
1340 |
+
}
|
1341 |
+
}
|
1342 |
+
if ( wppa_switch( 'enable_video' ) ) {
|
1343 |
+
echo '<br />';
|
1344 |
+
_e( 'Video file types:', 'wp-photo-album-plus' );
|
1345 |
+
foreach ( $wppa_supported_video_extensions as $ext ) {
|
1346 |
+
echo ' .'.$ext;
|
1347 |
+
}
|
1348 |
+
}
|
1349 |
+
if ( wppa_switch( 'enable_audio' ) ) {
|
1350 |
+
echo '<br />';
|
1351 |
+
_e( 'Audio file types:', 'wp-photo-album-plus' );
|
1352 |
+
foreach ( $wppa_supported_audio_extensions as $ext ) {
|
1353 |
+
echo ' .'.$ext;
|
1354 |
+
}
|
1355 |
+
}
|
1356 |
+
echo '<br />';
|
1357 |
+
_e( 'WPPA+ file types: .amf .pmf', 'wp-photo-album-plus' );
|
1358 |
+
echo '<br />';
|
1359 |
+
_e( 'Directories with optional subdirs containig photos', 'wp-photo-album-plus' );
|
1360 |
+
echo '<br />';
|
1361 |
+
_e( 'Custom data files of type .csv', 'wp-photo-album-plus' );
|
1362 |
+
echo '<br /><br />';
|
1363 |
+
_e( 'Your depot directory is:', 'wp-photo-album-plus' );
|
1364 |
+
echo '<b> .../' . WPPA_DEPOT . '/</b>';
|
1365 |
+
|
1366 |
+
if ( wppa( 'continue' ) ) {
|
1367 |
+
wppa_warning_message( __( 'Trying to continue...', 'wp-photo-album-plus') );
|
1368 |
+
echo '<script type="text/javascript">document.location=\''.get_admin_url().'admin.php?page=wppa_import_photos&continue&nonce='.wp_create_nonce( 'dirimport' ).'\';</script>';
|
1369 |
+
}
|
1370 |
+
|
1371 |
+
echo
|
1372 |
+
'</div><!-- .wrap -->';
|
1373 |
+
}
|
1374 |
+
|
1375 |
+
// get array of files to import
|
1376 |
+
function wppa_get_import_files() {
|
1377 |
+
|
1378 |
+
// Init
|
1379 |
+
$user = wppa_get_user();
|
1380 |
+
$source_type = get_option( 'wppa_import_source_type_'.$user, 'local' );
|
1381 |
+
$files = array();
|
1382 |
+
|
1383 |
+
// Ajax? one file
|
1384 |
+
if ( isset ( $_POST['import-ajax-file'] ) ) {
|
1385 |
+
$files = array( $_POST['import-ajax-file'] );
|
1386 |
+
}
|
1387 |
+
|
1388 |
+
// Dispatch on source type local/remote
|
1389 |
+
elseif ( $source_type == 'local' ) {
|
1390 |
+
$source = get_option( 'wppa_import_source_'.$user, WPPA_DEPOT_PATH );
|
1391 |
+
$source_path = $source; // Filesystem
|
1392 |
+
$files = glob( $source_path . '/*' );
|
1393 |
+
}
|
1394 |
+
else { // remote
|
1395 |
+
$max_tries = get_option( 'wppa_import_remote_max_'.$user, '10' );
|
1396 |
+
$setting = get_option( 'wppa_import_source_url_'.$user, 'http://' );
|
1397 |
+
$pattern = '/src=".*?"/';
|
1398 |
+
|
1399 |
+
// Is it a photofile in a wppa tree filestructure?
|
1400 |
+
$old_setting = $setting;
|
1401 |
+
|
1402 |
+
// assume not
|
1403 |
+
if ( is_array( @ getimagesize( $setting ) ) ) {
|
1404 |
+
wppa( 'is_wppa_tree', false );
|
1405 |
+
}
|
1406 |
+
|
1407 |
+
// though?
|
1408 |
+
else {
|
1409 |
+
$setting = wppa_expand_tree_path( $old_setting );
|
1410 |
+
if ( is_array( @ getimagesize( $setting ) ) ) {
|
1411 |
+
wppa( 'is_wppa_tree', true );
|
1412 |
+
}
|
1413 |
+
}
|
1414 |
+
|
1415 |
+
// Is it a photofile?
|
1416 |
+
if ( is_array( @ getimagesize( $setting ) ) ) { // image uri
|
1417 |
+
$files = array( $setting );
|
1418 |
+
$pid = wppa_strip_ext( basename( $old_setting ) );
|
1419 |
+
if ( is_numeric( $pid ) ) {
|
1420 |
+
$tries = 1;
|
1421 |
+
$before = substr( $old_setting, 0, strpos( $old_setting, $pid) );
|
1422 |
+
while ( $tries < $max_tries ) {
|
1423 |
+
$tries++;
|
1424 |
+
$pid++;
|
1425 |
+
if ( wppa( 'is_wppa_tree' ) ) {
|
1426 |
+
$files[] = $before . wppa_expand_id($pid) . '.jpg';
|
1427 |
+
}
|
1428 |
+
else {
|
1429 |
+
$files[] = $before . $pid . '.jpg';
|
1430 |
+
}
|
1431 |
+
}
|
1432 |
+
}
|
1433 |
+
}
|
1434 |
+
|
1435 |
+
// is it a page url
|
1436 |
+
else {
|
1437 |
+
$files = get_option( 'wppa_import_source_url_found_'.$user, false );
|
1438 |
+
if ( $files === false ) {
|
1439 |
+
|
1440 |
+
// Init
|
1441 |
+
$files = array();
|
1442 |
+
|
1443 |
+
// Get page content
|
1444 |
+
$curl = curl_init();
|
1445 |
+
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
|
1446 |
+
curl_setopt( $curl, CURLOPT_URL, $setting );
|
1447 |
+
$contents = curl_exec( $curl );
|
1448 |
+
curl_close( $curl );
|
1449 |
+
|
1450 |
+
// Process result
|
1451 |
+
if ( $contents ) {
|
1452 |
+
|
1453 |
+
// Preprocess
|
1454 |
+
$contents = str_replace( '\'', '"', $contents );
|
1455 |
+
|
1456 |
+
// Find matches
|
1457 |
+
preg_match_all( $pattern, $contents, $matches, PREG_PATTERN_ORDER );
|
1458 |
+
if ( is_array( $matches[0] ) ) {
|
1459 |
+
|
1460 |
+
// Sort
|
1461 |
+
sort( $matches[0] );
|
1462 |
+
|
1463 |
+
// Copy to $files, skipping dups
|
1464 |
+
$val = '';
|
1465 |
+
$count = 0;
|
1466 |
+
$sfxs = array( 'jpg', 'jpeg', 'gif', 'png', 'JPG', 'JPEG', 'GIF', 'PNG' );
|
1467 |
+
foreach ( array_keys( $matches[0] ) as $idx ) {
|
1468 |
+
if ( $matches[0][$idx] != $val ) {
|
1469 |
+
$val = $matches[0][$idx];
|
1470 |
+
// Post process found item
|
1471 |
+
$match = substr( $matches[0][$idx], 5 );
|
1472 |
+
$matchpos = strpos( $contents, $match );
|
1473 |
+
$match = trim( $match, '"' );
|
1474 |
+
if ( strpos( $match, '?' ) ) $match = substr( $match, 0, strpos( $match, '?' ) );
|
1475 |
+
$match = str_replace( '/uploads/wppa/thumbs/', '/uploads/wppa/', $match );
|
1476 |
+
$sfx = wppa_get_ext( $match );
|
1477 |
+
if ( in_array( $sfx, $sfxs ) ) {
|
1478 |
+
// Save it
|
1479 |
+
$count++;
|
1480 |
+
if ( $count <= $max_tries ) {
|
1481 |
+
$files[] = $match;
|
1482 |
+
}
|
1483 |
+
}
|
1484 |
+
}
|
1485 |
+
}
|
1486 |
+
}
|
1487 |
+
}
|
1488 |
+
update_option( 'wppa_import_source_url_found_'.$user, $files );
|
1489 |
+
}
|
1490 |
+
}
|
1491 |
+
}
|
1492 |
+
|
1493 |
+
// Remove non originals
|
1494 |
+
if ( is_array( $files ) ) foreach ( array_keys( $files ) as $key ) {
|
1495 |
+
if ( ! wppa_is_orig( $files[$key] ) ) {
|
1496 |
+
unset ( $files[$key] );
|
1497 |
+
}
|
1498 |
+
}
|
1499 |
+
|
1500 |
+
// Sort to keep synchronicity when doing ajax import
|
1501 |
+
if ( is_array( $files ) ) sort( $files );
|
1502 |
+
|
1503 |
+
// Done, return result
|
1504 |
+
return $files;
|
1505 |
+
}
|
1506 |
+
|
1507 |
+
|
1508 |
+
|
1509 |
+
// Send emails after backend upload
|
1510 |
+
function wppa_backend_upload_mail( $id, $alb, $name ) {
|
1511 |
+
|
1512 |
+
$owner = wppa_get_user();
|
1513 |
+
if ( $owner == 'admin' ) return; // Admin does not send mails to himself
|
1514 |
+
|
1515 |
+
if ( wppa_switch( 'upload_backend_notify' ) ) {
|
1516 |
+
$to = get_bloginfo( 'admin_email' );
|
1517 |
+
$subj = sprintf( __( 'New photo uploaded: %s', 'wp-photo-album-plus'), wppa_sanitize_file_name( $name ) );
|
1518 |
+
$cont['0'] = sprintf( __( 'User %1$s uploaded photo %2$s into album %3$s', 'wp-photo-album-plus'), $owner, $id, wppa_get_album_name( $alb ) );
|
1519 |
+
if ( wppa_switch( 'upload_moderate' ) && !current_user_can( 'wppa_admin' ) ) {
|
1520 |
+
$cont['1'] = __( 'This upload requires moderation', 'wp-photo-album-plus' );
|
1521 |
+
$cont['2'] = '<a href="'.get_admin_url().'admin.php?page=wppa_admin_menu&tab=pmod&photo='.$id.'" >'.__( 'Moderate manage photo', 'wp-photo-album-plus').'</a>';
|
1522 |
+
}
|
1523 |
+
else {
|
1524 |
+
$cont['1'] = __( 'Details:', 'wp-photo-album-plus' );
|
1525 |
+
$cont['1'] .= ' <a href="'.get_admin_url().'admin.php?page=wppa_admin_menu&tab=pmod&photo='.$id.'" >'.__( 'Manage photo', 'wp-photo-album-plus').'</a>';
|
1526 |
+
}
|
1527 |
+
wppa_send_mail( $to, $subj, $cont, $id );
|
1528 |
+
}
|
1529 |
+
}
|
1530 |
+
|
1531 |
+
// Do the import photos
|
1532 |
+
function wppa_import_photos( $delp = false, $dela = false, $delz = false, $delv = false, $delu = false, $delc = false, $delf = false ) {
|
1533 |
+
global $wpdb;
|
1534 |
+
global $warning_given;
|
1535 |
+
global $wppa_supported_photo_extensions;
|
1536 |
+
global $wppa_supported_video_extensions;
|
1537 |
+
global $wppa_supported_audio_extensions;
|
1538 |
+
|
1539 |
+
$warning_given = false;
|
1540 |
+
|
1541 |
+
// Get this users current source directory setting
|
1542 |
+
$user = wppa_get_user();
|
1543 |
+
$source_type = get_option( 'wppa_import_source_type_'.$user, 'local' );
|
1544 |
+
if ( $source_type == 'remote' ) wppa( 'is_remote', true );
|
1545 |
+
$source = get_option( 'wppa_import_source_'.$user, WPPA_DEPOT_PATH );
|
1546 |
+
|
1547 |
+
$depot = WPPA_ABSPATH . $source; // Filesystem
|
1548 |
+
$depoturl = get_bloginfo( 'wpurl' ).'/'.$source; // url
|
1549 |
+
|
1550 |
+
// See what's in there
|
1551 |
+
$files = wppa_get_import_files();
|
1552 |
+
|
1553 |
+
// First extract zips if our php version is ok
|
1554 |
+
$idx='0';
|
1555 |
+
$zcount = 0;
|
1556 |
+
if ( PHP_VERSION_ID >= 50207 ) {
|
1557 |
+
foreach( $files as $zipfile ) {
|
1558 |
+
if ( isset( $_POST['file-'.$idx] ) ) {
|
1559 |
+
$ext = strtolower( substr( strrchr( $zipfile, "." ), 1 ) );
|
1560 |
+
|
1561 |
+
if ( $ext == 'zip' ) {
|
1562 |
+
$err = wppa_extract( $zipfile, $delz );
|
1563 |
+
if ( $err == '0' ) $zcount++;
|
1564 |
+
} // if ext = zip
|
1565 |
+
} // if isset
|
1566 |
+
$idx++;
|
1567 |
+
} // foreach
|
1568 |
+
}
|
1569 |
+
|
1570 |
+
// Now see if albums must be created
|
1571 |
+
$idx='0';
|
1572 |
+
$acount = 0;
|
1573 |
+
foreach( $files as $album ) {
|
1574 |
+
if ( isset( $_POST['file-'.$idx] ) ) {
|
1575 |
+
$ext = strtolower( substr( strrchr( $album, "." ), 1 ) );
|
1576 |
+
if ( $ext == 'amf' ) {
|
1577 |
+
$name = '';
|
1578 |
+
$desc = '';
|
1579 |
+
$aord = '0';
|
1580 |
+
$parent = '0';
|
1581 |
+
$porder = '0';
|
1582 |
+
$owner = '';
|
1583 |
+
$handle = fopen( $album, "r" );
|
1584 |
+
if ( $handle ) {
|
1585 |
+
$buffer = fgets( $handle, 4096 );
|
1586 |
+
while ( !feof( $handle ) ) {
|
1587 |
+
$tag = substr( $buffer, 0, 5 );
|
1588 |
+
$len = strlen( $buffer ) - 6; // substract 5 for label and one for eol
|
1589 |
+
$data = substr( $buffer, 5, $len );
|
1590 |
+
switch( $tag ) {
|
1591 |
+
case 'name=':
|
1592 |
+
$name = $data;
|
1593 |
+
break;
|
1594 |
+
case 'desc=':
|
1595 |
+
$desc = wppa_txt_to_nl( $data );
|
1596 |
+
break;
|
1597 |
+
case 'aord=':
|
1598 |
+
if ( is_numeric( $data ) ) $aord = $data;
|
1599 |
+
break;
|
1600 |
+
case 'prnt=':
|
1601 |
+
if ( $data == __( '--- none ---', 'wp-photo-album-plus') ) $parent = '0';
|
1602 |
+
elseif ( $data == __( '--- separate ---', 'wp-photo-album-plus') ) $parent = '-1';
|
1603 |
+
else {
|
1604 |
+
$prnt = wppa_get_album_id( $data );
|
1605 |
+
if ( $prnt != '' ) {
|
1606 |
+
$parent = $prnt;
|
1607 |
+
}
|
1608 |
+
else {
|
1609 |
+
$parent = '0';
|
1610 |
+
wppa_warning_message( __( 'Unknown parent album:', 'wp-photo-album-plus').' '.$data.' '.__( '--- none --- used.', 'wp-photo-album-plus') );
|
1611 |
+
}
|
1612 |
+
}
|
1613 |
+
break;
|
1614 |
+
case 'pord=':
|
1615 |
+
if ( is_numeric( $data ) ) $porder = $data;
|
1616 |
+
break;
|
1617 |
+
case 'ownr=':
|
1618 |
+
$owner = $data;
|
1619 |
+
break;
|
1620 |
+
}
|
1621 |
+
$buffer = fgets( $handle, 4096 );
|
1622 |
+
} // while !foef
|
1623 |
+
fclose( $handle );
|
1624 |
+
if ( wppa_get_album_id( $name ) != '' ) {
|
1625 |
+
wppa_warning_message( 'Album already exists '.stripslashes( $name ) );
|
1626 |
+
if ( $dela ) unlink( $album );
|
1627 |
+
}
|
1628 |
+
else {
|
1629 |
+
$id = basename( $album );
|
1630 |
+
$id = substr( $id, 0, strpos( $id, '.' ) );
|
1631 |
+
$id = wppa_create_album_entry( array ( 'id' => $id,
|
1632 |
+
'name' => stripslashes( $name ),
|
1633 |
+
'description' => stripslashes( $desc ),
|
1634 |
+
'a_order' => $aord,
|
1635 |
+
'a_parent' => $parent,
|
1636 |
+
'p_order_by' => $porder,
|
1637 |
+
'owner' => $owner
|
1638 |
+
) );
|
1639 |
+
|
1640 |
+
if ( $id === false ) {
|
1641 |
+
wppa_error_message( __( 'Could not create album.', 'wp-photo-album-plus') );
|
1642 |
+
}
|
1643 |
+
else {
|
1644 |
+
//$id = wppa_get_album_id( $name );
|
1645 |
+
wppa_set_last_album( $id );
|
1646 |
+
wppa_index_add( 'album', $id );
|
1647 |
+
wppa_ok_message( __( 'Album #', 'wp-photo-album-plus') . ' ' . $id . ': '.stripslashes( $name ).' ' . __( 'Added.', 'wp-photo-album-plus') );
|
1648 |
+
if ( $dela ) unlink( $album );
|
1649 |
+
$acount++;
|
1650 |
+
wppa_clear_cache();
|
1651 |
+
wppa_flush_treecounts( $id );
|
1652 |
+
} // album added
|
1653 |
+
} // album did not exist
|
1654 |
+
} // if handle ( file open )
|
1655 |
+
} // if its an album
|
1656 |
+
} // if isset
|
1657 |
+
$idx++;
|
1658 |
+
} // foreach file
|
1659 |
+
|
1660 |
+
// Now the photos
|
1661 |
+
$idx = '0';
|
1662 |
+
$pcount = '0';
|
1663 |
+
$totpcount = '0';
|
1664 |
+
|
1665 |
+
// find album id
|
1666 |
+
if ( isset( $_POST['cre-album'] ) ) { // use album ngg gallery name for ngg conversion
|
1667 |
+
$album = wppa_get_album_id( strip_tags( $_POST['cre-album'] ) );
|
1668 |
+
if ( ! $album ) { // the album does not exist yet, create it
|
1669 |
+
$name = strip_tags( $_POST['cre-album'] );
|
1670 |
+
$desc = sprintf( __( 'This album has been converted from ngg gallery %s', 'wp-photo-album-plus'), $name );
|
1671 |
+
$uplim = '0/0'; // Unlimited not to destroy the conversion process!!
|
1672 |
+
$album = wppa_create_album_entry( array ( 'name' => $name,
|
1673 |
+
'description' => $desc,
|
1674 |
+
'upload_limit' => $uplim
|
1675 |
+
) );
|
1676 |
+
if ( $album === false ) {
|
1677 |
+
wppa_error_message( __( 'Could not create album.', 'wp-photo-album-plus').'<br/>Query = '.$query );
|
1678 |
+
wp_die( 'Sorry, cannot continue' );
|
1679 |
+
}
|
1680 |
+
}
|
1681 |
+
}
|
1682 |
+
elseif ( isset( $_POST['wppa-photo-album'] ) ) {
|
1683 |
+
$album = $_POST['wppa-photo-album'];
|
1684 |
+
}
|
1685 |
+
else $album = '0';
|
1686 |
+
|
1687 |
+
// Report starting process
|
1688 |
+
wppa_ok_message( __( 'Processing files, please wait...', 'wp-photo-album-plus').' '.__( 'If the line of dots stops growing or your browser reports Ready, your server has given up. In that case: try again', 'wp-photo-album-plus').' <a href="'.wppa_dbg_url( get_admin_url().'admin.php?page=wppa_import_photos' ).'">'.__( 'here.', 'wp-photo-album-plus').'</a>' );
|
1689 |
+
|
1690 |
+
// Do them all
|
1691 |
+
foreach ( array_keys( $files ) as $file_idx ) {
|
1692 |
+
$unsanitized_path_name = $files[$file_idx];
|
1693 |
+
$file = $files[$file_idx];
|
1694 |
+
wppa_is_wppa_tree( $file ); // Sets wppa( 'is_wppa_tree' )
|
1695 |
+
if ( isset( $_POST['use-backup'] ) && is_file( $file.'_backup' ) ) {
|
1696 |
+
$file = $file.'_backup';
|
1697 |
+
}
|
1698 |
+
$file = wppa_sanitize_file_name( $file );
|
1699 |
+
if ( isset( $_POST['file-'.$idx] ) || wppa( 'ajax' ) ) {
|
1700 |
+
if ( wppa( 'is_wppa_tree' ) ) {
|
1701 |
+
if ( wppa( 'ajax' ) ) wppa( 'ajax_import_files', basename( wppa_compress_tree_path( $file ) ) );
|
1702 |
+
}
|
1703 |
+
else {
|
1704 |
+
if ( wppa( 'ajax' ) ) wppa( 'ajax_import_files', basename( $file ) );
|
1705 |
+
}
|
1706 |
+
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
1707 |
+
$ext = str_replace( '_backup', '', $ext );
|
1708 |
+
if ( in_array( $ext, $wppa_supported_photo_extensions ) ) {
|
1709 |
+
|
1710 |
+
// See if a metafile exists
|
1711 |
+
//$meta = substr( $file, 0, strlen( $file ) - 3 ).'pmf';
|
1712 |
+
$meta = wppa_strip_ext( $unsanitized_path_name ) . '.PMF';
|
1713 |
+
if ( ! is_file( $meta ) ) {
|
1714 |
+
$meta = wppa_strip_ext( $unsanitized_path_name ) . '.pmf';
|
1715 |
+
}
|
1716 |
+
|
1717 |
+
// find all data: name, desc, porder form metafile
|
1718 |
+
if ( is_file( $meta ) ) {
|
1719 |
+
$alb = wppa_get_album_id( wppa_get_meta_album( $meta ) );
|
1720 |
+
$name = wppa_get_meta_name( $meta );
|
1721 |
+
$desc = wppa_txt_to_nl( wppa_get_meta_desc( $meta ) );
|
1722 |
+
$porder = wppa_get_meta_porder( $meta );
|
1723 |
+
$linkurl = wppa_get_meta_linkurl( $meta );
|
1724 |
+
$linktitle = wppa_get_meta_linktitle( $meta );
|
1725 |
+
}
|
1726 |
+
else {
|
1727 |
+
$alb = $album; // default album
|
1728 |
+
$name = ''; // default name
|
1729 |
+
$desc = ''; // default description
|
1730 |
+
$porder = '0'; // default p_order
|
1731 |
+
$linkurl = '';
|
1732 |
+
$linktitle = '';
|
1733 |
+
}
|
1734 |
+
|
1735 |
+
// If there is a video or audio with the same name, this is the poster.
|
1736 |
+
$is_poster = wppa_file_is_in_album( wppa_strip_ext( basename( $file ) ) . '.xxx', $alb );
|
1737 |
+
if ( $is_poster ) {
|
1738 |
+
|
1739 |
+
// Delete possible poster sourcefile
|
1740 |
+
wppa_delete_source( basename( $file ), $alb );
|
1741 |
+
|
1742 |
+
// Remove possible existing posters, the file-extension may be different as before
|
1743 |
+
$old_photo = wppa_strip_ext( wppa_get_photo_path( $is_poster ) );
|
1744 |
+
$old_thumb = wppa_strip_ext( wppa_get_thumb_path( $is_poster ) );
|
1745 |
+
foreach ( $wppa_supported_photo_extensions as $pext ) {
|
1746 |
+
@ unlink( $old_photo . '.' . $pext );
|
1747 |
+
@ unlink( $old_thumb . '.' . $pext );
|
1748 |
+
}
|
1749 |
+
|
1750 |
+
// Clear sizes on db
|
1751 |
+
wppa_update_photo( array( 'thumbx' => '0',
|
1752 |
+
'thumby' => '0',
|
1753 |
+
'photox' => '0',
|
1754 |
+
'photoy' => '0'
|
1755 |
+
));
|
1756 |
+
|
1757 |
+
// Make new files
|
1758 |
+
$bret = wppa_make_the_photo_files( $file, $is_poster, strtolower( wppa_get_ext( basename( $file ) ) ) );
|
1759 |
+
if ( $bret ) { // Success
|
1760 |
+
if ( wppa( 'ajax' ) ) wppa( 'ajax_import_files_done', true );
|
1761 |
+
wppa_save_source( $file, basename( $file ), $alb );
|
1762 |
+
wppa_make_o1_source( $is_poster );
|
1763 |
+
$pcount++;
|
1764 |
+
$totpcount += $bret;
|
1765 |
+
if ( $delp ) {
|
1766 |
+
unlink( $file );
|
1767 |
+
}
|
1768 |
+
}
|
1769 |
+
else { // Failed
|
1770 |
+
if ( ! wppa( 'ajax' ) ) {
|
1771 |
+
wppa_error_message('Failed to add poster for item '.$is_poster);
|
1772 |
+
}
|
1773 |
+
if ( $delf ) {
|
1774 |
+
unlink( $file );
|
1775 |
+
}
|
1776 |
+
}
|
1777 |
+
}
|
1778 |
+
|
1779 |
+
// Update the photo ?
|
1780 |
+
elseif ( isset( $_POST['wppa-update'] ) ) {
|
1781 |
+
|
1782 |
+
if ( wppa( 'is_wppa_tree' ) ) {
|
1783 |
+
$tmp = explode( '/wppa/', $file );
|
1784 |
+
$name = str_replace( '/', '', $tmp[1] );
|
1785 |
+
}
|
1786 |
+
|
1787 |
+
$iret = wppa_update_photo_files( $unsanitized_path_name, $name );
|
1788 |
+
if ( $iret ) {
|
1789 |
+
if ( wppa( 'ajax' ) ) wppa( 'ajax_import_files_done', true );
|
1790 |
+
$pcount++;
|
1791 |
+
$totpcount += $iret;
|
1792 |
+
if ( $delp ) {
|
1793 |
+
unlink( $unsanitized_path_name );
|
1794 |
+
}
|
1795 |
+
}
|
1796 |
+
else {
|
1797 |
+
if ( $delf ) {
|
1798 |
+
unlink( $unsanitized_path_name );
|
1799 |
+
}
|
1800 |
+
}
|
1801 |
+
}
|
1802 |
+
|
1803 |
+
// Insert the photo
|
1804 |
+
else {
|
1805 |
+
if ( is_numeric( $alb ) && $alb != '0' ) {
|
1806 |
+
if ( wppa( 'is_wppa_tree' ) ) {
|
1807 |
+
$tmp = explode( '/wppa/', $file );
|
1808 |
+
$id = str_replace( '/', '', $tmp[1] );
|
1809 |
+
$name = $id;
|
1810 |
+
}
|
1811 |
+
else {
|
1812 |
+
$id = basename( $file );
|
1813 |
+
}
|
1814 |
+
if ( wppa_switch( 'void_dups' ) && wppa_file_is_in_album( $id, $alb ) ) {
|
1815 |
+
wppa_warning_message( sprintf( __( 'Photo %s already exists in album %s. (1)', 'wp-photo-album-plus'), $id, $alb ) );
|
1816 |
+
wppa( 'ajax_import_files_error', __( 'Duplicate', 'wp-photo-album-plus') );
|
1817 |
+
if ( $delf ) {
|
1818 |
+
unlink( $file );
|
1819 |
+
}
|
1820 |
+
}
|
1821 |
+
else {
|
1822 |
+
$id = substr( $id, 0, strpos( $id, '.' ) );
|
1823 |
+
if ( !is_numeric( $id ) || ! wppa_is_id_free( 'photo', $id ) ) $id = 0;
|
1824 |
+
if ( wppa_insert_photo( $unsanitized_path_name, $alb, stripslashes( $name ), stripslashes( $desc ), $porder, $id, stripslashes( $linkurl ), stripslashes( $linktitle ) ) ) {
|
1825 |
+
if ( wppa( 'ajax' ) ) {
|
1826 |
+
wppa( 'ajax_import_files_done', true );
|
1827 |
+
}
|
1828 |
+
$pcount++;
|
1829 |
+
if ( $delp ) {
|
1830 |
+
unlink( $unsanitized_path_name );
|
1831 |
+
if ( is_file( $meta ) ) unlink( $meta );
|
1832 |
+
}
|
1833 |
+
}
|
1834 |
+
else {
|
1835 |
+
wppa_error_message( __( 'Error inserting photo', 'wp-photo-album-plus') . ' ' . basename( $file ) . '.' );
|
1836 |
+
if ( $delf ) {
|
1837 |
+
unlink( $unsanitized_path_name );
|
1838 |
+
}
|
1839 |
+
}
|
1840 |
+
}
|
1841 |
+
}
|
1842 |
+
else {
|
1843 |
+
wppa_error_message( sprintf( __( 'Error inserting photo %s, unknown or non existent album.', 'wp-photo-album-plus'), basename( $file ) ) );
|
1844 |
+
}
|
1845 |
+
} // Insert
|
1846 |
+
}
|
1847 |
+
}
|
1848 |
+
$idx++;
|
1849 |
+
if ( $source_type == 'remote' ) unset( $files[$file_idx] );
|
1850 |
+
if ( wppa_is_time_up() ) {
|
1851 |
+
wppa_warning_message( sprintf( __( 'Time out. %s photos imported. Please restart this operation.', 'wp-photo-album-plus'), $pcount ) );
|
1852 |
+
wppa_set_last_album( $album );
|
1853 |
+
if ( $source_type == 'remote' ) update_option( 'wppa_import_source_url_found_'.$user, $files );
|
1854 |
+
return;
|
1855 |
+
}
|
1856 |
+
} // foreach $files
|
1857 |
+
if ( $source_type == 'remote' ) update_option( 'wppa_import_source_url_found_'.$user, $files );
|
1858 |
+
|
1859 |
+
// Now the dirs to album imports
|
1860 |
+
|
1861 |
+
$idx = '0';
|
1862 |
+
$dircount = '0';
|
1863 |
+
global $photocount;
|
1864 |
+
$photocount = '0';
|
1865 |
+
$iret = true;
|
1866 |
+
|
1867 |
+
foreach ( $files as $file ) {
|
1868 |
+
if ( basename( $file ) != '.' && basename( $file ) != '..' && ( isset( $_POST['file-'.$idx] ) || isset( $_GET['continue'] ) ) ) {
|
1869 |
+
if ( is_dir( $file ) ) {
|
1870 |
+
$iret = wppa_import_dir_to_album( $file, '0' );
|
1871 |
+
if ( wppa_is_time_up() && wppa_switch( 'auto_continue' ) ) {
|
1872 |
+
wppa( 'continue', 'continue' );
|
1873 |
+
}
|
1874 |
+
$dircount++;
|
1875 |
+
}
|
1876 |
+
}
|
1877 |
+
$idx++;
|
1878 |
+
if ( $iret == false ) break; // Time out
|
1879 |
+
}
|
1880 |
+
|
1881 |
+
// Now the video files
|
1882 |
+
$videocount = '0';
|
1883 |
+
$alb = isset( $_POST['wppa-video-album'] ) ? $_POST['wppa-video-album'] : '0';
|
1884 |
+
if ( wppa( 'ajax' ) && ! $alb ) {
|
1885 |
+
wppa( 'ajax_import_files_error', __( 'Unknown album', 'wp-photo-album-plus' ) );
|
1886 |
+
}
|
1887 |
+
else foreach ( array_keys( $files ) as $idx ) {
|
1888 |
+
$file = $files[$idx];
|
1889 |
+
if ( isset( $_POST['file-'.$idx] ) || wppa( 'ajax' ) ) {
|
1890 |
+
if ( wppa( 'ajax' ) ) wppa( 'ajax_import_files', wppa_sanitize_file_name( basename( $file ) ) ); /* */
|
1891 |
+
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
1892 |
+
if ( in_array( $ext, $wppa_supported_video_extensions ) ) {
|
1893 |
+
if ( is_numeric( $alb ) && $alb != '0' ) {
|
1894 |
+
|
1895 |
+
// Do we have this filename with ext xxx in this album?
|
1896 |
+
$filename = wppa_strip_ext( basename( $file ) ).'.xxx';
|
1897 |
+
$id = wppa_file_is_in_album( $filename, $alb );
|
1898 |
+
|
1899 |
+
// Or maybe the poster is already there
|
1900 |
+
foreach ( $wppa_supported_photo_extensions as $pext ) {
|
1901 |
+
if ( ! $id ) {
|
1902 |
+
$id = wppa_file_is_in_album( str_replace( 'xxx', $pext, $filename ), $alb );
|
1903 |
+
}
|
1904 |
+
}
|
1905 |
+
|
1906 |
+
// This filename already exists: is the poster. Fix the filename in the photo info
|
1907 |
+
if ( $id ) {
|
1908 |
+
$fname = wppa_get_photo_item( $id, 'filename' );
|
1909 |
+
$fname = wppa_strip_ext( $fname ) . '.xxx';
|
1910 |
+
|
1911 |
+
// Fix filename and ext in photo info
|
1912 |
+
wppa_update_photo( array( 'id' => $id, 'filename' => $fname, 'ext' => 'xxx' ) );
|
1913 |
+
}
|
1914 |
+
|
1915 |
+
// Add new entry
|
1916 |
+
if ( ! $id ) {
|
1917 |
+
$id = wppa_create_photo_entry( array( 'album' => $alb, 'filename' => $filename, 'ext' => 'xxx', 'name' => wppa_strip_ext( $filename ) ) );
|
1918 |
+
wppa_flush_treecounts( $alb );
|
1919 |
+
}
|
1920 |
+
|
1921 |
+
// Add video filetype
|
1922 |
+
$newpath = wppa_strip_ext( wppa_get_photo_path( $id ) ).'.'.$ext;
|
1923 |
+
copy( $file, $newpath );
|
1924 |
+
if ( $delv ) unlink( $file );
|
1925 |
+
if ( wppa( 'ajax' ) ) {
|
1926 |
+
wppa( 'ajax_import_files_done', true );
|
1927 |
+
}
|
1928 |
+
|
1929 |
+
// Make sure ext is set to xxx after adding video to an existing poster
|
1930 |
+
wppa_update_photo( array( 'id' => $id, 'ext' => 'xxx' ) );
|
1931 |
+
|
1932 |
+
// Book keeping
|
1933 |
+
$videocount++;
|
1934 |
+
}
|
1935 |
+
else {
|
1936 |
+
wppa_error_message( sprintf( __( 'Error inserting video %s, unknown or non existent album.', 'wp-photo-album-plus'), basename( $file ) ) );
|
1937 |
+
}
|
1938 |
+
}
|
1939 |
+
}
|
1940 |
+
}
|
1941 |
+
|
1942 |
+
// Now the audio files
|
1943 |
+
$audiocount = '0';
|
1944 |
+
$alb = isset( $_POST['wppa-audio-album'] ) ? $_POST['wppa-audio-album'] : '0';
|
1945 |
+
if ( wppa( 'ajax' ) && ! $alb ) {
|
1946 |
+
wppa( 'ajax_import_files_error', __( 'Unknown album', 'wp-photo-album-plus' ) );
|
1947 |
+
}
|
1948 |
+
else foreach ( array_keys( $files ) as $idx ) {
|
1949 |
+
$file = $files[$idx];
|
1950 |
+
if ( isset( $_POST['file-'.$idx] ) || wppa( 'ajax' ) ) {
|
1951 |
+
if ( wppa( 'ajax' ) ) wppa( 'ajax_import_files', wppa_sanitize_file_name( basename( $file ) ) );
|
1952 |
+
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
1953 |
+
if ( in_array( $ext, $wppa_supported_audio_extensions ) ) {
|
1954 |
+
if ( is_numeric( $alb ) && $alb != '0' ) {
|
1955 |
+
|
1956 |
+
// Do we have this filename with ext xxx in this album?
|
1957 |
+
$filename = wppa_strip_ext( basename( $file ) ).'.xxx';
|
1958 |
+
$id = wppa_file_is_in_album( $filename, $alb );
|
1959 |
+
|
1960 |
+
// Or maybe the poster is already there
|
1961 |
+
foreach ( $wppa_supported_photo_extensions as $pext ) {
|
1962 |
+
if ( ! $id ) {
|
1963 |
+
$id = wppa_file_is_in_album( str_replace( 'xxx', $pext, $filename ), $alb );
|
1964 |
+
}
|
1965 |
+
}
|
1966 |
+
|
1967 |
+
// This filename already exists: is the poster. Fix the filename in the photo info
|
1968 |
+
if ( $id ) {
|
1969 |
+
$fname = wppa_get_photo_item( $id, 'filename' );
|
1970 |
+
$fname = wppa_strip_ext( $fname ) . '.xxx';
|
1971 |
+
|
1972 |
+
// Fix filename and ext in photo info
|
1973 |
+
wppa_update_photo( array( 'id' => $id, 'filename' => $fname, 'ext' => 'xxx' ) );
|
1974 |
+
}
|
1975 |
+
|
1976 |
+
// Add new entry
|
1977 |
+
if ( ! $id ) {
|
1978 |
+
$id = wppa_create_photo_entry( array( 'album' => $alb, 'filename' => $filename, 'ext' => 'xxx', 'name' => wppa_strip_ext( $filename ) ) );
|
1979 |
+
wppa_flush_treecounts( $alb );
|
1980 |
+
}
|
1981 |
+
|
1982 |
+
// Add audio filetype
|
1983 |
+
$newpath = wppa_strip_ext( wppa_get_photo_path( $id ) ).'.'.$ext;
|
1984 |
+
copy( $file, $newpath );
|
1985 |
+
if ( $delu ) unlink( $file );
|
1986 |
+
if ( wppa( 'ajax' ) ) {
|
1987 |
+
wppa( 'ajax_import_files_done', true );
|
1988 |
+
}
|
1989 |
+
|
1990 |
+
// Make sure ext is set to xxx after adding audio to an existing poster
|
1991 |
+
wppa_update_photo( array( 'id' => $id, 'ext' => 'xxx' ) );
|
1992 |
+
|
1993 |
+
// Book keeping
|
1994 |
+
$audiocount++;
|
1995 |
+
}
|
1996 |
+
else {
|
1997 |
+
wppa_error_message( sprintf( __( 'Error inserting audio %s, unknown or non existent album.', 'wp-photo-album-plus'), basename( $file ) ) );
|
1998 |
+
}
|
1999 |
+
}
|
2000 |
+
}
|
2001 |
+
}
|
2002 |
+
|
2003 |
+
// The csv files. NOT with ajax
|
2004 |
+
$csvcount = wppa_get_csvcount( $files );
|
2005 |
+
if ( $csvcount ) {
|
2006 |
+
$csvcount = '0';
|
2007 |
+
if ( ! wppa( 'ajax' ) ) {
|
2008 |
+
if ( is_array( $files ) ) {
|
2009 |
+
|
2010 |
+
// Make sure the feature is on
|
2011 |
+
if ( ! wppa_switch( 'custom_fields' ) ) {
|
2012 |
+
wppa_update_option( 'wppa_custom_fields', 'yes' );
|
2013 |
+
echo '<b>' . __( 'Custom datafields enabled', 'wp-photo-album-plus').'</b><br />';
|
2014 |
+
}
|
2015 |
+
|
2016 |
+
// Get the captions we already have
|
2017 |
+
$cust_labels = array();
|
2018 |
+
for ( $i = '0'; $i < '10'; $i++ ) {
|
2019 |
+
$cust_labels[$i] = wppa_opt( 'custom_caption_' . $i );
|
2020 |
+
}
|
2021 |
+
/*
|
2022 |
+
// Display the captions we have
|
2023 |
+
echo __( 'Captions are:' ) . ' ';
|
2024 |
+
for ( $i = 0; $i < '10'; $i++ ) {
|
2025 |
+
echo '[' . $i . '] -> ';
|
2026 |
+
if ( $cust_labels[$i] ) {
|
2027 |
+
echo $cust_labels[$i] . ' ';
|
2028 |
+
}
|
2029 |
+
else {
|
2030 |
+
echo __( '--- not used ---' ) . ' ';
|
2031 |
+
}
|
2032 |
+
}
|
2033 |
+
echo '<br />';
|
2034 |
+
*/
|
2035 |
+
// Process the files
|
2036 |
+
$photos_processed_csv = '0';
|
2037 |
+
$photos_skipped_csv = '0';
|
2038 |
+
foreach ( array_keys( $files ) as $idx ) {
|
2039 |
+
$this_skipped = '0';
|
2040 |
+
$file = $files[$idx];
|
2041 |
+
if ( isset( $_POST['file-'.$idx] ) || isset( $_GET['continue'] ) ) {
|
2042 |
+
$ext = strtolower( wppa_get_ext( $file ) );
|
2043 |
+
if ( $ext == 'csv' ) {
|
2044 |
+
echo '<b>' . __( 'Processing', 'wp-photo-album-plus') . ' ' . basename( $file ) . '</b><br />';
|
2045 |
+
wppa_log( 'dbg', __( 'Processing', 'wp-photo-album-plus') . ' ' . basename( $file ) );
|
2046 |
+
|
2047 |
+
// Copy the file to a temp file
|
2048 |
+
$tempfile = dirname( $file ) . '/temp.csv';
|
2049 |
+
copy ( $file, $tempfile );
|
2050 |
+
|
2051 |
+
// Open file
|
2052 |
+
$handle = fopen( $tempfile, "rt" );
|
2053 |
+
if ( ! $handle ) {
|
2054 |
+
wppa_error_message( __( 'Can not open file. Can not continue. (1)', 'wp-photo-album-plus') );
|
2055 |
+
return;
|
2056 |
+
}
|
2057 |
+
$write_handle = fopen( $file, "wt" );
|
2058 |
+
if ( ! $write_handle ) {
|
2059 |
+
wppa_error_message( __( 'Can not open file. Can not continue. (2)', 'wp-photo-album-plus') );
|
2060 |
+
return;
|
2061 |
+
}
|
2062 |
+
|
2063 |
+
// Read header
|
2064 |
+
$header = fgets( $handle, 4096 );
|
2065 |
+
if ( ! $header ) {
|
2066 |
+
wppa_error_message( __( 'Can not read header. Can not continue.', 'wp-photo-album-plus') );
|
2067 |
+
fclose( $handle );
|
2068 |
+
return;
|
2069 |
+
}
|
2070 |
+
fputs( $write_handle, $header );
|
2071 |
+
echo __( 'Read header:', 'wp-photo-album-plus') . ' ' . $header . '<br />';
|
2072 |
+
|
2073 |
+
// Interprete header
|
2074 |
+
$captions = wppa_explode_csv( $header );
|
2075 |
+
if ( ! is_array( $captions ) || count( $captions ) < '2' ) {
|
2076 |
+
wppa_error_message( __( 'Invalid header. Can not continue.', 'wp-photo-album-plus') );
|
2077 |
+
fclose( $handle );
|
2078 |
+
return;
|
2079 |
+
}
|
2080 |
+
foreach ( array_keys( $captions ) as $key ) {
|
2081 |
+
if ( $key == '0' ) {
|
2082 |
+
if ( ! in_array( strtolower( trim( $captions['0'] ) ), array( 'name', 'photoname', 'filename' ) ) ) {
|
2083 |
+
wppa_error_message( __( 'Invalid header. First item must be \'name\', \'photoname\' or \'filename\'', 'wp-photo-album-plus') );
|
2084 |
+
fclose( $handle );
|
2085 |
+
return;
|
2086 |
+
}
|
2087 |
+
}
|
2088 |
+
elseif ( ! in_array( $captions[$key], $cust_labels ) ) {
|
2089 |
+
if ( ! in_array( '', $cust_labels ) ) {
|
2090 |
+
wppa_error_message( __( 'All available custom data fields are in use. There is no space for', 'wp-photo-album-plus') . ' ' . $captions[$key] );
|
2091 |
+
fclose( $handle );
|
2092 |
+
return;
|
2093 |
+
}
|
2094 |
+
|
2095 |
+
// Add a new caption
|
2096 |
+
$i = '0';
|
2097 |
+
while ( $cust_labels[$i] ) $i++;
|
2098 |
+
$cust_labels[$i] = $captions[$key];
|
2099 |
+
wppa_update_option( 'wppa_custom_caption_' . $i, $cust_labels[$i] );
|
2100 |
+
wppa_update_option( 'wppa_custom_visible_' . $i, 'yes' );
|
2101 |
+
wppa_log( 'dbg', sprintf( __( 'New caption %s added.', 'wp-photo-album-plus'), $cust_labels[$i] ) );
|
2102 |
+
}
|
2103 |
+
}
|
2104 |
+
|
2105 |
+
// Find the correlation between caption index and custom data index.
|
2106 |
+
$pointers = array();
|
2107 |
+
for ( $i = '1'; $i < count( $captions ); $i++ ) {
|
2108 |
+
for ( $j = '0'; $j < '10'; $j++ ) {
|
2109 |
+
if ( $captions[$i] == $cust_labels[$j] ) {
|
2110 |
+
$pointers[$j] = $i;
|
2111 |
+
}
|
2112 |
+
}
|
2113 |
+
}
|
2114 |
+
|
2115 |
+
// Now process the lines
|
2116 |
+
while ( ! feof( $handle ) ) {
|
2117 |
+
$dataline = fgets( $handle, 4096 );
|
2118 |
+
if ( $dataline ) {
|
2119 |
+
wppa_log( 'dbg', __( 'Read data:', 'wp-photo-album-plus') . ' ' . trim( $dataline ) );
|
2120 |
+
$data_arr = wppa_explode_csv( $dataline );
|
2121 |
+
$search = $data_arr[0];
|
2122 |
+
switch ( strtolower($captions[0]) ) {
|
2123 |
+
case 'photoname':
|
2124 |
+
$photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `name` = %s", $data_arr[0] ), ARRAY_A );
|
2125 |
+
break;
|
2126 |
+
case 'filename':
|
2127 |
+
$photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `filename` = %s", $data_arr[0] ), ARRAY_A );
|
2128 |
+
break;
|
2129 |
+
case 'name':
|
2130 |
+
$photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `name` = %s OR `filename` = %s", $data_arr[0], $data_arr[0] ), ARRAY_A );
|
2131 |
+
break;
|
2132 |
+
}
|
2133 |
+
if ( $photos ) {
|
2134 |
+
foreach( $photos as $photo ) {
|
2135 |
+
$cust_data = $photo['custom'] ? unserialize( $photo['custom'] ) : array( '', '', '', '', '', '', '', '', '', '' );
|
2136 |
+
foreach( array_keys( $pointers ) as $p ) {
|
2137 |
+
$cust_data[$p] = wppa_sanitize_custom_field( $data_arr[$pointers[$p]] );
|
2138 |
+
}
|
2139 |
+
wppa_update_photo( array( 'id' => $photo['id'], 'custom' => serialize( $cust_data ) ) );
|
2140 |
+
$photos_processed_csv ++;
|
2141 |
+
}
|
2142 |
+
wppa_log( 'dbg', 'Processed: ' . $data_arr[0] );
|
2143 |
+
}
|
2144 |
+
|
2145 |
+
// This line could not be processed
|
2146 |
+
else {
|
2147 |
+
wppa_log( 'dbg', 'Could not find: ' . $data_arr[0] );
|
2148 |
+
|
2149 |
+
// Write back to original file
|
2150 |
+
fputs( $write_handle, $dataline );
|
2151 |
+
$photos_skipped_csv++;
|
2152 |
+
$this_skipped++;
|
2153 |
+
}
|
2154 |
+
echo '.';
|
2155 |
+
}
|
2156 |
+
|
2157 |
+
// Time up?
|
2158 |
+
if ( wppa_is_time_up() && wppa_switch( 'auto_continue' ) ) {
|
2159 |
+
wppa( 'continue', 'continue' );
|
2160 |
+
|
2161 |
+
// Copy rest of file back to original
|
2162 |
+
while ( ! feof( $handle ) ) {
|
2163 |
+
$temp = fgets( $handle, 4096 );
|
2164 |
+
fputs( $write_handle, $temp );
|
2165 |
+
}
|
2166 |
+
}
|
2167 |
+
}
|
2168 |
+
|
2169 |
+
fclose( $handle );
|
2170 |
+
fclose( $write_handle );
|
2171 |
+
|
2172 |
+
$csvcount++;
|
2173 |
+
|
2174 |
+
// Remove tempfile
|
2175 |
+
unlink( $tempfile );
|
2176 |
+
|
2177 |
+
// Remove orig file
|
2178 |
+
if ( ! $this_skipped && ! wppa_is_time_up() ) {
|
2179 |
+
unlink( $file );
|
2180 |
+
}
|
2181 |
+
}
|
2182 |
+
}
|
2183 |
+
}
|
2184 |
+
}
|
2185 |
+
}
|
2186 |
+
}
|
2187 |
+
|
2188 |
+
wppa_ok_message( __( 'Done processing files.', 'wp-photo-album-plus') );
|
2189 |
+
|
2190 |
+
if ( $pcount == '0' && $acount == '0' && $zcount == '0' && $dircount == '0' && $photocount == '0' && $videocount == '0' && $audiocount == '0' && $csvcount == '0' ) {
|
2191 |
+
wppa_warning_message( __( 'No files to import.', 'wp-photo-album-plus') );
|
2192 |
+
}
|
2193 |
+
else {
|
2194 |
+
$msg = '';
|
2195 |
+
if ( $zcount ) $msg .= $zcount.' '.__( 'Zipfiles extracted.', 'wp-photo-album-plus').' ';
|
2196 |
+
if ( $acount ) $msg .= $acount.' '.__( 'Albums created.', 'wp-photo-album-plus').' ';
|
2197 |
+
if ( $dircount ) $msg .= $dircount.' '.__( 'Directory to album imports.', 'wp-photo-album-plus').' ';
|
2198 |
+
if ( $photocount ) $msg .= ' '.sprintf( __( 'With total %s photos.','wppa', 'wp-photo-album-plus'), $photocount ).' ';
|
2199 |
+
if ( $pcount ) {
|
2200 |
+
if ( isset( $_POST['wppa-update'] ) ) {
|
2201 |
+
$msg .= $pcount.' '.__( 'Photos updated', 'wp-photo-album-plus' );
|
2202 |
+
if ( $totpcount != $pcount ) {
|
2203 |
+
$msg .= ' '.sprintf( __( 'to %s locations', 'wp-photo-album-plus'), $totpcount );
|
2204 |
+
}
|
2205 |
+
$msg .= '.';
|
2206 |
+
}
|
2207 |
+
else $msg .= $pcount.' '.__( 'single photos imported.', 'wp-photo-album-plus').' ';
|
2208 |
+
}
|
2209 |
+
if ( $videocount ) {
|
2210 |
+
$msg .= $videocount.' '.__( 'Videos imported.', 'wp-photo-album-plus' );
|
2211 |
+
}
|
2212 |
+
if ( $audiocount ) {
|
2213 |
+
$msg .= $audiocount.' '.__( 'Audios imported.', 'wp-photo-album-plus' );
|
2214 |
+
}
|
2215 |
+
if ( $csvcount ) {
|
2216 |
+
$msg .= $csvcount . ' ' . __( 'CSVs imported,', 'wp-photo-album-plus') . ' ' .
|
2217 |
+
$photos_processed_csv .' '. __( 'photos processed.', 'wp-photo-album-plus') . ' ' .
|
2218 |
+
$photos_skipped_csv . ' ' . __('photos skipped.', 'wp-photo-album-plus' );
|
2219 |
+
}
|
2220 |
+
wppa_ok_message( $msg );
|
2221 |
+
wppa_set_last_album( $album );
|
2222 |
+
}
|
2223 |
+
}
|
2224 |
+
|
2225 |
+
function wppa_get_zipcount( $files ) {
|
2226 |
+
$result = 0;
|
2227 |
+
if ( $files ) {
|
2228 |
+
foreach ( $files as $file ) {
|
2229 |
+
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
2230 |
+
if ( $ext == 'zip' ) $result++;
|
2231 |
+
}
|
2232 |
+
}
|
2233 |
+
return $result;
|
2234 |
+
}
|
2235 |
+
|
2236 |
+
function wppa_get_albumcount( $files ) {
|
2237 |
+
$result = 0;
|
2238 |
+
if ( $files ) {
|
2239 |
+
foreach ( $files as $file ) {
|
2240 |
+
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
2241 |
+
if ( $ext == 'amf' ) $result++;
|
2242 |
+
}
|
2243 |
+
}
|
2244 |
+
return $result;
|
2245 |
+
}
|
2246 |
+
|
2247 |
+
function wppa_get_photocount( $files ) {
|
2248 |
+
global $wppa_supported_photo_extensions;
|
2249 |
+
|
2250 |
+
$result = 0;
|
2251 |
+
if ( $files ) {
|
2252 |
+
foreach ( $files as $file ) {
|
2253 |
+
$ext = strtolower( wppa_get_ext( $file ) );
|
2254 |
+
if ( in_array( $ext, $wppa_supported_photo_extensions ) ) $result++;
|
2255 |
+
}
|
2256 |
+
}
|
2257 |
+
return $result;
|
2258 |
+
}
|
2259 |
+
|
2260 |
+
function wppa_get_video_count( $files ) {
|
2261 |
+
global $wppa_supported_video_extensions;
|
2262 |
+
|
2263 |
+
$result = 0;
|
2264 |
+
if ( $files ) {
|
2265 |
+
foreach ( $files as $file ) {
|
2266 |
+
$ext = strtolower( wppa_get_ext( $file ) );
|
2267 |
+
if ( in_array( $ext, $wppa_supported_video_extensions ) ) $result++;
|
2268 |
+
}
|
2269 |
+
}
|
2270 |
+
return $result;
|
2271 |
+
}
|
2272 |
+
|
2273 |
+
function wppa_get_audio_count( $files ) {
|
2274 |
+
global $wppa_supported_audio_extensions;
|
2275 |
+
|
2276 |
+
$result = 0;
|
2277 |
+
if ( $files ) {
|
2278 |
+
foreach ( $files as $file ) {
|
2279 |
+
$ext = strtolower( wppa_get_ext( $file ) );
|
2280 |
+
if ( in_array( $ext, $wppa_supported_audio_extensions ) ) $result++;
|
2281 |
+
}
|
2282 |
+
}
|
2283 |
+
return $result;
|
2284 |
+
}
|
2285 |
+
|
2286 |
+
|
2287 |
+
// Find dir is new album candidates
|
2288 |
+
function wppa_get_dircount( $files ) {
|
2289 |
+
$result = 0;
|
2290 |
+
if ( $files ) {
|
2291 |
+
foreach ( $files as $file ) {
|
2292 |
+
if ( basename( $file ) == '.' ) {}
|
2293 |
+
elseif ( basename( $file ) == '..' ) {}
|
2294 |
+
elseif ( is_dir( $file ) ) $result++;
|
2295 |
+
}
|
2296 |
+
}
|
2297 |
+
return $result;
|
2298 |
+
}
|
2299 |
+
|
2300 |
+
// Find .csv file count
|
2301 |
+
function wppa_get_csvcount( $files ) {
|
2302 |
+
$result = 0;
|
2303 |
+
if ( $files ) {
|
2304 |
+
foreach ( $files as $file ) {
|
2305 |
+
if ( is_file( $file ) ) {
|
2306 |
+
if ( strtolower( wppa_get_ext( $file ) ) == 'csv' ) $result++;
|
2307 |
+
}
|
2308 |
+
}
|
2309 |
+
}
|
2310 |
+
return $result;
|
2311 |
+
}
|
2312 |
+
|
2313 |
+
function wppa_get_meta_name( $file, $opt = '' ) {
|
2314 |
+
return wppa_get_meta_data( $file, 'name', $opt );
|
2315 |
+
}
|
2316 |
+
function wppa_get_meta_album( $file, $opt = '' ) {
|
2317 |
+
return wppa_get_meta_data( $file, 'albm', $opt );
|
2318 |
+
}
|
2319 |
+
function wppa_get_meta_desc( $file, $opt = '' ) {
|
2320 |
+
return wppa_get_meta_data( $file, 'desc', $opt );
|
2321 |
+
}
|
2322 |
+
function wppa_get_meta_porder( $file, $opt = '' ) {
|
2323 |
+
return wppa_get_meta_data( $file, 'pord', $opt );
|
2324 |
+
}
|
2325 |
+
function wppa_get_meta_linkurl( $file, $opt = '' ) {
|
2326 |
+
return wppa_get_meta_data( $file, 'lnku', $opt );
|
2327 |
+
}
|
2328 |
+
function wppa_get_meta_linktitle( $file, $opt = '' ) {
|
2329 |
+
return wppa_get_meta_data( $file, 'lnkt', $opt );
|
2330 |
+
}
|
2331 |
+
|
2332 |
+
function wppa_get_meta_data( $file, $item, $opt ) {
|
2333 |
+
$result = '';
|
2334 |
+
$opt2 = '';
|
2335 |
+
if ( $opt == '( ' ) $opt2 = ' )';
|
2336 |
+
if ( $opt == '{' ) $opt2 = '}';
|
2337 |
+
if ( $opt == '[' ) $opt2 = ']';
|
2338 |
+
if ( is_file( $file ) ) {
|
2339 |
+
$handle = fopen( $file, "r" );
|
2340 |
+
if ( $handle ) {
|
2341 |
+
while ( ( $buffer = fgets( $handle, 4096 ) ) !== false ) {
|
2342 |
+
if ( substr( $buffer, 0, 5 ) == $item.'=' ) {
|
2343 |
+
if ( $opt == '' ) $result = substr( $buffer, 5, strlen( $buffer )-6 );
|
2344 |
+
else $result = $opt.__( substr( $buffer, 5, strlen( $buffer )-6 ) ).$opt2; // Translate for display purposes only
|
2345 |
+
}
|
2346 |
+
}
|
2347 |
+
if ( !feof( $handle ) ) {
|
2348 |
+
_e( 'Error: unexpected fgets() fail in wppa_get_meta_data().', 'wp-photo-album-plus' );
|
2349 |
+
}
|
2350 |
+
fclose( $handle );
|
2351 |
+
}
|
2352 |
+
}
|
2353 |
+
return $result;
|
2354 |
+
}
|
2355 |
+
|
2356 |
+
|
2357 |
+
function wppa_extract( $xpath, $delz ) {
|
2358 |
+
// There are two reasons that we do not allow the directory structure from the zipfile to be restored.
|
2359 |
+
// 1. we may have no create dir access rights.
|
2360 |
+
// 2. we can not reach the pictures as we only glob the users depot and not lower.
|
2361 |
+
// We extract all files to the users depot.
|
2362 |
+
// The illegal files will be deleted there by the wppa_sanitize_files routine,
|
2363 |
+
// so there is no chance a depot/subdir/destroy.php or the like will get a chance to be created.
|
2364 |
+
// dus...
|
2365 |
+
|
2366 |
+
$err = '0';
|
2367 |
+
if ( ! class_exists( 'ZipArchive' ) ) {
|
2368 |
+
$err = '3';
|
2369 |
+
wppa_error_message( __( 'Class ZipArchive does not exist! Check your php configuration', 'wp-photo-album-plus') );
|
2370 |
+
}
|
2371 |
+
else {
|
2372 |
+
|
2373 |
+
// Start security fix
|
2374 |
+
$path = wppa_sanitize_file_name( $xpath );
|
2375 |
+
if ( ! file_exists( $xpath ) ) {
|
2376 |
+
wppa_error_message( 'Zipfile '.$path.' does not exist.' );
|
2377 |
+
// unlink( $xpath );
|
2378 |
+
$err = '4';
|
2379 |
+
return $err;
|
2380 |
+
}
|
2381 |
+
// End security fix
|
2382 |
+
|
2383 |
+
$ext = strtolower( wppa_get_ext( $xpath ) );
|
2384 |
+
if ( $ext == 'zip' ) {
|
2385 |
+
$zip = new ZipArchive;
|
2386 |
+
if ( $zip->open( $xpath ) === true ) {
|
2387 |
+
|
2388 |
+
$supported_file_ext = array( 'jpg', 'png', 'gif', 'JPG', 'PNG', 'GIF', 'amf', 'pmf' );
|
2389 |
+
$done = '0';
|
2390 |
+
$skip = '0';
|
2391 |
+
for( $i = 0; $i < $zip->numFiles; $i++ ){
|
2392 |
+
$stat = $zip->statIndex( $i );
|
2393 |
+
$file_ext = @ end( explode( '.', $stat['name'] ) );
|
2394 |
+
if ( in_array( $file_ext, $supported_file_ext ) ) {
|
2395 |
+
$zip->extractTo( WPPA_DEPOT_PATH, $stat['name'] );
|
2396 |
+
$done++;
|
2397 |
+
}
|
2398 |
+
else {
|
2399 |
+
wppa_warning_message( sprintf( __( 'File %s is of an unsupported filetype and has been ignored during extraction.', 'wp-photo-album-plus'), wppa_sanitize_file_name( $stat['name'] ) ) );
|
2400 |
+
$skip++;
|
2401 |
+
}
|
2402 |
+
}
|
2403 |
+
|
2404 |
+
$zip->close();
|
2405 |
+
wppa_ok_message( sprintf( __( 'Zipfile %s processed. %s files extracted, %s files skipped.', 'wp-photo-album-plus'), basename( $path ), $done, $skip ) );
|
2406 |
+
if ( $delz ) unlink( $xpath );
|
2407 |
+
} else {
|
2408 |
+
wppa_error_message( __( 'Failed to extract', 'wp-photo-album-plus').' '.$path );
|
2409 |
+
$err = '1';
|
2410 |
+
}
|
2411 |
+
}
|
2412 |
+
else $err = '2';
|
2413 |
+
}
|
2414 |
+
return $err;
|
2415 |
+
}
|
2416 |
+
|
2417 |
+
function wppa_import_dir_to_album( $file, $parent ) {
|
2418 |
+
global $photocount;
|
2419 |
+
global $wpdb;
|
2420 |
+
global $wppa_session;
|
2421 |
+
|
2422 |
+
// Session should survive the default hour
|
2423 |
+
wppa_extend_session();
|
2424 |
+
|
2425 |
+
// see if album exists
|
2426 |
+
if ( is_dir( $file ) ) {
|
2427 |
+
|
2428 |
+
// Check parent
|
2429 |
+
if ( wppa_switch( 'import_parent_check' ) ) {
|
2430 |
+
|
2431 |
+
$alb = wppa_get_album_id( basename( $file ), $parent );
|
2432 |
+
|
2433 |
+
// If parent = 0 ( top-level album ) and album not found,
|
2434 |
+
// try a 'separate' album ( i.e. parent = -1 ) with this name
|
2435 |
+
if ( ! $alb && $parent == '0' ) {
|
2436 |
+
$alb = wppa_get_album_id( basename( $file ), '-1' );
|
2437 |
+
}
|
2438 |
+
}
|
2439 |
+
|
2440 |
+
// All albums have unique names, do'nt worry about parent
|
2441 |
+
else {
|
2442 |
+
$alb = wppa_get_album_id( basename( $file ), false );
|
2443 |
+
}
|
2444 |
+
|
2445 |
+
if ( ! $alb ) { // Album must be created
|
2446 |
+
$name = basename( $file );
|
2447 |
+
$uplim = wppa_opt( 'upload_limit_count' ). '/' . wppa_opt( 'upload_limit_time' );
|
2448 |
+
$alb = wppa_create_album_entry( array ( 'name' => $name,
|
2449 |
+
'a_parent' => $parent
|
2450 |
+
) );
|
2451 |
+
if ( $alb === false ) {
|
2452 |
+
wppa_error_message( __( 'Could not create album.', 'wp-photo-album-plus').'<br/>Query = '.$query );
|
2453 |
+
wp_die( 'Sorry, cannot continue' );
|
2454 |
+
}
|
2455 |
+
else {
|
2456 |
+
wppa_set_last_album( $alb );
|
2457 |
+
wppa_flush_treecounts( $alb );
|
2458 |
+
wppa_index_add( 'album', $alb );
|
2459 |
+
wppa_create_pl_htaccess();
|
2460 |
+
wppa_ok_message( __( 'Album #', 'wp-photo-album-plus') . ' ' . $alb . ' ( '.$name.' ) ' . __( 'Added.', 'wp-photo-album-plus') );
|
2461 |
+
if ( wppa_switch( 'newpag_create' ) && $parent <= '0' ) {
|
2462 |
+
|
2463 |
+
// Create post object
|
2464 |
+
$my_post = array(
|
2465 |
+
'post_title' => $name,
|
2466 |
+
'post_content' => str_replace( 'w#album', $alb, wppa_opt( 'newpag_content' ) ),
|
2467 |
+
'post_status' => wppa_opt( 'newpag_status' ),
|
2468 |
+
'post_type' => wppa_opt( 'newpag_type' )
|
2469 |
+
);
|
2470 |
+
|
2471 |
+
// Insert the post into the database
|
2472 |
+
$pagid = wp_insert_post( $my_post );
|
2473 |
+
if ( $pagid ) {
|
2474 |
+
wppa_ok_message( sprintf( __( 'Page <a href="%s" target="_blank" >%s</a> created.', 'wp-photo-album-plus'), home_url().'?page_id='.$pagid, $name ) );
|
2475 |
+
$wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_ALBUMS."` SET `cover_linkpage` = %s WHERE `id` = %s", $pagid, $alb ) );
|
2476 |
+
}
|
2477 |
+
else {
|
2478 |
+
wppa_error_message( __( 'Could not create page.', 'wp-photo-album-plus') );
|
2479 |
+
}
|
2480 |
+
}
|
2481 |
+
}
|
2482 |
+
}
|
2483 |
+
|
2484 |
+
// Now import the files
|
2485 |
+
$photofiles = glob( $file.'/*' );
|
2486 |
+
if ( $photofiles ) foreach ( $photofiles as $photofile ) {
|
2487 |
+
if ( ! is_dir( $photofile ) ) {
|
2488 |
+
|
2489 |
+
if ( ! isset( $wppa_session[$photofile] ) || ! wppa_switch( 'keep_import_files' ) ) {
|
2490 |
+
|
2491 |
+
if ( wppa_albumphoto_exists( $alb, basename( $photofile ) ) ) {
|
2492 |
+
if ( ! wppa_switch( 'keep_import_files' ) ) {
|
2493 |
+
wppa_warning_message( 'Photo '.basename( $photofile ).' already exists in album '.$alb.'. Removed. (2)' );
|
2494 |
+
}
|
2495 |
+
}
|
2496 |
+
else {
|
2497 |
+
$bret = wppa_insert_photo( $photofile, $alb, basename( $photofile ) );
|
2498 |
+
$photocount++;
|
2499 |
+
}
|
2500 |
+
if ( ! wppa_switch( 'keep_import_files' ) ) {
|
2501 |
+
@ unlink( $photofile );
|
2502 |
+
}
|
2503 |
+
$wppa_session[$photofile] = true;
|
2504 |
+
}
|
2505 |
+
|
2506 |
+
if ( wppa_is_time_up( $photocount ) ) return false;
|
2507 |
+
}
|
2508 |
+
}
|
2509 |
+
|
2510 |
+
// Now go deeper, process the subdirs
|
2511 |
+
$subdirs = glob( $file.'/*' );
|
2512 |
+
if ( $subdirs ) foreach ( $subdirs as $subdir ) {
|
2513 |
+
if ( is_dir( $subdir ) ) {
|
2514 |
+
if ( basename( $subdir ) != '.' && basename( $subdir ) != '..' ) {
|
2515 |
+
$bret = wppa_import_dir_to_album( $subdir, $alb );
|
2516 |
+
if ( ! $bret ) return false; // Time out
|
2517 |
+
}
|
2518 |
+
}
|
2519 |
+
}
|
2520 |
+
@ rmdir( $file ); // Try to remove dir, ignore error
|
2521 |
+
}
|
2522 |
+
else {
|
2523 |
+
wppa_dbg_msg( 'Invalid file in wppa_import_dir_to_album(): '.$file );
|
2524 |
+
return false;
|
2525 |
+
}
|
2526 |
+
return true;
|
2527 |
+
}
|
2528 |
+
|
2529 |
+
function wppa_is_wppa_tree( $file ) {
|
2530 |
+
|
2531 |
+
$temp = explode( '/uploads/wppa/', $file );
|
2532 |
+
if ( count( $temp ) === 2 ) {
|
2533 |
+
$temp[1] = wppa_expand_id( wppa_strip_ext( $temp[1] ) ) . '.' . wppa_get_ext( $temp[1] );
|
2534 |
+
$newf = implode( '/wppa/', $temp );
|
2535 |
+
wppa( 'is_wppa_tree', ( $newf != $file ) );
|
2536 |
+
}
|
2537 |
+
else {
|
2538 |
+
wppa( 'is_wppa_tree', false );
|
2539 |
+
}
|
2540 |
+
return wppa( 'is_wppa_tree' );
|
2541 |
+
}
|
2542 |
+
|
2543 |
+
function wppa_compress_tree_path( $path ) {
|
2544 |
+
|
2545 |
+
$result = $path;
|
2546 |
+
$temp = explode( '/wppa/', $path );
|
2547 |
+
if ( count( $temp ) == '2' ) {
|
2548 |
+
$temp[1] = str_replace( '/', '', $temp[1] );
|
2549 |
+
$result = implode( '/wppa/', $temp );
|
2550 |
+
}
|
2551 |
+
return $result;
|
2552 |
+
}
|
2553 |
+
|
2554 |
+
function wppa_expand_tree_path( $path ) {
|
2555 |
+
|
2556 |
+
$result = $path;
|
2557 |
+
$temp = explode( '/wppa/', $path );
|
2558 |
+
if ( count( $temp ) == '2' ) {
|
2559 |
+
$temp[1] = wppa_expand_id( wppa_strip_ext( $temp[1] ) ) . '.' . wppa_get_ext( $temp[1] );
|
2560 |
+
$result = implode( '/wppa/', $temp );
|
2561 |
+
}
|
2562 |
+
return $result;
|
2563 |
+
}
|
2564 |
+
|
2565 |
+
function wppa_abs_walktree( $root, $source ) {
|
2566 |
+
static $void_dirs;
|
2567 |
+
|
2568 |
+
$result = '';
|
2569 |
+
|
2570 |
+
// Init void dirs
|
2571 |
+
if ( ! $void_dirs ) {
|
2572 |
+
$void_dirs = array( '.', '..',
|
2573 |
+
'wp-admin',
|
2574 |
+
'wp-includes',
|
2575 |
+
'themes',
|
2576 |
+
'upgrade',
|
2577 |
+
'plugins',
|
2578 |
+
'languages',
|
2579 |
+
'wppa',
|
2580 |
+
( wppa_switch( 'allow_import_source') ? '' : 'wppa-source' ),
|
2581 |
+
);
|
2582 |
+
}
|
2583 |
+
|
2584 |
+
// If currently in selected dir, set selected
|
2585 |
+
$sel = $root == $source ? ' selected="selected"' : '';
|
2586 |
+
|
2587 |
+
// Set disabled if there are no files inside
|
2588 |
+
$n_files = count( glob( $root . '/*' ) );
|
2589 |
+
$n_dirs = count( glob( $root . '/*', GLOB_ONLYDIR ) );
|
2590 |
+
$dis = $n_files == $n_dirs ? ' disabled="disabled"' : '';
|
2591 |
+
|
2592 |
+
// Check for (sub)depot
|
2593 |
+
$my_depot = __( '--- My depot --- ' ,'wp-photo-album-plus' );
|
2594 |
+
$display = str_replace( WPPA_DEPOT_PATH, $my_depot, $root );
|
2595 |
+
if ( strpos( $display, $my_depot ) !== false ) {
|
2596 |
+
$dis = '';
|
2597 |
+
}
|
2598 |
+
|
2599 |
+
// Check for ngg gallery dir
|
2600 |
+
$ngg_opts = get_option( 'ngg_options', false );
|
2601 |
+
if ( $ngg_opts ) {
|
2602 |
+
$ngg_gal = __( '--- Ngg Galleries --- ', 'wp-photo-album-plus' );
|
2603 |
+
$display = str_replace( rtrim( $ngg_opts['gallerypath'], '/' ), $ngg_gal, $display );
|
2604 |
+
$pos = strpos( $display, $ngg_gal );
|
2605 |
+
if ( $pos ) {
|
2606 |
+
$display = substr( $display, $pos );
|
2607 |
+
}
|
2608 |
+
}
|
2609 |
+
|
2610 |
+
// Remove ABSPATH from display string
|
2611 |
+
$display = str_replace( ABSPATH, '', $display );
|
2612 |
+
|
2613 |
+
// Output the selecion if not in the wp dir
|
2614 |
+
if ( $root.'/' != ABSPATH ) {
|
2615 |
+
$result .=
|
2616 |
+
'<option' .
|
2617 |
+
' value="' . $root . '"' .
|
2618 |
+
$sel .
|
2619 |
+
$dis .
|
2620 |
+
' data-nfiles="' . $n_files . '"' .
|
2621 |
+
' data-ndirs="' . $n_dirs . '"' .
|
2622 |
+
' >' .
|
2623 |
+
$display .
|
2624 |
+
'</option>';
|
2625 |
+
}
|
2626 |
+
|
2627 |
+
// See if subdirs exist
|
2628 |
+
$dirs = glob( $root . '/*', GLOB_ONLYDIR );
|
2629 |
+
|
2630 |
+
// Go deeper if not in a list of void disnames
|
2631 |
+
if ( $dirs ) foreach( $dirs as $path ) {
|
2632 |
+
$dir = basename( $path );
|
2633 |
+
if ( ! in_array( $dir, $void_dirs ) ) {
|
2634 |
+
$newroot = $root . '/' . $dir;
|
2635 |
+
$result .= wppa_abs_walktree( $newroot, $source );
|
2636 |
+
}
|
2637 |
+
}
|
2638 |
+
|
2639 |
+
return $result;
|
2640 |
+
}
|
wppa-init.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* This file loads required php files and contains all functions used in init actions.
|
6 |
*
|
7 |
-
* Version 6.
|
8 |
*/
|
9 |
|
10 |
/* LOAD SIDEBAR WIDGETS */
|
@@ -278,6 +278,45 @@ function wppa_cat_message() {
|
|
278 |
wppa_error_message( __('</strong>The cats system needs to be converted. Please run <b>Photo Albums -> Settings</b> admin page <b>Table VIII-B17</b><strong>' , 'wp-photo-album-plus') );
|
279 |
}
|
280 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
/* This function will add "donate" link to main plugins page */
|
282 |
function wppa_donate_link($links, $file) {
|
283 |
if ( $file == plugin_basename(__FILE__) ) {
|
4 |
*
|
5 |
* This file loads required php files and contains all functions used in init actions.
|
6 |
*
|
7 |
+
* Version 6.5.02
|
8 |
*/
|
9 |
|
10 |
/* LOAD SIDEBAR WIDGETS */
|
278 |
wppa_error_message( __('</strong>The cats system needs to be converted. Please run <b>Photo Albums -> Settings</b> admin page <b>Table VIII-B17</b><strong>' , 'wp-photo-album-plus') );
|
279 |
}
|
280 |
|
281 |
+
function wppa_scripts_are_obssolete() {
|
282 |
+
global $wpdb;
|
283 |
+
|
284 |
+
// This notice dismissed?
|
285 |
+
if ( get_option( 'wppa_dismiss_admin_notice_scripts_are_obsolete', 'no' ) == 'yes' ) {
|
286 |
+
return;
|
287 |
+
}
|
288 |
+
|
289 |
+
$has_wppa_scripts = $wpdb->get_results( "SELECT `ID`, `post_title`, `post_content`, `post_type` " .
|
290 |
+
"FROM `" . $wpdb->prefix . 'posts' ."` " .
|
291 |
+
"WHERE `post_status` = 'publish' " .
|
292 |
+
"AND ( `post_type` = 'post' OR `post_type` = 'page' ) " .
|
293 |
+
"AND `post_content` LIKE '%\\%\\%wppa\\%\\%%' " , ARRAY_A );
|
294 |
+
|
295 |
+
if ( $has_wppa_scripts ) {
|
296 |
+
foreach( array_keys( $has_wppa_scripts ) as $key ) {
|
297 |
+
if ( strpos( $has_wppa_scripts[$key]['post_content'], '%%wppa%%' ) === false ) {
|
298 |
+
unset( $has_wppa_scripts[$key] );
|
299 |
+
}
|
300 |
+
}
|
301 |
+
}
|
302 |
+
|
303 |
+
if ( ! empty( $has_wppa_scripts ) ) {
|
304 |
+
$msg = __( 'WPPA scripts will no longer be supported in version 6.6. Please convert the %%wppa%% scripts to [wppa][/wppa] shortcodes before upgrading to version 6.6.', 'wp-photo-album-plus' );
|
305 |
+
$msg .= '<br /><br />';
|
306 |
+
$msg .= __( 'WPPA scripts found in the following Pages / Posts', 'wp-photo-album-plus' );
|
307 |
+
$msg .= '<br /><br />';
|
308 |
+
foreach( $has_wppa_scripts as $item ) {
|
309 |
+
$msg .= $item['ID'] . ' <a href="'. admin_url( 'post.php?post=' . $item['ID'] . '&action=edit' ) .'" title="Edit this ' . $item['post_type'] . '" >' . $item['post_title'] . '</a>' .
|
310 |
+
' at loc:' . strpos( $item['post_content'], '%%wppa%%' ) . ' :' . htmlspecialchars( substr( $item['post_content'] , strpos( $item['post_content'], '%%wppa%%' ), 32 ) ) . '...' .
|
311 |
+
'<br />';
|
312 |
+
}
|
313 |
+
$msg .= '<br />' . sprintf( __( 'For more information see the %s documentation page', 'wp-photo-album-plus' ), '<a href="http://wppa.nl/changelog/script-to-shortcode-conversion/" target="_blank" >Script to shortcode conversion</a>' );
|
314 |
+
$msg .= '<br /><div style="float:right;" ><input type="checkbox" onchange="wppaDismissAdminNotice(\'dismiss_admin_notice_scripts_are_obsolete\', this);" > Dismiss this message</div><div style="clear:both;" ></div>';
|
315 |
+
$msg .= wp_nonce_field('wppa-nonce', 'wppa-nonce', false, false);
|
316 |
+
wppa_warning_message( $msg );
|
317 |
+
}
|
318 |
+
}
|
319 |
+
|
320 |
/* This function will add "donate" link to main plugins page */
|
321 |
function wppa_donate_link($links, $file) {
|
322 |
if ( $file == plugin_basename(__FILE__) ) {
|
wppa-mobile.php
CHANGED
@@ -1,90 +1,90 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Mobile Detect
|
5 |
-
*
|
6 |
-
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
7 |
-
* @version SVN: $Id: Mobile_Detect.php 3 2009-05-21 13:06:28Z vic.stanciu $
|
8 |
-
* @version SVN: $Id: Mobile_Detect.php 3 2011-04-19 18:44:28Z sjevsejev $
|
9 |
-
*/
|
10 |
-
|
11 |
-
class wppa_mobile_detect {
|
12 |
-
|
13 |
-
protected $accept;
|
14 |
-
protected $userAgent;
|
15 |
-
|
16 |
-
protected $isMobile = false;
|
17 |
-
protected $isAndroid = null;
|
18 |
-
protected $isBlackberry = null;
|
19 |
-
protected $isIphone = null;
|
20 |
-
protected $isIpad = null;
|
21 |
-
protected $isOpera = null;
|
22 |
-
protected $isPalm = null;
|
23 |
-
protected $isWindows = null;
|
24 |
-
protected $isGeneric = null;
|
25 |
-
|
26 |
-
protected $devices = array(
|
27 |
-
"android" => "android",
|
28 |
-
"blackberry" => "blackberry",
|
29 |
-
"iphone" => "(iphone|ipod)",
|
30 |
-
"ipad" => "ipad",
|
31 |
-
"opera" => "opera mini",
|
32 |
-
"palm" => "(avantgo|blazer|elaine|hiptop|palm|plucker|xiino)",
|
33 |
-
"windows" => "windows ce; (iemobile|ppc|smartphone)",
|
34 |
-
"generic" => "(kindle|mobile|mmp|midp|o2|pda|pocket|psp|symbian|smartphone|treo|up.browser|up.link|vodafone|wap)"
|
35 |
-
);
|
36 |
-
|
37 |
-
public function __construct() {
|
38 |
-
$this->userAgent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
|
39 |
-
$this->accept = isset( $_SERVER['HTTP_ACCEPT'] ) ? $_SERVER['HTTP_ACCEPT'] : '';
|
40 |
-
|
41 |
-
if (isset($_SERVER['HTTP_X_WAP_PROFILE'])|| isset($_SERVER['HTTP_PROFILE'])) {
|
42 |
-
$this->isMobile = true;
|
43 |
-
} elseif (strpos($this->accept,'text/vnd.wap.wml') > 0 || strpos($this->accept,'application/vnd.wap.xhtml+xml') > 0) {
|
44 |
-
$this->isMobile = true;
|
45 |
-
} else {
|
46 |
-
foreach ($this->devices as $device => $regexp) {
|
47 |
-
if ($this->isDevice($device)) {
|
48 |
-
$this->isMobile = true;
|
49 |
-
}
|
50 |
-
}
|
51 |
-
}
|
52 |
-
}
|
53 |
-
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Overloads isAndroid() | isBlackberry() | isOpera() | isPalm() | isWindows() | isGeneric() through isDevice()
|
57 |
-
*
|
58 |
-
* @param string $name
|
59 |
-
* @param array $arguments
|
60 |
-
* @return bool
|
61 |
-
*/
|
62 |
-
public function __call($name, $arguments) {
|
63 |
-
$device = strtolower(substr($name, 2));
|
64 |
-
if ($name == "is" . ucfirst($device)) {
|
65 |
-
return $this->isDevice($device);
|
66 |
-
} else {
|
67 |
-
trigger_error("Method $name not defined", E_USER_ERROR);
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Returns true if any type of mobile device detected, including special ones
|
74 |
-
* @return bool
|
75 |
-
*/
|
76 |
-
public function isMobile() {
|
77 |
-
return $this->isMobile;
|
78 |
-
}
|
79 |
-
|
80 |
-
protected function isDevice($device) {
|
81 |
-
$var = "is" . ucfirst($device);
|
82 |
-
$return = $this->$var === null ? (bool) preg_match("/" . $this->devices[$device] . "/i", $this->userAgent) : $this->$var;
|
83 |
-
|
84 |
-
if ($device != 'generic' && $return == true) {
|
85 |
-
$this->isGeneric = false;
|
86 |
-
}
|
87 |
-
|
88 |
-
return $return;
|
89 |
-
}
|
90 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Mobile Detect
|
5 |
+
*
|
6 |
+
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
7 |
+
* @version SVN: $Id: Mobile_Detect.php 3 2009-05-21 13:06:28Z vic.stanciu $
|
8 |
+
* @version SVN: $Id: Mobile_Detect.php 3 2011-04-19 18:44:28Z sjevsejev $
|
9 |
+
*/
|
10 |
+
|
11 |
+
class wppa_mobile_detect {
|
12 |
+
|
13 |
+
protected $accept;
|
14 |
+
protected $userAgent;
|
15 |
+
|
16 |
+
protected $isMobile = false;
|
17 |
+
protected $isAndroid = null;
|
18 |
+
protected $isBlackberry = null;
|
19 |
+
protected $isIphone = null;
|
20 |
+
protected $isIpad = null;
|
21 |
+
protected $isOpera = null;
|
22 |
+
protected $isPalm = null;
|
23 |
+
protected $isWindows = null;
|
24 |
+
protected $isGeneric = null;
|
25 |
+
|
26 |
+
protected $devices = array(
|
27 |
+
"android" => "android",
|
28 |
+
"blackberry" => "blackberry",
|
29 |
+
"iphone" => "(iphone|ipod)",
|
30 |
+
"ipad" => "ipad",
|
31 |
+
"opera" => "opera mini",
|
32 |
+
"palm" => "(avantgo|blazer|elaine|hiptop|palm|plucker|xiino)",
|
33 |
+
"windows" => "windows ce; (iemobile|ppc|smartphone)",
|
34 |
+
"generic" => "(kindle|mobile|mmp|midp|o2|pda|pocket|psp|symbian|smartphone|treo|up.browser|up.link|vodafone|wap)"
|
35 |
+
);
|
36 |
+
|
37 |
+
public function __construct() {
|
38 |
+
$this->userAgent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
|
39 |
+
$this->accept = isset( $_SERVER['HTTP_ACCEPT'] ) ? $_SERVER['HTTP_ACCEPT'] : '';
|
40 |
+
|
41 |
+
if (isset($_SERVER['HTTP_X_WAP_PROFILE'])|| isset($_SERVER['HTTP_PROFILE'])) {
|
42 |
+
$this->isMobile = true;
|
43 |
+
} elseif (strpos($this->accept,'text/vnd.wap.wml') > 0 || strpos($this->accept,'application/vnd.wap.xhtml+xml') > 0) {
|
44 |
+
$this->isMobile = true;
|
45 |
+
} else {
|
46 |
+
foreach ($this->devices as $device => $regexp) {
|
47 |
+
if ($this->isDevice($device)) {
|
48 |
+
$this->isMobile = true;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Overloads isAndroid() | isBlackberry() | isOpera() | isPalm() | isWindows() | isGeneric() through isDevice()
|
57 |
+
*
|
58 |
+
* @param string $name
|
59 |
+
* @param array $arguments
|
60 |
+
* @return bool
|
61 |
+
*/
|
62 |
+
public function __call($name, $arguments) {
|
63 |
+
$device = strtolower(substr($name, 2));
|
64 |
+
if ($name == "is" . ucfirst($device)) {
|
65 |
+
return $this->isDevice($device);
|
66 |
+
} else {
|
67 |
+
trigger_error("Method $name not defined", E_USER_ERROR);
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Returns true if any type of mobile device detected, including special ones
|
74 |
+
* @return bool
|
75 |
+
*/
|
76 |
+
public function isMobile() {
|
77 |
+
return $this->isMobile;
|
78 |
+
}
|
79 |
+
|
80 |
+
protected function isDevice($device) {
|
81 |
+
$var = "is" . ucfirst($device);
|
82 |
+
$return = $this->$var === null ? (bool) preg_match("/" . $this->devices[$device] . "/i", $this->userAgent) : $this->$var;
|
83 |
+
|
84 |
+
if ($device != 'generic' && $return == true) {
|
85 |
+
$this->isGeneric = false;
|
86 |
+
}
|
87 |
+
|
88 |
+
return $return;
|
89 |
+
}
|
90 |
}
|
wppa-photo-admin-autosave.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* edit and delete photos
|
6 |
-
* Version 6.
|
7 |
*
|
8 |
*/
|
9 |
|
@@ -1550,11 +1550,26 @@ global $wpdb;
|
|
1550 |
background-color: rgb( 224, 255, 224 );
|
1551 |
border-color: rgb( 85, 238, 85 );
|
1552 |
}
|
1553 |
-
.wppa-pending {
|
1554 |
border: 1px solid;
|
1555 |
background-color: rgb( 255, 235, 232 );
|
1556 |
border-color: rgb( 204, 0, 0 );
|
1557 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1558 |
</style>
|
1559 |
<script>
|
1560 |
jQuery( function() {
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* edit and delete photos
|
6 |
+
* Version 6.5.02
|
7 |
*
|
8 |
*/
|
9 |
|
1550 |
background-color: rgb( 224, 255, 224 );
|
1551 |
border-color: rgb( 85, 238, 85 );
|
1552 |
}
|
1553 |
+
.wppa-pending, .wppa-scheduled, .wppa-private {
|
1554 |
border: 1px solid;
|
1555 |
background-color: rgb( 255, 235, 232 );
|
1556 |
border-color: rgb( 204, 0, 0 );
|
1557 |
}
|
1558 |
+
.wppa-bronze {
|
1559 |
+
border: 1px solid;
|
1560 |
+
background-color: rgb( 221, 221, 187 );
|
1561 |
+
border-color: rgb( 204, 204, 170 );
|
1562 |
+
}
|
1563 |
+
.wppa-silver {
|
1564 |
+
border: 1px solid;
|
1565 |
+
background-color: rgb( 255, 255, 255 );
|
1566 |
+
border-color: rgb( 238, 238, 238 );
|
1567 |
+
}
|
1568 |
+
.wppa-gold {
|
1569 |
+
border: 1px solid;
|
1570 |
+
background-color: rgb( 238, 238, 204 );
|
1571 |
+
border-color: rgb( 221, 221, 187 );
|
1572 |
+
}
|
1573 |
</style>
|
1574 |
<script>
|
1575 |
jQuery( function() {
|
wppa-settings-autosave.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* manage all options
|
6 |
-
* Version 6.5.
|
7 |
*
|
8 |
*/
|
9 |
|
@@ -2888,6 +2888,24 @@ global $wp_version;
|
|
2888 |
$clas = 'wppa_feup';
|
2889 |
$tags = 'upload';
|
2890 |
wppa_setting($slug, '15', $name, $desc, $html, $help, $clas, $tags);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2891 |
|
2892 |
}
|
2893 |
wppa_setting_subheader( 'J', '1', __( 'Miscellaneous visibility settings' , 'wp-photo-album-plus') );
|
@@ -6100,6 +6118,17 @@ global $wp_version;
|
|
6100 |
$clas = '';
|
6101 |
$tags = 'access,album';
|
6102 |
wppa_setting($slug, '2', $name, $desc, $html, $help, $clas, $tags);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6103 |
|
6104 |
// User upload limits
|
6105 |
$options = array( __('for ever', 'wp-photo-album-plus'),
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* manage all options
|
6 |
+
* Version 6.5.02
|
7 |
*
|
8 |
*/
|
9 |
|
2888 |
$clas = 'wppa_feup';
|
2889 |
$tags = 'upload';
|
2890 |
wppa_setting($slug, '15', $name, $desc, $html, $help, $clas, $tags);
|
2891 |
+
|
2892 |
+
$name = __('Blog It!', 'wp-photo-album-plus');
|
2893 |
+
$desc = __('Enable blogging photos.', 'wp-photo-album-plus');
|
2894 |
+
$help = esc_js( __('Users need the capability edit_posts to directly blog photos.', 'wp-photo-album-plus'));
|
2895 |
+
$slug = 'wppa_blog_it';
|
2896 |
+
$html = wppa_checkbox($slug);
|
2897 |
+
$clas = 'wppa_feup';
|
2898 |
+
$tags = 'upload';
|
2899 |
+
wppa_setting($slug, '16', $name, $desc, $html, $help, $clas, $tags);
|
2900 |
+
|
2901 |
+
$name = __('Blog It need moderation', 'wp-photo-album-plus');
|
2902 |
+
$desc = __('Posts with blogged photos need moderation.', 'wp-photo-album-plus');
|
2903 |
+
$help = '';
|
2904 |
+
$slug = 'wppa_blog_it_moderate';
|
2905 |
+
$html = wppa_checkbox($slug);
|
2906 |
+
$clas = 'wppa_feup';
|
2907 |
+
$tags = 'upload';
|
2908 |
+
wppa_setting($slug, '17', $name, $desc, $html, $help, $clas, $tags);
|
2909 |
|
2910 |
}
|
2911 |
wppa_setting_subheader( 'J', '1', __( 'Miscellaneous visibility settings' , 'wp-photo-album-plus') );
|
6118 |
$clas = '';
|
6119 |
$tags = 'access,album';
|
6120 |
wppa_setting($slug, '2', $name, $desc, $html, $help, $clas, $tags);
|
6121 |
+
|
6122 |
+
$name = __('User create Albums Captcha', 'wp-photo-album-plus');
|
6123 |
+
$desc = __('Uer must answer security question.', 'wp-photo-album-plus');
|
6124 |
+
$help = '';
|
6125 |
+
$slug = 'wppa_user_create_captcha';
|
6126 |
+
$html1 = wppa_checkbox($slug);
|
6127 |
+
$html2 = '';
|
6128 |
+
$html = array( $html1, $html2 );
|
6129 |
+
$clas = '';
|
6130 |
+
$tags = 'access,album';
|
6131 |
+
wppa_setting($slug, '3', $name, $desc, $html, $help, $clas, $tags);
|
6132 |
|
6133 |
// User upload limits
|
6134 |
$options = array( __('for ever', 'wp-photo-album-plus'),
|
wppa-setup.php
CHANGED
@@ -43,6 +43,7 @@ global $silent;
|
|
43 |
if ( $old_rev == $wppa_revno && ! $force ) return; // Nothing to do here
|
44 |
|
45 |
wppa_clear_cache(true); // Clear cache
|
|
|
46 |
|
47 |
$wppa_error = false; // Init no error
|
48 |
|
@@ -874,6 +875,8 @@ Hide Camera info
|
|
874 |
'wppa_up_tag_input_title' => __( 'Enter new tags:' , 'wp-photo-album-plus'),
|
875 |
'wppa_up_tag_preview' => 'yes',
|
876 |
'wppa_camera_connect' => 'yes',
|
|
|
|
|
877 |
|
878 |
// J Custom datafields
|
879 |
'wppa_album_custom_fields' => 'no',
|
@@ -1300,6 +1303,7 @@ Hide Camera info
|
|
1300 |
'wppa_spam_maxage' => 'none',
|
1301 |
'wppa_user_create_on' => 'no',
|
1302 |
'wppa_user_create_login' => 'yes',
|
|
|
1303 |
'wppa_user_destroy_on' => 'no',
|
1304 |
'wppa_upload_fronend_maxsize' => '0',
|
1305 |
'wppa_void_dups' => 'no',
|
@@ -1592,8 +1596,11 @@ Hide Camera info
|
|
1592 |
// QR code settings
|
1593 |
'wppa_qr_size' => '200',
|
1594 |
'wppa_qr_color' => '#000000',
|
1595 |
-
'wppa_qr_bgcolor' => '#FFFFFF'
|
1596 |
|
|
|
|
|
|
|
1597 |
);
|
1598 |
|
1599 |
array_walk( $wppa_defaults, 'wppa_set_default', $force );
|
43 |
if ( $old_rev == $wppa_revno && ! $force ) return; // Nothing to do here
|
44 |
|
45 |
wppa_clear_cache(true); // Clear cache
|
46 |
+
delete_option( 'wppa_dismiss_admin_notice_scripts_are_obsolete' );
|
47 |
|
48 |
$wppa_error = false; // Init no error
|
49 |
|
875 |
'wppa_up_tag_input_title' => __( 'Enter new tags:' , 'wp-photo-album-plus'),
|
876 |
'wppa_up_tag_preview' => 'yes',
|
877 |
'wppa_camera_connect' => 'yes',
|
878 |
+
'wppa_blog_it' => 'no',
|
879 |
+
'wppa_blog_it_moderate' => 'yes',
|
880 |
|
881 |
// J Custom datafields
|
882 |
'wppa_album_custom_fields' => 'no',
|
1303 |
'wppa_spam_maxage' => 'none',
|
1304 |
'wppa_user_create_on' => 'no',
|
1305 |
'wppa_user_create_login' => 'yes',
|
1306 |
+
'wppa_user_create_captcha' => 'yes', // VII-B3
|
1307 |
'wppa_user_destroy_on' => 'no',
|
1308 |
'wppa_upload_fronend_maxsize' => '0',
|
1309 |
'wppa_void_dups' => 'no',
|
1596 |
// QR code settings
|
1597 |
'wppa_qr_size' => '200',
|
1598 |
'wppa_qr_color' => '#000000',
|
1599 |
+
'wppa_qr_bgcolor' => '#FFFFFF',
|
1600 |
|
1601 |
+
|
1602 |
+
'wppa_dismiss_admin_notice_scripts_are_obsolete' => 'no',
|
1603 |
+
|
1604 |
);
|
1605 |
|
1606 |
array_walk( $wppa_defaults, 'wppa_set_default', $force );
|
wppa-source.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* Contains photo source file management routines
|
6 |
-
* Version 6.
|
7 |
*
|
8 |
*/
|
9 |
|
@@ -136,6 +136,8 @@ global $wppa_supported_photo_extensions;
|
|
136 |
foreach( $supext as $ext ) {
|
137 |
if ( is_file( $frompath.'.'.$ext ) ) {
|
138 |
@ copy( $frompath.'.'.$ext, $topath.'.'.$ext );
|
|
|
|
|
139 |
@ copy( $frompath.'-o1.'.$ext, $topath.'-o1.'.$ext );
|
140 |
}
|
141 |
}
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* Contains photo source file management routines
|
6 |
+
* Version 6.5.02
|
7 |
*
|
8 |
*/
|
9 |
|
136 |
foreach( $supext as $ext ) {
|
137 |
if ( is_file( $frompath.'.'.$ext ) ) {
|
138 |
@ copy( $frompath.'.'.$ext, $topath.'.'.$ext );
|
139 |
+
}
|
140 |
+
if ( is_file( $frompath.'-o1.'.$ext ) ) {
|
141 |
@ copy( $frompath.'-o1.'.$ext, $topath.'-o1.'.$ext );
|
142 |
}
|
143 |
}
|
wppa-tinymce-shortcodes.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Pachkage: wp-photo-album-plus
|
4 |
*
|
5 |
*
|
6 |
-
* Version 6.
|
7 |
*
|
8 |
*/
|
9 |
|
@@ -600,8 +600,10 @@ global $wpdb;
|
|
600 |
'<br />'.
|
601 |
'<small>'.
|
602 |
__('Specify the horizontal size in pixels or <span style="color:blue" >auto</span>.', 'wp-photo-album-plus').' '.
|
603 |
-
__('A value less than <span style="color:blue" >100</span> will automaticly be interpreted as a <span style="color:blue" >percentage</span> of the available space.', 'wp-photo-album-plus').
|
604 |
-
__('
|
|
|
|
|
605 |
'</td>'.
|
606 |
'</tr>'.
|
607 |
|
3 |
* Pachkage: wp-photo-album-plus
|
4 |
*
|
5 |
*
|
6 |
+
* Version 6.5.02
|
7 |
*
|
8 |
*/
|
9 |
|
600 |
'<br />'.
|
601 |
'<small>'.
|
602 |
__('Specify the horizontal size in pixels or <span style="color:blue" >auto</span>.', 'wp-photo-album-plus').' '.
|
603 |
+
__('A value less than <span style="color:blue" >100</span> will automaticly be interpreted as a <span style="color:blue" >percentage</span> of the available space.', 'wp-photo-album-plus').
|
604 |
+
__('For responsive with a fixed maximum, add the max to auto e.g. <span style="color:blue" >auto,550</span>', 'wp-photo-album-plus' ).'<br />'.
|
605 |
+
__('Leave this blank for default size', 'wp-photo-album-plus').
|
606 |
+
'</small>'.
|
607 |
'</td>'.
|
608 |
'</tr>'.
|
609 |
|
wppa-upload.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/* wppa-upload.php
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
-
* Contains all the upload
|
6 |
-
* Version 6.
|
7 |
*
|
8 |
*/
|
9 |
|
@@ -13,19 +13,59 @@ if ( ! defined( 'ABSPATH' ) ) die( "Can't load this file directly" );
|
|
13 |
function _wppa_page_upload() {
|
14 |
global $target;
|
15 |
global $wppa_revno;
|
|
|
16 |
|
17 |
// sanitize system
|
18 |
$user = wppa_get_user();
|
19 |
wppa_sanitize_files();
|
20 |
|
21 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
if ( wppa_switch( 'watermark_on' ) && ( wppa_switch( 'watermark_user' ) || current_user_can( 'wppa_settings' ) ) ) {
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
// If from album admin set the last album
|
28 |
-
if ( isset( $_REQUEST['wppa-set-album'] ) )
|
|
|
|
|
29 |
|
30 |
// Do the upload if requested
|
31 |
// From BOX A
|
@@ -35,7 +75,7 @@ global $wppa_revno;
|
|
35 |
if ( isset( $_POST['wppa-go-edit-multiple'] ) ) {
|
36 |
if ( current_user_can( 'wppa_admin' ) ) {
|
37 |
wppa_ok_message( __( 'Connecting to edit album...' , 'wp-photo-album-plus' ) ); ?>
|
38 |
-
<script type="text/javascript">document.location = '<?php echo( wppa_dbg_url( get_admin_url().'admin.php?page=wppa_admin_menu&tab=edit&edit_id='.$
|
39 |
<?php }
|
40 |
else {
|
41 |
wppa_ok_message( __( 'Connecting to edit photos...' , 'wp-photo-album-plus' ) ); ?>
|
@@ -50,7 +90,7 @@ global $wppa_revno;
|
|
50 |
if ( isset( $_POST['wppa-go-edit-single'] ) ) {
|
51 |
if ( current_user_can( 'wppa_admin' ) ) {
|
52 |
wppa_ok_message( __( 'Connecting to edit album...' , 'wp-photo-album-plus' ) ); ?>
|
53 |
-
<script type="text/javascript">document.location = '<?php echo( wppa_dbg_url( get_admin_url().'admin.php?page=wppa_admin_menu&tab=edit&edit_id='.$
|
54 |
<?php }
|
55 |
else {
|
56 |
wppa_ok_message( __( 'Connecting to edit photos...' , 'wp-photo-album-plus' ) ); ?>
|
@@ -72,27 +112,13 @@ global $wppa_revno;
|
|
72 |
// sanitize system again
|
73 |
wppa_sanitize_files();
|
74 |
|
75 |
-
?>
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
</
|
81 |
-
<?php $iconurl = WPPA_URL.'/images/arrow32.png'; ?>
|
82 |
-
<div id="icon-arrow" class="icon32" style="background: transparent url( <?php echo( $iconurl ); ?> ) no-repeat">
|
83 |
-
</div>
|
84 |
-
<?php $iconurl = WPPA_URL.'/images/album32.png'; ?>
|
85 |
-
<div id="icon-album" class="icon32" style="background: transparent url( <?php echo( $iconurl ); ?> ) no-repeat">
|
86 |
-
<br />
|
87 |
-
</div>
|
88 |
-
<h2><?php _e( 'Upload Photos' , 'wp-photo-album-plus'); ?></h2>
|
89 |
-
|
90 |
-
<?php
|
91 |
-
// Check for trivial requirements
|
92 |
-
if ( ! function_exists( 'wppa_imagecreatefromjpeg' ) ) {
|
93 |
-
wppa_error_message( __( 'There is a serious misconfiguration in your servers PHP config. Function wppa_imagecreatefromjpeg() does not exist. You will encounter problems when uploading photos and not be able to generate thumbnail images. Ask your hosting provider to add GD support with a minimal version 1.8.' , 'wp-photo-album-plus' ) );
|
94 |
-
}
|
95 |
|
|
|
96 |
$max_files = ini_get( 'max_file_uploads' );
|
97 |
$max_files_txt = $max_files;
|
98 |
if ( $max_files < '1' ) {
|
@@ -101,1252 +127,367 @@ global $wppa_revno;
|
|
101 |
}
|
102 |
$max_size = ini_get( 'upload_max_filesize' );
|
103 |
$max_time = ini_get( 'max_input_time' );
|
104 |
-
if ( $max_time < '1' ) $max_time = __( 'unknown'
|
105 |
-
|
106 |
-
//
|
107 |
-
if ( wppa_has_albums() ) {
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
<?php echo wppa_album_select_a( array( 'path' => wppa_switch( 'hier_albsel' ),'addpleaseselect' => true, 'checkowner' => true, 'checkupload' => true ) ) ?>
|
119 |
-
</select>
|
120 |
-
</p>
|
121 |
-
<?php if ( wppa_switch( 'watermark_on' ) && ( wppa_switch( 'watermark_user' ) || current_user_can( 'wppa_settings' ) ) ) { ?>
|
122 |
-
<p>
|
123 |
-
<?php _e( 'Apply watermark file:' , 'wp-photo-album-plus') ?>
|
124 |
-
<select name="wppa-watermark-file" id="wppa-watermark-file">
|
125 |
-
<?php echo( wppa_watermark_file_select() ) ?>
|
126 |
-
</select>
|
127 |
-
|
128 |
-
<?php _e( 'Position:' , 'wp-photo-album-plus') ?>
|
129 |
-
<select name="wppa-watermark-pos" id="wppa-watermark-pos">
|
130 |
-
<?php echo( wppa_watermark_pos_select() ) ?>
|
131 |
-
</select>
|
132 |
-
</p>
|
133 |
-
<?php } ?>
|
134 |
-
<input type="submit" class="button-primary" name="wppa-upload-multiple" value="<?php _e( 'Upload Photo' , 'wp-photo-album-plus') ?>" onclick="if ( document.getElementById( 'wppa-album-s' ).value == 0 ) { alert( '<?php _e( 'Please select an album' , 'wp-photo-album-plus') ?>' ); return false; }" />
|
135 |
-
<input type="checkbox" id="wppa-go-edit-multiple" name="wppa-go-edit-multiple" style="display:none" checked="checked" />
|
136 |
-
</form>
|
137 |
-
</div>
|
138 |
-
<?php }
|
139 |
-
else { ?>
|
140 |
-
<div style="border:1px solid #ccc; padding:10px; margin-bottom:10px; width: 600px; background-color:#fffbcc; border-color:#e6db55;">
|
141 |
-
<?php echo( sprintf( __( '<b>Notice:</b> your server allows you to upload <b>%s</b> files of maximum total <b>%s</b> bytes and allows <b>%s</b> seconds to complete.' , 'wp-photo-album-plus' ), $max_files_txt, $max_size, $max_time ) ) ?>
|
142 |
-
<?php _e( 'If your request exceeds these limitations, it will fail, probably without an errormessage.' , 'wp-photo-album-plus' ) ?>
|
143 |
-
<?php _e( 'Additionally your hosting provider may have set other limitations on uploading files.' , 'wp-photo-album-plus' ) ?>
|
144 |
-
<?php echo '<br />'.wppa_check_memory_limit() ?>
|
145 |
-
</div>
|
146 |
-
<?php /* Multple photos */ ?>
|
147 |
-
<div style="border:1px solid #ccc; padding:10px; margin-bottom:10px; width: 600px;">
|
148 |
-
<h3 style="margin-top:0px;"><?php _e( 'Box A:' , 'wp-photo-album-plus'); echo ' ';_e( 'Multiple Photos in one selection' , 'wp-photo-album-plus'); ?></h3>
|
149 |
-
<?php echo sprintf( __( 'You can select up to %s photos in one selection and upload them.' , 'wp-photo-album-plus'), $max_files_txt ); ?>
|
150 |
-
<br /><small style="color:blue" ><?php _e( 'You need a modern browser that supports HTML-5 to select multiple files' , 'wp-photo-album-plus') ?></small>
|
151 |
-
<form enctype="multipart/form-data" action="<?php echo( wppa_dbg_url( get_admin_url().'admin.php?page=wppa_upload_photos' ) ) ?>" method="post">
|
152 |
-
<?php wp_nonce_field( '$wppa_nonce', WPPA_NONCE ); ?>
|
153 |
-
<input id="my_files" type="file" multiple="multiple" name="my_files[]" onchange="showit()" />
|
154 |
-
<div id="files_list2">
|
155 |
-
<h3><?php _e( 'Selected Files:' , 'wp-photo-album-plus'); ?></h3>
|
156 |
-
|
157 |
-
</div>
|
158 |
-
<script type="text/javascript">
|
159 |
-
function showit() {
|
160 |
-
var maxsize = parseInt( '<?php echo $max_size ?>' ) * 1024 * 1024;
|
161 |
-
var maxcount = parseInt( '<?php echo $max_files_txt ?>' );
|
162 |
-
var totsize = 0;
|
163 |
-
var files = document.getElementById( 'my_files' ).files;
|
164 |
-
var tekst = '<h3><?php _e( 'Selected Files:' , 'wp-photo-album-plus') ?></h3>';
|
165 |
-
tekst += '<table><thead><tr>';
|
166 |
-
tekst += '<td><?php _e( 'Name' , 'wp-photo-album-plus') ?></td><td><?php _e( 'Size' , 'wp-photo-album-plus') ?></td><td><?php _e( 'Type' , 'wp-photo-album-plus') ?></td>';
|
167 |
-
tekst += '</tr></thead>';
|
168 |
-
tekst += '<tbody>';
|
169 |
-
tekst += '<tr><td><hr /></td><td><hr /></td><td><hr /></td></tr>';
|
170 |
-
for ( var i=0;i<files.length;i++ ) {
|
171 |
-
tekst += '<tr>';
|
172 |
-
tekst += '<td>' + files[i].name + '</td>';
|
173 |
-
tekst += '<td>' + files[i].size + '</td>';
|
174 |
-
totsize += files[i].size;
|
175 |
-
tekst += '<td>' + files[i].type + '</td>';
|
176 |
-
tekst += '</tr>';
|
177 |
-
}
|
178 |
-
tekst += '<tr><td><hr /></td><td><hr /></td><td><hr /></td></tr>';
|
179 |
-
var style1 = '';
|
180 |
-
var style2 = '';
|
181 |
-
var style3 = '';
|
182 |
-
var warn1 = '';
|
183 |
-
var warn2 = '';
|
184 |
-
var warn3 = '';
|
185 |
-
if ( maxcount > 0 && files.length > maxcount ) {
|
186 |
-
style1 = 'color:red';
|
187 |
-
warn1 = '<?php _e( 'Too many!' , 'wp-photo-album-plus') ?>';
|
188 |
-
}
|
189 |
-
if ( maxsize > 0 && totsize > maxsize ) {
|
190 |
-
style2 = 'color:red';
|
191 |
-
warn2 = '<?php _e( 'Too big!' , 'wp-photo-album-plus') ?>';
|
192 |
-
}
|
193 |
-
if ( warn1 || warn2 ) {
|
194 |
-
style3 = 'color:green';
|
195 |
-
warn3 = '<?php _e( 'Try again!' , 'wp-photo-album-plus') ?>';
|
196 |
-
}
|
197 |
-
tekst += '<tr><td style="'+style1+'" ><?php _e( 'Total' , 'wp-photo-album-plus') ?>: '+files.length+' '+warn1+'</td><td style="'+style2+'" >'+totsize+' '+warn2+'</td><td style="'+style3+'" >'+warn3+'</td></tr>';
|
198 |
-
tekst += '</tbody>';
|
199 |
-
tekst += '</table>';
|
200 |
-
jQuery( '#files_list2' ).html( tekst );
|
201 |
-
}
|
202 |
-
</script>
|
203 |
-
<p>
|
204 |
-
<label for="wppa-album"><?php _e( 'Album:' , 'wp-photo-album-plus'); ?> </label>
|
205 |
-
<select name="wppa-album" id="wppa-album-s">
|
206 |
-
<?php echo wppa_album_select_a( array( 'path' => wppa_switch( 'hier_albsel' ), 'addpleaseselect' => true, 'checkowner' => true, 'checkupload' => true ) ) ?>
|
207 |
-
</select>
|
208 |
-
</p>
|
209 |
-
<?php if ( wppa_switch( 'watermark_on' ) && ( wppa_switch( 'watermark_user' ) || current_user_can( 'wppa_settings' ) ) ) { ?>
|
210 |
-
<p>
|
211 |
-
<?php _e( 'Apply watermark file:' , 'wp-photo-album-plus') ?>
|
212 |
-
<select name="wppa-watermark-file" id="wppa-watermark-file">
|
213 |
-
<?php echo( wppa_watermark_file_select() ) ?>
|
214 |
-
</select>
|
215 |
-
|
216 |
-
<?php _e( 'Position:' , 'wp-photo-album-plus') ?>
|
217 |
-
<select name="wppa-watermark-pos" id="wppa-watermark-pos">
|
218 |
-
<?php echo( wppa_watermark_pos_select() ) ?>
|
219 |
-
</select>
|
220 |
-
</p>
|
221 |
-
<?php } ?>
|
222 |
-
<input type="submit" class="button-primary" name="wppa-upload-multiple" value="<?php _e( 'Upload Multiple Photos' , 'wp-photo-album-plus') ?>" onclick="if ( document.getElementById( 'wppa-album-s' ).value == 0 ) { alert( '<?php _e( 'Please select an album' , 'wp-photo-album-plus') ?>' ); return false; }" />
|
223 |
-
<input type="checkbox" id="wppa-go-edit-multiple" name="wppa-go-edit-multiple" onchange="wppaCookieCheckbox( this, 'wppa-go-edit-multiple' )" />
|
224 |
-
<script type="text/javascript" >
|
225 |
-
if ( wppa_getCookie( 'wppa-go-edit-multiple' ) == 'on' ) document.getElementById( 'wppa-go-edit-multiple' ).checked = 'checked';
|
226 |
-
</script>
|
227 |
-
<?php
|
228 |
-
if ( current_user_can( 'wppa_admin' ) ) {
|
229 |
-
_e( 'After upload: Go to the <b>Edit Album</b> page.' , 'wp-photo-album-plus');
|
230 |
-
}
|
231 |
-
else {
|
232 |
-
_e( 'After upload: Go to the <b>Edit Photos</b> page.' , 'wp-photo-album-plus');
|
233 |
-
}
|
234 |
-
?>
|
235 |
-
</form>
|
236 |
-
</div>
|
237 |
-
<?php /* End multiple */ ?>
|
238 |
-
|
239 |
-
<?php /* Single photos */ ?>
|
240 |
-
<div style="border:1px solid #ccc; padding:10px; margin-bottom:10px; width: 600px;">
|
241 |
-
<h3 style="margin-top:0px;"><?php _e( 'Box B:' , 'wp-photo-album-plus'); echo ' ';_e( 'Single Photos in multiple selections' , 'wp-photo-album-plus'); ?></h3>
|
242 |
-
<?php echo sprintf( __( 'You can select up to %s photos one by one and upload them at once.' , 'wp-photo-album-plus'), $max_files_txt ); ?>
|
243 |
-
<form enctype="multipart/form-data" action="<?php echo( wppa_dbg_url( get_admin_url().'admin.php?page=wppa_upload_photos' ) ) ?>" method="post">
|
244 |
-
<?php wp_nonce_field( '$wppa_nonce', WPPA_NONCE ); ?>
|
245 |
-
<input id="my_file_element" type="file" name="file_1" />
|
246 |
-
<div id="files_list">
|
247 |
-
<h3><?php _e( 'Selected Files:' , 'wp-photo-album-plus'); ?></h3>
|
248 |
-
|
249 |
-
</div>
|
250 |
-
<p>
|
251 |
-
<label for="wppa-album"><?php _e( 'Album:' , 'wp-photo-album-plus'); ?> </label>
|
252 |
-
<select name="wppa-album" id="wppa-album-m">
|
253 |
-
<?php echo wppa_album_select_a( array( 'path' => wppa_switch( 'hier_albsel' ), 'addpleaseselect' => true, 'checkowner' => true, 'checkupload' => true ) );//( '', '', false, false, false, false, false, true ) ); ?>
|
254 |
-
</select>
|
255 |
-
</p>
|
256 |
-
<?php if ( wppa_switch( 'watermark_on' ) && ( wppa_switch( 'watermark_user' ) || current_user_can( 'wppa_settings' ) ) ) { ?>
|
257 |
-
<p>
|
258 |
-
<?php _e( 'Apply watermark file:' , 'wp-photo-album-plus') ?>
|
259 |
-
<select name="wppa-watermark-file" id="wppa-watermark-file">
|
260 |
-
<?php echo( wppa_watermark_file_select() ) ?>
|
261 |
-
</select>
|
262 |
-
|
263 |
-
<?php _e( 'Position:' , 'wp-photo-album-plus') ?>
|
264 |
-
<select name="wppa-watermark-pos" id="wppa-watermark-pos">
|
265 |
-
<?php echo( wppa_watermark_pos_select() ) ?>
|
266 |
-
</select>
|
267 |
-
</p>
|
268 |
-
<?php } ?>
|
269 |
-
<input type="submit" class="button-primary" name="wppa-upload" value="<?php _e( 'Upload Single Photos' , 'wp-photo-album-plus') ?>" onclick="if ( document.getElementById( 'wppa-album-m' ).value == 0 ) { alert( '<?php _e( 'Please select an album' , 'wp-photo-album-plus') ?>' ); return false; }" />
|
270 |
-
<input type="checkbox" id="wppa-go-edit-single" name="wppa-go-edit-single" onchange="wppaCookieCheckbox( this, 'wppa-go-edit-single' )" />
|
271 |
-
<script type="text/javascript" >
|
272 |
-
if ( wppa_getCookie( 'wppa-go-edit-single' ) == 'on' ) document.getElementById( 'wppa-go-edit-single' ).checked = 'checked';
|
273 |
-
</script>
|
274 |
-
<?php
|
275 |
-
if ( current_user_can( 'wppa_admin' ) ) {
|
276 |
-
_e( 'After upload: Go to the <b>Edit Album</b> page.' , 'wp-photo-album-plus');
|
277 |
-
}
|
278 |
-
else {
|
279 |
-
_e( 'After upload: Go to the <b>Edit Photos</b> page.' , 'wp-photo-album-plus');
|
280 |
-
}
|
281 |
-
?>
|
282 |
-
</form>
|
283 |
-
<script type="text/javascript">
|
284 |
-
<!-- Create an instance of the multiSelector class, pass it the output target and the max number of files -->
|
285 |
-
var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), <?php echo( $max_files ) ?> );
|
286 |
-
<!-- Pass in the file element -->
|
287 |
-
multi_selector.addElement( document.getElementById( 'my_file_element' ) );
|
288 |
-
</script>
|
289 |
-
</div>
|
290 |
-
<?php /* End single photos */ ?>
|
291 |
-
|
292 |
-
<?php /* Single zips */ ?>
|
293 |
-
<?php if ( current_user_can( 'wppa_import' ) ) { ?>
|
294 |
-
<?php if ( PHP_VERSION_ID >= 50207 ) { ?>
|
295 |
-
<div style="border:1px solid #ccc; padding:10px; width: 600px;">
|
296 |
-
<h3 style="margin-top:0px;"><?php _e( 'Box C:' , 'wp-photo-album-plus'); echo ' ';_e( 'Zipped Photos in one selection' , 'wp-photo-album-plus'); ?></h3>
|
297 |
-
<?php echo sprintf( __( 'You can upload one zipfile. It will be placed in your personal wppa-depot: <b>.../%s</b><br/>Once uploaded, use <b>Import Photos</b> to unzip the file and place the photos in any album.' , 'wp-photo-album-plus'), WPPA_DEPOT ) ?>
|
298 |
-
<form enctype="multipart/form-data" action="<?php echo( wppa_dbg_url( get_admin_url().'admin.php?page=wppa_upload_photos' ) ) ?>" method="post">
|
299 |
-
<?php wp_nonce_field( '$wppa_nonce', WPPA_NONCE ); ?>
|
300 |
-
<input id="my_zipfile_element" type="file" name="file_zip" /><br/><br/>
|
301 |
-
<input type="submit" class="button-primary" name="wppa-upload-zip" value="<?php _e( 'Upload Zipped Photos' , 'wp-photo-album-plus') ?>" />
|
302 |
-
<input type="checkbox" id="wppa-go-import" name="wppa-go-import" onchange="wppaCookieCheckbox( this, 'wppa-go-import' )" />
|
303 |
-
<script type="text/javascript" >
|
304 |
-
if ( wppa_getCookie( 'wppa-go-import' ) == 'on' ) document.getElementById( 'wppa-go-import' ).checked = 'checked';
|
305 |
-
</script>
|
306 |
-
<?php _e( 'After upload: Go to the <b>Import Photos</b> page.' , 'wp-photo-album-plus') ?>
|
307 |
-
</form>
|
308 |
-
</div>
|
309 |
-
<?php }
|
310 |
-
else { ?>
|
311 |
-
<div style="border:1px solid #ccc; padding:10px; width: 600px;">
|
312 |
-
<?php _e( '<small>Ask your administrator to upgrade php to version 5.2.7 or later. This will enable you to upload zipped photos.</small>' , 'wp-photo-album-plus') ?>
|
313 |
-
</div>
|
314 |
-
<?php }
|
315 |
-
}
|
316 |
-
}
|
317 |
-
}
|
318 |
-
else { ?>
|
319 |
-
<?php $url = wppa_dbg_url( get_admin_url().'admin.php?page=wppa_admin_menu' ); ?>
|
320 |
-
<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>
|
321 |
-
<?php } ?>
|
322 |
-
</div>
|
323 |
-
<?php
|
324 |
-
}
|
325 |
-
|
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 |
-
global $wppa_session;
|
334 |
-
|
335 |
-
if ( wppa( 'ajax' ) ) ob_start(); // Suppress output if ajax operation
|
336 |
-
|
337 |
-
// Init
|
338 |
-
$ngg_opts = get_option( 'ngg_options', false );
|
339 |
-
$user = wppa_get_user();
|
340 |
-
|
341 |
-
// Check database
|
342 |
-
wppa_check_database( true );
|
343 |
-
|
344 |
-
// Update watermark settings
|
345 |
-
if ( wppa_switch( 'watermark_on' ) && ( wppa_switch( 'watermark_user' ) || current_user_can( 'wppa_settings' ) ) ) {
|
346 |
-
if ( isset( $_POST['wppa-watermark-file'] ) ) update_option( 'wppa_watermark_file_'.$user, $_POST['wppa-watermark-file'] );
|
347 |
-
if ( isset( $_POST['wppa-watermark-pos'] ) ) update_option( 'wppa_watermark_pos_'.$user, $_POST['wppa-watermark-pos'] );
|
348 |
-
}
|
349 |
-
|
350 |
-
// Update last used albums
|
351 |
-
if ( isset( $_POST['wppa-photo-album'] ) ) {
|
352 |
-
update_option( 'wppa-photo-album-import-'.wppa_get_user(), $_POST['wppa-photo-album'] ); // nog in form verwerken
|
353 |
-
}
|
354 |
-
if ( isset( $_POST['wppa-video-album'] ) ) {
|
355 |
-
update_option( 'wppa-video-album-import-'.wppa_get_user(), $_POST['wppa-video-album'] );
|
356 |
-
}
|
357 |
-
if ( isset( $_POST['wppa-audio-album'] ) ) {
|
358 |
-
update_option( 'wppa-audio-album-import-'.wppa_get_user(), $_POST['wppa-audio-album'] );
|
359 |
-
}
|
360 |
-
|
361 |
-
// Verify last albums still exist
|
362 |
-
$alb = get_option( 'wppa-photo-album-import-'.wppa_get_user(), '0' );
|
363 |
-
if ( $alb ) {
|
364 |
-
$exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $alb ) );
|
365 |
-
if ( ! $exists ) update_option( 'wppa-photo-album-import-'.wppa_get_user(), '0' );
|
366 |
-
}
|
367 |
-
$alb = get_option( 'wppa-video-album-import-'.wppa_get_user(), '0' );
|
368 |
-
if ( $alb ) {
|
369 |
-
$exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $alb ) );
|
370 |
-
if ( ! $exists ) update_option( 'wppa-video-album-import-'.wppa_get_user(), '0' );
|
371 |
-
}
|
372 |
-
$alb = get_option( 'wppa-audio-album-import-'.wppa_get_user(), '0' );
|
373 |
-
if ( $alb ) {
|
374 |
-
$exists = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $alb ) );
|
375 |
-
if ( ! $exists ) update_option( 'wppa-audio-album-import-'.wppa_get_user(), '0' );
|
376 |
-
}
|
377 |
-
|
378 |
-
// Extract zip
|
379 |
-
if ( isset( $_GET['zip'] ) ) {
|
380 |
-
wppa_extract( $_GET['zip'], true );
|
381 |
-
}
|
382 |
-
|
383 |
-
// Set local / remote
|
384 |
-
if ( isset( $_POST['wppa-local-remote'] ) ) {
|
385 |
-
check_admin_referer( '$wppa_nonce', WPPA_NONCE );
|
386 |
-
update_option( 'wppa_import_source_type_'.$user, $_POST['wppa-local-remote'] );
|
387 |
-
}
|
388 |
-
|
389 |
-
// Set import source dir ( when local )
|
390 |
-
if ( isset( $_POST['wppa-import-set-source-dir'] ) ) {
|
391 |
-
check_admin_referer( '$wppa_nonce', WPPA_NONCE );
|
392 |
-
if ( isset( $_POST['wppa-source'] ) ) {
|
393 |
-
update_option( 'wppa_import_source_'.$user, $_POST['wppa-source'] );
|
394 |
-
}
|
395 |
-
}
|
396 |
-
|
397 |
-
// Set import source url ( when remote )
|
398 |
-
if ( isset( $_POST['wppa-import-set-source-url'] ) ) {
|
399 |
-
check_admin_referer( '$wppa_nonce', WPPA_NONCE );
|
400 |
-
if ( isset( $_POST['wppa-source-remote'] ) ) {
|
401 |
-
update_option( 'wppa_import_source_url_'.$user, $_POST['wppa-source-remote'] );
|
402 |
-
update_option( 'wppa_import_source_url_found_'.$user, false );
|
403 |
-
update_option( 'wppa_import_remote_max_'.$user, strval( intval( $_POST['wppa-import-remote-max'] ) ) );
|
404 |
-
}
|
405 |
-
}
|
406 |
-
|
407 |
-
// Hit the submit button
|
408 |
-
if ( isset( $_POST['wppa-import-submit'] ) ) {
|
409 |
-
if ( wppa( 'ajax' ) ) {
|
410 |
-
if ( ! wp_verify_nonce( $_POST['wppa-update-check'], '$wppa_nonce' ) ) {
|
411 |
-
echo $_POST['wppa-update-check'].' Security check failure';
|
412 |
-
wppa_exit();
|
413 |
-
}
|
414 |
-
}
|
415 |
-
else {
|
416 |
-
check_admin_referer( '$wppa_nonce', WPPA_NONCE );
|
417 |
-
}
|
418 |
-
if ( isset( $_POST['del-after-p'] ) ) $delp = true; else $delp = false;
|
419 |
-
if ( isset( $_POST['del-after-f'] ) ) $delf = true; else $delf = false;
|
420 |
-
if ( isset( $_POST['del-after-a'] ) ) $dela = true; else $dela = false;
|
421 |
-
if ( isset( $_POST['del-after-z'] ) ) $delz = true; else $delz = false;
|
422 |
-
if ( isset( $_POST['del-after-v'] ) ) $delv = true; else $delv = false;
|
423 |
-
if ( isset( $_POST['del-after-u'] ) ) $delu = true; else $delu = false;
|
424 |
-
if ( isset( $_POST['del-after-c'] ) ) $delc = true; else $delc = false;
|
425 |
-
|
426 |
-
wppa_import_photos( $delp, $dela, $delz, $delv, $delu, $delc, $delf );
|
427 |
-
}
|
428 |
-
|
429 |
-
// Continue dirimport after timeout
|
430 |
-
elseif ( isset( $_GET['continue'] ) ) {
|
431 |
-
if ( wp_verify_nonce( $_GET['nonce'], 'dirimport' ) ) wppa_import_photos();
|
432 |
-
}
|
433 |
-
|
434 |
-
// If we did this by ajax, setup reporting results for it
|
435 |
-
if ( wppa( 'ajax' ) ) {
|
436 |
-
ob_end_clean();
|
437 |
-
if ( wppa( 'ajax_import_files_done' ) ) {
|
438 |
-
echo '<span style="color:green" >' . wppa( 'ajax_import_files' ) . ' ' . __( 'Done!', 'wp-photo-album-plus' ) . '</span>';
|
439 |
-
}
|
440 |
-
elseif ( wppa( 'ajax_import_files_error' ) ) {
|
441 |
-
echo '<span style="color:red" >' . wppa( 'ajax_import_files' ) . ' ' . wppa( 'ajax_import_files_error' ) . '</span>';
|
442 |
-
}
|
443 |
-
else {
|
444 |
-
echo '<span style="color:red" >' . wppa( 'ajax_import_files' ) . ' ' . __( 'Failed!', 'wp-photo-album-plus' ) . '</span>';
|
445 |
-
}
|
446 |
-
wppa_exit();
|
447 |
-
}
|
448 |
-
|
449 |
-
?>
|
450 |
-
|
451 |
-
<div class="wrap">
|
452 |
-
<?php $iconurl = WPPA_URL.'/images/camera32.png'; ?>
|
453 |
-
<div id="icon-camera" class="icon32" style="background: transparent url( <?php echo( $iconurl ); ?> ) no-repeat"></div>
|
454 |
-
<?php $iconurl = WPPA_URL.'/images/arrow32.png'; ?>
|
455 |
-
<div id="icon-arrow" class="icon32" style="background: transparent url( <?php echo( $iconurl ); ?> ) no-repeat"></div>
|
456 |
-
<?php $iconurl = WPPA_URL.'/images/album32.png'; ?>
|
457 |
-
<div id="icon-album" class="icon32" style="background: transparent url( <?php echo( $iconurl ); ?> ) no-repeat"><br /></div>
|
458 |
-
|
459 |
-
<h2><?php _e( 'Import Photos' , 'wp-photo-album-plus'); ?></h2><br />
|
460 |
-
<?php
|
461 |
-
|
462 |
-
// Get this users current source directory setting
|
463 |
-
$can_remote = ini_get( 'allow_url_fopen' ) && function_exists( 'curl_init' );
|
464 |
-
// $can_remote = false; // Debug
|
465 |
-
if ( ! $can_remote ) {
|
466 |
-
update_option( 'wppa_import_source_type_'.$user, 'local' );
|
467 |
-
}
|
468 |
-
$source_type = get_option( 'wppa_import_source_type_'.$user, 'local' );
|
469 |
-
if ( $source_type == 'local' ) {
|
470 |
-
$source = get_option( 'wppa_import_source_'.$user, WPPA_DEPOT_PATH );
|
471 |
-
if ( ! $source || ! is_dir( $source ) ) {
|
472 |
-
$source = WPPA_DEPOT_PATH;
|
473 |
-
update_option( 'wppa_import_source_'.$user, WPPA_DEPOT_PATH );
|
474 |
-
}
|
475 |
-
|
476 |
-
// See if the current source is the 'home' directory
|
477 |
-
$is_depot = ( $source == WPPA_DEPOT_PATH );
|
478 |
-
|
479 |
-
// See if the current source is a subdir of my depot
|
480 |
-
$is_sub_depot = ( substr( $source, 0, strlen( WPPA_DEPOT_PATH ) ) == WPPA_DEPOT_PATH );
|
481 |
-
|
482 |
-
// Sanitize system
|
483 |
-
if ( $is_sub_depot ) {
|
484 |
-
wppa_sanitize_files();
|
485 |
-
}
|
486 |
-
|
487 |
-
// See what's in there
|
488 |
-
$files = wppa_get_import_files();
|
489 |
-
$zipcount = wppa_get_zipcount( $files );
|
490 |
-
$albumcount = wppa_get_albumcount( $files );
|
491 |
-
$photocount = wppa_get_photocount( $files );
|
492 |
-
$videocount = wppa_get_video_count( $files );
|
493 |
-
$audiocount = wppa_get_audio_count( $files );
|
494 |
-
$dircount = $is_depot ? wppa_get_dircount( $files ) : '0';
|
495 |
-
$csvcount = $is_depot ? wppa_get_csvcount( $files ) : '0';
|
496 |
-
// echo 'zips:'.$zipcount,' albs:'.$albumcount.' pho:'.$photocount.' dirs:'.$dircount;
|
497 |
-
if ( $ngg_opts ) {
|
498 |
-
$is_ngg = strpos( $source, $ngg_opts['gallerypath'] ) !== false; // this is false for the ngg root !!
|
499 |
-
}
|
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;
|
508 |
-
$is_sub_depot = false;
|
509 |
-
$files = wppa_get_import_files();
|
510 |
-
$zipcount = '0';
|
511 |
-
$albumcount = '0';
|
512 |
-
$photocount = $files ? count( $files ) : '0';
|
513 |
-
$videocount = '0';
|
514 |
-
$audiocount = '0';
|
515 |
-
$dircount = '0';
|
516 |
-
$csvcount = '0';
|
517 |
-
$is_ngg = false;
|
518 |
-
$remote_max = get_option( 'wppa_import_remote_max_'.$user, '10' );
|
519 |
-
}
|
520 |
-
|
521 |
-
?>
|
522 |
-
<form action="<?php echo( wppa_dbg_url( get_admin_url().'admin.php?page=wppa_import_photos' ) ) ?>" method="post">
|
523 |
-
<?php if ( wppa_user_is( 'administrator' ) || ! wppa_switch( 'chgsrc_is_restricted' ) ) { ?>
|
524 |
-
|
525 |
-
<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >
|
526 |
-
<?php
|
527 |
-
wp_nonce_field( '$wppa_nonce', WPPA_NONCE );
|
528 |
-
_e( 'Select Local or Remote' , 'wp-photo-album-plus');
|
529 |
-
$disabled = $can_remote ? '' : 'disabled="disabled"';
|
530 |
-
?>
|
531 |
-
<select name="wppa-local-remote" >
|
532 |
-
<option value="local" <?php if ( $source_type == 'local' ) echo 'selected="selected"' ?>><?php _e( 'Local' , 'wp-photo-album-plus') ?></option>
|
533 |
-
<option value="remote" <?php echo $disabled; if ( $source_type == 'remote' ) echo 'selected="selected"' ?>><?php _e( 'Remote' , 'wp-photo-album-plus') ?></option>
|
534 |
-
</select>
|
535 |
-
<?php if ( $can_remote ) { ?>
|
536 |
-
<input type="submit" class="button-secundary" name="wppa-import-set-source" value="<?php _e( 'Set Local/Remote' , 'wp-photo-album-plus'); ?>" />
|
537 |
-
<?php } else {
|
538 |
-
if ( ! ini_get( 'allow_url_fopen' ) )
|
539 |
-
_e( 'The server does not allow you to import from remote locations. ( The php directive allow_url_fopen is not set to 1 )' , 'wp-photo-album-plus');
|
540 |
-
if ( ! function_exists( 'curl_init' ) )
|
541 |
-
_e( 'The server does not allow you to import from remote locations. ( The curl functions are not set up )' , 'wp-photo-album-plus');
|
542 |
-
} ?>
|
543 |
-
</div>
|
544 |
-
<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >
|
545 |
-
<?php wp_nonce_field( '$wppa_nonce', WPPA_NONCE ); ?>
|
546 |
-
<?php _e( 'Import photos from:' , 'wp-photo-album-plus'); ?>
|
547 |
-
<?php if ( $source_type == 'local' ) { ?>
|
548 |
-
<select name="wppa-source">
|
549 |
-
<?php wppa_abs_walktree( wppa_opt( 'import_root'), $source ) ?>
|
550 |
-
</select>
|
551 |
-
<input type="submit" class="button-secundary" name="wppa-import-set-source-dir" value="<?php _e( 'Set source directory' , 'wp-photo-album-plus'); ?>" />
|
552 |
-
<?php } else { ?>
|
553 |
-
<input type="text" style="width:50%" name="wppa-source-remote" value="<?php echo $source ?>" />
|
554 |
-
<?php _e( 'Max:' , 'wp-photo-album-plus') ?>
|
555 |
-
<input type="text" style="width:50px;" name="wppa-import-remote-max" value="<?php echo $remote_max ?>" />
|
556 |
-
<input type="submit" onclick="jQuery( '#rem-rem' ).css( 'display','inline' ); return true;" class="button-secundary" name="wppa-import-set-source-url" value="<?php _e( 'Find remote photos' , 'wp-photo-album-plus'); ?>" />
|
557 |
-
<span id="rem-rem" style="display:none;"><?php _e( 'Working, please wait...' , 'wp-photo-album-plus') ?></span>
|
558 |
-
<?php _e( '<br />You can enter either a web page address like <i>http://mysite.com/mypage/</i> or a full url to an image file like <i>http://mysite.com/wp-content/uploads/wppa/4711.jpg</i>' , 'wp-photo-album-plus'); ?>
|
559 |
-
<?php } ?>
|
560 |
-
</div>
|
561 |
-
|
562 |
-
<?php } ?>
|
563 |
-
</form>
|
564 |
-
|
565 |
-
<?php
|
566 |
-
// check if albums exist or will be made before allowing upload
|
567 |
-
if ( wppa_has_albums() || $albumcount > '0' || $zipcount >'0' || $dircount > '0' || $videocount > '0' || $audiocount > '0' || $csvcount > '0' ) {
|
568 |
-
|
569 |
-
if ( $photocount > '0' || $albumcount > '0' || $zipcount >'0' || $dircount > '0' || $videocount > '0' || $audiocount > '0' || $csvcount > '0' ) { ?>
|
570 |
-
|
571 |
-
<form action="<?php echo( wppa_dbg_url( get_admin_url().'admin.php?page=wppa_import_photos' ) ) ?>" method="post">
|
572 |
-
<?php wp_nonce_field( '$wppa_nonce', WPPA_NONCE );
|
573 |
-
|
574 |
-
// Display the zips
|
575 |
-
if ( PHP_VERSION_ID >= 50207 && $zipcount > '0' ) { ?>
|
576 |
-
<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >
|
577 |
-
<p><b>
|
578 |
-
<?php _e( 'There are' , 'wp-photo-album-plus'); echo( ' '.$zipcount.' ' ); _e( 'zipfiles in the depot.' , 'wp-photo-album-plus') ?><br/>
|
579 |
-
</b></p>
|
580 |
-
<table class="form-table wppa-table widefat" style="margin-bottom:0;" >
|
581 |
-
<thead>
|
582 |
-
<tr>
|
583 |
-
<td>
|
584 |
-
<input type="checkbox" id="all-zip" checked="checked" onchange="checkAll( 'all-zip', '.wppa-zip' )" /><b> <?php _e( 'Check/uncheck all' , 'wp-photo-album-plus') ?></b>
|
585 |
-
</td>
|
586 |
-
<?php if ( $is_sub_depot ) { ?>
|
587 |
-
<td>
|
588 |
-
<input type="checkbox" id="del-after-z" name="del-after-z" checked="checked" /><b> <?php _e( 'Delete after successful extraction.' , 'wp-photo-album-plus'); ?></b>
|
589 |
-
</td>
|
590 |
-
<?php } ?>
|
591 |
-
</tr>
|
592 |
-
</thead>
|
593 |
-
</table>
|
594 |
-
<table class="form-table wppa-table widefat" style="margin-top:0;" >
|
595 |
-
<tr>
|
596 |
-
<?php
|
597 |
-
$ct = 0;
|
598 |
-
$idx = '0';
|
599 |
-
foreach ( $files as $file ) {
|
600 |
-
|
601 |
-
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
602 |
-
if ( $ext == 'zip' ) { ?>
|
603 |
-
<td>
|
604 |
-
<input type="checkbox" id="file-<?php echo( $idx ) ?>" name="file-<?php echo( $idx ) ?>" class="wppa-zip" checked="checked" /> <?php echo( wppa_sanitize_file_name( basename( $file ) ) ); ?>
|
605 |
-
</td>
|
606 |
-
<?php if ( $ct == 3 ) {
|
607 |
-
echo( '</tr><tr>' );
|
608 |
-
$ct = 0;
|
609 |
-
}
|
610 |
-
else {
|
611 |
-
$ct++;
|
612 |
-
}
|
613 |
-
}
|
614 |
-
$idx++;
|
615 |
-
} ?>
|
616 |
-
</tr>
|
617 |
-
</table>
|
618 |
-
</div>
|
619 |
-
<?php }
|
620 |
-
|
621 |
-
// Dispay the albums ( .amf files )
|
622 |
-
if ( $albumcount > '0' ) { ?>
|
623 |
-
<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >
|
624 |
-
<p><b>
|
625 |
-
<?php _e( 'There are' , 'wp-photo-album-plus'); echo( ' '.$albumcount.' ' ); _e( 'albumdefinitions in the depot.' , 'wp-photo-album-plus') ?><br/>
|
626 |
-
</b></p>
|
627 |
-
<table class="form-table wppa-table widefat" style="margin-bottom:0;" >
|
628 |
-
<thead>
|
629 |
-
<tr>
|
630 |
-
<td>
|
631 |
-
<input type="checkbox" id="all-amf" checked="checked" onchange="checkAll( 'all-amf', '.wppa-amf' )" /><b> <?php _e( 'Check/uncheck all' , 'wp-photo-album-plus') ?></b>
|
632 |
-
</td>
|
633 |
-
<?php if ( $is_sub_depot ) { ?>
|
634 |
-
<td>
|
635 |
-
<input type="checkbox" id="del-after-a" name="del-after-a" checked="checked" /><b> <?php _e( 'Remove from depot after successful import, or if the album already exists.' , 'wp-photo-album-plus'); ?></b>
|
636 |
-
</td>
|
637 |
-
<?php } ?>
|
638 |
-
</tr>
|
639 |
-
</thead>
|
640 |
-
</table>
|
641 |
-
<table class="form-table wppa-table widefat" style="margin-top:0;" >
|
642 |
-
<tr>
|
643 |
-
<?php
|
644 |
-
$ct = 0;
|
645 |
-
$idx = '0';
|
646 |
-
foreach ( $files as $file ) {
|
647 |
-
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
648 |
-
if ( $ext == 'amf' ) { ?>
|
649 |
-
<td>
|
650 |
-
<input type="checkbox" id="file-<?php echo( $idx ) ?>" name="file-<?php echo( $idx ) ?>" class="wppa-amf" checked="checked" /> <?php echo( basename( $file ) ); ?> <?php echo( stripslashes( wppa_get_meta_name( $file, '( ' ) ) ) ?>
|
651 |
-
</td>
|
652 |
-
<?php if ( $ct == 3 ) {
|
653 |
-
echo( '</tr><tr>' );
|
654 |
-
$ct = 0;
|
655 |
-
}
|
656 |
-
else {
|
657 |
-
$ct++;
|
658 |
-
}
|
659 |
-
}
|
660 |
-
$idx++;
|
661 |
-
} ?>
|
662 |
-
</tr>
|
663 |
-
</table>
|
664 |
-
</div>
|
665 |
-
<?php }
|
666 |
-
|
667 |
-
// Display the single photos
|
668 |
-
if ( $photocount > '0' ) { ?>
|
669 |
-
<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >
|
670 |
-
<p><b>
|
671 |
-
<?php _e( 'There are' , 'wp-photo-album-plus'); echo( ' '.$photocount.' ' );
|
672 |
-
if ( $source_type == 'local' ) {
|
673 |
-
if ( $is_ngg ) {
|
674 |
-
_e( 'photos in the ngg gallery.' , 'wp-photo-album-plus');
|
675 |
-
}
|
676 |
-
else _e( 'photos in the depot.' , 'wp-photo-album-plus');
|
677 |
-
}
|
678 |
-
else _e( 'possible photos found remote.' , 'wp-photo-album-plus');
|
679 |
-
if ( wppa_switch( 'resize_on_upload' ) ) { echo( ' ' ); _e( 'Photos will be downsized during import.' , 'wp-photo-album-plus'); } ?><br/>
|
680 |
-
</b></p>
|
681 |
-
<p class="hideifupdate" >
|
682 |
-
<?php _e( 'Default album for import:' , 'wp-photo-album-plus') ?>
|
683 |
-
<select name="wppa-photo-album" id="wppa-photo-album">
|
684 |
-
<?php echo wppa_album_select_a( array( 'path' => wppa_switch( 'hier_albsel' ),
|
685 |
-
'selected' => get_option( 'wppa-photo-album-import-'.wppa_get_user(), '0' ),
|
686 |
-
'addpleaseselect' => true,
|
687 |
-
'checkowner' => true,
|
688 |
-
'checkupload' => true
|
689 |
-
) ) ?>
|
690 |
-
</select>
|
691 |
-
<?php _e( 'Photos that have (<em>name</em>)[<em>album</em>] will be imported by that <em>name</em> in that <em>album</em>.' , 'wp-photo-album-plus') ?>
|
692 |
-
</p>
|
693 |
-
<?php if ( wppa_switch( 'watermark_on' ) && ( wppa_switch( 'watermark_user' ) || current_user_can( 'wppa_settings' ) ) ) { ?>
|
694 |
-
<p>
|
695 |
-
<?php _e( 'Apply watermark file:' , 'wp-photo-album-plus') ?>
|
696 |
-
<select name="wppa-watermark-file" id="wppa-watermark-file">
|
697 |
-
<?php echo( wppa_watermark_file_select() ) ?>
|
698 |
-
</select>
|
699 |
-
<?php _e( 'Position:' , 'wp-photo-album-plus') ?>
|
700 |
-
<select name="wppa-watermark-pos" id="wppa-watermark-pos">
|
701 |
-
<?php echo( wppa_watermark_pos_select() ) ?>
|
702 |
-
</select>
|
703 |
-
</p>
|
704 |
-
<?php } ?>
|
705 |
-
<table class="form-table wppa-table widefat" style="margin-bottom:0;" >
|
706 |
-
<thead>
|
707 |
-
<tr>
|
708 |
-
<td>
|
709 |
-
<input type="checkbox" id="all-pho" <?php if ( $is_sub_depot ) echo( 'checked="checked"' ) ?> onchange="checkAll( 'all-pho', '.wppa-pho' )" /><b> <?php _e( 'Check/uncheck all' , 'wp-photo-album-plus') ?></b>
|
710 |
-
</td>
|
711 |
-
<?php if ( $is_sub_depot ) { ?>
|
712 |
-
<td>
|
713 |
-
<input type="checkbox" id="del-after-p" name="del-after-p" checked="checked" /><b> <?php _e( 'Remove from depot after successful import.' , 'wp-photo-album-plus'); ?></b>
|
714 |
-
</td>
|
715 |
-
<td>
|
716 |
-
<input type="checkbox" id="del-after-f" name="del-after-f" /><b> <?php _e( 'Remove from depot after failed import.' , 'wp-photo-album-plus'); ?></b>
|
717 |
-
</td>
|
718 |
-
<?php } ?>
|
719 |
-
<?php if ( $is_ngg ) { ?>
|
720 |
-
<td>
|
721 |
-
<input type="checkbox" id="cre-album" name="cre-album" checked="checked" value="<?php echo esc_attr( basename( $source ) ) ?>" /><b> <?php echo sprintf( __( 'Import into album <i>%s</i>.' , 'wp-photo-album-plus'), basename( $source ) ); ?></b>
|
722 |
-
<br /><small><?php _e( 'The album will be created if it does not exist' , 'wp-photo-album-plus') ?></small>
|
723 |
-
</td>
|
724 |
-
<td>
|
725 |
-
<input type="checkbox" id="use-backup" name="use-backup" checked="checked" /><b> <?php _e( 'Use backup if available' , 'wp-photo-album-plus') ?></b>
|
726 |
-
</td>
|
727 |
-
<?php } ?>
|
728 |
-
<td>
|
729 |
-
<input type="checkbox" id="wppa-update" onchange="impUpd( this, '#submit' )" name="wppa-update"><b> <?php _e( 'Update existing photos' , 'wp-photo-album-plus') ?></b>
|
730 |
-
</td>
|
731 |
-
<td>
|
732 |
-
<?php if ( wppa_switch( 'void_dups' ) ) { ?>
|
733 |
-
<input type="hidden" id="wppa-nodups" name="wppa-nodups" value="true" />
|
734 |
-
<?php } else { ?>
|
735 |
-
<input type="checkbox" id="wppa-nodups" name="wppa-nodups" checked="checked" ><b> <?php _e( 'Do not create duplicates' , 'wp-photo-album-plus') ?></b>
|
736 |
-
<?php } ?>
|
737 |
-
</td>
|
738 |
-
<?php
|
739 |
-
if ( wppa_switch( 'import_preview' ) ) { ?>
|
740 |
-
<td>
|
741 |
-
<input type="checkbox" id="wppa-zoom" onclick="wppa_setCookie('zoompreview', this.checked, '365')" ><b> <?php _e( 'Zoom previews' , 'wp-photo-album-plus') ?></b>
|
742 |
-
<script type="text/javascript">if ( wppa_getCookie('zoompreview') == true ) { jQuery('#wppa-zoom').attr('checked', 'checked') }</script>
|
743 |
-
</td>
|
744 |
-
<?php } ?>
|
745 |
-
</tr>
|
746 |
-
</thead>
|
747 |
-
</table>
|
748 |
-
<table class="form-table wppa-table widefat" style="margin-top:0;" >
|
749 |
-
<tr>
|
750 |
-
<?php
|
751 |
-
$ct = 0;
|
752 |
-
$idx = '0';
|
753 |
-
if ( is_array( $files ) ) foreach ( $files as $file ) {
|
754 |
-
$ext = wppa_get_ext( $file ); //strtolower( substr( strrchr( $file, "." ), 1 ) );
|
755 |
-
$meta = wppa_strip_ext( $file ).'.PMF';
|
756 |
-
if ( ! is_file( $meta ) ) {
|
757 |
-
$meta = wppa_strip_ext( $file ).'.pmf';
|
758 |
-
}
|
759 |
-
if ( in_array( strtolower($ext), $wppa_supported_photo_extensions ) ) { ?>
|
760 |
-
<td id="td-file-<?php echo( $idx ) ?>" >
|
761 |
-
<input type="checkbox" id="file-<?php echo( $idx ) ?>" name="file-<?php echo( $idx ) ?>" title="<?php echo $file ?>" class= "wppa-pho" <?php if ( $is_sub_depot ) echo( 'checked="checked"' ) ?> />
|
762 |
-
<span id="name-file-<?php echo( $idx ) ?>" >
|
763 |
-
<?php
|
764 |
-
if ( wppa( 'is_wppa_tree' ) ) {
|
765 |
-
$t = explode( '/wppa/', $file );
|
766 |
-
echo $t[1];
|
767 |
-
}
|
768 |
-
else {
|
769 |
-
echo( wppa_sanitize_file_name( basename( $file ) ) );
|
770 |
-
}
|
771 |
-
?>
|
772 |
-
<?php echo( stripslashes( wppa_get_meta_name( $meta, '( ' ) ) ) ?>
|
773 |
-
<?php echo( stripslashes( wppa_get_meta_album( $meta, '[' ) ) ) ?>
|
774 |
-
</span>
|
775 |
-
<?php
|
776 |
-
if ( wppa_switch( 'import_preview' ) ) {
|
777 |
-
if ( wppa( 'is_remote' ) ) {
|
778 |
-
if ( strpos( $file, '//res.cloudinary.com/' ) !== false ) {
|
779 |
-
$img_url = dirname( $file ) . '/h_144/' . basename( $file );
|
780 |
-
}
|
781 |
-
else {
|
782 |
-
$img_url = $file;
|
783 |
-
}
|
784 |
-
}
|
785 |
-
else {
|
786 |
-
$img_url = str_replace( ABSPATH, home_url().'/', $file );
|
787 |
-
}
|
788 |
-
?>
|
789 |
-
<img src="<?php echo $img_url ?>" alt="N.A." style="max-height:48px;" onmouseover="if (jQuery('#wppa-zoom').attr('checked')) jQuery(this).css('max-height', '144px')" onmouseout="if (jQuery('#wppa-zoom').attr('checked')) jQuery(this).css('max-height', '48px')" />
|
790 |
-
<?php } ?>
|
791 |
-
</td>
|
792 |
-
<?php if ( $ct == 3 ) {
|
793 |
-
echo( '</tr><tr>' );
|
794 |
-
$ct = 0;
|
795 |
-
}
|
796 |
-
else {
|
797 |
-
$ct++;
|
798 |
-
}
|
799 |
-
}
|
800 |
-
$idx++;
|
801 |
-
} ?>
|
802 |
-
</tr>
|
803 |
-
</table>
|
804 |
-
</div>
|
805 |
-
<?php }
|
806 |
-
|
807 |
-
// Display the videos
|
808 |
-
if ( $videocount > '0' && wppa_switch( 'enable_video' ) ) { ?>
|
809 |
-
<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >
|
810 |
-
<p><b>
|
811 |
-
<?php _e( 'There are' , 'wp-photo-album-plus'); echo( ' '.$videocount.' ' ); _e( 'videos in the depot.' , 'wp-photo-album-plus') ?><br/>
|
812 |
-
</b></p>
|
813 |
-
<p class="hideifupdate" >
|
814 |
-
<?php _e( 'Album to import to:' , 'wp-photo-album-plus') ?>
|
815 |
-
<select name="wppa-video-album" id="wppa-video-album">
|
816 |
-
<?php echo wppa_album_select_a( array( 'path' => wppa_switch( 'hier_albsel' ),
|
817 |
-
'selected' => get_option( 'wppa-video-album-import-'.wppa_get_user(), '0' ),
|
818 |
-
'addpleaseselect' => true,
|
819 |
-
'checkowner' => true,
|
820 |
-
'checkupload' => true
|
821 |
-
) ) ?>
|
822 |
-
</select>
|
823 |
-
</p>
|
824 |
-
<table class="form-table wppa-table widefat" style="margin-bottom:0;" >
|
825 |
-
<thead>
|
826 |
-
<tr>
|
827 |
-
<td>
|
828 |
-
<input type="checkbox" id="all-video" checked="checked" onchange="checkAll( 'all-video', '.wppa-video' )" /><b> <?php _e( 'Check/uncheck all' , 'wp-photo-album-plus') ?></b>
|
829 |
-
</td>
|
830 |
-
<?php if ( $is_sub_depot ) { ?>
|
831 |
-
<td>
|
832 |
-
<input type="checkbox" id="del-after-v" name="del-after-v" checked="checked" /><b> <?php _e( 'Remove from depot after successful import.' , 'wp-photo-album-plus'); ?></b>
|
833 |
-
</td>
|
834 |
-
<?php } ?>
|
835 |
-
</tr>
|
836 |
-
</thead>
|
837 |
-
</table>
|
838 |
-
<table class="form-table wppa-table widefat" style="margin-top:0;" >
|
839 |
-
<tr>
|
840 |
-
<?php
|
841 |
-
$ct = 0;
|
842 |
-
$idx = '0';
|
843 |
-
if ( is_array( $files ) ) foreach ( $files as $file ) {
|
844 |
-
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
845 |
-
if ( in_array( strtolower($ext), $wppa_supported_video_extensions ) ) { ?>
|
846 |
-
<td>
|
847 |
-
<input type="checkbox" id="file-<?php echo( $idx ) ?>" name="file-<?php echo( $idx ) ?>" title="<?php echo $file ?>" class="wppa-video" checked="checked" /><span id="name-file-<?php echo( $idx ) ?>" > <?php echo( wppa_sanitize_file_name( basename( $file ) ) ); ?></span>
|
848 |
-
</td>
|
849 |
-
<?php if ( $ct == 3 ) {
|
850 |
-
echo( '</tr><tr>' );
|
851 |
-
$ct = 0;
|
852 |
-
}
|
853 |
-
else {
|
854 |
-
$ct++;
|
855 |
-
}
|
856 |
-
}
|
857 |
-
$idx++;
|
858 |
-
} ?>
|
859 |
-
</tr>
|
860 |
-
</table>
|
861 |
-
</div>
|
862 |
-
<?php }
|
863 |
-
|
864 |
-
// Display the audios
|
865 |
-
if ( $audiocount > '0' && wppa_switch( 'enable_audio' ) ) { ?>
|
866 |
-
<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >
|
867 |
-
<p><b>
|
868 |
-
<?php _e( 'There are' , 'wp-photo-album-plus'); echo( ' '.$audiocount.' ' ); _e( 'audios in the depot.' , 'wp-photo-album-plus') ?><br/>
|
869 |
-
</b></p>
|
870 |
-
<p class="hideifupdate" >
|
871 |
-
<?php _e( 'Album to import to:' , 'wp-photo-album-plus') ?>
|
872 |
-
<select name="wppa-audio-album" id="wppa-audio-album">
|
873 |
-
<?php echo wppa_album_select_a( array( 'path' => wppa_switch( 'hier_albsel' ),
|
874 |
-
'selected' => get_option( 'wppa-audio-album-import-'.wppa_get_user(), '0' ),
|
875 |
-
'addpleaseselect' => true,
|
876 |
-
'checkowner' => true,
|
877 |
-
'checkupload' => true
|
878 |
-
) ) ?>
|
879 |
-
</select>
|
880 |
-
</p>
|
881 |
-
<table class="form-table wppa-table widefat" style="margin-bottom:0;" >
|
882 |
-
<thead>
|
883 |
-
<tr>
|
884 |
-
<td>
|
885 |
-
<input type="checkbox" id="all-audio" checked="checked" onchange="checkAll( 'all-audio', '.wppa-audio' )" /><b> <?php _e( 'Check/uncheck all' , 'wp-photo-album-plus') ?></b>
|
886 |
-
</td>
|
887 |
-
<?php if ( $is_sub_depot ) { ?>
|
888 |
-
<td>
|
889 |
-
<input type="checkbox" id="del-after-u" name="del-after-u" checked="checked" /><b> <?php _e( 'Remove from depot after successful import.' , 'wp-photo-album-plus'); ?></b>
|
890 |
-
</td>
|
891 |
-
<?php } ?>
|
892 |
-
</tr>
|
893 |
-
</thead>
|
894 |
-
</table>
|
895 |
-
<table class="form-table wppa-table widefat" style="margin-top:0;" >
|
896 |
-
<tr>
|
897 |
-
<?php
|
898 |
-
$ct = 0;
|
899 |
-
$idx = '0';
|
900 |
-
if ( is_array( $files ) ) foreach ( $files as $file ) {
|
901 |
-
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
902 |
-
if ( in_array( strtolower($ext), $wppa_supported_audio_extensions ) ) { ?>
|
903 |
-
<td>
|
904 |
-
<input type="checkbox" id="file-<?php echo( $idx ) ?>" name="file-<?php echo( $idx ) ?>" title="<?php echo $file ?>" class="wppa-audio" checked="checked" /><span id="name-file-<?php echo( $idx ) ?>" > <?php echo( wppa_sanitize_file_name( basename( $file ) ) ); ?></span>
|
905 |
-
</td>
|
906 |
-
<?php if ( $ct == 3 ) {
|
907 |
-
echo( '</tr><tr>' );
|
908 |
-
$ct = 0;
|
909 |
-
}
|
910 |
-
else {
|
911 |
-
$ct++;
|
912 |
-
}
|
913 |
-
}
|
914 |
-
$idx++;
|
915 |
-
} ?>
|
916 |
-
</tr>
|
917 |
-
</table>
|
918 |
-
</div>
|
919 |
-
<?php }
|
920 |
-
|
921 |
-
// Display the directories to be imported as albums. Do this in the depot only!!
|
922 |
-
if ( $is_depot && $dircount > '0' ) { ?>
|
923 |
-
<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >
|
924 |
-
<p><b>
|
925 |
-
<?php _e( 'There are' , 'wp-photo-album-plus'); echo( ' '.$dircount.' ' ); _e( 'albumdirectories in the depot.' , 'wp-photo-album-plus') ?><br/>
|
926 |
-
</b></p>
|
927 |
-
<table class="form-table wppa-table widefat" style="margin-bottom:0;" >
|
928 |
-
<thead>
|
929 |
-
<tr>
|
930 |
-
<td>
|
931 |
-
<input type="checkbox" id="all-dir" checked="checked" onchange="checkAll( 'all-dir', '.wppa-dir' )" /><b> <?php _e( 'Check/uncheck all' , 'wp-photo-album-plus') ?></b>
|
932 |
-
</td>
|
933 |
-
</tr>
|
934 |
-
</thead>
|
935 |
-
</table>
|
936 |
-
<table class="form-table wppa-table widefat" style="margin-top:0;" >
|
937 |
-
<?php
|
938 |
-
$ct = 0;
|
939 |
-
$idx = '0';
|
940 |
-
foreach( $files as $dir ) {
|
941 |
-
if ( basename( $dir ) == '.' ) {}
|
942 |
-
elseif ( basename( $dir ) == '..' ) {}
|
943 |
-
elseif ( is_dir( $dir ) ) { ?>
|
944 |
-
<tr>
|
945 |
-
<td>
|
946 |
-
<input type="checkbox" id="file-<?php echo( $idx ) ?>" name="file-<?php echo( $idx ) ?>" class= "wppa-dir" checked="checked" /> <b><?php echo( wppa_sanitize_file_name( basename( $dir ) ) ) ?></b>
|
947 |
-
<?php
|
948 |
-
$subfiles = glob( $dir.'/*' );
|
949 |
-
$subdircount = '0';
|
950 |
-
if ( $subfiles ) foreach ( $subfiles as $subfile ) if ( is_dir( $subfile ) && basename( $subfile ) != '.' && basename( $subfile ) != '..' ) $subdircount++;
|
951 |
-
$sfcount = empty( $subfiles ) ? '0' : wppa_get_photocount( $subfiles );
|
952 |
-
echo ' Contains '.$sfcount.' files';
|
953 |
-
if ( $subdircount ) echo ' and '.$subdircount.' sub directories.';
|
954 |
-
?>
|
955 |
-
</td>
|
956 |
-
</tr>
|
957 |
-
<?php
|
958 |
-
}
|
959 |
-
$idx++;
|
960 |
-
} ?>
|
961 |
-
</table>
|
962 |
-
</div>
|
963 |
-
<?php } ?>
|
964 |
-
<?php
|
965 |
-
|
966 |
-
// Display the csv files
|
967 |
-
if ( $is_depot && $csvcount > '0' ) { ?>
|
968 |
-
<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >
|
969 |
-
<p><b>
|
970 |
-
<?php _e( 'There are' , 'wp-photo-album-plus'); echo( ' '.$csvcount.' ' ); _e( 'csv files in the depot.' , 'wp-photo-album-plus') ?><br/>
|
971 |
-
</b></p>
|
972 |
-
<table class="form-table wppa-table widefat" style="margin-bottom:0;" >
|
973 |
-
<thead>
|
974 |
-
<tr>
|
975 |
-
<td>
|
976 |
-
<input type="checkbox" id="all-csv" checked="checked" onchange="checkAll( 'all-csv', '.wppa-csv' )" /><b> <?php _e( 'Check/uncheck all' , 'wp-photo-album-plus') ?></b>
|
977 |
-
</td>
|
978 |
-
<td>
|
979 |
-
<input type="checkbox" id="del-after-c" name="del-after-c" checked="checked" disabled="disabled" /><b> <?php _e( 'Remove from depot after successful import.' , 'wp-photo-album-plus'); ?></b>
|
980 |
-
</td>
|
981 |
-
</tr>
|
982 |
-
</thead>
|
983 |
-
</table>
|
984 |
-
<table class="form-table wppa-table widefat" style="margin-top:0;" >
|
985 |
-
<?php
|
986 |
-
$ct = 0;
|
987 |
-
$idx = '0';
|
988 |
-
foreach( $files as $csv ) {
|
989 |
-
if ( is_file( $csv ) && strtolower( wppa_get_ext( $csv ) ) == 'csv' ) { ?>
|
990 |
-
<tr>
|
991 |
-
<td>
|
992 |
-
<input type="checkbox" id="file-<?php echo( $idx ) ?>" name="file-<?php echo( $idx ) ?>" class= "wppa-csv" checked="checked" /> <b><?php echo wppa_sanitize_file_name( basename( $csv ) ) . ' (' . sprintf( '%5.1f', filesize( $csv ) / 1024 ) . ' kb)' ?></b>
|
993 |
-
</td>
|
994 |
-
</tr>
|
995 |
-
<?php
|
996 |
-
}
|
997 |
-
$idx++;
|
998 |
-
} ?>
|
999 |
-
</table>
|
1000 |
-
</div>
|
1001 |
-
|
1002 |
-
<?php } ?>
|
1003 |
-
<?php
|
1004 |
-
|
1005 |
-
// The submit button
|
1006 |
-
?>
|
1007 |
-
<p>
|
1008 |
-
<script type="text/javascript">
|
1009 |
-
function wppaVfyAlbum() {
|
1010 |
-
var csvs = jQuery( '.wppa-csv' );
|
1011 |
-
if ( jQuery( '#wppa-update' ).attr( 'checked' ) != 'checked' ) {
|
1012 |
-
if ( ! parseInt( jQuery( '#wppa-photo-album' ).attr( 'value' ) ) &&
|
1013 |
-
! parseInt( jQuery( '#wppa-video-album' ).attr( 'value' ) ) &&
|
1014 |
-
! parseInt( jQuery( '#wppa-audio-album' ).attr( 'value' ) ) &&
|
1015 |
-
csvs.length == 0
|
1016 |
-
) {
|
1017 |
-
alert( 'Please select an album first' );
|
1018 |
-
return false;
|
1019 |
-
}
|
1020 |
-
}
|
1021 |
-
return true;
|
1022 |
-
}
|
1023 |
-
function wppaCheckInputVars() {
|
1024 |
-
var checks = jQuery( ':checked' );
|
1025 |
-
var nChecks = checks.length;
|
1026 |
-
var nMax = <?php echo ini_get( 'max_input_vars' ) ?>;
|
1027 |
-
if ( nMax == 0 ) nMax = 100;
|
1028 |
-
if ( nChecks > nMax ) {
|
1029 |
-
alert ( 'There are '+nChecks+' boxes checked or selected, that is more than the maximum allowed number of '+nMax );
|
1030 |
-
return false;
|
1031 |
-
}
|
1032 |
-
var dirs = jQuery( '.wppa-dir' );
|
1033 |
-
var nDirsChecked = 0;
|
1034 |
-
if ( dirs.length > 0 ) {
|
1035 |
-
var i = 0;
|
1036 |
-
while ( i < dirs.length ) {
|
1037 |
-
if ( jQuery( dirs[i] ).attr( 'checked' ) == 'checked' ) {
|
1038 |
-
nDirsChecked++;
|
1039 |
-
}
|
1040 |
-
i++;
|
1041 |
-
}
|
1042 |
-
}
|
1043 |
-
var zips = jQuery( '.wppa-zip' );
|
1044 |
-
var nZipsChecked = 0;
|
1045 |
-
if ( zips.length > 0 ) {
|
1046 |
-
var i = 0;
|
1047 |
-
while ( i < zips.length ) {
|
1048 |
-
if ( jQuery( zips[i] ).attr( 'checked' ) == 'checked' ) {
|
1049 |
-
nZipsChecked++;
|
1050 |
-
}
|
1051 |
-
i++;
|
1052 |
-
}
|
1053 |
-
}
|
1054 |
-
// If no dirs to import checked, there must be an album selected
|
1055 |
-
if ( 0 == nDirsChecked && 0 == nZipsChecked && ! wppaVfyAlbum() ) return false;
|
1056 |
-
return true;
|
1057 |
-
}
|
1058 |
-
</script>
|
1059 |
-
<input type="submit" onclick="return wppaCheckInputVars()" class="button-primary" id="submit" name="wppa-import-submit" value="<?php _e( 'Import' , 'wp-photo-album-plus'); ?>" />
|
1060 |
-
<script type="text/javascript" >
|
1061 |
-
var wppaImportRuns = false;
|
1062 |
-
function wppaDoAjaxImport() {
|
1063 |
-
wppaImportRuns = true;
|
1064 |
-
var data = '';
|
1065 |
-
data += 'wppa-update-check='+jQuery( '#wppa-update-check' ).attr( 'value' );
|
1066 |
-
data += '&wppa-photo-album='+jQuery( '#wppa-photo-album' ).attr( 'value' );
|
1067 |
-
data += '&wppa-video-album='+jQuery( '#wppa-video-album' ).attr( 'value' );
|
1068 |
-
data += '&wppa-audio-album='+jQuery( '#wppa-audio-album' ).attr( 'value' );
|
1069 |
-
data += '&wppa-watermark-file='+jQuery( '#wppa-watermark-file' ).attr( 'value' );
|
1070 |
-
data += '&wppa-watermark-pos='+jQuery( '#wppa-watermark-pos' ).attr( 'value' );
|
1071 |
-
if ( jQuery( '#cre-album' ).attr( 'checked' ) ) data += '&cre-album='+jQuery( '#cre-album' ).attr( 'value' );
|
1072 |
-
if ( jQuery( '#use-backup' ).attr( 'checked' ) ) data += '&use-backup=on'; //+jQuery( '#use-backup' ).attr( 'value' );
|
1073 |
-
if ( jQuery( '#wppa-update' ).attr( 'checked' ) ) data += '&wppa-update=on'; //+jQuery( '#wppa-update' ).attr( 'value' );
|
1074 |
-
if ( jQuery( '#wppa-nodups' ).attr( 'checked' ) ) data += '&wppa-nodups=on'; //+jQuery( '#wppa-nudups' ).attr( 'value' );
|
1075 |
-
if ( jQuery( '#del-after-p' ).attr( 'checked' ) ) data += '&del-after-p=on';
|
1076 |
-
if ( jQuery( '#del-after-f' ).attr( 'checked' ) ) data += '&del-after-f=on';
|
1077 |
-
if ( jQuery( '#del-after-v' ).attr( 'checked' ) ) data += '&del-after-v=on';
|
1078 |
-
if ( jQuery( '#del-after-u' ).attr( 'checked' ) ) data += '&del-after-u=on';
|
1079 |
-
data += '&wppa-import-submit=ajax';
|
1080 |
-
|
1081 |
-
var files = jQuery( ':checked' );
|
1082 |
-
var found = false;
|
1083 |
-
var i=0;
|
1084 |
-
var elm;
|
1085 |
-
var fulldata;
|
1086 |
-
for ( i=0; i<files.length; i++ ) {
|
1087 |
-
found = false; // assume done
|
1088 |
-
elm = files[i];
|
1089 |
-
// Is it a file checkbox?
|
1090 |
-
var temp = elm.id.split( '-' );
|
1091 |
-
if ( temp[0] != 'file' ) continue; // no
|
1092 |
-
fulldata = data+'&import-ajax-file='+elm.title;
|
1093 |
-
found = true;
|
1094 |
-
break;
|
1095 |
-
}
|
1096 |
-
// alert( data );
|
1097 |
-
if ( ! found ) {
|
1098 |
-
wppaStopAjaxImport();
|
1099 |
-
return; // nothing left
|
1100 |
-
}
|
1101 |
-
// found one, do it
|
1102 |
-
var oldhtml=jQuery( '#name-'+elm.id ).html();
|
1103 |
-
var xmlhttp = wppaGetXmlHttp();
|
1104 |
-
xmlhttp.onreadystatechange = function() {
|
1105 |
-
if ( xmlhttp.readyState == 4 ) {
|
1106 |
-
if ( xmlhttp.status!=404 ) {
|
1107 |
-
var resp = xmlhttp.responseText;
|
1108 |
-
//
|
1109 |
-
if ( resp.length == 0 ) {
|
1110 |
-
jQuery( '#name-'+elm.id ).html('<span style="color:red" >Timeout</span>');
|
1111 |
-
wppaStopAjaxImport();
|
1112 |
-
return;
|
1113 |
-
}
|
1114 |
-
//
|
1115 |
-
if ( resp.indexOf( 'Server' ) != -1 && resp.indexOf( 'Error' ) != -1 ) {
|
1116 |
-
resp = '<span style="color:red" >Server error</span>';
|
1117 |
-
}
|
1118 |
-
jQuery( '#name-'+elm.id ).html( ' <b>'+resp+'</b>' );
|
1119 |
-
elm.checked = '';
|
1120 |
-
if ( jQuery( '#del-after-p' ).attr( 'checked' ) ||
|
1121 |
-
jQuery( '#del-after-f' ).attr( 'checked' ) ) {
|
1122 |
-
elm.disabled = 'disabled';
|
1123 |
-
elm.title = '';
|
1124 |
-
}
|
1125 |
-
if ( wppaImportRuns ) {
|
1126 |
-
setTimeout( 'wppaDoAjaxImport()', 100 );
|
1127 |
-
}
|
1128 |
-
}
|
1129 |
-
else {
|
1130 |
-
jQuery( '#name-'+elm.id ).html( ' <b>Not found</b>' );
|
1131 |
-
}
|
1132 |
-
}
|
1133 |
-
}
|
1134 |
-
var url = wppaAjaxUrl+'?action=wppa&wppa-action=import';
|
1135 |
-
xmlhttp.open( 'POST',url,true );
|
1136 |
-
xmlhttp.setRequestHeader( "Content-type","application/x-www-form-urlencoded" );
|
1137 |
-
xmlhttp.send( fulldata );
|
1138 |
-
jQuery( '#name-'+elm.id ).html( ' <b style="color:blue" >' + '<?php _e( 'Working...', 'wp-photo-album-plus' ) ?>' + '</b>' );
|
1139 |
-
jQuery( '#wppa-start-ajax' ).css( 'display', 'none' );
|
1140 |
-
jQuery( '#wppa-stop-ajax' ).css( 'display', 'inline' );
|
1141 |
-
}
|
1142 |
-
function wppaStopAjaxImport() {
|
1143 |
-
wppaImportRuns = false;
|
1144 |
-
jQuery( '#wppa-start-ajax' ).css( 'display', 'inline' );
|
1145 |
-
jQuery( '#wppa-stop-ajax' ).css( 'display', 'none' );
|
1146 |
-
}
|
1147 |
-
</script>
|
1148 |
-
<?php if ( ( $photocount || $videocount || $audiocount ) && ! $albumcount && ! $dircount && ! $zipcount ) { ?>
|
1149 |
-
<input id="wppa-start-ajax" type="button" onclick="if ( wppaVfyAlbum() ) { wppaDoAjaxImport() }" class="button-secundary" value="<?php esc_attr( _e( 'Start Ajax Import', 'wp-photo-album-plus' ) ) ?>" />
|
1150 |
-
<input id="wppa-stop-ajax" style="display:none;" type="button" onclick="wppaStopAjaxImport()" class="button-secundary" value="<?php esc_attr( _e( 'Stop Ajax Import', 'wp-photo-album-plus' ) ) ?>" />
|
1151 |
-
<?php } ?>
|
1152 |
-
</p>
|
1153 |
-
</form>
|
1154 |
-
|
1155 |
-
<?php }
|
1156 |
-
else {
|
1157 |
-
if ( $source_type == 'local' ) {
|
1158 |
-
wppa_ok_message( __( 'There are no importable files found in directory:' , 'wp-photo-album-plus').' '.$source );
|
1159 |
-
}
|
1160 |
-
else {
|
1161 |
-
wppa_ok_message( __( 'There are no photos found or left to process at url:' , 'wp-photo-album-plus').' '.$source_url );
|
1162 |
-
}
|
1163 |
-
}
|
1164 |
-
echo '<br /><b>';
|
1165 |
-
_e( 'You can import the following file types:', 'wp-photo-album-plus');
|
1166 |
-
echo '</b><br />';
|
1167 |
-
if ( PHP_VERSION_ID >= 50207 ) {
|
1168 |
-
echo '<br />';
|
1169 |
-
_e( 'Compressed file types: .zip' , 'wp-photo-album-plus');
|
1170 |
-
}
|
1171 |
-
if ( true ) {
|
1172 |
-
echo '<br />';
|
1173 |
-
_e( 'Photo file types:' , 'wp-photo-album-plus');
|
1174 |
-
foreach ( $wppa_supported_photo_extensions as $ext ) {
|
1175 |
-
echo ' .'.$ext;
|
1176 |
-
}
|
1177 |
-
}
|
1178 |
-
if ( wppa_switch( 'enable_video' ) ) {
|
1179 |
-
echo '<br />';
|
1180 |
-
_e( 'Video file types:' , 'wp-photo-album-plus');
|
1181 |
-
foreach ( $wppa_supported_video_extensions as $ext ) {
|
1182 |
-
echo ' .'.$ext;
|
1183 |
-
}
|
1184 |
-
}
|
1185 |
-
if ( wppa_switch( 'enable_audio' ) ) {
|
1186 |
-
echo '<br />';
|
1187 |
-
_e( 'Audio file types:' , 'wp-photo-album-plus');
|
1188 |
-
foreach ( $wppa_supported_audio_extensions as $ext ) {
|
1189 |
-
echo ' .'.$ext;
|
1190 |
-
}
|
1191 |
-
}
|
1192 |
-
echo '<br />';
|
1193 |
-
_e( 'WPPA+ file types: .amf .pmf' , 'wp-photo-album-plus');
|
1194 |
-
echo '<br />';
|
1195 |
-
_e( 'Directories with optional subdirs containig photos' , 'wp-photo-album-plus');
|
1196 |
-
echo '<br />';
|
1197 |
-
_e( 'Custom data files of type .csv' , 'wp-photo-album-plus');
|
1198 |
-
echo '<br /><br />';
|
1199 |
-
_e( 'Your depot directory is:' , 'wp-photo-album-plus');
|
1200 |
-
echo '<b> .../' . WPPA_DEPOT . '/</b>';
|
1201 |
-
}
|
1202 |
-
else { ?>
|
1203 |
-
<?php $url = wppa_dbg_url( get_admin_url().'admin.php?page=wppa_admin_menu' ); ?>
|
1204 |
-
<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
|
1205 |
-
}
|
1206 |
-
if ( wppa( 'continue' ) ) {
|
1207 |
-
wppa_warning_message( __( 'Trying to continue...' , 'wp-photo-album-plus') );
|
1208 |
-
echo '<script type="text/javascript">document.location=\''.get_admin_url().'admin.php?page=wppa_import_photos&continue&nonce='.wp_create_nonce( 'dirimport' ).'\';</script>';
|
1209 |
-
} ?>
|
1210 |
-
</div>
|
1211 |
-
<?php
|
1212 |
-
}
|
1213 |
-
|
1214 |
-
// get array of files to import
|
1215 |
-
function wppa_get_import_files() {
|
1216 |
-
|
1217 |
-
// Init
|
1218 |
-
$user = wppa_get_user();
|
1219 |
-
$source_type = get_option( 'wppa_import_source_type_'.$user, 'local' );
|
1220 |
-
$files = array();
|
1221 |
-
|
1222 |
-
// Ajax? one file
|
1223 |
-
if ( isset ( $_POST['import-ajax-file'] ) ) {
|
1224 |
-
$files = array( $_POST['import-ajax-file'] );
|
1225 |
-
}
|
1226 |
-
|
1227 |
-
// Dispatch on source type local/remote
|
1228 |
-
elseif ( $source_type == 'local' ) {
|
1229 |
-
$source = get_option( 'wppa_import_source_'.$user, WPPA_DEPOT_PATH );
|
1230 |
-
$source_path = $source; // Filesystem
|
1231 |
-
$files = glob( $source_path . '/*' );
|
1232 |
-
}
|
1233 |
-
else { // remote
|
1234 |
-
$max_tries = get_option( 'wppa_import_remote_max_'.$user, '10' );
|
1235 |
-
$setting = get_option( 'wppa_import_source_url_'.$user, 'http://' );
|
1236 |
-
$pattern = '/src=".*?"/';
|
1237 |
-
|
1238 |
-
// Is it a photofile in a wppa tree filestructure?
|
1239 |
-
$old_setting = $setting;
|
1240 |
-
|
1241 |
-
// assume not
|
1242 |
-
if ( is_array( @ getimagesize( $setting ) ) ) {
|
1243 |
-
wppa( 'is_wppa_tree', false );
|
1244 |
}
|
1245 |
|
1246 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1247 |
else {
|
1248 |
-
$setting = wppa_expand_tree_path( $old_setting );
|
1249 |
-
if ( is_array( @ getimagesize( $setting ) ) ) {
|
1250 |
-
wppa( 'is_wppa_tree', true );
|
1251 |
-
}
|
1252 |
-
}
|
1253 |
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1266 |
}
|
1267 |
else {
|
1268 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1269 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1270 |
}
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
// Init
|
1280 |
-
$files = array();
|
1281 |
-
|
1282 |
-
// Get page content
|
1283 |
-
$curl = curl_init();
|
1284 |
-
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
|
1285 |
-
curl_setopt( $curl, CURLOPT_URL, $setting );
|
1286 |
-
$contents = curl_exec( $curl );
|
1287 |
-
curl_close( $curl );
|
1288 |
-
|
1289 |
-
// Process result
|
1290 |
-
if ( $contents ) {
|
1291 |
-
|
1292 |
-
// Preprocess
|
1293 |
-
$contents = str_replace( '\'', '"', $contents );
|
1294 |
-
|
1295 |
-
// Find matches
|
1296 |
-
preg_match_all( $pattern, $contents, $matches, PREG_PATTERN_ORDER );
|
1297 |
-
if ( is_array( $matches[0] ) ) {
|
1298 |
-
|
1299 |
-
// Sort
|
1300 |
-
sort( $matches[0] );
|
1301 |
-
|
1302 |
-
// Copy to $files, skipping dups
|
1303 |
-
$val = '';
|
1304 |
-
$count = 0;
|
1305 |
-
$sfxs = array( 'jpg', 'jpeg', 'gif', 'png', 'JPG', 'JPEG', 'GIF', 'PNG' );
|
1306 |
-
foreach ( array_keys( $matches[0] ) as $idx ) {
|
1307 |
-
if ( $matches[0][$idx] != $val ) {
|
1308 |
-
$val = $matches[0][$idx];
|
1309 |
-
// Post process found item
|
1310 |
-
$match = substr( $matches[0][$idx], 5 );
|
1311 |
-
$matchpos = strpos( $contents, $match );
|
1312 |
-
$match = trim( $match, '"' );
|
1313 |
-
if ( strpos( $match, '?' ) ) $match = substr( $match, 0, strpos( $match, '?' ) );
|
1314 |
-
$match = str_replace( '/uploads/wppa/thumbs/', '/uploads/wppa/', $match );
|
1315 |
-
$sfx = wppa_get_ext( $match );
|
1316 |
-
if ( in_array( $sfx, $sfxs ) ) {
|
1317 |
-
// Save it
|
1318 |
-
$count++;
|
1319 |
-
if ( $count <= $max_tries ) {
|
1320 |
-
$files[] = $match;
|
1321 |
-
}
|
1322 |
-
}
|
1323 |
-
}
|
1324 |
-
}
|
1325 |
-
}
|
1326 |
}
|
1327 |
-
update_option( 'wppa_import_source_url_found_'.$user, $files );
|
1328 |
}
|
1329 |
}
|
1330 |
-
}
|
1331 |
-
|
1332 |
-
// Remove non originals
|
1333 |
-
if ( is_array( $files ) ) foreach ( array_keys( $files ) as $key ) {
|
1334 |
-
if ( ! wppa_is_orig( $files[$key] ) ) {
|
1335 |
-
unset ( $files[$key] );
|
1336 |
-
}
|
1337 |
-
}
|
1338 |
-
|
1339 |
-
// Sort to keep synchronicity when doing ajax import
|
1340 |
-
if ( is_array( $files ) ) sort( $files );
|
1341 |
|
1342 |
-
|
1343 |
-
|
1344 |
}
|
1345 |
|
1346 |
// Upload multiple photos
|
1347 |
function wppa_upload_multiple() {
|
1348 |
-
|
1349 |
-
|
|
|
1350 |
|
1351 |
$warning_given = false;
|
1352 |
$uploaded_a_file = false;
|
@@ -1356,16 +497,16 @@ function wppa_upload_multiple() {
|
|
1356 |
if ( is_array( $file['error'] ) ) {
|
1357 |
for ( $i = '0'; $i < count( $file['error'] ); $i++ ) {
|
1358 |
if ( wppa_is_time_up() ) {
|
1359 |
-
wppa_warning_message( sprintf( __( 'Time out. %s photos uploaded in album nr %s.' , 'wp-photo-album-plus'), $count, $
|
1360 |
-
wppa_set_last_album( $
|
1361 |
return;
|
1362 |
}
|
1363 |
if ( ! $file['error'][$i] ) {
|
1364 |
-
$id = wppa_insert_photo( $file['tmp_name'][$i], $
|
1365 |
if ( $id ) {
|
1366 |
$uploaded_a_file = true;
|
1367 |
$count++;
|
1368 |
-
wppa_backend_upload_mail( $id, $
|
1369 |
}
|
1370 |
else {
|
1371 |
wppa_error_message( __( 'Error inserting photo' , 'wp-photo-album-plus') . ' ' . wppa_sanitize_file_name( basename( $file['name'][$i] ) ) . '.' );
|
@@ -1377,15 +518,17 @@ function wppa_upload_multiple() {
|
|
1377 |
}
|
1378 |
|
1379 |
if ( $uploaded_a_file ) {
|
1380 |
-
wppa_update_message( $count.' '.__( 'Photos Uploaded in album nr' , 'wp-photo-album-plus') . ' ' . $
|
1381 |
-
wppa_set_last_album( $
|
1382 |
}
|
1383 |
}
|
1384 |
|
1385 |
// Upload single photos
|
1386 |
function wppa_upload_photos() {
|
1387 |
-
|
1388 |
-
|
|
|
|
|
1389 |
|
1390 |
$warning_given = false;
|
1391 |
$uploaded_a_file = false;
|
@@ -1393,12 +536,11 @@ function wppa_upload_photos() {
|
|
1393 |
$count = '0';
|
1394 |
foreach ( $_FILES as $file ) {
|
1395 |
if ( $file['tmp_name'] != '' ) {
|
1396 |
-
|
1397 |
-
$id = wppa_insert_photo( $file['tmp_name'], $_POST['wppa-album'], $file['name'] );
|
1398 |
if ( $id ) {
|
1399 |
$uploaded_a_file = true;
|
1400 |
$count++;
|
1401 |
-
wppa_backend_upload_mail( $id, $
|
1402 |
}
|
1403 |
else {
|
1404 |
wppa_error_message( __( 'Error inserting photo' , 'wp-photo-album-plus') . ' ' . wppa_sanitize_file_name( basename( $file['name'] ) ) . '.' );
|
@@ -1408,8 +550,8 @@ function wppa_upload_photos() {
|
|
1408 |
}
|
1409 |
|
1410 |
if ( $uploaded_a_file ) {
|
1411 |
-
wppa_update_message( $count.' '.__( 'Photos Uploaded in album nr' , 'wp-photo-album-plus') . ' ' . $
|
1412 |
-
wppa_set_last_album( $
|
1413 |
}
|
1414 |
}
|
1415 |
|
@@ -1454,1109 +596,3 @@ global $target;
|
|
1454 |
|
1455 |
return $error;
|
1456 |
}
|
1457 |
-
|
1458 |
-
// Do the import photos
|
1459 |
-
function wppa_import_photos( $delp = false, $dela = false, $delz = false, $delv = false, $delu = false, $delc = false, $delf = false ) {
|
1460 |
-
global $wpdb;
|
1461 |
-
global $warning_given;
|
1462 |
-
global $wppa_supported_photo_extensions;
|
1463 |
-
global $wppa_supported_video_extensions;
|
1464 |
-
global $wppa_supported_audio_extensions;
|
1465 |
-
|
1466 |
-
$warning_given = false;
|
1467 |
-
|
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_PATH );
|
1473 |
-
|
1474 |
-
$depot = WPPA_ABSPATH . $source; // Filesystem
|
1475 |
-
$depoturl = get_bloginfo( 'wpurl' ).'/'.$source; // url
|
1476 |
-
|
1477 |
-
// See what's in there
|
1478 |
-
$files = wppa_get_import_files();
|
1479 |
-
|
1480 |
-
// First extract zips if our php version is ok
|
1481 |
-
$idx='0';
|
1482 |
-
$zcount = 0;
|
1483 |
-
if ( PHP_VERSION_ID >= 50207 ) {
|
1484 |
-
foreach( $files as $zipfile ) {
|
1485 |
-
if ( isset( $_POST['file-'.$idx] ) ) {
|
1486 |
-
$ext = strtolower( substr( strrchr( $zipfile, "." ), 1 ) );
|
1487 |
-
|
1488 |
-
if ( $ext == 'zip' ) {
|
1489 |
-
$err = wppa_extract( $zipfile, $delz );
|
1490 |
-
if ( $err == '0' ) $zcount++;
|
1491 |
-
} // if ext = zip
|
1492 |
-
} // if isset
|
1493 |
-
$idx++;
|
1494 |
-
} // foreach
|
1495 |
-
}
|
1496 |
-
|
1497 |
-
// Now see if albums must be created
|
1498 |
-
$idx='0';
|
1499 |
-
$acount = 0;
|
1500 |
-
foreach( $files as $album ) {
|
1501 |
-
if ( isset( $_POST['file-'.$idx] ) ) {
|
1502 |
-
$ext = strtolower( substr( strrchr( $album, "." ), 1 ) );
|
1503 |
-
if ( $ext == 'amf' ) {
|
1504 |
-
$name = '';
|
1505 |
-
$desc = '';
|
1506 |
-
$aord = '0';
|
1507 |
-
$parent = '0';
|
1508 |
-
$porder = '0';
|
1509 |
-
$owner = '';
|
1510 |
-
$handle = fopen( $album, "r" );
|
1511 |
-
if ( $handle ) {
|
1512 |
-
$buffer = fgets( $handle, 4096 );
|
1513 |
-
while ( !feof( $handle ) ) {
|
1514 |
-
$tag = substr( $buffer, 0, 5 );
|
1515 |
-
$len = strlen( $buffer ) - 6; // substract 5 for label and one for eol
|
1516 |
-
$data = substr( $buffer, 5, $len );
|
1517 |
-
switch( $tag ) {
|
1518 |
-
case 'name=':
|
1519 |
-
$name = $data;
|
1520 |
-
break;
|
1521 |
-
case 'desc=':
|
1522 |
-
$desc = wppa_txt_to_nl( $data );
|
1523 |
-
break;
|
1524 |
-
case 'aord=':
|
1525 |
-
if ( is_numeric( $data ) ) $aord = $data;
|
1526 |
-
break;
|
1527 |
-
case 'prnt=':
|
1528 |
-
if ( $data == __( '--- none ---' , 'wp-photo-album-plus') ) $parent = '0';
|
1529 |
-
elseif ( $data == __( '--- separate ---' , 'wp-photo-album-plus') ) $parent = '-1';
|
1530 |
-
else {
|
1531 |
-
$prnt = wppa_get_album_id( $data );
|
1532 |
-
if ( $prnt != '' ) {
|
1533 |
-
$parent = $prnt;
|
1534 |
-
}
|
1535 |
-
else {
|
1536 |
-
$parent = '0';
|
1537 |
-
wppa_warning_message( __( 'Unknown parent album:' , 'wp-photo-album-plus').' '.$data.' '.__( '--- none --- used.' , 'wp-photo-album-plus') );
|
1538 |
-
}
|
1539 |
-
}
|
1540 |
-
break;
|
1541 |
-
case 'pord=':
|
1542 |
-
if ( is_numeric( $data ) ) $porder = $data;
|
1543 |
-
break;
|
1544 |
-
case 'ownr=':
|
1545 |
-
$owner = $data;
|
1546 |
-
break;
|
1547 |
-
}
|
1548 |
-
$buffer = fgets( $handle, 4096 );
|
1549 |
-
} // while !foef
|
1550 |
-
fclose( $handle );
|
1551 |
-
if ( wppa_get_album_id( $name ) != '' ) {
|
1552 |
-
wppa_warning_message( 'Album already exists '.stripslashes( $name ) );
|
1553 |
-
if ( $dela ) unlink( $album );
|
1554 |
-
}
|
1555 |
-
else {
|
1556 |
-
$id = basename( $album );
|
1557 |
-
$id = substr( $id, 0, strpos( $id, '.' ) );
|
1558 |
-
$id = wppa_create_album_entry( array ( 'id' => $id,
|
1559 |
-
'name' => stripslashes( $name ),
|
1560 |
-
'description' => stripslashes( $desc ),
|
1561 |
-
'a_order' => $aord,
|
1562 |
-
'a_parent' => $parent,
|
1563 |
-
'p_order_by' => $porder,
|
1564 |
-
'owner' => $owner
|
1565 |
-
) );
|
1566 |
-
|
1567 |
-
if ( $id === false ) {
|
1568 |
-
wppa_error_message( __( 'Could not create album.' , 'wp-photo-album-plus') );
|
1569 |
-
}
|
1570 |
-
else {
|
1571 |
-
//$id = wppa_get_album_id( $name );
|
1572 |
-
wppa_set_last_album( $id );
|
1573 |
-
wppa_index_add( 'album', $id );
|
1574 |
-
wppa_ok_message( __( 'Album #' , 'wp-photo-album-plus') . ' ' . $id . ': '.stripslashes( $name ).' ' . __( 'Added.' , 'wp-photo-album-plus') );
|
1575 |
-
if ( $dela ) unlink( $album );
|
1576 |
-
$acount++;
|
1577 |
-
wppa_clear_cache();
|
1578 |
-
wppa_flush_treecounts( $id );
|
1579 |
-
} // album added
|
1580 |
-
} // album did not exist
|
1581 |
-
} // if handle ( file open )
|
1582 |
-
} // if its an album
|
1583 |
-
} // if isset
|
1584 |
-
$idx++;
|
1585 |
-
} // foreach file
|
1586 |
-
|
1587 |
-
// Now the photos
|
1588 |
-
$idx = '0';
|
1589 |
-
$pcount = '0';
|
1590 |
-
$totpcount = '0';
|
1591 |
-
|
1592 |
-
// find album id
|
1593 |
-
if ( isset( $_POST['cre-album'] ) ) { // use album ngg gallery name for ngg conversion
|
1594 |
-
$album = wppa_get_album_id( strip_tags( $_POST['cre-album'] ) );
|
1595 |
-
if ( ! $album ) { // the album does not exist yet, create it
|
1596 |
-
$name = strip_tags( $_POST['cre-album'] );
|
1597 |
-
$desc = sprintf( __( 'This album has been converted from ngg gallery %s' , 'wp-photo-album-plus'), $name );
|
1598 |
-
$uplim = '0/0'; // Unlimited not to destroy the conversion process!!
|
1599 |
-
$album = wppa_create_album_entry( array ( 'name' => $name,
|
1600 |
-
'description' => $desc,
|
1601 |
-
'upload_limit' => $uplim
|
1602 |
-
) );
|
1603 |
-
if ( $album === false ) {
|
1604 |
-
wppa_error_message( __( 'Could not create album.' , 'wp-photo-album-plus').'<br/>Query = '.$query );
|
1605 |
-
wp_die( 'Sorry, cannot continue' );
|
1606 |
-
}
|
1607 |
-
}
|
1608 |
-
}
|
1609 |
-
elseif ( isset( $_POST['wppa-photo-album'] ) ) {
|
1610 |
-
$album = $_POST['wppa-photo-album'];
|
1611 |
-
}
|
1612 |
-
else $album = '0';
|
1613 |
-
|
1614 |
-
// Report starting process
|
1615 |
-
wppa_ok_message( __( 'Processing files, please wait...' , 'wp-photo-album-plus').' '.__( 'If the line of dots stops growing or your browser reports Ready, your server has given up. In that case: try again' , 'wp-photo-album-plus').' <a href="'.wppa_dbg_url( get_admin_url().'admin.php?page=wppa_import_photos' ).'">'.__( 'here.' , 'wp-photo-album-plus').'</a>' );
|
1616 |
-
|
1617 |
-
// Do them all
|
1618 |
-
foreach ( array_keys( $files ) as $file_idx ) {
|
1619 |
-
$unsanitized_path_name = $files[$file_idx];
|
1620 |
-
$file = $files[$file_idx];
|
1621 |
-
wppa_is_wppa_tree( $file ); // Sets wppa( 'is_wppa_tree' )
|
1622 |
-
if ( isset( $_POST['use-backup'] ) && is_file( $file.'_backup' ) ) {
|
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 );
|
1635 |
-
if ( in_array( $ext, $wppa_supported_photo_extensions ) ) {
|
1636 |
-
|
1637 |
-
// See if a metafile exists
|
1638 |
-
//$meta = substr( $file, 0, strlen( $file ) - 3 ).'pmf';
|
1639 |
-
$meta = wppa_strip_ext( $unsanitized_path_name ) . '.PMF';
|
1640 |
-
if ( ! is_file( $meta ) ) {
|
1641 |
-
$meta = wppa_strip_ext( $unsanitized_path_name ) . '.pmf';
|
1642 |
-
}
|
1643 |
-
|
1644 |
-
// find all data: name, desc, porder form metafile
|
1645 |
-
if ( is_file( $meta ) ) {
|
1646 |
-
$alb = wppa_get_album_id( wppa_get_meta_album( $meta ) );
|
1647 |
-
$name = wppa_get_meta_name( $meta );
|
1648 |
-
$desc = wppa_txt_to_nl( wppa_get_meta_desc( $meta ) );
|
1649 |
-
$porder = wppa_get_meta_porder( $meta );
|
1650 |
-
$linkurl = wppa_get_meta_linkurl( $meta );
|
1651 |
-
$linktitle = wppa_get_meta_linktitle( $meta );
|
1652 |
-
}
|
1653 |
-
else {
|
1654 |
-
$alb = $album; // default album
|
1655 |
-
$name = ''; // default name
|
1656 |
-
$desc = ''; // default description
|
1657 |
-
$porder = '0'; // default p_order
|
1658 |
-
$linkurl = '';
|
1659 |
-
$linktitle = '';
|
1660 |
-
}
|
1661 |
-
|
1662 |
-
// If there is a video or audio with the same name, this is the poster.
|
1663 |
-
$is_poster = wppa_file_is_in_album( wppa_strip_ext( basename( $file ) ) . '.xxx', $alb );
|
1664 |
-
if ( $is_poster ) {
|
1665 |
-
|
1666 |
-
// Delete possible poster sourcefile
|
1667 |
-
wppa_delete_source( basename( $file ), $alb );
|
1668 |
-
|
1669 |
-
// Remove possible existing posters, the file-extension may be different as before
|
1670 |
-
$old_photo = wppa_strip_ext( wppa_get_photo_path( $is_poster ) );
|
1671 |
-
$old_thumb = wppa_strip_ext( wppa_get_thumb_path( $is_poster ) );
|
1672 |
-
foreach ( $wppa_supported_photo_extensions as $pext ) {
|
1673 |
-
@ unlink( $old_photo . '.' . $pext );
|
1674 |
-
@ unlink( $old_thumb . '.' . $pext );
|
1675 |
-
}
|
1676 |
-
|
1677 |
-
// Clear sizes on db
|
1678 |
-
wppa_update_photo( array( 'thumbx' => '0',
|
1679 |
-
'thumby' => '0',
|
1680 |
-
'photox' => '0',
|
1681 |
-
'photoy' => '0'
|
1682 |
-
));
|
1683 |
-
|
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 |
-
wppa_make_o1_source( $is_poster );
|
1690 |
-
$pcount++;
|
1691 |
-
$totpcount += $bret;
|
1692 |
-
if ( $delp ) {
|
1693 |
-
unlink( $file );
|
1694 |
-
}
|
1695 |
-
}
|
1696 |
-
else { // Failed
|
1697 |
-
if ( ! wppa( 'ajax' ) ) {
|
1698 |
-
wppa_error_message('Failed to add poster for item '.$is_poster);
|
1699 |
-
}
|
1700 |
-
if ( $delf ) {
|
1701 |
-
unlink( $file );
|
1702 |
-
}
|
1703 |
-
}
|
1704 |
-
}
|
1705 |
-
|
1706 |
-
// Update the photo ?
|
1707 |
-
elseif ( isset( $_POST['wppa-update'] ) ) {
|
1708 |
-
|
1709 |
-
if ( wppa( 'is_wppa_tree' ) ) {
|
1710 |
-
$tmp = explode( '/wppa/', $file );
|
1711 |
-
$name = str_replace( '/', '', $tmp[1] );
|
1712 |
-
}
|
1713 |
-
|
1714 |
-
$iret = wppa_update_photo_files( $unsanitized_path_name, $name );
|
1715 |
-
if ( $iret ) {
|
1716 |
-
if ( wppa( 'ajax' ) ) wppa( 'ajax_import_files_done', true );
|
1717 |
-
$pcount++;
|
1718 |
-
$totpcount += $iret;
|
1719 |
-
if ( $delp ) {
|
1720 |
-
unlink( $unsanitized_path_name );
|
1721 |
-
}
|
1722 |
-
}
|
1723 |
-
else {
|
1724 |
-
if ( $delf ) {
|
1725 |
-
unlink( $unsanitized_path_name );
|
1726 |
-
}
|
1727 |
-
}
|
1728 |
-
}
|
1729 |
-
|
1730 |
-
// Insert the photo
|
1731 |
-
else {
|
1732 |
-
if ( is_numeric( $alb ) && $alb != '0' ) {
|
1733 |
-
if ( wppa( 'is_wppa_tree' ) ) {
|
1734 |
-
$tmp = explode( '/wppa/', $file );
|
1735 |
-
$id = str_replace( '/', '', $tmp[1] );
|
1736 |
-
$name = $id;
|
1737 |
-
}
|
1738 |
-
else {
|
1739 |
-
$id = basename( $file );
|
1740 |
-
}
|
1741 |
-
if ( wppa_switch( 'void_dups' ) && wppa_file_is_in_album( $id, $alb ) ) {
|
1742 |
-
wppa_warning_message( sprintf( __( 'Photo %s already exists in album %s. (1)' , 'wp-photo-album-plus'), $id, $alb ) );
|
1743 |
-
wppa( 'ajax_import_files_error', __( 'Duplicate', 'wp-photo-album-plus') );
|
1744 |
-
if ( $delf ) {
|
1745 |
-
unlink( $file );
|
1746 |
-
}
|
1747 |
-
}
|
1748 |
-
else {
|
1749 |
-
$id = substr( $id, 0, strpos( $id, '.' ) );
|
1750 |
-
if ( !is_numeric( $id ) || ! wppa_is_id_free( 'photo', $id ) ) $id = 0;
|
1751 |
-
if ( wppa_insert_photo( $unsanitized_path_name, $alb, stripslashes( $name ), stripslashes( $desc ), $porder, $id, stripslashes( $linkurl ), stripslashes( $linktitle ) ) ) {
|
1752 |
-
if ( wppa( 'ajax' ) ) {
|
1753 |
-
wppa( 'ajax_import_files_done', true );
|
1754 |
-
}
|
1755 |
-
$pcount++;
|
1756 |
-
if ( $delp ) {
|
1757 |
-
unlink( $unsanitized_path_name );
|
1758 |
-
if ( is_file( $meta ) ) unlink( $meta );
|
1759 |
-
}
|
1760 |
-
}
|
1761 |
-
else {
|
1762 |
-
wppa_error_message( __( 'Error inserting photo' , 'wp-photo-album-plus') . ' ' . basename( $file ) . '.' );
|
1763 |
-
if ( $delf ) {
|
1764 |
-
unlink( $unsanitized_path_name );
|
1765 |
-
}
|
1766 |
-
}
|
1767 |
-
}
|
1768 |
-
}
|
1769 |
-
else {
|
1770 |
-
wppa_error_message( sprintf( __( 'Error inserting photo %s, unknown or non existent album.' , 'wp-photo-album-plus'), basename( $file ) ) );
|
1771 |
-
}
|
1772 |
-
} // Insert
|
1773 |
-
}
|
1774 |
-
}
|
1775 |
-
$idx++;
|
1776 |
-
if ( $source_type == 'remote' ) unset( $files[$file_idx] );
|
1777 |
-
if ( wppa_is_time_up() ) {
|
1778 |
-
wppa_warning_message( sprintf( __( 'Time out. %s photos imported. Please restart this operation.' , 'wp-photo-album-plus'), $pcount ) );
|
1779 |
-
wppa_set_last_album( $album );
|
1780 |
-
if ( $source_type == 'remote' ) update_option( 'wppa_import_source_url_found_'.$user, $files );
|
1781 |
-
return;
|
1782 |
-
}
|
1783 |
-
} // foreach $files
|
1784 |
-
if ( $source_type == 'remote' ) update_option( 'wppa_import_source_url_found_'.$user, $files );
|
1785 |
-
|
1786 |
-
// Now the dirs to album imports
|
1787 |
-
|
1788 |
-
$idx = '0';
|
1789 |
-
$dircount = '0';
|
1790 |
-
global $photocount;
|
1791 |
-
$photocount = '0';
|
1792 |
-
$iret = true;
|
1793 |
-
|
1794 |
-
foreach ( $files as $file ) {
|
1795 |
-
if ( basename( $file ) != '.' && basename( $file ) != '..' && ( isset( $_POST['file-'.$idx] ) || isset( $_GET['continue'] ) ) ) {
|
1796 |
-
if ( is_dir( $file ) ) {
|
1797 |
-
$iret = wppa_import_dir_to_album( $file, '0' );
|
1798 |
-
if ( wppa_is_time_up() && wppa_switch( 'auto_continue' ) ) {
|
1799 |
-
wppa( 'continue', 'continue' );
|
1800 |
-
}
|
1801 |
-
$dircount++;
|
1802 |
-
}
|
1803 |
-
}
|
1804 |
-
$idx++;
|
1805 |
-
if ( $iret == false ) break; // Time out
|
1806 |
-
}
|
1807 |
-
|
1808 |
-
// Now the video files
|
1809 |
-
$videocount = '0';
|
1810 |
-
$alb = isset( $_POST['wppa-video-album'] ) ? $_POST['wppa-video-album'] : '0';
|
1811 |
-
if ( wppa( 'ajax' ) && ! $alb ) {
|
1812 |
-
wppa( 'ajax_import_files_error', __( 'Unknown album' , 'wp-photo-album-plus' ) );
|
1813 |
-
}
|
1814 |
-
else foreach ( array_keys( $files ) as $idx ) {
|
1815 |
-
$file = $files[$idx];
|
1816 |
-
if ( isset( $_POST['file-'.$idx] ) || wppa( 'ajax' ) ) {
|
1817 |
-
if ( wppa( 'ajax' ) ) wppa( 'ajax_import_files', wppa_sanitize_file_name( basename( $file ) ) ); /* */
|
1818 |
-
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
1819 |
-
if ( in_array( $ext, $wppa_supported_video_extensions ) ) {
|
1820 |
-
if ( is_numeric( $alb ) && $alb != '0' ) {
|
1821 |
-
|
1822 |
-
// Do we have this filename with ext xxx in this album?
|
1823 |
-
$filename = wppa_strip_ext( basename( $file ) ).'.xxx';
|
1824 |
-
$id = wppa_file_is_in_album( $filename, $alb );
|
1825 |
-
|
1826 |
-
// Or maybe the poster is already there
|
1827 |
-
foreach ( $wppa_supported_photo_extensions as $pext ) {
|
1828 |
-
if ( ! $id ) {
|
1829 |
-
$id = wppa_file_is_in_album( str_replace( 'xxx', $pext, $filename ), $alb );
|
1830 |
-
}
|
1831 |
-
}
|
1832 |
-
|
1833 |
-
// This filename already exists: is the poster. Fix the filename in the photo info
|
1834 |
-
if ( $id ) {
|
1835 |
-
$fname = wppa_get_photo_item( $id, 'filename' );
|
1836 |
-
$fname = wppa_strip_ext( $fname ) . '.xxx';
|
1837 |
-
|
1838 |
-
// Fix filename and ext in photo info
|
1839 |
-
wppa_update_photo( array( 'id' => $id, 'filename' => $fname, 'ext' => 'xxx' ) );
|
1840 |
-
}
|
1841 |
-
|
1842 |
-
// Add new entry
|
1843 |
-
if ( ! $id ) {
|
1844 |
-
$id = wppa_create_photo_entry( array( 'album' => $alb, 'filename' => $filename, 'ext' => 'xxx', 'name' => wppa_strip_ext( $filename ) ) );
|
1845 |
-
wppa_flush_treecounts( $alb );
|
1846 |
-
}
|
1847 |
-
|
1848 |
-
// Add video filetype
|
1849 |
-
$newpath = wppa_strip_ext( wppa_get_photo_path( $id ) ).'.'.$ext;
|
1850 |
-
copy( $file, $newpath );
|
1851 |
-
if ( $delv ) unlink( $file );
|
1852 |
-
if ( wppa( 'ajax' ) ) {
|
1853 |
-
wppa( 'ajax_import_files_done', true );
|
1854 |
-
}
|
1855 |
-
|
1856 |
-
// Make sure ext is set to xxx after adding video to an existing poster
|
1857 |
-
wppa_update_photo( array( 'id' => $id, 'ext' => 'xxx' ) );
|
1858 |
-
|
1859 |
-
// Book keeping
|
1860 |
-
$videocount++;
|
1861 |
-
}
|
1862 |
-
else {
|
1863 |
-
wppa_error_message( sprintf( __( 'Error inserting video %s, unknown or non existent album.' , 'wp-photo-album-plus'), basename( $file ) ) );
|
1864 |
-
}
|
1865 |
-
}
|
1866 |
-
}
|
1867 |
-
}
|
1868 |
-
|
1869 |
-
// Now the audio files
|
1870 |
-
$audiocount = '0';
|
1871 |
-
$alb = isset( $_POST['wppa-audio-album'] ) ? $_POST['wppa-audio-album'] : '0';
|
1872 |
-
if ( wppa( 'ajax' ) && ! $alb ) {
|
1873 |
-
wppa( 'ajax_import_files_error', __( 'Unknown album', 'wp-photo-album-plus' ) );
|
1874 |
-
}
|
1875 |
-
else foreach ( array_keys( $files ) as $idx ) {
|
1876 |
-
$file = $files[$idx];
|
1877 |
-
if ( isset( $_POST['file-'.$idx] ) || wppa( 'ajax' ) ) {
|
1878 |
-
if ( wppa( 'ajax' ) ) wppa( 'ajax_import_files', wppa_sanitize_file_name( basename( $file ) ) );
|
1879 |
-
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
1880 |
-
if ( in_array( $ext, $wppa_supported_audio_extensions ) ) {
|
1881 |
-
if ( is_numeric( $alb ) && $alb != '0' ) {
|
1882 |
-
|
1883 |
-
// Do we have this filename with ext xxx in this album?
|
1884 |
-
$filename = wppa_strip_ext( basename( $file ) ).'.xxx';
|
1885 |
-
$id = wppa_file_is_in_album( $filename, $alb );
|
1886 |
-
|
1887 |
-
// Or maybe the poster is already there
|
1888 |
-
foreach ( $wppa_supported_photo_extensions as $pext ) {
|
1889 |
-
if ( ! $id ) {
|
1890 |
-
$id = wppa_file_is_in_album( str_replace( 'xxx', $pext, $filename ), $alb );
|
1891 |
-
}
|
1892 |
-
}
|
1893 |
-
|
1894 |
-
// This filename already exists: is the poster. Fix the filename in the photo info
|
1895 |
-
if ( $id ) {
|
1896 |
-
$fname = wppa_get_photo_item( $id, 'filename' );
|
1897 |
-
$fname = wppa_strip_ext( $fname ) . '.xxx';
|
1898 |
-
|
1899 |
-
// Fix filename and ext in photo info
|
1900 |
-
wppa_update_photo( array( 'id' => $id, 'filename' => $fname, 'ext' => 'xxx' ) );
|
1901 |
-
}
|
1902 |
-
|
1903 |
-
// Add new entry
|
1904 |
-
if ( ! $id ) {
|
1905 |
-
$id = wppa_create_photo_entry( array( 'album' => $alb, 'filename' => $filename, 'ext' => 'xxx', 'name' => wppa_strip_ext( $filename ) ) );
|
1906 |
-
wppa_flush_treecounts( $alb );
|
1907 |
-
}
|
1908 |
-
|
1909 |
-
// Add audio filetype
|
1910 |
-
$newpath = wppa_strip_ext( wppa_get_photo_path( $id ) ).'.'.$ext;
|
1911 |
-
copy( $file, $newpath );
|
1912 |
-
if ( $delu ) unlink( $file );
|
1913 |
-
if ( wppa( 'ajax' ) ) {
|
1914 |
-
wppa( 'ajax_import_files_done', true );
|
1915 |
-
}
|
1916 |
-
|
1917 |
-
// Make sure ext is set to xxx after adding audio to an existing poster
|
1918 |
-
wppa_update_photo( array( 'id' => $id, 'ext' => 'xxx' ) );
|
1919 |
-
|
1920 |
-
// Book keeping
|
1921 |
-
$audiocount++;
|
1922 |
-
}
|
1923 |
-
else {
|
1924 |
-
wppa_error_message( sprintf( __( 'Error inserting audio %s, unknown or non existent album.' , 'wp-photo-album-plus'), basename( $file ) ) );
|
1925 |
-
}
|
1926 |
-
}
|
1927 |
-
}
|
1928 |
-
}
|
1929 |
-
|
1930 |
-
// The csv files. NOT with ajax
|
1931 |
-
$csvcount = wppa_get_csvcount( $files );
|
1932 |
-
if ( $csvcount ) {
|
1933 |
-
$csvcount = '0';
|
1934 |
-
if ( ! wppa( 'ajax' ) ) {
|
1935 |
-
if ( is_array( $files ) ) {
|
1936 |
-
|
1937 |
-
// Make sure the feature is on
|
1938 |
-
if ( ! wppa_switch( 'custom_fields' ) ) {
|
1939 |
-
wppa_update_option( 'wppa_custom_fields', 'yes' );
|
1940 |
-
echo '<b>' . __( 'Custom datafields enabled' , 'wp-photo-album-plus').'</b><br />';
|
1941 |
-
}
|
1942 |
-
|
1943 |
-
// Get the captions we already have
|
1944 |
-
$cust_labels = array();
|
1945 |
-
for ( $i = '0'; $i < '10'; $i++ ) {
|
1946 |
-
$cust_labels[$i] = wppa_opt( 'custom_caption_' . $i );
|
1947 |
-
}
|
1948 |
-
/*
|
1949 |
-
// Display the captions we have
|
1950 |
-
echo __( 'Captions are:' ) . ' ';
|
1951 |
-
for ( $i = 0; $i < '10'; $i++ ) {
|
1952 |
-
echo '[' . $i . '] -> ';
|
1953 |
-
if ( $cust_labels[$i] ) {
|
1954 |
-
echo $cust_labels[$i] . ' ';
|
1955 |
-
}
|
1956 |
-
else {
|
1957 |
-
echo __( '--- not used ---' ) . ' ';
|
1958 |
-
}
|
1959 |
-
}
|
1960 |
-
echo '<br />';
|
1961 |
-
*/
|
1962 |
-
// Process the files
|
1963 |
-
$photos_processed_csv = '0';
|
1964 |
-
$photos_skipped_csv = '0';
|
1965 |
-
foreach ( array_keys( $files ) as $idx ) {
|
1966 |
-
$this_skipped = '0';
|
1967 |
-
$file = $files[$idx];
|
1968 |
-
if ( isset( $_POST['file-'.$idx] ) || isset( $_GET['continue'] ) ) {
|
1969 |
-
$ext = strtolower( wppa_get_ext( $file ) );
|
1970 |
-
if ( $ext == 'csv' ) {
|
1971 |
-
echo '<b>' . __( 'Processing', 'wp-photo-album-plus') . ' ' . basename( $file ) . '</b><br />';
|
1972 |
-
wppa_log( 'dbg', __( 'Processing', 'wp-photo-album-plus') . ' ' . basename( $file ) );
|
1973 |
-
|
1974 |
-
// Copy the file to a temp file
|
1975 |
-
$tempfile = dirname( $file ) . '/temp.csv';
|
1976 |
-
copy ( $file, $tempfile );
|
1977 |
-
|
1978 |
-
// Open file
|
1979 |
-
$handle = fopen( $tempfile, "rt" );
|
1980 |
-
if ( ! $handle ) {
|
1981 |
-
wppa_error_message( __( 'Can not open file. Can not continue. (1)' , 'wp-photo-album-plus') );
|
1982 |
-
return;
|
1983 |
-
}
|
1984 |
-
$write_handle = fopen( $file, "wt" );
|
1985 |
-
if ( ! $write_handle ) {
|
1986 |
-
wppa_error_message( __( 'Can not open file. Can not continue. (2)' , 'wp-photo-album-plus') );
|
1987 |
-
return;
|
1988 |
-
}
|
1989 |
-
|
1990 |
-
// Read header
|
1991 |
-
$header = fgets( $handle, 4096 );
|
1992 |
-
if ( ! $header ) {
|
1993 |
-
wppa_error_message( __( 'Can not read header. Can not continue.' , 'wp-photo-album-plus') );
|
1994 |
-
fclose( $handle );
|
1995 |
-
return;
|
1996 |
-
}
|
1997 |
-
fputs( $write_handle, $header );
|
1998 |
-
echo __( 'Read header:' , 'wp-photo-album-plus') . ' ' . $header . '<br />';
|
1999 |
-
|
2000 |
-
// Interprete header
|
2001 |
-
$captions = wppa_explode_csv( $header );
|
2002 |
-
if ( ! is_array( $captions ) || count( $captions ) < '2' ) {
|
2003 |
-
wppa_error_message( __( 'Invalid header. Can not continue.' , 'wp-photo-album-plus') );
|
2004 |
-
fclose( $handle );
|
2005 |
-
return;
|
2006 |
-
}
|
2007 |
-
foreach ( array_keys( $captions ) as $key ) {
|
2008 |
-
if ( $key == '0' ) {
|
2009 |
-
if ( ! in_array( strtolower( trim( $captions['0'] ) ), array( 'name', 'photoname', 'filename' ) ) ) {
|
2010 |
-
wppa_error_message( __( 'Invalid header. First item must be \'name\', \'photoname\' or \'filename\'' , 'wp-photo-album-plus') );
|
2011 |
-
fclose( $handle );
|
2012 |
-
return;
|
2013 |
-
}
|
2014 |
-
}
|
2015 |
-
elseif ( ! in_array( $captions[$key], $cust_labels ) ) {
|
2016 |
-
if ( ! in_array( '', $cust_labels ) ) {
|
2017 |
-
wppa_error_message( __( 'All available custom data fields are in use. There is no space for' , 'wp-photo-album-plus') . ' ' . $captions[$key] );
|
2018 |
-
fclose( $handle );
|
2019 |
-
return;
|
2020 |
-
}
|
2021 |
-
|
2022 |
-
// Add a new caption
|
2023 |
-
$i = '0';
|
2024 |
-
while ( $cust_labels[$i] ) $i++;
|
2025 |
-
$cust_labels[$i] = $captions[$key];
|
2026 |
-
wppa_update_option( 'wppa_custom_caption_' . $i, $cust_labels[$i] );
|
2027 |
-
wppa_update_option( 'wppa_custom_visible_' . $i, 'yes' );
|
2028 |
-
wppa_log( 'dbg', sprintf( __( 'New caption %s added.' , 'wp-photo-album-plus'), $cust_labels[$i] ) );
|
2029 |
-
}
|
2030 |
-
}
|
2031 |
-
|
2032 |
-
// Find the correlation between caption index and custom data index.
|
2033 |
-
$pointers = array();
|
2034 |
-
for ( $i = '1'; $i < count( $captions ); $i++ ) {
|
2035 |
-
for ( $j = '0'; $j < '10'; $j++ ) {
|
2036 |
-
if ( $captions[$i] == $cust_labels[$j] ) {
|
2037 |
-
$pointers[$j] = $i;
|
2038 |
-
}
|
2039 |
-
}
|
2040 |
-
}
|
2041 |
-
|
2042 |
-
// Now process the lines
|
2043 |
-
while ( ! feof( $handle ) ) {
|
2044 |
-
$dataline = fgets( $handle, 4096 );
|
2045 |
-
if ( $dataline ) {
|
2046 |
-
wppa_log( 'dbg', __( 'Read data:' , 'wp-photo-album-plus') . ' ' . trim( $dataline ) );
|
2047 |
-
$data_arr = wppa_explode_csv( $dataline );
|
2048 |
-
$search = $data_arr[0];
|
2049 |
-
switch ( strtolower($captions[0]) ) {
|
2050 |
-
case 'photoname':
|
2051 |
-
$photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `name` = %s", $data_arr[0] ), ARRAY_A );
|
2052 |
-
break;
|
2053 |
-
case 'filename':
|
2054 |
-
$photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `filename` = %s", $data_arr[0] ), ARRAY_A );
|
2055 |
-
break;
|
2056 |
-
case 'name':
|
2057 |
-
$photos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPPA_PHOTOS."` WHERE `name` = %s OR `filename` = %s", $data_arr[0], $data_arr[0] ), ARRAY_A );
|
2058 |
-
break;
|
2059 |
-
}
|
2060 |
-
if ( $photos ) {
|
2061 |
-
foreach( $photos as $photo ) {
|
2062 |
-
$cust_data = $photo['custom'] ? unserialize( $photo['custom'] ) : array( '', '', '', '', '', '', '', '', '', '' );
|
2063 |
-
foreach( array_keys( $pointers ) as $p ) {
|
2064 |
-
$cust_data[$p] = wppa_sanitize_custom_field( $data_arr[$pointers[$p]] );
|
2065 |
-
}
|
2066 |
-
wppa_update_photo( array( 'id' => $photo['id'], 'custom' => serialize( $cust_data ) ) );
|
2067 |
-
$photos_processed_csv ++;
|
2068 |
-
}
|
2069 |
-
wppa_log( 'dbg', 'Processed: ' . $data_arr[0] );
|
2070 |
-
}
|
2071 |
-
|
2072 |
-
// This line could not be processed
|
2073 |
-
else {
|
2074 |
-
wppa_log( 'dbg', 'Could not find: ' . $data_arr[0] );
|
2075 |
-
|
2076 |
-
// Write back to original file
|
2077 |
-
fputs( $write_handle, $dataline );
|
2078 |
-
$photos_skipped_csv++;
|
2079 |
-
$this_skipped++;
|
2080 |
-
}
|
2081 |
-
echo '.';
|
2082 |
-
}
|
2083 |
-
|
2084 |
-
// Time up?
|
2085 |
-
if ( wppa_is_time_up() && wppa_switch( 'auto_continue' ) ) {
|
2086 |
-
wppa( 'continue', 'continue' );
|
2087 |
-
|
2088 |
-
// Copy rest of file back to original
|
2089 |
-
while ( ! feof( $handle ) ) {
|
2090 |
-
$temp = fgets( $handle, 4096 );
|
2091 |
-
fputs( $write_handle, $temp );
|
2092 |
-
}
|
2093 |
-
}
|
2094 |
-
}
|
2095 |
-
|
2096 |
-
fclose( $handle );
|
2097 |
-
fclose( $write_handle );
|
2098 |
-
|
2099 |
-
$csvcount++;
|
2100 |
-
|
2101 |
-
// Remove tempfile
|
2102 |
-
unlink( $tempfile );
|
2103 |
-
|
2104 |
-
// Remove orig file
|
2105 |
-
if ( ! $this_skipped && ! wppa_is_time_up() ) {
|
2106 |
-
unlink( $file );
|
2107 |
-
}
|
2108 |
-
}
|
2109 |
-
}
|
2110 |
-
}
|
2111 |
-
}
|
2112 |
-
}
|
2113 |
-
}
|
2114 |
-
|
2115 |
-
wppa_ok_message( __( 'Done processing files.' , 'wp-photo-album-plus') );
|
2116 |
-
|
2117 |
-
if ( $pcount == '0' && $acount == '0' && $zcount == '0' && $dircount == '0' && $photocount == '0' && $videocount == '0' && $audiocount == '0' && $csvcount == '0' ) {
|
2118 |
-
wppa_warning_message( __( 'No files to import.' , 'wp-photo-album-plus') );
|
2119 |
-
}
|
2120 |
-
else {
|
2121 |
-
$msg = '';
|
2122 |
-
if ( $zcount ) $msg .= $zcount.' '.__( 'Zipfiles extracted.' , 'wp-photo-album-plus').' ';
|
2123 |
-
if ( $acount ) $msg .= $acount.' '.__( 'Albums created.' , 'wp-photo-album-plus').' ';
|
2124 |
-
if ( $dircount ) $msg .= $dircount.' '.__( 'Directory to album imports.' , 'wp-photo-album-plus').' ';
|
2125 |
-
if ( $photocount ) $msg .= ' '.sprintf( __( 'With total %s photos.','wppa' , 'wp-photo-album-plus'), $photocount ).' ';
|
2126 |
-
if ( $pcount ) {
|
2127 |
-
if ( isset( $_POST['wppa-update'] ) ) {
|
2128 |
-
$msg .= $pcount.' '.__( 'Photos updated' , 'wp-photo-album-plus');
|
2129 |
-
if ( $totpcount != $pcount ) {
|
2130 |
-
$msg .= ' '.sprintf( __( 'to %s locations' , 'wp-photo-album-plus'), $totpcount );
|
2131 |
-
}
|
2132 |
-
$msg .= '.';
|
2133 |
-
}
|
2134 |
-
else $msg .= $pcount.' '.__( 'single photos imported.' , 'wp-photo-album-plus').' ';
|
2135 |
-
}
|
2136 |
-
if ( $videocount ) {
|
2137 |
-
$msg .= $videocount.' '.__( 'Videos imported.' , 'wp-photo-album-plus');
|
2138 |
-
}
|
2139 |
-
if ( $audiocount ) {
|
2140 |
-
$msg .= $audiocount.' '.__( 'Audios imported.' , 'wp-photo-album-plus');
|
2141 |
-
}
|
2142 |
-
if ( $csvcount ) {
|
2143 |
-
$msg .= $csvcount . ' ' . __( 'CSVs imported,' , 'wp-photo-album-plus') . ' ' .
|
2144 |
-
$photos_processed_csv .' '. __( 'photos processed.', 'wp-photo-album-plus') . ' ' .
|
2145 |
-
$photos_skipped_csv . ' ' . __('photos skipped.', 'wp-photo-album-plus');
|
2146 |
-
}
|
2147 |
-
wppa_ok_message( $msg );
|
2148 |
-
wppa_set_last_album( $album );
|
2149 |
-
}
|
2150 |
-
}
|
2151 |
-
|
2152 |
-
function wppa_get_zipcount( $files ) {
|
2153 |
-
$result = 0;
|
2154 |
-
if ( $files ) {
|
2155 |
-
foreach ( $files as $file ) {
|
2156 |
-
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
2157 |
-
if ( $ext == 'zip' ) $result++;
|
2158 |
-
}
|
2159 |
-
}
|
2160 |
-
return $result;
|
2161 |
-
}
|
2162 |
-
|
2163 |
-
function wppa_get_albumcount( $files ) {
|
2164 |
-
$result = 0;
|
2165 |
-
if ( $files ) {
|
2166 |
-
foreach ( $files as $file ) {
|
2167 |
-
$ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
|
2168 |
-
if ( $ext == 'amf' ) $result++;
|
2169 |
-
}
|
2170 |
-
}
|
2171 |
-
return $result;
|
2172 |
-
}
|
2173 |
-
|
2174 |
-
function wppa_get_photocount( $files ) {
|
2175 |
-
global $wppa_supported_photo_extensions;
|
2176 |
-
|
2177 |
-
$result = 0;
|
2178 |
-
if ( $files ) {
|
2179 |
-
foreach ( $files as $file ) {
|
2180 |
-
$ext = strtolower( wppa_get_ext( $file ) );
|
2181 |
-
if ( in_array( $ext, $wppa_supported_photo_extensions ) ) $result++;
|
2182 |
-
}
|
2183 |
-
}
|
2184 |
-
return $result;
|
2185 |
-
}
|
2186 |
-
|
2187 |
-
function wppa_get_video_count( $files ) {
|
2188 |
-
global $wppa_supported_video_extensions;
|
2189 |
-
|
2190 |
-
$result = 0;
|
2191 |
-
if ( $files ) {
|
2192 |
-
foreach ( $files as $file ) {
|
2193 |
-
$ext = strtolower( wppa_get_ext( $file ) );
|
2194 |
-
if ( in_array( $ext, $wppa_supported_video_extensions ) ) $result++;
|
2195 |
-
}
|
2196 |
-
}
|
2197 |
-
return $result;
|
2198 |
-
}
|
2199 |
-
|
2200 |
-
function wppa_get_audio_count( $files ) {
|
2201 |
-
global $wppa_supported_audio_extensions;
|
2202 |
-
|
2203 |
-
$result = 0;
|
2204 |
-
if ( $files ) {
|
2205 |
-
foreach ( $files as $file ) {
|
2206 |
-
$ext = strtolower( wppa_get_ext( $file ) );
|
2207 |
-
if ( in_array( $ext, $wppa_supported_audio_extensions ) ) $result++;
|
2208 |
-
}
|
2209 |
-
}
|
2210 |
-
return $result;
|
2211 |
-
}
|
2212 |
-
|
2213 |
-
|
2214 |
-
// Find dir is new album candidates
|
2215 |
-
function wppa_get_dircount( $files ) {
|
2216 |
-
$result = 0;
|
2217 |
-
if ( $files ) {
|
2218 |
-
foreach ( $files as $file ) {
|
2219 |
-
if ( basename( $file ) == '.' ) {}
|
2220 |
-
elseif ( basename( $file ) == '..' ) {}
|
2221 |
-
elseif ( is_dir( $file ) ) $result++;
|
2222 |
-
}
|
2223 |
-
}
|
2224 |
-
return $result;
|
2225 |
-
}
|
2226 |
-
|
2227 |
-
// Find .csv file count
|
2228 |
-
function wppa_get_csvcount( $files ) {
|
2229 |
-
$result = 0;
|
2230 |
-
if ( $files ) {
|
2231 |
-
foreach ( $files as $file ) {
|
2232 |
-
if ( is_file( $file ) ) {
|
2233 |
-
if ( strtolower( wppa_get_ext( $file ) ) == 'csv' ) $result++;
|
2234 |
-
}
|
2235 |
-
}
|
2236 |
-
}
|
2237 |
-
return $result;
|
2238 |
-
}
|
2239 |
-
|
2240 |
-
function wppa_get_meta_name( $file, $opt = '' ) {
|
2241 |
-
return wppa_get_meta_data( $file, 'name', $opt );
|
2242 |
-
}
|
2243 |
-
function wppa_get_meta_album( $file, $opt = '' ) {
|
2244 |
-
return wppa_get_meta_data( $file, 'albm', $opt );
|
2245 |
-
}
|
2246 |
-
function wppa_get_meta_desc( $file, $opt = '' ) {
|
2247 |
-
return wppa_get_meta_data( $file, 'desc', $opt );
|
2248 |
-
}
|
2249 |
-
function wppa_get_meta_porder( $file, $opt = '' ) {
|
2250 |
-
return wppa_get_meta_data( $file, 'pord', $opt );
|
2251 |
-
}
|
2252 |
-
function wppa_get_meta_linkurl( $file, $opt = '' ) {
|
2253 |
-
return wppa_get_meta_data( $file, 'lnku', $opt );
|
2254 |
-
}
|
2255 |
-
function wppa_get_meta_linktitle( $file, $opt = '' ) {
|
2256 |
-
return wppa_get_meta_data( $file, 'lnkt', $opt );
|
2257 |
-
}
|
2258 |
-
|
2259 |
-
function wppa_get_meta_data( $file, $item, $opt ) {
|
2260 |
-
$result = '';
|
2261 |
-
$opt2 = '';
|
2262 |
-
if ( $opt == '( ' ) $opt2 = ' )';
|
2263 |
-
if ( $opt == '{' ) $opt2 = '}';
|
2264 |
-
if ( $opt == '[' ) $opt2 = ']';
|
2265 |
-
if ( is_file( $file ) ) {
|
2266 |
-
$handle = fopen( $file, "r" );
|
2267 |
-
if ( $handle ) {
|
2268 |
-
while ( ( $buffer = fgets( $handle, 4096 ) ) !== false ) {
|
2269 |
-
if ( substr( $buffer, 0, 5 ) == $item.'=' ) {
|
2270 |
-
if ( $opt == '' ) $result = substr( $buffer, 5, strlen( $buffer )-6 );
|
2271 |
-
else $result = $opt.__( substr( $buffer, 5, strlen( $buffer )-6 ) ).$opt2; // Translate for display purposes only
|
2272 |
-
}
|
2273 |
-
}
|
2274 |
-
if ( !feof( $handle ) ) {
|
2275 |
-
_e( 'Error: unexpected fgets() fail in wppa_get_meta_data().' , 'wp-photo-album-plus');
|
2276 |
-
}
|
2277 |
-
fclose( $handle );
|
2278 |
-
}
|
2279 |
-
}
|
2280 |
-
return $result;
|
2281 |
-
}
|
2282 |
-
|
2283 |
-
|
2284 |
-
function wppa_extract( $xpath, $delz ) {
|
2285 |
-
// There are two reasons that we do not allow the directory structure from the zipfile to be restored.
|
2286 |
-
// 1. we may have no create dir access rights.
|
2287 |
-
// 2. we can not reach the pictures as we only glob the users depot and not lower.
|
2288 |
-
// We extract all files to the users depot.
|
2289 |
-
// The illegal files will be deleted there by the wppa_sanitize_files routine,
|
2290 |
-
// so there is no chance a depot/subdir/destroy.php or the like will get a chance to be created.
|
2291 |
-
// dus...
|
2292 |
-
|
2293 |
-
$err = '0';
|
2294 |
-
if ( ! class_exists( 'ZipArchive' ) ) {
|
2295 |
-
$err = '3';
|
2296 |
-
wppa_error_message( __( 'Class ZipArchive does not exist! Check your php configuration' , 'wp-photo-album-plus') );
|
2297 |
-
}
|
2298 |
-
else {
|
2299 |
-
|
2300 |
-
// Start security fix
|
2301 |
-
$path = wppa_sanitize_file_name( $xpath );
|
2302 |
-
if ( ! file_exists( $xpath ) ) {
|
2303 |
-
wppa_error_message( 'Zipfile '.$path.' does not exist.' );
|
2304 |
-
// unlink( $xpath );
|
2305 |
-
$err = '4';
|
2306 |
-
return $err;
|
2307 |
-
}
|
2308 |
-
// End security fix
|
2309 |
-
|
2310 |
-
$ext = strtolower( wppa_get_ext( $xpath ) );
|
2311 |
-
if ( $ext == 'zip' ) {
|
2312 |
-
$zip = new ZipArchive;
|
2313 |
-
if ( $zip->open( $xpath ) === true ) {
|
2314 |
-
|
2315 |
-
$supported_file_ext = array( 'jpg', 'png', 'gif', 'JPG', 'PNG', 'GIF', 'amf', 'pmf' );
|
2316 |
-
$done = '0';
|
2317 |
-
$skip = '0';
|
2318 |
-
for( $i = 0; $i < $zip->numFiles; $i++ ){
|
2319 |
-
$stat = $zip->statIndex( $i );
|
2320 |
-
$file_ext = @ end( explode( '.', $stat['name'] ) );
|
2321 |
-
if ( in_array( $file_ext, $supported_file_ext ) ) {
|
2322 |
-
$zip->extractTo( WPPA_DEPOT_PATH, $stat['name'] );
|
2323 |
-
$done++;
|
2324 |
-
}
|
2325 |
-
else {
|
2326 |
-
wppa_warning_message( sprintf( __( 'File %s is of an unsupported filetype and has been ignored during extraction.' , 'wp-photo-album-plus'), wppa_sanitize_file_name( $stat['name'] ) ) );
|
2327 |
-
$skip++;
|
2328 |
-
}
|
2329 |
-
}
|
2330 |
-
|
2331 |
-
$zip->close();
|
2332 |
-
wppa_ok_message( sprintf( __( 'Zipfile %s processed. %s files extracted, %s files skipped.' , 'wp-photo-album-plus'), basename( $path ), $done, $skip ) );
|
2333 |
-
if ( $delz ) unlink( $xpath );
|
2334 |
-
} else {
|
2335 |
-
wppa_error_message( __( 'Failed to extract' , 'wp-photo-album-plus').' '.$path );
|
2336 |
-
$err = '1';
|
2337 |
-
}
|
2338 |
-
}
|
2339 |
-
else $err = '2';
|
2340 |
-
}
|
2341 |
-
return $err;
|
2342 |
-
}
|
2343 |
-
|
2344 |
-
function wppa_import_dir_to_album( $file, $parent ) {
|
2345 |
-
global $photocount;
|
2346 |
-
global $wpdb;
|
2347 |
-
global $wppa_session;
|
2348 |
-
|
2349 |
-
// Session should survive the default hour
|
2350 |
-
wppa_extend_session();
|
2351 |
-
|
2352 |
-
// see if album exists
|
2353 |
-
if ( is_dir( $file ) ) {
|
2354 |
-
|
2355 |
-
// Check parent
|
2356 |
-
if ( wppa_switch( 'import_parent_check' ) ) {
|
2357 |
-
|
2358 |
-
$alb = wppa_get_album_id( basename( $file ), $parent );
|
2359 |
-
|
2360 |
-
// If parent = 0 ( top-level album ) and album not found,
|
2361 |
-
// try a 'separate' album ( i.e. parent = -1 ) with this name
|
2362 |
-
if ( ! $alb && $parent == '0' ) {
|
2363 |
-
$alb = wppa_get_album_id( basename( $file ), '-1' );
|
2364 |
-
}
|
2365 |
-
}
|
2366 |
-
|
2367 |
-
// All albums have unique names, do'nt worry about parent
|
2368 |
-
else {
|
2369 |
-
$alb = wppa_get_album_id( basename( $file ), false );
|
2370 |
-
}
|
2371 |
-
|
2372 |
-
if ( ! $alb ) { // Album must be created
|
2373 |
-
$name = basename( $file );
|
2374 |
-
$uplim = wppa_opt( 'upload_limit_count' ). '/' . wppa_opt( 'upload_limit_time' );
|
2375 |
-
$alb = wppa_create_album_entry( array ( 'name' => $name,
|
2376 |
-
'a_parent' => $parent
|
2377 |
-
) );
|
2378 |
-
if ( $alb === false ) {
|
2379 |
-
wppa_error_message( __( 'Could not create album.' , 'wp-photo-album-plus').'<br/>Query = '.$query );
|
2380 |
-
wp_die( 'Sorry, cannot continue' );
|
2381 |
-
}
|
2382 |
-
else {
|
2383 |
-
wppa_set_last_album( $alb );
|
2384 |
-
wppa_flush_treecounts( $alb );
|
2385 |
-
wppa_index_add( 'album', $alb );
|
2386 |
-
wppa_create_pl_htaccess();
|
2387 |
-
wppa_ok_message( __( 'Album #' , 'wp-photo-album-plus') . ' ' . $alb . ' ( '.$name.' ) ' . __( 'Added.' , 'wp-photo-album-plus') );
|
2388 |
-
if ( wppa_switch( 'newpag_create' ) && $parent <= '0' ) {
|
2389 |
-
|
2390 |
-
// Create post object
|
2391 |
-
$my_post = array(
|
2392 |
-
'post_title' => $name,
|
2393 |
-
'post_content' => str_replace( 'w#album', $alb, wppa_opt( 'newpag_content' ) ),
|
2394 |
-
'post_status' => wppa_opt( 'newpag_status' ),
|
2395 |
-
'post_type' => wppa_opt( 'newpag_type' )
|
2396 |
-
);
|
2397 |
-
|
2398 |
-
// Insert the post into the database
|
2399 |
-
$pagid = wp_insert_post( $my_post );
|
2400 |
-
if ( $pagid ) {
|
2401 |
-
wppa_ok_message( sprintf( __( 'Page <a href="%s" target="_blank" >%s</a> created.' , 'wp-photo-album-plus'), home_url().'?page_id='.$pagid, $name ) );
|
2402 |
-
$wpdb->query( $wpdb->prepare( "UPDATE `".WPPA_ALBUMS."` SET `cover_linkpage` = %s WHERE `id` = %s", $pagid, $alb ) );
|
2403 |
-
}
|
2404 |
-
else {
|
2405 |
-
wppa_error_message( __( 'Could not create page.' , 'wp-photo-album-plus') );
|
2406 |
-
}
|
2407 |
-
}
|
2408 |
-
}
|
2409 |
-
}
|
2410 |
-
|
2411 |
-
// Now import the files
|
2412 |
-
$photofiles = glob( $file.'/*' );
|
2413 |
-
if ( $photofiles ) foreach ( $photofiles as $photofile ) {
|
2414 |
-
if ( ! is_dir( $photofile ) ) {
|
2415 |
-
|
2416 |
-
if ( ! isset( $wppa_session[$photofile] ) || ! wppa_switch( 'keep_import_files' ) ) {
|
2417 |
-
|
2418 |
-
if ( wppa_albumphoto_exists( $alb, basename( $photofile ) ) ) {
|
2419 |
-
if ( ! wppa_switch( 'keep_import_files' ) ) {
|
2420 |
-
wppa_warning_message( 'Photo '.basename( $photofile ).' already exists in album '.$alb.'. Removed. (2)' );
|
2421 |
-
}
|
2422 |
-
}
|
2423 |
-
else {
|
2424 |
-
$bret = wppa_insert_photo( $photofile, $alb, basename( $photofile ) );
|
2425 |
-
$photocount++;
|
2426 |
-
}
|
2427 |
-
if ( ! wppa_switch( 'keep_import_files' ) ) {
|
2428 |
-
@ unlink( $photofile );
|
2429 |
-
}
|
2430 |
-
$wppa_session[$photofile] = true;
|
2431 |
-
}
|
2432 |
-
|
2433 |
-
if ( wppa_is_time_up( $photocount ) ) return false;
|
2434 |
-
}
|
2435 |
-
}
|
2436 |
-
|
2437 |
-
// Now go deeper, process the subdirs
|
2438 |
-
$subdirs = glob( $file.'/*' );
|
2439 |
-
if ( $subdirs ) foreach ( $subdirs as $subdir ) {
|
2440 |
-
if ( is_dir( $subdir ) ) {
|
2441 |
-
if ( basename( $subdir ) != '.' && basename( $subdir ) != '..' ) {
|
2442 |
-
$bret = wppa_import_dir_to_album( $subdir, $alb );
|
2443 |
-
if ( ! $bret ) return false; // Time out
|
2444 |
-
}
|
2445 |
-
}
|
2446 |
-
}
|
2447 |
-
@ rmdir( $file ); // Try to remove dir, ignore error
|
2448 |
-
}
|
2449 |
-
else {
|
2450 |
-
wppa_dbg_msg( 'Invalid file in wppa_import_dir_to_album(): '.$file );
|
2451 |
-
return false;
|
2452 |
-
}
|
2453 |
-
return true;
|
2454 |
-
}
|
2455 |
-
|
2456 |
-
function wppa_is_wppa_tree( $file ) {
|
2457 |
-
|
2458 |
-
$temp = explode( '/uploads/wppa/', $file );
|
2459 |
-
if ( count( $temp ) === 2 ) {
|
2460 |
-
$temp[1] = wppa_expand_id( wppa_strip_ext( $temp[1] ) ) . '.' . wppa_get_ext( $temp[1] );
|
2461 |
-
$newf = implode( '/wppa/', $temp );
|
2462 |
-
wppa( 'is_wppa_tree', ( $newf != $file ) );
|
2463 |
-
}
|
2464 |
-
else {
|
2465 |
-
wppa( 'is_wppa_tree', false );
|
2466 |
-
}
|
2467 |
-
return wppa( 'is_wppa_tree' );
|
2468 |
-
}
|
2469 |
-
|
2470 |
-
function wppa_compress_tree_path( $path ) {
|
2471 |
-
|
2472 |
-
$result = $path;
|
2473 |
-
$temp = explode( '/wppa/', $path );
|
2474 |
-
if ( count( $temp ) == '2' ) {
|
2475 |
-
$temp[1] = str_replace( '/', '', $temp[1] );
|
2476 |
-
$result = implode( '/wppa/', $temp );
|
2477 |
-
}
|
2478 |
-
return $result;
|
2479 |
-
}
|
2480 |
-
|
2481 |
-
function wppa_expand_tree_path( $path ) {
|
2482 |
-
|
2483 |
-
$result = $path;
|
2484 |
-
$temp = explode( '/wppa/', $path );
|
2485 |
-
if ( count( $temp ) == '2' ) {
|
2486 |
-
$temp[1] = wppa_expand_id( wppa_strip_ext( $temp[1] ) ) . '.' . wppa_get_ext( $temp[1] );
|
2487 |
-
$result = implode( '/wppa/', $temp );
|
2488 |
-
}
|
2489 |
-
return $result;
|
2490 |
-
}
|
2491 |
-
|
2492 |
-
function wppa_abs_walktree( $root, $source ) {
|
2493 |
-
static $void_dirs;
|
2494 |
-
|
2495 |
-
// Init void dirs
|
2496 |
-
if ( ! $void_dirs ) {
|
2497 |
-
$void_dirs = array( '.', '..',
|
2498 |
-
'wp-admin',
|
2499 |
-
'wp-includes',
|
2500 |
-
'themes',
|
2501 |
-
'upgrade',
|
2502 |
-
'plugins',
|
2503 |
-
'languages',
|
2504 |
-
'wppa',
|
2505 |
-
( wppa_switch( 'allow_import_source') ? '' : 'wppa-source' ),
|
2506 |
-
);
|
2507 |
-
}
|
2508 |
-
|
2509 |
-
// If currently in selected dir, set selected
|
2510 |
-
$sel = $root == $source ? ' selected="selected"' : '';
|
2511 |
-
|
2512 |
-
// Set disabled if there are no files inside
|
2513 |
-
$n_files = count( glob( $root . '/*' ) );
|
2514 |
-
$n_dirs = count( glob( $root . '/*', GLOB_ONLYDIR ) );
|
2515 |
-
$dis = $n_files == $n_dirs ? ' disabled="disabled"' : '';
|
2516 |
-
|
2517 |
-
// Check for (sub)depot
|
2518 |
-
$my_depot = __( '--- My depot --- ' ,'wp-photo-album-plus' );
|
2519 |
-
$display = str_replace( WPPA_DEPOT_PATH, $my_depot, $root );
|
2520 |
-
if ( strpos( $display, $my_depot ) !== false ) {
|
2521 |
-
$dis = '';
|
2522 |
-
}
|
2523 |
-
|
2524 |
-
// Check for ngg gallery dir
|
2525 |
-
$ngg_opts = get_option( 'ngg_options', false );
|
2526 |
-
if ( $ngg_opts ) {
|
2527 |
-
$ngg_gal = __( '--- Ngg Galleries --- ', 'wp-photo-album-plus' );
|
2528 |
-
$display = str_replace( rtrim( $ngg_opts['gallerypath'], '/' ), $ngg_gal, $display );
|
2529 |
-
$pos = strpos( $display, $ngg_gal );
|
2530 |
-
if ( $pos ) {
|
2531 |
-
$display = substr( $display, $pos );
|
2532 |
-
}
|
2533 |
-
}
|
2534 |
-
|
2535 |
-
// Remove ABSPATH from display string
|
2536 |
-
$display = str_replace( ABSPATH, '', $display );
|
2537 |
-
|
2538 |
-
// Output the selecion if not in the wp dir
|
2539 |
-
if ( $root.'/' != ABSPATH ) {
|
2540 |
-
echo "\n" . '<option' .
|
2541 |
-
' value="' . $root . '"' .
|
2542 |
-
$sel .
|
2543 |
-
$dis .
|
2544 |
-
' data-nfiles="' . $n_files . '"' .
|
2545 |
-
' data-ndirs="' . $n_dirs . '"' .
|
2546 |
-
' >' .
|
2547 |
-
$display .
|
2548 |
-
'</option>';
|
2549 |
-
}
|
2550 |
-
|
2551 |
-
// See if subdirs exist
|
2552 |
-
$dirs = glob( $root . '/*', GLOB_ONLYDIR );
|
2553 |
-
|
2554 |
-
// Go deeper if not in a list of void disnames
|
2555 |
-
if ( $dirs ) foreach( $dirs as $path ) {
|
2556 |
-
$dir = basename( $path );
|
2557 |
-
if ( ! in_array( $dir, $void_dirs ) ) {
|
2558 |
-
$newroot = $root . '/' . $dir;
|
2559 |
-
wppa_abs_walktree( $newroot, $source );
|
2560 |
-
}
|
2561 |
-
}
|
2562 |
-
}
|
2 |
/* wppa-upload.php
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
+
* Contains all the upload pages and functions
|
6 |
+
* Version 6.5.02
|
7 |
*
|
8 |
*/
|
9 |
|
13 |
function _wppa_page_upload() {
|
14 |
global $target;
|
15 |
global $wppa_revno;
|
16 |
+
global $upload_album;
|
17 |
|
18 |
// sanitize system
|
19 |
$user = wppa_get_user();
|
20 |
wppa_sanitize_files();
|
21 |
|
22 |
+
// Sanitize album input
|
23 |
+
if ( isset( $_POST['wppa-album'] ) ) {
|
24 |
+
$upload_album = strval( intval( $_POST['wppa-album'] ) );
|
25 |
+
}
|
26 |
+
else {
|
27 |
+
$upload_album = null;
|
28 |
+
}
|
29 |
+
|
30 |
+
// Update watermark settings for the user if new values supplied
|
31 |
if ( wppa_switch( 'watermark_on' ) && ( wppa_switch( 'watermark_user' ) || current_user_can( 'wppa_settings' ) ) ) {
|
32 |
+
|
33 |
+
// File
|
34 |
+
if ( isset( $_POST['wppa-watermark-file'] ) ) {
|
35 |
+
|
36 |
+
// Sanitize input
|
37 |
+
$watermark_file = $_POST['wppa-watermark-file'];
|
38 |
+
if ( stripos( $watermark_file, '.png' ) !== false ) {
|
39 |
+
$watermark_file = sanitize_file_name( $watermark_file );
|
40 |
+
}
|
41 |
+
else {
|
42 |
+
if ( ! in_array( $watermark_file, array( '--- none ---', '---name---', '---filename---', '---description---', '---predef---' ) ) ) {
|
43 |
+
$watermark_file = 'nil';
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
// Update setting
|
48 |
+
update_option( 'wppa_watermark_file_'.$user, $watermark_file );
|
49 |
+
}
|
50 |
+
|
51 |
+
// Position
|
52 |
+
if ( isset( $_POST['wppa-watermark-pos'] ) ) {
|
53 |
+
|
54 |
+
// Sanitize input
|
55 |
+
$watermark_pos = $_POST['wppa-watermark-pos'];
|
56 |
+
if ( ! in_array( $watermark_pos, array( 'toplft', 'topcen', 'toprht', 'cenlft', 'cencen', 'cenrht', 'botlft', 'botcen', 'botrht' ) ) ) {
|
57 |
+
$watermark_pos = 'nil';
|
58 |
+
}
|
59 |
+
|
60 |
+
// Update setting
|
61 |
+
update_option( 'wppa_watermark_pos_'.$user, $watermark_pos );
|
62 |
+
}
|
63 |
}
|
64 |
|
65 |
// If from album admin set the last album
|
66 |
+
if ( isset( $_REQUEST['wppa-set-album'] ) ) {
|
67 |
+
wppa_set_last_album( strval( intval( $_REQUEST['wppa-set-album'] ) ) );
|
68 |
+
}
|
69 |
|
70 |
// Do the upload if requested
|
71 |
// From BOX A
|
75 |
if ( isset( $_POST['wppa-go-edit-multiple'] ) ) {
|
76 |
if ( current_user_can( 'wppa_admin' ) ) {
|
77 |
wppa_ok_message( __( 'Connecting to edit album...' , 'wp-photo-album-plus' ) ); ?>
|
78 |
+
<script type="text/javascript">document.location = '<?php echo( wppa_dbg_url( get_admin_url().'admin.php?page=wppa_admin_menu&tab=edit&edit_id='.$upload_album, 'js' ) ) ?>';</script>
|
79 |
<?php }
|
80 |
else {
|
81 |
wppa_ok_message( __( 'Connecting to edit photos...' , 'wp-photo-album-plus' ) ); ?>
|
90 |
if ( isset( $_POST['wppa-go-edit-single'] ) ) {
|
91 |
if ( current_user_can( 'wppa_admin' ) ) {
|
92 |
wppa_ok_message( __( 'Connecting to edit album...' , 'wp-photo-album-plus' ) ); ?>
|
93 |
+
<script type="text/javascript">document.location = '<?php echo( wppa_dbg_url( get_admin_url().'admin.php?page=wppa_admin_menu&tab=edit&edit_id='.$upload_album, 'js' ) ) ?>';</script>
|
94 |
<?php }
|
95 |
else {
|
96 |
wppa_ok_message( __( 'Connecting to edit photos...' , 'wp-photo-album-plus' ) ); ?>
|
112 |
// sanitize system again
|
113 |
wppa_sanitize_files();
|
114 |
|
|
|
115 |
|
116 |
+
// Open the form
|
117 |
+
echo
|
118 |
+
'<div class="wrap">' .
|
119 |
+
'<h2>' . __( 'Upload Photos', 'wp-photo-album-plus' ) . '</h2>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
+
// Get some req'd data
|
122 |
$max_files = ini_get( 'max_file_uploads' );
|
123 |
$max_files_txt = $max_files;
|
124 |
if ( $max_files < '1' ) {
|
127 |
}
|
128 |
$max_size = ini_get( 'upload_max_filesize' );
|
129 |
$max_time = ini_get( 'max_input_time' );
|
130 |
+
if ( $max_time < '1' ) $max_time = __( 'unknown', 'wp-photo-album-plus' );
|
131 |
+
|
132 |
+
// check if albums exist before allowing upload
|
133 |
+
if ( ! wppa_has_albums() ) {
|
134 |
+
$url = wppa_dbg_url( get_admin_url().'admin.php?page=wppa_admin_menu' );
|
135 |
+
echo
|
136 |
+
'<p>' .
|
137 |
+
__( 'No albums exist. You must' , 'wp-photo-album-plus') .
|
138 |
+
' <a href="' . $url . '" >' .
|
139 |
+
__( 'create one' , 'wp-photo-album-plus') .
|
140 |
+
'</a> ' .
|
141 |
+
__( 'before you can upload your photos.', 'wp-photo-album-plus' ) .
|
142 |
+
'</p>' . '</div>';
|
143 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
}
|
145 |
|
146 |
+
// Upload One only configured and not administrator or super user?
|
147 |
+
if ( wppa_switch( 'upload_one_only' ) && ! wppa_user_is( 'administrator' ) ) {
|
148 |
+
|
149 |
+
// One only
|
150 |
+
echo
|
151 |
+
'<div style="border:1px solid #ccc; padding:10px; margin-bottom:10px; width: 600px;">' .
|
152 |
+
'<h3 style="margin-top:0px;">' . __( 'Upload a single photo' , 'wp-photo-album-plus' ) . '</h3>' .
|
153 |
+
'<form enctype="multipart/form-data" action="' . wppa_dbg_url( get_admin_url() . 'admin.php?page=wppa_upload_photos' ) . '" method="post">' .
|
154 |
+
wp_nonce_field( '$wppa_nonce', WPPA_NONCE ) .
|
155 |
+
'<input id="my_files" type="file" name="my_files[]" />' .
|
156 |
+
'<p>' .
|
157 |
+
'<label for="wppa-album">' .
|
158 |
+
__( 'Album:' , 'wp-photo-album-plus') .
|
159 |
+
'</label>' .
|
160 |
+
'<select name="wppa-album" id="wppa-album-s" >' .
|
161 |
+
wppa_album_select_a( array( 'path' => wppa_switch( 'hier_albsel' ), 'addpleaseselect' => true, 'checkowner' => true, 'checkupload' => true ) ) .
|
162 |
+
'</select>' .
|
163 |
+
'</p>';
|
164 |
+
if ( wppa_switch( 'watermark_on' ) && ( wppa_switch( 'watermark_user' ) || current_user_can( 'wppa_settings' ) ) ) {
|
165 |
+
echo
|
166 |
+
'<p>' .
|
167 |
+
__( 'Apply watermark file:' , 'wp-photo-album-plus' ) .
|
168 |
+
'<select name="wppa-watermark-file" id="wppa-watermark-file" >' .
|
169 |
+
wppa_watermark_file_select() .
|
170 |
+
'</select>' .
|
171 |
+
__( 'Position:' , 'wp-photo-album-plus' ) .
|
172 |
+
'<select name="wppa-watermark-pos" id="wppa-watermark-pos" >' .
|
173 |
+
wppa_watermark_pos_select() .
|
174 |
+
'</select>' .
|
175 |
+
'</p>';
|
176 |
+
}
|
177 |
+
echo
|
178 |
+
'<input' .
|
179 |
+
' type="submit" class="button-primary"' .
|
180 |
+
' name="wppa-upload-multiple"' .
|
181 |
+
' value="' . __( 'Upload Photo' , 'wp-photo-album-plus') . '"' .
|
182 |
+
' onclick="if ( document.getElementById( \'wppa-album-s\' ).value == 0 ) { alert( \'' . __( 'Please select an album' , 'wp-photo-album-plus' ) . '\' ); return false; }"' .
|
183 |
+
' />' .
|
184 |
+
'<input type="checkbox"' .
|
185 |
+
' id="wppa-go-edit-multiple"' .
|
186 |
+
' name="wppa-go-edit-multiple"' .
|
187 |
+
' style="display:none"' .
|
188 |
+
' checked="checked"' .
|
189 |
+
' />' .
|
190 |
+
'</form>' .
|
191 |
+
'</div>';
|
192 |
+
}
|
193 |
+
|
194 |
+
// Upload multiple allowed
|
195 |
else {
|
|
|
|
|
|
|
|
|
|
|
196 |
|
197 |
+
// The information box
|
198 |
+
echo
|
199 |
+
'<div' .
|
200 |
+
' style="' .
|
201 |
+
'border:1px solid #ccc;' .
|
202 |
+
'padding:10px;' .
|
203 |
+
'margin-bottom:10px;' .
|
204 |
+
'width:600px;' .
|
205 |
+
'background-color:#fffbcc;' .
|
206 |
+
'border-color:#e6db55;' .
|
207 |
+
'"' .
|
208 |
+
' >' .
|
209 |
+
sprintf( __( '<b>Notice:</b> your server allows you to upload <b>%s</b> files of maximum total <b>%s</b> bytes and allows <b>%s</b> seconds to complete.' , 'wp-photo-album-plus' ), $max_files_txt, $max_size, $max_time ) .
|
210 |
+
__( 'If your request exceeds these limitations, it will fail, probably without an errormessage.' , 'wp-photo-album-plus' ) .
|
211 |
+
__( 'Additionally your hosting provider may have set other limitations on uploading files.' , 'wp-photo-album-plus' ) .
|
212 |
+
'<br />' .
|
213 |
+
wppa_check_memory_limit() .
|
214 |
+
'</div>';
|
215 |
+
|
216 |
+
// Box A: Upload Multple photos
|
217 |
+
echo
|
218 |
+
'<div' .
|
219 |
+
' style="' .
|
220 |
+
'border:1px solid #ccc;' .
|
221 |
+
'padding:10px;' .
|
222 |
+
'margin-bottom:10px;' .
|
223 |
+
'width: 600px;' .
|
224 |
+
'"' .
|
225 |
+
' >' .
|
226 |
+
'<h3 style="margin-top:0px;">' .
|
227 |
+
__( 'Box A:' , 'wp-photo-album-plus' ) . ' ' . __( 'Multiple Photos in one selection' , 'wp-photo-album-plus' ) .
|
228 |
+
'</h3>' .
|
229 |
+
sprintf( __( 'You can select up to %s photos in one selection and upload them.' , 'wp-photo-album-plus' ), $max_files_txt ) .
|
230 |
+
'<br />' .
|
231 |
+
'<small style="color:blue" >' .
|
232 |
+
__( 'You need a modern browser that supports HTML-5 to select multiple files' , 'wp-photo-album-plus') .
|
233 |
+
'</small>' .
|
234 |
+
'<form' .
|
235 |
+
' enctype="multipart/form-data"' .
|
236 |
+
' action="' . wppa_dbg_url( get_admin_url() . 'admin.php?page=wppa_upload_photos' ) . '"' .
|
237 |
+
' method="post" >' .
|
238 |
+
wp_nonce_field( '$wppa_nonce', WPPA_NONCE, true, false ) .
|
239 |
+
'<input' .
|
240 |
+
' id="my_files"' .
|
241 |
+
' type="file"' .
|
242 |
+
' multiple="multiple"' .
|
243 |
+
' name="my_files[]"' .
|
244 |
+
' onchange="showit()"' .
|
245 |
+
' />' .
|
246 |
+
'<div id="files_list2" >' .
|
247 |
+
'<h3>' .
|
248 |
+
__( 'Selected Files:' , 'wp-photo-album-plus' ) .
|
249 |
+
'</h3>' .
|
250 |
+
'</div>' .
|
251 |
+
'<script type="text/javascript">' .
|
252 |
+
'function showit() {' .
|
253 |
+
'var maxsize = parseInt( \'' . $max_size . '\' ) * 1024 * 1024;' .
|
254 |
+
'var maxcount = parseInt( \'' . $max_files_txt . '\' );' .
|
255 |
+
'var totsize = 0;' .
|
256 |
+
'var files = document.getElementById( \'my_files\' ).files;' .
|
257 |
+
'var tekst = "<h3>' . __( 'Selected Files:' , 'wp-photo-album-plus' ) . '</h3>";' .
|
258 |
+
'tekst += "<table><thead><tr>";' .
|
259 |
+
'tekst += "<td>' . __( 'Name' , 'wp-photo-album-plus' ) . '</td>";' .
|
260 |
+
'tekst += "<td>' . __( 'Size' , 'wp-photo-album-plus' ) . '</td>";' .
|
261 |
+
'tekst += "<td>' . __( 'Type' , 'wp-photo-album-plus' ) . '</td>";' .
|
262 |
+
'tekst += "</tr></thead>";' .
|
263 |
+
'tekst += "<tbody>";' .
|
264 |
+
'tekst += "<tr><td><hr /></td><td><hr /></td><td><hr /></td></tr>";' .
|
265 |
+
'for ( var i=0;i<files.length;i++ ) {' .
|
266 |
+
'tekst += "<tr>";' .
|
267 |
+
'tekst += "<td>" + files[i].name + "</td>";' .
|
268 |
+
'tekst += "<td>" + files[i].size + "</td>";' .
|
269 |
+
'totsize += files[i].size;' .
|
270 |
+
'tekst += "<td>" + files[i].type + "</td>";' .
|
271 |
+
'tekst += "</tr>";' .
|
272 |
+
'}' .
|
273 |
+
'tekst += "<tr><td><hr /></td><td><hr /></td><td><hr /></td></tr>";' .
|
274 |
+
'var style1 = "";' .
|
275 |
+
'var style2 = "";' .
|
276 |
+
'var style3 = "";' .
|
277 |
+
'var warn1 = "";' .
|
278 |
+
'var warn2 = "";' .
|
279 |
+
'var warn3 = "";' .
|
280 |
+
'if ( maxcount > 0 && files.length > maxcount ) {' .
|
281 |
+
'style1 = "color:red";' .
|
282 |
+
'warn1 = "' . __( 'Too many!' , 'wp-photo-album-plus' ) . '";' .
|
283 |
+
'}' .
|
284 |
+
'if ( maxsize > 0 && totsize > maxsize ) {' .
|
285 |
+
'style2 = "color:red";' .
|
286 |
+
'warn2 = "' . __( 'Too big!' , 'wp-photo-album-plus') . '";' .
|
287 |
+
'}' .
|
288 |
+
'if ( warn1 || warn2 ) {' .
|
289 |
+
'style3 = "color:green";' .
|
290 |
+
'warn3 = "' . __( 'Try again!' , 'wp-photo-album-plus' ) . '";' .
|
291 |
+
'}' .
|
292 |
+
'tekst += "<tr><td style="+style1+" >' . __( 'Total' , 'wp-photo-album-plus' ) . ': "+files.length+" "+warn1+"</td><td style="+style2+" >"+totsize+" "+warn2+"</td><td style="+style3+" >"+warn3+"</td></tr>";' .
|
293 |
+
'tekst += "</tbody>";' .
|
294 |
+
'tekst += "</table>";' .
|
295 |
+
'jQuery( "#files_list2" ).html( tekst );' .
|
296 |
+
'}' .
|
297 |
+
'</script>' .
|
298 |
+
'<p>' .
|
299 |
+
'<label for="wppa-album">' . __( 'Album:' , 'wp-photo-album-plus' ) . '</label>' .
|
300 |
+
'<select name="wppa-album" id="wppa-album-s">' .
|
301 |
+
wppa_album_select_a( array( 'path' => wppa_switch( 'hier_albsel' ), 'addpleaseselect' => true, 'checkowner' => true, 'checkupload' => true ) ) .
|
302 |
+
'</select>' .
|
303 |
+
'</p>';
|
304 |
+
|
305 |
+
// Watermark?
|
306 |
+
if ( wppa_switch( 'watermark_on' ) && ( wppa_switch( 'watermark_user' ) || current_user_can( 'wppa_settings' ) ) ) {
|
307 |
+
echo
|
308 |
+
'<p>' .
|
309 |
+
__( 'Apply watermark file:' , 'wp-photo-album-plus' ) .
|
310 |
+
'<select name="wppa-watermark-file" id="wppa-watermark-file" >' .
|
311 |
+
wppa_watermark_file_select() .
|
312 |
+
'</select>' .
|
313 |
+
__( 'Position:' , 'wp-photo-album-plus' ) .
|
314 |
+
'<select name="wppa-watermark-pos" id="wppa-watermark-pos" >' .
|
315 |
+
wppa_watermark_pos_select() .
|
316 |
+
'</select>' .
|
317 |
+
'</p>';
|
318 |
+
}
|
319 |
+
|
320 |
+
// Submit section
|
321 |
+
echo
|
322 |
+
'<input' .
|
323 |
+
' type="submit"' .
|
324 |
+
' class="button-primary"' .
|
325 |
+
' name="wppa-upload-multiple"' .
|
326 |
+
' value="' . __( 'Upload Multiple Photos', 'wp-photo-album-plus' ) . '"' .
|
327 |
+
' onclick="if ( document.getElementById( \'wppa-album-s\' ).value == 0 ) { alert( \'' . __( 'Please select an album' , 'wp-photo-album-plus' ) . '\' ); return false; }"' .
|
328 |
+
' />' .
|
329 |
+
' ' .
|
330 |
+
'<input' .
|
331 |
+
' type="checkbox"' .
|
332 |
+
' id="wppa-go-edit-multiple"' .
|
333 |
+
' name="wppa-go-edit-multiple"' .
|
334 |
+
' onchange="wppaCookieCheckbox( this, \'wppa-go-edit-multiple\' )"' .
|
335 |
+
' />' .
|
336 |
+
'<script type="text/javascript" >' .
|
337 |
+
'if ( wppa_getCookie( \'wppa-go-edit-multiple\' ) == \'on\' ) document.getElementById( \'wppa-go-edit-multiple\' ).checked = \'checked\';' .
|
338 |
+
'</script>';
|
339 |
+
|
340 |
+
if ( current_user_can( 'wppa_admin' ) ) {
|
341 |
+
_e( 'After upload: Go to the <b>Edit Album</b> page.', 'wp-photo-album-plus');
|
342 |
}
|
343 |
else {
|
344 |
+
_e( 'After upload: Go to the <b>Edit Photos</b> page.', 'wp-photo-album-plus');
|
345 |
+
}
|
346 |
+
echo
|
347 |
+
'</form>' .
|
348 |
+
'</div>';
|
349 |
+
// End BOX A
|
350 |
+
|
351 |
+
// Box B: Single photos
|
352 |
+
echo
|
353 |
+
'<div style="border:1px solid #ccc; padding:10px; margin-bottom:10px; width: 600px;" >' .
|
354 |
+
'<h3 style="margin-top:0px;" >' .
|
355 |
+
__( 'Box B:' , 'wp-photo-album-plus') . ' ' . __( 'Single Photos in multiple selections' , 'wp-photo-album-plus') .
|
356 |
+
'</h3>' .
|
357 |
+
sprintf( __( 'You can select up to %s photos one by one and upload them at once.' , 'wp-photo-album-plus'), $max_files_txt ) .
|
358 |
+
'<form' .
|
359 |
+
' enctype="multipart/form-data"' .
|
360 |
+
' action="' . wppa_dbg_url( get_admin_url().'admin.php?page=wppa_upload_photos' ) . '"' .
|
361 |
+
' method="post" ' .
|
362 |
+
' >' .
|
363 |
+
wp_nonce_field( '$wppa_nonce', WPPA_NONCE, true, false ) .
|
364 |
+
'<input' .
|
365 |
+
' id="my_file_element"' .
|
366 |
+
' type="file"' .
|
367 |
+
' name="file_1"' .
|
368 |
+
'/>' .
|
369 |
+
'<div id="files_list">' .
|
370 |
+
'<h3>' . __( 'Selected Files:' , 'wp-photo-album-plus') . '</h3>' .
|
371 |
+
'</div>' .
|
372 |
+
'<p>' .
|
373 |
+
'<label for="wppa-album">' . __( 'Album:' , 'wp-photo-album-plus') . '</label>' .
|
374 |
+
'<select name="wppa-album" id="wppa-album-m">' .
|
375 |
+
wppa_album_select_a( array( 'path' => wppa_switch( 'hier_albsel' ), 'addpleaseselect' => true, 'checkowner' => true, 'checkupload' => true ) ) .
|
376 |
+
'</select>' .
|
377 |
+
'</p>';
|
378 |
+
|
379 |
+
// Watermark?
|
380 |
+
if ( wppa_switch( 'watermark_on' ) && ( wppa_switch( 'watermark_user' ) || current_user_can( 'wppa_settings' ) ) ) {
|
381 |
+
echo
|
382 |
+
'<p>' .
|
383 |
+
__( 'Apply watermark file:' , 'wp-photo-album-plus' ) .
|
384 |
+
'<select name="wppa-watermark-file" id="wppa-watermark-file" >' .
|
385 |
+
wppa_watermark_file_select() .
|
386 |
+
'</select>' .
|
387 |
+
__( 'Position:' , 'wp-photo-album-plus' ) .
|
388 |
+
'<select name="wppa-watermark-pos" id="wppa-watermark-pos" >' .
|
389 |
+
wppa_watermark_pos_select() .
|
390 |
+
'</select>' .
|
391 |
+
'</p>';
|
392 |
+
}
|
393 |
+
|
394 |
+
// Submit section
|
395 |
+
echo
|
396 |
+
'<input' .
|
397 |
+
' type="submit"' .
|
398 |
+
' class="button-primary"' .
|
399 |
+
' name="wppa-upload"' .
|
400 |
+
' value="' . __( 'Upload Single Photos' , 'wp-photo-album-plus') . '"' .
|
401 |
+
' onclick="if ( document.getElementById( \'wppa-album-m\' ).value == 0 ) { alert( \'' . __( 'Please select an album' , 'wp-photo-album-plus' ) . '\' ); return false; }"' .
|
402 |
+
' />' .
|
403 |
+
' ' .
|
404 |
+
'<input' .
|
405 |
+
' type="checkbox"' .
|
406 |
+
' id="wppa-go-edit-single"' .
|
407 |
+
' name="wppa-go-edit-single"' .
|
408 |
+
' onchange="wppaCookieCheckbox( this, \'wppa-go-edit-single\' )" />' .
|
409 |
+
'<script type="text/javascript" >' .
|
410 |
+
'if ( wppa_getCookie( \'wppa-go-edit-single\' ) == \'on\' ) document.getElementById( \'wppa-go-edit-single\' ).checked = \'checked\';' .
|
411 |
+
'</script>';
|
412 |
+
|
413 |
+
if ( current_user_can( 'wppa_admin' ) ) {
|
414 |
+
_e( 'After upload: Go to the <b>Edit Album</b> page.' , 'wp-photo-album-plus');
|
415 |
}
|
416 |
+
else {
|
417 |
+
_e( 'After upload: Go to the <b>Edit Photos</b> page.' , 'wp-photo-album-plus');
|
418 |
+
}
|
419 |
+
echo
|
420 |
+
'</form>' .
|
421 |
+
'<script type="text/javascript">' .
|
422 |
+
'<!-- Create an instance of the multiSelector class, pass it the output target and the max number of files -->' .
|
423 |
+
'var multi_selector = new MultiSelector( document.getElementById( \'files_list\' ), ' . $max_files . ');' .
|
424 |
+
'<!-- Pass in the file element -->' .
|
425 |
+
'multi_selector.addElement( document.getElementById( \'my_file_element\' ) );' .
|
426 |
+
'</script>' .
|
427 |
+
'</div>';
|
428 |
+
// End Box B
|
429 |
+
|
430 |
+
// Box C: Single zips, useless if user can not imort, or when php <50207: no unzip
|
431 |
+
if ( current_user_can( 'wppa_import' ) ) {
|
432 |
+
if ( PHP_VERSION_ID >= 50207 ) {
|
433 |
+
echo
|
434 |
+
'<div style="border:1px solid #ccc; padding:10px; width: 600px;" >' .
|
435 |
+
'<h3 style="margin-top:0px;" >' .
|
436 |
+
__( 'Box C:' , 'wp-photo-album-plus') . ' ' . __( 'Zipped Photos in one selection' , 'wp-photo-album-plus') .
|
437 |
+
'</h3>' .
|
438 |
+
sprintf( __( 'You can upload one zipfile. It will be placed in your personal wppa-depot: <b>.../%s</b><br/>Once uploaded, use <b>Import Photos</b> to unzip the file and place the photos in any album.' , 'wp-photo-album-plus'), WPPA_DEPOT ) .
|
439 |
+
'<form' .
|
440 |
+
' enctype="multipart/form-data"' .
|
441 |
+
' action="' . wppa_dbg_url( get_admin_url() . 'admin.php?page=wppa_upload_photos' ) . '"' .
|
442 |
+
' method="post"' .
|
443 |
+
' >' .
|
444 |
+
wp_nonce_field( '$wppa_nonce', WPPA_NONCE, true, false ) .
|
445 |
+
'<input' .
|
446 |
+
' id="my_zipfile_element"' .
|
447 |
+
' type="file"' .
|
448 |
+
' name="file_zip"' .
|
449 |
+
' />' .
|
450 |
+
'<br/><br/>' .
|
451 |
+
'<input' .
|
452 |
+
' type="submit"' .
|
453 |
+
' class="button-primary"' .
|
454 |
+
' name="wppa-upload-zip"' .
|
455 |
+
' value="' . __( 'Upload Zipped Photos' , 'wp-photo-album-plus') . '"' .
|
456 |
+
' />' .
|
457 |
+
' ' .
|
458 |
+
'<input' .
|
459 |
+
' type="checkbox"' .
|
460 |
+
' id="wppa-go-import"' .
|
461 |
+
' name="wppa-go-import"' .
|
462 |
+
' onchange="wppaCookieCheckbox( this, \'wppa-go-import\' )"' .
|
463 |
+
' />' .
|
464 |
+
'<script type="text/javascript" >' .
|
465 |
+
'if ( wppa_getCookie( \'wppa-go-import\' ) == \'on\' ) document.getElementById( \'wppa-go-import\' ).checked = \'checked\';' .
|
466 |
+
'</script>' .
|
467 |
+
__( 'After upload: Go to the <b>Import Photos</b> page.' , 'wp-photo-album-plus') .
|
468 |
+
'</form>' .
|
469 |
+
'</div>';
|
470 |
}
|
471 |
+
else {
|
472 |
+
echo
|
473 |
+
'<div style="border:1px solid #ccc; padding:10px; width: 600px;">' .
|
474 |
+
'<small>' .
|
475 |
+
__( 'Ask your administrator to upgrade php to version 5.2.7 or later. This will enable you to upload zipped photos.' , 'wp-photo-album-plus') .
|
476 |
+
'</small>' .
|
477 |
+
'</div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
478 |
}
|
|
|
479 |
}
|
480 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
481 |
|
482 |
+
echo
|
483 |
+
'</div>';
|
484 |
}
|
485 |
|
486 |
// Upload multiple photos
|
487 |
function wppa_upload_multiple() {
|
488 |
+
global $wpdb;
|
489 |
+
global $warning_given;
|
490 |
+
global $upload_album;
|
491 |
|
492 |
$warning_given = false;
|
493 |
$uploaded_a_file = false;
|
497 |
if ( is_array( $file['error'] ) ) {
|
498 |
for ( $i = '0'; $i < count( $file['error'] ); $i++ ) {
|
499 |
if ( wppa_is_time_up() ) {
|
500 |
+
wppa_warning_message( sprintf( __( 'Time out. %s photos uploaded in album nr %s.' , 'wp-photo-album-plus'), $count, $upload_album ) );
|
501 |
+
wppa_set_last_album( $upload_album );
|
502 |
return;
|
503 |
}
|
504 |
if ( ! $file['error'][$i] ) {
|
505 |
+
$id = wppa_insert_photo( $file['tmp_name'][$i], $upload_album, $file['name'][$i] );
|
506 |
if ( $id ) {
|
507 |
$uploaded_a_file = true;
|
508 |
$count++;
|
509 |
+
wppa_backend_upload_mail( $id, $upload_album, $file['name'][$i] );
|
510 |
}
|
511 |
else {
|
512 |
wppa_error_message( __( 'Error inserting photo' , 'wp-photo-album-plus') . ' ' . wppa_sanitize_file_name( basename( $file['name'][$i] ) ) . '.' );
|
518 |
}
|
519 |
|
520 |
if ( $uploaded_a_file ) {
|
521 |
+
wppa_update_message( $count.' '.__( 'Photos Uploaded in album nr' , 'wp-photo-album-plus') . ' ' . $upload_album );
|
522 |
+
wppa_set_last_album( $upload_album );
|
523 |
}
|
524 |
}
|
525 |
|
526 |
// Upload single photos
|
527 |
function wppa_upload_photos() {
|
528 |
+
global $wpdb;
|
529 |
+
global $warning_given;
|
530 |
+
global $upload_album;
|
531 |
+
|
532 |
|
533 |
$warning_given = false;
|
534 |
$uploaded_a_file = false;
|
536 |
$count = '0';
|
537 |
foreach ( $_FILES as $file ) {
|
538 |
if ( $file['tmp_name'] != '' ) {
|
539 |
+
$id = wppa_insert_photo( $file['tmp_name'], $upload_album, $file['name'] );
|
|
|
540 |
if ( $id ) {
|
541 |
$uploaded_a_file = true;
|
542 |
$count++;
|
543 |
+
wppa_backend_upload_mail( $id, $upload_album, $file['name'] );
|
544 |
}
|
545 |
else {
|
546 |
wppa_error_message( __( 'Error inserting photo' , 'wp-photo-album-plus') . ' ' . wppa_sanitize_file_name( basename( $file['name'] ) ) . '.' );
|
550 |
}
|
551 |
|
552 |
if ( $uploaded_a_file ) {
|
553 |
+
wppa_update_message( $count.' '.__( 'Photos Uploaded in album nr' , 'wp-photo-album-plus') . ' ' . $upload_album );
|
554 |
+
wppa_set_last_album( $upload_album );
|
555 |
}
|
556 |
}
|
557 |
|
596 |
|
597 |
return $error;
|
598 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wppa-users.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* Contains user and capabilities related routines
|
6 |
-
* Version 6.
|
7 |
*
|
8 |
*/
|
9 |
|
@@ -280,9 +280,6 @@ function wppa_may_user_fe_edit( $id ) {
|
|
280 |
// See if the current user may delete a given photo
|
281 |
function wppa_may_user_fe_delete( $id ) {
|
282 |
|
283 |
-
// If not allowed to edit, also deny deletion
|
284 |
-
// if ( ! wppa_may_user_fe_edit( $id ) ) return false;
|
285 |
-
|
286 |
// Superuser?
|
287 |
if ( wppa_is_user_superuser() ) return true;
|
288 |
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* Contains user and capabilities related routines
|
6 |
+
* Version 6.5.02
|
7 |
*
|
8 |
*/
|
9 |
|
280 |
// See if the current user may delete a given photo
|
281 |
function wppa_may_user_fe_delete( $id ) {
|
282 |
|
|
|
|
|
|
|
283 |
// Superuser?
|
284 |
if ( wppa_is_user_superuser() ) return true;
|
285 |
|
wppa-utils.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* Contains low-level utility routines
|
6 |
-
* Version 6.5.
|
7 |
*
|
8 |
*/
|
9 |
|
@@ -2566,7 +2566,7 @@ function wppa_force_numeric_else( $value, $default ) {
|
|
2566 |
function wppa_sanitize_file_name( $file, $check_length = true ) {
|
2567 |
$temp = explode( '/', $file );
|
2568 |
$cnt = count( $temp );
|
2569 |
-
$temp[$cnt - 1] = sanitize_file_name( $temp[$cnt - 1] );
|
2570 |
$maxlen = wppa_opt( 'max_filename_length' );
|
2571 |
if ( $maxlen && $check_length ) {
|
2572 |
if ( strpos( $temp[$cnt - 1], '.' ) !== false ) {
|
3 |
* Package: wp-photo-album-plus
|
4 |
*
|
5 |
* Contains low-level utility routines
|
6 |
+
* Version 6.5.02
|
7 |
*
|
8 |
*/
|
9 |
|
2566 |
function wppa_sanitize_file_name( $file, $check_length = true ) {
|
2567 |
$temp = explode( '/', $file );
|
2568 |
$cnt = count( $temp );
|
2569 |
+
$temp[$cnt - 1] = strip_tags( stripslashes( $temp[$cnt - 1] ) );//sanitize_file_name( $temp[$cnt - 1] );
|
2570 |
$maxlen = wppa_opt( 'max_filename_length' );
|
2571 |
if ( $maxlen && $check_length ) {
|
2572 |
if ( strpos( $temp[$cnt - 1], '.' ) !== 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.5.
|
6 |
* Author: J.N. Breetvelt a.k.a. OpaJaap
|
7 |
* Author URI: http://wppa.opajaap.nl/
|
8 |
* Plugin URI: http://wordpress.org/extend/plugins/wp-photo-album-plus/
|
@@ -22,8 +22,8 @@ global $wpdb;
|
|
22 |
global $wp_version;
|
23 |
|
24 |
/* WPPA GLOBALS */
|
25 |
-
global $wppa_revno; $wppa_revno = '
|
26 |
-
global $wppa_api_version; $wppa_api_version = '6-5-
|
27 |
|
28 |
/* start timers */
|
29 |
global $wppa_starttime; $wppa_starttime = microtime(true);
|
@@ -91,7 +91,7 @@ if ( defined( 'WP_CONTENT_DIR' ) ) {
|
|
91 |
define( 'WPPA_CONTENT_PATH', wppa_flips( WP_CONTENT_DIR ) );
|
92 |
}
|
93 |
|
94 |
-
// In the normal case i use content_url() with the site_url() part replaced by WPPA_ABSPATH,
|
95 |
// i.e. ABSPATH with the slashes in the right direction (in case of windows server)
|
96 |
else {
|
97 |
define( 'WPPA_CONTENT_PATH',
|
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.5.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/
|
22 |
global $wp_version;
|
23 |
|
24 |
/* WPPA GLOBALS */
|
25 |
+
global $wppa_revno; $wppa_revno = '6502'; // WPPA db version
|
26 |
+
global $wppa_api_version; $wppa_api_version = '6-5-02-006'; // WPPA software version
|
27 |
|
28 |
/* start timers */
|
29 |
global $wppa_starttime; $wppa_starttime = microtime(true);
|
91 |
define( 'WPPA_CONTENT_PATH', wppa_flips( WP_CONTENT_DIR ) );
|
92 |
}
|
93 |
|
94 |
+
// In the normal case i use content_url() with the site_url() part replaced by WPPA_ABSPATH,
|
95 |
// i.e. ABSPATH with the slashes in the right direction (in case of windows server)
|
96 |
else {
|
97 |
define( 'WPPA_CONTENT_PATH',
|