示例#1
0
function dm_add_pages()
{
    global $current_site, $wpdb, $wp_db_version;
    if (!isset($current_site) && $wp_db_version >= 15260) {
        // WP 3.0 network hasn't been configured
        add_action('admin_notices', 'domain_mapping_warning');
        return false;
    }
    if ($current_site->path != "/") {
        wp_die(__("The domain mapping plugin only works if the site is installed in /. This is a limitation of how virtual servers work and is very difficult to work around.", 'wordpress-mu-domain-mapping'));
    }
    maybe_create_db();
    if (get_site_option('dm_user_settings') && $current_site->blog_id != $wpdb->blogid && !dm_sunrise_warning(false)) {
        add_management_page('Domain Mapping', 'Domain Mapping', 'manage_options', 'domainmapping', 'dm_manage_page');
    }
    if (is_super_admin()) {
        add_submenu_page('index.php', 'Domain Mapping', 'Domain Mapping', 'manage_options', 'dm_admin_page', 'dm_admin_page');
        add_submenu_page('index.php', 'Domains', 'Domains', 'manage_options', 'dm_domains_admin', 'dm_domains_admin');
    }
}
示例#2
0
function dm_admin_page()
{
    global $nxtdb, $current_site;
    if (false == dm_site_admin()) {
        // paranoid? moi?
        return false;
    }
    dm_sunrise_warning();
    maybe_create_db();
    if ($current_site->path != "/") {
        nxt_die(sprintf(__("<strong>Warning!</strong> This plugin will only work if NXTClass is installed in the root directory of your webserver. It is currently installed in &#8217;%s&#8217;.", "nxtclass-mu-domain-mapping"), $current_site->path));
    }
    // set up some defaults
    if (get_site_option('dm_remote_login', 'NA') == 'NA') {
        add_site_option('dm_remote_login', 1);
    }
    if (get_site_option('dm_redirect_admin', 'NA') == 'NA') {
        add_site_option('dm_redirect_admin', 1);
    }
    if (get_site_option('dm_user_settings', 'NA') == 'NA') {
        add_site_option('dm_user_settings', 1);
    }
    if (!empty($_POST['action'])) {
        check_admin_referer('domain_mapping');
        if ($_POST['action'] == 'update') {
            $ipok = true;
            $ipaddresses = explode(',', $_POST['ipaddress']);
            foreach ($ipaddresses as $address) {
                if (($ip = trim($address)) && !preg_match('|^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$|', $ip)) {
                    $ipok = false;
                    break;
                }
            }
            if ($ipok) {
                update_site_option('dm_ipaddress', $_POST['ipaddress']);
            }
            if (intval($_POST['always_redirect_admin']) == 0) {
                $_POST['dm_remote_login'] = 0;
            }
            // disable remote login if redirecting to mapped domain
            update_site_option('dm_remote_login', intval($_POST['dm_remote_login']));
            if (!preg_match('/(--|\\.\\.)/', $_POST['cname']) && preg_match('|^([a-zA-Z0-9-\\.])+$|', $_POST['cname'])) {
                update_site_option('dm_cname', stripslashes($_POST['cname']));
            } else {
                update_site_option('dm_cname', '');
            }
            update_site_option('dm_301_redirect', intval($_POST['permanent_redirect']));
            update_site_option('dm_redirect_admin', intval($_POST['always_redirect_admin']));
            update_site_option('dm_user_settings', intval($_POST['dm_user_settings']));
            update_site_option('dm_no_primary_domain', intval($_POST['dm_no_primary_domain']));
        }
    }
    echo '<h3>' . __('Domain Mapping Configuration', 'nxtclass-mu-domain-mapping') . '</h3>';
    echo '<form method="POST">';
    echo '<input type="hidden" name="action" value="update" />';
    echo "<p>" . __("As a super admin on this network you can set the IP address users need to point their DNS A records at <em>or</em> the domain to point CNAME record at. If you don't know what the IP address is, ping this blog to get it.", 'nxtclass-mu-domain-mapping') . "</p>";
    echo "<p>" . __("If you use round robin DNS or another load balancing technique with more than one IP, enter each address, separating them by commas.", 'nxtclass-mu-domain-mapping') . "</p>";
    _e("Server IP Address: ", 'nxtclass-mu-domain-mapping');
    echo "<input type='text' name='ipaddress' value='" . get_site_option('dm_ipaddress') . "' /><br />";
    // Using a CNAME is a safer method than using IP adresses for some people (IMHO)
    echo "<p>" . __("If you prefer the use of a CNAME record, you can set the domain here. This domain must be configured with an A record or ANAME pointing at an IP address. Visitors may experience problems if it is a CNAME of another domain.", 'nxtclass-mu-domain-mapping') . "</p>";
    echo "<p>" . __("NOTE, this voids the use of any IP address set above", 'nxtclass-mu-domain-mapping') . "</p>";
    _e("Server CNAME domain: ", 'nxtclass-mu-domain-mapping');
    echo "<input type='text' name='cname' value='" . get_site_option('dm_cname') . "' /> (" . dm_idn_warning() . ")<br />";
    echo '<p>' . __('The information you enter here will be shown to your users so they can configure their DNS correctly. It is for informational purposes only', 'nxtclass-mu-domain-mapping') . '</p>';
    echo "<h3>" . __('Domain Options', 'nxtclass-mu-domain-mapping') . "</h3>";
    echo "<ol><li><input type='checkbox' name='dm_remote_login' value='1' ";
    echo get_site_option('dm_remote_login') == 1 ? "checked='checked'" : "";
    echo " /> " . __('Remote Login', 'nxtclass-mu-domain-mapping') . "</li>";
    echo "<li><input type='checkbox' name='permanent_redirect' value='1' ";
    echo get_site_option('dm_301_redirect') == 1 ? "checked='checked'" : "";
    echo " /> " . __("Permanent redirect (better for your blogger's pagerank)", 'nxtclass-mu-domain-mapping') . "</li>";
    echo "<li><input type='checkbox' name='dm_user_settings' value='1' ";
    echo get_site_option('dm_user_settings') == 1 ? "checked='checked'" : "";
    echo " /> " . __('User domain mapping page', 'nxtclass-mu-domain-mapping') . "</li> ";
    echo "<li><input type='checkbox' name='always_redirect_admin' value='1' ";
    echo get_site_option('dm_redirect_admin') == 1 ? "checked='checked'" : "";
    echo " /> " . __("Redirect administration pages to site's original domain (remote login disabled if this redirect is disabled)", 'nxtclass-mu-domain-mapping') . "</li>";
    echo "<li><input type='checkbox' name='dm_no_primary_domain' value='1' ";
    echo get_site_option('dm_no_primary_domain') == 1 ? "checked='checked'" : "";
    echo " /> " . __("Disable primary domain check. Sites will not redirect to one domain name. May cause duplicate content issues.", 'nxtclass-mu-domain-mapping') . "</li></ol>";
    nxt_nonce_field('domain_mapping');
    echo "<p><input class='button-primary' type='submit' value='" . __("Save", 'nxtclass-mu-domain-mapping') . "' /></p>";
    echo "</form><br />";
}