ďťż

[PHP] Nazwa systemu Jak zmienić kod(...), by pokazywał nazwę sys?

       

Podstrony


telcocafe

Jak zmienić kod(na rozpoznanie przeglądarki), by pokazywał nazwę i wersję systemu?
Kod:
$browser = strtolower($_SERVER['HTTP_USER_AGENT']); if(strpos($browser, 'opera')!== false){ print"oj"; } else if(strpos($browser, 'netscape')!== false){ print"nn"; } else if(strpos($browser, 'msie')!== false){ print"ie"; } else if(strpos($browser, 'firefox')!== false){ print"ff"; } else{ print"UFO"; }
Pozdr.:skiing:



Tak?
$browser = strtolower($_SERVER['HTTP_USER_AGENT']); if(strpos($browser, 'windows')!== false){ print"Windows"; } else if(strpos($browser, 'linux')!== false){ print"Linux"; } else if(strpos($browser, 'NT')!== false){ print"Windows NT"; } else{ print"UFO"; }
Edytowany na szybko. Może miec błędy. :P

Fajnie :) Jak rozróżnić Windowsy (2000, XP... oraz Linuxy Mandriva, Ubuntu, RedHat itd.)?
Pozdr.

zainteresuj się funkcją z phpBB2 modified by Przemo v1.12.5, odczytuje także przeglądarkę:
function user_agent($agent) { $agent_tst = ' ' . strtolower($agent); $sa = $ba = ''; if ( strpos($agent_tst, 'windows') || strpos($agent_tst, 'win9') || strpos($agent_tst, 'win32') || strpos($agent_tst, 'nt 5.') || strpos($agent_tst, 'nt 4') ) { $sa = ( strpos($agent_tst, 'windows 9') || strpos($agent_tst, 'nt 4') || strpos($agent_tst, 'windows') || strpos($agent_tst, 'win32') ) ? 'windows_98_nt_2000' : $sa; $sa = ( strpos($agent_tst, 'nt 5.') || strpos($agent_tst, 'nt 6.') || strpos($agent_tst, 'nt 7.') || strpos($agent_tst, 'nt 8.') ) ? 'windows_xp_2003' : $sa; $sa = (strpos($agent_tst, 'nt 5.0')) ? 'windows_98_nt_2000' : $sa; } else { $sa = (strpos($agent_tst, 'linux')) ? 'linux' : $sa; $sa = (strpos($agent_tst, 'suse')) ? 'linux_suse' : $sa; $sa = (strpos($agent_tst, 'knoppix')) ? 'linux_knoppix' : $sa; $sa = (strpos($agent_tst, 'turbolinux')) ? 'linux_turbolinux' : $sa; $sa = (strpos($agent_tst, 'slackware')) ? 'linux_slackware' : $sa; $sa = (strpos($agent_tst, 'gentoo')) ? 'linux_gentoo' : $sa; $sa = (strpos($agent_tst, 'lycoris')) ? 'linux_lycoris' : $sa; $sa = (strpos($agent_tst, 'debian')) ? 'linux_debian' : $sa; $sa = (strpos($agent_tst, 'redhat')) ? 'linux_redhat' : $sa; $sa = (strpos($agent_tst, 'archlinux')) ? 'linux_arch' : $sa; $sa = (strpos($agent_tst, 'ubuntu')) ? 'linux_ubuntu' : $sa; $sa = (strpos($agent_tst, 'bsd')) ? 'linux_freebsd' : $sa; // I know, sorry :) } if ( $sa == '') { $sa = (strpos($agent_tst, 'mac')) ? 'macos' : $sa; $sa = (strpos($agent_tst, 'aix')) ? 'aix' : $sa; $sa = (strpos($agent_tst, 'lindows')) ? 'lindows' : $sa; $sa = (strpos($agent_tst, 'amiga')) ? 'amiga' : $sa; $sa = (strpos($agent_tst, 'athe')) ? 'athe' : $sa; $sa = (strpos($agent_tst, 'beos')) ? 'beos' : $sa; $sa = (strpos($agent_tst, 'zeta')) ? 'beos' : $sa; $sa = (strpos($agent_tst, 'BlueEyed')) ? 'beos' : $sa; $sa = (strpos($agent_tst, 'nextstep')) ? 'nextstep' : $sa; $sa = (strpos($agent_tst, 'warp')) ? 'warp' : $sa; $sa = (strpos($agent_tst, 'qnx')) ? 'qnx' : $sa; $sa = (strpos($agent_tst, 'risc')) ? 'risc' : $sa; $sa = (strpos($agent_tst, 'solaris')) ? 'solaris' : $sa; $sa = (strpos($agent_tst, 'unix')) ? 'unix' : $sa; $sa = (strpos($agent_tst, 'macos')) ? 'macos' : $sa; $sa = (strpos($agent_tst, 'mac os')) ? 'macos' : $sa; $sa = (strpos($agent_tst, 'symbian')) ? 'symbian' : $sa; $sa = ($sa == '' && strpos($agent_tst, 'win9') || strpos($agent_tst, 'win3') || strpos($agent_tst, 'windows') ) ? 'windows_98_nt_2000' : $sa; } $ba = (strpos($agent_tst, 'mozilla')) ? 'mozilla' : $ba; $ba = (strpos($agent_tst, 'msie')) ? 'ie' : $ba; $ba = (strpos($agent_tst, 'netscape')) ? 'netscape' : $ba; $ba = (strpos($agent_tst, 'opera')) ? 'opera' : $ba; $ba = (strpos($agent_tst, 'konqueror')) ? 'konqueror' : $ba; $ba = (strpos($agent_tst, 'galeon')) ? 'galeon' : $ba; $ba = (strpos($agent_tst, 'firefox')) ? 'firefox' : $ba; $ba = (strpos($agent_tst, 'netsprint')) ? 'netsprint' : $ba; $ba = (strpos($agent_tst, 'firebird')) ? 'firebird' : $ba; $ba = (strpos($agent_tst, 'links')) ? 'links' : $ba; $ba = (strpos($agent_tst, 'dillo')) ? 'dillo' : $ba; $ba = (strpos($agent_tst, 'omniweb')) ? 'omniweb' : $ba; $ba = (strpos($agent_tst, 'avant')) ? 'avant' : $ba; $ba = (strpos($agent_tst, 'myie2')) ? 'myie2' : $ba; $ba = (strpos($agent_tst, 'seamonkey')) ? 'seamonkey' : $ba; $ba = (strpos($agent_tst, 'maxthon')) ? 'maxthon' : $ba; $ba = ($ba == '') ? 'unknown' : $ba; $sa = ($sa == '') ? 'unknown' : $sa; return array('icon_' . $sa . '.gif', 'icon_' . $ba . '.gif', $agent); }



jakis czas temu bawilem sie w to, kody jakie wtedy namascilem, w wersji czysto roboczej i pewnie nie zrozumialej dla innych daje nizej - moze cos ci sie przyda...

<?php $pliczki = glob("stats/*.txt"); $osy = array(); foreach ($pliczki as $pliczek) { $wpis = file_get_contents($pliczek); $OSList = array( 'Windows 3.11' => 'Win16', 'Windows 95' => '(Windows 95)|(Win95)|(Windows_95)', 'Windows 98' => '(Windows 98)|(Win98)', 'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)', 'Windows MC' => 'Media Center PC', 'Windows XP' => '(Windows NT 5.1)|(Windows XP)', 'Windows Server 2003' => '(Windows NT 5.2)', 'Windows Vista' => '(Windows NT 6.0)', 'Windows 7' => '(Windows NT 7.0)', 'Windows NT 4.0' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)', 'Windows ME' => 'Windows ME', 'Open BSD' => 'OpenBSD', 'Sun OS' => 'SunOS', 'Linux' => '(Linux)|(X11)', 'Mac OS' => '(Mac_PowerPC)|(Macintosh)', 'QNX' => 'QNX', 'BeOS' => 'BeOS', 'OS/2' => 'OS/2', 'Bot'=>'(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves/Teoma)|(ia_archiver)', 'Komórka'=>'(J2ME/MIDP)', 'inny' => '(.*)'); foreach($OSList as $CurrOS=>$Match) { if (eregi($Match, $wpis)) { break; } } $osy[$CurrOS]=1+$osy[$CurrOS]; } natsort($osy); echo '<table border="1" width="200" cellpadding="0" cellspacing="0">'; foreach ($osy as $osa=>$osb) { echo '<tr><td>'.$osa.'</td><td align="center">'.$osb.'</td></tr>'; } echo '</table>'; ?><?php $pliczki = glob("stats/*.txt"); $osy = array(); foreach ($pliczki as $pliczek) { $wpis = file_get_contents($pliczek); $OSList = array( 'Bot' => '(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves/Teoma)|(ia_archiver)', 'Internet Explorer 5' => '(MSIE 5.0)', 'Internet Explorer 5.5' => '(MSIE 5.5)', 'Internet Explorer 6' => '(MSIE 6.0)', 'Internet Explorer 6.1' => '(MSIE 6.1)', 'Internet Explorer 7' => '(MSIE 7.0)', 'Internet Explorer' => '(MSIE)', 'Safari' => '(Safari)', 'Opera' => '(Opera/)', 'Firefox' => '(Firefox/)', 'Inna' => '(.*)' ); foreach($OSList as $CurrOS=>$Match) { if (eregi($Match, $wpis)) { break; } } $osy[$CurrOS]=1+$osy[$CurrOS]; } natsort($osy); echo '<table border="1" width="200" cellpadding="0" cellspacing="0">'; foreach ($osy as $osa=>$osb) { echo '<tr><td>'.$osa.'</td><td align="center">'.$osb.'</td></tr>'; } echo '</table>'; ?>

a kod generujacy z poprzedniego tematu [link na poczatku] wygladal tak:

<?php file_put_contents('stats/'.md5($_SERVER['REMOTE_ADDR']).' .txt', $_SERVER['HTTP_USER_AGENT']." - [".$_GET['sys']."]"); ?> Dzieki!

mam nadzieje ze taki kod ci sie przyda do czegos.

Dzięki :)
Pozdr.

P.S. Jak to użyć??

Nie działa! Nie wiem jak to użyć :(

a konkretnie? utworz 3 pliki o takiej zawartosci jak napisal bikstopa i juz

Dobrze, dzięki :)
Pozdr.

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • nvm.keep.pl

  • Sitedesign by AltusUmbrae.