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 {
13 function tor_chk_cmd($cmd_cls, $ch, $ctx, $user_idx, $user_sess, $conn_ip)
15 parent::__construct($cmd_cls, $ch);
17 $this->user_idx = $user_idx;
18 $this->user_sess = $user_sess;
19 $this->conn_ip = $conn_ip;
23 class tor_chk_cmd_cls extends CDS_cmd_cls {
24 function tor_chk_cmd_cls()
26 parent::__construct("tor_chk", 10);
29 function create($cds, $ctx, $user_idx, $user_sess, $conn_ip)
31 if ($cds->dbg_get() > 0) {
32 printf("'tor_chk'::create url:[%s]\n", 'TOR_CHK_URL');
36 $opts = array( CURLOPT_HEADER => 0,
37 CURLOPT_RETURNTRANSFER => 1,
38 CURLOPT_FORBID_REUSE => true,
39 CURLOPT_HTTPHEADER => array('Connection: close'),
41 CURLOPT_POSTFIELDS => array('QueryIP' => $conn_ip));
43 if (($ch = parent::pre_create($cds, TOR_CHK_URL, $opts)) == FALSE)
46 if (parent::create($cds, $ch) == FALSE)
49 $cmd = new tor_chk_cmd($this, $ch, $ctx, $user_idx, $user_sess, $conn_ip);
57 function process($cmd, $ret)
59 if ($this->dbg_get() > 2) {
60 printf("CURL: 'tor_chk' process: curl_multi_getcontent\n");
64 $content = curl_multi_getcontent($cmd->ch_get());
65 if ($this->dbg_get() > 0) { printf("'tor_chk' process: [%s]\n", $content); }
68 if (mb_strpos($content,
69 "The IP Address you entered matches one or more active Tor servers",
70 0, "UTF-8") !== FALSE) {
71 printf("WARNING: stripos ok\n");
74 else if (mb_strpos($content,
75 "The IP Address you entered is NOT an active Tor server",
76 0, "UTF-8") === FALSE) {
77 printf("WARNING: tor check disabled\n");
80 printf("WARNING: NOT an active ...\n");
83 $cmd->ctx->cds_postprocess($cmd->user_idx, $cmd->user_sess, $cmd->conn_ip, $is_tor);
88 function timeout($cmd)
90 printf("'tor_chk' timeout function reached\n");