function pre_http_request($pre, $args, $url)
 {
     $this->args = wp_parse_args($args, array('authentication' => NULL, 'username' => NULL, 'password' => NULL));
     // Ruh roh...
     if (!is_null($this->args['authentication'])) {
         switch ($this->args['authentication']) {
             case '-':
                 // No HTTP Auth method. Remove this stuff.
                 $this->args['authentication'] = NULL;
                 $this->args['username'] = NULL;
                 $this->args['password'] = NULL;
                 break;
             case 'basic':
                 if ($this->have_curl($args, $url)) {
                     // Don't need to do anything. http_api_curl hook takes care
                     // of it.
                     break;
                 } elseif ($this->have_streams($args, $url)) {
                     // curl has a nice native way to jam in the username and
                     // passwd but streams and fsockopen do not. So we have to
                     // make a recursive call with the credentials in the URL.
                     // Wee ha!
                     $method = $this->args['authentication'];
                     $credentials = $this->args['username'];
                     if (!is_null($this->args['password'])) {
                         $credentials .= ':' . $args['password'];
                     }
                     // Remove these so we don't recurse all the way down
                     unset($this->args['authentication']);
                     unset($this->args['username']);
                     unset($this->args['password']);
                     $url = preg_replace('!(https?://)!', '$1' . $credentials . '@', $url);
                     // Subsidiary request
                     $pre = wp_remote_request($url, $this->args);
                     break;
                 }
             case 'digest':
                 if ($this->have_curl($args, $url)) {
                     // Don't need to do anything. http_api_curl hook takes care
                     // of it.
                     break;
                 }
             default:
                 if (is_callable('WP_Http', '_get_first_available_transport')) {
                     $trans = WP_Http::_get_first_available_transport($args, $url);
                     if (!$trans) {
                         $trans = WP_Http::_get_first_available_transport(array(), $url);
                     }
                 } elseif (is_callable('WP_Http', '_getTransport')) {
                     $transports = WP_Http::_getTransport($args);
                     $trans = get_class(reset($transports));
                 } else {
                     $trans = 'HTTP';
                 }
                 $pre = new WP_Error('http_request_failed', sprintf(__('%s cannot use %s authentication with the %s transport.'), __CLASS__, $args['authentication'], $trans));
         }
     }
     return $pre;
 }
예제 #2
0
 /**
  * Ajax: Return blog info
  */
 public function tm_aj_get_bloginfo($data_args)
 {
     try {
         $http_api_transports = apply_filters('http_api_transports', array('curl', 'streams'), array(), $this->api);
         $http = new WP_Http();
         $vars = array("name" => get_bloginfo("name"), "description" => get_bloginfo("description"), "wpurl" => get_bloginfo("wpurl"), "url" => get_bloginfo("url"), "version" => get_bloginfo("version"), "language" => get_bloginfo("language"), "pingback_url" => get_bloginfo("pingback_url"), "rss2_url" => get_bloginfo("rss2_url"), "timezone_string" => get_option("timezone_string"), "gmt_offset" => get_option("gmt_offset"), "plugin_version" => $this->version, "plugin_build" => $this->build, "is_wp_vip" => $this->is_wp_vip, "charset" => get_bloginfo('charset'), "first_transport" => $http->_get_first_available_transport($this->api), "all_transports" => implode(',', $http_api_transports), "is_multisite" => is_multisite(), "base64_decode_disabled" => $this->base64_decode_disabled, "php_disabled_fn" => ini_get('disable_functions'), "php_disabled_cl" => ini_get('disable_classes'));
         if (isset($_GET['tm_debug']) || isset($data_args['tm_debug'])) {
             $vars["debug"] = array();
             $vars["debug"]["server_time"] = time();
             $vars["debug"]["server_date"] = date('c');
             $vars["debug"]["site_url"] = get_option('siteurl');
             $vars["debug"]["php_version"] = phpversion();
             $theme = wp_get_theme();
             $vars["debug"]["theme"] = array();
             $vars["debug"]["theme"]["Name"] = $theme->get('Name');
             $vars["debug"]["theme"]["ThemeURI"] = $theme->get('ThemeURI');
             $vars["debug"]["theme"]["Description"] = $theme->get('Description');
             $vars["debug"]["theme"]["Author"] = $theme->get('Author');
             $vars["debug"]["theme"]["AuthorURI"] = $theme->get('AuthorURI');
             $vars["debug"]["theme"]["Version"] = $theme->get('Version');
             $vars["debug"]["theme"]["Template"] = $theme->get('Template');
             $vars["debug"]["theme"]["Status"] = $theme->get('Status');
             $vars["debug"]["theme"]["Tags"] = $theme->get('Tags');
             $vars["debug"]["theme"]["TextDomain"] = $theme->get('TextDomain');
             $vars["debug"]["theme"]["DomainPath"] = $theme->get('DomainPath');
             $vars["debug"]["plugins"] = $this->get_installed_plugins();
         }
         $this->respond_json_and_die($this->array_decode_entities($vars));
     } catch (Exception $e) {
         $this->respond_exception_and_die($e);
     }
 }
예제 #3
0
function wpgform_curl_transport_missing_notice()
{
    $wpgform_options = wpgform_get_plugin_options();
    //  Skip check if disabled in settings
    if ($wpgform_options['curl_transport_missing_message']) {
        return;
    }
    //  Test for cURL transport
    $t = new WP_Http();
    if (strtolower($t->_get_first_available_transport('')) != 'wp_http_curl') {
        ?>
<div class="update-nag">
<?php 
        _e('The <a href="http://codex.wordpress.org/HTTP_API">WordPress HTTP API</a> cURL transport was not detected.  The Google Forms plugin may not operate correctly.', WPGFORM_I18N_DOMAIN);
        ?>
<br />
<small>
<?php 
        printf(__('This notification may be hidden via a setting on the <a href="%s">Google Forms settings page</a>.', WPGFORM_I18N_DOMAIN), admin_url('options-general.php?page=wpgform-options.php'));
        ?>
</small>
</div>
<?php 
    }
    unset($t);
}
예제 #4
0
        /**
         * Print and request user for Google in profile. Token link present
         * uses if settings in user level
         * run by action 'show_user_profile' from user-edit.php
         *
         * @param object $user
         */
        function user_profile($user)
        {
            if (!current_user_can('picasa_dialog')) {
                return;
            }
            if ($this->options['pe2_level'] != 'user') {
                return;
            }
            $user_id = $user->ID;
            if (isset($_GET['revoke'])) {
                $response = $this->get_feed("https://www.google.com/accounts/AuthSubRevokeToken");
                if (is_wp_error($response)) {
                    $message = __('Google returned error: ', 'pe2') . $response->get_error_message();
                } else {
                    $message = __('Private access revoked', 'pe2');
                }
                delete_user_meta($user_id, 'pe2_token');
                $this->options['pe2_token'] = '';
            }
            if (isset($_GET['message']) && $_GET['message']) {
                $message = esc_html(stripcslashes($_GET['message']));
            }
            if (!get_user_meta($user_id, 'pe2_user_name', true) && current_user_can('manage_options')) {
                update_user_meta($user_id, 'pe2_user_name', $this->options['pe2_user_name']);
                if ($this->options['pe2_token']) {
                    update_user_meta($user_id, 'pe2_token', $this->options['pe2_token']);
                }
            }
            ?>
				<h3><?php 
            _e('Google+ Express access', 'pe2');
            ?>
</h3>

				<?php 
            if ($message) {
                echo '<div id="picasa-express-x2-message" class="updated"><p><strong>' . $message . '</strong></p></div>';
            }
            ?>

				<table class="form-table">
					<?php 
            $user = get_user_meta($user_id, 'pe2_user_name', true);
            $result = 'ok';
            $feed_url = "http://picasaweb.google.com/data/feed/base/user/{$user}?alt=rss&kind=album&hl=en_US";
            $response = $this->get_feed($feed_url);
            if (is_wp_error($response)) {
                $result = 'error: ' . $response->get_error_message();
            } else {
                if (!$this->get_item($response, 'atom:id')) {
                    $result = 'error: wrong answer';
                }
            }
            if (method_exists('WP_Http', '_getTransport')) {
                $ta = array();
                $transports = WP_Http::_getTransport(array());
                foreach ($transports as $t) {
                    $ta[] = strtolower(str_replace('WP_Http_', '', get_class($t)));
                }
                if ($ta) {
                    $result = sprintf(__("Checking user: %s - Transport: %s - <a href=\"%s\" target=\"_blank\">URL</a>", 'pe2'), $result, implode(',', $ta), $feed_url);
                }
            } else {
                if (method_exists('WP_Http', '_get_first_available_transport')) {
                    $transport = WP_Http::_get_first_available_transport(array());
                    if ($transport) {
                        $transport_name = strtolower(str_replace('WP_HTTP_', '', $transport));
                        $result = sprintf(' ' . __("Checking user: %s - Transport: %s - <a href=\"%s\" target=\"_blank\">URL</a>", 'pe2'), $result, $transport_name, $feed_url);
                    }
                } else {
                    $result = '';
                }
            }
            $this->make_settings_row(__('Google user name', 'pe2'), '<input type="text" class="regular-text" name="pe2_user_name" value="' . esc_attr($user) . '" />' . $result . (!get_user_meta($user_id, 'pe2_token', true) ? '<br /><a href="https://www.google.com/accounts/AuthSubRequest?next=' . urlencode($this->google_authorize_plugin_URL . '?authorize&user='******'&scope=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2F&session=1&secure=0">' . __('Requesting access to private albums', 'pe2') . '</a>' : '<br/><a href="?revoke=true">' . __('Revoke access to private albums', 'pe2') . '</a>'), get_user_meta($user_id, 'pe2_token', true) ? __('You already received the access to private albums', 'pe2') : __('By this link you will be redirected to the Google authorization page. Please, use same name as above to login before accept.', 'pe2'));
            $option = get_user_meta($user_id, 'pe2_save_state', true);
            $this->make_settings_row(__('Save last state', 'pe2'), '<label><input type="checkbox" name="pe2_save_state" value="1" ' . checked($option, '1', false) . ' /> ' . __('Save last state in dialog', 'pe2') . '</label> ', __('Save user when changes, album if you insert images or albums list if you shorcode for album', 'pe2'));
            ?>
				</table>
			<?php 
        }