Skip to content

Commit b08c1ac

Browse files
committed
Update market.class.php
1 parent 00f17ab commit b08c1ac

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

modules/market/market.class.php

+27-14
Original file line numberDiff line numberDiff line change
@@ -674,30 +674,40 @@ function updateAll($can_be_updated, $frame = 0)
674674

675675
if (is_array($can_be_updated)) {
676676
foreach ($can_be_updated as $k => $v) {
677+
677678
//$this->getLatest($out, $v['URL'], $v['NAME'], $v['VERSION']);
678679
$name = $v['NAME'];
679680
$version = $v['VERSION'];
680681
$url = $v['URL'];
681682

683+
684+
682685
$filename = ROOT . 'cms/saverestore/' . $name . '.tgz';
683686
if (file_exists($filename)) {
684687
unlink($filename);
685688
}
686-
$filename = ROOT . 'cms/saverestore/' . $name . '.tar';
687-
if (file_exists($filename)) {
688-
unlink($filename);
689+
$filename2 = ROOT . 'cms/saverestore/' . $name . '.tar';
690+
if (file_exists($filename2)) {
691+
unlink($filename2);
689692
}
690693

691694
$f = fopen($filename, 'wb');
692695
if ($f == FALSE) {
693696
$this->redirect("?err_msg=" . urlencode("Cannot open " . $filename . " for writing"));
694697
}
695698

699+
if (!isset($url) || !$url) {
700+
if ($frame) {
701+
$this->echonow("No download URL available for $name ($version).<br/>");
702+
}
703+
continue;
704+
}
705+
696706
if ($frame) {
697707
$this->echonow("Downloading '$url' ... ");
698708
}
699709

700-
DebMes("Downloading plugin $name ($version) from $url");
710+
DebMes("Downloading plugin $name ($version) from $url",'market');
701711
$ch = curl_init();
702712
curl_setopt($ch, CURLOPT_URL, $url);
703713
curl_setopt($ch, CURLOPT_TIMEOUT, 600);
@@ -709,20 +719,19 @@ function updateAll($can_be_updated, $frame = 0)
709719
curl_close($ch);
710720
@fclose($f);
711721

712-
if (file_exists($filename)) {
722+
if (file_exists($filename) && filesize($filename)>0) {
713723

714724
if ($frame) {
715725
$this->echonow("OK<br/>", 'green');
716726
}
717727

718-
719728
$file = basename($filename);
720-
DebMes("Installing/updating plugin $name ($version)");
729+
DebMes("Installing/updating plugin $name ($version)",'market');
721730

722731
chdir(ROOT . 'cms/saverestore/temp');
723732

724733
if ($frame) {
725-
$this->echonow("Unpacking '$file' ..");
734+
$this->echonow("Unpacking '$file' ...");
726735
}
727736

728737
if (IsWindowsOS()) {
@@ -734,8 +743,8 @@ function updateAll($can_be_updated, $frame = 0)
734743
}
735744

736745
if (!$result) {
737-
$this->echonow("Unpack failed!", 'red');
738-
return false;
746+
$this->echonow("Unpack failed!<br/>", 'red');
747+
continue;
739748
}
740749

741750
$x = 0;
@@ -760,13 +769,13 @@ function updateAll($can_be_updated, $frame = 0)
760769

761770
chdir('../../');
762771

763-
DebMes("Latest folder: $latest_dir");
772+
DebMes("Latest folder: $latest_dir",'market');
764773

765774
if ($latest_dir == '') {
766775
if ($frame) {
767776
$this->echonow("ERROR<br/>", 'red');
768777
}
769-
DebMes("Error extracting $file");
778+
DebMes("Error extracting $file",'market');
770779
continue;
771780
}
772781

@@ -799,6 +808,10 @@ function updateAll($can_be_updated, $frame = 0)
799808
}
800809
$this->checkIfCycleRestartRequired($name);
801810

811+
} else {
812+
if ($frame) {
813+
$this->echonow("Download failed.<br/>",'red');
814+
}
802815
}
803816
}
804817
}
@@ -1139,7 +1152,7 @@ function upload(&$out, $frame = 0)
11391152
}
11401153

11411154

1142-
DebMes("Installing/updating plugin $name ($version)");
1155+
DebMes("Installing/updating plugin $name ($version)",'market');
11431156

11441157
$rec = SQLSelectOne("SELECT * FROM plugins WHERE MODULE_NAME LIKE '" . DBSafe($name) . "'");
11451158
$rec['MODULE_NAME'] = $name;
@@ -1362,7 +1375,7 @@ function copyFiles($source, $destination, $over = 0, $patterns = 0)
13621375

13631376
function echonow($msg, $color = '')
13641377
{
1365-
DebMes(strip_tags($msg), 'auto_update');
1378+
DebMes(strip_tags($msg), 'market');
13661379
if ($color) {
13671380
echo '<font color="' . $color . '">';
13681381
}

0 commit comments

Comments
 (0)