diff --git a/README.md b/README.md new file mode 100755 index 0000000..9ef20df --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Italian petrol pumps comparator +![Italian petrol pumps comparator](http://fuel.reyboz.it/images/fuel-64px.png) + +This web app allows you to list in a map and sort all fuel suppliers who are in a particular area, also it provides the current prices on every suppliers. + +We have engineered this solution in a Hackathon that was sponsored by *Facile.it*, an Italian price comparator. This submission **won the competition**. + +## Use +Use the http://fuel.reyboz.it online mirror. It has data updated on a daily basis. + +## More about +Heroes and original technologies in the [/about.php](http://fuel.reyboz.it/about.php) page of the online mirror. + +## Hacking +Clone the source code using Bazaar: + + bzr clone lp:it-fuel-stations-comparator + +## Installation +This project is built over the [Boz-PHP - Another PHP framework](https://github.com/valerio-bozzolan/boz-php-another-php-framework). Install it in your `/usr/share`: + + bzr branch lp:boz-php-another-php-framework /usr/share/boz-php-another-php-framework + +After that you only have to rename and fill the `load-sample.php` to `load.php` and import in MySQL/MariaDB the `database-schema.sql` from the `installation` folder. + +## Import data from MISE +Please download data from the Italian [Ministero dello Sviluppo Economico](http://www.sviluppoeconomico.gov.it/index.php/it/open-data/elenco-dataset/2032336-carburanti-prezzi-praticati-e-anagrafica-degli-impianti): + * http://www.sviluppoeconomico.gov.it/images/exportCSV/prezzo_alle_8.csv + * http://www.sviluppoeconomico.gov.it/images/exportCSV/anagrafica_impianti_attivi.csv + +They are released under the terms of the Italian [Open Data License v2.0](http://www.dati.gov.it/iodl/2.0/). + +The `cli/import.php` can import them into your DB: + + php ./cli/import.php anagrafica_impianti_attivi.csv prezzo_alle_8.csv + +## Pull requests +Push in Launchpad: + +https://code.launchpad.net/it-fuel-stations-comparator + +## License +This is a **Free** as in **Freedom** project. It comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under the terms of the **GNU Affero General Public License v3+**. diff --git a/about.php b/about.php index e6b02d7..c538414 100755 --- a/about.php +++ b/about.php @@ -1,218 +1,235 @@ . + */ require 'load.php'; get_header('about'); ?>

Alexander Busta

Alexander Busta

Cesare de Cal

Cesare de Cal


Edoardo de Cal

Edoardo de Cal


Fabio Bottan

Fabio Bottan


Marcelino Franchini

Marcelino Franchini


Valerio Bozzolan

Valerio Bozzolan


Apache
Boz PHP - Another PHP Framework
Debian GNU/Linux
jQuery + jQuery UI
Leaflet
Materialize
Material Design Icons
MySQL Relational database management system
Open Data MISE
OpenStreetMap
OpenClipArt
PHP
Reveal.JS

. */ require '../load.php'; -http_json_header(); - -$lat_n = @$_GET['lat_n']; -$lat_s = @$_GET['lat_s']; -$lng_e = @$_GET['lng_e']; -$lng_w = @$_GET['lng_w']; - $results = array(); -if( ! empty($lat_n) && ! empty($lat_s) && ! empty($lng_e) && ! empty($lng_w) ) { +if( isset( $_GET['lat_n'], $_GET['lat_s'], $_GET['lng_e'], $_GET['lng_w'] ) ) { - $results = $GLOBALS['db']->getResults( sprintf( - "SELECT station.idImpianto, station.gestore, station.latitudine, station.longitudine FROM station WHERE " . - "station.latitudine BETWEEN %f AND %f AND " . - "station.longitudine BETWEEN %f AND %f", - $lat_s, - $lat_n, - $lng_w, - $lng_e - ) ); + $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) { - $results->error = false; - - // "intify" - $n = count($n_results); - for($i=0; $i<$n_results; $i++) { - $results[$i]->idImpianto = (int) $results[$i]->idImpianto; - $results[$i]->prezzo = (float) $results[$i]->prezzo; - } + // Get prices for($i=0; $i<$n_results; $i++) { - $results[$i]->prezzi = $db->getResults( sprintf( - "SELECT DISTINCT price.prezzo, price.isSelf, descCarburante " . - "FROM price, station " . - "WHERE price.idImpianto = %d AND price.idImpianto = station.idImpianto " . - "ORDER BY price.prezzo" - , - $results[$i]->idImpianto - ) ); + $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]->idImpianto + ), + 'Price' + ); } } } -echo json_encode($results); +http_json_header(); + +echo json_encode( + $results, + isset( $_GET['pretty'] ) ? JSON_PRETTY_PRINT : 0 +); diff --git a/cli/import-functions.php b/cli/import-functions.php new file mode 100755 index 0000000..ed1a612 --- /dev/null +++ b/cli/import-functions.php @@ -0,0 +1,275 @@ +. + */ + +/** + * Fu**ing increase performance + */ +function dichotomic_property_in_array($heystack, $needle, $compare_field, $return_existing_field = null, & $i) { + if( $return_existing_field === null ) { + $return_existing_field = $compare_field; + } + + $i = 0; + $inf = 0; + $n = count($heystack); + $sup = $n - 1; + $val = null; + + while($inf <= $sup) { + $i = (int) ( ($inf + $sup) / 2 ); + $val = $heystack[$i]->{$compare_field}; + + if( $val === $needle ) { + return $heystack[$i]->{$return_existing_field}; + } elseif($needle > $val) { + $inf = $i + 1; + } else { + $sup = $i - 1; + } + } + + if($val !== null && $needle > $val) { + // Please insert after this + $i++; + } + + return false; +} + +/* + * Insert an element in an array maintaining ordered indexes + * Assuming 0 < $here < count($heystack) + */ +function insert_here(& $heystack, $insert, $here) { + $n = count($heystack); + for($i=$n; $i>$here; $i--) { + $heystack[$i] = $heystack[$i-1]; + } + $heystack[ $here ] = $insert; +} + +function get_station_ID($station_miseID, $station_name = null, $station_type = null, $station_address = null, $station_lat = null, $station_lon = null, $comune_ID = null, $stationowner_ID = null, $fuelprovider_ID = null) { + global $db, $stations; + + $station_ID = dichotomic_property_in_array($stations, $station_miseID, 'station_miseID', 'station_ID', $here); + if($station_ID !== false) { + return $station_ID; + } + + if( $station_name === null ) { + throw new Exception( _("La stazione miseID %d doveva essere già stata inserita"), $station_miseID ); + } + + if($station_type === 'Altro') { + $station_type = 'ALTRO'; + } elseif($station_type === 'Strada Statale') { + $station_type = 'STRADA_STATALE'; + } elseif($station_type === 'Autostradale') { + $station_type = 'AUTOSTRADALE'; + } else { + throw new Exception( sprintf( "Tipo di stazione non prevista: %s", esc_html( $station_type ) ) ); + } + + $db->insertRow('station', [ + new DBCol('station_miseID', $station_miseID, 'd'), + new DBCol('station_name', $station_name, 's'), + new DBCol('station_type', $station_type, 's'), + new DBCol('station_address', $station_address, 's'), + new DBCol('station_lat', $station_lat, 'f'), + new DBCol('station_lon', $station_lon, 'f'), + new DBCol('comune_ID', $comune_ID, 'd'), + new DBCol('stationowner_ID', $stationowner_ID, 'd'), + new DBCol('fuelprovider_ID', $fuelprovider_ID, 'd') + ] ); + + $station = $db->getRow( + sprintf( + "SELECT station_ID, station_miseID " . + "FROM {$db->getTable('station')} " . + "WHERE station_ID = %d", + $db->getLastInsertedID() + ), + 'Station' + ); + + insert_here($stations, $station, $here); + + return $station->station_ID; +} + +function get_comune_ID($comune_uid, $comune_name, $provincia_name) { + global $db, $comuni; + + $comune_ID = dichotomic_property_in_array($comuni, $comune_uid, 'comune_uid', 'comune_ID', $here); + if($comune_ID !== false) { + return $comune_ID; + } + + $db->insertRow('comune', [ + new DBCol('comune_uid', $comune_uid, 's'), + new DBCol('comune_name', $comune_name, 's') + ] ); + + $comune = $db->getRow( + sprintf( + "SELECT comune_ID, comune_uid " . + "FROM {$db->getTable('comune')} " . + "WHERE comune_ID = %d", + $db->getLastInsertedID() + ), + 'Comune' + ); + + insert_here($comuni, $comune, $here); + + $db->insertRow('rel_provincia_comune', [ + new DBCol( + 'provincia_ID', + get_provincia_ID( + generate_slug($provincia_name), + $provincia_name + ), + 'd' + ), + new DBCol('comune_ID', $comune->comune_ID, 'd') + ] ); + + return $comune->comune_ID; +} + +function get_fuelprovider_ID($fuelprovider_uid, $fuelprovider_name) { + global $db, $fuelproviders; + + $fuelprovider_ID = dichotomic_property_in_array($fuelproviders, $fuelprovider_uid, 'fuelprovider_uid', 'fuelprovider_ID', $here); + if($fuelprovider_ID !== false) { + return $fuelprovider_ID; + } + + $db->insertRow('fuelprovider', [ + new DBCol('fuelprovider_uid', $fuelprovider_uid, 's'), + new DBCol('fuelprovider_name', $fuelprovider_name, 's') + ] ); + + $fuelprovider = $db->getRow( + sprintf( + "SELECT fuelprovider_ID, fuelprovider_uid " . + "FROM {$db->getTable('fuelprovider')} " . + "WHERE fuelprovider_ID = %d", + $db->getLastInsertedID() + ), + 'Fuelprovider' + ); + + insert_here($fuelproviders, $fuelprovider, $here); + + return $fuelprovider->fuelprovider_ID; +} +function get_stationowner_ID($stationowner_uid, $stationowner_name) { + global $db, $stationowners; + + // Lol + if( ($pos = strpos($stationowner_name, ' IL REGISTRO IMPRESE NON GARANTISCE') ) !== false ) { + $stationowner_name = substr($stationowner_name, 0, $pos); + $stationowner_uid = generate_slug( $stationowner_name ); + $stationowner_note = substr($stationowner_name, $pos); + } else { + $stationowner_note = null; + } + + $stationowner_ID = dichotomic_property_in_array($stationowners, $stationowner_uid, 'stationowner_uid', 'stationowner_ID', $here); + if($stationowner_ID !== false) { + return $stationowner_ID; + } + + $db->insertRow('stationowner', [ + new DBCol('stationowner_uid', $stationowner_uid, 's'), + new DBCol('stationowner_name', $stationowner_name, 's'), + new DBCol('stationowner_note', $stationowner_note, 'snull') + ] ); + + $stationowner = $db->getRow( + sprintf( + "SELECT stationowner_ID, stationowner_uid " . + "FROM {$db->getTable('stationowner')} " . + "WHERE stationowner_ID = %d", + $db->getLastInsertedID() + ), + 'Stationowner' + ); + + insert_here($stationowners, $stationowner, $here); + + return $stationowner->stationowner_ID; +} + +function get_fuel_ID($fuel_uid, $fuel_name) { + global $db, $fuels; + + $fuel_ID = dichotomic_property_in_array($fuels, $fuel_uid, 'fuel_uid', 'fuel_ID', $here); + if($fuel_ID !== false) { + return $fuel_ID; + } + + $db->insertRow('fuel', [ + new DBCol('fuel_uid', $fuel_uid, 's'), + new DBCol('fuel_name', $fuel_name, 's') + ] ); + + $fuel = $db->getRow( + sprintf( + "SELECT fuel_ID, fuel_uid " . + "FROM {$db->getTable('fuel')} " . + "WHERE fuel_ID = %d", + $db->getLastInsertedID() + ), + 'Fuel' + ); + + insert_here($fuels, $fuel, $here); + + return $fuel->fuel_ID; +} + +function get_provincia_ID($provincia_uid, $provincia_name) { + global $db, $provincie; + + $provincia_ID = dichotomic_property_in_array($provincie, $provincia_uid, 'provincia_uid', 'provincia_ID', $here); + if($provincia_ID !== false) { + return $provincia_ID; + } + + $db->insertRow('provincia', [ + new DBCol('provincia_uid', $provincia_uid, 's'), + new DBCol('provincia_name', $provincia_name, 's') + ] ); + + $provincia = $db->getRow( + sprintf( + "SELECT provincia_ID, provincia_uid " . + "FROM {$db->getTable('provincia')} " . + "WHERE provincia_ID = %d", + $db->getLastInsertedID() + ), + 'Provincia' + ); + + insert_here($provincie, $provincia, $here); + + return $provincia->provincia_ID; +} diff --git a/cli/import.php b/cli/import.php new file mode 100755 index 0000000..596d83a --- /dev/null +++ b/cli/import.php @@ -0,0 +1,157 @@ +. + */ + +/* + * Manually download data from Ministero dello Sviluppo Economico + * http://www.sviluppoeconomico.gov.it/index.php/it/open-data/elenco-dataset/2032336-carburanti-prezzi-praticati-e-anagrafica-degli-impianti + * + * Files: + * http://www.sviluppoeconomico.gov.it/images/exportCSV/prezzo_alle_8.csv + * http://www.sviluppoeconomico.gov.it/images/exportCSV/anagrafica_impianti_attivi.csv + * + * The files are licensed under the terms of the Italian Open Data License v2.0 + * http://www.dati.gov.it/iodl/2.0/ + */ + +require '../load.php'; +require 'import-functions.php'; + +//$db->query("TRUNCATE {$db->getTable('rel_provincia_comune')}"); +//$db->query("TRUNCATE {$db->getTable('provincia')}"); +//$db->query("TRUNCATE {$db->getTable('comune')}"); +//$db->query("TRUNCATE {$db->getTable('station')}"); +//$db->query("TRUNCATE {$db->getTable('stationowner')}"); +//$db->query("TRUNCATE {$db->getTable('fuelprovider')}"); +//$db->query("TRUNCATE {$db->getTable('fuel')}"); +$db->query("TRUNCATE {$db->getTable('price')}"); + +$comuni = $db->getResults( + "SELECT comune_ID, comune_uid FROM {$db->getTable('comune')} ORDER BY comune_uid", + 'Comune' +); +$provincie = $db->getResults( + "SELECT provincia_ID, provincia_uid FROM {$db->getTable('provincia')} ORDER BY provincia_uid", + 'Provincia' +); +$fuels = $db->getResults( + "SELECT fuel_ID, fuel_uid FROM {$db->getTable('fuel')} ORDER BY fuel_uid", + 'Fuel' +); +$stations = $db->getResults( + "SELECT station_ID, station_miseID FROM {$db->getTable('station')} ORDER BY station_miseID", + 'Station' +); +$stationowners = $db->getResults( + "SELECT stationowner_ID, stationowner_uid FROM {$db->getTable('stationowner')} ORDER BY stationowner_uid", + 'Stationowner' +); +$fuelproviders = $db->getResults( + "SELECT fuelprovider_ID, fuelprovider_uid FROM {$db->getTable('fuelprovider')} ORDER BY fuelprovider_uid", + 'Fuelprovider' +); + +try { + if( ! isset( $argv[1], $argv[2] ) ) { + throw new Exception( + sprintf( + _("Utilizzo: %s FILE_STAZIONI.csv PREZZI_ALLE_8.csv"), + esc_html( $argv[0] ) + ), + 1 + ); + } + + define('FILENAME_STATIONS', $argv[1]); + define('FILENAME_PRICES', $argv[2]); + + if( ! file_exists(FILENAME_STATIONS) ) { + throw new Exception( _("File delle stazioni non trovato"), 2 ); + } + + if( ! $handle = fopen(FILENAME_STATIONS, 'r') ) { + throw new Exception( _("Impossibile aprire il file delle stazioni"), 3 ); + } + + // Waste first 2 lines + fgetcsv($handle); + fgetcsv($handle); + while( $data = fgetcsv($handle, 512, ';') ) { + get_station_ID( + (int) $data[0] /*$station_miseID*/, + $data[4] /*$station_name*/, + $data[3] /*$station_type*/, + $data[5] /*$station_address*/, + (float) $data[8] /*$station_lat*/, + (float) $data[9] /*$station_lon*/, + get_comune_ID( + generate_slug( $data[6] ) /*$comune_uid*/, + $data[6] /*$comune_name*/, + $data[7] /*$provincia_name*/ + ), + get_stationowner_ID( + generate_slug( $data[1] ) /*$stationowner_uid*/, + $data[1] /*$stationowner_name*/ + ), + get_fuelprovider_ID( + generate_slug( $data[2] ) /*$fuelprovider_uid*/, + $data[2] /*$fuelprovider_name*/ + ) + ); + } + fclose($handle); + + // Prices + if( ! file_exists(FILENAME_PRICES) ) { + throw new Exception( _("File dei prezzi non trovato"), 4 ); + } + + if( ! $handle = fopen(FILENAME_PRICES, 'r') ) { + throw new Exception( _("Impossibile aprire il file dei prezzi"), 5 ); + } + + // Waste first 2 lines + fgetcsv($handle); + fgetcsv($handle); + + while( $data = fgetcsv($handle, 255, ';') ) { + $db->insertRow('price', [ + new DBCol('price_value', (float) $data[2], 'f'), + new DBCol('price_self', (int) $data[3], 'd'), + new DBCol('price_date', $data[4], 's'), + new DBCol( + 'fuel_ID', + get_fuel_ID( + generate_slug($data[1]) /*$fuel_uid*/, + $data[1] /*$fuel_name*/ + ), + 'd' + ), + new DBCol('station_ID', get_station_ID( (int) $data[0] ), 'd') + ] ); + } + + fclose($handle); + +} catch(Exception $e) { + printf( + _("Errore:\n\t%s.\n"), + $e->getMessage() + ); + exit( $e->getCode() ); +} diff --git a/localize.sh b/cli/localize.sh similarity index 73% rename from localize.sh rename to cli/localize.sh index 8a6c026..93bca07 100755 --- a/localize.sh +++ b/cli/localize.sh @@ -1,39 +1,53 @@ #!/bin/sh ############################################################################# # # Copyright (C) 2015 Valerio Bozzolan # ############################################################################# # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # ############################################################################# # This script do the entire Gettext i18n workflow # The copyright older of your localization copyright="Valerio Bozzolan" # The prefix of your localization's files -# (you have to know how Gettext works to change it). +# You have to know how GNU Gettext works to change it. package="fuel.reyboz.it" +rtfm() { + echo Usage: + echo $1 SITE_ROOT + echo Example: + echo $1 /var/www/mysite +} + +if [ -z "$1" ]; then + rtfm $0 + exit 1 +fi + +path="$1" + # Generate/update the .pot file from the single script (index.php) -xgettext --copyright-holder="$copyright" --package-name=$package --from-code=UTF-8 --keyword=_e --default-domain=$package -o l10n/$package.pot *.php api/*.php includes/*.php +xgettext --copyright-holder="$copyright" --package-name=$package --from-code=UTF-8 --keyword=_e --default-domain=$package -o "$path"/l10n/$package.pot "$path"/*.php "$path"/*/*.php # Generate/update the .po files from the .pot file -find ./l10n/ -name \*.po -execdir msgmerge -o $package.po $package.po ../../$package.pot \; +find "$path"/l10n -name \*.po -execdir msgmerge -o $package.po $package.po ../../$package.pot \; # Generate/update the .mo files from .po files -find ./l10n/ -name \*.po -execdir msgfmt -o $package.mo $package.po \; +find "$path"/l10n -name \*.po -execdir msgfmt -o $package.mo $package.po \; diff --git a/db-schema.sql b/db-schema.sql deleted file mode 100644 index 8295975..0000000 --- a/db-schema.sql +++ /dev/null @@ -1,98 +0,0 @@ --- phpMyAdmin SQL Dump --- version 3.3.7deb7 --- http://www.phpmyadmin.net --- --- Host: localhost --- Generation Time: Nov 18, 2015 at 12:11 AM --- Server version: 5.5.38 --- PHP Version: 5.4.45-1~dotdeb+6.1 - -SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; - --- --- Database: `facile.it` --- - --- -------------------------------------------------------- - --- --- Table structure for table `comune` --- - -CREATE TABLE IF NOT EXISTS `comune` ( - `comune_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, - `comune_uid` varchar(64) NOT NULL, - `comune_name` varchar(64) NOT NULL, - PRIMARY KEY (`comune_ID`), - UNIQUE KEY `comune_uid` (`comune_uid`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5197 ; - --- -------------------------------------------------------- - --- --- Table structure for table `price` --- - -CREATE TABLE IF NOT EXISTS `price` ( - `idImpianto` int(10) unsigned NOT NULL, - `descCarburante` varchar(64) NOT NULL, - `prezzo` float NOT NULL, - `isSelf` tinyint(1) NOT NULL, - `dtComu` varchar(64) NOT NULL, - KEY `idImpianto` (`idImpianto`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- - --- --- Table structure for table `provincia` --- - -CREATE TABLE IF NOT EXISTS `provincia` ( - `provincia_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, - `provincia_uid` varchar(2) NOT NULL, - `provincia_name` varchar(64) NOT NULL, - PRIMARY KEY (`provincia_ID`), - UNIQUE KEY `provincia_uid` (`provincia_uid`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=111 ; - --- -------------------------------------------------------- - --- --- Table structure for table `rel_provincia_comune` --- - -CREATE TABLE IF NOT EXISTS `rel_provincia_comune` ( - `provincia_ID` int(10) unsigned NOT NULL, - `comune_ID` int(10) unsigned NOT NULL, - PRIMARY KEY (`provincia_ID`,`comune_ID`), - KEY `comune_ID` (`comune_ID`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- - --- --- Table structure for table `station` --- - -CREATE TABLE IF NOT EXISTS `station` ( - `idImpianto` int(11) NOT NULL, - `gestore` varchar(64) NOT NULL, - `bandiera` varchar(64) NOT NULL, - `tipoImpianto` varchar(64) NOT NULL, - `nomeImpianto` varchar(255) NOT NULL, - `indirizzo` varchar(255) NOT NULL, - `latitudine` float NOT NULL, - `longitudine` float NOT NULL, - `comune_ID` int(10) unsigned NOT NULL, - KEY `station_uid` (`idImpianto`), - KEY `latitudine` (`latitudine`), - KEY `longitudine` (`longitudine`), - KEY `comune_ID` (`comune_ID`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; diff --git a/content/fuel-300px.png b/images/fuel-300px.png similarity index 100% rename from content/fuel-300px.png rename to images/fuel-300px.png diff --git a/content/fuel-64px.png b/images/fuel-64px.png similarity index 100% rename from content/fuel-64px.png rename to images/fuel-64px.png diff --git a/content/fuel-782px.png b/images/fuel-782px.png similarity index 100% rename from content/fuel-782px.png rename to images/fuel-782px.png diff --git a/import/import.php b/import/import.php deleted file mode 100755 index 7cb06f7..0000000 --- a/import/import.php +++ /dev/null @@ -1,179 +0,0 @@ -. - */ - -/* - * Manually download data from Ministero dello Sviluppo Economico - * http://www.sviluppoeconomico.gov.it/index.php/it/open-data/elenco-dataset/2032336-carburanti-prezzi-praticati-e-anagrafica-degli-impianti - * - * Files: - * http://www.sviluppoeconomico.gov.it/images/exportCSV/prezzo_alle_8.csv - * http://www.sviluppoeconomico.gov.it/images/exportCSV/anagrafica_impianti_attivi.csv - * - * The files are licensed under the terms of the Italian Open Data License v2.0 - * http://www.dati.gov.it/iodl/2.0/ - */ - -// Uncomment -die("No."); - -define('FILENAME_STATIONS', 'anagrafica_impianti_attivi.csv'); -define('FILENAME_PRICES', 'prezzo_alle_8.csv'); - -require '../load.php'; - -$db->query("TRUNCATE {$db->getTable('price')}"); -$db->query("TRUNCATE {$db->getTable('station')}"); - -$error_code = null; -$error_message = null; - -$comuni = $db->getResults("SELECT * FROM {$db->getTable('comune')}"); -$provincie = $db->getResults("SELECT * FROM {$db->getTable('provincia')}"); - -function get_comune_ID($comune_uid, $comune_name, $provincia_name) { - global $db, $comuni; - - $n = count($comuni); - $i = 0; - while($i<$n && $comuni[$i++]->comune_uid !== $comune_uid); - $i--; - if($i>=0 && $i<$n && $comuni[$i]->comune_uid === $comune_uid) { - return $comuni[$i]->comune_ID; - } - - $db->insertRow('comune', [ - new DBCol('comune_uid', $comune_uid, 's'), - new DBCol('comune_name', $comune_name, 's') - ] ); - - $comuni[] = $db->getRow( sprintf( - "SELECT * FROM {$db->getTable('comune')} WHERE comune_ID = '%d'", - $db->getLastInsertedID() - ) ); - - $db->insertRow('rel_provincia_comune', [ - new DBCol( - 'provincia_ID', - get_provincia_ID( - generate_slug($provincia_name), - $provincia_name - ), - 'd' - ), - new DBCol('comune_ID', $comuni[$n]->comune_ID, 'd') - ] ); - - return $comuni[$n]->comune_ID; -} - -function get_provincia_ID($provincia_uid, $provincia_name) { - global $db, $provincie; - - $n = count($provincie); - $i = 0; - while($i<$n && $provincie[$i++]->provincia_uid !== $provincia_uid); - $i--; - if($i>=0 && $i<$n && $provincie[$i]->provincia_uid === $provincia_uid) { - return $provincie[$i]->provincia_ID; - } - - $db->insertRow('provincia', [ - new DBCol('provincia_uid', $provincia_uid, 's'), - new DBCol('provincia_name', $provincia_name, 's') - ] ); - - $provincie[] = $db->getRow( sprintf( - "SELECT * FROM {$db->getTable('provincia')} WHERE provincia_ID = '%d'", - $db->getLastInsertedID() - ) ); - - return $provincie[$n]->provincia_ID; -} - -try { - if( ! file_exists(FILENAME_STATIONS) ) { - throw new Exception( _("File delle stazioni non trovato"), 1 ); - } - - if( ! $handle = fopen(FILENAME_STATIONS, 'r') ) { - throw new Exception( _("Impossibile aprire il file delle stazioni"), 2 ); - } - - // Waste first 2 lines - fgetcsv($handle); - fgetcsv($handle); - while( $data = fgetcsv($handle, 512, ';') ) { - $db->insertRow('station', [ - new DBCol('idImpianto', intval($data[0]), 'd'), - new DBCol('gestore', $data[1], 's'), - new DBCol('bandiera', $data[2], 's'), - new DBCol('tipoImpianto', $data[3], 's'), - new DBCol('nomeImpianto', $data[4], 's'), - new DBCol('indirizzo', $data[5], 's'), - new DBCol('latitudine', floatval($data[8]), 'f'), - new DBCol('longitudine', floatval($data[9]), 'f'), - new DBCol( - 'comune_ID', - get_comune_ID( - generate_slug($data[6]), - $data[6], - $data[7] - ), - 'd' - ) - ] ); - } - fclose($handle); - - // Prices - if( ! file_exists(FILENAME_PRICES) ) { - throw new Exception( _("File dei prezzi non trovato"), 3 ); - } - - if( ! $handle = fopen(FILENAME_PRICES, 'r') ) { - throw new Exception( _("Impossibile aprire il file dei prezzi"), 4 ); - } - - // Waste first 2 lines - fgetcsv($handle); - fgetcsv($handle); - - while( $data = fgetcsv($handle, 255, ';') ) { - $db->insertRow('price', [ - new DBCol('idImpianto', intval($data[0]), 'd'), - new DBCol('descCarburante', $data[1], 's'), - new DBCol('prezzo', floatval($data[2]), 'f'), - new DBCol('isSelf', intval($data[3]), 'd'), - new DBCol('dtComu', $data[4], 's') - ] ); - } - - fclose($handle); - -} catch(Exception $e) { - $error_code = $e->getCode(); - $error_message = $e->getMessage(); -} - -http_json_header(); - -echo json_encode( [ - 'error' => $error_code, - 'errorMessage' => $error_message -] ); diff --git a/includes/classes.php b/includes/classes.php new file mode 100755 index 0000000..e0043c1 --- /dev/null +++ b/includes/classes.php @@ -0,0 +1,154 @@ +. + */ + +/* + * PHP Traits and classes. + */ + +trait FuelTrait { + public static function prepareFuel(& $fuel) { + if( @$fuel->fuel_ID ) { + $fuel->fuel_ID = (int) $fuel->fuel_ID; + } + } +} + +trait ComuneTrait { + public static function prepareComune(& $comune) { + if( @$comune->comune_ID ) { + $comune->comune_ID = (int) $comune->comune_ID; + } + } +} + +trait FuelproviderTrait { + public static function prepareFuelprovider(& $fuelprovider) { + if( @$fuelprovider->fuelprovider_ID ) { + $fuelprovider->fuelprovider_ID = (int) $fuelprovider->fuelprovider_ID; + } + } +} + +trait PriceTrait { + public static function preparePrice(& $price) { + if( @$price->price_ID ) { + $price->price_ID = (int) $price->price_ID; + } + + if( @$price->price_value ) { + $price->price_value = (float) $price->price_value; + } + + if( @$price->price_self ) { + $price->price_self = (bool) $price->price_self; + } + } +} + +trait ProvinciaTrait { + public static function prepareProvincia(& $provincia) { + if( @$provincia->provincia_ID ) { + $provincia->provincia_ID = (int) $provincia->provincia_ID; + } + } +} + +trait StationTrait { + public static function prepareStation(& $station) { + if( @$station->station_ID ) { + $station->station_ID = (int) $station->station_ID; + } + + if( @$station->station_miseID ) { + $station->station_miseID = (int) $station->station_miseID; + } + + if( @$station->station_lat ) { + $station->station_lat = (float) $station->station_lat; + } + + if( @$station->station_lon ) { + $station->station_lon = (float) $station->station_lon; + } + } +} + +trait StationownerTrait { + public static function prepareStationowner(& $stationowner) { + if( @$stationowner->stationowner_ID ) { + $stationowner->stationowner_ID = (int) $stationowner->stationowner_ID; + } + } +} + +class Comune { + use ComuneTrait; + + function __construct() { + self::prepareComune($this); + } +} + +class Fuelprovider { + use FuelproviderTrait; + + function __Construct() { + self::prepareFuelprovider($this); + } +} + +class Fuel { + use FuelTrait; + + function __construct() { + self::prepareFuel($this); + } +} + +class Price { + use PriceTrait; + + function __construct() { + self::preparePrice($this); + } +} + +class Provincia { + use ProvinciaTrait; + + function __construct() { + self::prepareProvincia($this); + } +} + +class Station { + use StationTrait; + + function __construct() { + self::prepareStation($this); + } +} + +class Stationowner { + use StationownerTrait; + + function __construct() { + self::prepareStationowner($this); + } +} diff --git a/includes/facile.js b/includes/facile.js index b1fd694..84f380b 100644 --- a/includes/facile.js +++ b/includes/facile.js @@ -1,323 +1,335 @@ /* * Italian petrol pumps comparator - Project born (and winner) at hackaton Facile.it 2015 * Copyright (C) 2015 Valerio Bozzolan, Marcelino Franchini, Fabio Mottan, Alexander Bustamente, Cesare de Cal, Edoardo de Cal * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ var map; var EUROS = 40; var errortooresults = true; var trovalatuazona = true; var nessunfornitore = true; -var Impianti = { +var Stations = { all: [], exists: function(id) { var i = 0; while(i < this.all.length && this.all[i++] !== id); - return Impianti.all[i-1] === id; + return this.all[i-1] === id; }, add: function(id) { this.all.push(id); + }, + alreadyAdded: function(id) { + if( this.exists(id) ) { + return true; + } + this.add(id); + return false; } + }; var Overworld = { $el: undefined, $action: undefined, visible: true, running: false, hide: function() { if(Overworld.running) { return; } Overworld.running = true; Overworld.$el.hide("drop", {direction: "up"}, "slow", function() { Overworld.$action.show("drop", {direction: "up"}, "fast", function() { Overworld.running = false; }); }); }, show: function() { if(Overworld.running) { return; } Overworld.running = true; map.closePopup(); Overworld.$el.find("input").val(""); Overworld.$action.hide("drop", {direction: "up"}, "slow", function() { Overworld.$el.show("drop", {direction: "up"}, "fast", function() { Overworld.$el.find("input").focus(); Overworld.running = false; }); }); } }; $(document).ready(function() { Overworld.$action = $("#overworld-buttons"); Overworld.$el = $("#overworld"); Overworld.$action.hide().click(function() { Overworld.show(); }); $("form").submit(function(event) { suggest_nominatim_addresses( $("input[name=search_address]").val() ); event.preventDefault(); }); map = L.map('map'); // create the tile layer with correct attribution var osmUrl='http://{s}.tile.osm.org/{z}/{x}/{y}.png'; var osmAttrib='© OpenStreetMap contributors'; var osm = new L.TileLayer(osmUrl, {maxZoom: 17, attribution: osmAttrib}); map.addLayer(osm); map.setView([41.49, 13.11], 6); map.on("moveend", function() { getMarkersInBounds(); return true; }); map.on("popupopen", function() { Overworld.hide(); }); fitDocument(); map.locate({setView: true, enableHighAccuracy: true, maxZoom: 16}); map.on("locationfound", function(e) { var radius = e.accuracy / 2; enfatizeLatLng(e.latlng, 2000); }); map.on("locationerror", function(e) { Materialize.toast("Posizione non disponibile. Zomma!", 3000); }); getMarkersInBounds(); }); function toast(s) { Materialize.toast(s, 3000); } function getMarkersInBounds(preCallback, postCallback) { var zoom = map.getZoom(); if(zoom < 13) { trovalatuazona && toast( L10N.pleaseZoomIn ); trovalatuazona = false; return; } trovalatuazona = true; var bounds = map.getBounds(); var data = { lat_n: bounds.getNorth(), lat_s: bounds.getSouth(), lng_w: bounds.getWest(), lng_e: bounds.getEast() }; $.getJSON("/api/bounds.php", data, function(json) { if(json.error) { errortooresults && toast( L10N.errorTooStations ); errortooresults = false; return; } errortooresults = true; if(json.length === 0) { nessunfornitore && toast( L10N.noStations ); nessunfornitore = false; return; } nessunfornitore = true; if(json.length > 90) { toast( L10N.tooStations.formatUnicorn({n: json.length}) ); return; } if(preCallback && preCallback(bounds, json) === false ) { return; } var minPriceId = 0; var minPrice = 999.0; for(var i=0; i"; } else { txt += "" + litres + " L"; } - txt += "per il " + json[i].prezzi[j].descCarburante + ""; + txt += "per il " + json[i].prices[j].fuel_name + ""; txt += ""; - if(json[i].prezzi[j].isSelf === "1") { + if(json[i].prices[j].price_self) { txt += "(self)"; } else { txt += ""; } txt += ""; txt += ""; } txt += ""; txt += "

+ " + L10N.actionFavorites + ""; txt += "segnala errore

"; - var m = L.marker([json[i].latitudine, json[i].longitudine], { + var m = L.marker([json[i].station_lat, json[i].station_lon], { bounceOnAdd: true, bounceOnAddOptions: {duration: 500, height: 100}, bounceOnAddCallback: function() {} - }).bindPopup(txt).addTo(map).options.idImpianto = json[i].idImpianto; + }) + .bindPopup(txt) + .addTo(map) + .options; + + m.station_ID = json[i].station_ID; } postCallback && postCallback(bounds, json); }); } function suggest_nominatim_addresses(query) { $.ajax({ url: "https://nominatim.openstreetmap.org/search", jsonp: "nominatimJsonp", dataType: "jsonp", data: { q: query, format: "json", json_callback: "nominatimJsonp" } }); } function nominatimJsonp(json) { var $searchResults = $("#modal-search-addr-results"); var $list = $searchResults.find("ol").empty(); if(json.length > 0) { for(i=0; i") .append( $('') .text(json[i].display_name) .data("latLng", {lat: json[i].lat, lng: json[i].lon}) .data("bounds", json[i].boundingbox) .click(function(event) { $searchResults.closeModal(); var latLng = $(this).data("latLng"); var bounds = $(this).data("bounds"); var adaptedBounds = [ [bounds[0], bounds[3]], [bounds[1], bounds[2]] ]; map.fitBounds( adaptedBounds ); getMarkersInBounds(); Overworld.hide(); event.preventDefault(); }) ) .append( $("
") ) .append( $("") .text(json[i].licence) ) ); } // Result links $searchResults.find("a").click(function() { $searchResults.closeModal(); }); } else { $list.append( $("
  • ").text( L10N.noAddressFound ) ); } $searchResults.openModal(); } function enfatizeLatLng(latLng, duration, radius) { duration = duration || 2000; radius = radius || 100; var circle = L.circle(latLng, radius).addTo(map); window.setTimeout(function () { map.removeLayer(circle); }, duration); } function fitDocument() { var w = $("body").width(); var h = $("body").height(); $("#map").width( w ).height( h ); } // http://stackoverflow.com/questions/610406/javascript-equivalent-to-printf-string-format String.prototype.formatUnicorn = function() { var str = this.toString(); if(!arguments.length) { return str; } var args = typeof arguments[0], args = (("string" == args || "number" == args) ? arguments : arguments[0]); for(var arg in args) { str = str.replace(RegExp("\\{" + arg + "\\}", "gi"), args[arg]); } return str; } $(window).resize(function() { // jQuery's windowResize is a bit crazy setTimeout(fitDocument, 500); setTimeout(fitDocument, 2000); setTimeout(fitDocument, 4000); }); $(document).on("click", ".add-favorites", function() { toast( L10N.addedToFavorites ); }); $(document).on("click", ".segnala-errore", function() { toast( L10N.errorSent ); }); diff --git a/includes/header.php b/includes/header.php index cd81a7e..ae3d9e7 100755 --- a/includes/header.php +++ b/includes/header.php @@ -1,65 +1,68 @@ . */ function get_header($uid, $args = array()) { $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->getExtra('description') + $menuEntry->get('description') ) . "\n"; } diff --git a/index.php b/index.php index d3bf54a..83292bf 100755 --- a/index.php +++ b/index.php @@ -1,93 +1,92 @@ . */ // The map require 'load.php'; enqueue_css('leaflet'); -enqueue_css('my-facile'); +enqueue_css('my-fuel-map'); enqueue_js('jquery.ui'); enqueue_js('leaflet'); enqueue_js('leaflet.bouncemarker'); -enqueue_js('my-facile'); +enqueue_js('my-fuel-map'); get_header('map'); ?>

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

    + ) ?>

    navigation
    , 2015. # msgid "" msgstr "" "Project-Id-Version: it.reyboz.fuel\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-11-18 22:06+0100\n" +"POT-Creation-Date: 2015-12-21 12:37+0100\n" "PO-Revision-Date: 2015-11-18 07:22+0100\n" "Last-Translator: \n" "Language-Team: \n" "Language: en\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 1.8.6\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: about.php:9 +#: about.php:26 msgid "Il Team «Il Cloud non esiste»" msgstr "“Cloud storage doesn’t exist” team" -#: about.php:10 +#: about.php:27 msgid "" "«Il Cloud non esiste» è il team che in 24 ore ha realizzato il progetto " "vincitore dell'Hackaton di Facile.it 2015 presentando un comparatore di " "prezzi dei carburanti." msgstr "" "“Cloud storage doesn’t exist” is the team that in 24 hours has developed the " "winning project of the Facile.it 2015 Hackathon, presenting a fuel price " "comparator." -#: about.php:15 about.php:24 +#: about.php:32 about.php:41 #, php-format msgid "Articolo su %s" msgstr "Article on %s" -#: about.php:16 about.php:25 +#: about.php:33 about.php:42 #, php-format msgid "Leggi l'articolo su %s" msgstr "Read the article on %s" -#: about.php:41 +#: about.php:58 msgid "Offensive Security Entusiast" msgstr "Offensive Security Entusiast" -#: about.php:57 +#: about.php:74 msgid "Junior Hackathon hacker" msgstr "Junior Hackathon hacker" -#: about.php:58 about.php:75 +#: about.php:75 about.php:92 msgid "Smartphone & web developer." msgstr "Smartphone & web developer." -#: about.php:74 +#: about.php:91 msgid "Very Junior Hackathon hacker" msgstr "Very Junior Hackathon hacker" -#: about.php:91 +#: about.php:108 msgid "Developer - DBA & Marketing Specialist" msgstr "Developer - DBA & Marketing Specialist" -#: about.php:92 +#: about.php:109 msgid "" "Sviluppo dell'importatore-bridge in PHP, MySQL fra i dati dello Sviluppo " "Economico. Presentatore del progetto." msgstr "" "Developed the PHP bridge, MySQL using the data supplied by Economic " "Development. Presenter of the project" -#: about.php:108 +#: about.php:125 msgid "Tactical Banana" msgstr "Tactical Banana" -#: about.php:109 +#: about.php:126 msgid "«Valerio per favore scrivi qui qualcosa di divertente». -Fatto-" msgstr "«Valerio please write down something funny». -Done-" -#: about.php:125 +#: about.php:142 msgid "No-sleep Tech Orchestrator" msgstr "No-sleep Tech Orchestrator" -#: about.php:126 +#: about.php:143 msgid "Sviluppo del frontend in PHP, MySQL e JavaScript." msgstr "Developed front-end in PHP, MySQL and JavaScript" -#: about.php:136 +#: about.php:153 msgid "Tecnologie utilizzate" msgstr "Technologies" -#: about.php:140 +#: about.php:157 msgid "Nome tecnologia" msgstr "Technology name" -#: about.php:141 +#: about.php:158 msgid "Ruolo" msgstr "Team role" -#: about.php:142 +#: about.php:159 msgid "Licenza di software libero" msgstr "Free software license" -#: about.php:148 +#: about.php:165 msgid "Server web" msgstr "Server web" -#: about.php:153 +#: about.php:170 msgid "Framework casereccio in PHP" msgstr "Homemade framework in PHP" -#: about.php:158 +#: about.php:175 msgid "Ambiente server GNU/Linux" msgstr "GNU/Linux server environment" -#: about.php:163 +#: about.php:180 msgid "" "Libreria JavaScript per l'attraversamento, manipolazione e animazioni del DOM" msgstr "JavaScript library for manipulating and animating DOM" -#: about.php:168 +#: about.php:185 msgid "Libreria JavaScript per mappe interattive" msgstr "JavaScript framework for interactive maps" -#: about.php:173 +#: about.php:190 msgid "Framework responsivo ispirato al Material Design" msgstr "Responsive framework inspired by Material Design" -#: about.php:178 +#: about.php:195 msgid "Set di icone Material Design" msgstr "Material Design icon set" -#: about.php:188 +#: about.php:205 msgid "" "Prezzi praticati e anagrafica degli impianti di carburante dal Ministero " "dello Sviluppo Economico italiano." msgstr "" -#: about.php:189 +#: about.php:206 msgid "Carburanti - Prezzi praticati e anagrafica degli impianti" msgstr "Fuels - prices and details info about fuel stations" -#: about.php:193 +#: about.php:210 msgid "Mappa collaborativa globale" msgstr "Collaborative global map" -#: about.php:198 +#: about.php:215 msgid "Logo e favicon" msgstr "Logo and favicon" -#: about.php:199 +#: about.php:216 msgid "Pubblico dominio" msgstr "Public domain" -#: about.php:203 +#: about.php:220 msgid "Pre-processore di ipertesti" msgstr "Pre-processor of hypertexts" -#: about.php:204 +#: about.php:221 msgid "Licenza PHP" msgstr "PHP licence" -#: about.php:208 +#: about.php:225 msgid "" "Software di presentazione HTML utilizzato per presentare il progetto " "all'hackaton" msgstr "" "Software for HTML presentations, used to present the project at the hackathon" -#: about.php:209 +#: about.php:226 msgid "Licenza Reveal.JS" msgstr "Reveal.JS license" -#: about.php:215 +#: about.php:232 msgid "Torna alla mappa" msgstr "Back to the map" -#: about.php:215 +#: about.php:232 #, php-format msgid "Torna a %s" msgstr "Back to %s" #: index.php:48 #, php-format msgid "Confronta velocemente i prezzi fra %s stazioni di rifornimento." msgstr "Quickly compare fuel prices between %s stations." -#: index.php:79 +#: index.php:72 +msgid "Risultati ricerca" +msgstr "" + +#: index.php:78 msgid "La tua segnalazione è preziosa. Per ora però sara ignorata <_<" msgstr "Your report is important to us. " -#: index.php:80 +#: index.php:79 msgid "Aggiunta ai preferiti... Se funzionassero <_<" msgstr "Added to favorites. " -#: index.php:81 +#: index.php:80 msgid "Geolocalizzazione fallita" msgstr "I couldn’t locate yourself" -#: index.php:82 +#: index.php:81 msgid "Trova la tua zona, zomma!" msgstr "Find your area, zoom in!" -#: index.php:83 +#: index.php:82 msgid "Vedo molte stazioni. Fai zoom per scoprirle" msgstr "I see many stations in this area. Zoom in" -#: index.php:84 +#: index.php:83 msgid "Nessuna pompa di benzina in questa zona" msgstr "No fuel station found in this area." -#: index.php:85 +#: index.php:84 msgid "Fai zoom! Qui ci sono {n} stazioni" msgstr "Zoom in! There are {n} stations" -#: index.php:86 +#: index.php:85 msgid "Litri ogni {euro} € per {station}" msgstr "{euro}/liters per {station}" -#: index.php:87 +#: index.php:86 msgid "Preferiti" msgstr "Favorites" -#: index.php:88 +#: index.php:87 msgid "Segnala errore" msgstr "Report error" -#: index.php:89 +#: index.php:88 msgid "Nessun indirizzo trovato. Riprova con parole più semplici." msgstr "No address found. Try with simpler words." -#: load-post.php:49 +#: load-post.php:55 msgid "Compara carburanti" msgstr "Compare fuel prices" -#: load-post.php:50 +#: load-post.php:56 msgid "Confronta i prezzi dei carburanti" msgstr "Compare fuels prices" -#: load-post.php:106 +#: load-post.php:112 msgid "La mappa" msgstr "The map" -#: load-post.php:111 +#: load-post.php:117 msgid "Informazioni sulla piattaforma" msgstr "Platform information" +#: cli/import-functions.php:76 +#, php-format +msgid "La stazione miseID %d doveva essere già stata inserita" +msgstr "" + +#: cli/import.php:73 +#, php-format +msgid "Utilizzo: %s FILE_STAZIONI.csv PREZZI_ALLE_8.csv" +msgstr "" + +#: cli/import.php:84 +msgid "File delle stazioni non trovato" +msgstr "" + +#: cli/import.php:88 +msgid "Impossibile aprire il file delle stazioni" +msgstr "" + +#: cli/import.php:121 +msgid "File dei prezzi non trovato" +msgstr "" + +#: cli/import.php:125 +msgid "Impossibile aprire il file dei prezzi" +msgstr "" + +#: cli/import.php:153 +#, php-format +msgid "" +"Errore:\n" +"\t%s.\n" +msgstr "" + #: includes/functions.php:40 msgid "Entra in contatto" msgstr "Get in touch" #: includes/functions.php:40 #, php-format msgid "Mettiti in contatto con %s" msgstr "Get in touch with %s" #: includes/functions.php:44 #, php-format msgid "Informazioni legali su %s" msgstr "Legal information on %s" diff --git a/l10n/fuel.reyboz.it.pot b/l10n/fuel.reyboz.it.pot index 4c8b81f..d35ce30 100644 --- a/l10n/fuel.reyboz.it.pot +++ b/l10n/fuel.reyboz.it.pot @@ -1,254 +1,291 @@ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR Valerio Bozzolan # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: fuel.reyboz.it\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-11-18 22:06+0100\n" +"POT-Creation-Date: 2015-12-21 12:37+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: about.php:9 +#: about.php:26 msgid "Il Team «Il Cloud non esiste»" msgstr "" -#: about.php:10 +#: about.php:27 msgid "" "«Il Cloud non esiste» è il team che in 24 ore ha realizzato il progetto " "vincitore dell'Hackaton di Facile.it 2015 presentando un comparatore di " "prezzi dei carburanti." msgstr "" -#: about.php:15 about.php:24 +#: about.php:32 about.php:41 #, php-format msgid "Articolo su %s" msgstr "" -#: about.php:16 about.php:25 +#: about.php:33 about.php:42 #, php-format msgid "Leggi l'articolo su %s" msgstr "" -#: about.php:41 +#: about.php:58 msgid "Offensive Security Entusiast" msgstr "" -#: about.php:57 +#: about.php:74 msgid "Junior Hackathon hacker" msgstr "" -#: about.php:58 about.php:75 +#: about.php:75 about.php:92 msgid "Smartphone & web developer." msgstr "" -#: about.php:74 +#: about.php:91 msgid "Very Junior Hackathon hacker" msgstr "" -#: about.php:91 +#: about.php:108 msgid "Developer - DBA & Marketing Specialist" msgstr "" -#: about.php:92 +#: about.php:109 msgid "" "Sviluppo dell'importatore-bridge in PHP, MySQL fra i dati dello Sviluppo " "Economico. Presentatore del progetto." msgstr "" -#: about.php:108 +#: about.php:125 msgid "Tactical Banana" msgstr "" -#: about.php:109 +#: about.php:126 msgid "«Valerio per favore scrivi qui qualcosa di divertente». -Fatto-" msgstr "" -#: about.php:125 +#: about.php:142 msgid "No-sleep Tech Orchestrator" msgstr "" -#: about.php:126 +#: about.php:143 msgid "Sviluppo del frontend in PHP, MySQL e JavaScript." msgstr "" -#: about.php:136 +#: about.php:153 msgid "Tecnologie utilizzate" msgstr "" -#: about.php:140 +#: about.php:157 msgid "Nome tecnologia" msgstr "" -#: about.php:141 +#: about.php:158 msgid "Ruolo" msgstr "" -#: about.php:142 +#: about.php:159 msgid "Licenza di software libero" msgstr "" -#: about.php:148 +#: about.php:165 msgid "Server web" msgstr "" -#: about.php:153 +#: about.php:170 msgid "Framework casereccio in PHP" msgstr "" -#: about.php:158 +#: about.php:175 msgid "Ambiente server GNU/Linux" msgstr "" -#: about.php:163 +#: about.php:180 msgid "" "Libreria JavaScript per l'attraversamento, manipolazione e animazioni del DOM" msgstr "" -#: about.php:168 +#: about.php:185 msgid "Libreria JavaScript per mappe interattive" msgstr "" -#: about.php:173 +#: about.php:190 msgid "Framework responsivo ispirato al Material Design" msgstr "" -#: about.php:178 +#: about.php:195 msgid "Set di icone Material Design" msgstr "" -#: about.php:188 +#: about.php:205 msgid "" "Prezzi praticati e anagrafica degli impianti di carburante dal Ministero " "dello Sviluppo Economico italiano." msgstr "" -#: about.php:189 +#: about.php:206 msgid "Carburanti - Prezzi praticati e anagrafica degli impianti" msgstr "" -#: about.php:193 +#: about.php:210 msgid "Mappa collaborativa globale" msgstr "" -#: about.php:198 +#: about.php:215 msgid "Logo e favicon" msgstr "" -#: about.php:199 +#: about.php:216 msgid "Pubblico dominio" msgstr "" -#: about.php:203 +#: about.php:220 msgid "Pre-processore di ipertesti" msgstr "" -#: about.php:204 +#: about.php:221 msgid "Licenza PHP" msgstr "" -#: about.php:208 +#: about.php:225 msgid "" "Software di presentazione HTML utilizzato per presentare il progetto " "all'hackaton" msgstr "" -#: about.php:209 +#: about.php:226 msgid "Licenza Reveal.JS" msgstr "" -#: about.php:215 +#: about.php:232 msgid "Torna alla mappa" msgstr "" -#: about.php:215 +#: about.php:232 #, php-format msgid "Torna a %s" msgstr "" #: index.php:48 #, php-format msgid "Confronta velocemente i prezzi fra %s stazioni di rifornimento." msgstr "" -#: index.php:79 +#: index.php:72 +msgid "Risultati ricerca" +msgstr "" + +#: index.php:78 msgid "La tua segnalazione è preziosa. Per ora però sara ignorata <_<" msgstr "" -#: index.php:80 +#: index.php:79 msgid "Aggiunta ai preferiti... Se funzionassero <_<" msgstr "" -#: index.php:81 +#: index.php:80 msgid "Geolocalizzazione fallita" msgstr "" -#: index.php:82 +#: index.php:81 msgid "Trova la tua zona, zomma!" msgstr "" -#: index.php:83 +#: index.php:82 msgid "Vedo molte stazioni. Fai zoom per scoprirle" msgstr "" -#: index.php:84 +#: index.php:83 msgid "Nessuna pompa di benzina in questa zona" msgstr "" -#: index.php:85 +#: index.php:84 msgid "Fai zoom! Qui ci sono {n} stazioni" msgstr "" -#: index.php:86 +#: index.php:85 msgid "Litri ogni {euro} € per {station}" msgstr "" -#: index.php:87 +#: index.php:86 msgid "Preferiti" msgstr "" -#: index.php:88 +#: index.php:87 msgid "Segnala errore" msgstr "" -#: index.php:89 +#: index.php:88 msgid "Nessun indirizzo trovato. Riprova con parole più semplici." msgstr "" -#: load-post.php:49 +#: load-post.php:55 msgid "Compara carburanti" msgstr "" -#: load-post.php:50 +#: load-post.php:56 msgid "Confronta i prezzi dei carburanti" msgstr "" -#: load-post.php:106 +#: load-post.php:112 msgid "La mappa" msgstr "" -#: load-post.php:111 +#: load-post.php:117 msgid "Informazioni sulla piattaforma" msgstr "" +#: cli/import-functions.php:76 +#, php-format +msgid "La stazione miseID %d doveva essere già stata inserita" +msgstr "" + +#: cli/import.php:73 +#, php-format +msgid "Utilizzo: %s FILE_STAZIONI.csv PREZZI_ALLE_8.csv" +msgstr "" + +#: cli/import.php:84 +msgid "File delle stazioni non trovato" +msgstr "" + +#: cli/import.php:88 +msgid "Impossibile aprire il file delle stazioni" +msgstr "" + +#: cli/import.php:121 +msgid "File dei prezzi non trovato" +msgstr "" + +#: cli/import.php:125 +msgid "Impossibile aprire il file dei prezzi" +msgstr "" + +#: cli/import.php:153 +#, php-format +msgid "" +"Errore:\n" +"\t%s.\n" +msgstr "" + #: includes/functions.php:40 msgid "Entra in contatto" msgstr "" #: includes/functions.php:40 #, php-format msgid "Mettiti in contatto con %s" msgstr "" #: includes/functions.php:44 #, php-format msgid "Informazioni legali su %s" msgstr "" diff --git a/load-post.php b/load-post.php index 104b4f2..f2c8ea4 100755 --- a/load-post.php +++ b/load-post.php @@ -1,113 +1,119 @@ . */ // Customizing Boz PHP - Another PHP framework 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; - default: - gettext_rocks('en_US'); - } +if( isset( $_GET['l'] ) ) { + $lang = $_GET['l']; + switch( $lang ) { + 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': + 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-facile', + 'my-fuel-map', URL . _ . INCLUDES . '/facile.js' ); register_css( 'materialize', URL . _ . MATERIALIZE . '/css/materialize.min.css' ); register_css( 'leaflet', URL . _ . LEAFLET . '/leaflet.css' ); register_css( - 'my-facile', + 'my-fuel-map', URL . _ . INCLUDES . '/facile.css' ); register_css( 'materialize.icons', 'https://fonts.googleapis.com/icon?family=Material+Icons' ); add_menu_entries([ new MenuEntry( 'map', URL, _("La mappa") ), new MenuEntry( 'about', URL . '/about.php', _("Informazioni sulla piattaforma") ) ]); diff --git a/load-sample.php b/load-sample.php new file mode 100755 index 0000000..8a8ec61 --- /dev/null +++ b/load-sample.php @@ -0,0 +1,36 @@ +. + */ + +// Basic settings for Boz PHP - Another PHP framework + +// Database info +$database = ''; +$username = ''; +$password = ''; +$location = ''; + +// Database table prefix +$prefix = ''; + +define('ABSPATH', __DIR__); +define('ROOT', ''); +define('DEBUG', true); +define('USE_DB_OPTIONS', false); + +require '/usr/share/boz-php-another-php-framework/load.php';