Refactor to use PostGIS database instead of gtfs tools
[busui.git] / updatedb.php
blob:a/updatedb.php -> blob:b/updatedb.php
--- a/updatedb.php
+++ b/updatedb.php
@@ -1,9 +1,13 @@
 <?php
+include ('include/common.inc.php');
+$conn = pg_connect("dbname=transitdata user=postgres password=snmc host=localhost") or die('connection failed');
 // Unzip cbrfeed.zip, import all csv files to database
+$unzip = true;
 $zip = zip_open(dirname(__FILE__) . "/cbrfeed.zip");
 $tmpdir = "/tmp/cbrfeed/";
 mkdir($tmpdir);
-/*if (is_resource($zip)) {
+if ($unzip) {
+if (is_resource($zip)) {
 	while ($zip_entry = zip_read($zip)) {
 		$fp = fopen($tmpdir . zip_entry_name($zip_entry) , "w");
 		if (zip_entry_open($zip, $zip_entry, "r")) {
@@ -15,12 +19,8 @@
 		}
 	}
 	zip_close($zip);
-}*/
-$conn = pg_connect("dbname=transitdata user=postgres password=snmc");
-  if (!$conn) {
-      echo "An error occured.\n";
-      exit;
-  }
+}
+}
                         
 foreach (scandir($tmpdir) as $file) {
 	if (!strpos($file, ".txt") === false) {