public function getDeviceFromUA_RIS($userAgent, $tolerance, UserAgentMatcher &$matcher) { $this->numQueries++; $query = sprintf("CALL " . TeraWurflConfig::$TABLE_PREFIX . "_RIS(%s,%s,%s)", $this->SQLPrep($userAgent), $tolerance, $this->SQLPrep($matcher->tableSuffix())); $res = $this->dbcon->query($query); if (!$res) { throw new Exception(sprintf("Error in DB RIS Query: %s. \nQuery: %s\n", $this->dbcon->error, $query)); exit; } $data = $res->fetch_assoc(); $this->cleanConnection(); $wurflid = $data['DeviceID']; return $wurflid == 'NULL' || is_null($wurflid) ? WurflConstants::$GENERIC : $wurflid; }
public function fullTableName() { return TeraWurflConfig::$TABLE_PREFIX . '_' . $this->userAgentMatcher->tableSuffix(); }
public function getDeviceFromUA_RIS($userAgent, $tolerance, UserAgentMatcher &$matcher) { $this->numQueries++; $stmt = $this->dbcon->prepare('CALL ' . TeraWurflConfig::$TABLE_PREFIX . '_RIS(?, ?, ?)'); if (!$stmt->execute(array($userAgent, $tolerance, $matcher->tableSuffix()))) { $error = $stmt->errorInfo(); throw new Exception(sprintf("Error in DB RIS Query: %s\n", $error[2])); } $data = $stmt->fetch(PDO::FETCH_ASSOC); $stmt = null; $wurflid = $data['DeviceID']; return $wurflid == 'NULL' || is_null($wurflid) ? WurflConstants::NO_MATCH : $wurflid; }
public function getDeviceFromUA_RIS($userAgent, $tolerance, UserAgentMatcher &$matcher) { $this->numQueries++; $query = sprintf("EXEC " . TeraWurflConfig::$TABLE_PREFIX . "_RIS %s,%s,%s", $this->SQLPrep($userAgent), $tolerance, $this->SQLPrep($matcher->tableSuffix())); $result = sqlsrv_query($this->dbcon, $query); if (!$result) { throw new Exception(sprintf("Error in DB RIS Query: %s. \nQuery: %s\n", $this->lastDBError(), $query)); } $data = sqlsrv_fetch_array($result); sqlsrv_free_stmt($result); $wurflid = $data['DeviceID']; return $wurflid == 'NULL' || is_null($wurflid) ? WurflConstants::NO_MATCH : $wurflid; }
/** * RIS == Reduction in String (reduce string one char at a time) * * @param string $userAgent * @param int $tolerance * @param UserAgentMatcher $matcher * @return string A TW Device ID */ public function getDeviceFromUA_RIS($userAgent, $tolerance, UserAgentMatcher $matcher) { $toexec = 'function(ua, tolerance, matcher) { return performRis(ua, tolerance, matcher) }'; $args = array(utf8_encode($userAgent), $tolerance, $matcher->tableSuffix()); $this->numQueries++; $response = $this->dbcon->execute($toexec, $args); if (!empty($response['ok']) && $response['ok'] == 1 && !empty($response['retval'])) { return $response['retval']; } return WurflConstants::$GENERIC; }