mobil

Web : http://www.carpediem.fr */ class mobile_browser_outils { var $config; function mobile_browser_outils($debug = false) { $this->debug = $debug; $this->config->url_redir = 'http://gwt.ipigz.com'; $this->config->http_accepted = array( 'VND.WAP.WML', 'XHTML+XML', '*/*', ); $this->config->agent_denied = array( 'OfficeLiveConnector', 'Swapper', ); $this->config->agent_accepted = array( 'airness', 'alcatel', 'amoi', 'android', //'asus', 'benq', //'bird', 'blackberry', 'cdm-', 'docomo', 'ericsson', //'eten', 'gigabyte', 'Google Wireless Transcoder', //'haier', 'Huawei', 'htc_', 'htc-', 'i-mate', 'i-mobile', 'ipaq', 'iphone', 'j-phone', 'kwc-', 'kddi', 'lenovo-', //'lg', 'lg-', 'lg/', 'lge-', 'midp', 'mitsu/', 'mot-', //'motor', 'motorola', 'nokia', //'nec', 'palm', 'panasonic', 'pantech', 'philips', //'ppc', 'pg-', 'portalmmm', 'qtek', 'sagem', 'samsung', 'sanyo', 'sch-', 'sec-', 'sendo', 'sgh-', 'sharp', 'sie-', 'siemens', 'sonyericsson', 'sph-', 'symbianos', 'treo', 'telit', 'toshiba', //'tsm', 'vk-', 'vodafone', 'wap2', //'wap', 'windows ce', 'wnd', 'wonu', 'zte-', ); $this->config->regex['http_accepted'] = '/(' . str_replace(',', '|', preg_quote(implode(',', $this->config->http_accepted), '/')) . ')/i'; $this->config->regex['agent_denied'] = '/(' . str_replace(',', '|', preg_quote(implode(',', $this->config->agent_denied), '/')) . ')/i'; $this->config->regex['agent_accepted'] = '/(' . str_replace(',', '|', preg_quote(implode(',', $this->config->agent_accepted), '/')) . ')/i'; } function check_http_accept($value = NULL) { return preg_match($this->config->regex['http_accepted'], $value); } function check_http_user_agent($value = NULL) { $status = false; if (!preg_match($this->config->regex['agent_denied'], $value)) { $status = preg_match($this->config->regex['agent_accepted'], $value); } return $status; } function redirect ($params=array()) { if (empty($_SERVER['HTTP_ACCEPT']) || empty($_SERVER['HTTP_USER_AGENT'])) { return 'HTTP_HEADER_MISSING'; } if (!$this->check_http_accept($_SERVER['HTTP_ACCEPT'])) { return 'BAD_HTTP_ACCEPT'; } if (!$this->check_http_user_agent($_SERVER['HTTP_USER_AGENT'])) { return 'BAD_HTTP_USER_AGENT'; } if (!is_array($params) || empty($params)) { $params = array(); } if (array_key_exists('id', $params)) { $params['idw'] = $params['id']; } $fields = array('idw', 'tracker', 'synergie', 'niche'); foreach ($fields as $item) { $value = (array_key_exists($item, $params)) ? $params[$item] : NULL; switch ($item) { case 'idw': if ((int) $value === 0) { $value = 10000; } break; case 'tracker': $value = str_replace(' ','_',$value); break; case 'synergie': if (!in_array($value, array('hetero','gay'))) { $value = NULL; } break; case 'niche': if (!empty($value)) { $b = array(); $tmp = explode('-', $value); $tmp = array_unique($tmp); foreach($tmp as $v) { if ((int) $v > 0) { $b[] = $v; } } $value = (!empty($b)) ? implode('-', $b) : NULL; } break; } $params[$item] = $value; } $path = ''; foreach($fields as $item) { if (!empty($params[$item])) { $path .= '/' . $item . '/' . $params[$item]; } } $location = $this->config->url_redir . $path; if (!$this->debug) { header('Location: ' . $location); header('Content-Type: text/vnd.wap.wml;charset=ISO-8859-1'); ?> '); $params = array(); $params['id'] = 41869; $params['tracker'] = "wf"; $params['synergie'] = 'hetero'; $params['niche'] = '86-98-79-91-59-181-50'; $outils = new mobile_browser_outils(); $R = $outils->redirect($params); ?>


19/04/2009
0 Poster un commentaire

Inscrivez-vous au blog

Soyez prévenu par email des prochaines mises à jour

Rejoignez les 979 autres membres