Browse Source

fix copy path

CauseFX 6 years ago
parent
commit
994dae056a
2 changed files with 10 additions and 1 deletions
  1. 7 0
      api/functions/normal-functions.php
  2. 3 1
      api/functions/update-functions.php

+ 7 - 0
api/functions/normal-functions.php

@@ -765,3 +765,10 @@ function formatSeconds($seconds)
 	//return $timeExtra[0] . 's ' . (number_format(('0.' . substr($timeExtra[1], 0, 4)), 4, '.', '') * 1000) . 'ms';
 	//return (number_format(('0.' . substr($timeExtra[1], 0, 4)), 4, '.', '') * 1000) . 'ms';
 }
+
+function cleanPath($path)
+{
+	$path = preg_replace('/([^:])(\/{2,})/', '$1/', $path);
+	$path = rtrim($path, '/');
+	return $path;
+}

+ 3 - 1
api/functions/update-functions.php

@@ -78,7 +78,7 @@ function downloadFile($url, $path)
 	$newfname = $folderPath . $path;
 	$context = stream_context_create(
 		array(
-			'ssl'=> array(
+			'ssl' => array(
 				'verify_peer' => true,
 				'cafile' => getCert()
 			)
@@ -187,6 +187,8 @@ function rcopy($src, $dst)
 {
 	ini_set('max_execution_time', 0);
 	set_time_limit(0);
+	$src = cleanPath($src);
+	$dst = cleanPath($dst);
 	if (is_dir($src)) {
 		if (!file_exists($dst)) : mkdir($dst);
 		endif;