Exemplo n.º 1
0
 function lookup($user_agent)
 {
     if (owa_coreAPI::getSetting('base', 'cache_objects')) {
         owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
         $cache_obj = $this->cache->get('browscap', $this->ua);
     }
     if (!$cache_obj) {
         $custom_db = owa_coreAPI::getSetting('base', 'ua-regexes');
         if ($custom_db) {
             $parser = new UAParser($custom_db);
         } else {
             $parser = new UAParser();
         }
         $cap = $parser->parse($this->ua);
     } else {
         $cap = $cache_obj;
     }
     if (!empty($cap)) {
         if (owa_coreAPI::getSetting('base', 'cache_objects')) {
             $family = $cap->ua->family;
             if ($family != 'Default Browser') {
                 $this->cache->set('browscap', $this->ua, $cap, $this->cacheExpiration);
             }
         }
     }
     return $cap;
 }
Exemplo n.º 2
0
 function __destruct()
 {
     owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
 }
 public static function profileDisplay()
 {
     $p = owa_coreAPI::profile();
     if ($p) {
         $p->display();
     }
 }
 /**
  * Database Query
  *
  * @param 	string $sql
  * @access 	public
  *
  */
 function query($sql)
 {
     //echo "Inside query <br/>";
     $sql = str_replace("false", "0", $sql);
     //for sql server test
     $sql = str_replace("true", "1", $sql);
     if ($this->connection_status == false) {
         owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
         $this->connect();
         owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
     }
     owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
     $this->e->debug(sprintf('Query: %s', $sql));
     $this->result = '';
     $this->new_result = '';
     if (!empty($this->new_result)) {
         sqlsrv_free_stmt($this->new_result);
     }
     owa_coreAPI::profile($this, __FUNCTION__, __LINE__, $sql);
     $result = @sqlsrv_query($this->connection, $sql);
     owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
     // Log Errors only the first row
     $errors = sqlsrv_errors();
     if ($errors !== null) {
         $this->e->notice(sprintf('A SQL error occured. Error: (%s) %s %s. Query: %s', $errors[0]['SQLSTATE'], $errors[0]['code'], htmlspecialchars($errors[0]['message']), $sql));
     }
     owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
     $this->new_result = $result;
     return $this->new_result;
 }
 /**
  * Database Query
  *
  * @param 	string $sql
  * @access 	public
  * 
  */
 function query($sql)
 {
     if ($this->connection_status == false) {
         owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
         $this->connect();
         owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
     }
     owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
     $this->e->debug(sprintf('Query: %s', $sql));
     $this->result = '';
     $this->new_result = '';
     if (!empty($this->new_result)) {
         mysql_free_result($this->new_result);
     }
     owa_coreAPI::profile($this, __FUNCTION__, __LINE__, $sql);
     $result = @mysql_unbuffered_query($sql, $this->connection);
     owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
     // Log Errors
     if (mysql_errno($this->connection)) {
         $this->e->debug(sprintf('A MySQL error occured. Error: (%s) %s. Query: %s', mysql_errno($this->connection), htmlspecialchars(mysql_error($this->connection)), $sql));
     }
     owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
     $this->new_result = $result;
     return $this->new_result;
 }
 function lookup($user_agent)
 {
     if (owa_coreAPI::getSetting('base', 'cache_objects') === true) {
         owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
         $cache_obj = $this->cache->get('browscap', $this->ua);
     }
     if (!empty($cache_obj)) {
         owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
         return $cache_obj;
     } else {
         owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
         // Load browscap file into memory
         $user_browscap_file = OWA_DATA_DIR . 'browscap/php_browscap.ini';
         // check to see if a user downloaded version of the file exists
         if (file_exists($user_browscap_file)) {
             $this->browscap_db = $this->load($user_browscap_file);
         } else {
             $this->browscap_db = $this->load($this->config['browscap.ini']);
         }
         $cap = null;
         foreach ($this->browscap_db as $key => $value) {
             if ($key != '*' && !array_key_exists('Parent', $value)) {
                 continue;
             }
             $keyEreg = '^' . str_replace(array('\\', '.', '?', '*', '^', '$', '[', ']', '|', '(', ')', '+', '{', '}', '%'), array('\\\\', '\\.', '.', '.*', '\\^', '\\$', '\\[', '\\]', '\\|', '\\(', '\\)', '\\+', '\\{', '\\}', '\\%'), $key) . '$';
             if (preg_match('%' . $keyEreg . '%i', $user_agent)) {
                 $cap = array('browser_name_regex' => strtolower($keyEreg), 'browser_name_pattern' => $key) + $value;
                 $maxDeep = 8;
                 while (array_key_exists('Parent', $value) && --$maxDeep > 0) {
                     $cap += $value = $this->browscap_db[$value['Parent']];
                 }
                 break;
             }
         }
         if (!empty($cap)) {
             if ($this->config['cache_objects'] == true) {
                 if ($cap['Browser'] != 'Default Browser') {
                     $this->cache->set('browscap', $this->ua, (object) $cap, $this->cacheExpiration);
                 }
             }
         }
         return (object) $cap;
     }
 }
 function _insertQuery()
 {
     owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
     $params = $this->_fetchSqlParams('set_values');
     $count = count($params);
     $i = 0;
     $sql_cols = '';
     $sql_values = '';
     foreach ($params as $k => $v) {
         $sql_cols .= $v['name'];
         $sql_values .= "'" . $this->prepare($v['value']) . "'";
         $i++;
         // Add commas
         if ($i < $count) {
             $sql_cols .= ", ";
             $sql_values .= ", ";
         }
     }
     owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
     $this->_setSql(sprintf(OWA_SQL_INSERT_ROW, $this->_sqlParams['table'], $sql_cols, $sql_values));
     owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
     $ret = $this->_query();
     owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
     return $ret;
 }