discourse-legacysite-perl/site/googlemaps/map_json_cache.php
2024-06-17 22:42:14 +10:00

50 lines
812 B
PHP

<?php
require_once('map_json.php');
if ( $_GET['fetch'] == 'all' ) {
writeAllJson();
}
function fetchJson( $slug = null ) {
global $db_tables;
if ( $slug !== null ) {
$filename = $slug . '.json';
$content = connectdb( $slug );
$json = array( $filename, $content );
return $json;
}
}
// $test = fetchJson( 'runshop' );
// writeJson( $test );
function writeJson( $json = array() ) {
$myfile = fopen( 'json/' . $json['0'], "w") or die("Unable to open file!" . $json['0']);
fwrite( $myfile, $json['1'] );
fclose( $myfile );
echo $json['0'] . ' write complete ' . date('Y-m-d (D) g:m:s A T') . '<br/>';
}
function writeAllJson() {
global $db_tables;
foreach ( $db_tables as $slug => $table ) {
$data = fetchJson( $slug );
writeJson( $data );
}
}
?>