Skip to content

Commit 59c1b4f

Browse files
author
Florian Schaal
committed
2 parents f9f6efe + 0e899ee commit 59c1b4f

File tree

4 files changed

+157
-149
lines changed

4 files changed

+157
-149
lines changed

install/tpl/nginx_apps.vhost.master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ server {
1212
}
1313

1414
# serve static files directly
15-
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
15+
location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
1616
access_log off;
1717
}
1818

install/tpl/nginx_ispconfig.vhost.master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ server {
1919
}
2020

2121
# serve static files directly
22-
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
22+
location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
2323
access_log off;
2424
}
2525

interface/lib/classes/aps_crawler.inc.php

Lines changed: 154 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ private function fetchFiles($input)
189189
curl_setopt($conn[$i], CURLOPT_TIMEOUT, 0);
190190
curl_setopt($conn[$i], CURLOPT_FAILONERROR, 1);
191191
curl_setopt($conn[$i], CURLOPT_FOLLOWLOCATION, 1);
192-
curl_setopt($conn[$i], CURLOPT_SSL_VERIFYPEER, 0);
192+
curl_setopt($conn[$i], CURLOPT_SSL_VERIFYHOST, 1);
193+
curl_setopt($conn[$i], CURLOPT_SSL_VERIFYPEER, false);
193194

194195
curl_multi_add_handle($mh, $conn[$i]);
195196
}
@@ -284,179 +285,185 @@ public function startCrawler()
284285
$apps_count = substr_count($apps[$j], '<opensearch:totalResults>0</opensearch:totalResults>');
285286
if($apps_count == 0) // obviously this vendor provides one or more apps
286287
{
287-
// Rename namespaces and register them
288-
$xml = str_replace("xmlns=", "ns=", $apps[$j]);
289-
$sxe = new SimpleXMLElement($xml);
290-
$namespaces = $sxe->getDocNamespaces(true);
291-
foreach($namespaces as $ns => $url) $sxe->registerXPathNamespace($ns, $url);
288+
try {
289+
// Rename namespaces and register them
290+
$xml = str_replace("xmlns=", "ns=", $apps[$j]);
291+
$sxe = new SimpleXMLElement($xml);
292+
$namespaces = $sxe->getDocNamespaces(true);
293+
foreach($namespaces as $ns => $url) $sxe->registerXPathNamespace($ns, $url);
292294

293-
//Find highest version
294-
$app_version = "0.0.0";
295-
$entry_pos = 1;
296-
for ($p = 1; ; $p++) {
297-
$app_version_tmp = parent::getXPathValue($sxe, 'entry[position()=' . $p . ']/a:version');
298-
if (strlen($app_version_tmp) < 1) break;
299-
if (version_compare($app_version_tmp, $app_version) >= 0) {
300-
$app_version = $app_version_tmp;
301-
$entry_pos = $p;
295+
//Find highest version
296+
$app_version = "0.0.0";
297+
$entry_pos = 1;
298+
for ($p = 1; ; $p++) {
299+
$app_version_tmp = parent::getXPathValue($sxe, 'entry[position()=' . $p . ']/a:version');
300+
if (strlen($app_version_tmp) < 1) break;
301+
if (version_compare($app_version_tmp, $app_version) >= 0) {
302+
$app_version = $app_version_tmp;
303+
$entry_pos = $p;
304+
}
302305
}
303-
}
304306

305-
// Fetching values of interest
306-
//$app_name = parent::getXPathValue($sxe, 'entry[position()=1]/a:name');
307-
//$app_version = parent::getXPathValue($sxe, 'entry[position()=1]/a:version');
308-
//$app_release = parent::getXPathValue($sxe, 'entry[position()=1]/a:release');
309-
$app_name = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:name");
310-
$app_version = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:version");
311-
$app_release = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:release");
312-
313-
// Find out a (possibly) existing package version
314-
$ex_ver = '';
315-
/*
316-
array_walk($existing_apps,
317-
create_function('$v, $k, $ex_ver', 'if($v["Name"] == "'.$app_name.'") $ex_ver = $v["CurrentVersion"];'), &$ex_ver);
318-
*/
319-
if(is_array($existing_apps)) {
320-
foreach($existing_apps as $k => $v) {
321-
if($v["Name"] == $app_name) $ex_ver = $v["CurrentVersion"];
307+
// Fetching values of interest
308+
//$app_name = parent::getXPathValue($sxe, 'entry[position()=1]/a:name');
309+
//$app_version = parent::getXPathValue($sxe, 'entry[position()=1]/a:version');
310+
//$app_release = parent::getXPathValue($sxe, 'entry[position()=1]/a:release');
311+
$app_name = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:name");
312+
$app_version = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:version");
313+
$app_release = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:release");
314+
315+
// Find out a (possibly) existing package version
316+
$ex_ver = '';
317+
/*
318+
array_walk($existing_apps,
319+
create_function('$v, $k, $ex_ver', 'if($v["Name"] == "'.$app_name.'") $ex_ver = $v["CurrentVersion"];'), &$ex_ver);
320+
*/
321+
if(is_array($existing_apps)) {
322+
foreach($existing_apps as $k => $v) {
323+
if($v["Name"] == $app_name) $ex_ver = $v["CurrentVersion"];
324+
}
322325
}
323-
}
324326

325-
$new_ver = $app_version.'-'.$app_release;
326-
$local_intf_folder = $this->interface_pkg_dir.'/'.$app_name.'-'.$new_ver.'.app.zip/';
327-
328-
// Proceed if a newer or at least equal version has been found with server mode or
329-
// interface mode is activated and there are no valid APP-META.xml and PKG_URL existing yet
330-
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))){
331-
// Check if we already have an old version of this app
332-
if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1) $apps_updated++;
333-
334-
//$app_dl = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='aps']/@href");
335-
//$app_filesize = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='aps']/@length");
336-
//$app_metafile = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='meta']/@href");
337-
$app_dl = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='aps']/@href");
338-
$app_filesize = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='aps']/@length");
339-
$app_metafile = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='meta']/@href");
340-
341-
//$this->app_download_url_list[$app_name.'-'.$new_ver.'.app.zip'] = $app_dl;
342-
// Skip ASP.net packages because they can't be used at all
343-
$asp_handler = parent::getXPathValue($sxe, '//aspnet:handler');
344-
$asp_permissions = parent::getXPathValue($sxe, '//aspnet:permissions');
345-
$asp_version = parent::getXPathValue($sxe, '//aspnet:version');
346-
if(!empty($asp_handler) || !empty($asp_permissions) || !empty($asp_version)) continue;
347-
348-
// Interface mode (download only parts)
349-
if($this->interface_mode)
350-
{
351-
// Delete an obviously out-dated version from the system and DB
352-
if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1)
327+
$new_ver = $app_version.'-'.$app_release;
328+
$local_intf_folder = $this->interface_pkg_dir.'/'.$app_name.'-'.$new_ver.'.app.zip/';
329+
330+
// Proceed if a newer or at least equal version has been found with server mode or
331+
// interface mode is activated and there are no valid APP-META.xml and PKG_URL existing yet
332+
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))){
333+
// Check if we already have an old version of this app
334+
if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1) $apps_updated++;
335+
336+
//$app_dl = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='aps']/@href");
337+
//$app_filesize = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='aps']/@length");
338+
//$app_metafile = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='meta']/@href");
339+
$app_dl = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='aps']/@href");
340+
$app_filesize = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='aps']/@length");
341+
$app_metafile = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='meta']/@href");
342+
343+
//$this->app_download_url_list[$app_name.'-'.$new_ver.'.app.zip'] = $app_dl;
344+
// Skip ASP.net packages because they can't be used at all
345+
$asp_handler = parent::getXPathValue($sxe, '//aspnet:handler');
346+
$asp_permissions = parent::getXPathValue($sxe, '//aspnet:permissions');
347+
$asp_version = parent::getXPathValue($sxe, '//aspnet:version');
348+
if(!empty($asp_handler) || !empty($asp_permissions) || !empty($asp_version)) continue;
349+
350+
// Interface mode (download only parts)
351+
if($this->interface_mode)
353352
{
354-
$old_folder = $this->interface_pkg_dir.'/'.$app_name.'-'.$ex_ver.'.app.zip';
355-
if(file_exists($old_folder)) $this->removeDirectory($old_folder);
356-
357-
/*
358-
$app->db->query("UPDATE aps_packages SET package_status = '".PACKAGE_OUTDATED."' WHERE name = '".
359-
$app->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '".
360-
$app->db->quote($ex_ver)."';");
361-
*/
362-
$tmp = $app->db->queryOneRecord("SELECT id FROM aps_packages WHERE name = '".
363-
$app->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '".
364-
$app->db->quote($ex_ver)."';");
365-
$app->db->datalogUpdate('aps_packages', "package_status = ".PACKAGE_OUTDATED, 'id', $tmp['id']);
366-
unset($tmp);
367-
}
368-
369-
// Create the local folder if not yet existing
370-
if(!file_exists($local_intf_folder)) @mkdir($local_intf_folder, 0777, true);
353+
// Delete an obviously out-dated version from the system and DB
354+
if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1)
355+
{
356+
$old_folder = $this->interface_pkg_dir.'/'.$app_name.'-'.$ex_ver.'.app.zip';
357+
if(file_exists($old_folder)) $this->removeDirectory($old_folder);
358+
359+
/*
360+
$app->db->query("UPDATE aps_packages SET package_status = '".PACKAGE_OUTDATED."' WHERE name = '".
361+
$app->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '".
362+
$app->db->quote($ex_ver)."';");
363+
*/
364+
$tmp = $app->db->queryOneRecord("SELECT id FROM aps_packages WHERE name = '".
365+
$app->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '".
366+
$app->db->quote($ex_ver)."';");
367+
$app->db->datalogUpdate('aps_packages', "package_status = ".PACKAGE_OUTDATED, 'id', $tmp['id']);
368+
unset($tmp);
369+
}
371370

372-
// Save the package URL in an extra file because it's not part of the APP-META.xml file
373-
@file_put_contents($local_intf_folder.'PKG_URL', $app_dl);
371+
// Create the local folder if not yet existing
372+
if(!file_exists($local_intf_folder)) @mkdir($local_intf_folder, 0777, true);
374373

375-
// Download the meta file
376-
$local_metafile = $local_intf_folder.'APP-META.xml';
377-
if(!file_exists($local_metafile) || filesize($local_metafile) == 0)
378-
{
379-
$apps_to_dl[] = array('name' => 'APP-META.xml',
380-
'url' => $app_metafile,
381-
'filesize' => 0,
382-
'localtarget' => $local_metafile);
383-
$apps_downloaded++;
384-
}
374+
// Save the package URL in an extra file because it's not part of the APP-META.xml file
375+
@file_put_contents($local_intf_folder.'PKG_URL', $app_dl);
385376

386-
// Download package license
387-
//$license = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='eula']/@href");
388-
$license = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='eula']/@href");
389-
if($license != '')
390-
{
391-
$local_license = $local_intf_folder.'LICENSE';
392-
if(!file_exists($local_license) || filesize($local_license) == 0)
377+
// Download the meta file
378+
$local_metafile = $local_intf_folder.'APP-META.xml';
379+
if(!file_exists($local_metafile) || filesize($local_metafile) == 0)
393380
{
394-
$apps_to_dl[] = array('name' => basename($license),
395-
'url' => $license,
381+
$apps_to_dl[] = array('name' => 'APP-META.xml',
382+
'url' => $app_metafile,
396383
'filesize' => 0,
397-
'localtarget' => $local_license);
384+
'localtarget' => $local_metafile);
385+
$apps_downloaded++;
398386
}
399-
}
400387

401-
// Download package icon
402-
//$icon = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='icon']/@href");
403-
$icon = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='icon']/@href");
404-
if($icon != '')
405-
{
406-
$local_icon = $local_intf_folder.basename($icon);
407-
if(!file_exists($local_icon) || filesize($local_icon) == 0)
388+
// Download package license
389+
//$license = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='eula']/@href");
390+
$license = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='eula']/@href");
391+
if($license != '')
408392
{
409-
$apps_to_dl[] = array('name' => basename($icon),
410-
'url' => $icon,
411-
'filesize' => 0,
412-
'localtarget' => $local_icon);
393+
$local_license = $local_intf_folder.'LICENSE';
394+
if(!file_exists($local_license) || filesize($local_license) == 0)
395+
{
396+
$apps_to_dl[] = array('name' => basename($license),
397+
'url' => $license,
398+
'filesize' => 0,
399+
'localtarget' => $local_license);
400+
}
413401
}
414-
}
415402

416-
// Download available screenshots
417-
//$screenshots = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='screenshot']", true);
418-
$screenshots = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='screenshot']", true);
419-
if(!empty($screenshots))
420-
{
421-
foreach($screenshots as $screen)
403+
// Download package icon
404+
//$icon = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='icon']/@href");
405+
$icon = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='icon']/@href");
406+
if($icon != '')
422407
{
423-
$local_screen = $local_intf_folder.basename($screen['href']);
424-
if(!file_exists($local_screen) || filesize($local_screen) == 0)
408+
$local_icon = $local_intf_folder.basename($icon);
409+
if(!file_exists($local_icon) || filesize($local_icon) == 0)
425410
{
426-
$apps_to_dl[] = array('name' => basename($screen['href']),
427-
'url' => $screen['href'],
411+
$apps_to_dl[] = array('name' => basename($icon),
412+
'url' => $icon,
428413
'filesize' => 0,
429-
'localtarget' => $local_screen);
414+
'localtarget' => $local_icon);
415+
}
416+
}
417+
418+
// Download available screenshots
419+
//$screenshots = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='screenshot']", true);
420+
$screenshots = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='screenshot']", true);
421+
if(!empty($screenshots))
422+
{
423+
foreach($screenshots as $screen)
424+
{
425+
$local_screen = $local_intf_folder.basename($screen['href']);
426+
if(!file_exists($local_screen) || filesize($local_screen) == 0)
427+
{
428+
$apps_to_dl[] = array('name' => basename($screen['href']),
429+
'url' => $screen['href'],
430+
'filesize' => 0,
431+
'localtarget' => $local_screen);
432+
}
430433
}
431434
}
432435
}
433-
}
434-
else // Server mode (download whole ZIP archive)
435-
{
436-
// Delete an obviously out-dated version from the system
437-
if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1)
438-
{
439-
$old_file = $this->packages_dir.'/'.$app_name.'-'.$ex_ver.'.app.zip';
440-
if(file_exists($old_file)) $this->removeDirectory($old_file);
441-
}
436+
else // Server mode (download whole ZIP archive)
437+
{
438+
// Delete an obviously out-dated version from the system
439+
if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1)
440+
{
441+
$old_file = $this->packages_dir.'/'.$app_name.'-'.$ex_ver.'.app.zip';
442+
if(file_exists($old_file)) $this->removeDirectory($old_file);
443+
}
442444

443-
// Attention: $new_ver can also be == $ex_ver (according to version_compare >= 0)
444-
$local_zip = $this->packages_dir.'/'.$app_name.'-'.$new_ver.'.app.zip';
445+
// Attention: $new_ver can also be == $ex_ver (according to version_compare >= 0)
446+
$local_zip = $this->packages_dir.'/'.$app_name.'-'.$new_ver.'.app.zip';
445447

446-
// Before re-downloading a file, make sure it's not yet existing on HDD (due to DB inconsistency)
447-
if((file_exists($local_zip) && (filesize($local_zip) == $app_filesize)) === false)
448-
{
449-
$apps_to_dl[] = array('name' => $app_name,
450-
'url' => $app_dl,
451-
'filesize' => $app_filesize,
452-
'localtarget' => $local_zip);
453-
$apps_downloaded++;
448+
// Before re-downloading a file, make sure it's not yet existing on HDD (due to DB inconsistency)
449+
if((file_exists($local_zip) && (filesize($local_zip) == $app_filesize)) === false)
450+
{
451+
$apps_to_dl[] = array('name' => $app_name,
452+
'url' => $app_dl,
453+
'filesize' => $app_filesize,
454+
'localtarget' => $local_zip);
455+
$apps_downloaded++;
456+
}
454457
}
455458
}
456-
}
457459

458-
unset($sxe);
459-
$apps_in_repo++;
460+
unset($sxe);
461+
$apps_in_repo++;
462+
} catch (Exception $e) {
463+
// We dont want the crawler to fail on xml parse errors
464+
$app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_WARN);
465+
//echo 'Caught exception: ', $e->getMessage(), "\n";
466+
}
460467
}
461468
}
462469
//var_dump($apps);

server/scripts/ispconfig_patch

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ echo "Please enter the patch id that you want to be applied to your ISPConfig in
102102

103103
if(!is_installed('patch')) {
104104
swriteln("The program 'patch' is missing on your server. Please install it and try again.");
105+
exit;
105106
}
106107

107108
$patch_id = simple_query('Enter patch id', false, '');

0 commit comments

Comments
 (0)