33 lines
923 B
PHP
33 lines
923 B
PHP
var VARNAME =
|
|
<?php
|
|
const MAP_ID = MAP_ID_VALUE;
|
|
include('../../admin/snippets/index_prefix.php');
|
|
|
|
const CACHE_PERIOD = CACHE_PERIOD_SECONDS;
|
|
if(CACHE_PERIOD == 0){
|
|
$proj_db = new Database("PG_HOST", "PG_DB", "PG_USER", "PG_PWD", PG_PORT, "public");
|
|
$proj_db->getGeoJSON("public", "PG_TBL", "geom");
|
|
}else {
|
|
$js_file = CACHE_DIR.'/MAP_ID_VALUE/VARNAME_data.js';
|
|
if(!is_file($js_file) || (time() - filemtime($js_file)) > CACHE_PERIOD){
|
|
|
|
if(!is_dir(CACHE_DIR.'/MAP_ID_VALUE')){
|
|
mkdir(CACHE_DIR.'/MAP_ID_VALUE');
|
|
}
|
|
|
|
$fout = fopen($js_file, 'w');
|
|
ob_start(function($buffer) use($fout){
|
|
fwrite($fout, $buffer);
|
|
}, 1024); //notice the use of chunk_size == 1
|
|
|
|
$proj_db = new Database("PG_HOST", "PG_DB", "PG_USER", "PG_PWD", PG_PORT, "public");
|
|
$proj_db->getGeoJSON("public", "PG_TBL", "geom");
|
|
|
|
ob_end_clean();
|
|
|
|
fclose($fout);
|
|
}
|
|
readfile($js_file);
|
|
}
|
|
?>
|
|
;
|