aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2016-06-24 12:45:03 +0200
committersteckbrief <steckbrief@chefmail.de>2016-06-24 12:45:03 +0200
commita139b9c4ea532f62143fc14b8e82b11a7be74192 (patch)
treebb5becabb87b638952a5e6fb4a85dd3547beb537 /src
Initial version. Just for testing
Diffstat (limited to 'src')
-rw-r--r--src/mvncache.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/mvncache.php b/src/mvncache.php
new file mode 100644
index 0000000..d296a4f
--- /dev/null
+++ b/src/mvncache.php
@@ -0,0 +1,29 @@
+<?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');
+
+stream_copy_to_stream($src, $dst);
+
+if (is_file($dstPath)) {
+ chmod($dstPath, 0660);
+ header('Location: http://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]);
+} else {
+ header('HTTP/1.0 404 Not Found');
+}
+?>