/** * Determines whether the browser's operating system is Macintosh. * @return boolean True if the brower's OS is mac, false otherwise. */ function is_browser_os_mac() { $agent_strs = array('mac', '68000', 'ppc', 'powerpc'); $return = string_in_array_value(get_user_agent_string(), $agent_strs); if (DEBUG_ENABLED) { debug_log('is_browser_os_windows(): Entered with (), Returning (%s)', 1, $return); } return $return; }
/** * Scrive alcune informazioni sul client: * - UserAgent * - indirizzo IP * Il livello di debug e' DEBUG_DUMP. */ public function client_info() { $info = array('useragent' => get_user_agent_string(), 'clientip' => get_client_ip()); $this->vardump($info, 'CLIENT INFO'); unset($info); }
/** * Determine the OS for the browser */ function is_browser($type) { $agents = array(); $agents['unix'] = array('sunos', 'sunos 4', 'sunos 5', 'i86', 'irix', 'irix 5', 'irix 6', 'irix6', 'hp-ux', '09.', '10.', 'aix', 'aix 1', 'aix 2', 'aix 3', 'aix 4', 'inux', 'sco', 'unix_sv', 'unix_system_v', 'ncr', 'reliant', 'dec', 'osf1', 'dec_alpha', 'alphaserver', 'ultrix', 'alphastation', 'sinix', 'freebsd', 'bsd', 'x11', 'vax', 'openvms'); $agents['win'] = array('win', 'win95', 'windows 95', 'win16', 'windows 3.1', 'windows 16-bit', 'windows', 'win31', 'win16', 'winme', 'win2k', 'winxp', 'win98', 'windows 98', 'win9x', 'winnt', 'windows nt', 'win32', '32bit'); $agents['mac'] = array('mac', '68000', 'ppc', 'powerpc'); if (isset($agents[$type])) { return in_array(get_user_agent_string(), $agents[$type]); } else { return false; } }
/** * Returns the size of a file without downloading it, or -1 if the file * size could not be determined. * * @param $url - The location of the remote file to download. Cannot * be null or empty. * * @return The size of the file referenced by $url, or -1 if the size * could not be determined. */ function curl_get_file_size($url) { // Assume failure. $result = -1; $curl = curl_init($url); // Issue a HEAD request and follow any redirects. curl_setopt($curl, CURLOPT_NOBODY, true); curl_setopt($curl, CURLOPT_HEADER, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_USERAGENT, get_user_agent_string()); $data = curl_exec($curl); curl_close($curl); if ($data) { $content_length = "unknown"; $status = "unknown"; if (preg_match("/^HTTP\\/1\\.[01] (\\d\\d\\d)/", $data, $matches)) { $status = (int) $matches[1]; } if (preg_match("/Content-Length: (\\d+)/", $data, $matches)) { $content_length = (int) $matches[1]; } // http://en.wikipedia.org/wiki/List_of_HTTP_status_codes if ($status == 200 || $status > 300 && $status <= 308) { $result = $content_length; } } return $result; }