From: Edward Date: Tue, 13 May 2014 11:23:01 +0000 (+0800) Subject: Import/Core_geoip.php X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=commitdiff_plain;h=e3d7da20592265e94f54542aefbbe810cbb816a5 Import/Core_geoip.php --- diff --git a/Import/Core_geoip.php b/Import/Core_geoip.php index 4edb6aa2..0a7c0e14 100644 --- a/Import/Core_geoip.php +++ b/Import/Core_geoip.php @@ -25,6 +25,10 @@ class Pman_Core_Import_Core_geoip extends Pman_Roo $this->get(); } + var $processed = 0; + var $total = 0; + var $echo = ''; + function get() { @@ -69,6 +73,8 @@ class Pman_Core_Import_Core_geoip extends Pman_Roo $cols = false; + $processed = 0 + while(false !== ($n = fgetcsv($fh,10000, ',', '"'))) { if(!array_filter($n)){ // empty row continue; @@ -99,6 +105,25 @@ class Pman_Core_Import_Core_geoip extends Pman_Roo } $this->processLocation($row); + + echo "\033[K"; // Erase to end of line: + + $echo = ''; + + if (strlen($echo)) { + echo "\033[".strlen($echo)."D"; // Move $length characters backward + } + + $echo = str_pad(ROUND(($this->processed / $this->total),2) * 100, 3, ' ', STR_PAD_LEFT) . + " % (" . str_pad(($this->processed), strlen($this->total), ' ', STR_PAD_LEFT) . + " / {$this->total}) - out {$this->out_count}"; + + + echo $this->echo; + + if($this->processed == $this->total){ + echo "\n"; + } } }