Plugin Directory

Changeset 1141552


Ignore:
Timestamp:
04/22/2015 01:08:55 AM (11 years ago)
Author:
norbusan
Message:

new version 2.29

Location:
piwigopress/trunk
Files:
3 added
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • piwigopress/trunk/Makefile

    r1136944 r1141552  
    3535    NV2=`grep "^Version:" piwigopress.php | awk -F' ' '{print $$NF}'` ;         \
    3636    NV3=`grep 'define(.PWGP_VERSION' piwigopress.php | sed -e "s/^.*PWGP_VERSION'\s*,\s*'//" -e "s/'.*$$//" -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\)\./\1/'` ;   \
    37     NV4=`grep 'define(.PWGP_VERSION' piwigopress_admin.php | sed -e "s/^.*PWGP_VERSION'\s*,\s*'//" -e "s/'.*$$//" -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\)\./\1/'` ;     \
    38     echo "V1 = $$NV1 (readme.txt)\nV2 = $$NV2 (piwigopress.php header)\nV3 = $$NV3 (piwigopress.php variable)\nV4 = $$NV4 (piwigopress_admin.php variable)"; \
    39     if [ "$$NV1" != "$$NV2" -o "$$NV1" != "$$NV3" -o "$$NV1" != "$$NV4" ] ; then false ; else true ; fi
     37    echo "V1 = $$NV1 (readme.txt)\nV2 = $$NV2 (piwigopress.php header)\nV3 = $$NV3 (piwigopress.php variable)"; \
     38    if [ "$$NV1" != "$$NV2" -o "$$NV1" != "$$NV3" ] ; then false ; else true ; fi
    4039   
  • piwigopress/trunk/PiwigoPress_get.php

    r1029167 r1141552  
    22if (defined('PHPWG_ROOT_PATH')) return; /* Avoid direct usage under Piwigo */
    33if (!defined('PWGP_NAME')) return; /* Avoid unpredicted access */
    4 //error_reporting(E_ALL);
    5 if (!isset($pwg_mode)) $pwg_mode = ''; // Remind which process is working well
    6 $pwg_prev_host = ''; // Remind last requested gallery
    74
    85function pwg_ret_protocol() {
     
    1815}
    1916
    20 function pwg_get_contents($url, $mode='', $timeout=5) {
    21 
    22     global $pwg_mode, $pwg_prev_host;
     17function pwg_get_contents($url) {
    2318
    2419    # support same-host piwigo
     
    3328      $fullurl = $url;
    3429    }
    35     $host = (strtolower(substr($fullurl,0,7)) == 'http://') ? substr($fullurl,7) : $fullurl;
    36     $host = (strtolower(substr($host,0,8)) == 'https://') ? substr($host,8) : $host;
    37     $doc = substr($host, strpos($host, '/'));
    38     $host = substr($host, 0, strpos($host, '/'));
    39     if ($pwg_prev_host != $host) $pwg_mode = ''; // What was possible with one website could be different with another
    40     $pwg_prev_host = $host;
    41     if ($mode == '') $mode = $pwg_mode; // Can be forced by the requester
    42     // $mode = 'fs'; // Test purpose only =>  '' all, 'fs' fsockopen, 'ch' cURL
    43     //echo "\n      <!-- *** PiwigoPress Getmode = " . $mode . " *** -->\n";
    44 // 1 - The simplest solution: file_get_contents
    45 // Contraint: php.ini
    46 //      ; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
    47 //      allow_url_fopen = On
    48     if ( $mode == '' and true === (bool) ini_get('allow_url_fopen') ) {
    49             $value = @file_get_contents($fullurl);
    50             if ( $value !== false) return $value;
    51     }
    52     if ( $mode == '' ) $mode = 'fs';
    53 // 2 - Often accepted access: fsockopen
    54     if ($mode == 'fs') {
    55         $fs = @fsockopen($host, 80, $errno, $errstr, $timeout);
    56         if ( $fs !== false ) {
    57             fwrite($fs, 'GET ' . $doc . " HTTP/1.1\r\n");
    58             fwrite($fs, 'Host: ' . $host . "\r\n");
    59             fwrite($fs, "Connection: Close\r\n\r\n");
    60             stream_set_blocking($fs, TRUE);
    61             stream_set_timeout($fs,$timeout); // Again the $timeout on the get
    62             $info = stream_get_meta_data($fs);
    63             $value = '';
    64             while ((!feof($fs)) && (!$info['timed_out'])) {
    65                             $value .= fgets($fs, 4096);
    66                             $info = stream_get_meta_data($fs);
    67                             flush();
    68             }
    69             $value = substr($value, strpos($value,'a:2:{s:4:"stat";'));
    70             $pwg_mode = 'fs';
    71             if ( $info['timed_out'] === false ) return $value;
    72         }
    73     }
    74 // 3 - Sometime another solution: curl_exec
    75 // See http://fr2.php.net/manual/en/curl.installation.php
    76     if ($mode !== 'Err' and function_exists('curl_init')) {
    77         $ch = @curl_init();
    78         @curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
    79         @curl_setopt($ch, CURLOPT_URL, $fullurl);
    80         @curl_setopt($ch, CURLOPT_HEADER, 1);
    81         @curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0');
    82         @curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    83         @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    84         $value = @curl_exec($ch);
    85         $header_length = @curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    86         $status = @curl_getinfo($ch, CURLINFO_HTTP_CODE);
    87         @curl_close($value);
    88         if ($value !== false and $status >= 200 and $status < 400) {
    89                 $value = substr($value, $header_length);
    90                 $pwg_mode = 'ch';
    91                 return $value;
    92         }
    93     }
    94     // No other solutions
    95     $return["stat"] = 'failed';
    96     if ($mode !== 'Err') {
    97         echo "\n            <!== PiwigoPress_get: failed on file_get, fsockopen and cURL processes "
    98             . "- No solution available on this website with its current configuration ==>\n";
    99     }
    100     $pwg_mode = 'Err';
    101     return serialize($return);
     30
     31    return wp_remote_get($fullurl);
    10232}
    103 ?>
     33
  • piwigopress/trunk/PiwigoPress_options.php

    r1136944 r1141552  
    217217    </tr></table>
    218218    </div>';
    219 ?>
     219
  • piwigopress/trunk/PiwigoPress_widget.php

    r1106463 r1141552  
    22if (defined('PHPWG_ROOT_PATH')) return; /* Avoid direct usage under Piwigo */
    33if (!defined('PWGP_NAME')) return; /* Avoid unpredicted access */
     4require_once('PiwigoPress_get.php');
    45
    56global $wpdb; /* Need for recent thumbnail access */
     
    5354echo $before_widget;
    5455echo $title;
    55 if (!function_exists('pwg_get_contents')) include 'PiwigoPress_get.php';
    5656
    5757if ($thumbnail) {
     
    6060            . 'ws.php?method=pwg.categories.getImages&format=php'
    6161            . $options . '&recursive=true&order=random&f_with_thumbnail=true');
    62     $thumbc = unserialize($response);
    63     if ($thumbc["stat"] == 'ok') {
     62    if (!is_wp_error($response)) {
     63        $thumbc = unserialize($response['body']);
    6464        /* fix from http://wordpress.org/support/topic/piwigo-260-and-piwigopress-223
    6565        ** for piwigo 2.6
     
    121121    $response = pwg_get_contents( $piwigo_url
    122122            . 'ws.php?method=pwg.categories.getList&format=php&public=true');
    123     $cats = unserialize($response);
    124     if ($cats["stat"] == 'ok') {
     123    if (!is_wp_error($response)) {
     124        $cats = unserialize($response['body']);
    125125        echo '<ul style="clear: both;"><li>' . __('Pictures categories','pwg') . '<ul>';
    126126        foreach ($cats["result"]["categories"] as $cat) {
     
    166166echo $after_widget;
    167167
    168 ?>
     168
  • piwigopress/trunk/js/piwigopress_adm.js

    r1136944 r1141552  
    7474          var url = $("#PWGP_finder").val(); // New URL to load
    7575          $('#PWGP_Load_Active').show(); // Busy icon is on
     76
    7677          $.ajax({
    77             url: '../wp-content/plugins/piwigopress/thumbnails_reloader.php?&loadcats=1&url='+url,
    78         cache: false,
     78            url: PwgpAjax.ajaxUrl,
     79            method: 'POST',
     80            data: {
     81              action: 'pwgp-categories',
     82              nonce: PwgpAjax.nonce,
     83              url: url
     84            },
     85            dataType: "json",
    7986            success: function(data) {
    8087          // console.log('got back: ' + data);
    81               var data = jQuery.parseJSON(data);
    8288              var $dropper = $('#PWGP_catscroll');
    8389              // remove all but the 0 value which is translated!
     
    9298                  $dropper.append('<option value='+id+'>'+nm+'</option>');
    9399                }
    94         $dropper.select();
    95         $dropper.focus();
     100                $dropper.select();
     101                $dropper.focus();
    96102              }
    97103            },
     
    118124          var catid = $('#PWGP_catscroll').val();
    119125          // console.log('catid='+catid);
    120           if (!catid) { catid = 0 } ;
    121           $gallery.load('../wp-content/plugins/piwigopress/thumbnails_reloader.php?&url='+url+'&category='+catid, function() {
     126          if (!catid) { catid = 0; }
     127
     128          $.post(PwgpAjax.ajaxUrl, {
     129            action: 'pwgp-thumbnails',
     130            nonce: PwgpAjax.nonce,
     131            url: url,
     132            category: catid
     133          }, function(response) {
     134            $gallery.empty().append(response);
    122135            $("#PWGP_more").show().unbind().click(function () {
    123136              Get_more();
     
    142155              $('#PWGP_Load_Active').show();
    143156              catid = $('#PWGP_catscroll').val();
    144               if (!catid) { catid = 0 } ;
     157              if (!catid) { catid = 0; }
    145158              // here we need to add the category id if set to the argument list, for now only category
    146159              // and recursive is also necessary!!
    147160              $.ajax({
    148                 url: '../wp-content/plugins/piwigopress/thumbnails_reloader.php?&loaded='+loaded+'&url='+url+'&category='+catid+'&recursive=1',
    149                 cache: false,
     161                url: PwgpAjax.ajaxUrl,
     162                data: {
     163                  action: 'pwgp-thumbnails',
     164                  nonce: PwgpAjax.nonce,
     165                  url: url,
     166                  loaded: loaded,
     167                  category: catid,
     168                  recursive: 1
     169                },
     170                method: 'post',
    150171                success: function(html){
    151                 Drag_n_Drop(html);
     172                  Drag_n_Drop(html);
    152173                }
    153174              });
     
    157178              if (loaded > 99) added = 100; // More we load larger next load might be
    158179              loaded += added;
    159             };
     180            }
    160181            function Drag_n_Drop(thumbs) {
    161182              $($gallery).append(thumbs);
     
    177198              if ($('li:visible', $gallery).size() > 0) $("#PWGP_hide").show();
    178199              $('#PWGP_Load_Active').hide();
    179             };
     200            }
    180201            function insertImage( $item ) {
    181202              $item.fadeOut(function() {
     
    225246              $("a#PWGP_Gen").show();
    226247              $("a#PWGP_rst").show();
    227             };
     248            }
    228249          }); // End of Loaded
    229250        }); 
  • piwigopress/trunk/js/piwigopress_adm.min.js

    r1136944 r1141552  
    1 (function(a){a.fn.extend({insertAtCaret:function(b){return this.each(function(e){if(document.selection){this.focus();sel=document.selection.createRange();sel.text=b;this.focus()}else{if(this.selectionStart||this.selectionStart=="0"){var d=this.selectionStart;var c=this.selectionEnd;var f=this.scrollTop;this.value=this.value.substring(0,d)+b+this.value.substring(c,this.value.length);this.focus();this.selectionStart=d+b.length;this.selectionEnd=d+b.length;this.scrollTop=f}else{this.value+=b;this.focus()}}})}});a(document).ready(function(){var b=true;a("a#PWGP_button").unbind().click(function(){if(b){if(a("#dashboard-widgets-wrap").size()==0){var c="#poststuff"}else{var c="#dashboard-widgets-wrap"}if(a("#PWGP_shortcoder").size()==0){var d=a("#PWGP_Gal_finder").html();a(c).before('<div id="PWGP_shortcoder" />');a("#PWGP_shortcoder").html(d);a("#PWGP_Gal_finder").remove()}else{a("#PWGP_shortcoder").show()}a("#PWGP_catscroll").on("focus",function(){current_catid=this.value}).change(function(){if(current_catid!=this.value){a("#PWGP_more").hide();a("#PWGP_hide").hide();a("#PWGP_show").hide();a("#PWGP_show_stats").hide()}});a("#PWGP_finder").focus(function(){current_url=this.value}).change(function(){if(current_url!=this.value){a("#PWGP_more").hide();a("#PWGP_hide").hide();a("#PWGP_show").hide();a("#PWGP_show_stats").hide();a("#PWGP_catscroll").hide();a("#PWGP_loadcat").show();a("#PWGP_catscroll").val(0)}});a("#PWGP_loadcat").unbind().click(function(){var e=a("#PWGP_finder").val();a("#PWGP_Load_Active").show();a.ajax({url:"../wp-content/plugins/piwigopress/thumbnails_reloader.php?&loadcats=1&url="+e,cache:false,success:function(j){var j=jQuery.parseJSON(j);var h=a("#PWGP_catscroll");a('#PWGP_catscroll option[value!="0"]').remove();if(j.stat=="ok"){var g=j.result.categories;for(var l=0;l<g.length;l++){var f=g[l].name;var k=g[l].id;h.append("<option value="+k+">"+f+"</option>")}h.select();h.focus()}},error:function(g,h,f){console.log("cannot load list of piwigo categories: "+h+" "+f+" "+g.responseText)}});a("#PWGP_Load_Active").hide();a("#PWGP_loadcat").hide();a("#PWGP_catscroll").show()});a("#PWGP_load").unbind().click(function(){var j=a("#PWGP_finder").val(),h=5,f=a("#PWGP_dragger"),k=a("#PWGP_dragger li"),e=a("#PWGP_dropping");a(".PWGP_system").show(500);a("#PWGP_Load_Active").show();var g=a("#PWGP_catscroll").val();if(!g){g=0}f.load("../wp-content/plugins/piwigopress/thumbnails_reloader.php?&url="+j+"&category="+g,function(){a("#PWGP_more").show().unbind().click(function(){l()});a("#PWGP_hide").show().unbind().click(function(){var o=Math.max(1,Math.floor(a("li:visible",f).size()/2));for(i=0;i<o;i++){f.find("li:visible").first().hide()}if(a("li:visible",f).size()==0){a("#PWGP_hide").hide()}else{a("#PWGP_show").show().unbind().click(function(){a("li:hidden",f).show();a("#PWGP_show").hide()})}});n();a("#PWGP_Load_Active").hide();function l(){a("#PWGP_Load_Active").show();g=a("#PWGP_catscroll").val();if(!g){g=0}a.ajax({url:"../wp-content/plugins/piwigopress/thumbnails_reloader.php?&loaded="+h+"&url="+j+"&category="+g+"&recursive=1",cache:false,success:function(p){n(p)}});var o=5;if(h>9){o=10}if(h>49){o=50}if(h>99){o=100}h+=o}function n(o){a(f).append(o);var q=(a("#PWGP_dragger img").first().height())+20;f.height(q);e.height(q+25).css("min-height",q+25);a("#PWGP_dropping ul").height(q);a("li",f).draggable({revert:true,cursor:"move",zIndex:50});var p=a("li",e).size()+a("li",f).size();a("#PWGP_show_stats").show().find("#PWGP_stats").text(" "+p+" / "+h);e.droppable({activeClass:"ui-state-highlight",drop:function(r,s){m(s.draggable)}});if(a("li:visible",f).size()>0){a("#PWGP_hide").show()}a("#PWGP_Load_Active").hide()}function m(o){o.fadeOut(function(){var p=a("ul",e);o.appendTo(p).fadeIn();a("a#PWGP_Gen").unbind().click(function(){var q=window.tinyMCE.majorVersion;a("img",e).each(function(){var s=a(this).attr("title").split("]");var r=s[0];var w=a("#thumbnail_size input[type=radio][name=thumbnail_size]:checked").attr("value");if(w!=="la"){r+=" size='"+w+"'"}a("input#desc_check[name=desc_check]").attr("value",0);$hdesc=0+a("input#desc_check[name=desc_check]:checked").attr("value",1).attr("value");if($hdesc==1){r+=" desc=1"}var u=a("#photo_class").val();if(u!=""){r+=" class='"+u+"'"}var t=a("#link_type input[type=radio][name=link_type]:checked").attr("value");if(t!="picture"){r+=" lnktype='"+t+"'"}var v=a("#open_type input[type=radio][name=open_type]:checked").attr("value");if(v!=""){r+=" opntype='"+v+"'"}var r="\t"+r+"] \n\r";a("#content").insertAtCaret(r);if(q>="4"){tinyMCE.execCommand("mceInsertContent",false,r)}else{tinyMCE.execInstanceCommand("content","mceInsertContent",false,r)}})});a("a#PWGP_rst").unbind().click(function(){a("li",e).appendTo(f);a("a#PWGP_Gen").hide();a("a#PWGP_rst").hide();a("#PWGP_show_stats").show().find("#PWGP_stats").text(" "+a("li",f).size()+" / "+h)})});a("a#PWGP_Gen").show();a("a#PWGP_rst").show()}})});b=false}else{a("div#PWGP_shortcoder").hide();b=true}})})}(jQuery));
     1(function(a){a.fn.extend({insertAtCaret:function(b){return this.each(function(e){if(document.selection){this.focus();sel=document.selection.createRange();sel.text=b;this.focus()}else{if(this.selectionStart||this.selectionStart=="0"){var d=this.selectionStart;var c=this.selectionEnd;var f=this.scrollTop;this.value=this.value.substring(0,d)+b+this.value.substring(c,this.value.length);this.focus();this.selectionStart=d+b.length;this.selectionEnd=d+b.length;this.scrollTop=f}else{this.value+=b;this.focus()}}})}});a(document).ready(function(){var b=true;a("a#PWGP_button").unbind().click(function(){if(b){if(a("#dashboard-widgets-wrap").size()==0){var c="#poststuff"}else{var c="#dashboard-widgets-wrap"}if(a("#PWGP_shortcoder").size()==0){var d=a("#PWGP_Gal_finder").html();a(c).before('<div id="PWGP_shortcoder" />');a("#PWGP_shortcoder").html(d);a("#PWGP_Gal_finder").remove()}else{a("#PWGP_shortcoder").show()}a("#PWGP_catscroll").on("focus",function(){current_catid=this.value}).change(function(){if(current_catid!=this.value){a("#PWGP_more").hide();a("#PWGP_hide").hide();a("#PWGP_show").hide();a("#PWGP_show_stats").hide()}});a("#PWGP_finder").focus(function(){current_url=this.value}).change(function(){if(current_url!=this.value){a("#PWGP_more").hide();a("#PWGP_hide").hide();a("#PWGP_show").hide();a("#PWGP_show_stats").hide();a("#PWGP_catscroll").hide();a("#PWGP_loadcat").show();a("#PWGP_catscroll").val(0)}});a("#PWGP_loadcat").unbind().click(function(){var e=a("#PWGP_finder").val();a("#PWGP_Load_Active").show();a.ajax({url:PwgpAjax.ajaxUrl,method:"POST",data:{action:"pwgp-categories",nonce:PwgpAjax.nonce,url:e},dataType:"json",success:function(j){var h=a("#PWGP_catscroll");a('#PWGP_catscroll option[value!="0"]').remove();if(j.stat=="ok"){var g=j.result.categories;for(var l=0;l<g.length;l++){var f=g[l].name;var k=g[l].id;h.append("<option value="+k+">"+f+"</option>")}h.select();h.focus()}},error:function(g,h,f){console.log("cannot load list of piwigo categories: "+h+" "+f+" "+g.responseText)}});a("#PWGP_Load_Active").hide();a("#PWGP_loadcat").hide();a("#PWGP_catscroll").show()});a("#PWGP_load").unbind().click(function(){var j=a("#PWGP_finder").val(),h=5,f=a("#PWGP_dragger"),k=a("#PWGP_dragger li"),e=a("#PWGP_dropping");a(".PWGP_system").show(500);a("#PWGP_Load_Active").show();var g=a("#PWGP_catscroll").val();if(!g){g=0}a.post(PwgpAjax.ajaxUrl,{action:"pwgp-thumbnails",nonce:PwgpAjax.nonce,url:j,category:g},function(l){f.empty().append(l);a("#PWGP_more").show().unbind().click(function(){m()});a("#PWGP_hide").show().unbind().click(function(){var p=Math.max(1,Math.floor(a("li:visible",f).size()/2));for(i=0;i<p;i++){f.find("li:visible").first().hide()}if(a("li:visible",f).size()==0){a("#PWGP_hide").hide()}else{a("#PWGP_show").show().unbind().click(function(){a("li:hidden",f).show();a("#PWGP_show").hide()})}});o();a("#PWGP_Load_Active").hide();function m(){a("#PWGP_Load_Active").show();g=a("#PWGP_catscroll").val();if(!g){g=0}a.ajax({url:PwgpAjax.ajaxUrl,data:{action:"pwgp-thumbnails",nonce:PwgpAjax.nonce,url:j,loaded:h,category:g,recursive:1},method:"post",success:function(q){o(q)}});var p=5;if(h>9){p=10}if(h>49){p=50}if(h>99){p=100}h+=p}function o(p){a(f).append(p);var r=(a("#PWGP_dragger img").first().height())+20;f.height(r);e.height(r+25).css("min-height",r+25);a("#PWGP_dropping ul").height(r);a("li",f).draggable({revert:true,cursor:"move",zIndex:50});var q=a("li",e).size()+a("li",f).size();a("#PWGP_show_stats").show().find("#PWGP_stats").text(" "+q+" / "+h);e.droppable({activeClass:"ui-state-highlight",drop:function(s,t){n(t.draggable)}});if(a("li:visible",f).size()>0){a("#PWGP_hide").show()}a("#PWGP_Load_Active").hide()}function n(p){p.fadeOut(function(){var q=a("ul",e);p.appendTo(q).fadeIn();a("a#PWGP_Gen").unbind().click(function(){var r=window.tinyMCE.majorVersion;a("img",e).each(function(){var t=a(this).attr("title").split("]");var s=t[0];var x=a("#thumbnail_size input[type=radio][name=thumbnail_size]:checked").attr("value");if(x!=="la"){s+=" size='"+x+"'"}a("input#desc_check[name=desc_check]").attr("value",0);$hdesc=0+a("input#desc_check[name=desc_check]:checked").attr("value",1).attr("value");if($hdesc==1){s+=" desc=1"}var v=a("#photo_class").val();if(v!=""){s+=" class='"+v+"'"}var u=a("#link_type input[type=radio][name=link_type]:checked").attr("value");if(u!="picture"){s+=" lnktype='"+u+"'"}var w=a("#open_type input[type=radio][name=open_type]:checked").attr("value");if(w!=""){s+=" opntype='"+w+"'"}var s="\t"+s+"] \n\r";a("#content").insertAtCaret(s);if(r>="4"){tinyMCE.execCommand("mceInsertContent",false,s)}else{tinyMCE.execInstanceCommand("content","mceInsertContent",false,s)}})});a("a#PWGP_rst").unbind().click(function(){a("li",e).appendTo(f);a("a#PWGP_Gen").hide();a("a#PWGP_rst").hide();a("#PWGP_show_stats").show().find("#PWGP_stats").text(" "+a("li",f).size()+" / "+h)})});a("a#PWGP_Gen").show();a("a#PWGP_rst").show()}})});b=false}else{a("div#PWGP_shortcoder").hide();b=true}})})}(jQuery));
  • piwigopress/trunk/piwigopress.php

    r1136944 r1141552  
    44Plugin URI: http://wordpress.org/extend/plugins/piwigopress/
    55Description: PiwigoPress from any open API Piwigo gallery, swiftly includes your photos in Posts/Pages and/or add randomized thumbnails and menus in your sidebar.
    6 Version: 2.28
     6Version: 2.29
    77Author: Norbert Preining
    88Author URI: http://www.preining.info/
    99*/
     10if (!defined('ABSPATH')) exit; /* Avoid unpredicted access */
    1011if (defined('PHPWG_ROOT_PATH')) return; /* Avoid Automatic install under Piwigo */
    1112/*  Copyright 2009-2012  VDigital  (email : vpiwigo[at]gmail[dot]com)
     
    2728*/
    2829if (!defined('PWGP_NAME')) define('PWGP_NAME','PiwigoPress');
    29 if (!defined('PWGP_VERSION')) define('PWGP_VERSION','2.2.8');
     30if (!defined('PWGP_VERSION')) define('PWGP_VERSION','2.2.9');
    3031
    3132load_plugin_textdomain('pwg', false, dirname (plugin_basename( __FILE__ ) ) . '/languages/');
    3233add_shortcode('PiwigoPress', 'PiwigoPress_photoblog');
     34
     35require_once('piwigopress_utils.php');
     36require_once('PiwigoPress_get.php');
    3337
    3438function PiwigoPress_photoblog($parm) {
     
    6367    $deriv = array ( 'sq' => 'square', 'th' => 'thumb', 'sm' => 'small', 'xs' => 'xsmall', '2s' => '2small',
    6468                     'me' => 'medium', 'la' => 'large', 'xl' => 'xlarge', 'xx' => 'xxlarge');
    65     if (!function_exists('pwg_get_contents')) include 'PiwigoPress_get.php';
    6669    $response = pwg_get_contents( $url . 'ws.php?method=pwg.images.getInfo&format=php&image_id=' . $id);
    67     $thumbc = unserialize($response);
    68     if ($thumbc["stat"] == 'ok') {
     70    if (!is_wp_error($response)) {
     71        $thumbc = unserialize($response['body']);
    6972        $picture = $thumbc["result"];
    7073        //var_dump($picture);
     
    190193    if ( is_admin() ) {
    191194        wp_register_script( 'piwigopress_a', plugins_url( 'piwigopress/js/piwigopress_adm.min.js'), array('jquery'), PWGP_VERSION );
     195        wp_localize_script( 'piwigopress_a', 'PwgpAjax', array(
     196            'ajaxUrl' => admin_url('admin-ajax.php'),
     197            'nonce' => wp_create_nonce('piwigopress-admin-nonce')
     198        ));
    192199        wp_enqueue_script( 'jquery-ui-draggable' );
    193200        wp_enqueue_script( 'jquery-ui-droppable' );
     
    197204}
    198205add_action('wp_footer',  PWGP_NAME . '_load_in_footer');
     206
     207// proxy a categories call from another server
     208function PiwigoPress_ajax_categories() {
     209    $url = PWGP_secure($_POST['url']);
     210    $nonce = $_POST['nonce'];
     211
     212    // check nonce and permissions
     213    if (!wp_verify_nonce($nonce, 'piwigopress-admin-nonce') ||
     214        (!current_user_can('edit_posts') && !current_user_can('edit_pages'))) {
     215        http_response_code(400);
     216        die;
     217    }
     218
     219    $url.= "ws.php?format=json&method=pwg.categories.getList&recursive=true";
     220    $response = pwg_get_contents($url);
     221    if (is_wp_error($response)) {
     222        http_response_code(400);
     223        $error_message = $response->get_error_message();
     224        echo "Error: $error_message";
     225    } else {
     226        header("Content-Type: application/json");
     227        echo $response['body'];
     228    }
     229    exit;
     230}
     231add_action('wp_ajax_pwgp-categories', PWGP_NAME . '_ajax_categories');
     232
     233// proxy thumbnails call from another server
     234function PiwigoPress_ajax_thumbnails() {
     235    require_once('piwigopress_thumbnails_reloader.php');
     236    exit;
     237}
     238add_action('wp_ajax_pwgp-thumbnails', PWGP_NAME . '_ajax_thumbnails');
    199239
    200240function PiwigoPress_register_plugin() {
     
    203243    add_action('admin_head', PWGP_NAME . '_load_in_head');
    204244}
    205 
    206245add_action('init', PWGP_NAME . '_register_plugin');
    207246
     
    222261    return $links; 
    223262
    224  
    225 add_filter( 'plugin_row_meta', PWGP_NAME . '_plugin_links', 10, 2 ); 
     263add_filter( 'plugin_row_meta', PWGP_NAME . '_plugin_links', 10, 2 );
     264
    226265# vim:set expandtab tabstop=2 shiftwidth=2 autoindent smartindent: #
    227 ?>
     266
  • piwigopress/trunk/piwigopress_admin.php

    r1136944 r1141552  
    22if (defined('PHPWG_ROOT_PATH')) return; /* Avoid direct usage under Piwigo */
    33if (!defined('PWGP_NAME')) return; /* Avoid unpredicted access */
    4 if (!defined('PWGP_VERSION')) define('PWGP_VERSION','2.2.8');
    5 if (!function_exists('pwg_get_contents')) include 'PiwigoPress_get.php';
     4require_once('PiwigoPress_get.php');
    65
    76if(!class_exists('PiwigoPress_Admin')){
     
    206205
    207206# vim:set expandtab tabstop=2 shiftwidth=2 autoindent smartindent: #
    208 ?>
     207
  • piwigopress/trunk/readme.txt

    r1136944 r1141552  
    33Tags: galleries, pictures, randomize, shortcode, gallery, integration, photos, drag, drop, widget, media, piwigo
    44Requires at least: 2.8.4
    5 Tested up to: 4.1.1
    6 Stable tag: 2.28
     5Tested up to: 4.2
     6Stable tag: 2.29
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1731739. Expected result on your page or post of your Wordpress blog.
    174174
     175== Copyright/License ==
     176
     177PiwigoPress WordPress Plugin
     178
     179  Copyright 2009-2012  VDigital
     180  Copyright 2014-2015  Norbert Preining
     181
     182Contributions by
     183
     184  Rüdiger Schulz 2015 (copyright transfered)
     185
     186PiwigoPress is distributed under the terms of the GNU GPL version 2+
     187
     188This program is free software: you can redistribute it and/or modify
     189it under the terms of the GNU General Public License as published by
     190the Free Software Foundation, either version 2 of the License, or
     191(at your option) any later version.
     192
     193This program is distributed in the hope that it will be useful,
     194but WITHOUT ANY WARRANTY; without even the implied warranty of
     195MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     196GNU General Public License for more details.
     197
     198You should have received a copy of the GNU General Public License
     199along with this program.  If not, see if not, write to the Free Software
     200Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     201
    175202== Changelog ==
     203
     204= 2.29 =
     205* security related improvements by Rüdiger Schulz, big thanks!
    176206
    177207= 2.28 =
Note: See TracChangeset for help on using the changeset viewer.