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
visejezicni site i IP

 
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
nel`chee



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 22.10.2005 15:02    Post subject: visejezicni site i IP Add user to your forum ignore list Reply with quote

koja komponenta IP-a govori da je rijec o hrvatskom ISP-u? kako mogu ljude iz hrvatske redirectati na hrvatsku verziju? po mogucnosti, u .htaccess-u
a sto ako ta osoba u cookie-ju ima vec postavljeno na engleski? kako onda overrideati taj rule?

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
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: 22.10.2005 16:31    Post subject: Add user to your forum ignore list Reply with quote

Skini si IP-to-country bazu i ubaci je u MySQL tablicu. Sad imaš IP rangeve za sve zemlje svijeta i preciznost ti je veća od 95% brijem, ali nikad ne može biti 100% zbog toga što ljudi koriste daleke proxye i drugih internetskih finti. Počupaš IP od klijenta, pretvoriš u long (ip2long) funkcija i query-aš bazu, izvučeš zemlju i serviraš jezik.

No, sve ovo je bez veze pošto jezik serviraš prema ACCEPT-LANGUAGE request headeru kojeg šalje browser, a ne prema IP-u. Ima puno Hrvata koji surfaju izvana a svejedno žele stranice na materinjem jeziku.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nel`chee



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 22.10.2005 17:55    Post subject: Add user to your forum ignore list Reply with quote

pa zato postoji cookie, koji bi bio vazniji od IP-a. covjek moze odabrat jezik ako mu ne odgovara.

hmm zar mi zbilja treba baza svih IP-eva na svijetu? ja zelim samo hrvatske, za sve ostalo ide engleski..
thanks anyway, vidjet cu dal uopce zelim to Confused

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
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: 22.10.2005 18:40    Post subject: Add user to your forum ignore list Reply with quote

Ozbiljno sam ti rekao, jezik bi se trebao servirati po više navedenom request headeru kojeg šalje svaki normalni browser, a ne po zemlji porijekla requesta!

Ako zaista želiš servirati po IP-u, možeš napraviti ovo - skinuti si bazu, pogledati je li čovjek iz Hrvatske, BIH, Srbije, Slovenije, čak i Makedonije Smile i servirati njima hrvatski po defaultu, ostalima engleski... ali ja uopće nisam za to da ignoriraš ACCEPT-LANGUAGE header, pošaljem ti funkciju koja ga parsira ako hoćeš, a što se tiče baze daš mi user i pass za svoju bazu i dumpiram ti tablicu IP rangeva za zemlje direktno u nju
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gog



Joined: 18 Jun 2004
Posts: 679
Location: zagreb

PostPosted: 22.10.2005 19:01    Post subject: Add user to your forum ignore list Reply with quote

Možeš ti iz baze izbaciti sve što nije hrv., onda lijepo imaš neki redirect.php koji prvo gleda cookie, ako tamo ništa nije pohranjeno radi upit na bazu, ukoliko ti je mysql_num_rows($upit) == 0 šalji na eng, ako nije onda na hr. i odmah postavi odgovarajući cookie. Ako netko želi promjeniti jezik, promijeniš cookie i to je to...
Back to top
View user's profile Send private message Visit poster's website
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 22.10.2005 19:18    Post subject: Add user to your forum ignore list Reply with quote

čitaj RFC
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nel`chee



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 22.10.2005 19:21    Post subject: Add user to your forum ignore list Reply with quote

ok Sulien ovu funkciju bi vrlo rado. nisam imala pojma da to postoji.. i kako uopce browser to skuzi? sta vuce iz sistema regional settings, don't get it.. Confused

ovo sto gog kaze je okej metoda.

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
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: 23.10.2005 04:30    Post subject: Add user to your forum ignore list Reply with quote

Sulien wrote:
Ozbiljno sam ti rekao, jezik bi se trebao servirati po više navedenom request headeru kojeg šalje svaki normalni browser, a ne po zemlji porijekla requesta!

jes, ali ono, ljudi si to ne namjestaju u browseru jer neznaju da se to uopce moze.
konkretno kad firefox instaliras, difoltni jezik ti je engleski.
IE je nesto pametniji, pa s njim je difoltni hrvatski (ako ti je difoltni jezik na kompu hrvatski).

naravno da je accept-language bolji, inteligentniji, ali sta ces kad svijet nije takav.

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



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 23.10.2005 04:53    Post subject: Add user to your forum ignore list Reply with quote

hm evo ko sto carr kaze nisam imala pojma do sad da to postoji... ali sad sam si namjestila Smile

ako imas gotovu funkciju za ovo bila bi jako zahvalna, buduci da mi i nakon citanja ovog nije jasno kako bi to trebalo izvest Confused

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
Back to top
View user's profile Send private message Visit poster's website Twitter profile
gog



Joined: 18 Jun 2004
Posts: 679
Location: zagreb

PostPosted: 23.10.2005 10:07    Post subject: Add user to your forum ignore list Reply with quote

http://www.grep.be/articles/php-accept
Back to top
View user's profile Send private message Visit poster's website
nel`chee



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 23.10.2005 15:56    Post subject: Add user to your forum ignore list Reply with quote

hvala Very Happy

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
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: 23.10.2005 21:53    Post subject: Add user to your forum ignore list Reply with quote

moj kod je ponešto kraći Embarassed

stvar je u tome što sam trebao nešto na brzinu i nisam siguran da li je baš bulletproof Confused ali vjerujem da radi jer vidim u statistikama logične rezultate

BTW ne snifa charset, ja svima uredno dajem Unicode
Code:
function languages(){
   if(isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])){
      $header = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
      if(preg_match_all('/q=(\d(?:\.\d)?)/', $header, $matches)){
         $langs = preg_split('/[,;]q=(\d(?:\.\d)?)[,;]?/', $header);
         array_pop($langs);
         $langs = array_combine($matches[1], $langs);
         ksort($langs, SORT_NUMERIC);
         $langs = array_reverse($langs, true);
         $retval = array();
         foreach($langs as $sub_langs) $retval += preg_split('/[,;]/', $sub_langs);
         return $retval;
      }
      return preg_split('/[,;]/', $header);
      }
   else return array();
}
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Pekx



Joined: 09 Sep 2004
Posts: 559

PostPosted: 28.10.2005 19:34    Post subject: Add user to your forum ignore list Reply with quote

sad naletio na ovo, možda pomogne, a možda zaspama Smile

http://www.ip2phrase.com/

_________________
mp3hr.com
Back to top
View user's profile Send private message Send e-mail
nel`chee



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 25.11.2005 16:44    Post subject: Add user to your forum ignore list Reply with quote

Sulien, postoji jedan problem a to je sto tvoj kod sadrzi funkciju array_combine(), a ja imam PHP 4 Confused

P.S. mozda sam nasla nesto..

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
Back to top
View user's profile Send private message Visit poster's website Twitter profile
retro_one



Joined: 16 Sep 2003
Posts: 880
Location: DUBRAVA.

PostPosted: 25.11.2005 17:10    Post subject: Add user to your forum ignore list Reply with quote

pa isprogramiraj funkciju array_combine... i onda je loadaj ako je verzija phpa manja od verzije 5, uostalom array_combine je jako jednostavna funkcija za isprogramirat

edit:

Code:
function array_combine($arrKeys, $arrVals)
{
   if(empty($arrKeys) || empty($arrVals))
      return false;
   if(count($arrKeys) != count($arrVals))
      return false;
   $returnArr = array();
   foreach($arrKeys AS $key)
   {
      $returnArr[$key] = current($arrVals);
      next($arrVals);
   }
   return $returnArr;
}

_________________
Just your average eccentric programmer.
Back to top
View user's profile Send private message
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 25.11.2005 19:25    Post subject: Add user to your forum ignore list Reply with quote

sorry, ja sam isto programirao svoju combine() ali sam zaboravio pejstati

thnx retro Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nel`chee



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 26.11.2005 16:41    Post subject: Add user to your forum ignore list Reply with quote

retro_one wrote:
uostalom array_combine je jako jednostavna funkcija za isprogramirat

da, kad znas sto ta funkcija treba napraviti Laughing
tnx Wink

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
Back to top
View user's profile Send private message Visit poster's website Twitter profile
retro_one



Joined: 16 Sep 2003
Posts: 880
Location: DUBRAVA.

PostPosted: 27.11.2005 02:38    Post subject: Add user to your forum ignore list Reply with quote

nel`chee wrote:
retro_one wrote:
uostalom array_combine je jako jednostavna funkcija za isprogramirat

da, kad znas sto ta funkcija treba napraviti Laughing
tnx Wink


http://hr.php.net/array_combine Cool

_________________
Just your average eccentric programmer.
Back to top
View user's profile Send private message
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