Skip to content
Snippets Groups Projects
Commit 59c1b4f7 authored by Florian Schaal's avatar Florian Schaal
Browse files
parents f9f6efe1 0e899eee
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ server { ...@@ -12,7 +12,7 @@ server {
} }
# serve static files directly # serve static files directly
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ { location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
access_log off; access_log off;
} }
......
...@@ -19,7 +19,7 @@ server { ...@@ -19,7 +19,7 @@ server {
} }
# serve static files directly # serve static files directly
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ { location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
access_log off; access_log off;
} }
......
...@@ -189,7 +189,8 @@ class ApsCrawler extends ApsBase ...@@ -189,7 +189,8 @@ class ApsCrawler extends ApsBase
curl_setopt($conn[$i], CURLOPT_TIMEOUT, 0); curl_setopt($conn[$i], CURLOPT_TIMEOUT, 0);
curl_setopt($conn[$i], CURLOPT_FAILONERROR, 1); curl_setopt($conn[$i], CURLOPT_FAILONERROR, 1);
curl_setopt($conn[$i], CURLOPT_FOLLOWLOCATION, 1); curl_setopt($conn[$i], CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($conn[$i], CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($conn[$i], CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($conn[$i], CURLOPT_SSL_VERIFYPEER, false);
curl_multi_add_handle($mh, $conn[$i]); curl_multi_add_handle($mh, $conn[$i]);
} }
...@@ -284,179 +285,185 @@ class ApsCrawler extends ApsBase ...@@ -284,179 +285,185 @@ class ApsCrawler extends ApsBase
$apps_count = substr_count($apps[$j], '<opensearch:totalResults>0</opensearch:totalResults>'); $apps_count = substr_count($apps[$j], '<opensearch:totalResults>0</opensearch:totalResults>');
if($apps_count == 0) // obviously this vendor provides one or more apps if($apps_count == 0) // obviously this vendor provides one or more apps
{ {
// Rename namespaces and register them try {
$xml = str_replace("xmlns=", "ns=", $apps[$j]); // Rename namespaces and register them
$sxe = new SimpleXMLElement($xml); $xml = str_replace("xmlns=", "ns=", $apps[$j]);
$namespaces = $sxe->getDocNamespaces(true); $sxe = new SimpleXMLElement($xml);
foreach($namespaces as $ns => $url) $sxe->registerXPathNamespace($ns, $url); $namespaces = $sxe->getDocNamespaces(true);
foreach($namespaces as $ns => $url) $sxe->registerXPathNamespace($ns, $url);
//Find highest version //Find highest version
$app_version = "0.0.0"; $app_version = "0.0.0";
$entry_pos = 1; $entry_pos = 1;
for ($p = 1; ; $p++) { for ($p = 1; ; $p++) {
$app_version_tmp = parent::getXPathValue($sxe, 'entry[position()=' . $p . ']/a:version'); $app_version_tmp = parent::getXPathValue($sxe, 'entry[position()=' . $p . ']/a:version');
if (strlen($app_version_tmp) < 1) break; if (strlen($app_version_tmp) < 1) break;
if (version_compare($app_version_tmp, $app_version) >= 0) { if (version_compare($app_version_tmp, $app_version) >= 0) {
$app_version = $app_version_tmp; $app_version = $app_version_tmp;
$entry_pos = $p; $entry_pos = $p;
}
} }
}
// Fetching values of interest // Fetching values of interest
//$app_name = parent::getXPathValue($sxe, 'entry[position()=1]/a:name'); //$app_name = parent::getXPathValue($sxe, 'entry[position()=1]/a:name');
//$app_version = parent::getXPathValue($sxe, 'entry[position()=1]/a:version'); //$app_version = parent::getXPathValue($sxe, 'entry[position()=1]/a:version');
//$app_release = parent::getXPathValue($sxe, 'entry[position()=1]/a:release'); //$app_release = parent::getXPathValue($sxe, 'entry[position()=1]/a:release');
$app_name = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:name"); $app_name = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:name");
$app_version = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:version"); $app_version = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:version");
$app_release = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:release"); $app_release = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:release");
// Find out a (possibly) existing package version // Find out a (possibly) existing package version
$ex_ver = ''; $ex_ver = '';
/* /*
array_walk($existing_apps, array_walk($existing_apps,
create_function('$v, $k, $ex_ver', 'if($v["Name"] == "'.$app_name.'") $ex_ver = $v["CurrentVersion"];'), &$ex_ver); create_function('$v, $k, $ex_ver', 'if($v["Name"] == "'.$app_name.'") $ex_ver = $v["CurrentVersion"];'), &$ex_ver);
*/ */
if(is_array($existing_apps)) { if(is_array($existing_apps)) {
foreach($existing_apps as $k => $v) { foreach($existing_apps as $k => $v) {
if($v["Name"] == $app_name) $ex_ver = $v["CurrentVersion"]; if($v["Name"] == $app_name) $ex_ver = $v["CurrentVersion"];
}
} }
}
$new_ver = $app_version.'-'.$app_release; $new_ver = $app_version.'-'.$app_release;
$local_intf_folder = $this->interface_pkg_dir.'/'.$app_name.'-'.$new_ver.'.app.zip/'; $local_intf_folder = $this->interface_pkg_dir.'/'.$app_name.'-'.$new_ver.'.app.zip/';
// Proceed if a newer or at least equal version has been found with server mode or // Proceed if a newer or at least equal version has been found with server mode or
// interface mode is activated and there are no valid APP-META.xml and PKG_URL existing yet // interface mode is activated and there are no valid APP-META.xml and PKG_URL existing yet
if((!$this->interface_mode && version_compare($new_ver, $ex_ver) >= 0) || ($this->interface_mode && (!file_exists($local_intf_folder.'APP-META.xml') || filesize($local_intf_folder.'APP-META.xml') == 0 || !file_exists($local_intf_folder.'PKG_URL') || filesize($local_intf_folder.'PKG_URL') == 0))){ if((!$this->interface_mode && version_compare($new_ver, $ex_ver) >= 0) || ($this->interface_mode && (!file_exists($local_intf_folder.'APP-META.xml') || filesize($local_intf_folder.'APP-META.xml') == 0 || !file_exists($local_intf_folder.'PKG_URL') || filesize($local_intf_folder.'PKG_URL') == 0))){
// Check if we already have an old version of this app // Check if we already have an old version of this app
if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1) $apps_updated++; 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_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_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_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_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_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"); $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; //$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 // Skip ASP.net packages because they can't be used at all
$asp_handler = parent::getXPathValue($sxe, '//aspnet:handler'); $asp_handler = parent::getXPathValue($sxe, '//aspnet:handler');
$asp_permissions = parent::getXPathValue($sxe, '//aspnet:permissions'); $asp_permissions = parent::getXPathValue($sxe, '//aspnet:permissions');
$asp_version = parent::getXPathValue($sxe, '//aspnet:version'); $asp_version = parent::getXPathValue($sxe, '//aspnet:version');
if(!empty($asp_handler) || !empty($asp_permissions) || !empty($asp_version)) continue; if(!empty($asp_handler) || !empty($asp_permissions) || !empty($asp_version)) continue;
// Interface mode (download only parts) // Interface mode (download only parts)
if($this->interface_mode) if($this->interface_mode)
{
// Delete an obviously out-dated version from the system and DB
if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1)
{ {
$old_folder = $this->interface_pkg_dir.'/'.$app_name.'-'.$ex_ver.'.app.zip'; // Delete an obviously out-dated version from the system and DB
if(file_exists($old_folder)) $this->removeDirectory($old_folder); if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1)
{
/* $old_folder = $this->interface_pkg_dir.'/'.$app_name.'-'.$ex_ver.'.app.zip';
$app->db->query("UPDATE aps_packages SET package_status = '".PACKAGE_OUTDATED."' WHERE name = '". if(file_exists($old_folder)) $this->removeDirectory($old_folder);
$app->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '".
$app->db->quote($ex_ver)."';"); /*
*/ $app->db->query("UPDATE aps_packages SET package_status = '".PACKAGE_OUTDATED."' WHERE name = '".
$tmp = $app->db->queryOneRecord("SELECT id FROM aps_packages WHERE name = '". $app->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '".
$app->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '". $app->db->quote($ex_ver)."';");
$app->db->quote($ex_ver)."';"); */
$app->db->datalogUpdate('aps_packages', "package_status = ".PACKAGE_OUTDATED, 'id', $tmp['id']); $tmp = $app->db->queryOneRecord("SELECT id FROM aps_packages WHERE name = '".
unset($tmp); $app->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '".
} $app->db->quote($ex_ver)."';");
$app->db->datalogUpdate('aps_packages', "package_status = ".PACKAGE_OUTDATED, 'id', $tmp['id']);
// Create the local folder if not yet existing unset($tmp);
if(!file_exists($local_intf_folder)) @mkdir($local_intf_folder, 0777, true); }
// Save the package URL in an extra file because it's not part of the APP-META.xml file // Create the local folder if not yet existing
@file_put_contents($local_intf_folder.'PKG_URL', $app_dl); if(!file_exists($local_intf_folder)) @mkdir($local_intf_folder, 0777, true);
// Download the meta file // Save the package URL in an extra file because it's not part of the APP-META.xml file
$local_metafile = $local_intf_folder.'APP-META.xml'; @file_put_contents($local_intf_folder.'PKG_URL', $app_dl);
if(!file_exists($local_metafile) || filesize($local_metafile) == 0)
{
$apps_to_dl[] = array('name' => 'APP-META.xml',
'url' => $app_metafile,
'filesize' => 0,
'localtarget' => $local_metafile);
$apps_downloaded++;
}
// Download package license // Download the meta file
//$license = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='eula']/@href"); $local_metafile = $local_intf_folder.'APP-META.xml';
$license = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='eula']/@href"); if(!file_exists($local_metafile) || filesize($local_metafile) == 0)
if($license != '')
{
$local_license = $local_intf_folder.'LICENSE';
if(!file_exists($local_license) || filesize($local_license) == 0)
{ {
$apps_to_dl[] = array('name' => basename($license), $apps_to_dl[] = array('name' => 'APP-META.xml',
'url' => $license, 'url' => $app_metafile,
'filesize' => 0, 'filesize' => 0,
'localtarget' => $local_license); 'localtarget' => $local_metafile);
$apps_downloaded++;
} }
}
// Download package icon // Download package license
//$icon = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='icon']/@href"); //$license = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='eula']/@href");
$icon = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='icon']/@href"); $license = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='eula']/@href");
if($icon != '') if($license != '')
{
$local_icon = $local_intf_folder.basename($icon);
if(!file_exists($local_icon) || filesize($local_icon) == 0)
{ {
$apps_to_dl[] = array('name' => basename($icon), $local_license = $local_intf_folder.'LICENSE';
'url' => $icon, if(!file_exists($local_license) || filesize($local_license) == 0)
'filesize' => 0, {
'localtarget' => $local_icon); $apps_to_dl[] = array('name' => basename($license),
'url' => $license,
'filesize' => 0,
'localtarget' => $local_license);
}
} }
}
// Download available screenshots // Download package icon
//$screenshots = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='screenshot']", true); //$icon = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='icon']/@href");
$screenshots = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='screenshot']", true); $icon = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='icon']/@href");
if(!empty($screenshots)) if($icon != '')
{
foreach($screenshots as $screen)
{ {
$local_screen = $local_intf_folder.basename($screen['href']); $local_icon = $local_intf_folder.basename($icon);
if(!file_exists($local_screen) || filesize($local_screen) == 0) if(!file_exists($local_icon) || filesize($local_icon) == 0)
{ {
$apps_to_dl[] = array('name' => basename($screen['href']), $apps_to_dl[] = array('name' => basename($icon),
'url' => $screen['href'], 'url' => $icon,
'filesize' => 0, 'filesize' => 0,
'localtarget' => $local_screen); 'localtarget' => $local_icon);
}
}
// Download available screenshots
//$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)
{
$local_screen = $local_intf_folder.basename($screen['href']);
if(!file_exists($local_screen) || filesize($local_screen) == 0)
{
$apps_to_dl[] = array('name' => basename($screen['href']),
'url' => $screen['href'],
'filesize' => 0,
'localtarget' => $local_screen);
}
} }
} }
} }
} else // Server mode (download whole ZIP archive)
else // Server mode (download whole ZIP archive) {
{ // Delete an obviously out-dated version from the system
// Delete an obviously out-dated version from the system if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1)
if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1) {
{ $old_file = $this->packages_dir.'/'.$app_name.'-'.$ex_ver.'.app.zip';
$old_file = $this->packages_dir.'/'.$app_name.'-'.$ex_ver.'.app.zip'; if(file_exists($old_file)) $this->removeDirectory($old_file);
if(file_exists($old_file)) $this->removeDirectory($old_file); }
}
// Attention: $new_ver can also be == $ex_ver (according to version_compare >= 0) // Attention: $new_ver can also be == $ex_ver (according to version_compare >= 0)
$local_zip = $this->packages_dir.'/'.$app_name.'-'.$new_ver.'.app.zip'; $local_zip = $this->packages_dir.'/'.$app_name.'-'.$new_ver.'.app.zip';
// Before re-downloading a file, make sure it's not yet existing on HDD (due to DB inconsistency) // Before re-downloading a file, make sure it's not yet existing on HDD (due to DB inconsistency)
if((file_exists($local_zip) && (filesize($local_zip) == $app_filesize)) === false) if((file_exists($local_zip) && (filesize($local_zip) == $app_filesize)) === false)
{ {
$apps_to_dl[] = array('name' => $app_name, $apps_to_dl[] = array('name' => $app_name,
'url' => $app_dl, 'url' => $app_dl,
'filesize' => $app_filesize, 'filesize' => $app_filesize,
'localtarget' => $local_zip); 'localtarget' => $local_zip);
$apps_downloaded++; $apps_downloaded++;
}
} }
} }
}
unset($sxe); unset($sxe);
$apps_in_repo++; $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); //var_dump($apps);
......
...@@ -102,6 +102,7 @@ echo "Please enter the patch id that you want to be applied to your ISPConfig in ...@@ -102,6 +102,7 @@ echo "Please enter the patch id that you want to be applied to your ISPConfig in
if(!is_installed('patch')) { if(!is_installed('patch')) {
swriteln("The program 'patch' is missing on your server. Please install it and try again."); swriteln("The program 'patch' is missing on your server. Please install it and try again.");
exit;
} }
$patch_id = simple_query('Enter patch id', false, ''); $patch_id = simple_query('Enter patch id', false, '');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment