Exemplo n.º 1
0
function get_remote_mail($a, $recipients)
{
    global $conf_use_ssl;
    global $console;
    global $keep_mail_generate_flag;
    global $panel_type;
    $flag = false;
    $retry = 0;
    $rcpthosts_file = "";
    //init variable here
    if ($recipients == 1) {
        $url = $a["server_addr"] . '/dtc/list_domains.php?action=list_mx_recipients&login='******'&pass='******'/dtc/list_domains.php?action=list_mx&login='******'&pass=' . $a["server_pass"];
    }
    while ($retry < 3 && $flag == false) {
        $a_vers = explode(".", phpversion());
        if ($a_vers[0] <= 4 && $a_vers[1] < 3) {
            // Todo: use exec(lynx -source) because HTTPS will not work !
            $lines = "";
            if ($panel_type == "cronjob") {
                echo "\nUsing lynx -source on " . $a["server_addr"] . " with login " . $a["server_login"] . "...";
            } else {
                $console .= "<br>Using lynx -source on " . $a["server_addr"] . " with login " . $a["server_login"] . "...";
            }
            $result = exec("lynx -source \"{$url}\"", $lines, $return_val);
            $nline = sizeof($lines);
            if (strstr($lines[0], "<dtc_backup_mx_domain_list>") && strstr($lines[$nline - 2], "</dtc_backup_mx_domain_list>") || $recipients == 1 && strstr($lines[0], "<dtc_backup_mx_recipient_list>") && strstr($lines[$nline - 2], "</dtc_backup_mx_recipient_list>")) {
                for ($j = 1; $j < $nline - 1; $j++) {
                    $rcpthosts_file .= $lines[$j] . "\n";
                }
                $flag = true;
                if ($panel_type == "cronjob") {
                    echo "success!\n";
                } else {
                    $console .= "success!<br>";
                }
            } else {
                if ($panel_type == "cronjob") {
                    echo "Failed!\n";
                } else {
                    $console .= "Failed!<br>";
                }
            }
            //			$rcpthosts_file .= "";
        } else {
            if ($panel_type == "cronjob") {
                echo "\nUsing php dtc_HTTPRequest class on " . $a["server_addr"] . " with login " . $a["server_login"] . "...";
            } else {
                $console .= "<br>Using php dtc_HTTPRequest class on " . $a["server_addr"] . " with login " . $a["server_login"] . "...";
            }
            $httprequest = new dtc_HTTPRequest("{$url}");
            $lines = $httprequest->DownloadToStringArray();
            if ($lines != FALSE) {
                $nline = sizeof($lines);
                if (strstr($lines[0], "<dtc_backup_mx_domain_list>") && strstr($lines[$nline - 1], "</dtc_backup_mx_domain_list>") || $recipients == 1 && strstr($lines[0], "<dtc_backup_mx_recipient_list>") && strstr($lines[$nline - 1], "</dtc_backup_mx_recipient_list>")) {
                    for ($j = 1; $j < $nline - 1; $j++) {
                        $rcpthosts_file .= $lines[$j] . "\n";
                    }
                    $flag = true;
                    if ($panel_type == "cronjob") {
                        echo "success!\n";
                    } else {
                        $console .= "success!<br>";
                    }
                }
            }
        }
        $retry++;
        if ($flag == false) {
            if ($panel_type == "cronjob") {
                echo "failed: delaying in 3s!\n";
            } else {
                $console .= "failed: delaying in 3s!<br>";
            }
            sleep(3);
        }
    }
    if ($flag == false) {
        $keep_mail_generate_flag = "yes";
        return false;
    } else {
        return $rcpthosts_file;
    }
}
Exemplo n.º 2
0
 function DownloadToString()
 {
     // store errors in case we need to handle them
     $errno;
     $errstr;
     $response = '';
     $crlf = "\r\n";
     // generate request
     $req = 'GET ' . $this->_uri . ' HTTP/1.0' . $crlf . 'Host: ' . $this->_host . $crlf . $crlf;
     // fetch from URL
     $this->_fp = fsockopen(($this->_protocol == 'https' ? 'ssl://' : '') . $this->_host, $this->_port, $errno, $errstr, $this->_timeout);
     fwrite($this->_fp, $req);
     $a_vers = explode(".", phpversion());
     $use_stream = TRUE;
     if ($a_vers[0] <= 4 && $a_vers[1] < 3) {
         // first < 4.3, then we need to use socket rather than stream
         $use_stream = FALSE;
     }
     if ($use_stream) {
         stream_set_blocking($this->_fp, TRUE);
         stream_set_timeout($this->_fp, $this->_timeout);
     } else {
         socket_set_blocking($this->_fp, TRUE);
         socket_set_timeout($this->_fp, $this->_timeout);
     }
     // get the socket status
     $info;
     if ($use_stream) {
         $info = stream_get_meta_data($this->_fp);
     } else {
         $info = socket_get_status($this->_fp);
     }
     while (is_resource($this->_fp) && $this->_fp && !feof($this->_fp) && !$info['timed_out']) {
         $response .= fread($this->_fp, 4096);
         if ($use_stream) {
             $info = stream_get_meta_data($this->_fp);
         } else {
             $info = socket_get_status($this->_fp);
         }
         @ob_flush();
         flush();
     }
     fclose($this->_fp);
     // split header and body
     $pos = strpos($response, $crlf . $crlf);
     if ($pos === false) {
         return $response;
     }
     $header = substr($response, 0, $pos);
     $body = substr($response, $pos + 2 * strlen($crlf));
     // parse headers
     $headers = array();
     $lines = explode($crlf, $header);
     foreach ($lines as $line) {
         if (($pos = strpos($line, ':')) !== false) {
             $headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos + 1));
         }
     }
     // redirection?
     if (isset($headers['location'])) {
         $http = new dtc_HTTPRequest($headers['location']);
         return $http->DownloadToString($http);
     } else {
         return $body;
     }
 }
Exemplo n.º 3
0
function commitTriggerToRemoteInternal($a, $recipients)
{
    $flag = false;
    $retry = 0;
    if ($recipients == 1) {
        $url = $a["server_addr"] . '/dtc/list_domains.php?action=trigger_update_mx_recipients&login='******'&pass='******'/dtc/list_domains.php?action=update_request&login='******'&pass=' . $a["server_pass"];
    }
    while ($retry < 3 && $flag == false) {
        $a_vers = explode(".", phpversion());
        if ($a_vers[0] <= 4 && $a_vers[1] < 3) {
            echo "using lynx -source...";
            $result = exec("lynx -source \"{$url}\"", $lines, $return_val);
        } else {
            $httprequest = new dtc_HTTPRequest("{$url}");
            $lines = $httprequest->DownloadToStringArray();
        }
        if ($lines != FALSE) {
            if ($recipients == 1) {
                if (strstr($lines[0], "Successfuly recieved trigger for MX!") != false) {
                    $flag = true;
                }
            } else {
                if (strstr($lines[0], "Successfuly recieved trigger!") != false) {
                    $flag = true;
                }
            }
        }
        $retry++;
        if ($flag == false) {
            sleep(3);
        }
    }
    return $flag;
}
Exemplo n.º 4
0
function get_remote_ns($a)
{
    global $console;
    global $keep_dns_generate_flag;
    global $panel_type;
    $retry = 0;
    $flag = FALSE;
    $named_file = "";
    //init $named_file var
    $url = $a["server_addr"] . '/dtc/list_domains.php?action=list_dns&login='******'&pass=' . $a["server_pass"];
    while ($retry < 3 && $flag == FALSE) {
        $a_vers = explode(".", phpversion());
        if ($a_vers[0] <= 4 && $a_vers[1] < 3) {
            if ($panel_type == "cronjob") {
                echo "\nUsing lynx -source on " . $a["server_addr"] . " with login " . $a["server_login"] . ".\n";
            } else {
                $console .= "<br>Using lynx -source on " . $a["server_addr"] . " with login " . $a["server_login"] . ".<br>\n";
            }
            $result = exec("lynx -source \"{$url}\"", $lines, $return_val);
        } else {
            if ($panel_type == "cronjob") {
                echo "\nUsing php dtc_HTTPRequest class on " . $a["server_addr"] . " with login " . $a["server_login"] . ".";
            } else {
                $console .= "<br>Using php dtc_HTTPRequest class on " . $a["server_addr"] . " with login " . $a["server_login"] . ".";
            }
            $httprequest = new dtc_HTTPRequest("{$url}");
            $lines = $httprequest->DownloadToStringArray();
            if ($lines === FALSE) {
                $lines = array();
            }
        }
        if ($lines != FALSE) {
            $nline = sizeof($lines);
            if (strstr($lines[0], "// Start of DTC generated slave zone file for backuping") && strstr($lines[$nline - 1], "// End of DTC generated slave zone file for backuping")) {
                for ($j = 0; $j < $nline; $j++) {
                    $named_file .= $lines[$j] . "\n";
                }
                $flag = true;
                if ($panel_type == "cronjob") {
                    echo "Success!\n";
                } else {
                    $console .= "Success!<br>";
                }
            }
        }
        $retry++;
        if ($flag == FALSE) {
            if ($panel_type == "cronjob") {
                $console .= "Failed: delaying 3s!\n";
            } else {
                $console .= "Failed: delaying 3s!<br>";
            }
            sleep(3);
        }
    }
    if ($flag == FALSE) {
        $keep_dns_generate_flag = "yes";
        return FALSE;
    } else {
        return $named_file;
    }
}