php include curl php include kernel proxy validators validators php pr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
include 'curl.php';
include 'kernel/proxy/validators/validators.php';
print "ProxyChecker started!\n"; flush();
$proxies = file('proxylist.txt');
print "Proxies count: " . sizeof($proxies) . "\n"; flush();
$proxies = array_unique($proxies);
print "Unique proxies count: " .sizeof($proxies) . "\n"; flush();
$alive_proxies = array();
$iterator = 0;
$cURL = new cURL;
$cURL->setOption('TIMEOUT', 5);
$ProxyValidator_Kontakt = new Cy_ProxyValidate_Vkontakte($cURL);
$ProxyValidator_Codeen = new Cy_ProxyValidate_Codeen($cURL);
define('TIME', time());
foreach ($proxies as $proxy) {
$proxy = trim($proxy);
$iterator++;
$isCodeenValidated = false;
$isKontaktValidated = false;
$cURL->setOption('PROXY', $proxy);
/**
* Codeen validations
*/
if($isCodeenValidated = $ProxyValidator_Codeen->validateGetQuery()) {
$ProxyValidator_Codeen->addAliveProxy($proxy);
} else {
$ProxyValidator_Codeen->addBlackProxy($proxy);
}
if($isCodeenValidated && ($isKontaktValidated = $ProxyValidator_Kontakt->validateGetQuery())) {
$ProxyValidator_Kontakt->addAliveProxy($proxy);
} else {
$ProxyValidator_Kontakt->addBlackProxy($proxy);
}
print "\n#{$iterator} Proxy {$proxy} is validated. Results: \n";
print "Codeen Networks: " . ($isCodeenValidated ? 'Ok' : 'Failed');
print "\n";
print "VKontakte: ". ($isKontaktValidated ? 'Ok' : 'Failed');
print "\n\n";
if($iterator % 10 == 0) {
print "\n=> {$iterator} proxies checked. ";
print "Some stats: \n";
print "=> Codeen free: " . $ProxyValidator_Codeen->getAliveProxiesCount() . "\n";
print "=> VKontakte alive: " . $ProxyValidator_Kontakt->getAliveProxiesCount() . "\n";
printf("=> CheckSpeed: %4f secods \n", (time() - TIME ) / $iterator);
// Store results
writeResults('results/vkontakte/alive.txt', $ProxyValidator_Kontakt->getAliveProxies());
writeResults('results/vkontakte/black.txt', $ProxyValidator_Kontakt->getBlackProxies());
writeResults('results/codeen/alive.txt', $ProxyValidator_Codeen->getAliveProxies());
writeResults('results/codeen/black.txt', $ProxyValidator_Codeen->getBlackProxies());
writeResults('results/black.txt', array_intersect($ProxyValidator_Codeen->getBlackProxies(), $ProxyValidator_Kontakt->getBlackProxies()));
}
}
function writeResults($file, $array) {
$fp = fopen($file, 'w+');
fwrite($fp, implode("\n", $array));
fclose($fp);
}