-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
36 lines (23 loc) · 866 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
error_reporting(E_ERROR);
require_once "functions.php";
require_once "config.php";
$requestUri = $_SERVER['REQUEST_URI'];
$scriptName = dirname($_SERVER['SCRIPT_NAME']);
$relativePath = $requestUri;
if ($scriptName != '/'){
$relativePath = str_replace($scriptName, '', $requestUri);
}
$dependencyPath = ltrim($relativePath, '/');
$repositoriesNames = array_keys($config['repositories']);
$requestedRepositoryName = startsWithArrayItem($dependencyPath,$repositoriesNames);
if ($requestedRepositoryName){
// filtered mirror (use specific repository)
$dependencyPath = str_replace($requestedRepositoryName.'/','',$dependencyPath);
doMirror($requestedRepositoryName,$dependencyPath);
}else{
foreach (array_keys($config['repositories']) as $repository) {
doMirror($repository,$dependencyPath);
}
}
dependencyNotFound();