sergey_prusov
Участник
- Регистрация
- 31 Окт 2008
- Сообщения
- 203
- Реакции
- 4
- Автор темы
- #1
Всем привет..... выскакивает ошибка:
<hide>PHP Warning: preg_match( Compilation failed: invalid range in character class at offset 23 in (адрес) on line 58</hide>
сам код того файла:
ну и где косяк? Строчку красным выделил.
<hide>PHP Warning: preg_match( Compilation failed: invalid range in character class at offset 23 in (адрес) on line 58</hide>
сам код того файла:
<code>
<?php
function get_user_info($user_agent = ''){
include('user_info_browsers.inc');
include('user_info_os.inc');
if(!$user_agent){
$user_agent = $_SERVER['HTTP_USER_AGENT'];
}
$res = false;
foreach($browser_name as $key => $value){
$pos = strpos($user_agent, $key);
if ($pos !== false){
$res['browser_key'] = $key;
$res['browser_name'] = $value;
break;
}
}
if(!$res['browser_key']){
$res['browser_key'] = 'Unknow';
$res['browser_name'] = 'Unknow';
}
$pattern = $browser_vers[$res['browser_key']];
if($pattern){
if(preg_match($pattern, $user_agent, $match)){
$res['browser_version'] = $match[1];
}else{
$res['browser_version'] = '';
}
}else{
$res['browser_version'] = '';
}
foreach($os_name as $key => $value){
$pos = strpos($user_agent, $key);
if ($pos !== false) {
$res['os_key'] = $key;
$res['os_name'] = $value;
break;
}
}
if (!$res['os_key']){
$res['os_key'] = 'Unknow';
$res['os_name'] = 'Unknow';
}
$pattern = $os_vers[$res['os_key']];
if($pattern){
if(preg_match($pattern, $user_agent, $match)){
$res['os_version'] = $match[1];
if ($res['os_key'] == 'Windows'){
switch ($res['os_version']){
case 'NT 5.0': $res['os_version'] = '2000'; break;
case 'NT 5.1': $res['os_version'] = 'XP'; break;
case 'NT 5.2': $res['os_version'] = 'XP 64-bit'; break;
case 'NT 6.0': $res['os_version'] = 'Vista'; break;
case 'NT 6.1': $res['os_version'] = '7'; break;
case 'NT 2000': $res['os_version'] = '2000'; break;
}
}
}else{
$res['os_version'] = '';
}
}else{
$res['os_version'] = '';
}
if(isset($res['os_key'])) unset($res['os_key']);
if(isset($res['browser_key'])) unset($res['browser_key']);
$res['os'] = $res['os_name'].' '.$res['os_version'];
$res['browser'] = $res['browser_name'].' '.$res['browser_version'];
return $res;
}
?>
</code>
<?php
function get_user_info($user_agent = ''){
include('user_info_browsers.inc');
include('user_info_os.inc');
if(!$user_agent){
$user_agent = $_SERVER['HTTP_USER_AGENT'];
}
$res = false;
foreach($browser_name as $key => $value){
$pos = strpos($user_agent, $key);
if ($pos !== false){
$res['browser_key'] = $key;
$res['browser_name'] = $value;
break;
}
}
if(!$res['browser_key']){
$res['browser_key'] = 'Unknow';
$res['browser_name'] = 'Unknow';
}
$pattern = $browser_vers[$res['browser_key']];
if($pattern){
if(preg_match($pattern, $user_agent, $match)){
$res['browser_version'] = $match[1];
}else{
$res['browser_version'] = '';
}
}else{
$res['browser_version'] = '';
}
foreach($os_name as $key => $value){
$pos = strpos($user_agent, $key);
if ($pos !== false) {
$res['os_key'] = $key;
$res['os_name'] = $value;
break;
}
}
if (!$res['os_key']){
$res['os_key'] = 'Unknow';
$res['os_name'] = 'Unknow';
}
$pattern = $os_vers[$res['os_key']];
if($pattern){
if(preg_match($pattern, $user_agent, $match)){
$res['os_version'] = $match[1];
if ($res['os_key'] == 'Windows'){
switch ($res['os_version']){
case 'NT 5.0': $res['os_version'] = '2000'; break;
case 'NT 5.1': $res['os_version'] = 'XP'; break;
case 'NT 5.2': $res['os_version'] = 'XP 64-bit'; break;
case 'NT 6.0': $res['os_version'] = 'Vista'; break;
case 'NT 6.1': $res['os_version'] = '7'; break;
case 'NT 2000': $res['os_version'] = '2000'; break;
}
}
}else{
$res['os_version'] = '';
}
}else{
$res['os_version'] = '';
}
if(isset($res['os_key'])) unset($res['os_key']);
if(isset($res['browser_key'])) unset($res['browser_key']);
$res['os'] = $res['os_name'].' '.$res['os_version'];
$res['browser'] = $res['browser_name'].' '.$res['browser_version'];
return $res;
}
?>
</code>
Последнее редактирование модератором: