Jump to content
eucumata

PHP help

Recommended Posts

Posted

Avem fisierul : fisier.txt care contine

BAD: ***.223.80.251:guest:guest

BAD: ***.223.81.34:guest:guest

OK: ***.202.122.224:guest:guest

OK: ***.202.122.228:guest:guest

OK: ***.202.122.230:guest:guest

OK: ***.202.122.227:guest:guest

OK: ***.220.72.1:guest:guest

OK: ***.220.196.1:guest:guest

OK: ***.221.40.1:guest:guest

OK: ***.230.139.35:guest:guest

OK: ***.230.161.151:guest:guest

BAD: ***.254.40.155:guest:guest

Avem scriptul :

<?php

$ok = file("fisier.txt");

foreach ($ok as $nr => $line){

$ss = explode(":",$line);

$IP = trim($ss[1]);

if (!empty($IP))

$content = file_get_contents('http://api.ipinfodb.com/v3/ip-city/?key=4e8d48cdc36fb87632873c5c93de9889d2c9454082c03e83dffbb46b34cb3260&ip='.$IP);

}

print "[iP = $content]"

?>

Cand execut scriptul.. ar trebui sa imi apara 'Location' de la fiecare ip in parte... dar imi apare doar de la ultimul.

[iP = OK;;188.254.40.155;UK;UNITED KINGDOM;-;-;-;54.167;-4.48211;+00:00]

Posted (edited)
Pei ma omule "print "[iP = $content]" e pus in afara foreach-ului =)).

<?php

$ok = file("fisier.txt");

foreach ($ok as $nr => $line){

$ss = explode(":",$line);

$IP = trim($ss[1]);

if (!empty($IP))

$content = file_get_contents('http://api.ipinfodb.com/v3/ip-city/?key=4e8d48cdc36fb87632873c5c93de9889d2c9454082c03e83dffbb46b34cb3260&ip='.$IP);

print "[iP = $content]"

}

?>

[root@localhost ~]# php a.php

PHP Parse error: syntax error, unexpected '}' in /root/a.php on line 9

[root@localhost ~]#

Da am uitat sa pun ; dupa print :P ms .. merge...

Edited by eucumata
Posted
Dupa faza cu print blablabla n-are trebuie sa pui cumva ";" ?

Acum le arata asa [iP = OK;;188.221.176.1;UK;UNITED KINGDOM;ENGLAND;LONDON;-;51.517;-0.105;+00:00][iP = OK;;188.222.88.1;UK;UNITED KINGDOM;-;-;-;54.167;-4.48211;+00:00][iP = OK;;188.223.120.1;UK;UNITED KINGDOM;ENGLAND;MANCHESTER;-;53.483;-2.249;+00:00]

cum il fac sa apara pe alt rand ? :))

[iP = OK;;188.221.176.1;UK;UNITED KINGDOM;ENGLAND;LONDON;-;51.517;-0.105;+00:00]

[iP = OK;;188.222.88.1;UK;UNITED KINGDOM;-;-;-;54.167;-4.48211;+00:00]

[iP = OK;;188.223.120.1;UK;UNITED KINGDOM;ENGLAND;MANCHESTER;-;53.483;-2.249;+00:00]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...