Skip to content

Commit 4d229b9

Browse files
committed
Randomizing ip list
Added a delay to the crawling of sacnr site. Lengthened the max run time/execution time in the event that the script is not done crawling in two minutes due to the crawl delay. Randomized ips instead of saving them in the same order as they are on sacnr monitor.
1 parent 6e80979 commit 4d229b9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

update_masterlist.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
define('MASTERLIST_FILE', 'masterlist.txt');
66
define('MASTERLIST_FILE_TEMP', 'masterlist.tmp');
77
define('LOG_EXECTIME_FILE', 'execinfo.log');
8-
define('EXEC_TIMELIMIT_MINUTES', 2);
8+
define('EXEC_TIMELIMIT_MINUTES', 3);
99

1010
function get_string_between($string, $start, $end, $offset)
1111
{
@@ -19,10 +19,9 @@ function get_string_between($string, $start, $end, $offset)
1919

2020
set_time_limit(EXEC_TIMELIMIT_MINUTES*60);
2121
$start_time = microtime(true);
22-
$master = fopen(MASTERLIST_FILE_TEMP, 'w');
2322
$i = 0;
2423
$servers = 0;
25-
24+
$iplist = [];
2625
while(1)
2726
{
2827
$page = file_get_contents(MASTERLIST_QUERY_LINK.$i);
@@ -35,11 +34,16 @@ function get_string_between($string, $start, $end, $offset)
3534
{
3635
$ip = get_string_between($page, '<a href="samp://', '">', $pos);
3736
$pos = strpos($page, '<a href="samp://', $pos + 1);
38-
fwrite($master, $ip."\n");
37+
$iplist[] = $ip;
3938
$servers++;
4039
}
4140
$i += MASTERLIST_SERVERS_PER_PAGE;
41+
sleep(1);
4242
}
43+
44+
shuffle($iplist);
45+
$master = fopen(MASTERLIST_FILE_TEMP, 'w');
46+
fwrite($master, implode("\n", $iplist));
4347
fclose($master);
4448

4549
if($servers >= MIN_SERVERS_FOR_REWRITE)

0 commit comments

Comments
 (0)