22-03-2008, 11:28
|
|
|
חבר מתאריך: 21.01.06
הודעות: 813
|
|
זיהוי דפדפן המשתמש ושימוש בו
קצת הסתבכתי עם זה..עשיתי משהו כזה:
קוד PHP:
<?php $user_agent = $_SERVER['HTTP_USER_AGENT']; $user_agent = str_replace ('/' , 'SIS' , $user_agent); $user_agent = str_replace (';' , 'SIS' , $user_agent); $user_agent = str_replace ('-' , 'SIS' , $user_agent); $user_agent = str_replace (' ' , 'SIS' , $user_agent); $user_agent = str_replace (')' , 'SIS' , $user_agent); $user_agent = str_replace ('(' , 'SIS' , $user_agent); $user_agent = str_replace (';' , 'SIS' , $user_agent); $user_agent = str_replace ('.' , 'SIS' , $user_agent); $user_agent = str_replace (':' , 'SIS' , $user_agent); $user_agent = str_replace ('\\' , 'SIS' , $user_agent); $user_agent = str_replace ('1' , 'NUM' , $user_agent); $user_agent = str_replace ('2' , 'NUM' , $user_agent); $user_agent = str_replace ('3' , 'NUM' , $user_agent); $user_agent = str_replace ('4' , 'NUM' , $user_agent); $user_agent = str_replace ('5' , 'NUM' , $user_agent); $user_agent = str_replace ('6' , 'NUM' , $user_agent); $user_agent = str_replace ('7' , 'NUM' , $user_agent); $user_agent = str_replace ('8' , 'NUM' , $user_agent); $user_agent = str_replace ('9' , 'NUM' , $user_agent); $user_agent = str_replace ('0' , 'NUM' , $user_agent); echo $user_agent; if (preg_match ("FireFox" , $user_agent)) { echo 'firefox'; } else { echo 'explorer'; } ?>
ביצעתי את כל ההחלפות כדי שלא תהיה בעיה שהpreg_match מכיל תווים לא חוקיים
לעומת זאת הוא עדיין מכיל תווים לא חוקיים:
Delimiter must not be alphanumeric or backslashוזה הערך שהחוזר מכל ההחלפות:
קוד:
MozillaSISNUMSISNUMSISSIScompatibleSISSISMSIESISNU MSISNUMSISSISWindowsSISNTSISNUMSISNUMSISSISSVNUMSI SSISiSISNavFourFSISSISSISNETSISCLRSISNUMSISNUMSISN UMNUMNUMNUMNUMSISSISSISNETSISCLRSISNUMSISNUMSISNUM NUMNUMNUMSIS
כמו שאתם רואים..רק אותיות..
* לא עשיתי ישירות אם הuser_agent שווה לערך מסויים של הדפדפן כי יש גרסאות שונות של fire fox
מה הבעיה? אולי יש דרך אחרת?
תודה לעוזרים!!!
_____________________________________
--- ! Area Close ! ---
|