Browse Source

Merge branch 'asset'

master
parent
commit
05d4fa5bec
  1. 30
      asset.php
  2. 1
      src/CategoryOverpass.js
  3. 16
      src/RepositoryDir.php

30
asset.php

@ -0,0 +1,30 @@
<?php include "conf.php"; /* load a local configuration */ ?>
<?php session_start(); ?>
<?php require 'vendor/autoload.php'; /* composer includes */ ?>
<?php include "modulekit/loader.php"; /* loads all php-includes */ ?>
<?php call_hooks("init"); /* initialize submodules */ ?>
<?php
$allRepositories = getRepositories();
$repoId = $_REQUEST['repo'];
if (!array_key_exists($repoId, $allRepositories)) {
Header("HTTP/1.1 404 Repository not found");
exit(0);
}
$repoData = $allRepositories[$repoId];
$repo = getRepo($repoId, $repoData);
$tmpfile = tempnam('/tmp', 'osb-asset-');
$contents = $repo->file_get_contents($_REQUEST['file']);
if ($contents === false) {
Header("HTTP/1.1 401 Permission denied");
exit(0);
}
file_put_contents($tmpfile, $contents);
$mime_type = mime_content_type($tmpfile);
Header("Content-Type: {$mime_type}; charset=utf-8");
print $contents;

1
src/CategoryOverpass.js

@ -72,6 +72,7 @@ function CategoryOverpass (options, data) {
data.feature.appUrl = '#' + this.id + '/{{ id }}'
data.styleNoBindPopup = [ 'hover', 'selected' ]
data.stylesNoAutoShow = [ 'hover', 'selected' ]
data.assetPrefix = 'asset.php?repo=' + this.options.repositoryId + '&file='
this.layer = new OverpassLayer(data)

16
src/RepositoryDir.php

@ -38,15 +38,31 @@ class RepositoryDir extends RepositoryBase {
return $data;
}
function access ($file) {
return (substr($file, 0, 1) !== '.' && !preg_match('/\/\./', $file));
}
function scandir($path="") {
if (!$this->access($path)) {
return false;
}
return scandir("{$this->path}/{$path}");
}
function file_get_contents ($file) {
if (!$this->access($file)) {
return false;
}
return file_get_contents("{$this->path}/{$file}");
}
function file_put_contents ($file, $content) {
if (!$this->access($file)) {
return false;
}
return file_put_contents("{$this->path}/{$file}", $content);
}
}
Loading…
Cancel
Save