Exemple #1
0
function cloudflare_conf()
{
    if (function_exists('current_user_can') && !current_user_can('manage_options')) {
        die(__('Cheatin’ uh?'));
    }
    global $cloudflare_api_key, $cloudflare_api_email, $is_cf;
    global $wpdb;
    // get raw domain - may include www.
    $urlparts = parse_url(site_url());
    $raw_domain = $urlparts["host"];
    $curl_installed = function_exists('curl_init');
    if ($curl_installed) {
        // Attempt to get the matching host from CF
        $domain = get_domain($cloudflare_api_key, $cloudflare_api_email, $raw_domain);
        // If not found, default to pulling the domain via client side.
        if (!$domain) {
            $domain = $raw_domain;
        }
    } else {
        $domain = $raw_domain;
    }
    define("THIS_DOMAIN", $domain);
    $db_results = array();
    if (isset($_POST['submit']) && check_admin_referer('cloudflare-db-api', 'cloudflare-db-api-nonce')) {
        if (function_exists('current_user_can') && !current_user_can('manage_options')) {
            die(__('Cheatin’ uh?'));
        }
        $key = $_POST['key'];
        $email = $_POST['email'];
        $dev_mode = esc_sql($_POST["dev_mode"]);
        if (empty($key)) {
            $key_status = 'empty';
            $ms[] = 'new_key_empty';
            delete_option('cloudflare_api_key');
        } else {
            $ms[] = 'new_key_valid';
            update_option('cloudflare_api_key', esc_sql($key));
            update_option('cloudflare_api_key_set_once', "TRUE");
        }
        if (empty($email) || !is_email($email)) {
            $email_status = 'empty';
            $ms[] = 'new_email_empty';
            delete_option('cloudflare_api_email');
        } else {
            $ms[] = 'new_email_valid';
            update_option('cloudflare_api_email', esc_sql($email));
            update_option('cloudflare_api_email_set_once', "TRUE");
        }
        $messages = array('new_key_empty' => array('color' => 'aa0', 'text' => __('Your key has been cleared.')), 'new_key_valid' => array('color' => '2d2', 'text' => __('Your key has been verified. Happy blogging!')), 'new_email_empty' => array('color' => 'aa0', 'text' => __('Your email has been cleared.')), 'new_email_valid' => array('color' => '2d2', 'text' => __('Your email has been verified. Happy blogging!')));
        if ($curl_installed) {
            if ($key != "" && $email != "") {
                set_dev_mode(esc_sql($key), esc_sql($email), THIS_DOMAIN, $dev_mode);
                if ($dev_mode) {
                    $ms[] = 'dev_mode_on';
                } else {
                    $ms[] = 'dev_mode_off';
                }
            }
            $messages['dev_mode_on'] = array('color' => '2d2', 'text' => __('Development mode is On. Happy blogging!'));
            $messages['dev_mode_off'] = array('color' => 'aa0', 'text' => __('Development mode is Off. Happy blogging!'));
        }
    }
    ?>
    <?php 
    if (!empty($_POST['submit'])) {
        ?>
    <div id="message" class="updated fade"><p><strong><?php 
        _e('Options saved.');
        ?>
</strong></p></div>
    <?php 
    }
    ?>
    <div class="wrap">

    <?php 
    if ($is_cf) {
        ?>
        <h3>You are currently using CloudFlare!</h3>
    <?php 
    }
    ?>

    <h4><?php 
    _e('CLOUDFLARE WORDPRESS PLUGIN:');
    ?>
</h4>
        <?php 
    //    <div class="narrow">
    ?>

CloudFlare has developed a plugin for WordPress. By using the CloudFlare WordPress Plugin, you receive: 
<ol>
<li>Correct IP Address information for comments posted to your site</li>
<li>Better protection as spammers from your WordPress blog get reported to CloudFlare</li>
</ol>

<h4>VERSION COMPATIBILITY:</h4>

The plugin is compatible with WordPress version 2.8.6 and later. The plugin will not install unless you have a compatible platform.

<h4>THINGS YOU NEED TO KNOW:</h4>

<ol>
<li>The main purpose of this plugin is to ensure you have no change to your originating IPs when using CloudFlare. Since CloudFlare acts a reverse proxy, connecting IPs now come from CloudFlare's range. This plugin will ensure you can continue to see the originating IP. Once you install the plugin, the IP benefit will be activated.</li>
 
<li>Every time you click the 'spam' button on your blog, this threat information is sent to CloudFlare to ensure you are constantly getting the best site protection.</li>

<li>We recommend that any user on CloudFlare with WordPress use this plugin. </li>

<li>NOTE: This plugin is complementary to Akismet and W3 Total Cache. We recommend that you continue to use those services.</li> 

</ol>

<h4>MORE INFORMATION ON CLOUDFLARE:</h4>

CloudFlare is a service that makes websites load faster and protects sites from online spammers and hackers. Any website with a root domain (ie www.mydomain.com) can use CloudFlare. On average, it takes less than 5 minutes to sign up. You can learn more here: <a href="http://www.cloudflare.com/">CloudFlare.com</a>.

    <?php 
    if ($curl_installed) {
        $dev_mode = get_dev_mode_status($cloudflare_api_key, $cloudflare_api_email, THIS_DOMAIN);
    }
    ?>

    <hr />

    <form action="" method="post" id="cloudflare-conf">
    <?php 
    wp_nonce_field('cloudflare-db-api', 'cloudflare-db-api-nonce');
    ?>
    <?php 
    if (get_option('cloudflare_api_key') && get_option('cloudflare_api_email')) {
        ?>
    <?php 
    } else {
        ?>
 
        <p><?php 
        printf(__('Input your API key from your CloudFlare Accounts Settings page here. To find your API key, log in to <a href="%1$s">CloudFlare</a> and go to \'Account\'.'), 'https://www.cloudflare.com/my-account.html');
        ?>
</p>
    <?php 
    }
    ?>
    <?php 
    if ($ms) {
        foreach ($ms as $m) {
            ?>
    <p style="padding: .5em; color: #<?php 
            echo $messages[$m]['color'];
            ?>
; font-weight: bold;"><?php 
            echo $messages[$m]['text'];
            ?>
</p>
    <?php 
        }
    }
    ?>
    <h3><label for="key"><?php 
    _e('CloudFlare API Key');
    ?>
</label></h3>
    <p><input id="key" name="key" type="text" size="50" maxlength="48" value="<?php 
    echo get_option('cloudflare_api_key');
    ?>
" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /> (<?php 
    _e('<a href="https://www.cloudflare.com/my-account.html">Get this?</a>');
    ?>
)</p>
    <h3><label for="email"><?php 
    _e('CloudFlare API Email');
    ?>
</label></h3>
    <p><input id="email" name="email" type="text" size="50" maxlength="48" value="<?php 
    echo get_option('cloudflare_api_email');
    ?>
" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /> (<?php 
    _e('<a href="https://www.cloudflare.com/my-account.html">Get this?</a>');
    ?>
)
    <h3><label for="dev_mode"><?php 
    _e('Development Mode');
    ?>
</label> <span style="font-size:9pt;">(<a href="http://support.cloudflare.com/kb/what-do-the-various-cloudflare-settings-do/what-does-cloudflare-development-mode-mean" " target="_blank">What is this?</a>)</span></h3>

    <?php 
    if ($curl_installed) {
        ?>
    <div style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;">
    <input type="radio" name="dev_mode" value="0" <?php 
        if ($dev_mode == "off") {
            echo "checked";
        }
        ?>
> Off
    <input type="radio" name="dev_mode" value="1" <?php 
        if ($dev_mode == "on") {
            echo "checked";
        }
        ?>
> On
    </div>
    <?php 
    } else {
        ?>
    You cannot toggle development mode because cURL is not installed for your domain.  Please contact a server administrator for assistance with installing cURL.
    <?php 
    }
    ?>
    
    </p>
    <p class="submit"><input type="submit" name="submit" value="<?php 
    _e('Update options &raquo;');
    ?>
" /></p>
    </form>

        <?php 
    //    </div>
    ?>
    </div>
    <?php 
}
function cloudflare_conf()
{
    if (function_exists('current_user_can') && !current_user_can('manage_options')) {
        die(__('Cheatin&#8217; uh?'));
    }
    global $cloudflare_zone_name, $cloudflare_api_key, $cloudflare_api_email, $cloudflare_protocol_rewrite, $is_cf;
    global $wpdb;
    load_cloudflare_keys();
    $messages = array('ip_restore_on' => array('text' => __('Plugin Status: True visitor IP is being restored')), 'comment_spam_on' => array('text' => __('Plugin Status: CloudFlare will be notified when you mark comments as spam')), 'comment_spam_off' => array('text' => __('Plugin Status: CloudFlare will NOT be notified when you mark comments as spam, enter your API details below')), 'curl_not_installed' => array('text' => __('Plugin Status: cURL is not installed/enabled on your server. You will not be able to toggle <a href="https://support.cloudflare.com/hc/en-us/articles/200168246-What-does-CloudFlare-Development-mode-mean-" target="_blank">development mode</a> via this plugin. If you wish to do this, please contact your server administrator or hosting provider for assistance with installing cURL.')), 'dev_mode_on' => array('text' => __('Development mode is On. Happy blogging!')), 'dev_mode_off' => array('text' => __('Development mode is Off. Happy blogging!')), 'protocol_rewrite_on' => array('text' => __('Protocol rewriting is On. Happy blogging!')), 'protocol_rewrite_off' => array('text' => __('Protocol rewriting is Off. Happy blogging!')), 'manual_entry' => array('text' => __('Enter your CloudFlare domain name, e-mail address and API key below')), 'options_saved' => array('text' => __('Options Saved')));
    $notices = array();
    $warnings = array();
    $errors = array();
    $notices[] = 'ip_restore_on';
    // Get raw domain - may include "www."
    $urlparts = parse_url(site_url());
    $raw_domain = $urlparts["host"];
    // If we don't have a domain name already populated
    if (empty($cloudflare_zone_name)) {
        if (!empty($cloudflare_api_key) && !empty($cloudflare_api_email)) {
            // Attempt to get the matching host from CF
            $getDomain = get_domain($cloudflare_api_key, $cloudflare_api_email, $raw_domain);
            // If not found, default to pulling the domain via client side.
            if (is_wp_error($getDomain)) {
                $messages['get_domain_failed'] = array('text' => __('Unable to automatically get domain - ' . $getDomain->get_error_message() . ' - please tell us your domain in the form below'));
                $warnings[] = 'get_domain_failed';
            } else {
                update_option('cloudflare_zone_name', esc_sql($getDomain));
                update_option('cloudflare_zone_name_set_once', "TRUE");
                load_cloudflare_keys();
            }
        }
    }
    $db_results = array();
    if (isset($_POST['submit']) && check_admin_referer('cloudflare-db-api', 'cloudflare-db-api-nonce')) {
        if (function_exists('current_user_can') && !current_user_can('manage_options')) {
            die(__('Cheatin&#8217; uh?'));
        }
        $zone_name = $_POST['cloudflare_zone_name'];
        $key = $_POST['key'];
        $email = $_POST['email'];
        $dev_mode = esc_sql($_POST["dev_mode"]);
        $protocol_rewrite = esc_sql($_POST["protocol_rewrite"]);
        if (empty($zone_name)) {
            $zone_status = 'empty';
            $zone_message = 'Your domain name has been cleared.';
            delete_option('cloudflare_zone_name');
        } else {
            $zone_message = 'Your domain name has been saved.';
            update_option('cloudflare_zone_name', esc_sql($zone_name));
            update_option('cloudflare_zone_name_set_once', "TRUE");
        }
        if (empty($key)) {
            $key_status = 'empty';
            $key_message = 'Your key has been cleared.';
            delete_option('cloudflare_api_key');
        } else {
            $key_message = 'Your key has been verified.';
            update_option('cloudflare_api_key', esc_sql($key));
            update_option('cloudflare_api_key_set_once', "TRUE");
        }
        if (empty($email) || !is_email($email)) {
            $email_status = 'empty';
            $email_message = 'Your email has been cleared.';
            delete_option('cloudflare_api_email');
        } else {
            $email_message = 'Your email has been verified.';
            update_option('cloudflare_api_email', esc_sql($email));
            update_option('cloudflare_api_email_set_once', "TRUE");
        }
        if (in_array($protocol_rewrite, array("0", "1")) === TRUE) {
            update_option('cloudflare_protocol_rewrite', $protocol_rewrite);
        }
        // Ipdate the values
        load_cloudflare_keys();
        if ($cloudflare_api_key != "" && $cloudflare_api_email != "" && $cloudflare_zone_name != "" && $dev_mode != "") {
            $result = set_dev_mode(esc_sql($cloudflare_api_key), esc_sql($cloudflare_api_email), $cloudflare_zone_name, $dev_mode);
            if (is_wp_error($result)) {
                trigger_error($result->get_error_message(), E_USER_WARNING);
                $messages['set_dev_mode_failed'] = array('text' => __('Unable to set development mode - ' . $result->get_error_message() . ' - try logging into cloudflare.com to set development mode'));
                $errors[] = 'set_dev_mode_failed';
            } else {
                if ($dev_mode && $result->result == 'success') {
                    $notices[] = 'dev_mode_on';
                } else {
                    if (!$dev_mode && $result->result == 'success') {
                        $notices[] = 'dev_mode_off';
                    }
                }
            }
        }
        $notices[] = 'options_saved';
    }
    if (!empty($cloudflare_api_key) && !empty($cloudflare_api_email) && !empty($cloudflare_zone_name)) {
        $dev_mode = get_dev_mode_status($cloudflare_api_key, $cloudflare_api_email, $cloudflare_zone_name);
        if (is_wp_error($dev_mode)) {
            $messages['get_dev_mode_failed'] = array('text' => __('Unable to get current development mode status - ' . $dev_mode->get_error_message()));
            $errors[] = 'get_dev_mode_failed';
        }
    } else {
        $warnings[] = 'manual_entry';
    }
    if (!empty($cloudflare_api_key) && !empty($cloudflare_api_email)) {
        $notices[] = 'comment_spam_on';
    } else {
        $warnings[] = 'comment_spam_off';
    }
    ?>
    <div class="wrap">

    <?php 
    if ($is_cf) {
        ?>
        <h3>You are currently using CloudFlare!</h3>
    <?php 
    }
    ?>

    <?php 
    if ($notices) {
        foreach ($notices as $m) {
            ?>
    <div class="updated" style="border-left-color: #7ad03a; padding: 10px;"><?php 
            echo $messages[$m]['text'];
            ?>
</div>
    <?php 
        }
    }
    ?>

    <?php 
    if ($warnings) {
        foreach ($warnings as $m) {
            ?>
    <div class="updated" style="border-left-color: #ffba00; padding: 10px;"><em><?php 
            echo $messages[$m]['text'];
            ?>
</em></div>
    <?php 
        }
    }
    ?>

    <?php 
    if ($errors) {
        foreach ($errors as $m) {
            ?>
    <div class="updated" style="border-left-color: #dd3d36; padding: 10px;"><b><?php 
            echo $messages[$m]['text'];
            ?>
</b></div>
    <?php 
        }
    }
    ?>

    <h4><?php 
    _e('CLOUDFLARE WORDPRESS PLUGIN:');
    ?>
</h4>

CloudFlare has developed a plugin for WordPress. By using the CloudFlare WordPress Plugin, you receive:
<ol>
<li>Correct IP Address information for comments posted to your site</li>
<li>Better protection as spammers from your WordPress blog get reported to CloudFlare</li>
<li>If cURL is installed, you can enter your CloudFlare API details so you can toggle <a href="https://support.cloudflare.com/hc/en-us/articles/200168246-What-does-CloudFlare-Development-mode-mean-" target="_blank">Development mode</a> on/off using the form below</li>
</ol>

<h4>VERSION COMPATIBILITY:</h4>

The plugin is compatible with WordPress version 2.8.6 and later. The plugin will not install unless you have a compatible platform.

<h4>THINGS YOU NEED TO KNOW:</h4>

<ol>
<li>The main purpose of this plugin is to ensure you have no change to your originating IPs when using CloudFlare. Since CloudFlare acts a reverse proxy, connecting IPs now come from CloudFlare's range. This plugin will ensure you can continue to see the originating IP. Once you install the plugin, the IP benefit will be activated.</li>

<li>Every time you click the 'spam' button on your blog, this threat information is sent to CloudFlare to ensure you are constantly getting the best site protection.</li>

<li>We recommend that any user on CloudFlare with WordPress use this plugin. </li>

<li>NOTE: This plugin is complementary to Akismet and W3 Total Cache. We recommend that you continue to use those services.</li>

</ol>

<h4>MORE INFORMATION ON CLOUDFLARE:</h4>

CloudFlare is a service that makes websites load faster and protects sites from online spammers and hackers. Any website with a root domain (ie www.mydomain.com) can use CloudFlare. On average, it takes less than 5 minutes to sign up. You can learn more here: <a href="http://www.cloudflare.com/" target="_blank">CloudFlare.com</a>.

    <hr />

    <form action="" method="post" id="cloudflare-conf">
    <?php 
    wp_nonce_field('cloudflare-db-api', 'cloudflare-db-api-nonce');
    ?>
    <?php 
    if (get_option('cloudflare_api_key') && get_option('cloudflare_api_email')) {
        ?>
    <?php 
    } else {
        ?>
        <p><?php 
        printf(__('Input your API key from your CloudFlare Accounts Settings page here. To find your API key, log in to <a href="%1$s">CloudFlare</a> and go to \'Account\'.'), 'https://www.cloudflare.com/my-account.html');
        ?>
</p>
    <?php 
    }
    ?>
    <h3><label for="cloudflare_zone_name"><?php 
    _e('CloudFlare Domain Name');
    ?>
</label></h3>
    <p>
        <input id="cloudflare_zone_name" name="cloudflare_zone_name" type="text" size="50" maxlength="255" value="<?php 
    echo $cloudflare_zone_name;
    ?>
" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /> (<?php 
    _e('<a href="https://www.cloudflare.com/my-websites" target="_blank">Get this?</a>');
    ?>
)
    </p>
    <p>E.g. Enter domain.com not www.domain.com / blog.domain.com</p>
    <?php 
    if (isset($zone_message)) {
        echo sprintf('<p>%s</p>', $zone_message);
    }
    ?>
    <h3><label for="key"><?php 
    _e('CloudFlare API Key');
    ?>
</label></h3>
    <p>
        <input id="key" name="key" type="text" size="50" maxlength="48" value="<?php 
    echo get_option('cloudflare_api_key');
    ?>
" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /> (<?php 
    _e('<a href="https://www.cloudflare.com/my-account.html" target="_blank">Get this?</a>');
    ?>
)
    </p>
    <?php 
    if (isset($key_message)) {
        echo sprintf('<p>%s</p>', $key_message);
    }
    ?>

    <h3><label for="email"><?php 
    _e('CloudFlare API Email');
    ?>
</label></h3>
    <p>
        <input id="email" name="email" type="text" size="50" maxlength="48" value="<?php 
    echo get_option('cloudflare_api_email');
    ?>
" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /> (<?php 
    _e('<a href="https://www.cloudflare.com/my-account.html" target="_blank">Get this?</a>');
    ?>
)
    </p>
    <?php 
    if (isset($key_message)) {
        echo sprintf('<p>%s</p>', $key_message);
    }
    ?>

    <h3><label for="dev_mode"><?php 
    _e('Development Mode');
    ?>
</label> <span style="font-size:9pt;">(<a href="https://support.cloudflare.com/hc/en-us/articles/200168246-What-does-CloudFlare-Development-mode-mean-" target="_blank">What is this?</a>)</span></h3>

    <div style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;">
    <input type="radio" name="dev_mode" value="0" <?php 
    if ($dev_mode == "off") {
        echo "checked";
    }
    ?>
> Off
    <input type="radio" name="dev_mode" value="1" <?php 
    if ($dev_mode == "on") {
        echo "checked";
    }
    ?>
> On
    </div>

    <h3><label for="protocol_rewrite"><?php 
    _e('HTTPS Protocol Rewriting');
    ?>
</label> <span style="font-size:9pt;">(<a href="https://support.cloudflare.com/hc/en-us/articles/203652674" target="_blank">What is this?</a>)</span></h3>

    <div style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;">
    <input type="radio" name="protocol_rewrite" value="0" <?php 
    if ($cloudflare_protocol_rewrite == 0) {
        echo "checked";
    }
    ?>
> Off
    <input type="radio" name="protocol_rewrite" value="1" <?php 
    if ($cloudflare_protocol_rewrite == 1) {
        echo "checked";
    }
    ?>
> On
    </div>

    <p class="submit"><input type="submit" name="submit" value="<?php 
    _e('Update options &raquo;');
    ?>
" /></p>
    </form>

    </div>
    <?php 
}
Exemple #3
0
function cloudflare_conf()
{
    if (function_exists('current_user_can') && !current_user_can('manage_options')) {
        die(__('哎呀,出错了!'));
    }
    global $cloudflare_api_key, $cloudflare_api_email, $is_cf;
    global $wpdb;
    $messages = array('dev_mode_on' => array('color' => '2d2', 'text' => __('开发模式已开启!')), 'dev_mode_off' => array('color' => 'aa0', 'text' => __('开发模式已关闭!')));
    // get raw domain - may include www.
    $urlparts = parse_url(site_url());
    $raw_domain = $urlparts["host"];
    $curl_installed = function_exists('curl_init');
    $domain = null;
    if ($curl_installed) {
        // Attempt to get the matching host from CF
        $domain = get_domain($cloudflare_api_key, $cloudflare_api_email, $raw_domain);
        // If not found, default to pulling the domain via client side.
        if (is_wp_error($domain)) {
            $messages['get_domain_failed'] = array('color' => 'FFA500', 'text' => __('无法通过 CloudFlare API 获取域名信息,出错信息: ' . $domain->get_error_message()));
            $ms[] = 'get_domain_failed';
            $domain = null;
        }
    }
    if ($domain == null) {
        $domain = $raw_domain;
        $messages['domain_not_found'] = array('color' => 'FFA500', 'text' => __('CloudFlare 未找到您的域名信息,请确认您的域名地址为 ' . $domain));
        $ms[] = 'domain_not_found';
    }
    define("THIS_DOMAIN", $domain);
    $db_results = array();
    if (isset($_POST['submit']) && check_admin_referer('cloudflare-db-api', 'cloudflare-db-api-nonce')) {
        if (function_exists('current_user_can') && !current_user_can('manage_options')) {
            die(__('哎呀,出错了!'));
        }
        $key = $_POST['key'];
        $email = $_POST['email'];
        $dev_mode = esc_sql($_POST["dev_mode"]);
        if (empty($key)) {
            $key_status = 'empty';
            $key_message = 'API Key 已清除。';
            delete_option('cloudflare_api_key');
        } else {
            $key_message = '您的 API Key 已验证。';
            update_option('cloudflare_api_key', esc_sql($key));
            update_option('cloudflare_api_key_set_once', "TRUE");
        }
        if (empty($email) || !is_email($email)) {
            $email_status = 'empty';
            $email_message = 'Email 已清除。';
            delete_option('cloudflare_api_email');
        } else {
            $email_message = '您的 Email 已验证。';
            update_option('cloudflare_api_email', esc_sql($email));
            update_option('cloudflare_api_email_set_once', "TRUE");
        }
        if ($curl_installed) {
            if ($key != "" && $email != "") {
                $result = set_dev_mode(esc_sql($key), esc_sql($email), THIS_DOMAIN, $dev_mode);
                if (is_wp_error($result)) {
                    error_log($result->get_error_message());
                    $messages['set_dev_mode_failed'] = array('color' => 'FF0000', 'text' => __('无法设置开发模式,出错信息: ' . $result->get_error_message()));
                    $ms[] = 'set_dev_mode_failed';
                } else {
                    if ($dev_mode && $result->result == 'success') {
                        $ms[] = 'dev_mode_on';
                    } else {
                        if (!$dev_mode && $result->result == 'success') {
                            $ms[] = 'dev_mode_off';
                        }
                    }
                }
            }
        }
    }
    ?>
    <div class="wrap">

    <?php 
    if ($is_cf) {
        ?>
        <h3>您正在使用 CloudFlare!</h3>
    <?php 
    }
    ?>
    
    <?php 
    if (!empty($_POST['submit'])) {
        ?>
    <div id="message" class="updated fade"><p><strong><?php 
        _e('设置已更新');
        ?>
</strong></p></div>
    <?php 
    }
    ?>
    <?php 
    if ($ms) {
        foreach ($ms as $m) {
            ?>
    <div id="message" class="updated fade"><p style="padding: .5em; color: #<?php 
            echo $messages[$m]['color'];
            ?>
; font-weight: bold;"><?php 
            echo $messages[$m]['text'];
            ?>
</p></div>
    <?php 
        }
    }
    ?>

    <h4><?php 
    _e('CLOUDFLARE WORDPRESS 插件:');
    ?>
</h4>
        <?php 
    //    <div class="narrow">
    ?>

CloudFlare 是一款专门为 WordPress 开发的插件,它的功能主要有:
<ol>
<li>还原访问者的原始 IP 地址</li>
<li>保护您的网站不受垃圾信息干扰</li>
</ol>

<h4>适用版本:</h4>

兼容 WordPress 2.8.6 至最新版。如果您正在使用的版本低于 2.8.6,将无法使用本插件,建议您升级到最新版本的 WordPress。

<h4>说明:</h4>

<ol>
<li>由于 CloudFlare 使用反向代理的方式导致访问者的真实 IP 地址变成了 CloudFlare 的 IP 地址,本插件能够获取网站访问者的原始 IP 地址。</li>
 
<li>如果您将某条评论标记为垃圾内容,那么这条评论内容将会发送到 CloudFlare,帮助您的网站得到更好的保护。</li>

<li>我们强烈推荐 CloudFlare 用户安装此插件。</li>

<li>注意:本插件与 Akismet 和 W3 Total Cache 兼容,您可以放心地使用它们。</li> 

</ol>

<h4>更多:</h4>

<a href="http://www.cloudflare.com/">CloudFlare 官方网站</a>

    <?php 
    if ($curl_installed) {
        $dev_mode = get_dev_mode_status($cloudflare_api_key, $cloudflare_api_email, THIS_DOMAIN);
        if (is_wp_error($dev_mode)) {
            $messages['get_dev_mode_failed'] = array('color' => 'aa0', 'text' => __('无法获取开发模式状态,出错信息: ' . $dev_mode->get_error_message()));
            $ms[] = 'get_dev_mode_failed';
        }
    }
    ?>

    <hr />

    <form action="" method="post" id="cloudflare-conf">
    <?php 
    wp_nonce_field('cloudflare-db-api', 'cloudflare-db-api-nonce');
    ?>
    <?php 
    if (get_option('cloudflare_api_key') && get_option('cloudflare_api_email')) {
        ?>
    <?php 
    } else {
        ?>
 
        <p><?php 
        printf(__('输入您的 API Key,获取 API Key 请登陆 <a href="%1$s">CloudFlare</a> 后进入 \'Account\'.'), 'https://www.cloudflare.com/my-account.html');
        ?>
</p>
    <?php 
    }
    ?>
    <h3><label for="key"><?php 
    _e('CloudFlare API Key');
    ?>
</label></h3>
    <p>
    	<input id="key" name="key" type="text" size="50" maxlength="48" value="<?php 
    echo get_option('cloudflare_api_key');
    ?>
" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /> (<?php 
    _e('<a href="https://www.cloudflare.com/my-account.html">获取 API Key</a>');
    ?>
)
    </p>
    <?php 
    if (isset($key_message)) {
        echo sprintf('<p>%s</p>', $key_message);
    }
    ?>
    
    <h3><label for="email"><?php 
    _e('CloudFlare 账户邮箱');
    ?>
</label></h3>
    <p>
    	<input id="email" name="email" type="text" size="50" maxlength="48" value="<?php 
    echo get_option('cloudflare_api_email');
    ?>
" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /> (<?php 
    _e('<a href="https://www.cloudflare.com/my-account.html">获取邮箱地址</a>');
    ?>
)
    </p>
    <?php 
    if (isset($key_message)) {
        echo sprintf('<p>%s</p>', $key_message);
    }
    ?>
    
    <h3><label for="dev_mode"><?php 
    _e('开发模式');
    ?>
</label> <span style="font-size:9pt;">(<a href="https://support.cloudflare.com/entries/22280726-what-does-cloudflare-development-mode-mean" " target="_blank">这是什么?</a>)</span></h3>

    <?php 
    if ($curl_installed) {
        ?>
    <div style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;">
    <input type="radio" name="dev_mode" value="0" <?php 
        if ($dev_mode == "off") {
            echo "checked";
        }
        ?>
> 关闭
    <input type="radio" name="dev_mode" value="1" <?php 
        if ($dev_mode == "on") {
            echo "checked";
        }
        ?>
> 开启
    </div>
    <?php 
    } else {
        ?>
    抱歉,CloudFlare 检测到您的服务器未安装 cURL 模块,无法切换到“开发模式”,请联系空间服务商或自行安装该模块。
    <?php 
    }
    ?>
    
    </p>
    <p class="submit"><input type="submit" name="submit" value="<?php 
    _e('保存设置 &raquo;');
    ?>
" /></p>
    </form>

        <?php 
    //    </div>
    ?>
    </div>
    <?php 
}