diff --git a/controllers/Qcar.php b/controllers/Qcar.php index 5a7ca6c..78566bb 100644 --- a/controllers/Qcar.php +++ b/controllers/Qcar.php @@ -10,8 +10,9 @@ class Qcar extends CI_Controller function __construct() { - - header('Location: http://59.120.213.62/qcar2.html'); + $client_ip = $this->my_ip(); + + header('Location: http://{$client_ip}/qcar2.html'); exit; parent::__construct(); // ----- 程式開發階段log設定 ----- @@ -67,7 +68,23 @@ class Qcar extends CI_Controller // ----- 歐付寶金流 (end) ----- } + // 取得 IP + function my_ip() + { + if (getenv('HTTP_X_FORWARDED_FOR')) + { + $ip = getenv('HTTP_X_FORWARDED_FOR'); + } + elseif (getenv('HTTP_X_REAL_IP')) + { + $ip = getenv('HTTP_X_REAL_IP'); + } + else { + $ip = $_SERVER['REMOTE_ADDR']; + } + return $ip; + } // 發生錯誤時集中在此處理 public function error_handler($errno, $errstr, $errfile, $errline, $errcontext) diff --git a/models/Pks_model.php b/models/Pks_model.php index 60da8ff..9862157 100644 --- a/models/Pks_model.php +++ b/models/Pks_model.php @@ -349,4 +349,13 @@ class Pks_model extends CI_Model $this->db->query($sql); } + //12171紅樹林特殊計數 + public function carno_updata_12171() + { + $sql = "SELECT (B.parked - A.sum_parked) as parked, (B.tot - A.sum_tot) - (B.parked - A.sum_parked) as availables FROM (SELECT SUM(parked) as sum_parked,SUM(tot) as sum_tot FROM pks_groups WHERE group_id != \"M888\" AND group_id !=\"3F\" AND group_id != \"P1\" AND group_id != \"C888\") A, pks_groups B WHERE B.group_id = \"C888\""; + $result = $this->db->query($sql)->result_array(); + $sql = "UPDATE `pks_groups` SET `parked`={$result[0]['parked']},`availables`={$result[0]['availables']} WHERE group_id = \"3F\";"; + $this->db->query($sql); + } + }