Ejemplo n.º 1
0
 /**
  * 紀錄管理者登入IP
  * 
  * @param string 管理者帳號
  * @param string IP Address
  * @return int
  * @access public
  */
 public function updateLoginIp($account, $ip)
 {
     $now = date('Y-m-d H:i:s');
     if (!is_object($this->pdo)) {
         $this->connect($DBConfig["Master"]);
     }
     try {
         $query = "UPDATE {$this->_name} \n                SET `first_ip` = `last_ip`, `first_time` = `last_time`, `last_ip` = :ip, `last_time` = :now \n                WHERE `account` = :account LIMIT 1";
         $stmt = $this->pdo->prepare($query);
         $stmt->bindParam(":account", $account);
         $stmt->bindParam(":ip", $ip);
         $stmt->bindParam(":now", $now);
         $res = $stmt->execute();
         if ($res === true) {
             $result = $stmt->rowCount();
         } else {
             // log it
             parent::logResError($this->_name, "updateLoginIp", $res);
             return false;
         }
     } catch (PDOException $e) {
         // log it
         parent::logPDOError($this->_name, "updateLoginIp", $e);
         return false;
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * 刪除已經發出的酷朋券
  * 
  * @return int $affectedRow
  * @access public
  */
 public function deleteEmailCoupon($coupon)
 {
     if (!is_object($this->pdo)) {
         $this->connect($DBConfig["Master"]);
     }
     try {
         $query = "DELETE FROM {$this->_name} WHERE `coupon` = :coupon";
         $stmt = $this->pdo->prepare($query);
         $stmt->bindParam(":coupon", $coupon);
         $res = $stmt->execute();
         if ($res === true) {
             $result = $stmt->rowCount();
         } else {
             // log it
             parent::logResError($this->_name, "deleteEmailCoupon", $res);
             return false;
         }
     } catch (PDOException $e) {
         // log it
         parent::logPDOError($this->_name, "deleteEmailCoupon", $e);
         return false;
     }
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * 使用者功能權限
  * 
  * @param array $param_array 
  * @return boolean
  * @access public
  */
 public function getPermissionById($admin_id)
 {
     if (!is_object($this->pdo)) {
         $this->connect($DBConfig["Master"]);
     }
     try {
         $query = "SELECT * FROM {$this->_name} WHERE `admin_id` = :admin_id LIMIT 1";
         $stmt = $this->pdo->prepare($query);
         $stmt->bindParam(":admin_id", $admin_id);
         $res = $stmt->execute();
         if ($res === true) {
             $result = $stmt->fetch(PDO::FETCH_ASSOC);
         } else {
             // log it
             parent::logResError($this->_name, "getPermissionById", $res);
             return false;
         }
     } catch (PDOException $e) {
         // log it
         parent::logPDOError($this->_name, "getPermissionById", $e);
         return false;
     }
     return $result;
 }
Ejemplo n.º 4
0
 /**
  * 取得某日的 LOG 數
  * 
  * @param string $date 
  * @return int $counts
  * @access public
  */
 public function countLikeLogByDate($date)
 {
     if (!is_object($this->pdo)) {
         $this->connect($DBConfig["Master"]);
     }
     try {
         $query = "SELECT COUNT(*) AS `Counts` FROM {$this->_name} \n            WHERE `log_date` = :log_date LIMIT 1";
         $stmt = $this->pdo->prepare($query);
         $stmt->bindParam(":log_date", $date);
         $res = $stmt->execute();
         if ($res === true) {
             $result = $stmt->fetch(PDO::FETCH_ASSOC);
         } else {
             // log it
             parent::logResError($this->_name, "countLikeLogByDate", $res);
             return false;
         }
     } catch (PDOException $e) {
         // log it
         parent::logPDOError($this->_name, "countLikeLogByDate", $e);
         return false;
     }
     return $result['Counts'];
 }
Ejemplo n.º 5
0
 /**
  * 更新使用者加入進戲資訊
  * 
  * @param array $param_array 
  * @return boolean
  * @access public
  */
 public function updateUserJoin($fbId)
 {
     if (!is_object($this->pdo)) {
         $this->connect($DBConfig["Master"]);
     }
     try {
         $query = "UPDATE {$this->_name} SET game_join = 1 WHERE fb_id = :fbId";
         $stmt = $this->pdo->prepare($query);
         $stmt->bindParam(":fbId", $fbId);
         $res = $stmt->execute();
         if ($res === true) {
             $result = $stmt->rowCount();
         } else {
             // log it
             parent::logResError($this->_name, "updateUserJoin", $res);
             return false;
         }
     } catch (PDOException $e) {
         // log it
         parent::logPDOError($this->_name, "updateUserJoin", $e);
         return false;
     }
     return $result;
 }
Ejemplo n.º 6
0
 /**
  * 取出該FB_ID的電子信箱
  * 
  * @return array
  * @access public
  */
 public function getByLotteryEmail($fbId)
 {
     if (!is_object($this->pdo)) {
         $this->connect($DBConfig["Master"]);
     }
     try {
         $query = "SELECT  *  FROM {$this->_name} WHERE fb_id = :fbId ";
         $stmt = $this->pdo->prepare($query);
         $stmt->bindParam(":fbId", $fbId);
         $res = $stmt->execute();
         if ($res === true) {
             $result = $stmt->fetch(PDO::FETCH_ASSOC);
         } else {
             // log it
             parent::logResError($this->_name, "getByLotteryEmail", $res);
             return false;
         }
     } catch (PDOException $e) {
         // log it
         parent::logPDOError($this->_name, "getByLotteryEmail", $e);
         return false;
     }
     return $result;
 }
Ejemplo n.º 7
0
 /**
  * 新增 LOG
  * 
  * @param array $param 
  * @return int $LastInsertId
  * @access public
  */
 public function addShareLog($param)
 {
     if (!is_object($this->pdo)) {
         $this->connect($DBConfig["Master"]);
     }
     try {
         $query = "INSERT INTO {$this->_name}(`fb_id`, `ip`, `log_date`) VALUES(?, ?, ?)";
         $stmt = $this->pdo->prepare($query);
         $stmt->bindParam(1, $param["fb_id"]);
         $stmt->bindParam(2, $param["ip"]);
         $stmt->bindParam(3, $param["today"]);
         $res = $stmt->execute();
         if ($res === true) {
             $result = $this->pdo->lastInsertId();
         } else {
             // log it
             parent::logResError($this->_name, "addShareLog", $res);
             return false;
         }
     } catch (PDOException $e) {
         // log it
         parent::logPDOError($this->_name, "addShareLog", $e);
         return false;
     }
     return $result;
 }
Ejemplo n.º 8
0
 /**
  * 新增 LOGIN 點擊 LOG
  * 
  * @return int
  * @access public
  */
 public function addLoginClickLog()
 {
     $today = date("Y-m-d");
     if (!is_object($this->pdo)) {
         $this->connect($DBConfig["Master"]);
     }
     try {
         $query = "INSERT INTO {$this->_name} (`log_date`, `login_click`) VALUES (:today, 1) \n                      ON DUPLICATE KEY UPDATE `login_click` = `login_click` + 1 ";
         $stmt = $this->pdo->prepare($query);
         $stmt->bindParam(":today", $today);
         $res = $stmt->execute();
         if ($res === true) {
             $result = $stmt->rowCount();
         } else {
             // log it
             parent::logResError($this->_name, "addLoginClickLog", $res);
             return false;
         }
     } catch (PDOException $e) {
         // log it
         parent::logPDOError($this->_name, "addLoginClickLog", $e);
         return false;
     }
     return $result;
 }
Ejemplo n.º 9
0
 /**
  * 取得好友列表
  * 
  * @param int Flag Join  
  * @return array
  * @access public
  */
 public function listFriend($fbId)
 {
     if (!is_object($this->pdo)) {
         $this->connect($DBConfig["Master"]);
     }
     try {
         $query = "SELECT friend_id FROM {$this->_name} WHERE fb_id = :fbId GROUP BY friend_id";
         $stmt = $this->pdo->prepare($query);
         $stmt->bindParam(":fbId", $fbId);
         $res = $stmt->execute();
         if ($res === true) {
             $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
             $list = array();
             foreach ($result as $row) {
                 $list[] = intval($row['friend_id']);
             }
         } else {
             // log it
             parent::logResError($this->_name, "listFriend", $res);
             return false;
         }
     } catch (PDOException $e) {
         // log it
         parent::logPDOError($this->_name, "listFriend", $e);
         return false;
     }
     return $list;
 }
Ejemplo n.º 10
0
 /**
  * 新增資料
  * 
  * @param array 日期(Y-m-d)
  * @return int 最後一筆的ID
  * @access public
  */
 public function add($data)
 {
     if (!is_object($this->pdo)) {
         $this->connect($DBConfig["Master"]);
     }
     try {
         $query = "INSERT IGNORE INTO {$this->_name} (fb_id, sender_id, game_join, create_date, create_time) \n                      VALUES (:fbId, :senderId, :join, :createDate, :createTime)";
         $stmt = $this->pdo->prepare($query);
         $stmt->bindParam(":fbId", $data["fbId"]);
         $stmt->bindParam(":senderId", $data["senderId"]);
         $stmt->bindParam(":join", $data["join"]);
         $stmt->bindParam(":createDate", $data["today"]);
         $stmt->bindParam(":createTime", $data["now"]);
         $res = $stmt->execute();
         if ($res === true) {
             $result = $this->pdo->lastInsertId();
         } else {
             // log it
             parent::logResError($this->_name, "add", $res);
             return false;
         }
     } catch (PDOException $e) {
         // log it
         parent::logPDOError($this->_name, "add", $e);
         return false;
     }
     return $result;
 }
Ejemplo n.º 11
0
 /**
  * 取得加入遊戲的玩家列表 BY Day
  * 
  * @param  
  * @return list
  * @access public
  */
 public function listGameUser($date)
 {
     if (!is_object($this->pdo)) {
         $this->connect($DBConfig["Master"]);
     }
     try {
         $query = "SELECT fb_id FROM {$this->_name} GROUP BY fb_id";
         $stmt = $this->pdo->prepare($query);
         $res = $stmt->execute();
         if ($res === true) {
             $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
         } else {
             // log it
             parent::logResError($this->_name, "listGameUser", $res);
             return false;
         }
     } catch (PDOException $e) {
         // log it
         parent::logPDOError($this->_name, "listGameUser", $e);
         return false;
     }
     return $result;
 }
Ejemplo n.º 12
0
 /**
  * 
  * 
  * @param array $param_array 
  * @return boolean
  * @access public
  */
 public function listByMenuLink($menuLink)
 {
     if (!is_object($this->pdo)) {
         $this->connect();
     }
     try {
         $query = "SELECT * FROM {$this->_name} \n                        WHERE `menu_link` = :menu_link AND `parent_id` <> '0' AND `type` = '1' \n                        ORDER BY `sort` ASC, `menu_id` ASC";
         $stmt = $this->pdo->prepare($query);
         $stmt->bindParam(":menu_link", $menuLink);
         $res = $stmt->execute();
         if ($res === true) {
             $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
         } else {
             return false;
         }
     } catch (PDOException $e) {
         // log it
         parent::logPDOError($this->_name, "getMenuList", $e);
         return false;
     }
     return $result;
 }
 /**
  * 取得某日的 LOG 數
  * 
  * @param string $date 
  * @return int $counts
  * @access public
  */
 public function listInviteFriend()
 {
     if (!is_object($this->pdo)) {
         $this->connect($DBConfig["Master"]);
     }
     try {
         $query = "SELECT `friend_id` FROM {$this->_name} GROUP BY `friend_id`";
         $stmt = $this->pdo->prepare($query);
         $stmt->bindParam(":friend_enter_date", $date);
         $res = $stmt->execute();
         if ($res === true) {
             $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
         } else {
             // log it
             parent::logResError($this->_name, "listInviteFriend", $res);
             return false;
         }
     } catch (PDOException $e) {
         // log it
         parent::logPDOError($this->_name, "listInviteFriend", $e);
         return false;
     }
     return $result;
 }
Ejemplo n.º 14
0
 /**
  * 新增關卡開始LOG
  * 
  * @param array 資料陣列
  * @return int
  * @access public
  */
 public function addActStartLog($data)
 {
     if (!is_object($this->pdo)) {
         $this->connect($DBConfig["Master"]);
     }
     try {
         $query = "INSERT IGNORE INTO {$this->_name} (`fb_id`, `ip`, `act`, `log_date`) \n                        VALUES (:fbId, :ip, :act, :log_date)";
         $stmt = $this->pdo->prepare($query);
         $stmt->bindParam(":fbId", $data['fbId']);
         $stmt->bindParam(":ip", $data['ip']);
         $stmt->bindParam(":act", $data['act']);
         $stmt->bindParam(":log_date", $data['today']);
         $res = $stmt->execute();
         if ($res === true) {
             $result = $this->pdo->lastInsertId();
         } else {
             // log it
             parent::logResError($this->_name, "add", $res);
             return false;
         }
     } catch (PDOException $e) {
         // log it
         parent::logPDOError($this->_name, "add", $e);
         return false;
     }
     return $result;
 }