From a092e7488edcf02d20806fa89ba5d8150c072c30 Mon Sep 17 00:00:00 2001 From: QxQ Date: Fri, 22 Mar 2019 14:07:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9F=A5=E8=A9=A2=E6=A9=9FIP?= =?UTF-8?q?=E8=BD=89=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/Qcar.php | 21 +++++++++++++++++++-- models/Pks_model.php | 9 +++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) 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); + } + }