Skip to content
This repository has been archived by the owner on Apr 29, 2019. It is now read-only.

Commit

Permalink
Version 1.1.5 - PHP 7.1 fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
formerandroider committed Nov 8, 2017
1 parent 5b9824a commit 5c8bd2a
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion addon-liam_xenforoUpdater.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<addon addon_id="liam_xenforoUpdater" title="XenForo Updater" version_string="1.1.4" version_id="1010470" url="https://xf-liam.com" install_callback_class="LiamW_XenForoUpdater_Installer" install_callback_method="install" uninstall_callback_class="LiamW_XenForoUpdater_Installer" uninstall_callback_method="uninstall">
<addon addon_id="liam_xenforoUpdater" title="XenForo Updater" version_string="1.1.5" version_id="1010570" url="" install_callback_class="LiamW_XenForoUpdater_Installer" install_callback_method="install" uninstall_callback_class="LiamW_XenForoUpdater_Installer" uninstall_callback_method="uninstall">
<admin_navigation>
<navigation navigation_id="liam_updateXenForo" parent_navigation_id="toolsGroups" display_order="50000" link="tools/update" admin_permission_id="upgradeXenForo" debug_only="0" hide_no_children="0"/>
</admin_navigation>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function getAvailableProducts()
{
$activeAddons = XenForo_Application::get('addOns');

$availableProducts = array(self::PRODUCT_XENFORO);
$availableProducts = [self::PRODUCT_XENFORO];

if (isset($activeAddons['XenResource']))
{
Expand All @@ -40,9 +40,7 @@ public function getAvailableProducts()

public function getLicenses($email, $password, $product = self::PRODUCT_XENFORO, Zend_Http_CookieJar $cookies = null)
{
$client = XenForo_Helper_Http::getClient(self::LOGIN_URL, array(
'useragent' => self::USER_AGENT
));
$client = $this->_getClient(self::LOGIN_URL);

if ($cookies == null)
{
Expand All @@ -59,20 +57,20 @@ public function getLicenses($email, $password, $product = self::PRODUCT_XENFORO,
$domQuery = new Zend_Dom_Query($loginResponse->getBody());
$licensesQuery = $domQuery->query('.licenses .license');

$licenses = array();
$licenses = [];

foreach ($licensesQuery as $license)
{
/** @var DOMElement $license */

$licenseId = false;

foreach ($license->lastChild->getElementsByTagName('a') as $downloadLink)
foreach ($license->getElementsByTagName('a') as $downloadLink)
{
$href = $downloadLink->attributes->getNamedItem('href')->textContent;

// Download link in format: customers/download/?l=<license_id>&d=<product>
$regex = sprintf('#^.*\?l\=([A-Z0-9]+)\&d=%s.*$#', $product);
$regex = sprintf('/^\/?customers\/download\/?\?l\=([A-Z0-9]+)\&d=%s$/', $product);
if (preg_match($regex, $href, $matches))
{
$licenseId = $matches[1];
Expand Down Expand Up @@ -103,9 +101,7 @@ public function getLicenses($email, $password, $product = self::PRODUCT_XENFORO,

public function getVersions($licenseId, $product = self::PRODUCT_XENFORO)
{
$client = XenForo_Helper_Http::getClient(self::DOWNLOAD_URL, array(
'useragent' => self::USER_AGENT
));
$client = $this->_getClient(self::DOWNLOAD_URL);

$client->setCookieJar($this->_getSavedCookieJar());
$client->setParameterGet('l', $licenseId);
Expand All @@ -121,16 +117,16 @@ public function getVersions($licenseId, $product = self::PRODUCT_XENFORO)
return false;
}

$downloadVersions = array();
$downloadVersions = [];

foreach ($versionsQuery as $version)
{
$downloadVersions[$version->getAttribute('value')] = array(
$downloadVersions[$version->getAttribute('value')] = [
'value' => $version->getAttribute('value'),
'label' => $version->textContent,
'selected' => $version->getAttribute('selected') == 'selected' && ($product != self::PRODUCT_XENFORO || (substr(XenForo_Application::$versionId,
5, 1) == 7 || substr(XenForo_Application::$versionId, 5, 1) == 9))
);
];
}

krsort($downloadVersions);
Expand All @@ -140,9 +136,7 @@ public function getVersions($licenseId, $product = self::PRODUCT_XENFORO)

public function downloadAndCopy($downloadVersionId, $licenseId, array $ftpData, &$error, $product = self::PRODUCT_XENFORO)
{
$client = XenForo_Helper_Http::getClient(self::DOWNLOAD_URL, array(
'useragent' => self::USER_AGENT
));
$client = $this->_getClient(self::DOWNLOAD_URL);

$streamDir = XenForo_Helper_File::getInternalDataPath() . '/xf_update/';
$streamFile = $streamDir . $downloadVersionId . '.zip';
Expand Down Expand Up @@ -180,12 +174,12 @@ public function downloadAndCopy($downloadVersionId, $licenseId, array $ftpData,

try
{
$zip = new Zend_Filter_Decompress(array(
$zip = new Zend_Filter_Decompress([
'adapter' => 'Zip',
'options' => array(
'options' => [
'target' => $streamDir . $downloadVersionId . '/'
)
));
]
]);

$zip->filter($streamFile);
} catch (Zend_Filter_Exception $e)
Expand Down Expand Up @@ -267,7 +261,7 @@ public function purgeZips()

if (file_exists($updateDataPath))
{
LiamW_XenForoUpdater_Helper::recursiveDelete($updateDataPath, array('zip'));
LiamW_XenForoUpdater_Helper::recursiveDelete($updateDataPath, ['zip']);
}
}

Expand Down Expand Up @@ -306,4 +300,11 @@ protected function _removeSavedCookieJar()
{
XenForo_Application::getSession()->remove(self::SESSION_COOKIE_JAR);
}

protected function _getClient($url)
{
return XenForo_Helper_Http::getClient($url, [
'timeout' => 5
]);
}
}

0 comments on commit 5c8bd2a

Please sign in to comment.