aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/config/config.inc.php10
-rw-r--r--src/loadArtifact.php34
-rw-r--r--src/mvncache.php6
3 files changed, 14 insertions, 36 deletions
diff --git a/src/config/config.inc.php b/src/config/config.inc.php
index ac61c27..53dd491 100644
--- a/src/config/config.inc.php
+++ b/src/config/config.inc.php
@@ -4,7 +4,15 @@
*/
return [
- 'mavenBaseUrls' => ['http://repo1.maven.org/maven2', ],
+ 'mavenBaseUrls' => [
+ 'https://repo1.maven.org/maven2',
+ 'https://jcenter.bintray.com',
+ 'https://jitpack.io/',
+ 'https://repo.maven.apache.org/maven2/',
+ 'https://oss.sonatype.org/content/repositories/snapshots/',
+ 'https://oss.sonatype.org/content/repositories/releases/',
+ 'https://plugins.gradle.org/m2' //Gradle plugin repo
+ ],
'logfile' => 'logs/mvncache.log',
];
?> \ No newline at end of file
diff --git a/src/loadArtifact.php b/src/loadArtifact.php
deleted file mode 100644
index 6205164..0000000
--- a/src/loadArtifact.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-$mvnBaseUrl = 'http://repo1.maven.org/maven2';
-
-$requestedArtifact = $_SERVER["REQUEST_URI"];
-$requestedArtifact = str_replace('/mvn', '', $requestedArtifact);
-$baseLocalFolder = __DIR__;
-$localFolder = $baseLocalFolder.substr($requestedArtifact, 0, strripos($requestedArtifact, '/'));
-//echo $localFolder."<br>";
-if (!is_dir($localFolder)) {
- mkdir($localFolder, 0770, true);
-}
-
-$srcUrl = $mvnBaseUrl.$requestedArtifact;
-//echo $srcUrl."<br>";
-$src = fopen($srcUrl, 'r');
-
-$dstPath = $baseLocalFolder.$requestedArtifact;
-//echo $dstPath;
-$dst = fopen($dstPath, 'w');
-
-$filesize = stream_copy_to_stream($src, $dst);
-
-if (0 == $filesize) {
- unlink($dstPath);
- unlink($localFolder);
-}
-
-if (is_file($dstPath)) {
- chmod($dstPath, 0660);
- header('Location: http://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]);
-} else {
- header('HTTP/1.0 404 Not Found');
-}
-?>
diff --git a/src/mvncache.php b/src/mvncache.php
index ef75a16..7abb765 100644
--- a/src/mvncache.php
+++ b/src/mvncache.php
@@ -12,6 +12,10 @@ $requestedArtifact = str_replace('/mvn', '', $requestedArtifact);
$baseLocalFolder = __DIR__.'/..';
$localFolder = $baseLocalFolder.substr($requestedArtifact, 0, strripos($requestedArtifact, '/'));
+if ('' == $requestedArtifact) { // no artifact is requested - return
+ sendHttpReturnCodeAndMessage(403, 'Not allowed');
+}
+
$tempFile = tmpfile();
foreach ($config['mavenBaseUrls'] as $mvnBaseUrl) {
$srcUrl = $mvnBaseUrl.$requestedArtifact;
@@ -46,7 +50,7 @@ if (!$found) {
stream_copy_to_stream($tempFile, $dst);
if (is_file($dstPath)) {
chmod($dstPath, 0660);
- header('Location: http://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]);
+ header('Location: '.getServerProtocol().'://'.getRequestHostname().$_SERVER["REQUEST_URI"]);
} else {
header('HTTP/1.0 404 Not Found');
}