예제 #1
0
function get_remote_mail_domains_internal($recipients)
{
    global $panel_type;
    global $pro_mysql_backup_table;
    global $conf_generated_file_path;
    global $console;
    $domain_list = "";
    $recipient_list = "";
    // Get all domains from the servers for wich we act as backup MX
    $q = "SELECT * FROM {$pro_mysql_backup_table} WHERE type='mail_backup';";
    $r = mysql_query($q) or die("Cannot query {$q} ! line " . __FILE__ . " file " . __FILE__ . " sql said " . mysql_error());
    $n = mysql_num_rows($r);
    for ($i = 0; $i < $n; $i++) {
        $retry = 0;
        $flag = false;
        $a = mysql_fetch_array($r);
        $u = remove_url_protocol($a["server_addr"]);
        if ($u == false) {
            return false;
        }
        $f = $conf_generated_file_path . "/mail_domains." . $u;
        $f_recipients = $conf_generated_file_path . "/mail_recipients." . $u;
        if ($a["status"] == "pending" || !file_exists($f)) {
            if ($recipients == 1) {
                if ($panel_type == "cronjob") {
                    echo "Getting mail recipient list from " . $a["server_addr"] . "/dtc/list_domains.php with login " . $a["server_login"] . " and writting to disk.\n";
                } else {
                    $console .= "Getting mail recipient list from " . $a["server_addr"] . "/dtc/list_domains.php with login " . $a["server_login"] . " and writting to disk.\n";
                }
            } else {
                if ($panel_type == "cronjob") {
                    echo "Getting mail domain list from " . $a["server_addr"] . "/dtc/list_domains.php with login " . $a["server_login"] . " and writting to disk.\n";
                } else {
                    $console .= "Getting mail domain list from " . $a["server_addr"] . "/dtc/list_domains.php with login " . $a["server_login"] . " and writting to disk.<br>";
                }
            }
            $remote_file = get_remote_mail($a, 0);
            if ($remote_file != false) {
                $fp = fopen($f, "w+");
                fwrite($fp, $remote_file);
                fclose($fp);
                // Check file is not zero lenght
                $fp = fopen($f, "r");
                fseek($fp, 0, SEEK_END);
                $size = ftell($fp);
                fclose($fp);
                //now grab the recipients for these remote MX
                $remote_file_recipients = get_remote_mail($a, 1);
                if (!$remote_file_recipients) {
                    //since we couldn't get the remote file, we need to relay for all emails
                    //TODO loop through each line, and prepend @
                    $domain_list = explode("\n", $remote_file);
                    $remote_file_recipients = "";
                    foreach ($domain_list as $domain) {
                        if (isset($domain) && strlen($domain) > 0) {
                            $remote_file_recipients .= "@" . $domain . "\n";
                        }
                    }
                }
                $fp = fopen($f_recipients, "w+");
                fwrite($fp, $remote_file_recipients);
                fclose($fp);
                // Check file is not zero lenght
                $fp = fopen($f_recipients, "r");
                fseek($fp, 0, SEEK_END);
                $size = ftell($fp);
                fclose($fp);
                if ($size > 0) {
                    $domain_list .= $remote_file;
                    $recipient_list .= $remote_file_recipients;
                    $q2 = "UPDATE {$pro_mysql_backup_table} SET status='done' WHERE id='" . $a["id"] . "';";
                    $r2 = mysql_query($q2) or die("Cannot query {$q2} ! line " . __FILE__ . " file " . __FILE__ . " sql said " . mysql_error());
                    if ($panel_type == "cronjob") {
                        echo "ok!\n";
                    } else {
                        $console .= "ok!<br>";
                    }
                    $flag = true;
                } else {
                    if ($panel_type == "cronjob") {
                        echo "wrong! File is empty!\n";
                    } else {
                        $console .= "wrong! File is empty!<br>";
                    }
                }
            } else {
                if ($panel_type == "cronjob") {
                    echo "failed!\n";
                } else {
                    $console .= "failed!<br>";
                }
            }
        }
        if ($flag == false) {
            $f_domains = $f;
            if ($recipients == 1) {
                $f = $f_recipients;
            }
            if (file_exists($f) || $recipients == 1) {
                if ($recipients == 1) {
                    if ($panel_type == "cronjob") {
                        echo "Using mail recipient list from cache of " . $a["server_addr"] . "...\n";
                    } else {
                        $console .= "Using mail recipient list from cache of " . $a["server_addr"] . "...<br>";
                    }
                } else {
                    if ($panel_type == "cronjob") {
                        echo "Using mail recipient list from cache of " . $a["server_addr"] . "...\n";
                    } else {
                        $console .= "Using mail recipient list from cache of " . $a["server_addr"] . "...<br>";
                    }
                }
                //if our recipient file doesn't exist, but our domains one does
                if (!file_exists($f) && $recipients == 1 && file_exists($f_domains)) {
                    $f = $f_domains;
                }
                $fp = fopen($f, "r");
                fseek($fp, 0, SEEK_END);
                $size = ftell($fp);
                if ($size > 0) {
                    fseek($fp, 0);
                    if ($recipients == 1) {
                        if ($f == $f_domains) {
                            //we need to generate a fake recipient file for now
                            $domain_list .= fread($fp, $size);
                            $domains_array = explode("\n", $domain_list);
                            foreach ($domains_array as $domain) {
                                if (isset($domain) && strlen($domain) > 0) {
                                    $recipient_list .= "@" . $domain . "\n";
                                }
                            }
                        } else {
                            //we have a real recipient file to read here
                            $recipient_list .= fread($fp, $size);
                        }
                    } else {
                        $domain_list .= fread($fp, $size);
                    }
                } else {
                    $console .= "File [" . $f . "] is empty<br>\n";
                }
                fclose($fp);
            } else {
                if ($panel_type == "cronjob") {
                    echo "Cache file not present, probably failed to read from remote host\n";
                } else {
                    $console .= "Cache file not present, probably failed to read from remote host<br>";
                }
            }
        }
    }
    if ($recipients == 1) {
        return $recipient_list;
    } else {
        return $domain_list;
    }
}
					<div class="highlight_slides">
<?php 
while ($slideCount <= $slideTotal) {
    $slideId = 'slide_' . $slideCount;
    ?>
						<div class="slide<?php 
    if ($slideCount > 1) {
        echo ' hide toggleFade';
    }
    ?>
" data-slide="<?php 
    echo $slideCount;
    ?>
">
<?php 
    $slideImageUrl = remove_url_protocol(esc_url(get_post_meta(get_the_ID(), 'slide_' . $slideCount . '_url', true)));
    $slideYouTubeUrl = esc_url(get_post_meta(get_the_ID(), 'slide_' . $slideCount . '_youtube_url', true));
    if ($slideYouTubeUrl) {
        ?>
							<iframe width="940" height="492" src="<?php 
        echo $slideYouTubeUrl;
        ?>
" allowfullscreen></iframe>
<?php 
    } else {
        ?>
							<img src="<?php 
        echo $slideImageUrl;
        ?>
" class="highlight" alt="">
<?php 
예제 #3
0
function get_remote_ns_domains()
{
    global $pro_mysql_backup_table;
    global $conf_generated_file_path;
    global $console;
    global $panel_type;
    $domain_list = "";
    // Get all domains from the servers for wich we act as backup MX
    $q = "SELECT * FROM {$pro_mysql_backup_table} WHERE type='dns_backup';";
    $r = mysql_query($q) or die("Cannot query {$q} ! line " . __FILE__ . " file " . __FILE__ . " sql said " . mysql_error());
    $n = mysql_num_rows($r);
    for ($i = 0; $i < $n; $i++) {
        $retry = 0;
        $flag = false;
        $a = mysql_fetch_array($r);
        $u = remove_url_protocol($a["server_addr"]);
        if ($u == false) {
            return false;
        }
        $f = $conf_generated_file_path . "/dns_domains." . $u;
        if ($a["status"] == "pending" || !file_exists($f)) {
            if ($panel_type == "cronjob") {
                echo "Getting dns domain list from " . $a["server_addr"] . "/dtc/list_domains.php with login " . $a["server_login"] . " and writting to disk.\n";
            } else {
                $console .= "Getting dns domain list from " . $a["server_addr"] . "/dtc/list_domains.php with login " . $a["server_login"] . " and writting to disk.<br>";
            }
            $remote_file = get_remote_ns($a);
            if ($remote_file != false) {
                $fp = fopen($f, "w+");
                fwrite($fp, $remote_file);
                fclose($fp);
                // Check filesize before db update
                $fp = fopen($f, "r");
                $test = fseek($fp, 0, SEEK_END);
                $size = ftell($fp);
                fclose($fp);
                if ($size > 0) {
                    $domain_list .= $remote_file;
                    $q2 = "UPDATE {$pro_mysql_backup_table} SET status='done' WHERE id='" . $a["id"] . "';";
                    $r2 = mysql_query($q2) or die("Cannot query {$q2} ! line " . __FILE__ . " file " . __FILE__ . " sql said " . mysql_error());
                    if ($panel_type == "cronjob") {
                        echo "ok!\n";
                    } else {
                        $console .= "ok!<br>";
                    }
                    $flag = true;
                } else {
                    if ($panel_type == "cronjob") {
                        echo "wrong! File is empty!!!\n";
                    } else {
                        $console .= "wrong! File is empty!!!<br>";
                    }
                }
            } else {
                if ($panel_type == "cronjob") {
                    echo "failed!\n";
                } else {
                    $console .= "failed!<br>";
                }
            }
        }
        if ($flag == false) {
            if (file_exists($f)) {
                if ($panel_type == "cronjob") {
                    echo "Using mail domain list from cache of " . $a["server_addr"] . "...\n";
                } else {
                    $console .= "Using mail domain list from cache of " . $a["server_addr"] . "...<br>";
                }
                $fp = fopen($f, "r");
                $test = fseek($fp, 0, SEEK_END);
                if ($test == -1) {
                    if ($panel_type == "cronjob") {
                        echo "Failed to seek to end of {$f}\n";
                    } else {
                        $console .= "Failed to seek to end of {$f}<br>";
                    }
                }
                $size = ftell($fp);
                if ($size > 0) {
                    fseek($fp, 0);
                    $domain_list .= fread($fp, $size);
                } else {
                    $console .= "File [" . $f . "] is empty\n";
                }
                fclose($fp);
            } else {
                if ($panel_type == "cronjob") {
                    echo "Cache file not present, probably failed to read from remote host\n";
                } else {
                    $console .= "Cache file not present, probably failed to read from remote host<br>";
                }
            }
        }
    }
    return $domain_list;
}