Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
Browser sniffing: < IE 6

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
red



Joined: 03 May 2004
Posts: 919
Location: Zabok

PostPosted: 03.04.2006 12:58    Post subject: Browser sniffing: < IE 6 Add user to your forum ignore list Reply with quote

Ajd please nek netko napiše ili pastira solidnu browser sniffing PHP skriptu. Treba mi jedna koja će ispisati neku poruku ako user koristi IE stariji od verzije 6. Dakle, user će vidjeti samo paragraf teksta i ništa više.

Thnx muchly.

_________________
Get busy living, or get busy dying.
Back to top
View user's profile Send private message Visit poster's website Twitter profile
che.UP
mi3.crew


Joined: 07 Sep 2003
Posts: 2320
Location: zagreb

PostPosted: 03.04.2006 13:22    Post subject: Add user to your forum ignore list Reply with quote

a oni kondicionalni komentari ti ne odgovaraju tu?

_________________
UP | TypeTester | Accommodations App
Meni u Firefox-u ne radi AJAX
Back to top
View user's profile Send private message Visit poster's website
red



Joined: 03 May 2004
Posts: 919
Location: Zabok

PostPosted: 03.04.2006 13:42    Post subject: Add user to your forum ignore list Reply with quote

Nope.

_________________
Get busy living, or get busy dying.
Back to top
View user's profile Send private message Visit poster's website Twitter profile
carr



Joined: 13 Nov 2003
Posts: 1397
Location: Karlovac

PostPosted: 03.04.2006 16:51    Post subject: Add user to your forum ignore list Reply with quote

Code:

$ua = $_SERVER['HTTP_USER_AGENT'];
   if (eregi('MSIE',$ua)) {
      $browser['browser'] = "Internet Explorer";
      eregi('MSIE ([[:digit:]\.]+)',$ua,$b);
      $browser['version'] = $b[1];
      }

nadam se da radi, nisam probavao.

_________________
Bolje biti malo lud, nego malo pametan.
Back to top
View user's profile Send private message Visit poster's website
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 03.04.2006 16:58    Post subject: Add user to your forum ignore list Reply with quote

Zašto? Insertiraš samo paragraf kroz DOM Confused

Ako moraš podržat ljude sa isključenim JS, pejstiram kod koji bi ti mogao poslužit...
Back to top
View user's profile Send private message Send e-mail Visit poster's website
maratz
mi3.crew


Joined: 24 Nov 2003
Posts: 1207
Location: ZAG

PostPosted: 03.04.2006 17:11    Post subject: Add user to your forum ignore list Reply with quote

OT: Sve sam više sklon teoriji da client-side probleme treba riješavat na client-sideu, tj. JavaScriptom, cond. commentsima etc...

Serverside snifanje ti treba praktički sam ak oš deliverat drukčiji CSS file

SI u shortstatsima ima dost dobru browser detection funkciju...

_________________
STOP HITTING YOURSELF! | NETIQUETTE | TYPETESTER | Hypertext rulez™ | CREATIVE NIGHTS | ACCOMMODATIONS
Back to top
View user's profile Send private message Visit poster's website Twitter profile
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 03.04.2006 17:11    Post subject: Add user to your forum ignore list Reply with quote

Vidim da je Carr već uskočio... predugo držim ove tabove otvorene Confused

Car, mislim da će to uhvatit neke browsere koji se predstavljaju kao MSIE... nisam siguran, idem provjeravat svoje logove

Slažem se sa Maratzem oko snifanja, ali ne i oko procjene SI-ove skripte koja je Sick
Usavršio sam je u više navrata, postam ako treba ali ona je previše za detektiranje samo jednog browsera
Back to top
View user's profile Send private message Send e-mail Visit poster's website
maratz
mi3.crew


Joined: 24 Nov 2003
Posts: 1207
Location: ZAG

PostPosted: 03.04.2006 17:16    Post subject: Add user to your forum ignore list Reply with quote

Sulien wrote:
Usavršio sam je u više navrata, postam ako treba ali ona je previše za detektiranje samo jednog browsera

eto... Smile

_________________
STOP HITTING YOURSELF! | NETIQUETTE | TYPETESTER | Hypertext rulez™ | CREATIVE NIGHTS | ACCOMMODATIONS
Back to top
View user's profile Send private message Visit poster's website Twitter profile
red



Joined: 03 May 2004
Posts: 919
Location: Zabok

PostPosted: 03.04.2006 17:25    Post subject: Add user to your forum ignore list Reply with quote

Okay, fanx... Hja, kad Sulje nikad nema na IM kad ga čovjek treba Smile

_________________
Get busy living, or get busy dying.
Back to top
View user's profile Send private message Visit poster's website Twitter profile
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 03.04.2006 17:32    Post subject: Add user to your forum ignore list Reply with quote

E da, Care, to što si napisao hvata otprilike sve Opere Smile

EDIT: ...i Googlebota Smile i još par drugih botova

Red: napišem ti PHP odmah, prošao sam kroz logove i vidio da bi bilo skroz jednostavno
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 03.04.2006 19:40    Post subject: Add user to your forum ignore list Reply with quote

Ultimate MSIE comparison function:

Code:
function MSIE_compare($ver, $ua = null){
   if(!is_numeric($ver)){
      trigger_error(__FUNCTION__.': argument not a version number', E_USER_WARNING);
      return false;
   }
   if(!$ua){
      if(!isset($_SERVER['HTTP_USER_AGENT'])) return false;
      $ua =& $_SERVER['HTTP_USER_AGENT'];
   }
   
   $precision = (is_string($ver) && @list(,$decimals) = explode('.', $ver)) ? strlen($decimals) : 0;
   $ver = round((float)$ver, $precision);

   if( strpos($ua, 'MSIE') !== false
      && !preg_match('/(?:bot|crawler)\b|\b(?:index(?:er|ing)|opera|netscape)\b/i', $ua)
      && preg_match('/MSIE\s+(\d+\.\d+)/', $ua, $matches)
      ){
      $client_ver = round(floatval($matches[1]), $precision);
      return $client_ver > $ver ? 1 : ($client_ver == $ver ? 0 : -1);
   }
   else return false;
}


F-ja prima dva argumenta: version number protiv kojeg se uspoređuje i (opcionalno) user agent string. Ako drugi argument nije zadan UA string će se uzeti iz browsera koji pokreće tu skriptu.

Version number poželjno predati kao string (npr. '5.1') da bi definirali preciznost usporedbe.

Funkcija vraća false ako browser nije MSIE, 0 ako je verzija ista kao zadana, -1 ako je manja i 1 ako je veća. Dakle, da provjeriš da li netko ima MSIE manji od 6.0 koristiš uvjet
Code:
MSIE_compare(6) < 0

Da provjeriš da li netko ima MSIE 5.x
Code:
MSIE_compare(5) === 0

Da provjeriš da li netko ima MSIE 5.5
Code:
MSIE_compare('5.5') === 0

Da li je veći od 6.0
Code:
MSIE_compare('6.0') > 0

Da li netko uopće ima MSIE??
Code:
MSIE_compare()


Javiti svakako bugove. Funkcija se vrti live na
http://odin.irb.hr/~mislav/tmp/MSIE/

Ono što se izvršava na linku je jedna linija koda:
Code:
var_dump(MSIE_compare('5.5'));
Back to top
View user's profile Send private message Send e-mail Visit poster's website
carr



Joined: 13 Nov 2003
Posts: 1397
Location: Karlovac

PostPosted: 04.04.2006 02:32    Post subject: Add user to your forum ignore list Reply with quote

maratz wrote:
SI u shortstatsima ima dost dobru browser detection funkciju...

tak je, ovo sta sam ja stavio je kopipejstano iz shortstatsa cinimise, slepa mi se to neko vrijeme po kodu pa ko ce ga znat Smile

@sulien: odlicno suljo, prasni to negdje u neki sticky il nesto.

_________________
Bolje biti malo lud, nego malo pametan.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group