3 require_once($G_base . 'Obj/curl-de-sac.phh');
5 define('TOR_CHK_URL', 'http://localhost/curl-de-sac/test/tor_mock.ppp');
7 class Tor_chk_cmd extends CDS_cmd {
14 function Tor_chk_cmd($cmd_cls, $ch, $ctx, $user_idx, $user_sess, $conn_ip, $is_auth)
16 parent::__construct($cmd_cls, $ch);
18 $this->user_idx = $user_idx;
19 $this->user_sess = $user_sess;
20 $this->conn_ip = $conn_ip;
21 $this->is_auth = $is_auth;
25 class Tor_chk_cmd_cls extends CDS_cmd_cls {
26 function Tor_chk_cmd_cls()
28 parent::__construct("tor_chk", 10);
31 function create($cds, $ctx, $user_idx, $user_sess, $conn_ip, $is_auth)
33 if ($cds->dbg_get() > 0) {
34 printf("'tor_chk'::create url:[%s]\n", 'TOR_CHK_URL');
38 $opts = array( CURLOPT_HEADER => 0,
39 CURLOPT_RETURNTRANSFER => 1,
40 CURLOPT_FORBID_REUSE => true,
41 CURLOPT_HTTPHEADER => array('Connection: close'),
43 CURLOPT_POSTFIELDS => array('QueryIP' => $conn_ip));
45 if (($ch = parent::pre_create($cds, TOR_CHK_URL, $opts)) == FALSE)
48 if (parent::create($cds, $ch) == FALSE)
51 $cmd = new Tor_chk_cmd($this, $ch, $ctx, $user_idx, $user_sess, $conn_ip, $is_auth);
59 function process($cmd, $ret)
61 if ($this->dbg_get() > 2) {
62 printf("CURL: 'tor_chk' process: curl_multi_getcontent\n");
66 $content = curl_multi_getcontent($cmd->ch_get());
67 if ($this->dbg_get() > 0) { printf("'tor_chk' process: [%s]\n", $content); }
70 if (mb_strpos($content,
71 "The IP Address you entered matches one or more active Tor servers",
72 0, "UTF-8") !== FALSE) {
73 // printf("WARNING: stripos ok\n");
76 else if (mb_strpos($content,
77 "The IP Address you entered is NOT an active Tor server",
78 0, "UTF-8") === FALSE) {
79 printf("WARNING: tor check disabled\n");
82 // printf("WARNING: NOT an active Tor server on IP [%s]\n", $cmd->conn_ip);
86 $cmd->ctx->tor_chk_postprocess($cmd->user_idx, $cmd->user_sess, $cmd->conn_ip, $cmd->is_auth, $is_tor);
91 function timeout($cmd)
93 printf("'tor_chk' timeout function reached\n");