diff --git a/api/bounds.php b/api/bounds.php index ce05070..4f6e314 100755 --- a/api/bounds.php +++ b/api/bounds.php @@ -1,76 +1,78 @@ . */ require '../load.php'; -$results = array(); +expect('db'); + +$results = []; if( isset( $_GET['lat_n'], $_GET['lat_s'], $_GET['lng_e'], $_GET['lng_w'] ) ) { $lat_n = & $_GET['lat_n']; $lat_s = & $_GET['lat_s']; $lng_e = & $_GET['lng_e']; $lng_w = & $_GET['lng_w']; $results = $db->getResults( sprintf( "SELECT station.station_ID, station.station_lat, station.station_lon, " . "stationowner.stationowner_uid, stationowner.stationowner_name " . "FROM {$db->getTables('station', 'stationowner')} " . "WHERE station.station_lat BETWEEN %f AND %f " . "AND station.station_lon BETWEEN %f AND %f " . "AND station.stationowner_ID = stationowner.stationowner_ID", $lat_s, $lat_n, $lng_w, $lng_e ), 'Station' ); $n_results = count( $results ); $results->error = $n_results > 90; if(! $results->error) { // Get prices for($i=0; $i<$n_results; $i++) { $results[$i]->prices = $db->getResults( sprintf( "SELECT DISTINCT price.price_value, price.price_self, " . "fuel.fuel_uid, fuel.fuel_name " . "FROM {$db->getTables('price', 'fuel')} " . "WHERE price.station_ID = %d " . "AND price.fuel_ID = fuel.fuel_ID " . "ORDER BY price.price_value", $results[$i]->station_ID ), 'Price' ); } } } http_json_header(); echo json_encode( $results, isset( $_GET['pretty'] ) ? JSON_PRETTY_PRINT : 0 ); diff --git a/includes/footer.php b/includes/footer.php index c0daf48..bed31da 100755 --- a/includes/footer.php +++ b/includes/footer.php @@ -1,25 +1,27 @@ . */ function get_footer($page = null, $args = null) { - load_module('theme-footer'); + expect('menu'); + + load_module('footer'); ?> . */ -function get_header($uid, $args = array()) { +function get_header($uid, $args = []) { + expect('menu'); + $args = merge_args_defaults($args, [ 'theme' => 'default' ] ); switch($args['theme']) { case 'default': enqueue_css('materialize'); enqueue_css('materialize.icons'); enqueue_js('jquery'); enqueue_js('materialize'); break; } header("Content-Type: text/html; charset=utf-8"); ?> <?php echo SITE_NAME ?> - <?php echo get_menu_entry($uid)->name ?> - + " . HTML::a( $menuEntry->url, $menuEntry->name, $menuEntry->get('description') ) . "\n"; } diff --git a/index.php b/index.php index 0591553..bbf4bd1 100755 --- a/index.php +++ b/index.php @@ -1,101 +1,103 @@ . */ /* * The map */ require 'load.php'; +expect('db'); + enqueue_css('leaflet'); enqueue_css('my-fuel-map'); enqueue_js('jquery.ui'); enqueue_js('leaflet'); enqueue_js('leaflet.bouncemarker'); enqueue_js('my-fuel-map'); get_header('map'); $last_price_rfc3339 = last_price_date(DateTime::RFC3339); $last_price_text = last_price_date(); ?>

getValue( "SELECT COUNT(*) as count FROM {$db->getTable('station')}", 'count' ), HTML::property('class', 'station-counter') ) ) ?>

$last_price_text" ) ?>

navigation " />
navigation
. */ // Customizing Boz PHP - Another PHP framework +expect('menu'); define('INCLUDES', 'includes'); define('IMAGES', 'images'); define('MATERIALIZE', INCLUDES . _ . 'materialize'); define('JQUERY', INCLUDES . _ . 'jquery'); define('LEAFLET', INCLUDES . _ . 'leaflet'); // Load functions require ABSPATH . _ . INCLUDES . '/functions.php'; require ABSPATH . _ . INCLUDES . '/classes.php'; require ABSPATH . _ . INCLUDES . '/header.php'; require ABSPATH . _ . INCLUDES . '/footer.php'; // Choose language switch( $lang = @$_GET['l'] ) { case 'en_US': case 'it_IT': gettext_rocks($lang); break; default: // Choose from browser settings switch( substr(@$_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) ) { case 'it': gettext_rocks('it_IT'); break; case 'en': gettext_rocks('en_US'); break; default: gettext_rocks('en_US'); } } define('SITE_NAME', _("Compara carburanti") ); define('SITE_DESCRIPTION', _("Confronta i prezzi dei carburanti") ); register_js( 'jquery', URL . _ . JQUERY . '/jquery-2.1.4.min.js' ); register_js( 'jquery.ui', URL . _ . INCLUDES . '/jquery-ui/jquery-ui.min.js' ); register_js( 'materialize', URL . _ . MATERIALIZE . '/js/materialize.min.js' ); register_js( 'leaflet', URL . _ . LEAFLET . '/leaflet.js' ); register_js( 'leaflet.bouncemarker', URL . _ . INCLUDES . '/leaflet.bouncemarker/bouncemarker.js' ); register_js( 'my-fuel-map', URL . _ . INCLUDES . '/scripts.js' ); register_css( 'materialize', URL . _ . MATERIALIZE . '/css/materialize.min.css' ); register_css( 'leaflet', URL . _ . LEAFLET . '/leaflet.css' ); register_css( 'my-fuel-map', URL . _ . INCLUDES . '/style.css' ); register_css( 'materialize.icons', 'https://fonts.googleapis.com/icon?family=Material+Icons' ); add_menu_entries([ new MenuEntry( 'map', URL, _("Mappa") ), new MenuEntry( 'about', URL . '/about.php', _("Informazioni sulla piattaforma") ) ]);