Hauv cov tshuab rau kev tswj cov khoom siv Is Taws Nem, uas tuaj yeem siv los ntawm ob tus neeg siv khoom siv thiab cov neeg tuaj saib tsis tau sau npe, cov ntawv sau xa mus tom kawg mus rau ib pab pawg sib cais. Feem ntau, pawg no ntawm tus xaib tsis siv npe hu ua "Qhua" hauv chav tswj hwm. Thaum txiav txim siab tus IP chaw nyob ntawm cov neeg tuaj saib uas tau tso cai yog feem ntau ib qho qauv scripting muaj nuj nqi, tom qab ntawd rau cov pab pawg neeg qhua, khaws cov lus no tsis yooj yim.
Cov Lus Qhia
Kauj ruam 1
Yog tias cov zaub lag luam IP chaw nyob ntawm tus neeg siv tsis raug cai ntawm kev sib tham, kev sib tham, blog lossis lwm qhov web zoo sib xws yog muab los ntawm cov chaw tsim khoom ntawm cov ntawv sau uas cov khoom siv no yog los ntawm, koj tsuas yog xav tau cov kev xaiv uas xav tau. Nws yog neeg xiam los ntawm kev ua haujlwm los cawm cov haujlwm web server. Saib rau cov chaw no hauv cov kab ke tswj hwm. Yog tias koj tsis tuaj yeem pom nws tus kheej, nyeem cov lus piav qhia, hu rau kev pabcuam kev txhawb nqa ntawm cov chaw tsim khoom sau ntawv, lossis nug ib qho lus nug hauv cov neeg siv rooj sablaj ntawm koj lub kaw lus.
Kauj ruam 2
Cov ntawv yuav tsis muaj chaw teeb tsa, tab sis yog tias txoj haujlwm ntawm kev txiav txim siab IP chaw siv nyob rau hauv nws cov haujlwm sab hauv, koj tuaj yeem sim siv nws rau koj lub hom phiaj. Txhawm rau ua qhov no, koj yuav tsum tau hloov kho cov kab ke system, yog li koj yuav xav tau qee qhov kev paub hauv kev ua haujlwm nrog cov lej txheej txheem ntawm cov qauv hauv cov chaw tswj lossis cov chaw sab sau npe server - feem ntau xws li cov ntawv sau yog sau hauv PHP. Qhib cov peev txheej ntawm nplooj ntawv uas koj xav pom cov qhua tus IP chaw nyob, txhais kom meej ib qho sib txawv uas muaj cov nqi xav tau thiab muab tso rau qhov chaw muaj tseeb. Piv txwv li, hauv kev siv dav siv tswj UCOZ, txhawm rau txhawm rau pom tus nqi no, koj yuav tsum sau tus lej $ _IP_ADDRESS $ rau hauv nplooj ntawv.
Kauj ruam 3
Ua qhov kawg, koj tuaj yeem siv koj tus kheej lub luag haujlwm PHP los txiav txim qhov chaw nyob IP. Qhov kev xaiv no haum rau cov tshuab uas tso cai koj los ntxig cov cai hauv cov lus no rau hauv nplooj ntawv. Tau kawg, hom no yuav xav tau ib qib siab dua ntawm kev paub ntawm hom lus. Koj yuav tsum tau ua cov haujlwm tawm rau nplooj ntawv IP-tus kheej, thiab txoj haujlwm rau kev txiav txim siab nws yuav zoo li no:
muaj nuj nqi getIPaddress () {
$ guestIP = getenv ('HTTP_CLIENT_IP') lossis $ guestIP = getenv ('HTTP_X_FORWARDED_FOR') lossis $ guestIP = getenv ('REMOTE_ADDR');
rov xa mus ua (preg_replace ('# ^ ([^,] +) (,. *)? #', '$ 1', $ guestIP));
}