ainars Posted September 14, 2004 Report Share Posted September 14, 2004 Ir shaads scriptinsh, bet kaa lai pielieku klaat komandu, lai vienu konkreetu IP nepieskaita klaat un neieraksta txt failaa..... taa it kaa shis IP vispaar nebuutu bijis shajaa lapaa!!!!!!!!!!!!!!! ///////////////////////////////////////////////////////////////////////////////////// <?php $rip = $_SERVER['REMOTE_ADDR']; $fname = $_SERVER['PHP_SELF']; $file1 = "HVT/ip.txt"; $open1 = fopen($file1, "r"); $size1 = filesize($file1); $count1 = fread($open1, $size1); $pos1 = strrpos($count1, '*'); $pos2 = strpos($count1, '*',$pos1-8); $count = substr($count1,$pos2+1,($pos1-$pos2)-1); $count = $count+1; fclose($open1); $today = getdate(); $time = $today['hours'].":".$today['minutes'].":".$today['seconds']; $day = $today['mday']."-".$today['mon']."-".$today['year']; $hostname = gethostbyaddr($rip); $open2 = fopen($file1, "a"); fwrite($open2, "*"); fwrite($open2, $count); fwrite($open2, "*"); fwrite($open2, $rip); fwrite($open2, "+"); fwrite($open2, $hostname); fwrite($open2, "+"); fwrite($open2, $fname); fwrite($open2, "+"); fwrite($open2, $time); fwrite($open2, "+"); fwrite($open2, $day); fwrite($open2, "\n"); fclose($open2); ?> ////////////////////////////////////////////////////////// Link to comment Share on other sites More sharing options...
bubu Posted September 14, 2004 Report Share Posted September 14, 2004 <?php if (sanjemtaaIP != nevajadziigaaIP) { // ierakstam failā } ?> Link to comment Share on other sites More sharing options...
ainars Posted September 14, 2004 Author Report Share Posted September 14, 2004 Tu gribi teikt, ja es ielieku shaadu kodu: <?php if (55.55.55.55 != 55.55.55.55) { // ierakstam failā } ?> tad viss straadaas, nedomaaju gan.... tur truukst dazhas komandas!!! NEvari uzrakstiit tieshi pilno coda dallu???? :blink: Link to comment Share on other sites More sharing options...
o2T Posted September 14, 2004 Report Share Posted September 14, 2004 kā jau teikts,$_SERVER['REMOTE_ADDR'] ne vienmēr parāda īsto ip. ;) tad jau tavā lapā, ja ieiet teiksim,5 apmeklētāji vienlaikus, viņi tiek skaitīti kā viens,ja izejošā ip ir viena. un salīdzināšana ir ==, nevis viena = :ph34r: Link to comment Share on other sites More sharing options...
bubu Posted September 14, 2004 Report Share Posted September 14, 2004 ainars: tak ne jau konstantas IP adreses tur jāliek! mainīgos, tipa sanjemtaaIP ir tas, ko dabūt no REMOTE_ADDR, un nevajadziigaaIP ir strings, piemēram '159.148.123.34'. Un tā komentārs jau nav jāaststāj kādu es tur uzliku, bet tur jāliekt tavs koda gabals. Nu šitik elementārās lietas jau vajadzētu jēgt, tur no php specifikas gandrīz nekā nava o2T: vai tad kāds apgalvoja, ka salīdzināšana ir viena = ? Link to comment Share on other sites More sharing options...
ainars Posted September 14, 2004 Author Report Share Posted September 14, 2004 Jā ta jau ir, bet man galvenais, lai šis scripts nepieskaita manu IP, jo labojot lapu eju tajaa entaas reizes un testeju... liidz ar to veidojas mani entie IP, kurus man nevajag........ Link to comment Share on other sites More sharing options...
ainars Posted September 14, 2004 Author Report Share Posted September 14, 2004 ainars: tak ne jau konstantas IP adreses tur jāliek! mainīgos, tipa sanjemtaaIP ir tas, ko dabūt no REMOTE_ADDR, un nevajadziigaaIP ir strings, piemēram '159.148.123.34'. Un tā komentārs jau nav jāaststāj kādu es tur uzliku, bet tur jāliekt tavs koda gabals. Nu šitik elementārās lietas jau vajadzētu jēgt, tur no php specifikas gandrīz nekā nava o2T: vai tad kāds apgalvoja, ka salīdzināšana ir viena = ? Esmu iesācējs PHP un mēģinu kaut ko iemācīties! Link to comment Share on other sites More sharing options...
o2T Posted September 14, 2004 Report Share Posted September 14, 2004 tad salīdzini <?php if(sanjemtaIP!==tavaIP){ rakstam_visu failaa } Link to comment Share on other sites More sharing options...
ainars Posted September 14, 2004 Author Report Share Posted September 14, 2004 (edited) Tur jau tā lieta, ka man to konkrēto IP nevajag rakstīt faila, lai raksta pārējos!!! TAd kods buutu shaads, tikai truukst komandas, lai IP netiek ņemts vērā un netiek ierakstīts viesu IP failā!!! <?php $rip = $_SERVER['REMOTE_ADDR']; $fname = $_SERVER['PHP_SELF']; if ($rip != '159.148.123.34') { // ierakstam failā } $file1 = "HVT/ip.txt"; $open1 = fopen($file1, "r"); $size1 = filesize($file1); $count1 = fread($open1, $size1); $pos1 = strrpos($count1, '*'); $pos2 = strpos($count1, '*',$pos1-8); $count = substr($count1,$pos2+1,($pos1-$pos2)-1); $count = $count+1; fclose($open1); $today = getdate(); $time = $today['hours'].":".$today['minutes'].":".$today['seconds']; $day = $today['mday']."-".$today['mon']."-".$today['year']; $hostname = gethostbyaddr($rip); $open2 = fopen($file1, "a"); fwrite($open2, "*"); fwrite($open2, $count); fwrite($open2, "*"); fwrite($open2, $rip); fwrite($open2, "+"); fwrite($open2, $hostname); fwrite($open2, "+"); fwrite($open2, $fname); fwrite($open2, "+"); fwrite($open2, $time); fwrite($open2, "+"); fwrite($open2, $day); fwrite($open2, "\n"); fclose($open2); ?> Edited September 14, 2004 by ainars Link to comment Share on other sites More sharing options...
bubu Posted September 14, 2004 Report Share Posted September 14, 2004 1-kārt) IP adresi ir strings! tā ir jāliek pēdiņās: '159.148.123.34' 2-kārt) tu saproti, ko nozīmē vārdi "ierakstam failā"???? tev taču koda gabals ir, kas raksta to visu infu failā, ne? Nu tad ieliec to visu tajā(komentāra) vietā ;) Esmu iesācējs PHP un mēģinu kaut ko iemācīties! Te jau galīgi nav nekāda sakara ar php, te ir triviāls izpildes gaitas kontroles operators (IF) Link to comment Share on other sites More sharing options...
ainars Posted September 14, 2004 Author Report Share Posted September 14, 2004 1-kārt) IP adresi ir strings! tā ir jāliek pēdiņās: '159.148.123.34'2-kārt) tu saproti, ko nozīmē vārdi "ierakstam failā"???? tev taču koda gabals ir, kas raksta to visu infu failā, ne? Nu tad ieliec to visu tajā(komentāra) vietā ;) Esmu iesācējs PHP un mēģinu kaut ko iemācīties! Te jau galīgi nav nekāda sakara ar php, te ir triviāls izpildes gaitas kontroles operators (IF) Jā ta jau ir, bet man galvenais, lai šis scripts nepieskaita manu IP, jo labojot lapu eju tajaa entaas reizes un testeju... liidz ar to veidojas mani entie IP, kurus man nevajag........ :(' Link to comment Share on other sites More sharing options...
spynode Posted September 18, 2004 Report Share Posted September 18, 2004 Nu to tavu probleemu saprataam, bet tev tak saka, ka komentaara vietaa ievieto to koda dalju, kura raksta failaa. Saprotu, ka tu no php gandriiz vispaar neko nesaproti tapeec reku ir : <?php $rip = $_SERVER['REMOTE_ADDR']; $fname = $_SERVER['PHP_SELF']; if ($rip != '159.148.123.34') { $file1 = "HVT/ip.txt"; $open1 = fopen($file1, "r"); $size1 = filesize($file1); $count1 = fread($open1, $size1); $pos1 = strrpos($count1, '*'); $pos2 = strpos($count1, '*',$pos1-8); $count = substr($count1,$pos2+1,($pos1-$pos2)-1); $count = $count+1; fclose($open1); $today = getdate(); $time = $today['hours'].":".$today['minutes'].":".$today['seconds']; $day = $today['mday']."-".$today['mon']."-".$today['year']; $hostname = gethostbyaddr($rip); $open2 = fopen($file1, "a"); fwrite($open2, "*"); fwrite($open2, $count); fwrite($open2, "*"); fwrite($open2, $rip); fwrite($open2, "+"); fwrite($open2, $hostname); fwrite($open2, "+"); fwrite($open2, $fname); fwrite($open2, "+"); fwrite($open2, $time); fwrite($open2, "+"); fwrite($open2, $day); fwrite($open2, "\n"); fclose($open2); } ?> Vinjsh vienkaarshi ar if paliidziibu paarbauda if ($rip != '159.148.123.34') vai taa ip kuru vinjsh ir ieguvis ir taada kaa tu noraadi kodaa , un ja vinja taada nav, tad vinjt tikai taalaak kautko dara. Preteejaa gadijumaa skripts tur arii apstaajaas. Link to comment Share on other sites More sharing options...
blackhalt Posted September 20, 2004 Report Share Posted September 20, 2004 <?php $manaipa='127.0.0.1'; // tava IP adrese $rip=$_SERVER['REMOTE_ADDR']; $fname=$_SERVER['PHP_SELF']; if($rip!="$manaipa"){ $file1="HVT/ip.txt"; $open1=fopen($file1,'r'); $size1=filesize($file1); $count1=fread($open1,$size1); $pos1=strrpos($count1,'*'); $pos2=strpos($count1,'*',$pos1-8); $count=substr($count1,$pos2+1,($pos1-$pos2)-1); $count=$count+1; fclose($open1); $today=getdate(); $time=$today['hours'].":".$today['minutes'].":".$today['seconds']; $day=$today['mday']."-".$today['mon']."-".$today['year']; $hostname=gethostbyaddr($rip); $open2=fopen($file1,'a'); fwrite($open2,"*$count*$rip+$hostname+$fname+$time+$day\n"); fclose($open2); } ?> Link to comment Share on other sites More sharing options...
ainars Posted September 30, 2004 Author Report Share Posted September 30, 2004 Paldies par palīdzību! :) Link to comment Share on other sites More sharing options...
Recommended Posts