I am logging outgoing traffic in a text file, which consists of ip & port. after copying all logs to text file and further copying its content to php string, I need to show all ips.
Code:
<?php
function get_string_between($string, $start, $end){
$string = ' ' . $string;
$ini = strpos($string, $start);
if ($ini == 0) return '';
$ini += strlen($start);
$len = strpos($string, $end, $ini) - $ini;
return substr($string, $ini, $len);
}
$fullstring = "[IP]49.44.50.18[/IP][PORT]80[/PORT] [IP]204.79.197.200[/IP][PORT]80[/PORT] [IP]49.44.50.18[/IP][PORT]80[/PORT] [IP]204.79.197.203[/IP][PORT]80[/PORT] [IP]204.79.197.200[/IP][PORT]80[/PORT] [IP]49.44.50.18[/IP][PORT]80[/PORT] [IP]204.79.197.203[/IP][PORT]80[/PORT] [IP]204.79.197.200[/IP][PORT]80[/PORT] [IP]49.44.50.18[/IP][PORT]80[/PORT] [IP]111.221.29.30[/IP][PORT]80[/PORT] [IP]23.99.125.55[/IP][PORT]80[/PORT] [IP]103.243.221.87[/IP][PORT]80[/PORT] [IP]107.21.211.226[/IP][PORT]80[/PORT] [IP]49.44.118.224[/IP][PORT]443[/PORT] [IP]49.44.50.9[/IP][PORT]80[/PORT] [IP]204.79.197.200[/IP][PORT]80[/PORT] [IP]46.137.205.158[/IP][PORT]80[/PORT] [IP]46.137.205.249[/IP][PORT]443[/PORT] [IP]204.79.197.200[/IP][PORT]80[/PORT] [IP]13.107.5.80[/IP][PORT]80[/PORT] [IP]103.243.221.87[/IP][PORT]443[/PORT] [IP]204.79.197.203[/IP][PORT]80[/PORT] [IP]204.79.197.200[/IP][PORT]80[/PORT] [IP]49.44.50.18[/IP][PORT]80[/PORT] [IP]175.41.140.23[/IP][PORT]443[/PORT] [IP]144.2.1.1[/IP][PORT]443[/PORT] [IP]111.221.29.30[/IP][PORT]80[/PORT] [IP]23.99.125.55[/IP][PORT]80[/PORT] [IP]103.243.221.87[/IP][PORT]80[/PORT] [IP]107.21.211.226[/IP][PORT]80[/PORT] [IP]49.44.118.224[/IP][PORT]443[/PORT] [IP]49.44.50.9[/IP][PORT]80[/PORT] [IP]204.79.197.200[/IP][PORT]80[/PORT] [IP]46.137.205.158[/IP][PORT]80[/PORT] [IP]46.137.205.249[/IP][PORT]443[/PORT] [IP]204.79.197.200[/IP][PORT]80[/PORT] [IP]13.107.5.80[/IP][PORT]80[/PORT] [IP]103.243.221.87[/IP][PORT]443[/PORT] [IP]204.79.197.203[/IP][PORT]80[/PORT] [IP]204.79.197.200[/IP][PORT]80[/PORT] [IP]49.44.50.18[/IP][PORT]80[/PORT] [IP]175.41.140.23[/IP][PORT]443[/PORT] [IP]144.2.1.1[/IP][PORT]443[/PORT] [IP]111.221.29.30[/IP][PORT]80[/PORT] [IP]23.99.125.55[/IP][PORT]80[/PORT] [IP]103.243.221.87[/IP][PORT]80[/PORT] [IP]107.21.211.226[/IP][PORT]80[/PORT]";
$parsed = get_string_between($fullstring, '[IP]', '[/IP]');
echo $parsed;
?>
Output:
49.44.50.18
How to show all IP's