Skip to content

Commit

Permalink
update PUC to 4.13 and wrapper to 1.30
Browse files Browse the repository at this point in the history
  • Loading branch information
Server committed Aug 11, 2022
1 parent cd077d6 commit fdfeb76
Show file tree
Hide file tree
Showing 53 changed files with 734 additions and 330 deletions.
8 changes: 7 additions & 1 deletion includes/api/class-api-v3-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,16 @@ private function request( $method, $resource, array $args = array() ) {
throw new NL4WP_API_Exception( 'Unexpected arguments for '.$resource, 999, false, $args ); // da verificare
}

$this->get_log()->debug( sprintf( "CALL service_info %s", print_r($args, true) ) );
$result=service_info();

if ($result)
return (object) array('account_id' => $this->api_key);
else throw new NL4WP_API_Exception( service_errormessage(), service_errorcode(), $result, $args ); // da verificare
else
{
$this->get_log()->warning( sprintf( "CALL to service_info failed: %s", service_errormessage() ) );
throw new NL4WP_API_Exception( service_errormessage(), service_errorcode(), $result, $args ); // da verificare
}

break;
case '/lists':
Expand Down Expand Up @@ -237,6 +242,7 @@ private function request( $method, $resource, array $args = array() ) {
$ip = !empty($args['ip_signup']) ? $args['ip_signup'] : false;
switch ($method) {
case 'GET':
$this->get_log()->debug( sprintf( "GET %s %s", $emailtocheck, print_r($args, true) ) );
$result = service_user_load($emailtocheck);
//check esistenza
if (is_array($result)) {
Expand Down
34 changes: 25 additions & 9 deletions includes/api/wrapper.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// API Wrapper v1.28(20220316)
// API Wrapper v1.30(20220811)
//
// Compatible with PHP4+ with HASH Cryptography extension (PHP >5.1.2)
// or the MHASH Cryptography extension.
Expand Down Expand Up @@ -38,7 +38,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.

if (!class_exists('xmlrpc_client') && !function_exists('xmlrpc_encode_request'))
if (!ini_get('allow_url_fopen') || (!class_exists('xmlrpc_client') && !function_exists('xmlrpc_encode_request')))
@include_once('xmlrpc.inc');

// Settings
Expand All @@ -47,7 +47,7 @@
if (!isset($GLOBALS['service_wrapper_timeout']))
$GLOBALS['service_wrapper_timeout'] = 30;
if (!isset($GLOBALS['service_wrapper_method']))
$GLOBALS['service_wrapper_method'] = "http11";
$GLOBALS['service_wrapper_method'] = "https"; // was http11 in older releases
if (!isset($GLOBALS['service_wrapper_url']))
$GLOBALS['service_wrapper_url'] = "services/xmlrpc";
if (!isset($GLOBALS['service_wrapper_time_offset']))
Expand Down Expand Up @@ -79,7 +79,7 @@


function service_version() {
return 1028;
return 1030;
}

function service_init($hostoruniquekey, $api_key = false, $secret = false) {
Expand All @@ -100,7 +100,7 @@ function service_invoke($method) {
global $service_host, $service_api_key, $service_secret, $service_last_result, $service_last_method, $service_last_args;
$service_last_result = 0;
$timestamp = time() + $GLOBALS['service_wrapper_time_offset'];
$nonce = md5(mt_rand());
$nonce = md5((string)mt_rand());
$hash = function_exists('hash_hmac') ?
hash_hmac("sha256", $service_api_key.';'.$timestamp.';'.$nonce.';'.$method, $service_secret) :
bin2hex(mhash(MHASH_SHA256, $service_api_key.';'.$timestamp.';'.$nonce.';'.$method, $service_secret));
Expand Down Expand Up @@ -176,7 +176,7 @@ function service_invoke($method) {
$service_last_result['value'] = $service_last_result_dec->value();
}

} else if (function_exists('xmlrpc_encode_request')) {
} else if (function_exists('xmlrpc_encode_request') && ini_get('allow_url_fopen')) {

$request = xmlrpc_encode_request($method,$args,array(
'encoding' => 'utf-8',
Expand All @@ -191,12 +191,21 @@ function service_invoke($method) {
'timeout' => $GLOBALS['service_wrapper_timeout'],
)));

$service_last_result_raw = file_get_contents('http://'.$service_host.'/'.$GLOBALS['service_wrapper_url'], false, $context);
$service_last_result_raw = @file_get_contents(($GLOBALS['service_wrapper_method'] == 'https' ? 'https://' : 'http://').$service_host.'/'.$GLOBALS['service_wrapper_url'], false, $context);

if ($GLOBALS['service_wrapper_debug']) {
print("<PRE>\r\n");
print(">>> file_get_contents(" . ($GLOBALS['service_wrapper_method'] == 'https' ? 'https://' : 'http://').$service_host.'/'.$GLOBALS['service_wrapper_url'] . ")\r\n");
print(">>> " . $request . "\r\n");
print("<<< " . ($service_last_result_raw ? $service_last_result_raw : "ERROR: " . print_r(error_get_last(), true)) . "\r\n");
print("</PRE>\r\n");
}

if ($service_last_result_raw == false) {
$error = error_get_last();
$service_last_result = array(
'faultCode' => 8,
'faultString' => 'Remote request timed-out or failed'
'faultString' => 'Remote request timed-out or failed: ' . $error['message']
);
} else {
$service_last_result_dec = xmlrpc_decode($service_last_result_raw, 'utf-8');
Expand All @@ -219,6 +228,13 @@ function service_invoke($method) {
}
}

} else if (function_exists('xmlrpc_encode_request')) {

$service_last_result = array(
'faultCode' => ENS_ERROR_UNKNOWN,
'faultString' => 'No usable XMLRPC library found. Please set allow_url_fopen PHP ini directive to 1 (default) or download xmlrpc.inc from http://phpxmlrpc.sourceforge.net/'
);

} else {

$service_last_result = array(
Expand Down Expand Up @@ -385,4 +401,4 @@ function service_audience_create($data) {
function service_audience_delete($aid) {
return service_invoke('service.audience.delete', $aid);
}

6 changes: 3 additions & 3 deletions newsletter-for-wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Newsletter for WordPress
Plugin URI: https://github.com/mailrouter/Newsletter-for-Wordpress
Description: Newsletter for WordPress by mailrouter. Aggiunge vari metodi di iscrizione newsletter al tuo sito.
Version: 4.5.8
Version: 4.5.9
Author: mailrouter
Text Domain: newsletter-for-wp
Domain Path: /languages
Expand Down Expand Up @@ -57,11 +57,11 @@ function _nl4wp_load_plugin()
}

// bootstrap the core plugin
define( 'NL4WP_VERSION', '4.5.8');
define( 'NL4WP_VERSION', '4.5.9');
/* NL_CHANGED - start
* imposta la versione pro
*/
define ('NL4WP_PREMIUM_VERSION', '4.5.8');
define ('NL4WP_PREMIUM_VERSION', '4.5.9');
/* NL_CHANGED - end */
define('NL4WP_PLUGIN_DIR', dirname(__FILE__) . '/');
define('NL4WP_PLUGIN_URL', plugins_url('/', __FILE__));
Expand Down
2 changes: 1 addition & 1 deletion plugin-update-checker/Puc/v4/Factory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
if ( !class_exists('Puc_v4_Factory', false) ):

class Puc_v4_Factory extends Puc_v4p11_Factory { }
class Puc_v4_Factory extends Puc_v4p13_Factory { }

endif;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

if ( !class_exists('Puc_v4p11_Autoloader', false) ):
if ( !class_exists('Puc_v4p13_Autoloader', false) ):

class Puc_v4p11_Autoloader {
class Puc_v4p13_Autoloader {
private $prefix = '';
private $rootDir = '';
private $libraryDir = '';
Expand All @@ -11,8 +11,15 @@ class Puc_v4p11_Autoloader {

public function __construct() {
$this->rootDir = dirname(__FILE__) . '/';
$nameParts = explode('_', __CLASS__, 3);
$this->prefix = $nameParts[0] . '_' . $nameParts[1] . '_';

if ( version_compare(PHP_VERSION, '5.3', '>=') && __NAMESPACE__ ) {
$namespaceWithSlash = __NAMESPACE__ . '\\';
} else {
$namespaceWithSlash = '';
}

$nameParts = explode('_', substr(__CLASS__, strlen($namespaceWithSlash)), 3);
$this->prefix = $namespaceWithSlash . $nameParts[0] . '_' . $nameParts[1] . '_';

$this->libraryDir = $this->rootDir . '../..';
if ( !self::isPhar() ) {
Expand All @@ -21,9 +28,9 @@ public function __construct() {
$this->libraryDir = $this->libraryDir . '/';

$this->staticMap = array(
'PucReadmeParser' => 'vendor/PucReadmeParser.php',
'Parsedown' => 'vendor/Parsedown.php',
'Puc_v4_Factory' => 'Puc/v4/Factory.php',
$namespaceWithSlash . 'PucReadmeParser' => 'vendor/PucReadmeParser.php',
$namespaceWithSlash . 'Parsedown' => 'vendor/Parsedown.php',
$namespaceWithSlash . 'Puc_v4_Factory' => 'Puc/v4/Factory.php',
);

spl_autoload_register(array($this, 'autoload'));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
if ( !class_exists('Puc_v4p11_DebugBar_Extension', false) ):
if ( !class_exists('Puc_v4p13_DebugBar_Extension', false) ):

class Puc_v4p11_DebugBar_Extension {
class Puc_v4p13_DebugBar_Extension {
const RESPONSE_BODY_LENGTH_LIMIT = 4000;

/** @var Puc_v4p11_UpdateChecker */
/** @var Puc_v4p13_UpdateChecker */
protected $updateChecker;
protected $panelClass = 'Puc_v4p11_DebugBar_Panel';
protected $panelClass = 'Puc_v4p13_DebugBar_Panel';

public function __construct($updateChecker, $panelClass = null) {
$this->updateChecker = $updateChecker;
Expand Down Expand Up @@ -163,11 +163,11 @@ private function getLibraryUrl($filePath) {
$absolutePath = realpath(dirname(__FILE__) . '/../../../' . ltrim($filePath, '/'));

//Where is the library located inside the WordPress directory structure?
$absolutePath = Puc_v4p11_Factory::normalizePath($absolutePath);
$absolutePath = Puc_v4p13_Factory::normalizePath($absolutePath);

$pluginDir = Puc_v4p11_Factory::normalizePath(WP_PLUGIN_DIR);
$muPluginDir = Puc_v4p11_Factory::normalizePath(WPMU_PLUGIN_DIR);
$themeDir = Puc_v4p11_Factory::normalizePath(get_theme_root());
$pluginDir = Puc_v4p13_Factory::normalizePath(WP_PLUGIN_DIR);
$muPluginDir = Puc_v4p13_Factory::normalizePath(WPMU_PLUGIN_DIR);
$themeDir = Puc_v4p13_Factory::normalizePath(get_theme_root());

if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) {
//It's part of a plugin.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

if ( !class_exists('Puc_v4p11_DebugBar_Panel', false) && class_exists('Debug_Bar_Panel', false) ):
if ( !class_exists('Puc_v4p13_DebugBar_Panel', false) && class_exists('Debug_Bar_Panel', false) ):

class Puc_v4p11_DebugBar_Panel extends Debug_Bar_Panel {
/** @var Puc_v4p11_UpdateChecker */
class Puc_v4p13_DebugBar_Panel extends Debug_Bar_Panel {
/** @var Puc_v4p13_UpdateChecker */
protected $updateChecker;

private $responseBox = '<div class="puc-ajax-response" style="display: none;"></div>';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
if ( !class_exists('Puc_v4p11_DebugBar_PluginExtension', false) ):
if ( !class_exists('Puc_v4p13_DebugBar_PluginExtension', false) ):

class Puc_v4p11_DebugBar_PluginExtension extends Puc_v4p11_DebugBar_Extension {
/** @var Puc_v4p11_Plugin_UpdateChecker */
class Puc_v4p13_DebugBar_PluginExtension extends Puc_v4p13_DebugBar_Extension {
/** @var Puc_v4p13_Plugin_UpdateChecker */
protected $updateChecker;

public function __construct($updateChecker) {
parent::__construct($updateChecker, 'Puc_v4p11_DebugBar_PluginPanel');
parent::__construct($updateChecker, 'Puc_v4p13_DebugBar_PluginPanel');

add_action('wp_ajax_puc_v4_debug_request_info', array($this, 'ajaxRequestInfo'));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

if ( !class_exists('Puc_v4p11_DebugBar_PluginPanel', false) ):
if ( !class_exists('Puc_v4p13_DebugBar_PluginPanel', false) ):

class Puc_v4p11_DebugBar_PluginPanel extends Puc_v4p11_DebugBar_Panel {
class Puc_v4p13_DebugBar_PluginPanel extends Puc_v4p13_DebugBar_Panel {
/**
* @var Puc_v4p11_Plugin_UpdateChecker
* @var Puc_v4p13_Plugin_UpdateChecker
*/
protected $updateChecker;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

if ( !class_exists('Puc_v4p11_DebugBar_ThemePanel', false) ):
if ( !class_exists('Puc_v4p13_DebugBar_ThemePanel', false) ):

class Puc_v4p11_DebugBar_ThemePanel extends Puc_v4p11_DebugBar_Panel {
class Puc_v4p13_DebugBar_ThemePanel extends Puc_v4p13_DebugBar_Panel {
/**
* @var Puc_v4p11_Theme_UpdateChecker
* @var Puc_v4p13_Theme_UpdateChecker
*/
protected $updateChecker;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
if ( !class_exists('Puc_v4p11_Factory', false) ):
if ( !class_exists('Puc_v4p13_Factory', false) ):

/**
* A factory that builds update checker instances.
Expand All @@ -11,7 +11,7 @@
* At the moment it can only build instances of the UpdateChecker class. Other classes are
* intended mainly for internal use and refer directly to specific implementations.
*/
class Puc_v4p11_Factory {
class Puc_v4p13_Factory {
protected static $classVersions = array();
protected static $sorted = false;

Expand All @@ -23,7 +23,7 @@ class Puc_v4p11_Factory {
*
* @param string $fullPath Full path to the main plugin file or the theme's style.css.
* @param array $args Optional arguments. Keys should match the argument names of the buildUpdateChecker() method.
* @return Puc_v4p11_Plugin_UpdateChecker|Puc_v4p11_Theme_UpdateChecker|Puc_v4p11_Vcs_BaseChecker
* @return Puc_v4p13_Plugin_UpdateChecker|Puc_v4p13_Theme_UpdateChecker|Puc_v4p13_Vcs_BaseChecker
*/
public static function buildFromHeader($fullPath, $args = array()) {
$fullPath = self::normalizePath($fullPath);
Expand Down Expand Up @@ -54,15 +54,15 @@ public static function buildFromHeader($fullPath, $args = array()) {
* This method automatically detects if you're using it for a plugin or a theme and chooses
* the appropriate implementation for your update source (JSON file, GitHub, BitBucket, etc).
*
* @see Puc_v4p11_UpdateChecker::__construct
* @see Puc_v4p13_UpdateChecker::__construct
*
* @param string $metadataUrl The URL of the metadata file, a GitHub repository, or another supported update source.
* @param string $fullPath Full path to the main plugin file or to the theme directory.
* @param string $slug Custom slug. Defaults to the name of the main plugin file or the theme directory.
* @param int $checkPeriod How often to check for updates (in hours).
* @param string $optionName Where to store book-keeping info about update checks.
* @param string $muPluginFile The plugin filename relative to the mu-plugins directory.
* @return Puc_v4p11_Plugin_UpdateChecker|Puc_v4p11_Theme_UpdateChecker|Puc_v4p11_Vcs_BaseChecker
* @return Puc_v4p13_Plugin_UpdateChecker|Puc_v4p13_Theme_UpdateChecker|Puc_v4p13_Vcs_BaseChecker
*/
public static function buildUpdateChecker($metadataUrl, $fullPath, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') {
$fullPath = self::normalizePath($fullPath);
Expand Down Expand Up @@ -337,7 +337,11 @@ protected static function compareVersions($a, $b) {
*/
public static function addVersion($generalClass, $versionedClass, $version) {
if ( empty(self::$myMajorVersion) ) {
$nameParts = explode('_', __CLASS__, 3);
$className = (version_compare(PHP_VERSION, '5.3', '>=') && __NAMESPACE__)
? substr(__CLASS__, strlen(__NAMESPACE__) + 1)
: __CLASS__;

$nameParts = explode('_', $className, 3);
self::$myMajorVersion = substr(ltrim($nameParts[1], 'v'), 0, 1);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php
if ( !class_exists('Puc_v4p11_InstalledPackage', false) ):
if ( !class_exists('Puc_v4p13_InstalledPackage', false) ):

/**
* This class represents a currently installed plugin or theme.
*
* Not to be confused with the "package" field in WP update API responses that contains
* the download URL of a the new version.
*/
abstract class Puc_v4p11_InstalledPackage {
abstract class Puc_v4p13_InstalledPackage {
/**
* @var Puc_v4p11_UpdateChecker
* @var Puc_v4p13_UpdateChecker
*/
protected $updateChecker;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
if ( !class_exists('Puc_v4p11_Metadata', false) ):
if ( !class_exists('Puc_v4p13_Metadata', false) ):

/**
* A base container for holding information about updates and plugin metadata.
Expand All @@ -8,7 +8,7 @@
* @copyright 2016
* @access public
*/
abstract class Puc_v4p11_Metadata {
abstract class Puc_v4p13_Metadata {

/**
* Create an instance of this class from a JSON document.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

if ( !class_exists('Puc_v4p11_OAuthSignature', false) ):
if ( !class_exists('Puc_v4p13_OAuthSignature', false) ):

/**
* A basic signature generator for zero-legged OAuth 1.0.
*/
class Puc_v4p11_OAuthSignature {
class Puc_v4p13_OAuthSignature {
private $consumerKey = '';
private $consumerSecret = '';

Expand Down
Loading

0 comments on commit fdfeb76

Please sign in to comment.