Refactor stopsList page
[busui.git] / updatedb.php
blob:a/updatedb.php -> blob:b/updatedb.php
--- a/updatedb.php
+++ b/updatedb.php
@@ -1,9 +1,13 @@
 <?php
-include('lib/common-db.inc.php');
+if ( php_sapi_name() == "cli") {
+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 ($unzip) {
 if (is_resource($zip)) {
 	while ($zip_entry = zip_read($zip)) {
 		$fp = fopen($tmpdir . zip_entry_name($zip_entry) , "w");
@@ -16,6 +20,7 @@
 		}
 	}
 	zip_close($zip);
+}
 }
                         
 foreach (scandir($tmpdir) as $file) {
@@ -53,5 +58,6 @@
 
 	}
 }
+}
 ?>