From ebd0e986ed11f2a34fb58cdd33efbfab192083ad Mon Sep 17 00:00:00 2001
From: Till Brehm <tbrehm@ispconfig.org>
Date: Fri, 22 Apr 2016 05:26:17 -0400
Subject: [PATCH] Added PHP 7 check in installer and updater.
---
interface/lib/classes/aps_crawler.inc.php | 50 ++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/interface/lib/classes/aps_crawler.inc.php b/interface/lib/classes/aps_crawler.inc.php
index 8260f34..58a8305 100644
--- a/interface/lib/classes/aps_crawler.inc.php
+++ b/interface/lib/classes/aps_crawler.inc.php
@@ -189,6 +189,8 @@
curl_setopt($conn[$i], CURLOPT_TIMEOUT, 0);
curl_setopt($conn[$i], CURLOPT_FAILONERROR, 1);
curl_setopt($conn[$i], CURLOPT_FOLLOWLOCATION, 1);
+ curl_setopt($conn[$i], CURLOPT_SSL_VERIFYHOST, 1);
+ curl_setopt($conn[$i], CURLOPT_SSL_VERIFYPEER, false);
curl_multi_add_handle($mh, $conn[$i]);
}
@@ -283,16 +285,32 @@
$apps_count = substr_count($apps[$j], '<opensearch:totalResults>0</opensearch:totalResults>');
if($apps_count == 0) // obviously this vendor provides one or more apps
{
+ try {
// Rename namespaces and register them
$xml = str_replace("xmlns=", "ns=", $apps[$j]);
$sxe = new SimpleXMLElement($xml);
$namespaces = $sxe->getDocNamespaces(true);
foreach($namespaces as $ns => $url) $sxe->registerXPathNamespace($ns, $url);
+
+ //Find highest version
+ $app_version = "0.0.0";
+ $entry_pos = 1;
+ for ($p = 1; ; $p++) {
+ $app_version_tmp = parent::getXPathValue($sxe, 'entry[position()=' . $p . ']/a:version');
+ if (strlen($app_version_tmp) < 1) break;
+ if (version_compare($app_version_tmp, $app_version) >= 0) {
+ $app_version = $app_version_tmp;
+ $entry_pos = $p;
+ }
+ }
// Fetching values of interest
- $app_name = parent::getXPathValue($sxe, 'entry[position()=1]/a:name');
- $app_version = parent::getXPathValue($sxe, 'entry[position()=1]/a:version');
- $app_release = parent::getXPathValue($sxe, 'entry[position()=1]/a:release');
+ //$app_name = parent::getXPathValue($sxe, 'entry[position()=1]/a:name');
+ //$app_version = parent::getXPathValue($sxe, 'entry[position()=1]/a:version');
+ //$app_release = parent::getXPathValue($sxe, 'entry[position()=1]/a:release');
+ $app_name = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:name");
+ $app_version = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:version");
+ $app_release = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:release");
// Find out a (possibly) existing package version
$ex_ver = '';
@@ -315,9 +333,12 @@
// Check if we already have an old version of this app
if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1) $apps_updated++;
- $app_dl = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='aps']/@href");
- $app_filesize = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='aps']/@length");
- $app_metafile = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='meta']/@href");
+ //$app_dl = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='aps']/@href");
+ //$app_filesize = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='aps']/@length");
+ //$app_metafile = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='meta']/@href");
+ $app_dl = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='aps']/@href");
+ $app_filesize = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='aps']/@length");
+ $app_metafile = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='meta']/@href");
//$this->app_download_url_list[$app_name.'-'.$new_ver.'.app.zip'] = $app_dl;
// Skip ASP.net packages because they can't be used at all
@@ -365,7 +386,8 @@
}
// Download package license
- $license = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='eula']/@href");
+ //$license = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='eula']/@href");
+ $license = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='eula']/@href");
if($license != '')
{
$local_license = $local_intf_folder.'LICENSE';
@@ -379,7 +401,8 @@
}
// Download package icon
- $icon = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='icon']/@href");
+ //$icon = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='icon']/@href");
+ $icon = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='icon']/@href");
if($icon != '')
{
$local_icon = $local_intf_folder.basename($icon);
@@ -393,7 +416,8 @@
}
// Download available screenshots
- $screenshots = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='screenshot']", true);
+ //$screenshots = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='screenshot']", true);
+ $screenshots = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='screenshot']", true);
if(!empty($screenshots))
{
foreach($screenshots as $screen)
@@ -435,9 +459,15 @@
unset($sxe);
$apps_in_repo++;
+ } catch (Exception $e) {
+ // We dont want the crawler to fail on xml parse errors
+ $app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_WARN);
+ //echo 'Caught exception: ', $e->getMessage(), "\n";
+ }
}
}
//var_dump($apps);
+ //echo print_r($apps_to_dl).'<br>-------------------<br>';
// For memory reasons, unset the current vendor and his apps
unset($apps);
@@ -595,7 +625,7 @@
foreach($incomplete_pkgs as $incomplete_pkg){
$pkg_url = @file_get_contents($this->interface_pkg_dir.'/'.$incomplete_pkg['path'].'/PKG_URL');
if($pkg_url != ''){
- $app->db->datalogUpdate('aps_packages', "package_url = '".$pkg_url."'", 'id', $incomplete_pkg['id']);
+ $app->db->datalogUpdate('aps_packages', "package_url = '".$app->db->quote($pkg_url)."'", 'id', $incomplete_pkg['id']);
}
}
}
--
Gitblit v1.9.1