$repoData) { $repo = getRepo($repoId, $repoData); print $c++ ? ',' : ''; print json_encode($repoId, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES) . ':'; $info = $repo->info(); if (isset($repoData['repositoryUrl'])) { $info['repositoryUrl'] = $repoData['repositoryUrl']; } if (isset($repoData['categoryUrl'])) { $info['categoryUrl'] = $repoData['categoryUrl']; } print json_encode($info, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_FORCE_OBJECT); } print '}'; exit(0); } $repoId = $_REQUEST['repo']; list($repoId, $branchId) = explode('~', $repoId); if (!array_key_exists($repoId, $allRepositories)) { Header("HTTP/1.1 404 Repository not found"); exit(0); } $repoData = $allRepositories[$repoId]; $repo = getRepo($repoId, $repoData); if ($branchId) { try { $repo->setBranch($branchId); } catch (Exception $e) { Header("HTTP/1.1 404 No such branch"); exit(0); } } $cacheDir = null; $ts = $repo->timestamp($path); if (isset($config['cache'])) { $cacheDir = "{$config['cache']}/repo"; @mkdir($cacheDir); $cacheTs = filemtime("{$cacheDir}/{$repoId}.json"); if ($cacheTs === $ts) { Header("Content-Type: application/json; charset=utf-8"); readfile("{$cacheDir}/{$repoId}.json"); exit(0); } } $data = $repo->data(); if (isset($repoData['repositoryUrl'])) { $data['repositoryUrl'] = $repoData['repositoryUrl']; } if (isset($repoData['categoryUrl'])) { $data['categoryUrl'] = $repoData['categoryUrl']; } $ret = json_encode($data, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); Header("Content-Type: application/json; charset=utf-8"); print $ret; file_put_contents("{$cacheDir}/{$repoId}.json", $ret); touch("{$cacheDir}/{$repoId}.json", $ts);